@devtable/dashboard 13.23.2 → 13.23.3
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/dashboard.es.js +1748 -1739
- package/dist/dashboard.umd.js +27 -27
- package/dist/i18n/en.d.ts +2 -2
- package/dist/i18n/zh.d.ts +2 -2
- package/dist/stats.html +1 -1
- package/dist/version.json +2 -2
- package/package.json +1 -1
package/dist/dashboard.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(w,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react"),require("@mantine/core"),require("@mantine/modals"),require("ahooks"),require("mobx"),require("mobx-react-lite"),require("@faker-js/faker"),require("crypto-js"),require("d3-array"),require("dayjs"),require("lodash"),require("mathjs"),require("numbro"),require("popmotion"),require("axios"),require("@mantine/hooks"),require("@tabler/icons-react"),require("react-i18next"),require("@mantine/tiptap"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-placeholder"),require("@tiptap/extension-subscript"),require("@tiptap/extension-superscript"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-table"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-table-row"),require("@tiptap/extension-underline"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("prosemirror-keymap"),require("prosemirror-commands"),require("prosemirror-schema-list"),require("@monaco-editor/react"),require("echarts/core"),require("echarts/charts"),require("echarts/components"),require("echarts/renderers"),require("constrained-editor-plugin"),require("js-base64"),require("eventemitter2"),require("chroma-js"),require("echarts-for-react/lib/core"),require("echarts-gl"),require("react-hook-form"),require("@mantine/dates"),require("tabler-icons-react"),require("@mantine/notifications"),require("@dnd-kit/react"),require("react-dom"),require("d3-regression"),require("@dnd-kit/helpers"),require("uuid"),require("@mantine/prism"),require("@tanstack/react-table"),require("react-virtual"),require("rc-select"),require("rc-tree-select"),require("react-grid-layout"),require("mobx-state-tree"),require("performant-array-to-tree"),require("file-saver"),require("dom-to-image-more"),require("jszip"),require("@json2csv/whatwg"),require("dayjs/plugin/advancedFormat"),require("dayjs/plugin/arraySupport"),require("dayjs/plugin/buddhistEra"),require("dayjs/plugin/calendar"),require("dayjs/plugin/customParseFormat"),require("dayjs/plugin/dayOfYear"),require("dayjs/plugin/duration"),require("dayjs/plugin/isBetween"),require("dayjs/plugin/isLeapYear"),require("dayjs/plugin/isMoment"),require("dayjs/plugin/isoWeek"),require("dayjs/plugin/isoWeeksInYear"),require("dayjs/plugin/isSameOrAfter"),require("dayjs/plugin/isSameOrBefore"),require("dayjs/plugin/isToday"),require("dayjs/plugin/isTomorrow"),require("dayjs/plugin/isYesterday"),require("dayjs/plugin/localeData"),require("dayjs/plugin/localizedFormat"),require("dayjs/plugin/minMax"),require("dayjs/plugin/objectSupport"),require("dayjs/plugin/pluralGetSet"),require("dayjs/plugin/preParsePostFormat"),require("dayjs/plugin/quarterOfYear"),require("dayjs/plugin/relativeTime"),require("dayjs/plugin/timezone"),require("dayjs/plugin/toArray"),require("dayjs/plugin/toObject"),require("dayjs/plugin/updateLocale"),require("dayjs/plugin/utc"),require("dayjs/plugin/weekday"),require("dayjs/plugin/weekOfYear"),require("dayjs/plugin/weekYear"),require("i18next"),require("i18next-browser-languagedetector"),require("intl-pluralrules"),require("reactflow")):typeof define=="function"&&define.amd?define(["exports","react","@mantine/core","@mantine/modals","ahooks","mobx","mobx-react-lite","@faker-js/faker","crypto-js","d3-array","dayjs","lodash","mathjs","numbro","popmotion","axios","@mantine/hooks","@tabler/icons-react","react-i18next","@mantine/tiptap","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-placeholder","@tiptap/extension-subscript","@tiptap/extension-superscript","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-table","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-table-row","@tiptap/extension-underline","@tiptap/react","@tiptap/starter-kit","prosemirror-keymap","prosemirror-commands","prosemirror-schema-list","@monaco-editor/react","echarts/core","echarts/charts","echarts/components","echarts/renderers","constrained-editor-plugin","js-base64","eventemitter2","chroma-js","echarts-for-react/lib/core","echarts-gl","react-hook-form","@mantine/dates","tabler-icons-react","@mantine/notifications","@dnd-kit/react","react-dom","d3-regression","@dnd-kit/helpers","uuid","@mantine/prism","@tanstack/react-table","react-virtual","rc-select","rc-tree-select","react-grid-layout","mobx-state-tree","performant-array-to-tree","file-saver","dom-to-image-more","jszip","@json2csv/whatwg","dayjs/plugin/advancedFormat","dayjs/plugin/arraySupport","dayjs/plugin/buddhistEra","dayjs/plugin/calendar","dayjs/plugin/customParseFormat","dayjs/plugin/dayOfYear","dayjs/plugin/duration","dayjs/plugin/isBetween","dayjs/plugin/isLeapYear","dayjs/plugin/isMoment","dayjs/plugin/isoWeek","dayjs/plugin/isoWeeksInYear","dayjs/plugin/isSameOrAfter","dayjs/plugin/isSameOrBefore","dayjs/plugin/isToday","dayjs/plugin/isTomorrow","dayjs/plugin/isYesterday","dayjs/plugin/localeData","dayjs/plugin/localizedFormat","dayjs/plugin/minMax","dayjs/plugin/objectSupport","dayjs/plugin/pluralGetSet","dayjs/plugin/preParsePostFormat","dayjs/plugin/quarterOfYear","dayjs/plugin/relativeTime","dayjs/plugin/timezone","dayjs/plugin/toArray","dayjs/plugin/toObject","dayjs/plugin/updateLocale","dayjs/plugin/utc","dayjs/plugin/weekday","dayjs/plugin/weekOfYear","dayjs/plugin/weekYear","i18next","i18next-browser-languagedetector","intl-pluralrules","reactflow"],g):(w=typeof globalThis<"u"?globalThis:w||self,g(w.dashboard={},w.react,w["@mantine/core"],w["@mantine/modals"],w.ahooks,w.mobx,w["mobx-react-lite"],w["@faker-js/faker"],w.CryptoJS,w["d3-array"],w.dayjs,w._,w.mathjs,w.numbro,w.popmotion,w.axios,w["@mantine/hooks"],w["@tabler/icons-react"],w["react-i18next"],w["@mantine/tiptap"],w["@tiptap/extension-color"],w["@tiptap/extension-highlight"],w["@tiptap/extension-placeholder"],w["@tiptap/extension-subscript"],w["@tiptap/extension-superscript"],w["@tiptap/extension-text-align"],w["@tiptap/extension-text-style"],w["@tiptap/extension-table"],w["@tiptap/extension-table-cell"],w["@tiptap/extension-table-header"],w["@tiptap/extension-table-row"],w["@tiptap/extension-underline"],w["@tiptap/react"],w["@tiptap/starter-kit"],w["prosemirror-keymap"],w["prosemirror-commands"],w["prosemirror-schema-list"],w["@monaco-editor/react"],w["echarts/core"],w["echarts/charts"],w["echarts/components"],w["echarts/renderers"],w["constrained-editor-plugin"],w["js-base64"],w.eventemitter2,w["chroma-js"],w["echarts-for-react/lib/core"],w["echarts-gl"],w["react-hook-form"],w["@mantine/dates"],w["tabler-icons-react"],w["@mantine/notifications"],w["@dnd-kit/react"],w["react-dom"],w["d3-regression"],w["@dnd-kit/helpers"],w.uuid,w["@mantine/prism"],w["@tanstack/react-table"],w["react-virtual"],w["rc-select"],w["rc-tree-select"],w["react-grid-layout"],w["mobx-state-tree"],w["performant-array-to-tree"],w["file-saver"],w["dom-to-image-more"],w.jszip,w["@json2csv/whatwg"],w["dayjs/plugin/advancedFormat"],w["dayjs/plugin/arraySupport"],w["dayjs/plugin/buddhistEra"],w["dayjs/plugin/calendar"],w["dayjs/plugin/customParseFormat"],w["dayjs/plugin/dayOfYear"],w["dayjs/plugin/duration"],w["dayjs/plugin/isBetween"],w["dayjs/plugin/isLeapYear"],w["dayjs/plugin/isMoment"],w["dayjs/plugin/isoWeek"],w["dayjs/plugin/isoWeeksInYear"],w["dayjs/plugin/isSameOrAfter"],w["dayjs/plugin/isSameOrBefore"],w["dayjs/plugin/isToday"],w["dayjs/plugin/isTomorrow"],w["dayjs/plugin/isYesterday"],w["dayjs/plugin/localeData"],w["dayjs/plugin/localizedFormat"],w["dayjs/plugin/minMax"],w["dayjs/plugin/objectSupport"],w["dayjs/plugin/pluralGetSet"],w["dayjs/plugin/preParsePostFormat"],w["dayjs/plugin/quarterOfYear"],w["dayjs/plugin/relativeTime"],w["dayjs/plugin/timezone"],w["dayjs/plugin/toArray"],w["dayjs/plugin/toObject"],w["dayjs/plugin/updateLocale"],w["dayjs/plugin/utc"],w["dayjs/plugin/weekday"],w["dayjs/plugin/weekOfYear"],w["dayjs/plugin/weekYear"],w.i18next,w["i18next-browser-languagedetector"],w["intl-pluralrules"],w.reactflow))})(this,function(w,g,o,lt,W,X,D,kg,Ql,ur,P,v,Tg,Zr,nn,At,he,M,_,Q,Ul,Yl,Kl,Xl,Jl,Zl,Hl,ec,tc,nc,rc,sc,ic,ac,
|
|
1
|
+
(function(w,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react"),require("@mantine/core"),require("@mantine/modals"),require("ahooks"),require("mobx"),require("mobx-react-lite"),require("@faker-js/faker"),require("crypto-js"),require("d3-array"),require("dayjs"),require("lodash"),require("mathjs"),require("numbro"),require("popmotion"),require("axios"),require("@mantine/hooks"),require("@tabler/icons-react"),require("react-i18next"),require("@mantine/tiptap"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-placeholder"),require("@tiptap/extension-subscript"),require("@tiptap/extension-superscript"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-table"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-table-row"),require("@tiptap/extension-underline"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("prosemirror-keymap"),require("prosemirror-commands"),require("prosemirror-schema-list"),require("@monaco-editor/react"),require("echarts/core"),require("echarts/charts"),require("echarts/components"),require("echarts/renderers"),require("constrained-editor-plugin"),require("js-base64"),require("eventemitter2"),require("chroma-js"),require("echarts-for-react/lib/core"),require("echarts-gl"),require("react-hook-form"),require("@mantine/dates"),require("tabler-icons-react"),require("@mantine/notifications"),require("@dnd-kit/react"),require("react-dom"),require("d3-regression"),require("@dnd-kit/helpers"),require("uuid"),require("@mantine/prism"),require("@tanstack/react-table"),require("react-virtual"),require("rc-select"),require("rc-tree-select"),require("react-grid-layout"),require("mobx-state-tree"),require("performant-array-to-tree"),require("file-saver"),require("dom-to-image-more"),require("jszip"),require("@json2csv/whatwg"),require("dayjs/plugin/advancedFormat"),require("dayjs/plugin/arraySupport"),require("dayjs/plugin/buddhistEra"),require("dayjs/plugin/calendar"),require("dayjs/plugin/customParseFormat"),require("dayjs/plugin/dayOfYear"),require("dayjs/plugin/duration"),require("dayjs/plugin/isBetween"),require("dayjs/plugin/isLeapYear"),require("dayjs/plugin/isMoment"),require("dayjs/plugin/isoWeek"),require("dayjs/plugin/isoWeeksInYear"),require("dayjs/plugin/isSameOrAfter"),require("dayjs/plugin/isSameOrBefore"),require("dayjs/plugin/isToday"),require("dayjs/plugin/isTomorrow"),require("dayjs/plugin/isYesterday"),require("dayjs/plugin/localeData"),require("dayjs/plugin/localizedFormat"),require("dayjs/plugin/minMax"),require("dayjs/plugin/objectSupport"),require("dayjs/plugin/pluralGetSet"),require("dayjs/plugin/preParsePostFormat"),require("dayjs/plugin/quarterOfYear"),require("dayjs/plugin/relativeTime"),require("dayjs/plugin/timezone"),require("dayjs/plugin/toArray"),require("dayjs/plugin/toObject"),require("dayjs/plugin/updateLocale"),require("dayjs/plugin/utc"),require("dayjs/plugin/weekday"),require("dayjs/plugin/weekOfYear"),require("dayjs/plugin/weekYear"),require("i18next"),require("i18next-browser-languagedetector"),require("intl-pluralrules"),require("reactflow")):typeof define=="function"&&define.amd?define(["exports","react","@mantine/core","@mantine/modals","ahooks","mobx","mobx-react-lite","@faker-js/faker","crypto-js","d3-array","dayjs","lodash","mathjs","numbro","popmotion","axios","@mantine/hooks","@tabler/icons-react","react-i18next","@mantine/tiptap","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-placeholder","@tiptap/extension-subscript","@tiptap/extension-superscript","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-table","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-table-row","@tiptap/extension-underline","@tiptap/react","@tiptap/starter-kit","prosemirror-keymap","prosemirror-commands","prosemirror-schema-list","@monaco-editor/react","echarts/core","echarts/charts","echarts/components","echarts/renderers","constrained-editor-plugin","js-base64","eventemitter2","chroma-js","echarts-for-react/lib/core","echarts-gl","react-hook-form","@mantine/dates","tabler-icons-react","@mantine/notifications","@dnd-kit/react","react-dom","d3-regression","@dnd-kit/helpers","uuid","@mantine/prism","@tanstack/react-table","react-virtual","rc-select","rc-tree-select","react-grid-layout","mobx-state-tree","performant-array-to-tree","file-saver","dom-to-image-more","jszip","@json2csv/whatwg","dayjs/plugin/advancedFormat","dayjs/plugin/arraySupport","dayjs/plugin/buddhistEra","dayjs/plugin/calendar","dayjs/plugin/customParseFormat","dayjs/plugin/dayOfYear","dayjs/plugin/duration","dayjs/plugin/isBetween","dayjs/plugin/isLeapYear","dayjs/plugin/isMoment","dayjs/plugin/isoWeek","dayjs/plugin/isoWeeksInYear","dayjs/plugin/isSameOrAfter","dayjs/plugin/isSameOrBefore","dayjs/plugin/isToday","dayjs/plugin/isTomorrow","dayjs/plugin/isYesterday","dayjs/plugin/localeData","dayjs/plugin/localizedFormat","dayjs/plugin/minMax","dayjs/plugin/objectSupport","dayjs/plugin/pluralGetSet","dayjs/plugin/preParsePostFormat","dayjs/plugin/quarterOfYear","dayjs/plugin/relativeTime","dayjs/plugin/timezone","dayjs/plugin/toArray","dayjs/plugin/toObject","dayjs/plugin/updateLocale","dayjs/plugin/utc","dayjs/plugin/weekday","dayjs/plugin/weekOfYear","dayjs/plugin/weekYear","i18next","i18next-browser-languagedetector","intl-pluralrules","reactflow"],g):(w=typeof globalThis<"u"?globalThis:w||self,g(w.dashboard={},w.react,w["@mantine/core"],w["@mantine/modals"],w.ahooks,w.mobx,w["mobx-react-lite"],w["@faker-js/faker"],w.CryptoJS,w["d3-array"],w.dayjs,w._,w.mathjs,w.numbro,w.popmotion,w.axios,w["@mantine/hooks"],w["@tabler/icons-react"],w["react-i18next"],w["@mantine/tiptap"],w["@tiptap/extension-color"],w["@tiptap/extension-highlight"],w["@tiptap/extension-placeholder"],w["@tiptap/extension-subscript"],w["@tiptap/extension-superscript"],w["@tiptap/extension-text-align"],w["@tiptap/extension-text-style"],w["@tiptap/extension-table"],w["@tiptap/extension-table-cell"],w["@tiptap/extension-table-header"],w["@tiptap/extension-table-row"],w["@tiptap/extension-underline"],w["@tiptap/react"],w["@tiptap/starter-kit"],w["prosemirror-keymap"],w["prosemirror-commands"],w["prosemirror-schema-list"],w["@monaco-editor/react"],w["echarts/core"],w["echarts/charts"],w["echarts/components"],w["echarts/renderers"],w["constrained-editor-plugin"],w["js-base64"],w.eventemitter2,w["chroma-js"],w["echarts-for-react/lib/core"],w["echarts-gl"],w["react-hook-form"],w["@mantine/dates"],w["tabler-icons-react"],w["@mantine/notifications"],w["@dnd-kit/react"],w["react-dom"],w["d3-regression"],w["@dnd-kit/helpers"],w.uuid,w["@mantine/prism"],w["@tanstack/react-table"],w["react-virtual"],w["rc-select"],w["rc-tree-select"],w["react-grid-layout"],w["mobx-state-tree"],w["performant-array-to-tree"],w["file-saver"],w["dom-to-image-more"],w.jszip,w["@json2csv/whatwg"],w["dayjs/plugin/advancedFormat"],w["dayjs/plugin/arraySupport"],w["dayjs/plugin/buddhistEra"],w["dayjs/plugin/calendar"],w["dayjs/plugin/customParseFormat"],w["dayjs/plugin/dayOfYear"],w["dayjs/plugin/duration"],w["dayjs/plugin/isBetween"],w["dayjs/plugin/isLeapYear"],w["dayjs/plugin/isMoment"],w["dayjs/plugin/isoWeek"],w["dayjs/plugin/isoWeeksInYear"],w["dayjs/plugin/isSameOrAfter"],w["dayjs/plugin/isSameOrBefore"],w["dayjs/plugin/isToday"],w["dayjs/plugin/isTomorrow"],w["dayjs/plugin/isYesterday"],w["dayjs/plugin/localeData"],w["dayjs/plugin/localizedFormat"],w["dayjs/plugin/minMax"],w["dayjs/plugin/objectSupport"],w["dayjs/plugin/pluralGetSet"],w["dayjs/plugin/preParsePostFormat"],w["dayjs/plugin/quarterOfYear"],w["dayjs/plugin/relativeTime"],w["dayjs/plugin/timezone"],w["dayjs/plugin/toArray"],w["dayjs/plugin/toObject"],w["dayjs/plugin/updateLocale"],w["dayjs/plugin/utc"],w["dayjs/plugin/weekday"],w["dayjs/plugin/weekOfYear"],w["dayjs/plugin/weekYear"],w.i18next,w["i18next-browser-languagedetector"],w["intl-pluralrules"],w.reactflow))})(this,function(w,g,o,lt,W,X,D,kg,Ql,ur,P,v,Tg,Zr,nn,At,he,M,_,Q,Ul,Yl,Kl,Xl,Jl,Zl,Hl,ec,tc,nc,rc,sc,ic,ac,AO,De,_i,et,oc,Pt,rn,Dg,Mg,lc,cc,Qt,Pe,PO,b,uc,V,sn,Hr,zg,Ig,Eg,Ut,an,bt,Ag,dc,pc,es,x,Pg,ts,hc,fc,Og,Lg,Bg,qg,Vg,Ng,$g,Fg,Gg,Wg,Rg,Qg,Ug,Yg,Kg,Xg,Jg,Zg,Hg,em,tm,nm,rm,sm,im,am,om,lm,cm,um,dm,pm,hm,fm,gm,mm,OO,Ee){"use strict";var IO=Object.defineProperty;var EO=(w,g,o)=>g in w?IO(w,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):w[g]=o;var B=(w,g,o)=>(EO(w,typeof g!="symbol"?g+"":g,o),o);function On(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const xm=On(Ql),ym=On(ur),Ln=On(Tg),bm=On(nn),Ae=On(oc),on=On(Ig);var ji={exports:{}},dr={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
`+ue+C}}var ot=!1,Wt;{var vn=typeof WeakMap=="function"?WeakMap:Map;Wt=new vn}function It(C,A){if(!C||ot)return"";{var L=Wt.get(C);if(L!==void 0)return L}var G;ot=!0;var ee=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var oe;oe=ae.current,ae.current=null,or();try{if(A){var J=function(){throw Error()};if(Object.defineProperty(J.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(J,[])}catch(tn){G=tn}Reflect.construct(C,[],J)}else{try{J.call()}catch(tn){G=tn}C.call(J.prototype)}}else{try{throw Error()}catch(tn){G=tn}C()}}catch(tn){if(tn&&G&&typeof tn.stack=="string"){for(var K=tn.stack.split(`
|
|
19
19
|
`),We=G.stack.split(`
|
|
20
20
|
`),ve=K.length-1,we=We.length-1;ve>=1&&we>=0&&K[ve]!==We[we];)we--;for(;ve>=1&&we>=0;ve--,we--)if(K[ve]!==We[we]){if(ve!==1||we!==1)do if(ve--,we--,we<0||K[ve]!==We[we]){var yt=`
|
|
21
|
-
`+K[ve].replace(" at new "," at ");return C.displayName&&yt.includes("<anonymous>")&&(yt=yt.replace("<anonymous>",C.displayName)),typeof C=="function"&&Wt.set(C,yt),yt}while(ve>=1&&we>=0);break}}}finally{ot=!1,ae.current=oe,Bl(),Error.prepareStackTrace=ee}var cr=C?C.displayName||C.name:"",Sg=cr?be(cr):"";return typeof C=="function"&&Wt.set(C,Sg),Sg}function Rt(C,A,L){return It(C,!1)}function Et(C){var A=C.prototype;return!!(A&&A.isReactComponent)}function xi(C,A,L){if(C==null)return"";if(typeof C=="function")return It(C,Et(C));if(typeof C=="string")return be(C);switch(C){case d:return be("Suspense");case p:return be("SuspenseList")}if(typeof C=="object")switch(C.$$typeof){case u:return Rt(C.render);case h:return xi(C.type,A,L);case f:{var G=C,ee=G._payload,oe=G._init;try{return xi(oe(ee),A,L)}catch{}}}return""}var yi=Object.prototype.hasOwnProperty,hg={},fg=S.ReactDebugCurrentFrame;function bi(C){if(C){var A=C._owner,L=xi(C.type,C._source,A?A.type:null);fg.setExtraStackFrame(L)}else fg.setExtraStackFrame(null)}function
|
|
21
|
+
`+K[ve].replace(" at new "," at ");return C.displayName&&yt.includes("<anonymous>")&&(yt=yt.replace("<anonymous>",C.displayName)),typeof C=="function"&&Wt.set(C,yt),yt}while(ve>=1&&we>=0);break}}}finally{ot=!1,ae.current=oe,Bl(),Error.prepareStackTrace=ee}var cr=C?C.displayName||C.name:"",Sg=cr?be(cr):"";return typeof C=="function"&&Wt.set(C,Sg),Sg}function Rt(C,A,L){return It(C,!1)}function Et(C){var A=C.prototype;return!!(A&&A.isReactComponent)}function xi(C,A,L){if(C==null)return"";if(typeof C=="function")return It(C,Et(C));if(typeof C=="string")return be(C);switch(C){case d:return be("Suspense");case p:return be("SuspenseList")}if(typeof C=="object")switch(C.$$typeof){case u:return Rt(C.render);case h:return xi(C.type,A,L);case f:{var G=C,ee=G._payload,oe=G._init;try{return xi(oe(ee),A,L)}catch{}}}return""}var yi=Object.prototype.hasOwnProperty,hg={},fg=S.ReactDebugCurrentFrame;function bi(C){if(C){var A=C._owner,L=xi(C.type,C._source,A?A.type:null);fg.setExtraStackFrame(L)}else fg.setExtraStackFrame(null)}function dO(C,A,L,G,ee){{var oe=Function.call.bind(yi);for(var J in C)if(oe(C,J)){var K=void 0;try{if(typeof C[J]!="function"){var We=Error((G||"React class")+": "+L+" type `"+J+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof C[J]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw We.name="Invariant Violation",We}K=C[J](A,J,G,L,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ve){K=ve}K&&!(K instanceof Error)&&(bi(ee),T("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",G||"React class",L,J,typeof K),bi(null)),K instanceof Error&&!(K.message in hg)&&(hg[K.message]=!0,bi(ee),T("Failed %s type: %s",L,K.message),bi(null))}}}var pO=Array.isArray;function ql(C){return pO(C)}function hO(C){{var A=typeof Symbol=="function"&&Symbol.toStringTag,L=A&&C[Symbol.toStringTag]||C.constructor.name||"Object";return L}}function fO(C){try{return gg(C),!1}catch{return!0}}function gg(C){return""+C}function mg(C){if(fO(C))return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",hO(C)),gg(C)}var Jr=S.ReactCurrentOwner,gO={key:!0,ref:!0,__self:!0,__source:!0},xg,yg,Vl;Vl={};function mO(C){if(yi.call(C,"ref")){var A=Object.getOwnPropertyDescriptor(C,"ref").get;if(A&&A.isReactWarning)return!1}return C.ref!==void 0}function xO(C){if(yi.call(C,"key")){var A=Object.getOwnPropertyDescriptor(C,"key").get;if(A&&A.isReactWarning)return!1}return C.key!==void 0}function yO(C,A){if(typeof C.ref=="string"&&Jr.current&&A&&Jr.current.stateNode!==A){var L=Fe(Jr.current.type);Vl[L]||(T('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',Fe(Jr.current.type),C.ref),Vl[L]=!0)}}function bO(C,A){{var L=function(){xg||(xg=!0,T("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",A))};L.isReactWarning=!0,Object.defineProperty(C,"key",{get:L,configurable:!0})}}function vO(C,A){{var L=function(){yg||(yg=!0,T("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",A))};L.isReactWarning=!0,Object.defineProperty(C,"ref",{get:L,configurable:!0})}}var _O=function(C,A,L,G,ee,oe,J){var K={$$typeof:t,type:C,key:A,ref:L,props:J,_owner:oe};return K._store={},Object.defineProperty(K._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(K,"_self",{configurable:!1,enumerable:!1,writable:!1,value:G}),Object.defineProperty(K,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ee}),Object.freeze&&(Object.freeze(K.props),Object.freeze(K)),K};function jO(C,A,L,G,ee){{var oe,J={},K=null,We=null;L!==void 0&&(mg(L),K=""+L),xO(A)&&(mg(A.key),K=""+A.key),mO(A)&&(We=A.ref,yO(A,ee));for(oe in A)yi.call(A,oe)&&!gO.hasOwnProperty(oe)&&(J[oe]=A[oe]);if(C&&C.defaultProps){var ve=C.defaultProps;for(oe in ve)J[oe]===void 0&&(J[oe]=ve[oe])}if(K||We){var we=typeof C=="function"?C.displayName||C.name||"Unknown":C;K&&bO(J,we),We&&vO(J,we)}return _O(C,K,We,ee,G,Jr.current,J)}}var Nl=S.ReactCurrentOwner,bg=S.ReactDebugCurrentFrame;function lr(C){if(C){var A=C._owner,L=xi(C.type,C._source,A?A.type:null);bg.setExtraStackFrame(L)}else bg.setExtraStackFrame(null)}var $l;$l=!1;function Fl(C){return typeof C=="object"&&C!==null&&C.$$typeof===t}function vg(){{if(Nl.current){var C=Fe(Nl.current.type);if(C)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+C+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+C+"`."}return""}}function wO(C){{if(C!==void 0){var A=C.fileName.replace(/^.*[\\\/]/,""),L=C.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+A+":"+L+"."}return""}}var _g={};function
|
|
25
|
+
Check your code at `+A+":"+L+"."}return""}}var _g={};function CO(C){{var A=vg();if(!A){var L=typeof C=="string"?C:C.displayName||C.name;L&&(A=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(!C._store||C._store.validated||C.key!=null)return;C._store.validated=!0;var L=
|
|
27
|
+
Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(!C._store||C._store.validated||C.key!=null)return;C._store.validated=!0;var L=CO(A);if(_g[L])return;_g[L]=!0;var G="";C&&C._owner&&C._owner!==Nl.current&&(G=" It was passed a child from "+Fe(C._owner.type)+"."),lr(C),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',L,G),lr(null)}}function wg(C,A){{if(typeof C!="object")return;if(ql(C))for(var L=0;L<C.length;L++){var G=C[L];Fl(G)&&jg(G,A)}else if(Fl(C))C._store&&(C._store.validated=!0);else if(C){var ee=k(C);if(typeof ee=="function"&&ee!==C.entries)for(var oe=ee.call(C),J;!(J=oe.next()).done;)Fl(J.value)&&jg(J.value,A)}}}function SO(C){{var A=C.type;if(A==null||typeof A=="string")return;var L;if(typeof A=="function")L=A.propTypes;else if(typeof A=="object"&&(A.$$typeof===u||A.$$typeof===h))L=A.propTypes;else return;if(L){var G=Fe(A);dO(L,C.props,"prop",G,C)}else if(A.PropTypes!==void 0&&!$l){$l=!0;var ee=Fe(A);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ee||"Unknown")}typeof A.getDefaultProps=="function"&&!A.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function kO(C){{for(var A=Object.keys(C.props),L=0;L<A.length;L++){var G=A[L];if(G!=="children"&&G!=="key"){lr(C),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",G),lr(null);break}}C.ref!==null&&(lr(C),T("Invalid attribute `ref` supplied to `React.Fragment`."),lr(null))}}function Cg(C,A,L,G,ee,oe){{var J=Ie(C);if(!J){var K="";(C===void 0||typeof C=="object"&&C!==null&&Object.keys(C).length===0)&&(K+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var We=wO(ee);We?K+=We:K+=vg();var ve;C===null?ve="null":ql(C)?ve="array":C!==void 0&&C.$$typeof===t?(ve="<"+(Fe(C.type)||"Unknown")+" />",K=" Did you accidentally export a JSX literal instead of a component?"):ve=typeof C,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ve,K)}var we=jO(C,A,L,ee,oe);if(we==null)return we;if(J){var yt=A.children;if(yt!==void 0)if(G)if(ql(yt)){for(var cr=0;cr<yt.length;cr++)wg(yt[cr],C);Object.freeze&&Object.freeze(yt)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else wg(yt,C)}return C===s?kO(we):SO(we),we}}function TO(C,A,L){return Cg(C,A,L,!0)}function DO(C,A,L){return Cg(C,A,L,!1)}var MO=DO,zO=TO;pr.Fragment=s,pr.jsx=MO,pr.jsxs=zO}()),pr}process.env.NODE_ENV==="production"?ji.exports=vm():ji.exports=_m();var r=ji.exports;const vt={CryptoJS:Ql,d3Array:ym,dayjs:P,lodash:v,numbro:Zr,mathjs:Ln,faker:kg.faker,popmotion:bm},jm=[{name:"CryptoJS",url:"https://github.com/brix/crypto-js",version:"4.1.1"},{name:"d3Array",url:"https://github.com/d3/d3-array",version:"3.2.0"},{name:"dayjs",url:"https://day.js.org/",version:"1.11.6"},{name:"lodash",url:"https://lodash.com/docs/4.17.15",version:"4.17.21"},{name:"mathjs",url:"https://mathjs.org/",version:"11.7.0"},{name:"numbro",url:"https://numbrojs.com/",version:"2.3.6"},{name:"faker",url:"https://fakerjs.dev/",version:"7.6.0"},{name:"popmotion",url:"https://popmotion.io/",version:"11.0.3"}],wm=e=>`
|
|
28
28
|
<tr>
|
|
29
29
|
<td><code>${e.name}</code></td>
|
|
30
30
|
<td>
|
|
@@ -56,7 +56,7 @@ Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(
|
|
|
56
56
|
`):n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let i=s.content[s.content.length-1],a=t.previousSibling;(!i||a&&a.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n)),this.findInText(t)}else this.findInside(t)}addElement(t,n){let s=t.nodeName.toLowerCase(),i;Tc.hasOwnProperty(s)&&this.parser.normalizeLists&&Nm(t);let a=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,n));if(a?a.ignore:Vm.hasOwnProperty(s))this.findInside(t),this.ignoreFallback(t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(t=a.skip);let l,c=this.top,u=this.needsBlock;if(kc.hasOwnProperty(s))c.content.length&&c.content[0].isInline&&this.open&&(this.open--,c=this.top),l=!0,c.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t);return}this.addAll(t),l&&this.sync(c),this.needsBlock=u}else this.addElementByRule(t,a,a.consuming===!1?i:void 0)}leafFallback(t){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
|
|
57
57
|
`))}ignoreFallback(t){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(t){let n=Lt.none,s=Lt.none;for(let i=0;i<t.length;i+=2)for(let a=void 0;;){let l=this.parser.matchStyle(t[i],t[i+1],this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(c=>{l.clearMark(c)&&(s=c.addToSet(s))}):n=this.parser.schema.marks[l.mark].create(l.attrs).addToSet(n),l.consuming===!1)a=l;else break}return[n,s]}addElementByRule(t,n,s){let i,a,l;n.node?(a=this.parser.schema.nodes[n.node],a.isLeaf?this.insertNode(a.create(n.attrs))||this.leafFallback(t):i=this.enter(a,n.attrs||null,n.preserveWhitespace)):(l=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(l));let c=this.top;if(a&&a.isLeaf)this.findInside(t);else if(s)this.addElement(t,s);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(u=>this.insertNode(u));else{let u=t;typeof n.contentElement=="string"?u=t.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(t):n.contentElement&&(u=n.contentElement),this.findAround(t,u,!0),this.addAll(u)}i&&this.sync(c)&&this.open--,l&&this.removePendingMark(l,c)}addAll(t,n,s){let i=n||0;for(let a=n?t.childNodes[n]:t.firstChild,l=s==null?null:t.childNodes[s];a!=l;a=a.nextSibling,++i)this.findAtPoint(t,i),this.addDOM(a);this.findAtPoint(t,i)}findPlace(t){let n,s;for(let i=this.open;i>=0;i--){let a=this.nodes[i],l=a.findWrapping(t);if(l&&(!n||n.length>l.length)&&(n=l,s=a,!l.length)||a.solid)break}if(!n)return!1;this.sync(s);for(let i=0;i<n.length;i++)this.enterInner(n[i],null,!1);return!0}insertNode(t){if(t.isInline&&this.needsBlock&&!this.top.type){let n=this.textblockFromContext();n&&this.enterInner(n)}if(this.findPlace(t)){this.closeExtra();let n=this.top;n.applyPending(t.type),n.match&&(n.match=n.match.matchType(t.type));let s=n.activeMarks;for(let i=0;i<t.marks.length;i++)(!n.type||n.type.allowsMarkType(t.marks[i].type))&&(s=t.marks[i].addToSet(s));return n.content.push(t.mark(s)),!0}return!1}enter(t,n,s){let i=this.findPlace(t.create(n));return i&&this.enterInner(t,n,!0,s),i}enterInner(t,n=null,s=!1,i){this.closeExtra();let a=this.top;a.applyPending(t),a.match=a.match&&a.match.matchType(t);let l=Dc(t,i,a.options);a.options&hr&&a.content.length==0&&(l|=hr),this.nodes.push(new cs(t,n,a.activeMarks,a.pendingMarks,s,null,l)),this.open++}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let n=this.open;n>=0;n--)if(this.nodes[n]==t)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let s=this.nodes[n].content;for(let i=s.length-1;i>=0;i--)t+=s[i].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let s=0;s<this.find.length;s++)this.find[s].node==t&&this.find[s].offset==n&&(this.find[s].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,s){if(t!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&t.nodeType==1&&t.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(s?2:4)&&(this.find[i].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),s=this.options.context,i=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),a=-(s?s.depth+1:0)+(i?0:1),l=(c,u)=>{for(;c>=0;c--){let d=n[c];if(d==""){if(c==n.length-1||c==0)continue;for(;u>=a;u--)if(l(c-1,u))return!0;return!1}else{let p=u>0||u==0&&i?this.nodes[u].type:s&&u>=a?s.node(u-a).type:null;if(!p||p.name!=d&&p.groups.indexOf(d)==-1)return!1;u--}}return!0};return l(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let s=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let n in this.parser.schema.nodes){let s=this.parser.schema.nodes[n];if(s.isTextblock&&s.defaultAttrs)return s}}addPendingMark(t){let n=Wm(t,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,n){for(let s=this.open;s>=0;s--){let i=this.nodes[s];if(i.pendingMarks.lastIndexOf(t)>-1)i.pendingMarks=t.removeFromSet(i.pendingMarks);else{i.activeMarks=t.removeFromSet(i.activeMarks);let l=i.popFromStashMark(t);l&&i.type&&i.type.allowsMarkType(l.type)&&(i.activeMarks=l.addToSet(i.activeMarks))}if(i==n)break}}}function Nm(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let s=t.nodeType==1?t.nodeName.toLowerCase():null;s&&Tc.hasOwnProperty(s)&&n?(n.appendChild(t),t=n):s=="li"?n=t:s&&(n=null)}}function $m(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Fm(e){let t=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,s=[];for(;n=t.exec(e);)s.push(n[1],n[2].trim());return s}function zc(e){let t={};for(let n in e)t[n]=e[n];return t}function Gm(e,t){let n=t.schema.nodes;for(let s in n){let i=n[s];if(!i.allowsMarkType(e))continue;let a=[],l=c=>{a.push(c);for(let u=0;u<c.edgeCount;u++){let{type:d,next:p}=c.edge(u);if(d==t||a.indexOf(p)<0&&l(p))return!0}};if(l(i.contentMatch))return!0}}function Wm(e,t){for(let n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}const Ic=65535,Ec=Math.pow(2,16);function Rm(e,t){return e+t*Ec}function Ac(e){return e&Ic}function Qm(e){return(e-(e&Ic))/Ec}const Pc=1,Oc=2,us=4,Lc=8;class Bc{constructor(t,n,s){this.pos=t,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&Lc)>0}get deletedBefore(){return(this.delInfo&(Pc|us))>0}get deletedAfter(){return(this.delInfo&(Oc|us))>0}get deletedAcross(){return(this.delInfo&us)>0}}class ct{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&ct.empty)return ct.empty}recover(t){let n=0,s=Ac(t);if(!this.inverted)for(let i=0;i<s;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[s*3]+n+Qm(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,s){let i=0,a=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?i:0);if(u>t)break;let d=this.ranges[c+a],p=this.ranges[c+l],h=u+d;if(t<=h){let f=d?t==u?-1:t==h?1:n:n,m=u+i+(f<0?0:p);if(s)return m;let y=t==(n<0?u:h)?null:Rm(c/3,t-u),j=t==u?Oc:t==h?Pc:us;return(n<0?t!=u:t!=h)&&(j|=Lc),new Bc(m,j,y)}i+=p-d}return s?t+i:new Bc(t+i,0,null)}touches(t,n){let s=0,i=Ac(n),a=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?s:0);if(u>t)break;let d=this.ranges[c+a],p=u+d;if(t<=p&&c==i*3)return!0;s+=this.ranges[c+l]-d}return!1}forEach(t){let n=this.inverted?2:1,s=this.inverted?1:2;for(let i=0,a=0;i<this.ranges.length;i+=3){let l=this.ranges[i],c=l-(this.inverted?a:0),u=l+(this.inverted?0:a),d=this.ranges[i+n],p=this.ranges[i+s];t(c,c+d,u,u+p),a+=p-d}}invert(){return new ct(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?ct.empty:new ct(t<0?[0,-t,0]:[0,0,t])}}ct.empty=new ct([]);const zi=Object.create(null);class Re{getMap(){return ct.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=zi[n.stepType];if(!s)throw new RangeError(`No step type ${n.stepType} defined`);return s.fromJSON(t,n)}static jsonID(t,n){if(t in zi)throw new RangeError("Duplicate use of step JSON ID "+t);return zi[t]=n,n.prototype.jsonID=t,n}}class Ce{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new Ce(t,null)}static fail(t){return new Ce(null,t)}static fromReplace(t,n,s,i){try{return Ce.ok(t.replace(n,s,i))}catch(a){if(a instanceof Bm)return Ce.fail(a.message);throw a}}}function Ii(e,t,n){let s=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(Ii(a.content,t,a))),a.isInline&&(a=t(a,n,i)),s.push(a)}return H.fromArray(s)}class _n extends Re{constructor(t,n,s){super(),this.from=t,this.to=n,this.mark=s}apply(t){let n=t.slice(this.from,this.to),s=t.resolve(this.from),i=s.node(s.sharedDepth(this.to)),a=new re(Ii(n.content,(l,c)=>!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),n.openStart,n.openEnd);return Ce.fromReplace(t,this.from,this.to,a)}invert(){return new jn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new _n(n.pos,s.pos,this.mark)}merge(t){return t instanceof _n&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new _n(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new _n(n.from,n.to,t.markFromJSON(n.mark))}}Re.jsonID("addMark",_n);class jn extends Re{constructor(t,n,s){super(),this.from=t,this.to=n,this.mark=s}apply(t){let n=t.slice(this.from,this.to),s=new re(Ii(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),t),n.openStart,n.openEnd);return Ce.fromReplace(t,this.from,this.to,s)}invert(){return new _n(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new jn(n.pos,s.pos,this.mark)}merge(t){return t instanceof jn&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new jn(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new jn(n.from,n.to,t.markFromJSON(n.mark))}}Re.jsonID("removeMark",jn);class wn extends Re{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return Ce.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ce.fromReplace(t,this.pos,this.pos+1,new re(H.from(s),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let s=this.mark.addToSet(n.marks);if(s.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(s))return new wn(this.pos,n.marks[i]);return new wn(this.pos,this.mark)}}return new fr(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new wn(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new wn(n.pos,t.markFromJSON(n.mark))}}Re.jsonID("addNodeMark",wn);class fr extends Re{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return Ce.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Ce.fromReplace(t,this.pos,this.pos+1,new re(H.from(s),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new wn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new fr(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new fr(n.pos,t.markFromJSON(n.mark))}}Re.jsonID("removeNodeMark",fr);class Bt extends Re{constructor(t,n,s,i=!1){super(),this.from=t,this.to=n,this.slice=s,this.structure=i}apply(t){return this.structure&&Ei(t,this.from,this.to)?Ce.fail("Structure replace would overwrite content"):Ce.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new ct([this.from,this.to-this.from,this.slice.size])}invert(t){return new Bt(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deletedAcross&&s.deletedAcross?null:new Bt(n.pos,Math.max(n.pos,s.pos),this.slice)}merge(t){if(!(t instanceof Bt)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?re.empty:new re(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Bt(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?re.empty:new re(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Bt(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Bt(n.from,n.to,re.fromJSON(t,n.slice),!!n.structure)}}Re.jsonID("replace",Bt);class Cn extends Re{constructor(t,n,s,i,a,l,c=!1){super(),this.from=t,this.to=n,this.gapFrom=s,this.gapTo=i,this.slice=a,this.insert=l,this.structure=c}apply(t){if(this.structure&&(Ei(t,this.from,this.gapFrom)||Ei(t,this.gapTo,this.to)))return Ce.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Ce.fail("Gap is not a flat range");let s=this.slice.insertAt(this.insert,n.content);return s?Ce.fromReplace(t,this.from,this.to,s):Ce.fail("Content does not fit in gap")}getMap(){return new ct([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new Cn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1),i=t.map(this.gapFrom,-1),a=t.map(this.gapTo,1);return n.deletedAcross&&s.deletedAcross||i<n.pos||a>s.pos?null:new Cn(n.pos,s.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Cn(n.from,n.to,n.gapFrom,n.gapTo,re.fromJSON(t,n.slice),n.insert,!!n.structure)}}Re.jsonID("replaceAround",Cn);function Ei(e,t,n){let s=e.resolve(t),i=n-t,a=s.depth;for(;i>0&&a>0&&s.indexAfter(a)==s.node(a).childCount;)a--,i--;if(i>0){let l=s.node(a).maybeChild(s.indexAfter(a));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function Um(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Ym(e){let n=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let s=e.depth;;--s){let i=e.$from.node(s),a=e.$from.index(s),l=e.$to.indexAfter(s);if(s<e.depth&&i.canReplace(a,l,n))return s;if(s==0||i.type.spec.isolating||!Um(i,a,l))break}return null}function ds(e,t,n=1,s){let i=e.resolve(t),a=i.depth-n,l=s&&s[s.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!l.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,p=n-2;d>a;d--,p--){let h=i.node(d),f=i.index(d);if(h.type.spec.isolating)return!1;let m=h.content.cutByIndex(f,h.childCount),y=s&&s[p+1];y&&(m=m.replaceChild(0,y.type.create(y.attrs)));let j=s&&s[p]||h;if(!h.canReplace(f+1,h.childCount)||!j.type.validContent(m))return!1}let c=i.indexAfter(a),u=s&&s[0];return i.node(a).canReplaceWith(c,c,u?u.type:i.node(a+1).type)}function qc(e,t){let n=e.resolve(t),s=n.index();return Km(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(s,s+1)}function Km(e,t){return!!(e&&t&&!e.isLeaf&&e.canAppend(t))}class gr extends Re{constructor(t,n,s){super(),this.pos=t,this.attr=n,this.value=s}apply(t){let n=t.nodeAt(this.pos);if(!n)return Ce.fail("No node at attribute step's position");let s=Object.create(null);for(let a in n.attrs)s[a]=n.attrs[a];s[this.attr]=this.value;let i=n.type.create(s,null,n.marks);return Ce.fromReplace(t,this.pos,this.pos+1,new re(H.from(i),0,n.isLeaf?0:1))}getMap(){return ct.empty}invert(t){return new gr(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new gr(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new gr(n.pos,n.attr,n.value)}}Re.jsonID("attr",gr);let mr=class extends Error{};mr=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},mr.prototype=Object.create(Error.prototype),mr.prototype.constructor=mr,mr.prototype.name="TransformError";const Ai=Object.create(null);class fe{constructor(t,n,s){this.$anchor=t,this.$head=n,this.ranges=s||[new Xm(t.min(n),t.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=re.empty){let s=n.content.lastChild,i=null;for(let c=0;c<n.openEnd;c++)i=s,s=s.lastChild;let a=t.steps.length,l=this.ranges;for(let c=0;c<l.length;c++){let{$from:u,$to:d}=l[c],p=t.mapping.slice(a);t.replaceRange(p.map(u.pos),p.map(d.pos),c?re.empty:n),c==0&&$c(t,a,(s?s.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(t,n){let s=t.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:l,$to:c}=i[a],u=t.mapping.slice(s),d=u.map(l.pos),p=u.map(c.pos);a?t.deleteRange(d,p):(t.replaceRangeWith(d,p,n),$c(t,s,n.isInline?-1:1))}}static findFrom(t,n,s=!1){let i=t.parent.inlineContent?new Se(t):Vn(t.node(0),t.parent,t.pos,t.index(),n,s);if(i)return i;for(let a=t.depth-1;a>=0;a--){let l=n<0?Vn(t.node(0),t.node(a),t.before(a+1),t.index(a),n,s):Vn(t.node(0),t.node(a),t.after(a+1),t.index(a)+1,n,s);if(l)return l}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new Yt(t.node(0))}static atStart(t){return Vn(t,t,0,0,1)||new Yt(t)}static atEnd(t){return Vn(t,t,t.content.size,t.childCount,-1)||new Yt(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=Ai[n.type];if(!s)throw new RangeError(`No selection type ${n.type} defined`);return s.fromJSON(t,n)}static jsonID(t,n){if(t in Ai)throw new RangeError("Duplicate use of selection JSON ID "+t);return Ai[t]=n,n.prototype.jsonID=t,n}getBookmark(){return Se.between(this.$anchor,this.$head).getBookmark()}}fe.prototype.visible=!0;class Xm{constructor(t,n){this.$from=t,this.$to=n}}let Vc=!1;function Nc(e){!Vc&&!e.parent.inlineContent&&(Vc=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Se extends fe{constructor(t,n=t){Nc(t),Nc(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let s=t.resolve(n.map(this.head));if(!s.parent.inlineContent)return fe.near(s);let i=t.resolve(n.map(this.anchor));return new Se(i.parent.inlineContent?i:s,s)}replace(t,n=re.empty){if(super.replace(t,n),n==re.empty){let s=this.$from.marksAcross(this.$to);s&&t.ensureMarks(s)}}eq(t){return t instanceof Se&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new ps(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Se(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,s=n){let i=t.resolve(n);return new this(i,s==n?i:t.resolve(s))}static between(t,n,s){let i=t.pos-n.pos;if((!s||i)&&(s=i>=0?1:-1),!n.parent.inlineContent){let a=fe.findFrom(n,s,!0)||fe.findFrom(n,-s,!0);if(a)n=a.$head;else return fe.near(n,s)}return t.parent.inlineContent||(i==0?t=n:(t=(fe.findFrom(t,-s,!0)||fe.findFrom(t,s,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new Se(t,n)}}fe.jsonID("text",Se);class ps{constructor(t,n){this.anchor=t,this.head=n}map(t){return new ps(t.map(this.anchor),t.map(this.head))}resolve(t){return Se.between(t.resolve(this.anchor),t.resolve(this.head))}}class tt extends fe{constructor(t){let n=t.nodeAfter,s=t.node(0).resolve(t.pos+n.nodeSize);super(t,s),this.node=n}map(t,n){let{deleted:s,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return s?fe.near(a):new tt(a)}content(){return new re(H.from(this.node),0,0)}eq(t){return t instanceof tt&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Pi(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new tt(t.resolve(n.anchor))}static create(t,n){return new tt(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}tt.prototype.visible=!1,fe.jsonID("node",tt);class Pi{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:s}=t.mapResult(this.anchor);return n?new ps(s,s):new Pi(s)}resolve(t){let n=t.resolve(this.anchor),s=n.nodeAfter;return s&&tt.isSelectable(s)?new tt(n):fe.near(n)}}class Yt extends fe{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=re.empty){if(n==re.empty){t.delete(0,t.doc.content.size);let s=fe.atStart(t.doc);s.eq(t.selection)||t.setSelection(s)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new Yt(t)}map(t){return new Yt(t)}eq(t){return t instanceof Yt}getBookmark(){return Jm}}fe.jsonID("all",Yt);const Jm={map(){return this},resolve(e){return new Yt(e)}};function Vn(e,t,n,s,i,a=!1){if(t.inlineContent)return Se.create(e,n);for(let l=s-(i>0?0:1);i>0?l<t.childCount:l>=0;l+=i){let c=t.child(l);if(c.isAtom){if(!a&&tt.isSelectable(c))return tt.create(e,n-(i<0?c.nodeSize:0))}else{let u=Vn(e,c,n+i,i<0?c.childCount:0,i,a);if(u)return u}n+=c.nodeSize*i}return null}function $c(e,t,n){let s=e.steps.length-1;if(s<t)return;let i=e.steps[s];if(!(i instanceof Bt||i instanceof Cn))return;let a=e.mapping.maps[s],l;a.forEach((c,u,d,p)=>{l==null&&(l=p)}),e.setSelection(fe.near(e.doc.resolve(l),n))}function Fc(e,t){return!t||!e?e:e.bind(t)}class hs{constructor(t,n,s){this.name=t,this.init=Fc(n.init,s),this.apply=Fc(n.apply,s)}}new hs("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new hs("selection",{init(e,t){return e.selection||fe.atStart(t.doc)},apply(e){return e.selection}}),new hs("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,s){return s.selection.$cursor?e.storedMarks:null}}),new hs("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}});function Gc(e,t,n){for(let s in e){let i=e[s];i instanceof Function?i=i.bind(t):s=="handleDOMEvents"&&(i=Gc(i,t,{})),n[s]=i}return n}let xr=class{constructor(t){this.spec=t,this.props={},t.props&&Gc(t.props,this,this.props),this.key=t.key?t.key.key:Wc("plugin")}getState(t){return t[this.key]}};const Oi=Object.create(null);function Wc(e){return e in Oi?e+"$"+ ++Oi[e]:(Oi[e]=0,e+"$")}class yr{constructor(t="key"){this.key=Wc(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}function Rc(e){const{state:t,transaction:n}=e;let{selection:s}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),filterTransaction:t.filterTransaction,plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return s},get doc(){return i},get tr(){return s=n.selection,i=n.doc,a=n.storedMarks,n}}}class Zm{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:n,state:s}=this,{view:i}=n,{tr:a}=s,l=this.buildProps(a);return Object.fromEntries(Object.entries(t).map(([c,u])=>[c,(...p)=>{const h=u(...p)(l);return!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){const{rawCommands:s,editor:i,state:a}=this,{view:l}=i,c=[],u=!!t,d=t||a.tr,p=()=>(!u&&n&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(d),c.every(f=>f===!0)),h={...Object.fromEntries(Object.entries(s).map(([f,m])=>[f,(...j)=>{const k=this.buildProps(d,n),S=m(...j)(k);return c.push(S),h}])),run:p};return h}createCan(t){const{rawCommands:n,state:s}=this,i=!1,a=t||s.tr,l=this.buildProps(a,i);return{...Object.fromEntries(Object.entries(n).map(([u,d])=>[u,(...p)=>d(...p)({...l,dispatch:void 0})])),chain:()=>this.createChain(a,i)}}buildProps(t,n=!0){const{rawCommands:s,editor:i,state:a}=this,{view:l}=i;a.storedMarks&&t.setStoredMarks(a.storedMarks);const c={tr:t,editor:i,view:l,state:Rc({state:a,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(s).map(([u,d])=>[u,(...p)=>d(...p)(c)]))}};return c}}function nt(e,t,n){return e.config[t]===void 0&&e.parent?nt(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?nt(e.parent,t,n):null}):e.config[t]}function Hm(e){const t=e.filter(i=>i.type==="extension"),n=e.filter(i=>i.type==="node"),s=e.filter(i=>i.type==="mark");return{baseExtensions:t,nodeExtensions:n,markExtensions:s}}function Oe(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function ex(e){return typeof e=="function"}function jt(e,t=void 0,...n){return ex(e)?t?e.bind(t)(...n):e(...n):e}function tx(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function nx(e){return Object.prototype.toString.call(e).slice(8,-1)}function Li(e){return nx(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function Bi(e,t){const n={...e};return Li(e)&&Li(t)&&Object.keys(t).forEach(s=>{Li(t[s])?s in e?n[s]=Bi(e[s],t[s]):Object.assign(n,{[s]:t[s]}):Object.assign(n,{[s]:t[s]})}),n}class qt{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=jt(nt(this,"addOptions",{name:this.name}))),this.storage=jt(nt(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new qt(t)}configure(t={}){const n=this.extend();return n.options=Bi(this.options,t),n.storage=jt(nt(n,"addStorage",{name:n.name,options:n.options})),n}extend(t={}){const n=new qt(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=jt(nt(n,"addOptions",{name:n.name})),n.storage=jt(nt(n,"addStorage",{name:n.name,options:n.options})),n}}function rx(e,t,n){const{from:s,to:i}=t,{blockSeparator:a=`
|
|
58
58
|
|
|
59
|
-
`,textSerializers:l={}}=n||{};let c="",u=!0;return e.nodesBetween(s,i,(d,p,h,f)=>{var m;const y=l==null?void 0:l[d.type.name];y?(d.isBlock&&!u&&(c+=a,u=!0),h&&(c+=y({node:d,pos:p,parent:h,index:f,range:t}))):d.isText?(c+=(m=d==null?void 0:d.text)===null||m===void 0?void 0:m.slice(Math.max(s,p)-p,i-p),u=!1):d.isBlock&&!u&&(c+=a,u=!0)}),c}function sx(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}qt.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new xr({key:new yr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:s,selection:i}=t,{ranges:a}=i,l=Math.min(...a.map(p=>p.$from.pos)),c=Math.max(...a.map(p=>p.$to.pos)),u=sx(n);return rx(s,{from:l,to:c},{textSerializers:u})}}})]}});const ix=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),ax=(e=!1)=>({commands:t})=>t.setContent("",e),ox=()=>({state:e,tr:t,dispatch:n})=>{const{selection:s}=t,{ranges:i}=s;return n&&i.forEach(({$from:a,$to:l})=>{e.doc.nodesBetween(a.pos,l.pos,(c,u)=>{if(c.type.isText)return;const{doc:d,mapping:p}=t,h=d.resolve(p.map(u)),f=d.resolve(p.map(u+c.nodeSize)),m=h.blockRange(f);if(!m)return;const y=Ym(m);if(c.type.isTextblock){const{defaultType:j}=h.parent.contentMatchAt(h.index());t.setNodeMarkup(m.start,j)}(y||y===0)&&t.lift(m,y)})}),!0},lx=e=>t=>e(t),cx=()=>({state:e,dispatch:t})=>De.createParagraphNear(e,t),ux=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,s=n.$anchor.node();if(s.content.size>0)return!1;const i=e.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===s.type){if(t){const c=i.before(a),u=i.after(a);e.delete(c,u).scrollIntoView()}return!0}return!1},dx=e=>({tr:t,state:n,dispatch:s})=>{const i=Oe(e,n.schema),a=t.selection.$anchor;for(let l=a.depth;l>0;l-=1)if(a.node(l).type===i){if(s){const u=a.before(l),d=a.after(l);t.delete(u,d).scrollIntoView()}return!0}return!1},px=e=>({tr:t,dispatch:n})=>{const{from:s,to:i}=e;return n&&t.delete(s,i),!0},hx=()=>({state:e,dispatch:t})=>De.deleteSelection(e,t),fx=()=>({commands:e})=>e.keyboardShortcut("Enter"),gx=()=>({state:e,dispatch:t})=>De.exitCode(e,t);function fs(e,t,n={strict:!0}){const s=Object.keys(t);return s.length?s.every(i=>n.strict?t[i]===e[i]:tx(t[i])?t[i].test(e[i]):t[i]===e[i]):!0}function qi(e,t,n={}){return e.find(s=>s.type===t&&fs(s.attrs,n))}function mx(e,t,n={}){return!!qi(e,t,n)}function Qc(e,t,n={}){if(!e||!t)return;let s=e.parent.childAfter(e.parentOffset);if(e.parentOffset===s.offset&&s.offset!==0&&(s=e.parent.childBefore(e.parentOffset)),!s.node)return;const i=qi([...s.node.marks],t,n);if(!i)return;let a=s.index,l=e.start()+s.offset,c=a+1,u=l+s.node.nodeSize;for(qi([...s.node.marks],t,n);a>0&&i.isInSet(e.parent.child(a-1).marks);)a-=1,l-=e.parent.child(a).nodeSize;for(;c<e.parent.childCount&&mx([...e.parent.child(c).marks],t,n);)u+=e.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function ln(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}const xx=(e,t={})=>({tr:n,state:s,dispatch:i})=>{const a=ln(e,s.schema),{doc:l,selection:c}=n,{$from:u,from:d,to:p}=c;if(i){const h=Qc(u,a,t);if(h&&h.from<=d&&h.to>=p){const f=Se.create(l,h.from,h.to);n.setSelection(f)}}return!0},yx=e=>t=>{const n=typeof e=="function"?e(t):e;for(let s=0;s<n.length;s+=1)if(n[s](t))return!0;return!1};function Uc(e){return e instanceof Se}function Sn(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function bx(e,t=null){if(!t)return null;const n=fe.atStart(e),s=fe.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return s;const i=n.from,a=s.to;return t==="all"?Se.create(e,Sn(0,i,a),Sn(e.content.size,i,a)):Se.create(e,Sn(t,i,a),Sn(t,i,a))}function Vi(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const vx=(e=null,t={})=>({editor:n,view:s,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};const l=()=>{Vi()&&s.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(s.focus(),t!=null&&t.scrollIntoView&&n.commands.scrollIntoView())})};if(s.hasFocus()&&e===null||e===!1)return!0;if(a&&e===null&&!Uc(n.state.selection))return l(),!0;const c=bx(i.doc,e)||n.state.selection,u=n.state.selection.eq(c);return a&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),l()),!0},_x=(e,t)=>n=>e.every((s,i)=>t(s,{...n,index:i})),jx=(e,t)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},e,t);function Yc(e){const t=`<body>${e}</body>`;return new window.DOMParser().parseFromString(t,"text/html").body}function gs(e,t,n){if(n={slice:!0,parseOptions:{},...n},typeof e=="object"&&e!==null)try{return Array.isArray(e)&&e.length>0?H.fromArray(e.map(s=>t.nodeFromJSON(s))):t.nodeFromJSON(e)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",s),gs("",t,n)}if(typeof e=="string"){const s=qm.fromSchema(t);return n.slice?s.parseSlice(Yc(e),n.parseOptions).content:s.parse(Yc(e),n.parseOptions)}return gs("",t,n)}function wx(e,t,n){const s=e.steps.length-1;if(s<t)return;const i=e.steps[s];if(!(i instanceof Bt||i instanceof Cn))return;const a=e.mapping.maps[s];let l=0;a.forEach((c,u,d,p)=>{l===0&&(l=p)}),e.setSelection(fe.near(e.doc.resolve(l),n))}const Cx=e=>e.toString().startsWith("<"),Sx=(e,t,n)=>({tr:s,dispatch:i,editor:a})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const l=gs(t,a.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if(l.toString()==="<>")return!0;let{from:c,to:u}=typeof e=="number"?{from:e,to:e}:e,d=!0,p=!0;if((Cx(l)?l:[l]).forEach(f=>{f.check(),d=d?f.isText&&f.marks.length===0:!1,p=p?f.isBlock:!1}),c===u&&p){const{parent:f}=s.doc.resolve(c);f.isTextblock&&!f.type.spec.code&&!f.childCount&&(c-=1,u+=1)}d?Array.isArray(t)?s.insertText(t.map(f=>f.text||"").join(""),c,u):typeof t=="object"&&t&&t.text?s.insertText(t.text,c,u):s.insertText(t,c,u):s.replaceWith(c,u,l),n.updateSelection&&wx(s,s.steps.length-1,-1)}return!0},kx=()=>({state:e,dispatch:t})=>De.joinUp(e,t),Tx=()=>({state:e,dispatch:t})=>De.joinDown(e,t),Dx=()=>({state:e,dispatch:t})=>De.joinBackward(e,t),Mx=()=>({state:e,dispatch:t})=>De.joinForward(e,t);function Kc(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function zx(e){const t=e.split(/-(?!$)/);let n=t[t.length-1];n==="Space"&&(n=" ");let s,i,a,l;for(let c=0;c<t.length-1;c+=1){const u=t[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))s=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))a=!0;else if(/^mod$/i.test(u))Vi()||Kc()?l=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return s&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),l&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}const Ix=e=>({editor:t,view:n,tr:s,dispatch:i})=>{const a=zx(e).split(/-(?!$)/),l=a.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),u=t.captureTransaction(()=>{n.someProp("handleKeyDown",d=>d(n,c))});return u==null||u.steps.forEach(d=>{const p=d.map(s.mapping);p&&i&&s.maybeStep(p)}),!0};function Ni(e,t,n={}){const{from:s,to:i,empty:a}=e.selection,l=t?Oe(t,e.schema):null,c=[];e.doc.nodesBetween(s,i,(h,f)=>{if(h.isText)return;const m=Math.max(s,f),y=Math.min(i,f+h.nodeSize);c.push({node:h,from:m,to:y})});const u=i-s,d=c.filter(h=>l?l.name===h.node.type.name:!0).filter(h=>fs(h.node.attrs,n,{strict:!1}));return a?!!d.length:d.reduce((h,f)=>h+f.to-f.from,0)>=u}const Ex=(e,t={})=>({state:n,dispatch:s})=>{const i=Oe(e,n.schema);return Ni(n,i,t)?De.lift(n,s):!1},Ax=()=>({state:e,dispatch:t})=>De.liftEmptyBlock(e,t),Px=e=>({state:t,dispatch:n})=>{const s=Oe(e,t.schema);return _i.liftListItem(s)(t,n)},Ox=()=>({state:e,dispatch:t})=>De.newlineInCode(e,t);function Xc(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Jc(e,t){const n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((s,i)=>(n.includes(i)||(s[i]=e[i]),s),{})}const Lx=(e,t)=>({tr:n,state:s,dispatch:i})=>{let a=null,l=null;const c=Xc(typeof e=="string"?e:e.name,s.schema);return c?(c==="node"&&(a=Oe(e,s.schema)),c==="mark"&&(l=ln(e,s.schema)),i&&n.selection.ranges.forEach(u=>{s.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,p)=>{a&&a===d.type&&n.setNodeMarkup(p,void 0,Jc(d.attrs,t)),l&&d.marks.length&&d.marks.forEach(h=>{l===h.type&&n.addMark(p,p+d.nodeSize,l.create(Jc(h.attrs,t)))})})}),!0):!1},Bx=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),qx=()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),Vx=()=>({state:e,dispatch:t})=>De.selectNodeBackward(e,t),Nx=()=>({state:e,dispatch:t})=>De.selectNodeForward(e,t),$x=()=>({state:e,dispatch:t})=>De.selectParentNode(e,t),Fx=()=>({state:e,dispatch:t})=>De.selectTextblockEnd(e,t),Gx=()=>({state:e,dispatch:t})=>De.selectTextblockStart(e,t);function Wx(e,t,n={}){return gs(e,t,{slice:!1,parseOptions:n})}const Rx=(e,t=!1,n={})=>({tr:s,editor:i,dispatch:a})=>{const{doc:l}=s,c=Wx(e,i.schema,n);return a&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!t),!0};function Qx(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Ux(e,t){for(let n=e.depth;n>0;n-=1){const s=e.node(n);if(t(s))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:s}}}function $i(e){return t=>Ux(t.$from,e)}function Yx(e,t){const n=ln(t,e.schema),{from:s,to:i,empty:a}=e.selection,l=[];a?(e.storedMarks&&l.push(...e.storedMarks),l.push(...e.selection.$head.marks())):e.doc.nodesBetween(s,i,u=>{l.push(...u.marks)});const c=l.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function ms(e,t,n){return Object.fromEntries(Object.entries(n).filter(([s])=>{const i=e.find(a=>a.type===t&&a.name===s);return i?i.attribute.keepOnSplit:!1}))}function Kx(e,t,n={}){const{empty:s,ranges:i}=e.selection,a=t?ln(t,e.schema):null;if(s)return!!(e.storedMarks||e.selection.$from.marks()).filter(h=>a?a.name===h.type.name:!0).find(h=>fs(h.attrs,n,{strict:!1}));let l=0;const c=[];if(i.forEach(({$from:h,$to:f})=>{const m=h.pos,y=f.pos;e.doc.nodesBetween(m,y,(j,k)=>{if(!j.isText&&!j.marks.length)return;const S=Math.max(m,k),T=Math.min(y,k+j.nodeSize),z=T-S;l+=z,c.push(...j.marks.map(I=>({mark:I,from:S,to:T})))})}),l===0)return!1;const u=c.filter(h=>a?a.name===h.mark.type.name:!0).filter(h=>fs(h.mark.attrs,n,{strict:!1})).reduce((h,f)=>h+f.to-f.from,0),d=c.filter(h=>a?h.mark.type!==a&&h.mark.type.excludes(a):!0).reduce((h,f)=>h+f.to-f.from,0);return(u>0?u+d:u)>=l}function Zc(e,t){const{nodeExtensions:n}=Hm(t),s=n.find(l=>l.name===e);if(!s)return!1;const i={name:s.name,options:s.options,storage:s.storage},a=jt(nt(s,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function Xx(e,t,n){var s;const{selection:i}=t;let a=null;if(Uc(i)&&(a=i.$cursor),a){const c=(s=e.storedMarks)!==null&&s!==void 0?s:a.marks();return!!n.isInSet(c)||!c.some(u=>u.type.excludes(n))}const{ranges:l}=i;return l.some(({$from:c,$to:u})=>{let d=c.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(c.pos,u.pos,(p,h,f)=>{if(d)return!1;if(p.isInline){const m=!f||f.type.allowsMarkType(n),y=!!n.isInSet(p.marks)||!p.marks.some(j=>j.type.excludes(n));d=m&&y}return!d}),d})}const Jx=(e,t={})=>({tr:n,state:s,dispatch:i})=>{const{selection:a}=n,{empty:l,ranges:c}=a,u=ln(e,s.schema);if(i)if(l){const d=Yx(s,u);n.addStoredMark(u.create({...d,...t}))}else c.forEach(d=>{const p=d.$from.pos,h=d.$to.pos;s.doc.nodesBetween(p,h,(f,m)=>{const y=Math.max(m,p),j=Math.min(m+f.nodeSize,h);f.marks.find(S=>S.type===u)?f.marks.forEach(S=>{u===S.type&&n.addMark(y,j,u.create({...S.attrs,...t}))}):n.addMark(y,j,u.create(t))})});return Xx(s,n,u)},Zx=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),Hx=(e,t={})=>({state:n,dispatch:s,chain:i})=>{const a=Oe(e,n.schema);return a.isTextblock?i().command(({commands:l})=>De.setBlockType(a,t)(n)?!0:l.clearNodes()).command(({state:l})=>De.setBlockType(a,t)(l,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ey=e=>({tr:t,dispatch:n})=>{if(n){const{doc:s}=t,i=Sn(e,0,s.content.size),a=tt.create(s,i);t.setSelection(a)}return!0},ty=e=>({tr:t,dispatch:n})=>{if(n){const{doc:s}=t,{from:i,to:a}=typeof e=="number"?{from:e,to:e}:e,l=Se.atStart(s).from,c=Se.atEnd(s).to,u=Sn(i,l,c),d=Sn(a,l,c),p=Se.create(s,u,d);t.setSelection(p)}return!0},ny=e=>({state:t,dispatch:n})=>{const s=Oe(e,t.schema);return _i.sinkListItem(s)(t,n)};function Hc(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const s=n.filter(i=>t==null?void 0:t.includes(i.type.name));e.tr.ensureMarks(s)}}const ry=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:s,editor:i})=>{const{selection:a,doc:l}=t,{$from:c,$to:u}=a,d=i.extensionManager.attributes,p=ms(d,c.node().type.name,c.node().attrs);if(a instanceof tt&&a.node.isBlock)return!c.parentOffset||!ds(l,c.pos)?!1:(s&&(e&&Hc(n,i.extensionManager.splittableMarks),t.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;if(s){const h=u.parentOffset===u.parent.content.size;a instanceof Se&&t.deleteSelection();const f=c.depth===0?void 0:Qx(c.node(-1).contentMatchAt(c.indexAfter(-1)));let m=h&&f?[{type:f,attrs:p}]:void 0,y=ds(t.doc,t.mapping.map(c.pos),1,m);if(!m&&!y&&ds(t.doc,t.mapping.map(c.pos),1,f?[{type:f}]:void 0)&&(y=!0,m=f?[{type:f,attrs:p}]:void 0),y&&(t.split(t.mapping.map(c.pos),1,m),f&&!h&&!c.parentOffset&&c.parent.type!==f)){const j=t.mapping.map(c.before()),k=t.doc.resolve(j);c.node(-1).canReplaceWith(k.index(),k.index()+1,f)&&t.setNodeMarkup(t.mapping.map(c.before()),f)}e&&Hc(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return!0},sy=e=>({tr:t,state:n,dispatch:s,editor:i})=>{var a;const l=Oe(e,n.schema),{$from:c,$to:u}=n.selection,d=n.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const p=c.node(-1);if(p.type!==l)return!1;const h=i.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(s){let k=H.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let R=c.depth-S;R>=c.depth-3;R-=1)k=H.from(c.node(R).copy(k));const T=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,z=ms(h,c.node().type.name,c.node().attrs),I=((a=l.contentMatch.defaultType)===null||a===void 0?void 0:a.createAndFill(z))||void 0;k=k.append(H.from(l.createAndFill(null,I)||void 0));const E=c.before(c.depth-(S-1));t.replace(E,c.after(-T),new re(k,4-S,0));let N=-1;t.doc.nodesBetween(E,t.doc.content.size,(R,pe)=>{if(N>-1)return!1;R.isTextblock&&R.content.size===0&&(N=pe+1)}),N>-1&&t.setSelection(Se.near(t.doc.resolve(N))),t.scrollIntoView()}return!0}const f=u.pos===c.end()?p.contentMatchAt(0).defaultType:null,m=ms(h,p.type.name,p.attrs),y=ms(h,c.node().type.name,c.node().attrs);t.delete(c.pos,u.pos);const j=f?[{type:l,attrs:m},{type:f,attrs:y}]:[{type:l,attrs:m}];if(!ds(t.doc,c.pos,2))return!1;if(s){const{selection:k,storedMarks:S}=n,{splittableMarks:T}=i.extensionManager,z=S||k.$to.parentOffset&&k.$from.marks();if(t.split(c.pos,2,j).scrollIntoView(),!z||!s)return!0;const I=z.filter(E=>T.includes(E.type.name));t.ensureMarks(I)}return!0},Fi=(e,t)=>{const n=$i(l=>l.type===t)(e.selection);if(!n)return!0;const s=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(s===void 0)return!0;const i=e.doc.nodeAt(s);return n.node.type===(i==null?void 0:i.type)&&qc(e.doc,n.pos)&&e.join(n.pos),!0},Gi=(e,t)=>{const n=$i(l=>l.type===t)(e.selection);if(!n)return!0;const s=e.doc.resolve(n.start).after(n.depth);if(s===void 0)return!0;const i=e.doc.nodeAt(s);return n.node.type===(i==null?void 0:i.type)&&qc(e.doc,s)&&e.join(s),!0};var iy=Object.freeze({__proto__:null,blur:ix,clearContent:ax,clearNodes:ox,command:lx,createParagraphNear:cx,deleteCurrentNode:ux,deleteNode:dx,deleteRange:px,deleteSelection:hx,enter:fx,exitCode:gx,extendMarkRange:xx,first:yx,focus:vx,forEach:_x,insertContent:jx,insertContentAt:Sx,joinUp:kx,joinDown:Tx,joinBackward:Dx,joinForward:Mx,keyboardShortcut:Ix,lift:Ex,liftEmptyBlock:Ax,liftListItem:Px,newlineInCode:Ox,resetAttributes:Lx,scrollIntoView:Bx,selectAll:qx,selectNodeBackward:Vx,selectNodeForward:Nx,selectParentNode:$x,selectTextblockEnd:Fx,selectTextblockStart:Gx,setContent:Rx,setMark:Jx,setMeta:Zx,setNode:Hx,setNodeSelection:ey,setTextSelection:ty,sinkListItem:ny,splitBlock:ry,splitListItem:sy,toggleList:(e,t,n,s={})=>({editor:i,tr:a,state:l,dispatch:c,chain:u,commands:d,can:p})=>{const{extensions:h,splittableMarks:f}=i.extensionManager,m=Oe(e,l.schema),y=Oe(t,l.schema),{selection:j,storedMarks:k}=l,{$from:S,$to:T}=j,z=S.blockRange(T),I=k||j.$to.parentOffset&&j.$from.marks();if(!z)return!1;const E=$i(N=>Zc(N.type.name,h))(j);if(z.depth>=1&&E&&z.depth-E.depth<=1){if(E.node.type===m)return d.liftListItem(y);if(Zc(E.node.type.name,h)&&m.validContent(E.node.content)&&c)return u().command(()=>(a.setNodeMarkup(E.pos,m),!0)).command(()=>Fi(a,m)).command(()=>Gi(a,m)).run()}return!n||!I||!c?u().command(()=>p().wrapInList(m,s)?!0:d.clearNodes()).wrapInList(m,s).command(()=>Fi(a,m)).command(()=>Gi(a,m)).run():u().command(()=>{const N=p().wrapInList(m,s),R=I.filter(pe=>f.includes(pe.type.name));return a.ensureMarks(R),N?!0:d.clearNodes()}).wrapInList(m,s).command(()=>Fi(a,m)).command(()=>Gi(a,m)).run()},toggleMark:(e,t={},n={})=>({state:s,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,l=ln(e,s.schema);return Kx(s,l,t)?i.unsetMark(l,{extendEmptyMarkRange:a}):i.setMark(l,t)},toggleNode:(e,t,n={})=>({state:s,commands:i})=>{const a=Oe(e,s.schema),l=Oe(t,s.schema);return Ni(s,a,n)?i.setNode(l):i.setNode(a,n)},toggleWrap:(e,t={})=>({state:n,commands:s})=>{const i=Oe(e,n.schema);return Ni(n,i,t)?s.lift(i):s.wrapIn(i,t)},undoInputRule:()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let s=0;s<n.length;s+=1){const i=n[s];let a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){const l=e.tr,c=a.transform;for(let u=c.steps.length-1;u>=0;u-=1)l.step(c.steps[u].invert(c.docs[u]));if(a.text){const u=l.doc.resolve(a.from).marks();l.replaceWith(a.from,a.to,e.schema.text(a.text,u))}else l.delete(a.from,a.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:s,ranges:i}=n;return s||t&&i.forEach(a=>{e.removeMark(a.$from.pos,a.$to.pos)}),!0},unsetMark:(e,t={})=>({tr:n,state:s,dispatch:i})=>{var a;const{extendEmptyMarkRange:l=!1}=t,{selection:c}=n,u=ln(e,s.schema),{$from:d,empty:p,ranges:h}=c;if(!i)return!0;if(p&&l){let{from:f,to:m}=c;const y=(a=d.marks().find(k=>k.type===u))===null||a===void 0?void 0:a.attrs,j=Qc(d,u,y);j&&(f=j.from,m=j.to),n.removeMark(f,m,u)}else h.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,u)});return n.removeStoredMark(u),!0},updateAttributes:(e,t={})=>({tr:n,state:s,dispatch:i})=>{let a=null,l=null;const c=Xc(typeof e=="string"?e:e.name,s.schema);return c?(c==="node"&&(a=Oe(e,s.schema)),c==="mark"&&(l=ln(e,s.schema)),i&&n.selection.ranges.forEach(u=>{const d=u.$from.pos,p=u.$to.pos;s.doc.nodesBetween(d,p,(h,f)=>{a&&a===h.type&&n.setNodeMarkup(f,void 0,{...h.attrs,...t}),l&&h.marks.length&&h.marks.forEach(m=>{if(l===m.type){const y=Math.max(f,d),j=Math.min(f+h.nodeSize,p);n.addMark(y,j,l.create({...m.attrs,...t}))}})})}),!0):!1},wrapIn:(e,t={})=>({state:n,dispatch:s})=>{const i=Oe(e,n.schema);return De.wrapIn(i,t)(n,s)},wrapInList:(e,t={})=>({state:n,dispatch:s})=>{const i=Oe(e,n.schema);return _i.wrapInList(i,t)(n,s)}});qt.create({name:"commands",addCommands(){return{...iy}}}),qt.create({name:"editable",addProseMirrorPlugins(){return[new xr({key:new yr("editable"),props:{editable:()=>this.editor.options.editable}})]}}),qt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new xr({key:new yr("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const s=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(s),!1},blur:(t,n)=>{e.isFocused=!1;const s=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(s),!1}}}})]}}),qt.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:u,doc:d}=c,{empty:p,$anchor:h}=u,{pos:f,parent:m}=h,y=fe.atStart(d).from===f;return!p||!y||!m.type.isTextblock||m.textContent.length?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},i={...s},a={...s,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Vi()||Kc()?a:i},addProseMirrorPlugins(){return[new xr({key:new yr("clearDocument"),appendTransaction:(e,t,n)=>{if(!(e.some(y=>y.docChanged)&&!t.doc.eq(n.doc)))return;const{empty:i,from:a,to:l}=t.selection,c=fe.atStart(t.doc).from,u=fe.atEnd(t.doc).to;if(i||!(a===c&&l===u)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;const h=n.tr,f=Rc({state:n,transaction:h}),{commands:m}=new Zm({editor:this.editor,state:f});if(m.clearNodes(),!!h.steps.length)return h}})]}}),qt.create({name:"tabindex",addProseMirrorPlugins(){return[new xr({key:new yr("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class xs{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=jt(nt(this,"addOptions",{name:this.name}))),this.storage=jt(nt(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new xs(t)}configure(t={}){const n=this.extend();return n.options=Bi(this.options,t),n.storage=jt(nt(n,"addStorage",{name:n.name,options:n.options})),n}extend(t={}){const n=new xs(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=jt(nt(n,"addOptions",{name:n.name})),n.storage=jt(nt(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:t,mark:n}){const{tr:s}=t.state,i=t.state.selection.$from;if(i.pos===i.end()){const l=i.marks();if(!!!l.find(d=>(d==null?void 0:d.type.name)===n.name))return!1;const u=l.find(d=>(d==null?void 0:d.type.name)===n.name);return u&&s.removeStoredMark(u),s.insertText(" ",i.pos),t.view.dispatch(s),!0}return!1}}const eu=qt.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize.replace(/['"]+/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),ay=["8","10","12","14","16","18","20","24","30","36","48","60","72"].map(e=>`${e}px`),oy=[{label:"auto",value:""}].concat(ay.map(e=>({label:e,value:e}))),ly={input:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"}},cy=({editor:e})=>{const t=e.getAttributes("textStyle").fontSize;return r.jsx(Q.RichTextEditor.ControlsGroup,{children:r.jsx(o.NativeSelect,{size:"xs",icon:r.jsx(M.IconTextSize,{stroke:1.5,size:16}),data:oy,styles:ly,value:t||"",onChange:n=>{const s=n.currentTarget.value;s?e.chain().focus().setFontSize(s).run():e.chain().focus().unsetFontSize().run()}})})},Wi="function color({ variables }, { filters, context }, utils) {",tu="}",uy=[Wi,' return "red";',tu].join(`
|
|
59
|
+
`,textSerializers:l={}}=n||{};let c="",u=!0;return e.nodesBetween(s,i,(d,p,h,f)=>{var m;const y=l==null?void 0:l[d.type.name];y?(d.isBlock&&!u&&(c+=a,u=!0),h&&(c+=y({node:d,pos:p,parent:h,index:f,range:t}))):d.isText?(c+=(m=d==null?void 0:d.text)===null||m===void 0?void 0:m.slice(Math.max(s,p)-p,i-p),u=!1):d.isBlock&&!u&&(c+=a,u=!0)}),c}function sx(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}qt.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new xr({key:new yr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:s,selection:i}=t,{ranges:a}=i,l=Math.min(...a.map(p=>p.$from.pos)),c=Math.max(...a.map(p=>p.$to.pos)),u=sx(n);return rx(s,{from:l,to:c},{textSerializers:u})}}})]}});const ix=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),ax=(e=!1)=>({commands:t})=>t.setContent("",e),ox=()=>({state:e,tr:t,dispatch:n})=>{const{selection:s}=t,{ranges:i}=s;return n&&i.forEach(({$from:a,$to:l})=>{e.doc.nodesBetween(a.pos,l.pos,(c,u)=>{if(c.type.isText)return;const{doc:d,mapping:p}=t,h=d.resolve(p.map(u)),f=d.resolve(p.map(u+c.nodeSize)),m=h.blockRange(f);if(!m)return;const y=Ym(m);if(c.type.isTextblock){const{defaultType:j}=h.parent.contentMatchAt(h.index());t.setNodeMarkup(m.start,j)}(y||y===0)&&t.lift(m,y)})}),!0},lx=e=>t=>e(t),cx=()=>({state:e,dispatch:t})=>De.createParagraphNear(e,t),ux=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,s=n.$anchor.node();if(s.content.size>0)return!1;const i=e.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===s.type){if(t){const c=i.before(a),u=i.after(a);e.delete(c,u).scrollIntoView()}return!0}return!1},dx=e=>({tr:t,state:n,dispatch:s})=>{const i=Oe(e,n.schema),a=t.selection.$anchor;for(let l=a.depth;l>0;l-=1)if(a.node(l).type===i){if(s){const u=a.before(l),d=a.after(l);t.delete(u,d).scrollIntoView()}return!0}return!1},px=e=>({tr:t,dispatch:n})=>{const{from:s,to:i}=e;return n&&t.delete(s,i),!0},hx=()=>({state:e,dispatch:t})=>De.deleteSelection(e,t),fx=()=>({commands:e})=>e.keyboardShortcut("Enter"),gx=()=>({state:e,dispatch:t})=>De.exitCode(e,t);function fs(e,t,n={strict:!0}){const s=Object.keys(t);return s.length?s.every(i=>n.strict?t[i]===e[i]:tx(t[i])?t[i].test(e[i]):t[i]===e[i]):!0}function qi(e,t,n={}){return e.find(s=>s.type===t&&fs(s.attrs,n))}function mx(e,t,n={}){return!!qi(e,t,n)}function Qc(e,t,n={}){if(!e||!t)return;let s=e.parent.childAfter(e.parentOffset);if(e.parentOffset===s.offset&&s.offset!==0&&(s=e.parent.childBefore(e.parentOffset)),!s.node)return;const i=qi([...s.node.marks],t,n);if(!i)return;let a=s.index,l=e.start()+s.offset,c=a+1,u=l+s.node.nodeSize;for(qi([...s.node.marks],t,n);a>0&&i.isInSet(e.parent.child(a-1).marks);)a-=1,l-=e.parent.child(a).nodeSize;for(;c<e.parent.childCount&&mx([...e.parent.child(c).marks],t,n);)u+=e.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function ln(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}const xx=(e,t={})=>({tr:n,state:s,dispatch:i})=>{const a=ln(e,s.schema),{doc:l,selection:c}=n,{$from:u,from:d,to:p}=c;if(i){const h=Qc(u,a,t);if(h&&h.from<=d&&h.to>=p){const f=Se.create(l,h.from,h.to);n.setSelection(f)}}return!0},yx=e=>t=>{const n=typeof e=="function"?e(t):e;for(let s=0;s<n.length;s+=1)if(n[s](t))return!0;return!1};function Uc(e){return e instanceof Se}function Sn(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function bx(e,t=null){if(!t)return null;const n=fe.atStart(e),s=fe.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return s;const i=n.from,a=s.to;return t==="all"?Se.create(e,Sn(0,i,a),Sn(e.content.size,i,a)):Se.create(e,Sn(t,i,a),Sn(t,i,a))}function Vi(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const vx=(e=null,t={})=>({editor:n,view:s,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};const l=()=>{Vi()&&s.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(s.focus(),t!=null&&t.scrollIntoView&&n.commands.scrollIntoView())})};if(s.hasFocus()&&e===null||e===!1)return!0;if(a&&e===null&&!Uc(n.state.selection))return l(),!0;const c=bx(i.doc,e)||n.state.selection,u=n.state.selection.eq(c);return a&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),l()),!0},_x=(e,t)=>n=>e.every((s,i)=>t(s,{...n,index:i})),jx=(e,t)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},e,t);function Yc(e){const t=`<body>${e}</body>`;return new window.DOMParser().parseFromString(t,"text/html").body}function gs(e,t,n){if(n={slice:!0,parseOptions:{},...n},typeof e=="object"&&e!==null)try{return Array.isArray(e)&&e.length>0?H.fromArray(e.map(s=>t.nodeFromJSON(s))):t.nodeFromJSON(e)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",s),gs("",t,n)}if(typeof e=="string"){const s=qm.fromSchema(t);return n.slice?s.parseSlice(Yc(e),n.parseOptions).content:s.parse(Yc(e),n.parseOptions)}return gs("",t,n)}function wx(e,t,n){const s=e.steps.length-1;if(s<t)return;const i=e.steps[s];if(!(i instanceof Bt||i instanceof Cn))return;const a=e.mapping.maps[s];let l=0;a.forEach((c,u,d,p)=>{l===0&&(l=p)}),e.setSelection(fe.near(e.doc.resolve(l),n))}const Cx=e=>e.toString().startsWith("<"),Sx=(e,t,n)=>({tr:s,dispatch:i,editor:a})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const l=gs(t,a.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if(l.toString()==="<>")return!0;let{from:c,to:u}=typeof e=="number"?{from:e,to:e}:e,d=!0,p=!0;if((Cx(l)?l:[l]).forEach(f=>{f.check(),d=d?f.isText&&f.marks.length===0:!1,p=p?f.isBlock:!1}),c===u&&p){const{parent:f}=s.doc.resolve(c);f.isTextblock&&!f.type.spec.code&&!f.childCount&&(c-=1,u+=1)}d?Array.isArray(t)?s.insertText(t.map(f=>f.text||"").join(""),c,u):typeof t=="object"&&t&&t.text?s.insertText(t.text,c,u):s.insertText(t,c,u):s.replaceWith(c,u,l),n.updateSelection&&wx(s,s.steps.length-1,-1)}return!0},kx=()=>({state:e,dispatch:t})=>De.joinUp(e,t),Tx=()=>({state:e,dispatch:t})=>De.joinDown(e,t),Dx=()=>({state:e,dispatch:t})=>De.joinBackward(e,t),Mx=()=>({state:e,dispatch:t})=>De.joinForward(e,t);function Kc(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function zx(e){const t=e.split(/-(?!$)/);let n=t[t.length-1];n==="Space"&&(n=" ");let s,i,a,l;for(let c=0;c<t.length-1;c+=1){const u=t[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))s=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))a=!0;else if(/^mod$/i.test(u))Vi()||Kc()?l=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return s&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),l&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}const Ix=e=>({editor:t,view:n,tr:s,dispatch:i})=>{const a=zx(e).split(/-(?!$)/),l=a.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),u=t.captureTransaction(()=>{n.someProp("handleKeyDown",d=>d(n,c))});return u==null||u.steps.forEach(d=>{const p=d.map(s.mapping);p&&i&&s.maybeStep(p)}),!0};function Ni(e,t,n={}){const{from:s,to:i,empty:a}=e.selection,l=t?Oe(t,e.schema):null,c=[];e.doc.nodesBetween(s,i,(h,f)=>{if(h.isText)return;const m=Math.max(s,f),y=Math.min(i,f+h.nodeSize);c.push({node:h,from:m,to:y})});const u=i-s,d=c.filter(h=>l?l.name===h.node.type.name:!0).filter(h=>fs(h.node.attrs,n,{strict:!1}));return a?!!d.length:d.reduce((h,f)=>h+f.to-f.from,0)>=u}const Ex=(e,t={})=>({state:n,dispatch:s})=>{const i=Oe(e,n.schema);return Ni(n,i,t)?De.lift(n,s):!1},Ax=()=>({state:e,dispatch:t})=>De.liftEmptyBlock(e,t),Px=e=>({state:t,dispatch:n})=>{const s=Oe(e,t.schema);return _i.liftListItem(s)(t,n)},Ox=()=>({state:e,dispatch:t})=>De.newlineInCode(e,t);function Xc(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function Jc(e,t){const n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((s,i)=>(n.includes(i)||(s[i]=e[i]),s),{})}const Lx=(e,t)=>({tr:n,state:s,dispatch:i})=>{let a=null,l=null;const c=Xc(typeof e=="string"?e:e.name,s.schema);return c?(c==="node"&&(a=Oe(e,s.schema)),c==="mark"&&(l=ln(e,s.schema)),i&&n.selection.ranges.forEach(u=>{s.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,p)=>{a&&a===d.type&&n.setNodeMarkup(p,void 0,Jc(d.attrs,t)),l&&d.marks.length&&d.marks.forEach(h=>{l===h.type&&n.addMark(p,p+d.nodeSize,l.create(Jc(h.attrs,t)))})})}),!0):!1},Bx=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),qx=()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),Vx=()=>({state:e,dispatch:t})=>De.selectNodeBackward(e,t),Nx=()=>({state:e,dispatch:t})=>De.selectNodeForward(e,t),$x=()=>({state:e,dispatch:t})=>De.selectParentNode(e,t),Fx=()=>({state:e,dispatch:t})=>De.selectTextblockEnd(e,t),Gx=()=>({state:e,dispatch:t})=>De.selectTextblockStart(e,t);function Wx(e,t,n={}){return gs(e,t,{slice:!1,parseOptions:n})}const Rx=(e,t=!1,n={})=>({tr:s,editor:i,dispatch:a})=>{const{doc:l}=s,c=Wx(e,i.schema,n);return a&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!t),!0};function Qx(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Ux(e,t){for(let n=e.depth;n>0;n-=1){const s=e.node(n);if(t(s))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:s}}}function $i(e){return t=>Ux(t.$from,e)}function Yx(e,t){const n=ln(t,e.schema),{from:s,to:i,empty:a}=e.selection,l=[];a?(e.storedMarks&&l.push(...e.storedMarks),l.push(...e.selection.$head.marks())):e.doc.nodesBetween(s,i,u=>{l.push(...u.marks)});const c=l.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function ms(e,t,n){return Object.fromEntries(Object.entries(n).filter(([s])=>{const i=e.find(a=>a.type===t&&a.name===s);return i?i.attribute.keepOnSplit:!1}))}function Kx(e,t,n={}){const{empty:s,ranges:i}=e.selection,a=t?ln(t,e.schema):null;if(s)return!!(e.storedMarks||e.selection.$from.marks()).filter(h=>a?a.name===h.type.name:!0).find(h=>fs(h.attrs,n,{strict:!1}));let l=0;const c=[];if(i.forEach(({$from:h,$to:f})=>{const m=h.pos,y=f.pos;e.doc.nodesBetween(m,y,(j,k)=>{if(!j.isText&&!j.marks.length)return;const S=Math.max(m,k),T=Math.min(y,k+j.nodeSize),z=T-S;l+=z,c.push(...j.marks.map(I=>({mark:I,from:S,to:T})))})}),l===0)return!1;const u=c.filter(h=>a?a.name===h.mark.type.name:!0).filter(h=>fs(h.mark.attrs,n,{strict:!1})).reduce((h,f)=>h+f.to-f.from,0),d=c.filter(h=>a?h.mark.type!==a&&h.mark.type.excludes(a):!0).reduce((h,f)=>h+f.to-f.from,0);return(u>0?u+d:u)>=l}function Zc(e,t){const{nodeExtensions:n}=Hm(t),s=n.find(l=>l.name===e);if(!s)return!1;const i={name:s.name,options:s.options,storage:s.storage},a=jt(nt(s,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function Xx(e,t,n){var s;const{selection:i}=t;let a=null;if(Uc(i)&&(a=i.$cursor),a){const c=(s=e.storedMarks)!==null&&s!==void 0?s:a.marks();return!!n.isInSet(c)||!c.some(u=>u.type.excludes(n))}const{ranges:l}=i;return l.some(({$from:c,$to:u})=>{let d=c.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(c.pos,u.pos,(p,h,f)=>{if(d)return!1;if(p.isInline){const m=!f||f.type.allowsMarkType(n),y=!!n.isInSet(p.marks)||!p.marks.some(j=>j.type.excludes(n));d=m&&y}return!d}),d})}const Jx=(e,t={})=>({tr:n,state:s,dispatch:i})=>{const{selection:a}=n,{empty:l,ranges:c}=a,u=ln(e,s.schema);if(i)if(l){const d=Yx(s,u);n.addStoredMark(u.create({...d,...t}))}else c.forEach(d=>{const p=d.$from.pos,h=d.$to.pos;s.doc.nodesBetween(p,h,(f,m)=>{const y=Math.max(m,p),j=Math.min(m+f.nodeSize,h);f.marks.find(S=>S.type===u)?f.marks.forEach(S=>{u===S.type&&n.addMark(y,j,u.create({...S.attrs,...t}))}):n.addMark(y,j,u.create(t))})});return Xx(s,n,u)},Zx=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),Hx=(e,t={})=>({state:n,dispatch:s,chain:i})=>{const a=Oe(e,n.schema);return a.isTextblock?i().command(({commands:l})=>De.setBlockType(a,t)(n)?!0:l.clearNodes()).command(({state:l})=>De.setBlockType(a,t)(l,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},ey=e=>({tr:t,dispatch:n})=>{if(n){const{doc:s}=t,i=Sn(e,0,s.content.size),a=tt.create(s,i);t.setSelection(a)}return!0},ty=e=>({tr:t,dispatch:n})=>{if(n){const{doc:s}=t,{from:i,to:a}=typeof e=="number"?{from:e,to:e}:e,l=Se.atStart(s).from,c=Se.atEnd(s).to,u=Sn(i,l,c),d=Sn(a,l,c),p=Se.create(s,u,d);t.setSelection(p)}return!0},ny=e=>({state:t,dispatch:n})=>{const s=Oe(e,t.schema);return _i.sinkListItem(s)(t,n)};function Hc(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const s=n.filter(i=>t==null?void 0:t.includes(i.type.name));e.tr.ensureMarks(s)}}const ry=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:s,editor:i})=>{const{selection:a,doc:l}=t,{$from:c,$to:u}=a,d=i.extensionManager.attributes,p=ms(d,c.node().type.name,c.node().attrs);if(a instanceof tt&&a.node.isBlock)return!c.parentOffset||!ds(l,c.pos)?!1:(s&&(e&&Hc(n,i.extensionManager.splittableMarks),t.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;if(s){const h=u.parentOffset===u.parent.content.size;a instanceof Se&&t.deleteSelection();const f=c.depth===0?void 0:Qx(c.node(-1).contentMatchAt(c.indexAfter(-1)));let m=h&&f?[{type:f,attrs:p}]:void 0,y=ds(t.doc,t.mapping.map(c.pos),1,m);if(!m&&!y&&ds(t.doc,t.mapping.map(c.pos),1,f?[{type:f}]:void 0)&&(y=!0,m=f?[{type:f,attrs:p}]:void 0),y&&(t.split(t.mapping.map(c.pos),1,m),f&&!h&&!c.parentOffset&&c.parent.type!==f)){const j=t.mapping.map(c.before()),k=t.doc.resolve(j);c.node(-1).canReplaceWith(k.index(),k.index()+1,f)&&t.setNodeMarkup(t.mapping.map(c.before()),f)}e&&Hc(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return!0},sy=e=>({tr:t,state:n,dispatch:s,editor:i})=>{var a;const l=Oe(e,n.schema),{$from:c,$to:u}=n.selection,d=n.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const p=c.node(-1);if(p.type!==l)return!1;const h=i.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(s){let k=H.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let R=c.depth-S;R>=c.depth-3;R-=1)k=H.from(c.node(R).copy(k));const T=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,z=ms(h,c.node().type.name,c.node().attrs),I=((a=l.contentMatch.defaultType)===null||a===void 0?void 0:a.createAndFill(z))||void 0;k=k.append(H.from(l.createAndFill(null,I)||void 0));const E=c.before(c.depth-(S-1));t.replace(E,c.after(-T),new re(k,4-S,0));let N=-1;t.doc.nodesBetween(E,t.doc.content.size,(R,pe)=>{if(N>-1)return!1;R.isTextblock&&R.content.size===0&&(N=pe+1)}),N>-1&&t.setSelection(Se.near(t.doc.resolve(N))),t.scrollIntoView()}return!0}const f=u.pos===c.end()?p.contentMatchAt(0).defaultType:null,m=ms(h,p.type.name,p.attrs),y=ms(h,c.node().type.name,c.node().attrs);t.delete(c.pos,u.pos);const j=f?[{type:l,attrs:m},{type:f,attrs:y}]:[{type:l,attrs:m}];if(!ds(t.doc,c.pos,2))return!1;if(s){const{selection:k,storedMarks:S}=n,{splittableMarks:T}=i.extensionManager,z=S||k.$to.parentOffset&&k.$from.marks();if(t.split(c.pos,2,j).scrollIntoView(),!z||!s)return!0;const I=z.filter(E=>T.includes(E.type.name));t.ensureMarks(I)}return!0},Fi=(e,t)=>{const n=$i(l=>l.type===t)(e.selection);if(!n)return!0;const s=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(s===void 0)return!0;const i=e.doc.nodeAt(s);return n.node.type===(i==null?void 0:i.type)&&qc(e.doc,n.pos)&&e.join(n.pos),!0},Gi=(e,t)=>{const n=$i(l=>l.type===t)(e.selection);if(!n)return!0;const s=e.doc.resolve(n.start).after(n.depth);if(s===void 0)return!0;const i=e.doc.nodeAt(s);return n.node.type===(i==null?void 0:i.type)&&qc(e.doc,s)&&e.join(s),!0};var iy=Object.freeze({__proto__:null,blur:ix,clearContent:ax,clearNodes:ox,command:lx,createParagraphNear:cx,deleteCurrentNode:ux,deleteNode:dx,deleteRange:px,deleteSelection:hx,enter:fx,exitCode:gx,extendMarkRange:xx,first:yx,focus:vx,forEach:_x,insertContent:jx,insertContentAt:Sx,joinUp:kx,joinDown:Tx,joinBackward:Dx,joinForward:Mx,keyboardShortcut:Ix,lift:Ex,liftEmptyBlock:Ax,liftListItem:Px,newlineInCode:Ox,resetAttributes:Lx,scrollIntoView:Bx,selectAll:qx,selectNodeBackward:Vx,selectNodeForward:Nx,selectParentNode:$x,selectTextblockEnd:Fx,selectTextblockStart:Gx,setContent:Rx,setMark:Jx,setMeta:Zx,setNode:Hx,setNodeSelection:ey,setTextSelection:ty,sinkListItem:ny,splitBlock:ry,splitListItem:sy,toggleList:(e,t,n,s={})=>({editor:i,tr:a,state:l,dispatch:c,chain:u,commands:d,can:p})=>{const{extensions:h,splittableMarks:f}=i.extensionManager,m=Oe(e,l.schema),y=Oe(t,l.schema),{selection:j,storedMarks:k}=l,{$from:S,$to:T}=j,z=S.blockRange(T),I=k||j.$to.parentOffset&&j.$from.marks();if(!z)return!1;const E=$i(N=>Zc(N.type.name,h))(j);if(z.depth>=1&&E&&z.depth-E.depth<=1){if(E.node.type===m)return d.liftListItem(y);if(Zc(E.node.type.name,h)&&m.validContent(E.node.content)&&c)return u().command(()=>(a.setNodeMarkup(E.pos,m),!0)).command(()=>Fi(a,m)).command(()=>Gi(a,m)).run()}return!n||!I||!c?u().command(()=>p().wrapInList(m,s)?!0:d.clearNodes()).wrapInList(m,s).command(()=>Fi(a,m)).command(()=>Gi(a,m)).run():u().command(()=>{const N=p().wrapInList(m,s),R=I.filter(pe=>f.includes(pe.type.name));return a.ensureMarks(R),N?!0:d.clearNodes()}).wrapInList(m,s).command(()=>Fi(a,m)).command(()=>Gi(a,m)).run()},toggleMark:(e,t={},n={})=>({state:s,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,l=ln(e,s.schema);return Kx(s,l,t)?i.unsetMark(l,{extendEmptyMarkRange:a}):i.setMark(l,t)},toggleNode:(e,t,n={})=>({state:s,commands:i})=>{const a=Oe(e,s.schema),l=Oe(t,s.schema);return Ni(s,a,n)?i.setNode(l):i.setNode(a,n)},toggleWrap:(e,t={})=>({state:n,commands:s})=>{const i=Oe(e,n.schema);return Ni(n,i,t)?s.lift(i):s.wrapIn(i,t)},undoInputRule:()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let s=0;s<n.length;s+=1){const i=n[s];let a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){const l=e.tr,c=a.transform;for(let u=c.steps.length-1;u>=0;u-=1)l.step(c.steps[u].invert(c.docs[u]));if(a.text){const u=l.doc.resolve(a.from).marks();l.replaceWith(a.from,a.to,e.schema.text(a.text,u))}else l.delete(a.from,a.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:s,ranges:i}=n;return s||t&&i.forEach(a=>{e.removeMark(a.$from.pos,a.$to.pos)}),!0},unsetMark:(e,t={})=>({tr:n,state:s,dispatch:i})=>{var a;const{extendEmptyMarkRange:l=!1}=t,{selection:c}=n,u=ln(e,s.schema),{$from:d,empty:p,ranges:h}=c;if(!i)return!0;if(p&&l){let{from:f,to:m}=c;const y=(a=d.marks().find(k=>k.type===u))===null||a===void 0?void 0:a.attrs,j=Qc(d,u,y);j&&(f=j.from,m=j.to),n.removeMark(f,m,u)}else h.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,u)});return n.removeStoredMark(u),!0},updateAttributes:(e,t={})=>({tr:n,state:s,dispatch:i})=>{let a=null,l=null;const c=Xc(typeof e=="string"?e:e.name,s.schema);return c?(c==="node"&&(a=Oe(e,s.schema)),c==="mark"&&(l=ln(e,s.schema)),i&&n.selection.ranges.forEach(u=>{const d=u.$from.pos,p=u.$to.pos;s.doc.nodesBetween(d,p,(h,f)=>{a&&a===h.type&&n.setNodeMarkup(f,void 0,{...h.attrs,...t}),l&&h.marks.length&&h.marks.forEach(m=>{if(l===m.type){const y=Math.max(f,d),j=Math.min(f+h.nodeSize,p);n.addMark(y,j,l.create({...m.attrs,...t}))}})})}),!0):!1},wrapIn:(e,t={})=>({state:n,dispatch:s})=>{const i=Oe(e,n.schema);return De.wrapIn(i,t)(n,s)},wrapInList:(e,t={})=>({state:n,dispatch:s})=>{const i=Oe(e,n.schema);return _i.wrapInList(i,t)(n,s)}});qt.create({name:"commands",addCommands(){return{...iy}}}),qt.create({name:"editable",addProseMirrorPlugins(){return[new xr({key:new yr("editable"),props:{editable:()=>this.editor.options.editable}})]}}),qt.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new xr({key:new yr("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const s=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(s),!1},blur:(t,n)=>{e.isFocused=!1;const s=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(s),!1}}}})]}}),qt.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:u,doc:d}=c,{empty:p,$anchor:h}=u,{pos:f,parent:m}=h,y=fe.atStart(d).from===f;return!p||!y||!m.type.isTextblock||m.textContent.length?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},i={...s},a={...s,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Vi()||Kc()?a:i},addProseMirrorPlugins(){return[new xr({key:new yr("clearDocument"),appendTransaction:(e,t,n)=>{if(!(e.some(y=>y.docChanged)&&!t.doc.eq(n.doc)))return;const{empty:i,from:a,to:l}=t.selection,c=fe.atStart(t.doc).from,u=fe.atEnd(t.doc).to;if(i||!(a===c&&l===u)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;const h=n.tr,f=Rc({state:n,transaction:h}),{commands:m}=new Zm({editor:this.editor,state:f});if(m.clearNodes(),!!h.steps.length)return h}})]}}),qt.create({name:"tabindex",addProseMirrorPlugins(){return[new xr({key:new yr("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class xs{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=jt(nt(this,"addOptions",{name:this.name}))),this.storage=jt(nt(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new xs(t)}configure(t={}){const n=this.extend();return n.options=Bi(this.options,t),n.storage=jt(nt(n,"addStorage",{name:n.name,options:n.options})),n}extend(t={}){const n=new xs(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=jt(nt(n,"addOptions",{name:n.name})),n.storage=jt(nt(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:t,mark:n}){const{tr:s}=t.state,i=t.state.selection.$from;if(i.pos===i.end()){const l=i.marks();if(!!!l.find(d=>(d==null?void 0:d.type.name)===n.name))return!1;const u=l.find(d=>(d==null?void 0:d.type.name)===n.name);return u&&s.removeStoredMark(u),s.insertText(" ",i.pos),t.view.dispatch(s),!0}return!1}}const eu=qt.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize.replace(/['"]+/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}; line-height: 1.2; overflow: auto`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),ay=["8","10","12","14","16","18","20","24","30","36","48","60","72"].map(e=>`${e}px`),oy=[{label:"auto",value:""}].concat(ay.map(e=>({label:e,value:e}))),ly={input:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"}},cy=({editor:e})=>{const t=e.getAttributes("textStyle").fontSize;return r.jsx(Q.RichTextEditor.ControlsGroup,{children:r.jsx(o.NativeSelect,{size:"xs",icon:r.jsx(M.IconTextSize,{stroke:1.5,size:16}),data:oy,styles:ly,value:t||"",onChange:n=>{const s=n.currentTarget.value;s?e.chain().focus().setFontSize(s).run():e.chain().focus().unsetFontSize().run()}})})},Wi="function color({ variables }, { filters, context }, utils) {",tu="}",uy=[Wi,' return "red";',tu].join(`
|
|
60
60
|
`);function dy(e){const t=e.split(`
|
|
61
61
|
`);if(t.length===2)return console.warn("[getDynamicColorRestrictions]unexpected lines of code: ",e),[];const n=t[t.length-2];return n?[{range:[2,1,t.length-1,n.length+1],label:"body",allowMultiline:!0}]:[]}const py=e=>!e||e.startsWith(Wi)?e:[Wi,e,tu].join(`
|
|
62
62
|
`),nu=e=>{const n="abcdefghijklmnopqrstuvwxyz",i=`1234567890${n}${n.toUpperCase()}`.split(""),a=new Uint8Array(e);return crypto.getRandomValues(a),a.reduce((l,c)=>`${l}${i[c&61]}`,"")};function hy(e,t,n){const s={},i=l=>new Function(`return ${py(l)}`)()({variables:n},t,vt);return e.querySelectorAll("dynamic-color").forEach(l=>{const c=l.getAttribute("data-value");c&&(s[`#${l.id}`]={color:i(c)})}),s}const br="data-value",fy=br,ru="dynamicColor",su=xs.create({name:ru,addAttributes(){return{id:{default:nu(6),parseHTML:e=>e.getAttribute("id")},[br]:{default:null,parseHTML:e=>e.getAttribute(br)}}},parseHTML(){return[{tag:"dynamic-color",getAttrs:e=>typeof e=="string"?(console.debug(e),!1):[e.getAttribute(br)]}]},renderHTML({HTMLAttributes:e}){return["dynamic-color",e,0]},addCommands(){return{setDynamicColor:e=>({commands:t})=>t.setMark(this.name,{[br]:e}),unsetDynamicColor:()=>({commands:e})=>e.unsetMark(this.name)}}}),gy=({value:e,onChange:t,onMount:n})=>{const s=i=>{if(!i){t("");return}t(i)};return r.jsx(et,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:e,onChange:s,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}},onMount:n})},Nn=g.forwardRef(({value:e,onChange:t,label:n,defaultValue:s,restrictions:i=[]},a)=>{const{t:l}=_.useTranslation(),[c,u]=g.useState(e),d=()=>{t(c)},p=()=>{u(e)},h=()=>{u(s)};g.useEffect(()=>{u(e)},[e]);const f=g.useCallback((j,k)=>{if(i.length===0)return;const S=Mg.constrainedEditor(k),T=j.getModel();if(S.initializeIn(j),S.addRestrictionsTo(T,i),!!T&&!T._hasHighlight){S.toggleDevMode(),T.toggleHighlightOfEditableAreas();const z=T.getCurrentEditableRanges(),I=T.getValueInEditableRanges();console.debug({model:T,currentRanges:z,currentValue:I})}},[]),m=c!==e,y=typeof c=="string"&&c.length===0;return r.jsxs(o.Stack,{spacing:4,sx:{height:"100%",".editableArea--multi-line":{backgroundColor:"rgba(255,183,78, 0.1)"},".editableArea--single-line":{backgroundColor:"rgba(255,183,78, 0.1)"}},children:[r.jsxs(o.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[r.jsx(o.Group,{position:"left",children:r.jsx(iu,{})}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:h,size:"xs",variant:"default",leftIcon:r.jsx(M.IconPlayerSkipBack,{size:16}),children:l("common.actions.reset_to_default")}),r.jsx(o.Button,{onClick:p,color:"red",size:"xs",disabled:!m,leftIcon:r.jsx(M.IconRecycle,{size:16}),children:l("common.actions.revert_changes")}),r.jsx(o.Button,{color:"green",size:"xs",onClick:d,disabled:!m,leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),children:l("common.actions.save_changes")})]})]}),r.jsx(o.Text,{size:14,children:n}),r.jsxs(o.Box,{sx:{position:"relative",flexGrow:1},children:[y&&r.jsx(o.Overlay,{center:!0,color:"#fff",opacity:.5,children:r.jsx(o.Button,{color:"blue",radius:"xl",onClick:h,children:l("common.actions.init_with_default")})}),r.jsx(gy,{value:c,onChange:u,onMount:f})]})]})}),Ri=g.forwardRef(({title:e,value:t,onChange:n,label:s,description:i=null,triggerLabel:a="Edit",triggerButtonProps:l={},renderTriggerButton:c,defaultValue:u,zIndex:d=320,restrictions:p},h)=>{const[f,{open:m,close:y}]=he.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Modal,{opened:f,onClose:y,title:e,withinPortal:!0,zIndex:d,size:"900px",children:[i,r.jsx(o.Box,{h:600,children:r.jsx(Nn,{value:t,onChange:n,defaultValue:u,label:s,restrictions:p})})]}),c==null?void 0:c({onClick:m}),!c&&r.jsx(o.Button,{onClick:m,...l,children:a})]})}),my=({onClick:e})=>{const{t}=_.useTranslation();return r.jsx(o.Tooltip,{label:t("rich_text.dynamic_color.label"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"rgb(190, 75, 219)"},onClick:e,children:r.jsx(M.IconMathFunction,{stroke:2,size:16})})})},xy=({editor:e})=>{const{t}=_.useTranslation(),n=e.getAttributes(ru)[fy]??"";return r.jsx(Ri,{title:t("rich_text.dynamic_color.edit"),label:"",triggerLabel:"",value:n,onChange:s=>{s?e.chain().focus().setDynamicColor(s).run():e.chain().focus().unsetDynamicColor().run()},defaultValue:uy,renderTriggerButton:my,restrictions:dy(n),zIndex:340})},vr=({value:e,styles:t={},sx:n={},dashboardState:s=Yi(),varaiables:i={}})=>{const a=ic.useEditor({extensions:[ac,sc,Q.Link,Jl,Xl,Yl,ec.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),rc,nc,tc,Zl.configure({types:["heading","paragraph"]}),Kl.configure({placeholder:"This is placeholder"}),Hl,Ul.Color,eu,su],content:e,editable:!1});g.useEffect(()=>{a==null||a.commands.setContent(e)},[e,a]);const l=g.useMemo(()=>new DOMParser().parseFromString(e,"text/html"),[e]),c=g.useMemo(()=>hy(l,s,i),[l,s,i]),u=g.useMemo(()=>v.defaultsDeep({},{content:{...Ti,...c}},t),[t,c]);return r.jsx(Q.RichTextEditor,{editor:a,styles:u,sx:n,children:r.jsx(Q.RichTextEditor.Content,{})})};function iu(){const{t:e}=_.useTranslation(),[t,{open:n,close:s}]=he.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:s,title:e("function_utils.modal_title"),zIndex:330,withinPortal:!0,children:r.jsx(vr,{value:Cm(e),styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),r.jsx(o.Button,{variant:"light",color:"violet",size:"xs",onClick:n,leftIcon:r.jsx(M.IconInfoCircle,{size:16}),children:e("function_utils.trigger_text")})]})}const au=g.forwardRef((e,t)=>{const{label:n,description:s,...i}=e;return r.jsx("div",{ref:t,...i,children:r.jsxs(o.Group,{position:"apart",noWrap:!0,children:[r.jsx(o.Text,{children:n}),r.jsx(o.Text,{size:"xs",color:"dimmed",children:s})]})})}),Qi=({value:e,onChange:t,height:n="200px",defaultLanguage:s="sql",theme:i="vs-dark"})=>{const a=c=>{t==null||t(c??"")},l=!t;return r.jsx(et,{className:"minimal-monaco-editor",height:n,defaultLanguage:s,value:e,onChange:l?void 0:a,theme:i,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!t,"semanticHighlighting.enabled":!0}})},yy={"dynamic-color":{position:"relative"},"dynamic-color:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"1px",border:"double 1px purple"}};function by(){const{editor:e}=Q.useRichTextEditorContext();return r.jsx(Q.RichTextEditor.Control,{onClick:()=>e==null?void 0:e.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}),"aria-label":"Insert table",title:"Insert table",children:r.jsx(M.IconBorderAll,{stroke:1.5,size:16})})}const ys=g.forwardRef(({value:e,onChange:t,styles:n={},label:s,autoSubmit:i,onSubmit:a},l)=>{const[c,u]=g.useState(e),d=ic.useEditor({extensions:[ac,sc,Q.Link,Jl,Xl,Yl,ec.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),rc,nc,tc,Zl.configure({types:["heading","paragraph"]}),Kl.configure({placeholder:"This is placeholder"}),Hl,Ul.Color,eu,su],content:c,onUpdate:({editor:m})=>{const y=m.getHTML();u(y)}});g.useEffect(()=>{u(m=>e===m?m:(d==null||d.commands.setContent(e),e))},[e]);const p=()=>{t(c),a==null||a()},h=e!==c;g.useEffect(()=>{i&&p()},[i,h]);const f=g.useMemo(()=>v.defaultsDeep({},{content:{...Ti,...yy}},n),[n]);return d?r.jsxs(o.Stack,{spacing:4,sx:{flexGrow:1,position:"relative"},children:[r.jsxs(o.Group,{align:"center",children:[r.jsx(o.Text,{size:14,fw:500,children:s}),!i&&r.jsx(o.ActionIcon,{color:"green",disabled:!h,onClick:p,children:r.jsx(M.IconDeviceFloppy,{size:18})})]}),r.jsxs(Q.RichTextEditor,{editor:d,styles:f,children:[r.jsxs(Q.RichTextEditor.Toolbar,{sticky:!0,stickyOffset:0,children:[r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.ColorPicker,{colors:["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"],popoverProps:{zIndex:320}}),r.jsx(xy,{editor:d})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Bold,{}),r.jsx(Q.RichTextEditor.Italic,{}),r.jsx(Q.RichTextEditor.Underline,{}),r.jsx(Q.RichTextEditor.ClearFormatting,{}),r.jsx(Q.RichTextEditor.Highlight,{}),r.jsx(Q.RichTextEditor.Code,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.H1,{}),r.jsx(Q.RichTextEditor.H2,{}),r.jsx(Q.RichTextEditor.H3,{}),r.jsx(Q.RichTextEditor.H4,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Blockquote,{}),r.jsx(Q.RichTextEditor.Hr,{}),r.jsx(Q.RichTextEditor.BulletList,{}),r.jsx(Q.RichTextEditor.OrderedList,{}),r.jsx(Q.RichTextEditor.Subscript,{}),r.jsx(Q.RichTextEditor.Superscript,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Link,{}),r.jsx(Q.RichTextEditor.Unlink,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.AlignLeft,{}),r.jsx(Q.RichTextEditor.AlignCenter,{}),r.jsx(Q.RichTextEditor.AlignJustify,{}),r.jsx(Q.RichTextEditor.AlignRight,{})]}),r.jsx(Q.RichTextEditor.ControlsGroup,{children:r.jsx(by,{})}),r.jsx(cy,{editor:d})]}),r.jsx(Q.RichTextEditor.Content,{})]})]}):null});function vy(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Vt({data_field:e,aggregation:t},n){return is(n,e,t)}function rt({formatter:e,aggregation:t},n){if(typeof n!="string"&&typeof n!="number")return vy(n);if(t.type==="custom")return n;try{return U(n,e)}catch(s){return console.error(s),n}}function ou(e,t){return e.replaceAll(/(\$\{([^{\}]+(?=}))\})/g,(...s)=>{const i=s[2],a=t.variableStyleMap[i];if(!a)return`{{${i}}}`;const{variable:l,...c}=a,u=Object.entries(c).map(([f,m])=>`${f}:${m}`).join(";"),d=l.color;if(d.type!=="continuous")return`<span style="${u}">{{${i}}}</span>`;const p=nu(6),h=`try {
|
|
@@ -71,7 +71,7 @@ Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(
|
|
|
71
71
|
${Object.entries(t).map(([s,i])=>`const ${s} = '${i}';`).join(`
|
|
72
72
|
`)}
|
|
73
73
|
return ${e};
|
|
74
|
-
`)(n)}catch(s){return console.error(s),console.log(e),e}}function pu(e,t,n,s){const i=Oy(t,s);return e.replaceAll(/(\{\{([^{\}]+(?=}))\}\})/g,(...l)=>{const c=l[2];if(!c)return c;const u=i[c];if(u)return u;const d=Ly(c);return By(d,i,n)})}function qy(e,t){const n=lc.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function Vy({query:e,name:t,payload:n,additionals:s},i){if(!e.sql)return[];const{type:a,key:l,sql:c,pre_process:u,post_process:d}=e,p=wi(c,n),h=Sm({sql:p,pre_process:u}),f=lc.encode(h);qy(h,f);let m=await Ot.query(i)({type:a,key:l,query:f,...s},{params:{name:t}});return m=km(d,m,Ki(n)),m}async function Ny({type:e,key:t,configString:n,name:s,additionals:i},a){try{return await Ot.httpDataSourceQuery(a)({type:e,key:t,query:n,...i},{params:{name:s}})}catch(l){if(At.isCancel(l))throw l;return console.error(l),l}}async function Xi(){try{return(await Ot.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function hu(){try{return(await Ot.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class fu{constructor(t){B(this,"rootRef");this.rootRef=X.observable({current:t})}async deleteItem(t){X.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?X.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(v.isObject(n))X.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else X.runInAction(()=>{v.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,s){return X.reaction(()=>this.getValueFromRoot(t),(i,a)=>{n(i,a)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class $y{constructor(){B(this,"channels",new Map);B(this,"globalChannel",new cc)}getChannel(t){const n=this.channels.get(t);if(n)return n;const s=new cc;return this.channels.set(t,s),s}}class Fy{constructor(t){B(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new $y,instanceData:new fu(t.viz.conf)};return this.instances.set(t.id,s),s}}function gu(e,t,n,s){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new fu({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const Gy=e=>{const{panel:t,measure:n,vizManager:s,data:i,variables:a}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={...gu(c,i,s,a),viewport:{width:n.w,height:n.h}},d=l.viewRender;return r.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},Wy=e=>{const{vizManager:t,panel:n,data:s,variables:i}=e,a=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...gu(l,s,t,i)},u=a.configRender;return r.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},mu=(e,t)=>{const n=Qt.bezier(e),s=Qt.bezier(t);return function(i){return i<50?n(i*2/100).hex():s((i-50)*2/100).hex()}},_s=e=>{const t=Qt.bezier(e);return function(n){return t(n/100).hex()}},Ry={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:mu(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Qy={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:mu(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Uy={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:_s(["#fff7f1","darkred"]),name:"red",category:"sequential"},Yy={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:_s(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ky={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:_s(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Xy={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:_s(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Jy{constructor(t){B(this,"symbol");this.symbol=Symbol(t)}}function Kt(e){return new Jy(e)}class Ji{constructor(){B(this,"parent");B(this,"factoryRegistry",new Map);B(this,"instanceRegistry",new Map)}createScoped(){const t=new Ji;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const s=n(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=v.get(t,"dispose");v.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const xu="13.23.2",Zy=Object.freeze(Object.defineProperty({__proto__:null,version:xu},Symbol.toStringTag,{value:"Module"}));class Hy{constructor(t){B(this,"staticColors",new Map);B(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class eb{constructor(){B(this,"plugins",new Map);B(this,"vizComponents",new Map);B(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class tb{constructor(){B(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,s){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),a=v.orderBy(i,"version","asc");if(((l=v.last(a))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return a.reduce((c,u)=>u.handler(c,s),n)}}class me extends tb{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(s,i)=>({version:t,...n(s,i)}))}async migrate({configData:t,panelModel:n}){const s=await t.getItem(null),i=v.get(s,"version",0),a=this.run({from:i,to:this.VERSION},s,{panelModel:n});await t.setItem(null,a)}async needMigration({configData:t}){const n=await t.getItem(null);return v.get(n,"version",0)<this.VERSION}}const $=(e,t)=>{const[n,{setFalse:s}]=W.useBoolean(!0),[i,a]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{a(c),s()}),e.watchItem(t,c=>{a(c)})));const l=g.useCallback(async c=>{await e.setItem(t,c),a(c)},[e,t]);return{loading:n,value:i,set:l}},Qe={top:16,right:16,bottom:16,left:16},wt=e=>Math.max(0,e-Qe.left-Qe.right),Ct=e=>Math.max(0,e-Qe.top-Qe.bottom),jr=(e,t)=>({width:wt(e),height:Ct(t)}),Ue=({width:e,height:t,children:n})=>r.jsx(o.Box,{pt:Qe.top,pr:Qe.right,pb:Qe.bottom,pl:Qe.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),Zi={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function nb({context:e}){const{value:t}=$(e.instanceData,"config"),n=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=v.defaults({},t,Zi),h=g.useMemo(()=>rs(n,a),[n,a]),{x:f,y:m,z:y}=g.useMemo(()=>({x:O(a),y:O(l),z:O(c)}),[a,l,c]),{min:j,max:k}=g.useMemo(()=>{const T=v.minBy(h,I=>I[y.columnKey]),z=v.maxBy(h,I=>I[y.columnKey]);return{min:v.get(T,y.columnKey),max:v.get(z,y.columnKey)}},[h,y]),S={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:k,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:p,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(T=>[T[f.columnKey],T[m.columnKey],T[y.columnKey]])}]};return t?r.jsx(Ue,{width:s,height:i,children:r.jsx(Pe,{echarts:Ae,option:S,style:jr(s,i),notMerge:!0,theme:"merico-light"})}):null}const yu=g.createContext(null),Hi=yu.Provider;function ea(){const e=g.useContext(yu);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const Z=()=>ea(),bu=()=>ea(),vu=g.createContext({searchButtonProps:{}}),ta=vu.Provider;function _u(){return g.useContext(vu)}const ju=g.createContext(null),na=ju.Provider;function wu(){const e=g.useContext(ju);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const Y=()=>wu(),_e=()=>wu(),rb={inEditMode:!1},js=g.createContext(rb),Cu=g.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),ra=Cu.Provider;function Su(){const e=g.useContext(Cu);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const St=()=>Su(),Ge=()=>Su(),sb={fullScreenPanelID:"",setFullScreenPanelID:v.noop},sa=g.createContext(sb);function ku(){const e=g.useContext(sa);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const ib={en:"en",zh:"zh-cn"};function ia({children:e}){const{i18n:t}=_.useTranslation(),n=g.useMemo(()=>{const s=t.language;return ib[s]??"en"},[t.language]);return r.jsx(uc.DatesProvider,{settings:{locale:n,firstDayOfWeek:1},children:e})}const F=D.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,queryID:a,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Ge(),h=g.useMemo(()=>p.dataFieldOptions(s,l,a),[s,l,a]);if(h.length===0){const f=p.explainDataKey(s);return r.jsxs(o.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Box,{children:r.jsx(o.TextInput,{label:e,required:t,defaultValue:f.columnKey,readOnly:!0,disabled:!0})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(o.Text,{size:"xs",color:f.queryName?"black":"red",sx:{fontFamily:"monospace"},children:f.queryName??f.queryID}),r.jsx(o.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),r.jsx(o.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:f.columnKey})]})})]})}return r.jsx(o.Select,{ref:d,label:e,description:n,data:h,value:s,onChange:i,required:t,sx:c,maxDropdownHeight:500,...u})}));function ab({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=v.defaults({},t,Zi),{control:i,handleSubmit:a,reset:l}=b.useForm({defaultValues:s});return g.useEffect(()=>{l(s)},[t]),t?r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(o.Text,{children:"X Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Y Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Z Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:r.jsxs(o.Button,{color:"blue",type:"submit",children:[r.jsx(V.DeviceFloppy,{size:20}),r.jsx(o.Text,{ml:"md",children:"Save"})]})})]})}):null}const ob=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function lb(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(a),z_axis_data_key:s(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class cb extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:lb(i,s)}})}}const ub={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new cb,name:"bar-3d",viewRender:nb,configRender:ab,createConfig(){return{version:2,config:v.cloneDeep(Zi)}},translation:ob},db=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(o.Box,{sx:{position:"relative"},children:[e&&r.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function Ye({enabled:e,func_content:t}){return(n,s)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function Le(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
74
|
+
`)(n)}catch(s){return console.error(s),console.log(e),e}}function pu(e,t,n,s){const i=Oy(t,s);return e.replaceAll(/(\{\{([^{\}]+(?=}))\}\})/g,(...l)=>{const c=l[2];if(!c)return c;const u=i[c];if(u)return u;const d=Ly(c);return By(d,i,n)})}function qy(e,t){const n=lc.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function Vy({query:e,name:t,payload:n,additionals:s},i){if(!e.sql)return[];const{type:a,key:l,sql:c,pre_process:u,post_process:d}=e,p=wi(c,n),h=Sm({sql:p,pre_process:u}),f=lc.encode(h);qy(h,f);let m=await Ot.query(i)({type:a,key:l,query:f,...s},{params:{name:t}});return m=km(d,m,Ki(n)),m}async function Ny({type:e,key:t,configString:n,name:s,additionals:i},a){try{return await Ot.httpDataSourceQuery(a)({type:e,key:t,query:n,...i},{params:{name:s}})}catch(l){if(At.isCancel(l))throw l;return console.error(l),l}}async function Xi(){try{return(await Ot.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function hu(){try{return(await Ot.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class fu{constructor(t){B(this,"rootRef");this.rootRef=X.observable({current:t})}async deleteItem(t){X.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?X.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(v.isObject(n))X.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else X.runInAction(()=>{v.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,s){return X.reaction(()=>this.getValueFromRoot(t),(i,a)=>{n(i,a)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class $y{constructor(){B(this,"channels",new Map);B(this,"globalChannel",new cc)}getChannel(t){const n=this.channels.get(t);if(n)return n;const s=new cc;return this.channels.set(t,s),s}}class Fy{constructor(t){B(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new $y,instanceData:new fu(t.viz.conf)};return this.instances.set(t.id,s),s}}function gu(e,t,n,s){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new fu({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const Gy=e=>{const{panel:t,measure:n,vizManager:s,data:i,variables:a}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={...gu(c,i,s,a),viewport:{width:n.w,height:n.h}},d=l.viewRender;return r.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},Wy=e=>{const{vizManager:t,panel:n,data:s,variables:i}=e,a=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...gu(l,s,t,i)},u=a.configRender;return r.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},mu=(e,t)=>{const n=Qt.bezier(e),s=Qt.bezier(t);return function(i){return i<50?n(i*2/100).hex():s((i-50)*2/100).hex()}},_s=e=>{const t=Qt.bezier(e);return function(n){return t(n/100).hex()}},Ry={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:mu(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Qy={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:mu(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Uy={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:_s(["#fff7f1","darkred"]),name:"red",category:"sequential"},Yy={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:_s(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ky={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:_s(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Xy={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:_s(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Jy{constructor(t){B(this,"symbol");this.symbol=Symbol(t)}}function Kt(e){return new Jy(e)}class Ji{constructor(){B(this,"parent");B(this,"factoryRegistry",new Map);B(this,"instanceRegistry",new Map)}createScoped(){const t=new Ji;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const s=n(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=v.get(t,"dispose");v.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const xu="13.23.3",Zy=Object.freeze(Object.defineProperty({__proto__:null,version:xu},Symbol.toStringTag,{value:"Module"}));class Hy{constructor(t){B(this,"staticColors",new Map);B(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class eb{constructor(){B(this,"plugins",new Map);B(this,"vizComponents",new Map);B(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class tb{constructor(){B(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,s){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),a=v.orderBy(i,"version","asc");if(((l=v.last(a))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return a.reduce((c,u)=>u.handler(c,s),n)}}class me extends tb{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(s,i)=>({version:t,...n(s,i)}))}async migrate({configData:t,panelModel:n}){const s=await t.getItem(null),i=v.get(s,"version",0),a=this.run({from:i,to:this.VERSION},s,{panelModel:n});await t.setItem(null,a)}async needMigration({configData:t}){const n=await t.getItem(null);return v.get(n,"version",0)<this.VERSION}}const $=(e,t)=>{const[n,{setFalse:s}]=W.useBoolean(!0),[i,a]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{a(c),s()}),e.watchItem(t,c=>{a(c)})));const l=g.useCallback(async c=>{await e.setItem(t,c),a(c)},[e,t]);return{loading:n,value:i,set:l}},Qe={top:16,right:16,bottom:16,left:16},wt=e=>Math.max(0,e-Qe.left-Qe.right),Ct=e=>Math.max(0,e-Qe.top-Qe.bottom),jr=(e,t)=>({width:wt(e),height:Ct(t)}),Ue=({width:e,height:t,children:n})=>r.jsx(o.Box,{pt:Qe.top,pr:Qe.right,pb:Qe.bottom,pl:Qe.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),Zi={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function nb({context:e}){const{value:t}=$(e.instanceData,"config"),n=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=v.defaults({},t,Zi),h=g.useMemo(()=>rs(n,a),[n,a]),{x:f,y:m,z:y}=g.useMemo(()=>({x:O(a),y:O(l),z:O(c)}),[a,l,c]),{min:j,max:k}=g.useMemo(()=>{const T=v.minBy(h,I=>I[y.columnKey]),z=v.maxBy(h,I=>I[y.columnKey]);return{min:v.get(T,y.columnKey),max:v.get(z,y.columnKey)}},[h,y]),S={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:k,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:p,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(T=>[T[f.columnKey],T[m.columnKey],T[y.columnKey]])}]};return t?r.jsx(Ue,{width:s,height:i,children:r.jsx(Pe,{echarts:Ae,option:S,style:jr(s,i),notMerge:!0,theme:"merico-light"})}):null}const yu=g.createContext(null),Hi=yu.Provider;function ea(){const e=g.useContext(yu);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const Z=()=>ea(),bu=()=>ea(),vu=g.createContext({searchButtonProps:{}}),ta=vu.Provider;function _u(){return g.useContext(vu)}const ju=g.createContext(null),na=ju.Provider;function wu(){const e=g.useContext(ju);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const Y=()=>wu(),_e=()=>wu(),rb={inEditMode:!1},js=g.createContext(rb),Cu=g.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),ra=Cu.Provider;function Su(){const e=g.useContext(Cu);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const St=()=>Su(),Ge=()=>Su(),sb={fullScreenPanelID:"",setFullScreenPanelID:v.noop},sa=g.createContext(sb);function ku(){const e=g.useContext(sa);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const ib={en:"en",zh:"zh-cn"};function ia({children:e}){const{i18n:t}=_.useTranslation(),n=g.useMemo(()=>{const s=t.language;return ib[s]??"en"},[t.language]);return r.jsx(uc.DatesProvider,{settings:{locale:n,firstDayOfWeek:1},children:e})}const F=D.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,queryID:a,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Ge(),h=g.useMemo(()=>p.dataFieldOptions(s,l,a),[s,l,a]);if(h.length===0){const f=p.explainDataKey(s);return r.jsxs(o.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Box,{children:r.jsx(o.TextInput,{label:e,required:t,defaultValue:f.columnKey,readOnly:!0,disabled:!0})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(o.Text,{size:"xs",color:f.queryName?"black":"red",sx:{fontFamily:"monospace"},children:f.queryName??f.queryID}),r.jsx(o.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),r.jsx(o.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:f.columnKey})]})})]})}return r.jsx(o.Select,{ref:d,label:e,description:n,data:h,value:s,onChange:i,required:t,sx:c,maxDropdownHeight:500,...u})}));function ab({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=v.defaults({},t,Zi),{control:i,handleSubmit:a,reset:l}=b.useForm({defaultValues:s});return g.useEffect(()=>{l(s)},[t]),t?r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(o.Text,{children:"X Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Y Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Z Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:r.jsxs(o.Button,{color:"blue",type:"submit",children:[r.jsx(V.DeviceFloppy,{size:20}),r.jsx(o.Text,{ml:"md",children:"Save"})]})})]})}):null}const ob=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function lb(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(a),z_axis_data_key:s(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class cb extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:lb(i,s)}})}}const ub={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new cb,name:"bar-3d",viewRender:nb,configRender:ab,createConfig(){return{version:2,config:v.cloneDeep(Zi)}},translation:ob},db=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(o.Box,{sx:{position:"relative"},children:[e&&r.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function Ye({enabled:e,func_content:t}){return(n,s)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function Le(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
75
75
|
`)}}const kt=g.forwardRef(({value:e,onChange:t,triggerButtonText:n},s)=>{const{t:i}=_.useTranslation(),[a,{setTrue:l,setFalse:c}]=W.useBoolean(),[u,d]=g.useState(e);g.useEffect(()=>{d(e)},[e]);const p=k=>{d({...u,enabled:k})},h=()=>{c();const{enabled:k,func_content:S}=u,T={enabled:k,func_content:S};d(T),t(T)},f=()=>{c(),d(e)},m=k=>{d(S=>({...S,func_content:k}))},y=()=>{m(Le().func_content)},j=n??i("chart.axis.customize_label");return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"filled",color:"grape",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:j}),r.jsx(o.Modal,{size:800,title:j,opened:a,onClose:c,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&r.jsxs(o.Stack,{children:[r.jsx(o.Checkbox,{mt:10,label:i("common.enabled"),checked:u.enabled,onChange:k=>p(k.currentTarget.checked)}),r.jsx(db,{value:u.func_content,onChange:m,disabled:!u.enabled}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:y,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:i("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:f,variant:"subtle",children:i("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:h,children:i("common.actions.save")})]})]})]})})]})}),Tn={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1};function Tu(){return v.cloneDeep(Tn)}const pb=[{lang:"en",resources:{boxplot:{viz_name:"Boxplot Chart",box:"Box",outlier:"Outlier",scatter:"Scatter",click_series:{label:"Click box, scatter or outlier"}}}},{lang:"zh",resources:{boxplot:{viz_name:"箱线图",box:"箱体",outlier:"异常点",scatter:"散点",click_series:{label:"点击箱体、散点或异常点"}}}}],Du={id:"builtin:echarts:click-echart:series",displayName:"viz.boxplot.click_series.label",nameRender:fb,configRender:hb,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'boxplot'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Record of 'name', 'min', 'q1', 'median', 'q3', 'max'",valueType:"object"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function hb(e){return r.jsx(r.Fragment,{})}function fb(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.boxplot.click_series.label")})}const ws=g.forwardRef(({sectionTitle:e,value:t,onChange:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=u=>d=>{const p=v.cloneDeep(t);v.set(p,u,d),n(p)},c=g.useMemo(()=>[{label:i("chart.axis.overflow.truncate"),value:"truncate"},{label:i("chart.axis.overflow.break_line"),value:"break"},{label:i("chart.axis.overflow.break_word"),value:"breakAll"}],[a.language]);return r.jsxs(o.Stack,{spacing:0,children:[e&&r.jsx(o.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.NumberInput,{label:i("chart.axis.overflow.max_width"),hideControls:!0,value:t.width,onChange:l("width")}),r.jsx(o.Select,{label:i("chart.axis.overflow.label"),data:c,value:t.overflow,onChange:l("overflow")}),r.jsx(o.TextInput,{label:i("chart.axis.overflow.ellipsis"),value:t.ellipsis,disabled:!0})]})]})}),Tt=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),i=l=>{t({...e,on_axis:l})},a=l=>{t({...e,in_tooltip:l})};return r.jsxs(o.Stack,{ref:n,spacing:0,children:[r.jsx(ws,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.on_axis,onChange:i}),r.jsx(ws,{sectionTitle:s("chart.axis.overflow.section_title.in_tooltip"),value:e.in_tooltip,onChange:a})]})});function Ke(){return{on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}}}function ut({overflow:e,width:t}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],s=e==="truncate"?"nowrap":"initial",i={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
|
|
76
76
|
max-width: ${t}px;
|
|
77
77
|
word-break: ${n};
|
|
@@ -288,7 +288,7 @@ Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(
|
|
|
288
288
|
<thead><tr>${d.join("")}</tr></thead>
|
|
289
289
|
<tbody>${h.join("")}</tbody>
|
|
290
290
|
</table>
|
|
291
|
-
`}})}function uT(e,t){const n=t.every(c=>!Number.isNaN(Number(c))),{overflow:s,...i}=e.x_axis.axisLabel,a=dt(s.on_axis),l=t.length===0;return[te.getXAxis({data:t,name:e.x_axis.name??"",nameGap:l?5:void 0,id:"main-x-axis",type:n?"value":"category",axisLabel:{...i,...a,formatter:Ye(i.formatter)}})]}function dT(e,t){return e.y_axes.map(({nameAlignment:n,min:s,max:i,...a},l)=>{let c=a.position;return c||(c=l>0?"right":"left"),te.getYAxis({...a,minInterval:1,min:s||void 0,max:i||void 0,position:c,axisLine:{show:!0},axisLabel:{show:!0,formatter:t[l]??t.default},nameTextStyle:{align:n},nameLocation:"end",nameGap:15,splitLine:{show:!1}})})}const pT={xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}],grid:{top:10,left:20,right:15,bottom:25,containLabel:!0}};function hT(e,t,n){const s=n.reduce((u,d)=>{const p=Vt(d,t);return u[d.name]=rt(d,p),u},{}),i=e.y_axes.reduce((u,{label_formatter:d},p)=>(u[p]=function(f){let m=f;if(typeof f=="object"&&(Array.isArray(f.value)&&f.value.length===2?m=f.value[1]:m=f.value),!d)return m;try{return U(m,d)}catch(y){return console.error(y),m}},u),{default:({value:u})=>u}),a=v.uniq(_t(t,e.x_axis.data_key)),l=aT(e,t,n,s),c={xAxis:uT(e,a),yAxis:dT(e,i),series:l,dataset:Zk(e,t),tooltip:cT(e,i),grid:Hk(e),legend:eT(),dataZoom:Ss(e.dataZoom)};return v.defaultsDeep({},c,pT)}function ah(e){return e.trim().length>0}function fT({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=Dn(t,e.x_axis.data_key),c=st(i.triggerManager,rh.id),u=g.useCallback(h=>{const f=h.data;c.forEach(m=>{i.runInteraction(m.id,{...h,rowData:f})})},[l,c,i]),d=g.useMemo(()=>({click:u}),[u]),p=g.useMemo(()=>hT(e,t,a),[e,t]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function gT({context:e,instance:t}){const n=it({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,zo),[s]),l=e.data,{width:c,height:u}=e.viewport,{ref:d,height:p}=he.useElementSize(),{ref:h,height:f}=he.useElementSize(),m=g.useMemo(()=>{const{stats:{templates:j}}=a;return{top:bs(j.top,i,l),bottom:bs(j.bottom,i,l)}},[a,l]),y=Math.max(0,Ct(u)-p-f);return!c||!u?null:r.jsxs(Ue,{width:c,height:u,children:[r.jsx(o.Text,{ref:d,align:"left",size:"xs",pl:"sm",sx:{display:ah(a.stats.templates.top)?"block":"none"},children:Object.values(m.top).map(j=>j)}),r.jsx(fT,{variables:i,width:wt(c),height:y,data:l,conf:a,interactionManager:n}),r.jsx(o.Text,{ref:h,align:"left",size:"xs",pl:"sm",sx:{display:ah(a.stats.templates.bottom)?"block":"none"},children:Object.values(m.bottom).map(j=>j)})]})}const mT=g.forwardRef(({value:e,onChange:t,xAxisOptions:n,yAxisOptions:s,variableOptions:i},a)=>{const{t:l,i18n:c}=_.useTranslation(),u=(d,p)=>{const h=v.cloneDeep(e);v.set(h,d,p),t(h)};return r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:l("chart.reference_area.content.label"),labelPosition:"right"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.TextInput,{label:l("chart.reference_area.content.content_text"),value:e.content.text,onChange:d=>u("content.text",d.currentTarget.value)}),r.jsx(nr,{label:l("chart.reference_area.content.text_position"),value:e.label.position,onChange:d=>u("label.position",d)})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:l("chart.reference_area.endpoint.labels"),labelPosition:"right"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[n&&r.jsx(o.Select,{label:l("chart.x_axis.label"),data:n,value:e.xAxisIndex,onChange:d=>u("xAxisIndex",d)}),s&&r.jsx(o.Select,{label:l("chart.y_axis.label"),data:s,value:e.yAxisIndex,onChange:d=>u("xAxisIndex",d)})]}),r.jsxs(o.Stack,{spacing:0,children:[r.jsx(o.Text,{size:14,color:"#212529",fw:500,children:l("chart.reference_area.endpoint.left_bottom_point")}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.Select,{icon:r.jsx(o.Text,{children:"x"}),data:i,value:e.leftBottomPoint.x_data_key,onChange:d=>u("leftBottomPoint.x_data_key",d??""),clearable:!0}),r.jsx(o.Select,{icon:r.jsx(o.Text,{children:"y"}),data:i,value:e.leftBottomPoint.y_data_key,onChange:d=>u("leftBottomPoint.y_data_key",d??""),clearable:!0})]})]}),r.jsxs(o.Stack,{spacing:0,children:[r.jsx(o.Text,{size:14,color:"#212529",fw:500,children:l("chart.reference_area.endpoint.right_top_point")}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.Select,{icon:r.jsx(o.Text,{children:"x"}),data:i,value:e.rightTopPoint.x_data_key,onChange:d=>u("rightTopPoint.x_data_key",d??""),clearable:!0}),r.jsx(o.Select,{icon:r.jsx(o.Text,{children:"y"}),data:i,value:e.rightTopPoint.y_data_key,onChange:d=>u("rightTopPoint.y_data_key",d??""),clearable:!0})]})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:l("chart.style.label"),labelPosition:"right"}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:14,children:l("chart.color.background_color")}),r.jsx(Be,{value:e.itemStyle.color,onChange:d=>u("itemStyle.color",d)})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:14,children:l("chart.color.text_color")}),r.jsx(Be,{value:e.label.color,onChange:d=>u("label.color",d)})]})]})});function xT(){const e=new Date().getTime().toString();return{id:e,content:{text:e},itemStyle:{color:"rgba(0,0,0,0.05)"},label:{position:"inside",color:"rgba(0,0,0,0.5)"},leftBottomPoint:{x_data_key:"",y_data_key:""},rightTopPoint:{x_data_key:"",y_data_key:""},xAxisIndex:"0",yAxisIndex:"0"}}function yT({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>xT(),a=g.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=t("y_axes"),c=g.useMemo(()=>l.map(({name:d},p)=>({label:d,value:p.toString()})),[l]),u=(d,p)=>p+1;return r.jsx(ge,{control:e,watch:t,name:"reference_areas",getItem:i,addButtonText:s("chart.reference_area.add"),deleteButtonText:s("chart.reference_area.delete"),renderTabName:u,children:({field:d,index:p})=>r.jsx(b.Controller,{name:`reference_areas.${p}`,control:e,render:({field:h})=>r.jsx(o.Stack,{children:r.jsx(mT,{variableOptions:a,yAxisOptions:c,...h})})})})}function bT({control:e,index:t,watch:n,variableOptions:s,yAxisOptions:i}){const{t:a}=_.useTranslation(),l=n(`reference_lines.${t}.orientation`);return r.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>r.jsx(o.Select,{label:a("common.data_field"),required:!0,data:s,sx:{flex:1},...c})})]}),r.jsx(b.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.hint"),sx:{flex:1},...c})}),r.jsxs(o.Group,{grow:!0,children:[r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>r.jsx(yn,{sx:{flex:1},...c})}),l==="vertical"&&r.jsx(o.Text,{mt:-10,color:"dimmed",size:12,children:a("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&r.jsx(b.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:u,...d}})=>r.jsx(o.Select,{label:"Y Axis",data:i,disabled:i.length===0,...d,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){u(0);return}u(Number(p))},sx:{flex:1}})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.style.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>r.jsx(tr,{sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>r.jsx(o.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:a("chart.color.label")}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>r.jsx(Be,{...c})})]})]})}function vT({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:Qt.random().css()},show_in_legend:!1,yAxisIndex:0}),a=g.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=t("y_axes"),c=g.useMemo(()=>l.map(({name:d},p)=>({label:d,value:p.toString()})),[l]),u=(d,p)=>{const h=d.name.trim();return h||p+1};return r.jsx(ge,{control:e,watch:t,name:"reference_lines",getItem:i,addButtonText:s("chart.reference_line.add"),deleteButtonText:s("chart.reference_line.delete"),renderTabName:u,children:({field:d,index:p})=>r.jsx(bT,{control:e,index:p,watch:t,variableOptions:a,yAxisOptions:c})})}const _T=({value:e,onChange:t})=>{const n=s=>{s&&t(s)};return r.jsx(o.Box,{children:r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},jT=({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),[s,{setTrue:i,setFalse:a}]=W.useBoolean(),[l,c]=g.useState(e),u=()=>{a();const{type:f,func_content:m}=l,y={type:f,func_content:m};c(y),t(y)},d=()=>{a(),c(e)},p=f=>{c(m=>({...m,func_content:f}))},h=()=>{p(Gr.dynamic.func_content)};return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{sx:{width:"50%"},children:r.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:i,sx:{flexGrow:0},children:n("viz.scatter_chart.color.dynamic.setup")})}),r.jsx(o.Modal,{size:800,title:n("viz.scatter_chart.color.dynamic.setup_title"),opened:s,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&r.jsxs(o.Stack,{children:[r.jsx(_T,{value:l.func_content,onChange:p}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:h,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:u,children:n("common.actions.save")})]})]})]})})]})},wT=({value:e,onChange:t})=>e.type!=="dynamic"?null:r.jsx(jT,{value:e,onChange:t}),CT=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=s=>{t({...e,color:s})};return r.jsx(o.ColorInput,{label:" ",format:"rgb",value:e.color,onChange:n})},ST=g.forwardRef(({label:e="Color",value:t,onChange:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=g.useMemo(()=>[{label:i("viz.scatter_chart.color.type.static"),value:"static"},{label:i("viz.scatter_chart.color.type.dynamic"),value:"dynamic"}],[a.language]),c=u=>{n({...Gr[u]})};return r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(o.Select,{ref:s,label:e,data:l,value:t.type,onChange:c,sx:{flexGrow:1}}),r.jsx(CT,{value:t,onChange:n}),r.jsx(wT,{value:t,onChange:n})]})}),kT=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),i=l=>{t({...e,label:l})},a=l=>{t({...e,tooltip:l})};return r.jsxs(o.Stack,{ref:n,spacing:0,children:[r.jsx(ws,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.label,onChange:i}),r.jsx(ws,{sectionTitle:s("chart.axis.overflow.section_title.in_tooltip"),value:e.tooltip,onChange:a})]})});function TT({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["scatter"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"scatter.name_data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.name_data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"scatter.y_data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.value_data_field"),required:!0,sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,label:n("chart.style.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"scatter.symbolSize",control:e,render:({field:s})=>r.jsx(_o,{...s})}),r.jsx(b.Controller,{name:"scatter.color",control:e,render:({field:s})=>r.jsx(ST,{...s})}),r.jsx(o.Divider,{mb:-15,label:n("chart.label.label"),labelPosition:"center"}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"scatter.label_position",control:e,render:({field:s})=>r.jsx(nr,{label:n("chart.label_position.label"),withOffOption:!0,...s,onChange:i=>{i&&s.onChange(i)}})})}),r.jsx(b.Controller,{name:"scatter.label_overflow",control:e,render:({field:s})=>r.jsx(kT,{...s})})]})}function DT({control:e,watch:t}){const{t:n}=_.useTranslation();return t("stats"),r.jsx(o.Stack,{children:r.jsxs(o.Stack,{spacing:0,children:[r.jsx(b.Controller,{name:"stats.templates.top",control:e,render:({field:s})=>r.jsx(ns,{label:n("chart.stats.template.above_chart"),py:"md",sx:{flexGrow:1},...s})}),r.jsx(b.Controller,{name:"stats.templates.bottom",control:e,render:({field:s})=>r.jsx(ns,{label:n("chart.stats.template.under_chart"),py:"md",sx:{flexGrow:1},...s})})]})})}const MT=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},zT=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),r.jsx(ge,{control:e,watch:t,name:"tooltip.metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(MT,{control:e,index:l})})]})};function IT({control:e,watch:t}){const{t:n,i18n:s}=_.useTranslation();t("tooltip.trigger");const i=g.useMemo(()=>[{label:n("chart.tooltip.trigger.scatter_point"),value:"item"},{label:n("chart.tooltip.trigger.x_axis"),value:"axis"}],[s.language]);return r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:"tooltip.trigger",control:e,render:({field:a})=>r.jsx(o.Select,{label:n("chart.tooltip.trigger.label"),data:i,sx:{flexGrow:1},...a})}),r.jsx(o.Divider,{variant:"dashed"}),r.jsx(zT,{control:e,watch:t})]})}function ET({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Zt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(kt,{...s})})]}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(Tt,{...s})})]})}function AT({control:e,index:t}){const{t:n}=_.useTranslation();return r.jsxs(o.Stack,{my:0,p:"0",sx:{position:"relative"},children:[r.jsx(o.Divider,{mb:-15,mt:15,variant:"dashed",label:n("chart.y_axis.y_axis_name"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:s})=>r.jsx(bn,{sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.layout"),labelPosition:"center"}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:s})=>r.jsx(Lp,{sx:{flex:1},...s})})}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.label_format"),labelPosition:"center"}),r.jsx(b.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:s})=>r.jsx(gt,{...s})})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.value_range"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.y_axis.value_min"),...s})}),r.jsx(b.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.y_axis.value_max"),...s})})]})]})]})}function PT({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>({name:"",label_formatter:Me,min:"",max:"",show:!0,position:"right",nameAlignment:"right"}),i=(l,c)=>{const u=l.name.trim();return u||c+1},a=({field:l,index:c,fields:u})=>u.length<=1;return r.jsx(ge,{control:e,watch:t,name:"y_axes",getItem:s,addButtonText:n("chart.y_axis.add"),deleteButtonText:n("chart.y_axis.delete"),renderTabName:i,deleteDisalbed:a,children:({field:l,index:c})=>r.jsx(AT,{control:e,index:c})})}function OT(e){return e||{templates:{top:"",bottom:""}}}function LT({reference_lines:e=[],stats:t,...n}){return{reference_lines:e,stats:OT(t),...n}}function BT({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaultsDeep({},n,zo),[n]),l=g.useMemo(()=>LT(a),[a]);g.useEffect(()=>{!v.isEqual(a,l)&&(console.log("config malformed, resetting to defaults",a,l),s(l))},[a,l]);const{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=b.useForm({defaultValues:l});g.useEffect(()=>{h(l)},[l]);const f=p(),m=g.useMemo(()=>!v.isEqual(f,a),[f,a]);return d(["dataZoom"]),r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:u(s),children:[r.jsx(ke,{canSubmit:m}),r.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Y Axes",children:t("chart.y_axis.labels")}),r.jsx(o.Tabs.Tab,{value:"Scatter",children:t("chart.series.scatter.label")}),r.jsx(o.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")}),r.jsx(o.Tabs.Tab,{value:"Stats",children:t("chart.stats.label")}),r.jsx(o.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")}),r.jsx(o.Tabs.Tab,{value:"Reference Areas",children:t("chart.reference_area.labels")}),r.jsx(o.Tabs.Tab,{value:"Zooming",children:t("chart.zooming.label")})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx(ET,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Y Axes",children:r.jsx(PT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Scatter",children:r.jsx(TT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(IT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Stats",children:r.jsx(DT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(vT,{variables:i,control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Reference Areas",children:r.jsx(yT,{variables:i,control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Zooming",children:r.jsx(b.Controller,{name:"dataZoom",control:c,render:({field:y})=>r.jsx(Us,{...y})})})]})]})})}const qT=[{lang:"en",resources:{scatter_chart:{viz_name:"Scatter Chart",color:{type:{static:"Static",dynamic:"Dynamic"},dynamic:{setup:"Setup",setup_title:"Setup dynamic color"}},click_scatter:{trigger:"Click Scatter"}}}},{lang:"zh",resources:{scatter_chart:{viz_name:"散点图",color:{type:{static:"具体颜色",dynamic:"动态计算颜色"},dynamic:{setup:"设置",setup_title:"设置动态计算颜色的逻辑"}},click_scatter:{trigger:"点击散点"}}}}];function VT(e){const{dataZoom:t=Tn,...n}=e;return{...n,dataZoom:t}}function NT(e){const t={scatter:{label_overflow:sh()}};return v.defaultsDeep(t,e)}function $T(e){const{color:t}=e.scatter;return typeof t=="string"?{...e,scatter:{...e.scatter,color:{...Gr.static,color:t}}}:e}function FT(e){const t=e.reference_lines.map(n=>{const{lineStyle:s={type:"dashed",width:1,color:Qt.random().css()},show_in_legend:i=!1,yAxisIndex:a=0}=n;return{...n,lineStyle:s,show_in_legend:i,yAxisIndex:a}});return{...e,reference_lines:t}}function GT(e){const t={tooltip:{trigger:"item"}};return v.defaultsDeep({},e,t)}function WT(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis:i,scatter:a,tooltip:l,...c}=e;return{...c,x_axis:{...i,data_key:s(i.data_key)},scatter:{...a,y_data_key:s(a.y_data_key),name_data_key:s(a.name_data_key)},tooltip:{...l,metrics:l.metrics.map(u=>({...u,data_key:s(u.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function RT(e){const t={x_axis:{axisLabel:{overflow:Ke()}}};return v.defaultsDeep(t,e)}class QT extends me{constructor(){super(...arguments);B(this,"VERSION",10)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{tooltip:s={metrics:[]},...i}=n.config;return{...n,version:2,config:{...i,tooltip:s}}}),this.version(3,n=>({...n,version:3,config:VT(n.config)})),this.version(4,n=>{const{config:s}=n;return{...n,version:5,config:NT(s)}}),this.version(6,n=>{const{config:s}=n;return{...n,version:6,config:$T(s)}}),this.version(7,n=>{const{config:s}=n;return{...n,version:7,config:FT(s)}}),this.version(8,n=>{const{config:s}=n;return{...n,version:8,config:GT(s)}}),this.version(9,(n,s)=>{const{config:i}=n;return{...n,version:9,config:WT(i,s)}}),this.version(10,(n,s)=>{const{config:i}=n;return{...n,version:10,config:RT(i)}})}}const UT={displayName:"viz.scatter_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new QT,name:"scatterChart",viewRender:gT,configRender:BT,createConfig(){return{version:10,config:v.cloneDeep(zo)}},triggers:[rh],translation:qT},Io={content:"Use double curly brackets to wrap js code: {{ new Date().getTime() }}",vertical_align:"center"};function YT(e){if("variables"in e)return e;const{align:t,size:n,weight:s,color:i,content:{prefix:a="",data_field:l="value",formatter:c={output:"number",mantissa:0},postfix:u=""}={}}=e;return{align:t,template:`${a} \${value} ${u}`,variables:[{name:"value",data_field:l,aggregation:{type:"none",config:{}},formatter:c,color:i,weight:s,size:n}]}}function KT(e){return v.omit(e,["variables"])}function XT(e){const{align:t,...n}=e;return{horizontal_align:t,vertical_align:"center",...n}}function JT(e){const t=v.cloneDeep(e),n=v.get(t,"color.valueRange");return n!==void 0&&v.set(t,"color.valueRange",n.map(s=>Number(s))),t}function ZT(e,t){return!t||t==="left"?e:`<p style="text-align: ${t}">${e}</p>`}function HT(e,t){const{horizontal_align:n,template:s,...i}=e;let a=ou(s,t);return a=ZT(a,n),{content:a,...i}}function e1(e,t){const{content:n,...s}=e;return{content:ou(n,t),...s}}class t1 extends me{constructor(){super(...arguments);B(this,"VERSION",5)}configVersions(){this.version(1,n=>({version:1,config:YT(n)})),this.version(2,(n,{panelModel:s})=>{const{config:i}=n;return(i.variables||[]).forEach(l=>{s.variables.find(c=>c.name===l.name)||s.addVariable(JT(l))}),{...n,version:2,config:KT(i)}}),this.version(3,n=>{const{config:s}=n;return{...n,version:3,config:XT(s)}}),this.version(4,(n,{panelModel:s})=>{const{config:i}=n;return{...n,version:4,config:HT(i,s)}}),this.version(5,(n,{panelModel:s})=>{const{config:i}=n;return{...n,version:5,config:e1(i,s)}})}}const oh={id:"builtin:stats:click-stats",displayName:"viz.stats.click_stats.trigger",nameRender:r1,configRender:n1,payload:[{name:"variables",description:"Panel variables",valueType:"object"}]};function n1(e){return r.jsx(r.Fragment,{})}function r1(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.stats.click_stats.trigger")})}const s1={top:"flex-start",center:"center",bottom:"flex-end"},i1=D.observer(({context:e,instance:t})=>{const n=it({vizManager:e.vizManager,instance:t}),s=st(n.triggerManager,oh.id),i=_e(),{value:a=Io}=$(e.instanceData,"config"),{panel:l}=St(),{data:c,variables:u}=e,{width:d,height:p}=e.viewport,h=g.useMemo(()=>{const j=v.defaults({},a,Io);return j.content?pu(j.content,u,i.payloadForViz,c):""},[a,u,i.payloadForViz]),f=l.variableValueMap,m=g.useCallback(()=>{s.forEach(j=>{n.runInteraction(j.id,{variables:f})})},[f,s,n]),y=s.length>0?{cursor:"pointer","&:hover":{textDecoration:"underline"}}:{};return r.jsx(o.Box,{sx:{width:d,height:p,alignItems:s1[a.vertical_align]},children:r.jsx(o.Box,{sx:y,onClick:m,children:r.jsx(vr,{value:h,styles:{root:{border:"none",height:"100%"},content:{padding:0}},dashboardState:i.dashboardState,varaiables:f})})})});function a1({conf:e,setConf:t}){const{t:n}=_.useTranslation(),s=g.useMemo(()=>v.defaults({},e),[e]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});g.useEffect(()=>{u(s)},[s]),l(["content","vertical_align"]);const d=c(),p=g.useMemo(()=>!v.isEqual(d,e),[d,e]);return r.jsx("form",{onSubmit:a(t),children:r.jsxs(o.Stack,{spacing:"xs",children:[r.jsx(ke,{canSubmit:p}),r.jsx(b.Controller,{control:i,name:"vertical_align",render:({field:h})=>r.jsx(Ou,{...h})}),r.jsx(b.Controller,{name:"content",control:i,render:({field:h})=>r.jsx(ys,{...h,styles:{root:{flexGrow:1,minHeight:"240px"}},label:n("rich_text.content.label"),autoSubmit:!0})})]})})}function o1(e){const{value:t,set:n}=$(e.context.instanceData,"config");return t?r.jsx(a1,{conf:t,setConf:n}):null}const l1=[{lang:"en",resources:{stats:{viz_name:"Stats",click_stats:{trigger:"Click stats text"}}}},{lang:"zh",resources:{stats:{viz_name:"数据指标",click_stats:{trigger:"点击文字"}}}}],c1={createConfig(){return{version:5,config:Io}},displayName:"viz.stats.viz_name",displayGroup:"chart.groups.others",migrator:new t1,name:"stats",viewRender:i1,configRender:o1,triggers:[oh],translation:l1},Eo={label_key:"",value_key:"",group_key:"",levels:[]};function u1(e){const t=new Set(e.map(s=>s.parent_id)),n=new Set(e.map(s=>s.id));return t.forEach(s=>{s===null||n.has(s)||e.push({id:s,name:s,parent_id:null})}),e}function d1(e){const t=u1(e).map(i=>({...i,children:[]})),n=v.keyBy(t,i=>i.id),s=[];return t.forEach(i=>{if(!i.parent_id||!n[i.parent_id]){s.push(i);return}n[i.parent_id].children.push(i)}),s}function p1(e,t){const{label_key:n,value_key:s,group_key:i}=e;if(!n||!s)return[];const a=O(n),l=O(s),c=O(i),u=t[a.queryID].map(d=>({...d,id:d[a.columnKey],parent_id:d[c.columnKey],name:d[a.columnKey],value:d[l.columnKey]?Number(d[l.columnKey]):d[l.columnKey]}));return i?d1(u):u}const h1=e=>({treePathInfo:t,name:n,value:s})=>{if(t.length===1||!e)return n;try{const i=t[t.length-2].value;if(s/i<e)return" "}catch{return n}};function f1(e){const{levels:t}=e;return t.map(n=>{const{show_label_tolerance:s,...i}=n.label;return{...n,label:{...i,formatter:h1(s)}}})}function g1(){return({treePathInfo:e,name:t,value:n,color:s,marker:i,...a})=>{const l=e.slice(0,e.length-1),c=[`<tr>
|
|
291
|
+
`}})}function uT(e,t){const n=t.every(c=>!Number.isNaN(Number(c))),{overflow:s,...i}=e.x_axis.axisLabel,a=dt(s.on_axis),l=t.length===0;return[te.getXAxis({data:t,name:e.x_axis.name??"",nameGap:l?5:void 0,id:"main-x-axis",type:n?"value":"category",axisLabel:{...i,...a,formatter:Ye(i.formatter)}})]}function dT(e,t){return e.y_axes.map(({nameAlignment:n,min:s,max:i,...a},l)=>{let c=a.position;return c||(c=l>0?"right":"left"),te.getYAxis({...a,minInterval:1,min:s||void 0,max:i||void 0,position:c,axisLine:{show:!0},axisLabel:{show:!0,formatter:t[l]??t.default},nameTextStyle:{align:n},nameLocation:"end",nameGap:15,splitLine:{show:!1}})})}const pT={xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}],grid:{top:10,left:20,right:15,bottom:25,containLabel:!0}};function hT(e,t,n){const s=n.reduce((u,d)=>{const p=Vt(d,t);return u[d.name]=rt(d,p),u},{}),i=e.y_axes.reduce((u,{label_formatter:d},p)=>(u[p]=function(f){let m=f;if(typeof f=="object"&&(Array.isArray(f.value)&&f.value.length===2?m=f.value[1]:m=f.value),!d)return m;try{return U(m,d)}catch(y){return console.error(y),m}},u),{default:({value:u})=>u}),a=v.uniq(_t(t,e.x_axis.data_key)),l=aT(e,t,n,s),c={xAxis:uT(e,a),yAxis:dT(e,i),series:l,dataset:Zk(e,t),tooltip:cT(e,i),grid:Hk(e),legend:eT(),dataZoom:Ss(e.dataZoom)};return v.defaultsDeep({},c,pT)}function ah(e){return e.trim().length>0}function fT({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=Dn(t,e.x_axis.data_key),c=st(i.triggerManager,rh.id),u=g.useCallback(h=>{const f=h.data;c.forEach(m=>{i.runInteraction(m.id,{...h,rowData:f})})},[l,c,i]),d=g.useMemo(()=>({click:u}),[u]),p=g.useMemo(()=>hT(e,t,a),[e,t]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function gT({context:e,instance:t}){const n=it({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,zo),[s]),l=e.data,{width:c,height:u}=e.viewport,{ref:d,height:p}=he.useElementSize(),{ref:h,height:f}=he.useElementSize(),m=g.useMemo(()=>{const{stats:{templates:j}}=a;return{top:bs(j.top,i,l),bottom:bs(j.bottom,i,l)}},[a,l]),y=Math.max(0,Ct(u)-p-f);return!c||!u?null:r.jsxs(Ue,{width:c,height:u,children:[r.jsx(o.Text,{ref:d,align:"left",size:"xs",pl:"sm",sx:{display:ah(a.stats.templates.top)?"block":"none"},children:Object.values(m.top).map(j=>j)}),r.jsx(fT,{variables:i,width:wt(c),height:y,data:l,conf:a,interactionManager:n}),r.jsx(o.Text,{ref:h,align:"left",size:"xs",pl:"sm",sx:{display:ah(a.stats.templates.bottom)?"block":"none"},children:Object.values(m.bottom).map(j=>j)})]})}const mT=g.forwardRef(({value:e,onChange:t,xAxisOptions:n,yAxisOptions:s,variableOptions:i},a)=>{const{t:l,i18n:c}=_.useTranslation(),u=(d,p)=>{const h=v.cloneDeep(e);v.set(h,d,p),t(h)};return r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:l("chart.reference_area.content.label"),labelPosition:"right"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.TextInput,{label:l("chart.reference_area.content.content_text"),value:e.content.text,onChange:d=>u("content.text",d.currentTarget.value)}),r.jsx(nr,{label:l("chart.reference_area.content.text_position"),value:e.label.position,onChange:d=>u("label.position",d)})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:l("chart.reference_area.endpoint.labels"),labelPosition:"right"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[n&&r.jsx(o.Select,{label:l("chart.x_axis.label"),data:n,value:e.xAxisIndex,onChange:d=>u("xAxisIndex",d)}),s&&r.jsx(o.Select,{label:l("chart.y_axis.label"),data:s,value:e.yAxisIndex,onChange:d=>u("xAxisIndex",d)})]}),r.jsxs(o.Stack,{spacing:0,children:[r.jsx(o.Text,{size:14,color:"#212529",fw:500,children:l("chart.reference_area.endpoint.left_bottom_point")}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.Select,{icon:r.jsx(o.Text,{children:"x"}),data:i,value:e.leftBottomPoint.x_data_key,onChange:d=>u("leftBottomPoint.x_data_key",d??""),clearable:!0}),r.jsx(o.Select,{icon:r.jsx(o.Text,{children:"y"}),data:i,value:e.leftBottomPoint.y_data_key,onChange:d=>u("leftBottomPoint.y_data_key",d??""),clearable:!0})]})]}),r.jsxs(o.Stack,{spacing:0,children:[r.jsx(o.Text,{size:14,color:"#212529",fw:500,children:l("chart.reference_area.endpoint.right_top_point")}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.Select,{icon:r.jsx(o.Text,{children:"x"}),data:i,value:e.rightTopPoint.x_data_key,onChange:d=>u("rightTopPoint.x_data_key",d??""),clearable:!0}),r.jsx(o.Select,{icon:r.jsx(o.Text,{children:"y"}),data:i,value:e.rightTopPoint.y_data_key,onChange:d=>u("rightTopPoint.y_data_key",d??""),clearable:!0})]})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:l("chart.style.label"),labelPosition:"right"}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:14,children:l("chart.color.background_color")}),r.jsx(Be,{value:e.itemStyle.color,onChange:d=>u("itemStyle.color",d)})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:14,children:l("chart.color.text_color")}),r.jsx(Be,{value:e.label.color,onChange:d=>u("label.color",d)})]})]})});function xT(){const e=new Date().getTime().toString();return{id:e,content:{text:e},itemStyle:{color:"rgba(0,0,0,0.05)"},label:{position:"inside",color:"rgba(0,0,0,0.5)"},leftBottomPoint:{x_data_key:"",y_data_key:""},rightTopPoint:{x_data_key:"",y_data_key:""},xAxisIndex:"0",yAxisIndex:"0"}}function yT({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>xT(),a=g.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=t("y_axes"),c=g.useMemo(()=>l.map(({name:d},p)=>({label:d,value:p.toString()})),[l]),u=(d,p)=>p+1;return r.jsx(ge,{control:e,watch:t,name:"reference_areas",getItem:i,addButtonText:s("chart.reference_area.add"),deleteButtonText:s("chart.reference_area.delete"),renderTabName:u,children:({field:d,index:p})=>r.jsx(b.Controller,{name:`reference_areas.${p}`,control:e,render:({field:h})=>r.jsx(o.Stack,{children:r.jsx(mT,{variableOptions:a,yAxisOptions:c,...h})})})})}function bT({control:e,index:t,watch:n,variableOptions:s,yAxisOptions:i}){const{t:a}=_.useTranslation(),l=n(`reference_lines.${t}.orientation`);return r.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>r.jsx(o.Select,{label:a("common.data_field"),required:!0,data:s,sx:{flex:1},...c})})]}),r.jsx(b.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.hint"),sx:{flex:1},...c})}),r.jsxs(o.Group,{grow:!0,children:[r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>r.jsx(yn,{sx:{flex:1},...c})}),l==="vertical"&&r.jsx(o.Text,{mt:-10,color:"dimmed",size:12,children:a("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&r.jsx(b.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:u,...d}})=>r.jsx(o.Select,{label:"Y Axis",data:i,disabled:i.length===0,...d,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){u(0);return}u(Number(p))},sx:{flex:1}})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.style.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>r.jsx(tr,{sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>r.jsx(o.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:a("chart.color.label")}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>r.jsx(Be,{...c})})]})]})}function vT({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:Qt.random().css()},show_in_legend:!1,yAxisIndex:0}),a=g.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=t("y_axes"),c=g.useMemo(()=>l.map(({name:d},p)=>({label:d,value:p.toString()})),[l]),u=(d,p)=>{const h=d.name.trim();return h||p+1};return r.jsx(ge,{control:e,watch:t,name:"reference_lines",getItem:i,addButtonText:s("chart.reference_line.add"),deleteButtonText:s("chart.reference_line.delete"),renderTabName:u,children:({field:d,index:p})=>r.jsx(bT,{control:e,index:p,watch:t,variableOptions:a,yAxisOptions:c})})}const _T=({value:e,onChange:t})=>{const n=s=>{s&&t(s)};return r.jsx(o.Box,{children:r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},jT=({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),[s,{setTrue:i,setFalse:a}]=W.useBoolean(),[l,c]=g.useState(e),u=()=>{a();const{type:f,func_content:m}=l,y={type:f,func_content:m};c(y),t(y)},d=()=>{a(),c(e)},p=f=>{c(m=>({...m,func_content:f}))},h=()=>{p(Gr.dynamic.func_content)};return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{sx:{width:"50%"},children:r.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:i,sx:{flexGrow:0},children:n("viz.scatter_chart.color.dynamic.setup")})}),r.jsx(o.Modal,{size:800,title:n("viz.scatter_chart.color.dynamic.setup_title"),opened:s,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&r.jsxs(o.Stack,{children:[r.jsx(_T,{value:l.func_content,onChange:p}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:h,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:u,children:n("common.actions.save")})]})]})]})})]})},wT=({value:e,onChange:t})=>e.type!=="dynamic"?null:r.jsx(jT,{value:e,onChange:t}),CT=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=s=>{t({...e,color:s})};return r.jsx(o.ColorInput,{label:" ",format:"rgb",value:e.color,onChange:n})},ST=g.forwardRef(({label:e="Color",value:t,onChange:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=g.useMemo(()=>[{label:i("viz.scatter_chart.color.type.static"),value:"static"},{label:i("viz.scatter_chart.color.type.dynamic"),value:"dynamic"}],[a.language]),c=u=>{n({...Gr[u]})};return r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(o.Select,{ref:s,label:e,data:l,value:t.type,onChange:c,sx:{flexGrow:1}}),r.jsx(CT,{value:t,onChange:n}),r.jsx(wT,{value:t,onChange:n})]})}),kT=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),i=l=>{t({...e,label:l})},a=l=>{t({...e,tooltip:l})};return r.jsxs(o.Stack,{ref:n,spacing:0,children:[r.jsx(ws,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.label,onChange:i}),r.jsx(ws,{sectionTitle:s("chart.axis.overflow.section_title.in_tooltip"),value:e.tooltip,onChange:a})]})});function TT({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["scatter"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"scatter.name_data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.name_data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"scatter.y_data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.value_data_field"),required:!0,sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,label:n("chart.style.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"scatter.symbolSize",control:e,render:({field:s})=>r.jsx(_o,{...s})}),r.jsx(b.Controller,{name:"scatter.color",control:e,render:({field:s})=>r.jsx(ST,{...s})}),r.jsx(o.Divider,{mb:-15,label:n("chart.label.label"),labelPosition:"center"}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"scatter.label_position",control:e,render:({field:s})=>r.jsx(nr,{label:n("chart.label_position.label"),withOffOption:!0,...s,onChange:i=>{i&&s.onChange(i)}})})}),r.jsx(b.Controller,{name:"scatter.label_overflow",control:e,render:({field:s})=>r.jsx(kT,{...s})})]})}function DT({control:e,watch:t}){const{t:n}=_.useTranslation();return t("stats"),r.jsx(o.Stack,{children:r.jsxs(o.Stack,{spacing:0,children:[r.jsx(b.Controller,{name:"stats.templates.top",control:e,render:({field:s})=>r.jsx(ns,{label:n("chart.stats.template.above_chart"),py:"md",sx:{flexGrow:1},...s})}),r.jsx(b.Controller,{name:"stats.templates.bottom",control:e,render:({field:s})=>r.jsx(ns,{label:n("chart.stats.template.under_chart"),py:"md",sx:{flexGrow:1},...s})})]})})}const MT=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},zT=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),r.jsx(ge,{control:e,watch:t,name:"tooltip.metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(MT,{control:e,index:l})})]})};function IT({control:e,watch:t}){const{t:n,i18n:s}=_.useTranslation();t("tooltip.trigger");const i=g.useMemo(()=>[{label:n("chart.tooltip.trigger.scatter_point"),value:"item"},{label:n("chart.tooltip.trigger.x_axis"),value:"axis"}],[s.language]);return r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:"tooltip.trigger",control:e,render:({field:a})=>r.jsx(o.Select,{label:n("chart.tooltip.trigger.label"),data:i,sx:{flexGrow:1},...a})}),r.jsx(o.Divider,{variant:"dashed"}),r.jsx(zT,{control:e,watch:t})]})}function ET({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Zt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(kt,{...s})})]}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(Tt,{...s})})]})}function AT({control:e,index:t}){const{t:n}=_.useTranslation();return r.jsxs(o.Stack,{my:0,p:"0",sx:{position:"relative"},children:[r.jsx(o.Divider,{mb:-15,mt:15,variant:"dashed",label:n("chart.y_axis.y_axis_name"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:s})=>r.jsx(bn,{sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.layout"),labelPosition:"center"}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:s})=>r.jsx(Lp,{sx:{flex:1},...s})})}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.label_format"),labelPosition:"center"}),r.jsx(b.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:s})=>r.jsx(gt,{...s})})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.value_range"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.y_axis.value_min"),...s})}),r.jsx(b.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.y_axis.value_max"),...s})})]})]})]})}function PT({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>({name:"",label_formatter:Me,min:"",max:"",show:!0,position:"right",nameAlignment:"right"}),i=(l,c)=>{const u=l.name.trim();return u||c+1},a=({field:l,index:c,fields:u})=>u.length<=1;return r.jsx(ge,{control:e,watch:t,name:"y_axes",getItem:s,addButtonText:n("chart.y_axis.add"),deleteButtonText:n("chart.y_axis.delete"),renderTabName:i,deleteDisalbed:a,children:({field:l,index:c})=>r.jsx(AT,{control:e,index:c})})}function OT(e){return e||{templates:{top:"",bottom:""}}}function LT({reference_lines:e=[],stats:t,...n}){return{reference_lines:e,stats:OT(t),...n}}function BT({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaultsDeep({},n,zo),[n]),l=g.useMemo(()=>LT(a),[a]);g.useEffect(()=>{!v.isEqual(a,l)&&(console.log("config malformed, resetting to defaults",a,l),s(l))},[a,l]);const{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=b.useForm({defaultValues:l});g.useEffect(()=>{h(l)},[l]);const f=p(),m=g.useMemo(()=>!v.isEqual(f,a),[f,a]);return d(["dataZoom"]),r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:u(s),children:[r.jsx(ke,{canSubmit:m}),r.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Y Axes",children:t("chart.y_axis.labels")}),r.jsx(o.Tabs.Tab,{value:"Scatter",children:t("chart.series.scatter.label")}),r.jsx(o.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")}),r.jsx(o.Tabs.Tab,{value:"Stats",children:t("chart.stats.label")}),r.jsx(o.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")}),r.jsx(o.Tabs.Tab,{value:"Reference Areas",children:t("chart.reference_area.labels")}),r.jsx(o.Tabs.Tab,{value:"Zooming",children:t("chart.zooming.label")})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx(ET,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Y Axes",children:r.jsx(PT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Scatter",children:r.jsx(TT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(IT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Stats",children:r.jsx(DT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(vT,{variables:i,control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Reference Areas",children:r.jsx(yT,{variables:i,control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Zooming",children:r.jsx(b.Controller,{name:"dataZoom",control:c,render:({field:y})=>r.jsx(Us,{...y})})})]})]})})}const qT=[{lang:"en",resources:{scatter_chart:{viz_name:"Scatter Chart",color:{type:{static:"Static",dynamic:"Dynamic"},dynamic:{setup:"Setup",setup_title:"Setup dynamic color"}},click_scatter:{trigger:"Click Scatter"}}}},{lang:"zh",resources:{scatter_chart:{viz_name:"散点图",color:{type:{static:"具体颜色",dynamic:"动态计算颜色"},dynamic:{setup:"设置",setup_title:"设置动态计算颜色的逻辑"}},click_scatter:{trigger:"点击散点"}}}}];function VT(e){const{dataZoom:t=Tn,...n}=e;return{...n,dataZoom:t}}function NT(e){const t={scatter:{label_overflow:sh()}};return v.defaultsDeep(t,e)}function $T(e){const{color:t}=e.scatter;return typeof t=="string"?{...e,scatter:{...e.scatter,color:{...Gr.static,color:t}}}:e}function FT(e){const t=e.reference_lines.map(n=>{const{lineStyle:s={type:"dashed",width:1,color:Qt.random().css()},show_in_legend:i=!1,yAxisIndex:a=0}=n;return{...n,lineStyle:s,show_in_legend:i,yAxisIndex:a}});return{...e,reference_lines:t}}function GT(e){const t={tooltip:{trigger:"item"}};return v.defaultsDeep({},e,t)}function WT(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis:i,scatter:a,tooltip:l,...c}=e;return{...c,x_axis:{...i,data_key:s(i.data_key)},scatter:{...a,y_data_key:s(a.y_data_key),name_data_key:s(a.name_data_key)},tooltip:{...l,metrics:l.metrics.map(u=>({...u,data_key:s(u.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function RT(e){const t={x_axis:{axisLabel:{overflow:Ke()}}};return v.defaultsDeep(t,e)}class QT extends me{constructor(){super(...arguments);B(this,"VERSION",10)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{tooltip:s={metrics:[]},...i}=n.config;return{...n,version:2,config:{...i,tooltip:s}}}),this.version(3,n=>({...n,version:3,config:VT(n.config)})),this.version(4,n=>{const{config:s}=n;return{...n,version:5,config:NT(s)}}),this.version(6,n=>{const{config:s}=n;return{...n,version:6,config:$T(s)}}),this.version(7,n=>{const{config:s}=n;return{...n,version:7,config:FT(s)}}),this.version(8,n=>{const{config:s}=n;return{...n,version:8,config:GT(s)}}),this.version(9,(n,s)=>{const{config:i}=n;return{...n,version:9,config:WT(i,s)}}),this.version(10,(n,s)=>{const{config:i}=n;return{...n,version:10,config:RT(i)}})}}const UT={displayName:"viz.scatter_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new QT,name:"scatterChart",viewRender:gT,configRender:BT,createConfig(){return{version:10,config:v.cloneDeep(zo)}},triggers:[rh],translation:qT},Io={content:"Use double curly brackets to wrap js code: {{ new Date().getTime() }}",vertical_align:"center"};function YT(e){if("variables"in e)return e;const{align:t,size:n,weight:s,color:i,content:{prefix:a="",data_field:l="value",formatter:c={output:"number",mantissa:0},postfix:u=""}={}}=e;return{align:t,template:`${a} \${value} ${u}`,variables:[{name:"value",data_field:l,aggregation:{type:"none",config:{}},formatter:c,color:i,weight:s,size:n}]}}function KT(e){return v.omit(e,["variables"])}function XT(e){const{align:t,...n}=e;return{horizontal_align:t,vertical_align:"center",...n}}function JT(e){const t=v.cloneDeep(e),n=v.get(t,"color.valueRange");return n!==void 0&&v.set(t,"color.valueRange",n.map(s=>Number(s))),t}function ZT(e,t){return!t||t==="left"?e:`<p style="text-align: ${t}">${e}</p>`}function HT(e,t){const{horizontal_align:n,template:s,...i}=e;let a=ou(s,t);return a=ZT(a,n),{content:a,...i}}function e1(e,t){const{content:n,...s}=e;return{content:ou(n,t),...s}}class t1 extends me{constructor(){super(...arguments);B(this,"VERSION",5)}configVersions(){this.version(1,n=>({version:1,config:YT(n)})),this.version(2,(n,{panelModel:s})=>{const{config:i}=n;return(i.variables||[]).forEach(l=>{s.variables.find(c=>c.name===l.name)||s.addVariable(JT(l))}),{...n,version:2,config:KT(i)}}),this.version(3,n=>{const{config:s}=n;return{...n,version:3,config:XT(s)}}),this.version(4,(n,{panelModel:s})=>{const{config:i}=n;return{...n,version:4,config:HT(i,s)}}),this.version(5,(n,{panelModel:s})=>{const{config:i}=n;return{...n,version:5,config:e1(i,s)}})}}const oh={id:"builtin:stats:click-stats",displayName:"viz.stats.click_stats.trigger",nameRender:r1,configRender:n1,payload:[{name:"variables",description:"Panel variables",valueType:"object"}]};function n1(e){return r.jsx(r.Fragment,{})}function r1(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.stats.click_stats.trigger")})}const s1={top:"flex-start",center:"center",bottom:"flex-end"};function i1(e){const t={flexGrow:1};return e>0&&(t.cursor="pointer",t["&:hover"]={textDecoration:"underline"}),t}const a1=D.observer(({context:e,instance:t})=>{const n=it({vizManager:e.vizManager,instance:t}),s=st(n.triggerManager,oh.id),i=_e(),{value:a=Io}=$(e.instanceData,"config"),{panel:l}=St(),{data:c,variables:u}=e,{width:d,height:p}=e.viewport,h=g.useMemo(()=>{const y=v.defaults({},a,Io);return y.content?pu(y.content,u,i.payloadForViz,c):""},[a,u,i.payloadForViz]),f=l.variableValueMap,m=g.useCallback(()=>{s.forEach(y=>{n.runInteraction(y.id,{variables:f})})},[f,s,n]);return r.jsx(o.Flex,{className:"viz-stats",sx:{width:d,height:p},align:s1[a.vertical_align],direction:"row",children:r.jsx(o.Box,{className:"viz-stats--clickable-wrapper",sx:i1(s.length),onClick:m,children:r.jsx(vr,{value:h,styles:{root:{border:"none",maxWidth:d,maxHeight:p,"&.mantine-RichTextEditor-root":{overflow:"auto !important"}},content:{"&.mantine-RichTextEditor-content .ProseMirror":{padding:0}}},dashboardState:i.dashboardState,varaiables:f})})})});function o1({conf:e,setConf:t}){const{t:n}=_.useTranslation(),s=g.useMemo(()=>v.defaults({},e),[e]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});g.useEffect(()=>{u(s)},[s]),l(["content","vertical_align"]);const d=c(),p=g.useMemo(()=>!v.isEqual(d,e),[d,e]);return r.jsx("form",{onSubmit:a(t),children:r.jsxs(o.Stack,{spacing:"xs",children:[r.jsx(ke,{canSubmit:p}),r.jsx(b.Controller,{control:i,name:"vertical_align",render:({field:h})=>r.jsx(Ou,{...h})}),r.jsx(b.Controller,{name:"content",control:i,render:({field:h})=>r.jsx(ys,{...h,styles:{root:{flexGrow:1,minHeight:"240px"}},label:n("rich_text.content.label"),autoSubmit:!0})})]})})}function l1(e){const{value:t,set:n}=$(e.context.instanceData,"config");return t?r.jsx(o1,{conf:t,setConf:n}):null}const c1=[{lang:"en",resources:{stats:{viz_name:"Stats",click_stats:{trigger:"Click stats text"}}}},{lang:"zh",resources:{stats:{viz_name:"数据指标",click_stats:{trigger:"点击文字"}}}}],u1={createConfig(){return{version:5,config:Io}},displayName:"viz.stats.viz_name",displayGroup:"chart.groups.others",migrator:new t1,name:"stats",viewRender:a1,configRender:l1,triggers:[oh],translation:c1},Eo={label_key:"",value_key:"",group_key:"",levels:[]};function d1(e){const t=new Set(e.map(s=>s.parent_id)),n=new Set(e.map(s=>s.id));return t.forEach(s=>{s===null||n.has(s)||e.push({id:s,name:s,parent_id:null})}),e}function p1(e){const t=d1(e).map(i=>({...i,children:[]})),n=v.keyBy(t,i=>i.id),s=[];return t.forEach(i=>{if(!i.parent_id||!n[i.parent_id]){s.push(i);return}n[i.parent_id].children.push(i)}),s}function h1(e,t){const{label_key:n,value_key:s,group_key:i}=e;if(!n||!s)return[];const a=O(n),l=O(s),c=O(i),u=t[a.queryID].map(d=>({...d,id:d[a.columnKey],parent_id:d[c.columnKey],name:d[a.columnKey],value:d[l.columnKey]?Number(d[l.columnKey]):d[l.columnKey]}));return i?p1(u):u}const f1=e=>({treePathInfo:t,name:n,value:s})=>{if(t.length===1||!e)return n;try{const i=t[t.length-2].value;if(s/i<e)return" "}catch{return n}};function g1(e){const{levels:t}=e;return t.map(n=>{const{show_label_tolerance:s,...i}=n.label;return{...n,label:{...i,formatter:f1(s)}}})}function m1(){return({treePathInfo:e,name:t,value:n,color:s,marker:i,...a})=>{const l=e.slice(0,e.length-1),c=[`<tr>
|
|
292
292
|
<th style="text-align: right; padding: 0 1em;">Value</th>
|
|
293
293
|
<td style="text-align: left; padding: 0 1em;">${n}</td>
|
|
294
294
|
</tr>
|
|
@@ -306,9 +306,9 @@ Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(
|
|
|
306
306
|
<table style="width: auto">
|
|
307
307
|
<tbody>${c.join("")}</tbody>
|
|
308
308
|
</table>
|
|
309
|
-
`}}function
|
|
310
|
-
`),ch={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",query_id:"",striped:!0,use_raw_columns:!0,ignored_column_keys:"",verticalSpacing:"14px"},uh={left:"flex-start",center:"center",right:"flex-end"},I1=({header:e,cx:t})=>{const n=v.get(e.column.columnDef.meta,"align","left");return r.jsxs(o.Text,{className:t("table-head-cell",{"table-head-cell--sortable":e.column.getCanSort()}),onClick:e.column.getToggleSortingHandler(),align:n,sx:{justifyContent:uh[n]},children:[e.isPlaceholder?null:bt.flexRender(e.column.columnDef.header,e.getContext()),r.jsx(E1,{direction:e.column.getIsSorted()})]})},E1=({direction:e})=>{switch(e){case"asc":return r.jsx(M.IconArrowUp,{size:16});case"desc":return r.jsx(M.IconArrowDown,{size:"1em"});default:return null}},A1=o.createStyles(e=>({root:{overflow:"auto",position:"relative","& .table-head-cell":{display:"flex",flexFlow:"row nowrap",alignItems:"center",whiteSpace:"nowrap","&.table-head-cell--sortable":{cursor:"pointer",userSelect:"none"}},"&.table-highlight-on-hover tr":{transition:"background-color 0.2s","&:hover":{backgroundColor:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[0]}}},thead:{background:e.colorScheme==="dark"?e.colors.dark[7]:e.white,position:"sticky",top:24,transform:"translateY(-1px)",zIndex:10},info_bar:{position:"sticky",top:0,left:0,right:0,zIndex:10,background:"white"}})),P1={tableLayout:"fixed",width:"fit-content",minWidth:"100%","thead, tbody":{tr:{width:"fit-content",th:{position:"relative"},"th, td":{padding:"2px 10px",div:{overflow:"hidden",textOverflow:"ellipsis"},"&:first-of-type":{paddingLeft:2,paddingRight:2}}}},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",transform:"translateY(-50%)",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}},dh=o.createStyles((e,t)=>({content:{display:"flex",alignItems:"center",justifyContent:uh[t.align],".table-cell-text":{whiteSpace:"nowrap",cursor:t.clickable?"pointer":"default",textDecoration:t.clickable?"underline":"none"}}}));function O1(e){return e?Qt(e).oklch()[0]>.7?"black":"white":"inherit"}function ph(e){const t=e.tableCellContext.bgColor;return{backgroundColor:t,color:O1(t)}}function sr(e){const t=e.tableCellContext.isClickable(),n=dh({clickable:t,align:e.align});return r.jsx("div",{className:n.classes.content,style:{...ph(e)},children:r.jsx(o.Text,{className:"table-cell-text",onClick:e.tableCellContext.getClickHandler(),children:r.jsx("span",{title:e.children,children:e.children})})})}function L1(e){return r.jsx(sr,{...e,children:e.value})}function B1(e){const t=dh({clickable:!0,align:e.align}),n=e.value;return r.jsx("div",{className:t.classes.content,style:{...ph(e)},children:r.jsx(o.Anchor,{className:"table-cell-text",href:n,target:"_blank",color:"black",children:n})})}function q1(e){const t=U(e.value,{output:"number",average:!0,mantissa:2,trimMantissa:!0,absolute:!1});return r.jsx(sr,{...e,children:t})}function V1(e){const t=U(e.value,{output:"number",mantissa:0,thousandSeparated:!0,absolute:!1});return r.jsx(sr,{...e,children:t})}function N1(e){const t=U(e.value,{output:"percent",mantissa:3,trimMantissa:!0,absolute:!1});return r.jsx(sr,{...e,children:t})}function $1(e){const{value:t,row_data:n,func_content:s}=e;if(!s)return r.jsx(sr,{...e,children:t});const i=new Function(`return ${s}`)()({value:t,row_data:n},vt);return r.jsx(sr,{...e,children:i})}function F1(e){switch(e.type){case Mt.string:return r.jsx(L1,{...e});case Mt.eloc:return r.jsx(q1,{...e});case Mt.number:return r.jsx(V1,{...e});case Mt.percentage:return r.jsx(N1,{...e});case Mt.url:return r.jsx(B1,{...e});case Mt.custom:return r.jsx($1,{...e})}}function G1({tableContainerRef:e,rows:t}){var c,u;const n=Ag.useVirtual({parentRef:e,size:t.length,estimateSize:g.useCallback(()=>28,[]),overscan:20}),{virtualItems:s,totalSize:i}=n,a=s.length>0&&((c=s==null?void 0:s[0])==null?void 0:c.start)||0,l=s.length>0?i-(((u=s==null?void 0:s[s.length-1])==null?void 0:u.end)||0):0;return r.jsxs("tbody",{children:[a>0&&r.jsx("tr",{children:r.jsx("td",{style:{height:`${a}px`}})}),s.map(d=>{const p=t[d.index];return r.jsx("tr",{children:p.getVisibleCells().map(h=>r.jsx("td",{children:bt.flexRender(h.column.columnDef.cell,h.getContext())},h.id))},p.id)}),l>0&&r.jsx("tr",{children:r.jsx("td",{style:{height:`${l}px`}})})]})}const Ao={id:"builtin:table:click-cell-content",displayName:"viz.table.click_cell.click_cell_content",nameRender:U1,configRender:R1,payload:[{name:"row_index",description:"Index of the row that the cell belongs to",valueType:"number"},{name:"col_index",description:"Index of the column that the cell belongs to",valueType:"number"},{name:"row_data",description:"Data of the row that the cell belongs to",valueType:"object"}]},W1={column:""};function hh(e,t){const{value:n}=$(e.instanceData,"config"),s={columnsFromConfig:[],columnsFromData:[]};if(n&&(s.columnsFromConfig=n.columns.map((i,a)=>({label:i.label,value:a.toString()}))),!t)return s;if(n!=null&&n.query_id){const i=t[n.query_id];(i==null?void 0:i.length)>0&&(s.columnsFromData=Object.keys(i[0]).map(a=>({label:a,value:a})))}return s}function fh(e){const{value:t}=$(e.instanceData,"config");return(t==null?void 0:t.use_raw_columns)??!1}function R1(e){const{t}=_.useTranslation(),{columnsFromConfig:n,columnsFromData:s}=hh(e.instance,e.sampleData),i=fh(e.instance),a=n.length>0?n:s,{value:l,set:c}=$(e.trigger.triggerData,"config"),{column:u}=v.defaults({},l,W1),d=p=>{isNaN(+p)?c({column:p}):c({column:+p})};return i?r.jsxs(o.Stack,{children:[r.jsx(o.Alert,{icon:r.jsx(M.IconAlertCircle,{size:"1rem"}),color:"gray",children:r.jsxs(_.Trans,{i18nKey:"viz.table.click_cell.why_column_data_field",children:["Option ",r.jsx(o.Mark,{children:"Use original data columns"})," is enabled, you have to address trigger column by its data field"]})}),r.jsx(o.TextInput,{label:t("viz.table.click_cell.column_data_field"),value:u.toString(),onChange:p=>d(p.currentTarget.value)})]}):r.jsx(o.Select,{clearable:!1,data:a,label:t("viz.table.click_cell.choose_a_column"),value:u.toString(),onChange:d})}function Q1(e,t,n){const{t:s}=_.useTranslation();return e?v.isNumber(e.column)?n?s("viz.table.click_cell.click_cell_of_x_th",{x:e.column+1}):s("viz.table.click_cell.click_cell_of_x",{x:t[e.column].label}):s("viz.table.click_cell.click_cell_of_x",{x:e.column}):s("viz.table.click_cell.click_cell_content")}function U1(e){const{columnsFromConfig:t}=hh(e.instance),{value:n}=$(e.trigger.triggerData,"config"),s=fh(e.instance);return r.jsx(o.Text,{children:Q1(n,t,s)})}function gh(e,t,n){return Math.min(Math.max(e,t),n)}class Y1{constructor(t){this.steps=t;const n=[],s=new Set;for(const i of t)s.has(i.to)||(n.push(i),s.add(i.to));if(n.sort((i,a)=>i.from-a.from),n.length<2)throw new Error("MultiStepValueMapper requires at least 2 steps");this.steps=n}getLinearFunction(t,n){const s=(n.to-t.to)/(n.from-t.from),i=t.to-s*t.from;return a=>s*a+i}getStepFunctionForValue(t){let n=v.findLastIndex(this.steps,s=>s.from<=t);return n=gh(n,0,this.steps.length-2),this.getLinearFunction(this.steps[n],this.steps[n+1])}mapValue(t){return gh(this.getStepFunctionForValue(t)(t),0,100)}}class K1{constructor(t,n,s,i,a){this.getColIndex=t,this.cell=n,this.triggers=s,this.interactionManager=i,this.colorManager=a}getClickHandler(){const t=this.getRelatedTrigger();if(t.length!==0)return()=>{const n={row_data:this.cell.row.original,row_index:this.cell.row.index,col_index:this.getColIndex(this.cell)};for(const s of t)this.interactionManager.runInteraction(s.id,n)}}getRelatedTrigger(){return this.triggers.filter(n=>n.schemaRef===Ao.id).filter(n=>{const s=this.getColIndex(this.cell),i=v.get(this.cell.column.columnDef.meta,"value_field"),a=v.get(n.config,"column");return a==s||a==i})}isClickable(){return this.getRelatedTrigger().length>0}get columnConf(){return this.cell.column.columnDef.meta}get bgColor(){const t=this.columnConf.cellBackgroundColor;if(!t||t==="none")return;if(v.isString(t))return t;const n=+this.cell.getValue();if(isFinite(n)){const s=this.colorManager.decodeInterpolation(t.interpolation),a=new Y1(t.steps).mapValue(n);return s==null?void 0:s.getColor(a)}}}const X1=e=>{const t=it(e),n=st(t.triggerManager,Ao.id),{colorManager:s}=g.useContext(Gt);return g.useCallback(i=>new K1(e.getColIndex,i,n,t,s),[n,t,e.getColIndex])};function mh({queryData:e,width:t,height:n,conf:s,context:i,instance:a}){const{t:l}=_.useTranslation(),{use_raw_columns:c,ignored_column_keys:u,columns:d,...p}=s,{classes:h,cx:f}=A1(),m=g.useMemo(()=>{if(!c)return d;if(!Array.isArray(e)||e.length===0)return[];let ie=Object.keys(e[0]);const Ie=new Set(u==null?void 0:u.split(/\r?\n|\r|\n/g).filter(xe=>!!xe));return Ie.size>0&&(ie=ie.filter(xe=>!Ie.has(xe))),ie.map(xe=>({id:xe,label:xe,value_field:xe,value_type:Mt.string,align:"left",width:"",cellBackgroundColor:""}))},[c,u,d,e]),y=X1({getColIndex:g.useCallback(ie=>m.indexOf(ie.column.columnDef.meta),[m]),vizManager:i.vizManager,instance:a}),j=g.useMemo(()=>{const ie=bt.createColumnHelper();return m.map(xe=>{const se=zm(xe.value_field);return ie.accessor(se.columnKey,{cell:Fe=>r.jsx(F1,{tableCellContext:y(Fe.cell),value:Fe.getValue(),type:xe.value_type,row_data:Fe.row.original,...xe}),header:xe.label,enableSorting:!0,meta:xe,size:typeof xe.width=="number"?xe.width:void 0,minSize:typeof xe.width=="number"?xe.width:void 0})})},[m,y]),[k,S]=g.useState([]),T=bt.useReactTable({data:e,state:{sorting:k},onSortingChange:S,columns:j,columnResizeMode:"onChange",getCoreRowModel:bt.getCoreRowModel(),getSortedRowModel:bt.getSortedRowModel()}),{rows:z}=T.getRowModel(),I=g.useRef(null),E=z.length,N=E>0,R=N?n-22:n,pe=N?22:0;return r.jsxs("div",{ref:I,style:{height:n,width:t,padding:"0 5px"},"data-enable-scrollbar":!0,className:f(h.root,{"table-highlight-on-hover":s.highlightOnHover}),children:[E>0&&r.jsx(o.Box,{className:h.info_bar,sx:{height:22},children:r.jsx(o.Text,{align:"right",pr:6,size:14,color:"dimmed",fw:"normal",children:l("common.pagination.total_rows",{total:E})})}),r.jsxs(o.Table,{sx:{...P1,maxHeight:R},...p,striped:s.striped,children:[r.jsx("thead",{className:h.thead,style:{top:pe},children:T.getHeaderGroups().map(ie=>r.jsx("tr",{children:ie.headers.map(Ie=>r.jsxs("th",{style:{width:Ie.getSize()},children:[r.jsx(I1,{header:Ie,cx:f}),r.jsx(o.ActionIcon,{onMouseDown:Ie.getResizeHandler(),onTouchStart:Ie.getResizeHandler(),className:`resizer ${Ie.column.getIsResizing()?"isResizing":""}`,children:r.jsx(M.IconArrowBarToRight,{})})]},Ie.id))},ie.id))}),r.jsx(G1,{tableContainerRef:I,rows:z})]})]})}function xh(){const{t:e}=_.useTranslation();return r.jsx(o.Text,{color:"gray",align:"center",children:e("data.empty_data")})}function J1({data:e,width:t,height:n,conf:s,context:i,instance:a}){const{t:l}=_.useTranslation(),{panel:c}=St(),u=c.firstQueryData??[];if(c.queryIDs.length===0)return r.jsx(o.Text,{color:"gray",align:"center",children:l("panel.settings.need_to_choose_queries")});const{query_id:d}=s;if(!d)return u.length===0?r.jsx(xh,{}):r.jsx(mh,{queryData:u,width:t,height:n,conf:{...s,use_raw_columns:!0,columns:[]},context:i,instance:a});const p=e[d];return!Array.isArray(p)||p.length===0?r.jsx(xh,{}):r.jsx(mh,{queryData:p,width:t,height:n,conf:s,context:i,instance:a})}function Z1({context:e,instance:t}){const n=e.data,{height:s,width:i}=e.viewport,{value:a}=$(e.instanceData,"config");return a?r.jsx(J1,{data:n,width:i,height:s,conf:a,context:e,instance:t}):null}const H1=D.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,clearable:a=!1,sx:l,...c},u)=>{const{panel:d}=Ge(),p=g.useMemo(()=>d.queryOptions(s,a),[s,a]);return p.length===0?r.jsx(o.Box,{children:r.jsx(o.TextInput,{label:e,required:t,defaultValue:s,readOnly:!0,disabled:!0})}):r.jsx(o.Select,{ref:u,label:e,description:n,data:p,value:s,onChange:i,required:t,sx:l,maxDropdownHeight:500,...c})})),eD=[{from:0,to:0},{from:100,to:100}];function yh(e){return e?v.isString(e)?e==="none"?"none":"static":"interpolation":"none"}function tD(e,t){var n;return yh(t)==="static"?t:(n=e.getStaticColors()[0])==null?void 0:n.value}function nD(e,t){return v.isObject(t)?t:{steps:eD,interpolation:e.encodeColor(e.getColorInterpolations()[0])}}const rD=g.forwardRef((e,t)=>{const{t:n}=_.useTranslation(),{colorManager:s}=g.useContext(Gt),[i,a]=g.useState(yh(e.value)),[l,c]=g.useState(tD(s,e.value)),u=W.useLatest(l),[d,p]=g.useState(nD(s,e.value)),h=W.useLatest(d),f=j=>{var k,S,T;a(j||"none"),j==="static"?(k=e.onChange)==null||k.call(e,u.current):j==="none"||!j?(S=e.onChange)==null||S.call(e,"none"):(T=e.onChange)==null||T.call(e,h.current)},m=j=>{var k;c(j),(k=e.onChange)==null||k.call(e,j)},y=j=>{var k;p(j),(k=e.onChange)==null||k.call(e,j)};return r.jsxs(o.Stack,{align:"stretch",children:[r.jsx(Bv,{label:n("viz.table.column.cell_background"),value:i||"none",onChange:f}),i==="static"&&r.jsx(Be,{value:l,onChange:m}),i==="interpolation"&&r.jsx(Lv,{colorManager:s,value:d,onChange:y})]})}),sD=g.forwardRef(({value:e,onChange:t,sx:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=g.useMemo(()=>Object.values(Mt).map(c=>({label:i(`viz.table.column.value_type.${c}`),value:c})),[a.language]);return r.jsx(o.Select,{ref:s,label:i("viz.table.column.value_type.label"),data:l,value:e,onChange:t,maxDropdownHeight:500,sx:n})}),iD=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),[i,{setTrue:a,setFalse:l}]=W.useBoolean(),[c,u]=g.useState(e),d=()=>{l(),t(c)},p=()=>{l(),u(e)},h=()=>{u(lh)};return g.useEffect(()=>{u(e)},[e]),r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:a,sx:{flexGrow:0},children:s("viz.table.column.custom_cell_content")}),r.jsx(o.Modal,{size:800,title:s("viz.table.column.custom_cell_content"),opened:i,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:i&&r.jsxs(o.Stack,{children:[r.jsx(o.Group,{position:"left",children:r.jsx(iu,{})}),r.jsx(o.Box,{sx:{position:"relative"},children:r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:c,onChange:f=>u(f??""),theme:"vs-dark",options:{minimap:{enabled:!1}}})}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:h,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:s("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:p,variant:"subtle",children:s("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:d,children:s("common.actions.save")})]})]})]})})]})}),Po=()=>r.jsx(o.Text,{color:"dimmed",size:12,children:"px"}),aD=({control:e,index:t,watch:n,remove:s,column:i})=>{const{t:a}=_.useTranslation(),l=n(`columns.${t}.value_type`),c=n("query_id");return r.jsxs(o.Stack,{my:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`columns.${t}.label`,control:e,render:({field:u})=>r.jsx(o.TextInput,{label:a("chart.label.label"),required:!0,id:`col-label-${t}`,sx:{flex:1},...u})}),r.jsx(b.Controller,{name:`columns.${t}.value_field`,control:e,render:({field:u})=>r.jsx(F,{label:a("common.data_field"),required:!0,queryID:c,...u})})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`columns.${t}.value_type`,control:e,render:({field:u})=>r.jsx(sD,{sx:{flex:1},...u})}),l===Mt.custom&&r.jsx(b.Controller,{name:`columns.${t}.func_content`,control:e,render:({field:u})=>r.jsx(iD,{value:u.value??lh,onChange:d=>u.onChange(d??"")})})]}),r.jsx(o.Divider,{mb:-10,variant:"dashed",label:a("style.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.min_width"),rightSection:r.jsx(Po,{}),disabled:!0}),r.jsx(b.Controller,{name:`columns.${t}.width`,control:e,render:({field:u})=>r.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.width"),rightSection:r.jsx(Po,{}),...u})}),r.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.max_width"),rightSection:r.jsx(Po,{}),disabled:!0})]}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:`columns.${t}.align`,control:e,render:({field:u})=>r.jsx(pa,{...u})})}),r.jsx(b.Controller,{name:`columns.${t}.cellBackgroundColor`,control:e,render:({field:u})=>r.jsx(rD,{...u})}),r.jsx(o.Divider,{mb:4,mt:12,variant:"dashed"}),r.jsx(o.Button,{leftIcon:r.jsx(V.Trash,{size:16}),color:"red",variant:"light",onClick:()=>s(t),children:a("viz.table.column.delete")})]})},oD=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),{fields:s,append:i,remove:a,update:l}=b.useFieldArray({control:e,name:"columns"}),c=()=>{const d=he.randomId();i({id:d,label:d,align:"center",value_field:"",value_type:Mt.string,width:""})};t(["columns","ignored_column_keys"]);const u=t("use_raw_columns");return r.jsxs(r.Fragment,{children:[r.jsx(b.Controller,{name:"use_raw_columns",control:e,render:({field:d})=>r.jsx(o.Switch,{mt:20,mb:20,label:n("viz.table.column.use_original_data_columns"),checked:d.value,onChange:p=>d.onChange(p.currentTarget.checked)})}),u&&r.jsx(b.Controller,{name:"ignored_column_keys",control:e,render:({field:d})=>r.jsx(o.Textarea,{label:n("viz.table.column.ignore_columns_by_these_key"),placeholder:n("viz.table.column.separate_by_line_break"),autosize:!0,minRows:2,maxRows:10,...d})}),!u&&r.jsx(o.Stack,{children:r.jsxs(o.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[r.jsxs(o.Tabs.List,{children:[s.map((d,p)=>r.jsx(o.Tabs.Tab,{value:p.toString(),children:p+1},d.id)),r.jsx(o.Tabs.Tab,{onClick:c,value:"add",children:r.jsx(V.Plus,{size:18,color:"#228be6"})})]}),s.map((d,p)=>r.jsx(o.Tabs.Panel,{value:p.toString(),children:r.jsx(aD,{control:e,watch:t,index:p,column:d,remove:a})},d.id))]})})]})};function lD({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["horizontalSpacing","verticalSpacing","fontSize","striped","highlightOnHover"]),r.jsxs(o.Stack,{spacing:"xs",children:[r.jsxs(o.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[r.jsx(b.Controller,{name:"horizontalSpacing",control:e,render:({field:s})=>r.jsx(go,{disabled:!0,label:n("viz.table.style.horizontal_spacing"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"verticalSpacing",control:e,render:({field:s})=>r.jsx(go,{disabled:!0,label:n("viz.table.style.vertical_spacing"),sx:{flex:1},...s})})]}),r.jsx(o.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:r.jsx(b.Controller,{name:"fontSize",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("style.font_size.label"),placeholder:n("style.font_size.placeholder"),required:!0,sx:{flex:1},...s})})}),r.jsxs(o.Group,{position:"apart",grow:!0,children:[r.jsx(b.Controller,{name:"striped",control:e,render:({field:s})=>r.jsx(o.Switch,{label:n("viz.table.style.striped"),checked:s.value,onChange:i=>s.onChange(i.currentTarget.checked)})}),r.jsx(b.Controller,{name:"highlightOnHover",control:e,render:({field:s})=>r.jsx(o.Switch,{label:n("viz.table.style.highlight_on_hover"),checked:s.value,onChange:i=>s.onChange(i.currentTarget.checked)})})]})]})}function cD({columns:e,...t}){return{...t,columns:e.map(({id:n,...s})=>({id:n??he.randomId(),...s}))}}function uD({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaultsDeep({},n,ch),[n]),a=g.useMemo(()=>cD(i),[i]);g.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]);const h=d(),f=g.useMemo(()=>!v.isEqual(h,i),[h,i]);return u(["query_id"]),r.jsxs("form",{onSubmit:c(s),children:[r.jsx(ke,{canSubmit:f}),r.jsxs(o.Tabs,{defaultValue:"Columns",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Columns",children:t("viz.table.column.labels")}),r.jsx(o.Tabs.Tab,{value:"Style",children:t("style.label")})]}),r.jsxs(o.Tabs.Panel,{value:"Columns",children:[r.jsx(b.Controller,{name:"query_id",control:l,render:({field:m})=>r.jsx(H1,{label:t("viz.table.column.query_id"),description:t("viz.table.column.query_id_hint"),required:!0,...m})}),r.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(oD,{control:l,watch:u})]}),r.jsx(o.Tabs.Panel,{value:"Style",children:r.jsx(lD,{control:l,watch:u})})]})]})}const dD=[{lang:"en",resources:{table:{viz_name:"Table",column:{labels:"Columns",delete:"Delete this column",query_id:"Query",query_id_hint:"Load table data from this query",use_original_data_columns:"Use original data columns",ignore_columns_by_these_key:"Ignore columns by these keys",separate_by_line_break:"Separate by line break",width:"Width",min_width:"Min Width",max_width:"Max Width",cell_background:"Cell background",custom_cell_content:"Custom cell content",value_type:{label:"Value Type",string:"String",number:"Number",percentage:"Percentage",eloc:"ELOC",url:"URL",custom:"Custom"}},style:{horizontal_spacing:"Horizontal Spacing",vertical_spacing:"Vertical Spacing",striped:"Striped",highlight_on_hover:"Hightlight on hover"},click_cell:{label:"Click cell content",click_cell_content:"Click cell content (click to config)",click_cell_of_x:"Click cell of {{ x }}",click_cell_of_x_th:"Click cell by column order {{ x }}",choose_a_column:"Choose a column",why_column_data_field:"Option <1>Use original data columns</1> is enabled, you have to address trigger column by its data field",column_data_field:"Column data field"}}}},{lang:"zh",resources:{table:{viz_name:"表格",column:{labels:"列设置",delete:"删除这个列",query_id:"表格数据来源",query_id_hint:"通过所选的查询获取表格数据",use_original_data_columns:"使用数据本身的列",ignore_columns_by_these_key:"按下述列名忽略列",separate_by_line_break:"以换行符分隔",width:"宽度",min_width:"最小宽度",max_width:"最大宽度",cell_background:"单元格背景",custom_cell_content:"自定义单元格内容",value_type:{label:"数据类型",string:"文本",number:"数字",percentage:"百分比",eloc:"ELOC",url:"URL",custom:"自定义"}},style:{horizontal_spacing:"水平间距",vertical_spacing:"垂直间距",striped:"隔行变色",highlight_on_hover:"鼠标悬停时高亮整行"},click_cell:{label:"点击单元格",click_cell_content:"点击单元格内容",click_cell_of_x:"点击 {{ x }} 列单元格",click_cell_of_x_th:"点击第 {{ x }} 列单元格",choose_a_column:"选择列",why_column_data_field:"选项 <1>使用数据本身的列</1> 已开启,只能通过填写数据字段来指定触发动作的列",column_data_field:"列的数据字段"}}}}];function pD(e){const{columns:t,...n}=e;return{...e,columns:t.map(s=>({...s,align:s.align??"left"}))}}function hD(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=c=>c&&`${n}.${c}`,{id_field:i,columns:a,...l}=e;return{...l,id_field:s(i),columns:a.map(c=>({...c,value_field:s(c.value_field)}))}}catch(n){throw console.error("[Migration failed]",n),n}}function fD(e){const{columns:t,...n}=e;return{...n,columns:t.map(s=>({...s,align:s.align??"left",cellBackgroundColor:s.cellBackgroundColor??"",width:s.width??""}))}}function gD(e){const{id_field:t,...n}=e,{queryID:s}=O(t);return{...n,query_id:s??""}}function mD(e){const{ignored_column_keys:t,...n}=e;return{...n,ignored_column_keys:t??""}}class xD extends me{constructor(){super(...arguments);B(this,"VERSION",7)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{columns:s,...i}=n.config;return{...n,version:2,config:{...i,columns:s.map(({id:a,...l})=>({id:a??he.randomId(),...l}))}}}),this.version(3,n=>({...n,version:3,config:pD(n.config)})),this.version(4,(n,s)=>({...n,version:4,config:hD(n.config,s)})),this.version(5,n=>({...n,version:5,config:fD(n.config)})),this.version(6,n=>({...n,version:6,config:gD(n.config)})),this.version(7,n=>({...n,version:7,config:mD(n.config)}))}}const Oo={createConfig(){return{version:7,config:v.cloneDeep(ch)}},displayName:"viz.table.viz_name",displayGroup:"chart.groups.others",migrator:new xD,name:"table",viewRender:Z1,configRender:uD,triggers:[Ao],translation:dD},bh=["function text({ data, variables, filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
311
|
-
`),Lo={func_content:bh,horizontal_align:"left",font_size:"14px",font_weight:"normal"},yD=D.observer(({context:e})=>{const t=_e(),{value:n=Lo}=$(e.instanceData,"config"),{variables:s}=e,i=e.data,{func_content:a,horizontal_align:l,font_size:c,font_weight:u}=n,d=g.useMemo(()=>s.reduce((h,f)=>{const m=Vt(f,i);return h[f.name]=rt(f,m),h},{}),[s,i]),p=g.useMemo(()=>new Function(`return ${a}`)()({data:i,variables:d,filters:t.payloadForSQL.filters,context:t.payloadForSQL.context}),[a,i,d,t.payloadForSQL]);return r.jsx(o.Text,{align:l,weight:u,sx:{fontSize:c},children:p})}),ni=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function bD({label:e,value:t,onChange:n},s){var l;const[i,a]=g.useState(((l=ni.find(c=>c.label===t))==null?void 0:l.value)??ni[0].value);return g.useEffect(()=>{const c=ni.find(u=>u.value===i);c&&n(c.label)},[i]),r.jsxs(o.Stack,{spacing:0,mt:"sm",mb:"lg",children:[r.jsx(o.Text,{size:"sm",children:e}),r.jsx(o.Box,{px:"1.5em",children:r.jsx(o.Slider,{label:null,marks:ni,value:i,onChange:a,step:25,ref:s})})]})}const vh=g.forwardRef(bD),vD=({value:e,onChange:t})=>{const n=s=>{s&&t(s)};return r.jsx(o.Box,{sx:{position:"relative"},children:r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},_D=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),[i,{setTrue:a,setFalse:l}]=W.useBoolean(),[c,u]=g.useState(e),d=()=>{l(),t(c)},p=()=>{l(),u(e)},h=()=>{u(bh)};return g.useEffect(()=>{u(e)},[e]),r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:a,sx:{flexGrow:0},children:s("viz.text.content.edit")}),r.jsx(o.Modal,{size:800,title:s("viz.text.content.label"),opened:i,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:i&&r.jsxs(o.Stack,{children:[r.jsx(vD,{value:c,onChange:u}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:h,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:s("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:p,variant:"subtle",children:s("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:d,children:s("common.actions.save_changes")})]})]})]})})]})});function jD({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaultsDeep({},n,Lo),[n]),a=g.useMemo(()=>{const{func_content:m,horizontal_align:y,font_size:j,font_weight:k}=i;return{func_content:m,horizontal_align:y,font_size:j,font_weight:k}},[i]);g.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]),u(["func_content","horizontal_align","font_size","font_weight"]);const h=d(),f=g.useMemo(()=>!v.isEqual(h,i),[h,i]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:c(s),children:[r.jsx(ke,{canSubmit:f}),r.jsxs(o.Stack,{spacing:10,children:[r.jsx(b.Controller,{name:"func_content",control:l,render:({field:m})=>r.jsx(_D,{...m})}),r.jsx(o.Divider,{mt:10,mb:-10,variant:"dashed",label:t("chart.style.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"horizontal_align",control:l,render:({field:m})=>r.jsx(pa,{...m})}),r.jsx(b.Controller,{name:"font_size",control:l,render:({field:m})=>r.jsx(o.TextInput,{label:t("style.font_size.label"),placeholder:t("style.font_size.placeholder"),sx:{flex:1},...m})}),r.jsx(o.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:r.jsx(b.Controller,{name:"font_weight",control:l,render:({field:m})=>r.jsx(vh,{label:t("style.font_weight.label"),...m})})})]})]})})}const wD=[{lang:"en",resources:{text:{viz_name:"Text",content:{label:"Text content",edit:"Edit Content"}}}},{lang:"zh",resources:{text:{viz_name:"文本",content:{label:"文本内容",edit:"编辑文本内容"}}}}];class CD extends me{constructor(){super(...arguments);B(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const SD={displayName:"viz.text.viz_name",displayGroup:"chart.groups.others",migrator:new CD,name:"text",viewRender:yD,configRender:jD,createConfig(){return{version:1,config:v.cloneDeep(Lo)}},translation:wD},kD=()=>r.jsxs("svg",{width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22.49 27.79H14.47C13.55 27.79 12.81 28.53 12.81 29.45C12.81 30.37 13.55 31.11 14.47 31.11H22.49C23.41 31.11 24.15 30.37 24.15 29.45C24.15 28.54 23.41 27.79 22.49 27.79ZM34.32 31.28C35.22 31.32 35.7 31.82 35.74 32.76C35.78 33.54 35.37 34.3 34.51 35.04C33.52 35.9 33.03 36.95 33.03 38.19V38.81H34.82V38.25C34.78 37.59 35.07 37.02 35.68 36.52C37.12 35.41 37.82 34.15 37.78 32.75C37.66 30.53 36.5 29.35 34.32 29.23C32.3 29.23 31.05 30.46 30.55 32.93L32.53 33.55C32.82 32.04 33.42 31.28 34.32 31.28ZM35 39.93H32.84V42.21H35V39.93ZM14.83 36.42H18.54C19.46 36.42 20.2 37.17 20.2 38.08C20.2 39 19.46 39.74 18.54 39.74H10.52C9.6 39.74 8.86 39 8.86 38.08C8.86 37.61 9.06 37.19 9.37 36.89H5.66C4.74 36.89 4 36.15 4 35.23C4 34.31 4.74 33.57 5.66 33.57H13.68C14.6 33.57 15.34 34.31 15.34 35.23C15.34 35.7 15.14 36.12 14.83 36.42ZM50.94 36.85H58.74C59.66 36.85 60.4 37.59 60.41 38.51C60.41 39.43 59.67 40.17 58.75 40.17H54.26C54.56 40.47 54.74 40.88 54.74 41.34C54.74 42.26 54 43 53.08 43H50.94V36.85Z",fill:"#B8C0CC"}),r.jsx("path",{d:"M18.39 32.28H16.51V35.02H18.39V32.28Z",fill:"#9399A5"}),r.jsx("path",{d:"M46.87 15H20.69C18.38 15 16.5 16.88 16.5 19.19V26.22H18.38V23.45H49.18V47.68H18.38V41.07H16.5V49.55H51.05V19.19C51.06 16.88 49.18 15 46.87 15ZM39.46 20.73C38.81 20.73 38.29 20.2 38.29 19.56C38.29 18.92 38.82 18.39 39.46 18.39C40.11 18.39 40.63 18.92 40.63 19.56C40.63 20.2 40.11 20.73 39.46 20.73ZM43.22 20.73C42.57 20.73 42.05 20.2 42.05 19.56C42.05 18.92 42.58 18.39 43.22 18.39C43.87 18.39 44.39 18.92 44.39 19.56C44.39 20.2 43.87 20.73 43.22 20.73ZM46.97 20.73C46.32 20.73 45.8 20.2 45.8 19.56C45.8 18.92 46.33 18.39 46.97 18.39C47.62 18.39 48.14 18.92 48.14 19.56C48.14 20.2 47.62 20.73 46.97 20.73Z",fill:"#9399A5"})]});function _h(e,t){const n=v.get(e,t,"");if(n)throw new Error(n)}async function TD(e,t,n,s={}){const i={"X-Requested-With":"XMLHttpRequest","Content-Type":s.string?"application/x-www-form-urlencoded":"application/json",...s.headers},a={baseURL:e,method:"POST",url:t,params:s.params,headers:i};return a.data=s.string?JSON.stringify(n):n,At(a).then(l=>l.data).catch(l=>Promise.reject(l))}const DD=({conf:e,panelData:t})=>async()=>{const{expertSystemURL:n,path:s,goal:i,question:a}=e;if(!s||!i||!a)return;const l=Im(t);if(!l)return;const c={dashboard:i,panel:a,data:l};try{const u=n.startsWith("http")?n:window.location.origin;return await TD(u,`/expert/v3/devtable/${s}`,c,{})}catch(u){throw _h(u,"response.data.detail"),_h(u,"response.data.error"),console.error(u),u}},Bo={expertSystemURL:"",path:"",goal:"",question:""},qo={height:"100%",overflowY:"auto",...Ti},jh=({message:e})=>r.jsx(o.Box,{sx:qo,children:r.jsx("div",{dangerouslySetInnerHTML:{__html:e},style:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45"}})}),MD=({error:e,width:t,height:n})=>{const s=e.message;if(s.startsWith("<"))return r.jsx(jh,{message:s});const a=n-25-20-30;return r.jsx(o.Center,{sx:{width:"100%",height:a},children:r.jsxs(o.Stack,{align:"center",spacing:20,children:[r.jsx(kD,{}),r.jsx(jh,{message:s})]})})};function zD({context:e}){const{value:t}=$(e.instanceData,"config"),n=g.useMemo(()=>v.defaultsDeep({},t,Bo),[t]),{width:s,height:i}=e.viewport,a=e.data,{data:l,error:c,loading:u}=W.useRequest(DD({conf:n,panelData:a}),{refreshDeps:[a,n]});return!s||!i||!n?null:u?r.jsx(o.Box,{sx:{position:"relative",height:i},children:r.jsx(o.LoadingOverlay,{visible:!0})}):c?r.jsx(o.Box,{sx:qo,"data-enable-scrollbar":!0,children:r.jsx(MD,{error:c,width:s,height:i})}):!l||!Array.isArray(l.replies)||l.replies.length===0?null:r.jsx(o.Box,{sx:qo,"data-enable-scrollbar":!0,children:l.replies.map((d,p)=>r.jsx("div",{dangerouslySetInnerHTML:{__html:d.interpretation.html}},p))})}function ID({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=g.useMemo(()=>v.defaultsDeep({},t,Bo),[t]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});g.useEffect(()=>{u(s)},[s]),l(["expertSystemURL","goal","path","question"]);const d=c(),p=g.useMemo(()=>!v.isEqual(d,s),[d,s]);return r.jsx("form",{onSubmit:a(n),children:r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:"expertSystemURL",control:i,render:({field:h})=>r.jsx(o.TextInput,{label:"Expert System URL",...h})}),r.jsx(b.Controller,{name:"path",control:i,render:({field:h})=>r.jsx(o.TextInput,{label:"Path",required:!0,...h})})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:"goal",control:i,render:({field:h})=>r.jsx(o.TextInput,{label:"Goal",required:!0,...h})}),r.jsx(b.Controller,{name:"question",control:i,render:({field:h})=>r.jsx(o.TextInput,{label:"Question",required:!0,...h})})]}),r.jsx(o.Divider,{variant:"dashed",mt:16,mb:8}),r.jsx(o.Button,{type:"submit",variant:"filled",color:"blue",leftIcon:r.jsx(V.DeviceFloppy,{size:20}),disabled:!p,sx:{alignSelf:"flex-end"},children:"Submit Changes"})]})})}const ED=[{lang:"en",resources:{merico_gqm:{viz_name:"Merico GQM"}}},{lang:"zh",resources:{merico_gqm:{viz_name:"思码逸GQM组件"}}}];class AD extends me{constructor(){super(...arguments);B(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const PD={displayName:"viz.merico_gqm.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new AD,name:"mericoGQM",viewRender:zD,configRender:ID,createConfig(){return{version:1,config:v.cloneDeep(Bo)}},translation:ED};function OD(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{calendar:i,heat_block:a,tooltip:l,...c}=e;return{...c,calendar:{...i,data_key:s(i.data_key)},heat_block:{...a,data_key:s(a.data_key)},tooltip:{...l,metrics:l.metrics.map(u=>({...u,data_key:s(u.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function LD(e){const{heat_block:t}=e;let{min:n,max:s}=t;return typeof n!="number"&&(n=0),typeof s!="number"&&(s=100),{...e,heat_block:{...t,min:{type:"static",value:n},max:{type:"static",value:s}}}}function BD(e){const{visualMap:t=Ht(),heat_block:{min:n,max:s,...i},...a}=e;return{...a,heat_block:i,visualMap:{...Ht(),min:n,max:s}}}const qD=[{lang:"en",resources:{calendar_heatmap:{viz_name:"Heatmap(Calendar)",calendar:{label:"Calendar",locale:"Langauge"},click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{calendar_heatmap:{viz_name:"日历热力图",calendar:{label:"日历",locale:"语言"},click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function VD(e){return r.jsx(r.Fragment,{})}function ND(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.calendar_heatmap.click_heatmap.heatblock.label")})}const wh={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.calendar_heatmap.click_heatmap.heatblock.label",nameRender:ND,configRender:VD,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},Vo={calendar:{data_key:"",locale:"EN"},heat_block:{name:"Value",data_key:"",value_formatter:Me},tooltip:{metrics:[]},visualMap:Ht()};function $D(e,t,n){if(!e)return n[0];try{return[t,P(t).add(1,"year").subtract(1,"day").valueOf()]}catch(s){return console.error(s),n[0]}}function FD(e,t,n){const s=$D(e,t,n);return{top:50,left:25,right:5,cellSize:["auto",13],range:s,itemStyle:{borderColor:"#eee"},splitLine:{show:!0},dayLabel:{firstDay:1},monthLabel:{position:"end"},yearLabel:{show:!0}}}function GD(e){return{heat_block:function(s){if(!e.heat_block.value_formatter)return s;try{return U(s,e.heat_block.value_formatter)}catch(i){return console.error(i),s}}}}function WD(e,t){return{show:!e,selectedMode:"single",top:5,right:5,data:t.map(n=>({name:n,icon:"circle"}))}}function RD(e,t,n){return e?{type:"heatmap",name:"heatmap",coordinateSystem:"calendar",calendarIndex:0,data:n}:Object.entries(t).map(([s,i])=>({type:"heatmap",name:s,coordinateSystem:"calendar",calendarIndex:0,data:i}))}const QD=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function UD({conf:e,valueFormatters:t,dataDict:n,params:s}){const{value:i}=s,[a,l]=i,u=[{label:e.heat_block.name,value:t.heat_block(l),style:{label:"",value:""}}],d=n[a];return d&&e.tooltip.metrics.forEach(p=>{const h=O(p.data_key);u.push({label:p.name,value:QD(v.get(d,h.columnKey,"")),style:{label:"",value:""}})}),u}function YD(e,t,n){const s=O(e.calendar.data_key),i=v.keyBy(t[s.queryID],s.columnKey);return te.getTooltip({formatter:function(a){const c=UD({conf:e,valueFormatters:n,dataDict:i,params:a}).map(p=>`
|
|
309
|
+
`}}function x1(){return te.getTooltip({trigger:"item",formatter:m1()})}const y1={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function b1(e,t,n){n.reduce((a,l)=>{const c=Vt(l,t);return a[l.name]=rt(l,c),a},{});const i={series:{data:h1(e,t),levels:g1(e)},tooltip:x1()};return v.defaultsDeep({},i,y1)}function v1({context:e}){const{variables:t}=e,{value:n}=$(e.instanceData,"config"),s=g.useMemo(()=>v.defaults({},n,Eo),[n]),i=e.data,{width:a,height:l}=e.viewport,c=g.useMemo(()=>b1(s,i,t),[s,i,t]);return!a||!l?null:r.jsx(Ue,{width:a,height:l,children:r.jsx(Pe,{echarts:Ae,option:c,style:jr(a,l),notMerge:!0,theme:"merico-light"})})}function _1({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["label_key","value_key","group_key"]),r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:"label_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.name_data_field"),required:!0,...s})}),r.jsx(b.Controller,{name:"value_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.value_data_field"),required:!0,...s})}),r.jsx(b.Controller,{name:"group_key",control:e,render:({field:s})=>r.jsx(F,{label:n("viz.sunburst_chart.group_key"),clearable:!0,...s})})]})}const j1=({control:e,index:t})=>{const{t:n,i18n:s}=_.useTranslation(),i=g.useMemo(()=>[{label:n("viz.sunburst_chart.label.rotate.radial"),value:"radial"},{label:n("viz.sunburst_chart.label.rotate.tangential"),value:"tangential"},{label:n("viz.sunburst_chart.label.rotate.none"),value:"0"}],[s.language]);return r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`levels.${t}.r0`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:n("viz.sunburst_chart.level.inside_radius"),placeholder:"0%",...a})}),r.jsx(b.Controller,{name:`levels.${t}.r`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:n("viz.sunburst_chart.level.outside_radius"),placeholder:"50%",...a})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:n("chart.label.label_full"),labelPosition:"center"}),r.jsx(b.Controller,{name:`levels.${t}.label.show_label_tolerance`,control:e,render:({field:a})=>r.jsx(o.NumberInput,{label:n("viz.sunburst_chart.label.show_label_tolerance"),precision:4,step:5e-4,min:0,max:1,...a})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`levels.${t}.label.rotate`,control:e,render:({field:a})=>r.jsx(o.Select,{label:n("viz.sunburst_chart.label.rotate.label"),data:i,...a})}),r.jsx(b.Controller,{name:`levels.${t}.label.align`,control:e,render:({field:a})=>r.jsx(bn,{...a})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`levels.${t}.label.position`,control:e,render:({field:a})=>r.jsx(nr,{label:n("chart.label_position.label"),...a,onChange:l=>{l&&a.onChange(l)}})}),r.jsx(b.Controller,{name:`levels.${t}.label.padding`,control:e,render:({field:a})=>r.jsx(o.NumberInput,{label:n("chart.padding"),min:0,hideControls:!0,...a})})]})]})},w1=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),r0:"",r:"",label:{show_label_tolerance:.001,rotate:"0",align:"center",position:"inside",padding:0}}),i=(a,l)=>l+1;return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("viz.sunburst_chart.level.hint")})]}),r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(ge,{control:e,watch:t,name:"levels",getItem:s,addButtonText:n("viz.sunburst_chart.level.add"),deleteButtonText:n("viz.sunburst_chart.level.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(j1,{control:e,index:l})})]})};function C1({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaultsDeep({},n,Eo),[n]),a=g.useMemo(()=>v.clone(i),[i]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]);const h=d(),f=g.useMemo(()=>!v.isEqual(h,i),[h,i]);u(["label_key","value_key","group_key","levels"]);const[m,y]=g.useState("Data");return r.jsx("form",{onSubmit:c(s),children:r.jsxs(o.Stack,{spacing:"xs",children:[r.jsx(ke,{canSubmit:f}),r.jsxs(o.Tabs,{value:m,onTabChange:y,orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Data",children:t("data.label")}),r.jsx(o.Tabs.Tab,{value:"Levels",children:t("viz.sunburst_chart.level.labels")})]}),r.jsx(o.Tabs.Panel,{value:"Data",children:r.jsx(_1,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Levels",children:r.jsx(w1,{control:l,watch:u})})]})]})})}const S1=[{lang:"en",resources:{sunburst_chart:{viz_name:"Sunburst Chart",level:{labels:"Levels",hint:"Configure ring style on each level",inside_radius:"Inside Radius",outside_radius:"Outside Radius",add:"Add a level",delete:"Delete this level"},label:{show_label_tolerance:"Hide label when its percentage is less than...",rotate:{label:"Rotate",radial:"Radial",tangential:"Tangential",none:"None"}},group_key:"Group Key"}}},{lang:"zh",resources:{sunburst_chart:{viz_name:"旭日图",level:{labels:"层级",hint:"为每层配置圆环样式",inside_radius:"内径",outside_radius:"外径",add:"增加一层",delete:"删除这一层"},label:{show_label_tolerance:"当百分比低于此值时,隐藏文案",rotate:{label:"旋转",radial:"径向旋转",tangential:"切向旋转",none:"不旋转"}},group_key:"分组字段"}}}];function k1(e){const{label_field:t,value_field:n,...s}=e;return{...s,label_key:t,value_key:n}}function T1(e){const{group_key:t="",...n}=e;return{...n,group_key:t}}function D1(e){const{levels:t=[],...n}=e;return{...n,levels:t}}function M1(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{label_key:i,value_key:a,group_key:l,...c}=e;return{...c,label_key:s(i),value_key:s(a),group_key:s(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class z1 extends me{constructor(){super(...arguments);B(this,"VERSION",5)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:k1(n.config)})),this.version(3,n=>({...n,version:3,config:T1(n.config)})),this.version(4,n=>({...n,version:4,config:D1(n.config)})),this.version(5,(n,s)=>({...n,version:5,config:M1(n.config,s)}))}}const I1={displayName:"viz.sunburst_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new z1,name:"sunburst",viewRender:v1,configRender:C1,createConfig(){return{version:5,config:v.cloneDeep(Eo)}},translation:S1};var Mt=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e.url="url",e.custom="custom",e))(Mt||{});const lh=["function text({ value, row_data }, utils) {"," return value","}"].join(`
|
|
310
|
+
`),ch={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",query_id:"",striped:!0,use_raw_columns:!0,ignored_column_keys:"",verticalSpacing:"14px"},uh={left:"flex-start",center:"center",right:"flex-end"},E1=({header:e,cx:t})=>{const n=v.get(e.column.columnDef.meta,"align","left");return r.jsxs(o.Text,{className:t("table-head-cell",{"table-head-cell--sortable":e.column.getCanSort()}),onClick:e.column.getToggleSortingHandler(),align:n,sx:{justifyContent:uh[n]},children:[e.isPlaceholder?null:bt.flexRender(e.column.columnDef.header,e.getContext()),r.jsx(A1,{direction:e.column.getIsSorted()})]})},A1=({direction:e})=>{switch(e){case"asc":return r.jsx(M.IconArrowUp,{size:16});case"desc":return r.jsx(M.IconArrowDown,{size:"1em"});default:return null}},P1=o.createStyles(e=>({root:{overflow:"auto",position:"relative","& .table-head-cell":{display:"flex",flexFlow:"row nowrap",alignItems:"center",whiteSpace:"nowrap","&.table-head-cell--sortable":{cursor:"pointer",userSelect:"none"}},"&.table-highlight-on-hover tr":{transition:"background-color 0.2s","&:hover":{backgroundColor:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[0]}}},thead:{background:e.colorScheme==="dark"?e.colors.dark[7]:e.white,position:"sticky",top:24,transform:"translateY(-1px)",zIndex:10},info_bar:{position:"sticky",top:0,left:0,right:0,zIndex:10,background:"white"}})),O1={tableLayout:"fixed",width:"fit-content",minWidth:"100%","thead, tbody":{tr:{width:"fit-content",th:{position:"relative"},"th, td":{padding:"2px 10px",div:{overflow:"hidden",textOverflow:"ellipsis"},"&:first-of-type":{paddingLeft:2,paddingRight:2}}}},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",transform:"translateY(-50%)",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}},dh=o.createStyles((e,t)=>({content:{display:"flex",alignItems:"center",justifyContent:uh[t.align],".table-cell-text":{whiteSpace:"nowrap",cursor:t.clickable?"pointer":"default",textDecoration:t.clickable?"underline":"none"}}}));function L1(e){return e?Qt(e).oklch()[0]>.7?"black":"white":"inherit"}function ph(e){const t=e.tableCellContext.bgColor;return{backgroundColor:t,color:L1(t)}}function sr(e){const t=e.tableCellContext.isClickable(),n=dh({clickable:t,align:e.align});return r.jsx("div",{className:n.classes.content,style:{...ph(e)},children:r.jsx(o.Text,{className:"table-cell-text",onClick:e.tableCellContext.getClickHandler(),children:r.jsx("span",{title:e.children,children:e.children})})})}function B1(e){return r.jsx(sr,{...e,children:e.value})}function q1(e){const t=dh({clickable:!0,align:e.align}),n=e.value;return r.jsx("div",{className:t.classes.content,style:{...ph(e)},children:r.jsx(o.Anchor,{className:"table-cell-text",href:n,target:"_blank",color:"black",children:n})})}function V1(e){const t=U(e.value,{output:"number",average:!0,mantissa:2,trimMantissa:!0,absolute:!1});return r.jsx(sr,{...e,children:t})}function N1(e){const t=U(e.value,{output:"number",mantissa:0,thousandSeparated:!0,absolute:!1});return r.jsx(sr,{...e,children:t})}function $1(e){const t=U(e.value,{output:"percent",mantissa:3,trimMantissa:!0,absolute:!1});return r.jsx(sr,{...e,children:t})}function F1(e){const{value:t,row_data:n,func_content:s}=e;if(!s)return r.jsx(sr,{...e,children:t});const i=new Function(`return ${s}`)()({value:t,row_data:n},vt);return r.jsx(sr,{...e,children:i})}function G1(e){switch(e.type){case Mt.string:return r.jsx(B1,{...e});case Mt.eloc:return r.jsx(V1,{...e});case Mt.number:return r.jsx(N1,{...e});case Mt.percentage:return r.jsx($1,{...e});case Mt.url:return r.jsx(q1,{...e});case Mt.custom:return r.jsx(F1,{...e})}}function W1({tableContainerRef:e,rows:t}){var c,u;const n=Ag.useVirtual({parentRef:e,size:t.length,estimateSize:g.useCallback(()=>28,[]),overscan:20}),{virtualItems:s,totalSize:i}=n,a=s.length>0&&((c=s==null?void 0:s[0])==null?void 0:c.start)||0,l=s.length>0?i-(((u=s==null?void 0:s[s.length-1])==null?void 0:u.end)||0):0;return r.jsxs("tbody",{children:[a>0&&r.jsx("tr",{children:r.jsx("td",{style:{height:`${a}px`}})}),s.map(d=>{const p=t[d.index];return r.jsx("tr",{children:p.getVisibleCells().map(h=>r.jsx("td",{children:bt.flexRender(h.column.columnDef.cell,h.getContext())},h.id))},p.id)}),l>0&&r.jsx("tr",{children:r.jsx("td",{style:{height:`${l}px`}})})]})}const Ao={id:"builtin:table:click-cell-content",displayName:"viz.table.click_cell.click_cell_content",nameRender:Y1,configRender:Q1,payload:[{name:"row_index",description:"Index of the row that the cell belongs to",valueType:"number"},{name:"col_index",description:"Index of the column that the cell belongs to",valueType:"number"},{name:"row_data",description:"Data of the row that the cell belongs to",valueType:"object"}]},R1={column:""};function hh(e,t){const{value:n}=$(e.instanceData,"config"),s={columnsFromConfig:[],columnsFromData:[]};if(n&&(s.columnsFromConfig=n.columns.map((i,a)=>({label:i.label,value:a.toString()}))),!t)return s;if(n!=null&&n.query_id){const i=t[n.query_id];(i==null?void 0:i.length)>0&&(s.columnsFromData=Object.keys(i[0]).map(a=>({label:a,value:a})))}return s}function fh(e){const{value:t}=$(e.instanceData,"config");return(t==null?void 0:t.use_raw_columns)??!1}function Q1(e){const{t}=_.useTranslation(),{columnsFromConfig:n,columnsFromData:s}=hh(e.instance,e.sampleData),i=fh(e.instance),a=n.length>0?n:s,{value:l,set:c}=$(e.trigger.triggerData,"config"),{column:u}=v.defaults({},l,R1),d=p=>{isNaN(+p)?c({column:p}):c({column:+p})};return i?r.jsxs(o.Stack,{children:[r.jsx(o.Alert,{icon:r.jsx(M.IconAlertCircle,{size:"1rem"}),color:"gray",children:r.jsxs(_.Trans,{i18nKey:"viz.table.click_cell.why_column_data_field",children:["Option ",r.jsx(o.Mark,{children:"Use original data columns"})," is enabled, you have to address trigger column by its data field"]})}),r.jsx(o.TextInput,{label:t("viz.table.click_cell.column_data_field"),value:u.toString(),onChange:p=>d(p.currentTarget.value)})]}):r.jsx(o.Select,{clearable:!1,data:a,label:t("viz.table.click_cell.choose_a_column"),value:u.toString(),onChange:d})}function U1(e,t,n){const{t:s}=_.useTranslation();return e?v.isNumber(e.column)?n?s("viz.table.click_cell.click_cell_of_x_th",{x:e.column+1}):s("viz.table.click_cell.click_cell_of_x",{x:t[e.column].label}):s("viz.table.click_cell.click_cell_of_x",{x:e.column}):s("viz.table.click_cell.click_cell_content")}function Y1(e){const{columnsFromConfig:t}=hh(e.instance),{value:n}=$(e.trigger.triggerData,"config"),s=fh(e.instance);return r.jsx(o.Text,{children:U1(n,t,s)})}function gh(e,t,n){return Math.min(Math.max(e,t),n)}class K1{constructor(t){this.steps=t;const n=[],s=new Set;for(const i of t)s.has(i.to)||(n.push(i),s.add(i.to));if(n.sort((i,a)=>i.from-a.from),n.length<2)throw new Error("MultiStepValueMapper requires at least 2 steps");this.steps=n}getLinearFunction(t,n){const s=(n.to-t.to)/(n.from-t.from),i=t.to-s*t.from;return a=>s*a+i}getStepFunctionForValue(t){let n=v.findLastIndex(this.steps,s=>s.from<=t);return n=gh(n,0,this.steps.length-2),this.getLinearFunction(this.steps[n],this.steps[n+1])}mapValue(t){return gh(this.getStepFunctionForValue(t)(t),0,100)}}class X1{constructor(t,n,s,i,a){this.getColIndex=t,this.cell=n,this.triggers=s,this.interactionManager=i,this.colorManager=a}getClickHandler(){const t=this.getRelatedTrigger();if(t.length!==0)return()=>{const n={row_data:this.cell.row.original,row_index:this.cell.row.index,col_index:this.getColIndex(this.cell)};for(const s of t)this.interactionManager.runInteraction(s.id,n)}}getRelatedTrigger(){return this.triggers.filter(n=>n.schemaRef===Ao.id).filter(n=>{const s=this.getColIndex(this.cell),i=v.get(this.cell.column.columnDef.meta,"value_field"),a=v.get(n.config,"column");return a==s||a==i})}isClickable(){return this.getRelatedTrigger().length>0}get columnConf(){return this.cell.column.columnDef.meta}get bgColor(){const t=this.columnConf.cellBackgroundColor;if(!t||t==="none")return;if(v.isString(t))return t;const n=+this.cell.getValue();if(isFinite(n)){const s=this.colorManager.decodeInterpolation(t.interpolation),a=new K1(t.steps).mapValue(n);return s==null?void 0:s.getColor(a)}}}const J1=e=>{const t=it(e),n=st(t.triggerManager,Ao.id),{colorManager:s}=g.useContext(Gt);return g.useCallback(i=>new X1(e.getColIndex,i,n,t,s),[n,t,e.getColIndex])};function mh({queryData:e,width:t,height:n,conf:s,context:i,instance:a}){const{t:l}=_.useTranslation(),{use_raw_columns:c,ignored_column_keys:u,columns:d,...p}=s,{classes:h,cx:f}=P1(),m=g.useMemo(()=>{if(!c)return d;if(!Array.isArray(e)||e.length===0)return[];let ie=Object.keys(e[0]);const Ie=new Set(u==null?void 0:u.split(/\r?\n|\r|\n/g).filter(xe=>!!xe));return Ie.size>0&&(ie=ie.filter(xe=>!Ie.has(xe))),ie.map(xe=>({id:xe,label:xe,value_field:xe,value_type:Mt.string,align:"left",width:"",cellBackgroundColor:""}))},[c,u,d,e]),y=J1({getColIndex:g.useCallback(ie=>m.indexOf(ie.column.columnDef.meta),[m]),vizManager:i.vizManager,instance:a}),j=g.useMemo(()=>{const ie=bt.createColumnHelper();return m.map(xe=>{const se=zm(xe.value_field);return ie.accessor(se.columnKey,{cell:Fe=>r.jsx(G1,{tableCellContext:y(Fe.cell),value:Fe.getValue(),type:xe.value_type,row_data:Fe.row.original,...xe}),header:xe.label,enableSorting:!0,meta:xe,size:typeof xe.width=="number"?xe.width:void 0,minSize:typeof xe.width=="number"?xe.width:void 0})})},[m,y]),[k,S]=g.useState([]),T=bt.useReactTable({data:e,state:{sorting:k},onSortingChange:S,columns:j,columnResizeMode:"onChange",getCoreRowModel:bt.getCoreRowModel(),getSortedRowModel:bt.getSortedRowModel()}),{rows:z}=T.getRowModel(),I=g.useRef(null),E=z.length,N=E>0,R=N?n-22:n,pe=N?22:0;return r.jsxs("div",{ref:I,style:{height:n,width:t,padding:"0 5px"},"data-enable-scrollbar":!0,className:f(h.root,{"table-highlight-on-hover":s.highlightOnHover}),children:[E>0&&r.jsx(o.Box,{className:h.info_bar,sx:{height:22},children:r.jsx(o.Text,{align:"right",pr:6,size:14,color:"dimmed",fw:"normal",children:l("common.pagination.total_rows",{total:E})})}),r.jsxs(o.Table,{sx:{...O1,maxHeight:R},...p,striped:s.striped,children:[r.jsx("thead",{className:h.thead,style:{top:pe},children:T.getHeaderGroups().map(ie=>r.jsx("tr",{children:ie.headers.map(Ie=>r.jsxs("th",{style:{width:Ie.getSize()},children:[r.jsx(E1,{header:Ie,cx:f}),r.jsx(o.ActionIcon,{onMouseDown:Ie.getResizeHandler(),onTouchStart:Ie.getResizeHandler(),className:`resizer ${Ie.column.getIsResizing()?"isResizing":""}`,children:r.jsx(M.IconArrowBarToRight,{})})]},Ie.id))},ie.id))}),r.jsx(W1,{tableContainerRef:I,rows:z})]})]})}function xh(){const{t:e}=_.useTranslation();return r.jsx(o.Text,{color:"gray",align:"center",children:e("data.empty_data")})}function Z1({data:e,width:t,height:n,conf:s,context:i,instance:a}){const{t:l}=_.useTranslation(),{panel:c}=St(),u=c.firstQueryData??[];if(c.queryIDs.length===0)return r.jsx(o.Text,{color:"gray",align:"center",children:l("panel.settings.need_to_choose_queries")});const{query_id:d}=s;if(!d)return u.length===0?r.jsx(xh,{}):r.jsx(mh,{queryData:u,width:t,height:n,conf:{...s,use_raw_columns:!0,columns:[]},context:i,instance:a});const p=e[d];return!Array.isArray(p)||p.length===0?r.jsx(xh,{}):r.jsx(mh,{queryData:p,width:t,height:n,conf:s,context:i,instance:a})}function H1({context:e,instance:t}){const n=e.data,{height:s,width:i}=e.viewport,{value:a}=$(e.instanceData,"config");return a?r.jsx(Z1,{data:n,width:i,height:s,conf:a,context:e,instance:t}):null}const eD=D.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,clearable:a=!1,sx:l,...c},u)=>{const{panel:d}=Ge(),p=g.useMemo(()=>d.queryOptions(s,a),[s,a]);return p.length===0?r.jsx(o.Box,{children:r.jsx(o.TextInput,{label:e,required:t,defaultValue:s,readOnly:!0,disabled:!0})}):r.jsx(o.Select,{ref:u,label:e,description:n,data:p,value:s,onChange:i,required:t,sx:l,maxDropdownHeight:500,...c})})),tD=[{from:0,to:0},{from:100,to:100}];function yh(e){return e?v.isString(e)?e==="none"?"none":"static":"interpolation":"none"}function nD(e,t){var n;return yh(t)==="static"?t:(n=e.getStaticColors()[0])==null?void 0:n.value}function rD(e,t){return v.isObject(t)?t:{steps:tD,interpolation:e.encodeColor(e.getColorInterpolations()[0])}}const sD=g.forwardRef((e,t)=>{const{t:n}=_.useTranslation(),{colorManager:s}=g.useContext(Gt),[i,a]=g.useState(yh(e.value)),[l,c]=g.useState(nD(s,e.value)),u=W.useLatest(l),[d,p]=g.useState(rD(s,e.value)),h=W.useLatest(d),f=j=>{var k,S,T;a(j||"none"),j==="static"?(k=e.onChange)==null||k.call(e,u.current):j==="none"||!j?(S=e.onChange)==null||S.call(e,"none"):(T=e.onChange)==null||T.call(e,h.current)},m=j=>{var k;c(j),(k=e.onChange)==null||k.call(e,j)},y=j=>{var k;p(j),(k=e.onChange)==null||k.call(e,j)};return r.jsxs(o.Stack,{align:"stretch",children:[r.jsx(Bv,{label:n("viz.table.column.cell_background"),value:i||"none",onChange:f}),i==="static"&&r.jsx(Be,{value:l,onChange:m}),i==="interpolation"&&r.jsx(Lv,{colorManager:s,value:d,onChange:y})]})}),iD=g.forwardRef(({value:e,onChange:t,sx:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=g.useMemo(()=>Object.values(Mt).map(c=>({label:i(`viz.table.column.value_type.${c}`),value:c})),[a.language]);return r.jsx(o.Select,{ref:s,label:i("viz.table.column.value_type.label"),data:l,value:e,onChange:t,maxDropdownHeight:500,sx:n})}),aD=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),[i,{setTrue:a,setFalse:l}]=W.useBoolean(),[c,u]=g.useState(e),d=()=>{l(),t(c)},p=()=>{l(),u(e)},h=()=>{u(lh)};return g.useEffect(()=>{u(e)},[e]),r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:a,sx:{flexGrow:0},children:s("viz.table.column.custom_cell_content")}),r.jsx(o.Modal,{size:800,title:s("viz.table.column.custom_cell_content"),opened:i,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:i&&r.jsxs(o.Stack,{children:[r.jsx(o.Group,{position:"left",children:r.jsx(iu,{})}),r.jsx(o.Box,{sx:{position:"relative"},children:r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:c,onChange:f=>u(f??""),theme:"vs-dark",options:{minimap:{enabled:!1}}})}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:h,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:s("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:p,variant:"subtle",children:s("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:d,children:s("common.actions.save")})]})]})]})})]})}),Po=()=>r.jsx(o.Text,{color:"dimmed",size:12,children:"px"}),oD=({control:e,index:t,watch:n,remove:s,column:i})=>{const{t:a}=_.useTranslation(),l=n(`columns.${t}.value_type`),c=n("query_id");return r.jsxs(o.Stack,{my:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`columns.${t}.label`,control:e,render:({field:u})=>r.jsx(o.TextInput,{label:a("chart.label.label"),required:!0,id:`col-label-${t}`,sx:{flex:1},...u})}),r.jsx(b.Controller,{name:`columns.${t}.value_field`,control:e,render:({field:u})=>r.jsx(F,{label:a("common.data_field"),required:!0,queryID:c,...u})})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`columns.${t}.value_type`,control:e,render:({field:u})=>r.jsx(iD,{sx:{flex:1},...u})}),l===Mt.custom&&r.jsx(b.Controller,{name:`columns.${t}.func_content`,control:e,render:({field:u})=>r.jsx(aD,{value:u.value??lh,onChange:d=>u.onChange(d??"")})})]}),r.jsx(o.Divider,{mb:-10,variant:"dashed",label:a("style.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.min_width"),rightSection:r.jsx(Po,{}),disabled:!0}),r.jsx(b.Controller,{name:`columns.${t}.width`,control:e,render:({field:u})=>r.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.width"),rightSection:r.jsx(Po,{}),...u})}),r.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.max_width"),rightSection:r.jsx(Po,{}),disabled:!0})]}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:`columns.${t}.align`,control:e,render:({field:u})=>r.jsx(pa,{...u})})}),r.jsx(b.Controller,{name:`columns.${t}.cellBackgroundColor`,control:e,render:({field:u})=>r.jsx(sD,{...u})}),r.jsx(o.Divider,{mb:4,mt:12,variant:"dashed"}),r.jsx(o.Button,{leftIcon:r.jsx(V.Trash,{size:16}),color:"red",variant:"light",onClick:()=>s(t),children:a("viz.table.column.delete")})]})},lD=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),{fields:s,append:i,remove:a,update:l}=b.useFieldArray({control:e,name:"columns"}),c=()=>{const d=he.randomId();i({id:d,label:d,align:"center",value_field:"",value_type:Mt.string,width:""})};t(["columns","ignored_column_keys"]);const u=t("use_raw_columns");return r.jsxs(r.Fragment,{children:[r.jsx(b.Controller,{name:"use_raw_columns",control:e,render:({field:d})=>r.jsx(o.Switch,{mt:20,mb:20,label:n("viz.table.column.use_original_data_columns"),checked:d.value,onChange:p=>d.onChange(p.currentTarget.checked)})}),u&&r.jsx(b.Controller,{name:"ignored_column_keys",control:e,render:({field:d})=>r.jsx(o.Textarea,{label:n("viz.table.column.ignore_columns_by_these_key"),placeholder:n("viz.table.column.separate_by_line_break"),autosize:!0,minRows:2,maxRows:10,...d})}),!u&&r.jsx(o.Stack,{children:r.jsxs(o.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[r.jsxs(o.Tabs.List,{children:[s.map((d,p)=>r.jsx(o.Tabs.Tab,{value:p.toString(),children:p+1},d.id)),r.jsx(o.Tabs.Tab,{onClick:c,value:"add",children:r.jsx(V.Plus,{size:18,color:"#228be6"})})]}),s.map((d,p)=>r.jsx(o.Tabs.Panel,{value:p.toString(),children:r.jsx(oD,{control:e,watch:t,index:p,column:d,remove:a})},d.id))]})})]})};function cD({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["horizontalSpacing","verticalSpacing","fontSize","striped","highlightOnHover"]),r.jsxs(o.Stack,{spacing:"xs",children:[r.jsxs(o.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[r.jsx(b.Controller,{name:"horizontalSpacing",control:e,render:({field:s})=>r.jsx(go,{disabled:!0,label:n("viz.table.style.horizontal_spacing"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"verticalSpacing",control:e,render:({field:s})=>r.jsx(go,{disabled:!0,label:n("viz.table.style.vertical_spacing"),sx:{flex:1},...s})})]}),r.jsx(o.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:r.jsx(b.Controller,{name:"fontSize",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("style.font_size.label"),placeholder:n("style.font_size.placeholder"),required:!0,sx:{flex:1},...s})})}),r.jsxs(o.Group,{position:"apart",grow:!0,children:[r.jsx(b.Controller,{name:"striped",control:e,render:({field:s})=>r.jsx(o.Switch,{label:n("viz.table.style.striped"),checked:s.value,onChange:i=>s.onChange(i.currentTarget.checked)})}),r.jsx(b.Controller,{name:"highlightOnHover",control:e,render:({field:s})=>r.jsx(o.Switch,{label:n("viz.table.style.highlight_on_hover"),checked:s.value,onChange:i=>s.onChange(i.currentTarget.checked)})})]})]})}function uD({columns:e,...t}){return{...t,columns:e.map(({id:n,...s})=>({id:n??he.randomId(),...s}))}}function dD({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaultsDeep({},n,ch),[n]),a=g.useMemo(()=>uD(i),[i]);g.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]);const h=d(),f=g.useMemo(()=>!v.isEqual(h,i),[h,i]);return u(["query_id"]),r.jsxs("form",{onSubmit:c(s),children:[r.jsx(ke,{canSubmit:f}),r.jsxs(o.Tabs,{defaultValue:"Columns",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Columns",children:t("viz.table.column.labels")}),r.jsx(o.Tabs.Tab,{value:"Style",children:t("style.label")})]}),r.jsxs(o.Tabs.Panel,{value:"Columns",children:[r.jsx(b.Controller,{name:"query_id",control:l,render:({field:m})=>r.jsx(eD,{label:t("viz.table.column.query_id"),description:t("viz.table.column.query_id_hint"),required:!0,...m})}),r.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(lD,{control:l,watch:u})]}),r.jsx(o.Tabs.Panel,{value:"Style",children:r.jsx(cD,{control:l,watch:u})})]})]})}const pD=[{lang:"en",resources:{table:{viz_name:"Table",column:{labels:"Columns",delete:"Delete this column",query_id:"Query",query_id_hint:"Load table data from this query",use_original_data_columns:"Use original data columns",ignore_columns_by_these_key:"Ignore columns by these keys",separate_by_line_break:"Separate by line break",width:"Width",min_width:"Min Width",max_width:"Max Width",cell_background:"Cell background",custom_cell_content:"Custom cell content",value_type:{label:"Value Type",string:"String",number:"Number",percentage:"Percentage",eloc:"ELOC",url:"URL",custom:"Custom"}},style:{horizontal_spacing:"Horizontal Spacing",vertical_spacing:"Vertical Spacing",striped:"Striped",highlight_on_hover:"Hightlight on hover"},click_cell:{label:"Click cell content",click_cell_content:"Click cell content (click to config)",click_cell_of_x:"Click cell of {{ x }}",click_cell_of_x_th:"Click cell by column order {{ x }}",choose_a_column:"Choose a column",why_column_data_field:"Option <1>Use original data columns</1> is enabled, you have to address trigger column by its data field",column_data_field:"Column data field"}}}},{lang:"zh",resources:{table:{viz_name:"表格",column:{labels:"列设置",delete:"删除这个列",query_id:"表格数据来源",query_id_hint:"通过所选的查询获取表格数据",use_original_data_columns:"使用数据本身的列",ignore_columns_by_these_key:"按下述列名忽略列",separate_by_line_break:"以换行符分隔",width:"宽度",min_width:"最小宽度",max_width:"最大宽度",cell_background:"单元格背景",custom_cell_content:"自定义单元格内容",value_type:{label:"数据类型",string:"文本",number:"数字",percentage:"百分比",eloc:"ELOC",url:"URL",custom:"自定义"}},style:{horizontal_spacing:"水平间距",vertical_spacing:"垂直间距",striped:"隔行变色",highlight_on_hover:"鼠标悬停时高亮整行"},click_cell:{label:"点击单元格",click_cell_content:"点击单元格内容",click_cell_of_x:"点击 {{ x }} 列单元格",click_cell_of_x_th:"点击第 {{ x }} 列单元格",choose_a_column:"选择列",why_column_data_field:"选项 <1>使用数据本身的列</1> 已开启,只能通过填写数据字段来指定触发动作的列",column_data_field:"列的数据字段"}}}}];function hD(e){const{columns:t,...n}=e;return{...e,columns:t.map(s=>({...s,align:s.align??"left"}))}}function fD(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=c=>c&&`${n}.${c}`,{id_field:i,columns:a,...l}=e;return{...l,id_field:s(i),columns:a.map(c=>({...c,value_field:s(c.value_field)}))}}catch(n){throw console.error("[Migration failed]",n),n}}function gD(e){const{columns:t,...n}=e;return{...n,columns:t.map(s=>({...s,align:s.align??"left",cellBackgroundColor:s.cellBackgroundColor??"",width:s.width??""}))}}function mD(e){const{id_field:t,...n}=e,{queryID:s}=O(t);return{...n,query_id:s??""}}function xD(e){const{ignored_column_keys:t,...n}=e;return{...n,ignored_column_keys:t??""}}class yD extends me{constructor(){super(...arguments);B(this,"VERSION",7)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{columns:s,...i}=n.config;return{...n,version:2,config:{...i,columns:s.map(({id:a,...l})=>({id:a??he.randomId(),...l}))}}}),this.version(3,n=>({...n,version:3,config:hD(n.config)})),this.version(4,(n,s)=>({...n,version:4,config:fD(n.config,s)})),this.version(5,n=>({...n,version:5,config:gD(n.config)})),this.version(6,n=>({...n,version:6,config:mD(n.config)})),this.version(7,n=>({...n,version:7,config:xD(n.config)}))}}const Oo={createConfig(){return{version:7,config:v.cloneDeep(ch)}},displayName:"viz.table.viz_name",displayGroup:"chart.groups.others",migrator:new yD,name:"table",viewRender:H1,configRender:dD,triggers:[Ao],translation:pD},bh=["function text({ data, variables, filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
311
|
+
`),Lo={func_content:bh,horizontal_align:"left",font_size:"14px",font_weight:"normal"},bD=D.observer(({context:e})=>{const t=_e(),{value:n=Lo}=$(e.instanceData,"config"),{variables:s}=e,i=e.data,{func_content:a,horizontal_align:l,font_size:c,font_weight:u}=n,d=g.useMemo(()=>s.reduce((h,f)=>{const m=Vt(f,i);return h[f.name]=rt(f,m),h},{}),[s,i]),p=g.useMemo(()=>new Function(`return ${a}`)()({data:i,variables:d,filters:t.payloadForSQL.filters,context:t.payloadForSQL.context}),[a,i,d,t.payloadForSQL]);return r.jsx(o.Text,{align:l,weight:u,sx:{fontSize:c},children:p})}),ni=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function vD({label:e,value:t,onChange:n},s){var l;const[i,a]=g.useState(((l=ni.find(c=>c.label===t))==null?void 0:l.value)??ni[0].value);return g.useEffect(()=>{const c=ni.find(u=>u.value===i);c&&n(c.label)},[i]),r.jsxs(o.Stack,{spacing:0,mt:"sm",mb:"lg",children:[r.jsx(o.Text,{size:"sm",children:e}),r.jsx(o.Box,{px:"1.5em",children:r.jsx(o.Slider,{label:null,marks:ni,value:i,onChange:a,step:25,ref:s})})]})}const vh=g.forwardRef(vD),_D=({value:e,onChange:t})=>{const n=s=>{s&&t(s)};return r.jsx(o.Box,{sx:{position:"relative"},children:r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},jD=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),[i,{setTrue:a,setFalse:l}]=W.useBoolean(),[c,u]=g.useState(e),d=()=>{l(),t(c)},p=()=>{l(),u(e)},h=()=>{u(bh)};return g.useEffect(()=>{u(e)},[e]),r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:a,sx:{flexGrow:0},children:s("viz.text.content.edit")}),r.jsx(o.Modal,{size:800,title:s("viz.text.content.label"),opened:i,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:i&&r.jsxs(o.Stack,{children:[r.jsx(_D,{value:c,onChange:u}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:h,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:s("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:p,variant:"subtle",children:s("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:d,children:s("common.actions.save_changes")})]})]})]})})]})});function wD({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaultsDeep({},n,Lo),[n]),a=g.useMemo(()=>{const{func_content:m,horizontal_align:y,font_size:j,font_weight:k}=i;return{func_content:m,horizontal_align:y,font_size:j,font_weight:k}},[i]);g.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]),u(["func_content","horizontal_align","font_size","font_weight"]);const h=d(),f=g.useMemo(()=>!v.isEqual(h,i),[h,i]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:c(s),children:[r.jsx(ke,{canSubmit:f}),r.jsxs(o.Stack,{spacing:10,children:[r.jsx(b.Controller,{name:"func_content",control:l,render:({field:m})=>r.jsx(jD,{...m})}),r.jsx(o.Divider,{mt:10,mb:-10,variant:"dashed",label:t("chart.style.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"horizontal_align",control:l,render:({field:m})=>r.jsx(pa,{...m})}),r.jsx(b.Controller,{name:"font_size",control:l,render:({field:m})=>r.jsx(o.TextInput,{label:t("style.font_size.label"),placeholder:t("style.font_size.placeholder"),sx:{flex:1},...m})}),r.jsx(o.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:r.jsx(b.Controller,{name:"font_weight",control:l,render:({field:m})=>r.jsx(vh,{label:t("style.font_weight.label"),...m})})})]})]})})}const CD=[{lang:"en",resources:{text:{viz_name:"Text",content:{label:"Text content",edit:"Edit Content"}}}},{lang:"zh",resources:{text:{viz_name:"文本",content:{label:"文本内容",edit:"编辑文本内容"}}}}];class SD extends me{constructor(){super(...arguments);B(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const kD={displayName:"viz.text.viz_name",displayGroup:"chart.groups.others",migrator:new SD,name:"text",viewRender:bD,configRender:wD,createConfig(){return{version:1,config:v.cloneDeep(Lo)}},translation:CD},TD=()=>r.jsxs("svg",{width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22.49 27.79H14.47C13.55 27.79 12.81 28.53 12.81 29.45C12.81 30.37 13.55 31.11 14.47 31.11H22.49C23.41 31.11 24.15 30.37 24.15 29.45C24.15 28.54 23.41 27.79 22.49 27.79ZM34.32 31.28C35.22 31.32 35.7 31.82 35.74 32.76C35.78 33.54 35.37 34.3 34.51 35.04C33.52 35.9 33.03 36.95 33.03 38.19V38.81H34.82V38.25C34.78 37.59 35.07 37.02 35.68 36.52C37.12 35.41 37.82 34.15 37.78 32.75C37.66 30.53 36.5 29.35 34.32 29.23C32.3 29.23 31.05 30.46 30.55 32.93L32.53 33.55C32.82 32.04 33.42 31.28 34.32 31.28ZM35 39.93H32.84V42.21H35V39.93ZM14.83 36.42H18.54C19.46 36.42 20.2 37.17 20.2 38.08C20.2 39 19.46 39.74 18.54 39.74H10.52C9.6 39.74 8.86 39 8.86 38.08C8.86 37.61 9.06 37.19 9.37 36.89H5.66C4.74 36.89 4 36.15 4 35.23C4 34.31 4.74 33.57 5.66 33.57H13.68C14.6 33.57 15.34 34.31 15.34 35.23C15.34 35.7 15.14 36.12 14.83 36.42ZM50.94 36.85H58.74C59.66 36.85 60.4 37.59 60.41 38.51C60.41 39.43 59.67 40.17 58.75 40.17H54.26C54.56 40.47 54.74 40.88 54.74 41.34C54.74 42.26 54 43 53.08 43H50.94V36.85Z",fill:"#B8C0CC"}),r.jsx("path",{d:"M18.39 32.28H16.51V35.02H18.39V32.28Z",fill:"#9399A5"}),r.jsx("path",{d:"M46.87 15H20.69C18.38 15 16.5 16.88 16.5 19.19V26.22H18.38V23.45H49.18V47.68H18.38V41.07H16.5V49.55H51.05V19.19C51.06 16.88 49.18 15 46.87 15ZM39.46 20.73C38.81 20.73 38.29 20.2 38.29 19.56C38.29 18.92 38.82 18.39 39.46 18.39C40.11 18.39 40.63 18.92 40.63 19.56C40.63 20.2 40.11 20.73 39.46 20.73ZM43.22 20.73C42.57 20.73 42.05 20.2 42.05 19.56C42.05 18.92 42.58 18.39 43.22 18.39C43.87 18.39 44.39 18.92 44.39 19.56C44.39 20.2 43.87 20.73 43.22 20.73ZM46.97 20.73C46.32 20.73 45.8 20.2 45.8 19.56C45.8 18.92 46.33 18.39 46.97 18.39C47.62 18.39 48.14 18.92 48.14 19.56C48.14 20.2 47.62 20.73 46.97 20.73Z",fill:"#9399A5"})]});function _h(e,t){const n=v.get(e,t,"");if(n)throw new Error(n)}async function DD(e,t,n,s={}){const i={"X-Requested-With":"XMLHttpRequest","Content-Type":s.string?"application/x-www-form-urlencoded":"application/json",...s.headers},a={baseURL:e,method:"POST",url:t,params:s.params,headers:i};return a.data=s.string?JSON.stringify(n):n,At(a).then(l=>l.data).catch(l=>Promise.reject(l))}const MD=({conf:e,panelData:t})=>async()=>{const{expertSystemURL:n,path:s,goal:i,question:a}=e;if(!s||!i||!a)return;const l=Im(t);if(!l)return;const c={dashboard:i,panel:a,data:l};try{const u=n.startsWith("http")?n:window.location.origin;return await DD(u,`/expert/v3/devtable/${s}`,c,{})}catch(u){throw _h(u,"response.data.detail"),_h(u,"response.data.error"),console.error(u),u}},Bo={expertSystemURL:"",path:"",goal:"",question:""},qo={height:"100%",overflowY:"auto",...Ti},jh=({message:e})=>r.jsx(o.Box,{sx:qo,children:r.jsx("div",{dangerouslySetInnerHTML:{__html:e},style:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45"}})}),zD=({error:e,width:t,height:n})=>{const s=e.message;if(s.startsWith("<"))return r.jsx(jh,{message:s});const a=n-25-20-30;return r.jsx(o.Center,{sx:{width:"100%",height:a},children:r.jsxs(o.Stack,{align:"center",spacing:20,children:[r.jsx(TD,{}),r.jsx(jh,{message:s})]})})};function ID({context:e}){const{value:t}=$(e.instanceData,"config"),n=g.useMemo(()=>v.defaultsDeep({},t,Bo),[t]),{width:s,height:i}=e.viewport,a=e.data,{data:l,error:c,loading:u}=W.useRequest(MD({conf:n,panelData:a}),{refreshDeps:[a,n]});return!s||!i||!n?null:u?r.jsx(o.Box,{sx:{position:"relative",height:i},children:r.jsx(o.LoadingOverlay,{visible:!0})}):c?r.jsx(o.Box,{sx:qo,"data-enable-scrollbar":!0,children:r.jsx(zD,{error:c,width:s,height:i})}):!l||!Array.isArray(l.replies)||l.replies.length===0?null:r.jsx(o.Box,{sx:qo,"data-enable-scrollbar":!0,children:l.replies.map((d,p)=>r.jsx("div",{dangerouslySetInnerHTML:{__html:d.interpretation.html}},p))})}function ED({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=g.useMemo(()=>v.defaultsDeep({},t,Bo),[t]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});g.useEffect(()=>{u(s)},[s]),l(["expertSystemURL","goal","path","question"]);const d=c(),p=g.useMemo(()=>!v.isEqual(d,s),[d,s]);return r.jsx("form",{onSubmit:a(n),children:r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:"expertSystemURL",control:i,render:({field:h})=>r.jsx(o.TextInput,{label:"Expert System URL",...h})}),r.jsx(b.Controller,{name:"path",control:i,render:({field:h})=>r.jsx(o.TextInput,{label:"Path",required:!0,...h})})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:"goal",control:i,render:({field:h})=>r.jsx(o.TextInput,{label:"Goal",required:!0,...h})}),r.jsx(b.Controller,{name:"question",control:i,render:({field:h})=>r.jsx(o.TextInput,{label:"Question",required:!0,...h})})]}),r.jsx(o.Divider,{variant:"dashed",mt:16,mb:8}),r.jsx(o.Button,{type:"submit",variant:"filled",color:"blue",leftIcon:r.jsx(V.DeviceFloppy,{size:20}),disabled:!p,sx:{alignSelf:"flex-end"},children:"Submit Changes"})]})})}const AD=[{lang:"en",resources:{merico_gqm:{viz_name:"Merico GQM"}}},{lang:"zh",resources:{merico_gqm:{viz_name:"思码逸GQM组件"}}}];class PD extends me{constructor(){super(...arguments);B(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const OD={displayName:"viz.merico_gqm.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new PD,name:"mericoGQM",viewRender:ID,configRender:ED,createConfig(){return{version:1,config:v.cloneDeep(Bo)}},translation:AD};function LD(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{calendar:i,heat_block:a,tooltip:l,...c}=e;return{...c,calendar:{...i,data_key:s(i.data_key)},heat_block:{...a,data_key:s(a.data_key)},tooltip:{...l,metrics:l.metrics.map(u=>({...u,data_key:s(u.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function BD(e){const{heat_block:t}=e;let{min:n,max:s}=t;return typeof n!="number"&&(n=0),typeof s!="number"&&(s=100),{...e,heat_block:{...t,min:{type:"static",value:n},max:{type:"static",value:s}}}}function qD(e){const{visualMap:t=Ht(),heat_block:{min:n,max:s,...i},...a}=e;return{...a,heat_block:i,visualMap:{...Ht(),min:n,max:s}}}const VD=[{lang:"en",resources:{calendar_heatmap:{viz_name:"Heatmap(Calendar)",calendar:{label:"Calendar",locale:"Langauge"},click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{calendar_heatmap:{viz_name:"日历热力图",calendar:{label:"日历",locale:"语言"},click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function ND(e){return r.jsx(r.Fragment,{})}function $D(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.calendar_heatmap.click_heatmap.heatblock.label")})}const wh={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.calendar_heatmap.click_heatmap.heatblock.label",nameRender:$D,configRender:ND,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},Vo={calendar:{data_key:"",locale:"EN"},heat_block:{name:"Value",data_key:"",value_formatter:Me},tooltip:{metrics:[]},visualMap:Ht()};function FD(e,t,n){if(!e)return n[0];try{return[t,P(t).add(1,"year").subtract(1,"day").valueOf()]}catch(s){return console.error(s),n[0]}}function GD(e,t,n){const s=FD(e,t,n);return{top:50,left:25,right:5,cellSize:["auto",13],range:s,itemStyle:{borderColor:"#eee"},splitLine:{show:!0},dayLabel:{firstDay:1},monthLabel:{position:"end"},yearLabel:{show:!0}}}function WD(e){return{heat_block:function(s){if(!e.heat_block.value_formatter)return s;try{return U(s,e.heat_block.value_formatter)}catch(i){return console.error(i),s}}}}function RD(e,t){return{show:!e,selectedMode:"single",top:5,right:5,data:t.map(n=>({name:n,icon:"circle"}))}}function QD(e,t,n){return e?{type:"heatmap",name:"heatmap",coordinateSystem:"calendar",calendarIndex:0,data:n}:Object.entries(t).map(([s,i])=>({type:"heatmap",name:s,coordinateSystem:"calendar",calendarIndex:0,data:i}))}const UD=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function YD({conf:e,valueFormatters:t,dataDict:n,params:s}){const{value:i}=s,[a,l]=i,u=[{label:e.heat_block.name,value:t.heat_block(l),style:{label:"",value:""}}],d=n[a];return d&&e.tooltip.metrics.forEach(p=>{const h=O(p.data_key);u.push({label:p.name,value:UD(v.get(d,h.columnKey,"")),style:{label:"",value:""}})}),u}function KD(e,t,n){const s=O(e.calendar.data_key),i=v.keyBy(t[s.queryID],s.columnKey);return te.getTooltip({formatter:function(a){const c=YD({conf:e,valueFormatters:n,dataDict:i,params:a}).map(p=>`
|
|
312
312
|
<tr>
|
|
313
313
|
<th style="text-align: right;">
|
|
314
314
|
<div style="${p.style.label}">${p.label}</div>
|
|
@@ -334,13 +334,13 @@ Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(
|
|
|
334
334
|
</thead>
|
|
335
335
|
<tbody>${c.join("")}</tbody>
|
|
336
336
|
</table>
|
|
337
|
-
`}})}const KD=e=>P(e).get("year");function XD(e){const t=v.groupBy(e,l=>l.value[2]),n=Object.keys(t),s=e.map(l=>P(l.value[0]).valueOf()),i=v.min(s),a=v.max(s);return{minDate:i??0,maxDate:a??0,dateSpan:P(a).diff(i,"day"),dataByYear:t,years:n}}function JD(e,t,n){const s=n.reduce((S,T)=>{const z=Vt(T,t);return S[T.name]=rt(T,z),S},{}),i=Xs(e.visualMap,s),{min:a,max:l}=i,c=GD(e),u=O(e.calendar.data_key),d=O(e.heat_block.data_key),p=t[u.queryID].map(S=>{const T=v.get(S,u.columnKey),z=v.get(S,d.columnKey),I=KD(S[u.columnKey]),E={value:[T,z,I]},{followVisualMap:N,color:R}=Co(z,a,l,e.visualMap);return N||(E.visualMap=!1,E.itemStyle={color:R}),E}),{dateSpan:h,minDate:f,dataByYear:m,years:y}=XD(p),j=h<=366;return{calendar:FD(j,f,y),series:RD(j,m,p),tooltip:YD(e,t,c),visualMap:{...i,orient:"horizontal",left:j?"center":5,dimension:1},legend:WD(j,y),grid:{containLabel:!0}}}function ZD({name:e},t){const n=t.getOption();n.calendar.forEach(s=>{s.range=e}),t.setOption(n)}function HD({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=Dn(t,e.calendar.data_key),c=st(i.triggerManager,wh.id),u=g.useCallback(h=>{const[f,m]=h.value,y=v.get(l,f,{error:"rowData is not found"});c.forEach(j=>{i.runInteraction(j.id,{...h,rowData:y})})},[l,c,i]),d=g.useMemo(()=>({click:u,legendselectchanged:ZD}),[u]),p=g.useMemo(()=>JD(e,t,a),[e,t]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,opts:{locale:e.calendar.locale},theme:"merico-light"})}function eM({context:e,instance:t}){const n=it({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,Vo),[s]),l=e.data,{width:c,height:u}=e.viewport;return!a.calendar.data_key||!a.heat_block.data_key||!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(HD,{variables:i,width:wt(c),height:Ct(u),data:l,conf:a,interactionManager:n})})}const tM=[{label:"中文",value:"ZH"},{label:"English",value:"EN"}];function nM({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["calendar"]),r.jsxs(o.Stack,{children:[r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"calendar.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),sx:{flex:1},...s})})}),r.jsx(b.Controller,{name:"calendar.locale",control:e,render:({field:s})=>r.jsx(o.Select,{label:n("viz.calendar_heatmap.calendar.locale"),data:tM,sx:{flex:1},...s})})]})}function rM({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["heat_block"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"heat_block.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"heat_block.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"heat_block.value_formatter",control:e,render:({field:s})=>r.jsx(gt,{...s})})]})}const sM=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},iM=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(ge,{control:e,watch:t,name:"tooltip.metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(sM,{control:e,index:l})})]})};function aM({control:e,watch:t}){return r.jsx(iM,{control:e,watch:t})}function oM({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>n?v.defaults({},n):Vo,[n]),a=g.useMemo(()=>v.cloneDeep(i),[i]);g.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const l=b.useForm({defaultValues:a}),{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=l;g.useEffect(()=>{h(a)},[a]);const f=p(),m=g.useMemo(()=>!v.isEqual(f,i),[f,i]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:u(s),children:[r.jsx(ke,{canSubmit:m}),r.jsxs(o.Tabs,{defaultValue:"Calendar",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Calendar",children:t("viz.calendar_heatmap.calendar.label")}),r.jsx(o.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),r.jsx(o.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),r.jsx(o.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")})]}),r.jsx(o.Tabs.Panel,{value:"Calendar",children:r.jsx(nM,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Heat Block",children:r.jsx(rM,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Visual Map",children:r.jsx(So,{form:l})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(aM,{control:c,watch:d})})]})]})})}class lM extends me{constructor(){super(...arguments);B(this,"VERSION",4)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>({...n,version:2,config:OD(n.config,s)})),this.version(3,n=>({...n,version:3,config:LD(n.config)})),this.version(4,n=>({...n,version:4,config:BD(n.config)}))}}const cM={displayName:"viz.calendar_heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new lM,name:"calendarHeatmap",viewRender:eM,configRender:oM,createConfig:()=>({version:4,config:Vo}),triggers:[wh],translation:qD},No={x_axes:[{id:"initial-x",min:"",max:"",name:"X Axis",data_key:"",position:"bottom",label_formatter:Me,show:!0}],y_axis:{name:"Y Axis",data_key:"",axisLabel:{formatter:Le(),overflow:Ke()},nameAlignment:"center"},series:[],tooltip:{metrics:[]},reference_lines:[]};function uM(){const e=new Date().getTime().toString();return{id:e,min:"",max:"",name:e,data_key:"",position:"bottom",label_formatter:Me,show:!0}}function dM(){const e=new Date().getTime().toString();return{id:e,type:"bar",name:e,stack:"",color:"",barGap:"0%",data_key:"",barWidth:"",barMinWidth:"1",barMaxWidth:"10",group_by_key:"",hide_in_legend:!1,invisible:!1,label_position:"right",aggregation_on_value:qn,xAxisIndex:"0"}}function pM(){const e=new Date().getTime().toString();return{id:e,name:e,template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,xAxisIndex:"0"}}function hM(e){const t=e.x_axes.some(a=>a.position==="top"&&!!a.name&&a.show);let n=0;t&&(n+=15);const s=e.x_axes.some(a=>a.position==="bottom"&&!!a.name&&a.show);let i=0;return s&&(i+=15),e.series.some(a=>!a.hide_in_legend)&&(i+=20),{top:n,right:5,bottom:i,left:5,containLabel:!0}}function fM(e){switch(e){case"bar":return"roundRect";case"scatter":return"circle"}}function gM(e){const t={show:!0,bottom:0,left:"center",type:"scroll"};return t.data=e.filter(n=>!n.hide_in_legend).map(({name:n,type:s})=>({name:n,icon:fM(s)})),t}function mM(e,t,n,s){return e.map(i=>{const a=i.orientation==="horizontal",l=a?"yAxis":"xAxis",c=a?"insideEndTop":"end";return{name:i.name,type:"line",hide_in_legend:!i.show_in_legend,xAxisIndex:i.xAxisIndex,data:[],lineStyle:i.lineStyle,markLine:{data:[{name:i.name,[l]:Number(n[i.variable_key])}],silent:!0,symbol:["none","none"],lineStyle:i.lineStyle,label:{formatter:function(){return i.template?_r(i.template,t,s):""},position:c}}}})}function ri(e,t,n){const s=_t(e,t),i=_t(e,n);return v.zip(i,s)}function xM(e,t,n,s){const i=ri(t,n,s);return v.unionBy(i,e,0)}function yM({dataTemplate:e,data:t,name_data_key:n,value_data_key:s,valueTypedXAxis:i}){return i?xM(e,t,n,s):ri(t,n,s)}function bM({dataTemplate:e,data:t,aggregation_on_value:n,name_data_key:s,value_data_key:i,valueTypedXAxis:a}){if(!n||n.type==="none")return yM({dataTemplate:e,data:t,name_data_key:s,value_data_key:i,valueTypedXAxis:a});const l=ri(t,s,i),c=v.groupBy(l,"0");return e.map(([d])=>{const h=c[d].map(m=>m[1]),f=ki(h,n);return[d,f]})}function vM({group_by_key:e,data:t,value_data_key:n,name_data_key:s}){const{queryID:i,columnKey:a}=O(e),l=v.groupBy(t[i],a);return Object.entries(l).forEach(([c,u])=>{l[c]=ri({[i]:u},s,n)}),l}function _M({y_axis:e},{data_key:t,xAxisIndex:n,label_position:s,name:i,group_by_key:a,aggregation_on_value:l,stack:c,color:u,hide_in_legend:d,invisible:p,id:h,...f},m,y,j,k,S){const T={label:{show:!!s,position:s,formatter:S[n??"default"]},name:i,yAxisId:"main-y-axis",xAxisIndex:n,stack:c,color:p?"transparent":u,hide_in_legend:d,labelLayout:{hideOverlap:!0},emphasis:{disabled:!0},...f};if(!a||a===e.data_key)return T.data=bM({dataTemplate:m,data:j,aggregation_on_value:l,name_data_key:e.data_key,value_data_key:t,valueTypedXAxis:y}),T;const z=vM({group_by_key:a,data:j,name_data_key:e.data_key,value_data_key:t});return Object.entries(z).map(([I,E])=>{const N=v.cloneDeep(T);return N.name=I,N.color=void 0,N.data=E,N})}function jM(e,t,n,s,i,a,l){const c=t.map(d=>[d,0]);return e.series.map(d=>_M(e,d,c,n,s,l,i)).flat().concat(mM(e.reference_lines,a,l,s))}function wM(e,t){const n=e.find(c=>c.axisDim==="y"&&c.axisId==="main-y-axis");if(!n)return"";const{name:s,axisType:i,axisValue:a,axisIndex:l}=n;return i==="yAxis.category"?s:Ye(t.y_axis.axisLabel.formatter)(a,l)}function CM(e,t,n){const s=t.reduce((i,{xAxisIndex:a,name:l})=>(i[l]=a,i),{});return te.getTooltip({trigger:"axis",axisPointer:{type:"shadow"},formatter:function(i){const a=Array.isArray(i)?i:[i];if(a.length===0)return"";const l=a.map(({seriesName:d,marker:p,value:h})=>{if(Array.isArray(h)&&h.length===2&&(h=h[0]),!d)return h;const f=s[d],m=n[f]??n.default;return`
|
|
337
|
+
`}})}const XD=e=>P(e).get("year");function JD(e){const t=v.groupBy(e,l=>l.value[2]),n=Object.keys(t),s=e.map(l=>P(l.value[0]).valueOf()),i=v.min(s),a=v.max(s);return{minDate:i??0,maxDate:a??0,dateSpan:P(a).diff(i,"day"),dataByYear:t,years:n}}function ZD(e,t,n){const s=n.reduce((S,T)=>{const z=Vt(T,t);return S[T.name]=rt(T,z),S},{}),i=Xs(e.visualMap,s),{min:a,max:l}=i,c=WD(e),u=O(e.calendar.data_key),d=O(e.heat_block.data_key),p=t[u.queryID].map(S=>{const T=v.get(S,u.columnKey),z=v.get(S,d.columnKey),I=XD(S[u.columnKey]),E={value:[T,z,I]},{followVisualMap:N,color:R}=Co(z,a,l,e.visualMap);return N||(E.visualMap=!1,E.itemStyle={color:R}),E}),{dateSpan:h,minDate:f,dataByYear:m,years:y}=JD(p),j=h<=366;return{calendar:GD(j,f,y),series:QD(j,m,p),tooltip:KD(e,t,c),visualMap:{...i,orient:"horizontal",left:j?"center":5,dimension:1},legend:RD(j,y),grid:{containLabel:!0}}}function HD({name:e},t){const n=t.getOption();n.calendar.forEach(s=>{s.range=e}),t.setOption(n)}function eM({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=Dn(t,e.calendar.data_key),c=st(i.triggerManager,wh.id),u=g.useCallback(h=>{const[f,m]=h.value,y=v.get(l,f,{error:"rowData is not found"});c.forEach(j=>{i.runInteraction(j.id,{...h,rowData:y})})},[l,c,i]),d=g.useMemo(()=>({click:u,legendselectchanged:HD}),[u]),p=g.useMemo(()=>ZD(e,t,a),[e,t]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,opts:{locale:e.calendar.locale},theme:"merico-light"})}function tM({context:e,instance:t}){const n=it({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,Vo),[s]),l=e.data,{width:c,height:u}=e.viewport;return!a.calendar.data_key||!a.heat_block.data_key||!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(eM,{variables:i,width:wt(c),height:Ct(u),data:l,conf:a,interactionManager:n})})}const nM=[{label:"中文",value:"ZH"},{label:"English",value:"EN"}];function rM({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["calendar"]),r.jsxs(o.Stack,{children:[r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"calendar.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),sx:{flex:1},...s})})}),r.jsx(b.Controller,{name:"calendar.locale",control:e,render:({field:s})=>r.jsx(o.Select,{label:n("viz.calendar_heatmap.calendar.locale"),data:nM,sx:{flex:1},...s})})]})}function sM({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["heat_block"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"heat_block.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"heat_block.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"heat_block.value_formatter",control:e,render:({field:s})=>r.jsx(gt,{...s})})]})}const iM=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},aM=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(ge,{control:e,watch:t,name:"tooltip.metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(iM,{control:e,index:l})})]})};function oM({control:e,watch:t}){return r.jsx(aM,{control:e,watch:t})}function lM({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>n?v.defaults({},n):Vo,[n]),a=g.useMemo(()=>v.cloneDeep(i),[i]);g.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const l=b.useForm({defaultValues:a}),{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=l;g.useEffect(()=>{h(a)},[a]);const f=p(),m=g.useMemo(()=>!v.isEqual(f,i),[f,i]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:u(s),children:[r.jsx(ke,{canSubmit:m}),r.jsxs(o.Tabs,{defaultValue:"Calendar",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Calendar",children:t("viz.calendar_heatmap.calendar.label")}),r.jsx(o.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),r.jsx(o.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),r.jsx(o.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")})]}),r.jsx(o.Tabs.Panel,{value:"Calendar",children:r.jsx(rM,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Heat Block",children:r.jsx(sM,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Visual Map",children:r.jsx(So,{form:l})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(oM,{control:c,watch:d})})]})]})})}class cM extends me{constructor(){super(...arguments);B(this,"VERSION",4)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>({...n,version:2,config:LD(n.config,s)})),this.version(3,n=>({...n,version:3,config:BD(n.config)})),this.version(4,n=>({...n,version:4,config:qD(n.config)}))}}const uM={displayName:"viz.calendar_heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new cM,name:"calendarHeatmap",viewRender:tM,configRender:lM,createConfig:()=>({version:4,config:Vo}),triggers:[wh],translation:VD},No={x_axes:[{id:"initial-x",min:"",max:"",name:"X Axis",data_key:"",position:"bottom",label_formatter:Me,show:!0}],y_axis:{name:"Y Axis",data_key:"",axisLabel:{formatter:Le(),overflow:Ke()},nameAlignment:"center"},series:[],tooltip:{metrics:[]},reference_lines:[]};function dM(){const e=new Date().getTime().toString();return{id:e,min:"",max:"",name:e,data_key:"",position:"bottom",label_formatter:Me,show:!0}}function pM(){const e=new Date().getTime().toString();return{id:e,type:"bar",name:e,stack:"",color:"",barGap:"0%",data_key:"",barWidth:"",barMinWidth:"1",barMaxWidth:"10",group_by_key:"",hide_in_legend:!1,invisible:!1,label_position:"right",aggregation_on_value:qn,xAxisIndex:"0"}}function hM(){const e=new Date().getTime().toString();return{id:e,name:e,template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,xAxisIndex:"0"}}function fM(e){const t=e.x_axes.some(a=>a.position==="top"&&!!a.name&&a.show);let n=0;t&&(n+=15);const s=e.x_axes.some(a=>a.position==="bottom"&&!!a.name&&a.show);let i=0;return s&&(i+=15),e.series.some(a=>!a.hide_in_legend)&&(i+=20),{top:n,right:5,bottom:i,left:5,containLabel:!0}}function gM(e){switch(e){case"bar":return"roundRect";case"scatter":return"circle"}}function mM(e){const t={show:!0,bottom:0,left:"center",type:"scroll"};return t.data=e.filter(n=>!n.hide_in_legend).map(({name:n,type:s})=>({name:n,icon:gM(s)})),t}function xM(e,t,n,s){return e.map(i=>{const a=i.orientation==="horizontal",l=a?"yAxis":"xAxis",c=a?"insideEndTop":"end";return{name:i.name,type:"line",hide_in_legend:!i.show_in_legend,xAxisIndex:i.xAxisIndex,data:[],lineStyle:i.lineStyle,markLine:{data:[{name:i.name,[l]:Number(n[i.variable_key])}],silent:!0,symbol:["none","none"],lineStyle:i.lineStyle,label:{formatter:function(){return i.template?_r(i.template,t,s):""},position:c}}}})}function ri(e,t,n){const s=_t(e,t),i=_t(e,n);return v.zip(i,s)}function yM(e,t,n,s){const i=ri(t,n,s);return v.unionBy(i,e,0)}function bM({dataTemplate:e,data:t,name_data_key:n,value_data_key:s,valueTypedXAxis:i}){return i?yM(e,t,n,s):ri(t,n,s)}function vM({dataTemplate:e,data:t,aggregation_on_value:n,name_data_key:s,value_data_key:i,valueTypedXAxis:a}){if(!n||n.type==="none")return bM({dataTemplate:e,data:t,name_data_key:s,value_data_key:i,valueTypedXAxis:a});const l=ri(t,s,i),c=v.groupBy(l,"0");return e.map(([d])=>{const h=c[d].map(m=>m[1]),f=ki(h,n);return[d,f]})}function _M({group_by_key:e,data:t,value_data_key:n,name_data_key:s}){const{queryID:i,columnKey:a}=O(e),l=v.groupBy(t[i],a);return Object.entries(l).forEach(([c,u])=>{l[c]=ri({[i]:u},s,n)}),l}function jM({y_axis:e},{data_key:t,xAxisIndex:n,label_position:s,name:i,group_by_key:a,aggregation_on_value:l,stack:c,color:u,hide_in_legend:d,invisible:p,id:h,...f},m,y,j,k,S){const T={label:{show:!!s,position:s,formatter:S[n??"default"]},name:i,yAxisId:"main-y-axis",xAxisIndex:n,stack:c,color:p?"transparent":u,hide_in_legend:d,labelLayout:{hideOverlap:!0},emphasis:{disabled:!0},...f};if(!a||a===e.data_key)return T.data=vM({dataTemplate:m,data:j,aggregation_on_value:l,name_data_key:e.data_key,value_data_key:t,valueTypedXAxis:y}),T;const z=_M({group_by_key:a,data:j,name_data_key:e.data_key,value_data_key:t});return Object.entries(z).map(([I,E])=>{const N=v.cloneDeep(T);return N.name=I,N.color=void 0,N.data=E,N})}function wM(e,t,n,s,i,a,l){const c=t.map(d=>[d,0]);return e.series.map(d=>jM(e,d,c,n,s,l,i)).flat().concat(xM(e.reference_lines,a,l,s))}function CM(e,t){const n=e.find(c=>c.axisDim==="y"&&c.axisId==="main-y-axis");if(!n)return"";const{name:s,axisType:i,axisValue:a,axisIndex:l}=n;return i==="yAxis.category"?s:Ye(t.y_axis.axisLabel.formatter)(a,l)}function SM(e,t,n){const s=t.reduce((i,{xAxisIndex:a,name:l})=>(i[l]=a,i),{});return te.getTooltip({trigger:"axis",axisPointer:{type:"shadow"},formatter:function(i){const a=Array.isArray(i)?i:[i];if(a.length===0)return"";const l=a.map(({seriesName:d,marker:p,value:h})=>{if(Array.isArray(h)&&h.length===2&&(h=h[0]),!d)return h;const f=s[d],m=n[f]??n.default;return`
|
|
338
338
|
<tr>
|
|
339
339
|
<td>${p}</td>
|
|
340
340
|
<th style="text-align: right; padding: 0 1em;">${d}</th>
|
|
341
341
|
<td style="text-align: left; padding: 0 1em;">${m({value:h})}</td>
|
|
342
342
|
</tr>
|
|
343
|
-
`}),c=ut(e.y_axis.axisLabel.overflow.in_tooltip),u=
|
|
343
|
+
`}),c=ut(e.y_axis.axisLabel.overflow.in_tooltip),u=CM(a,e);return`
|
|
344
344
|
<div style="text-align: left; margin-bottom: .5em; padding: 0 1em .5em; font-weight: bold; border-bottom: 1px dashed #ddd;">
|
|
345
345
|
<div style="${c}">${u}</div>
|
|
346
346
|
</div>
|
|
@@ -349,7 +349,7 @@ Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(
|
|
|
349
349
|
${l.join("")}
|
|
350
350
|
</tbody>
|
|
351
351
|
</table>
|
|
352
|
-
`}})}function SM(e){return e.x_axes.reduce((n,{label_formatter:s},i)=>(n[i]=function(l){let c=l;if(typeof l=="object"&&(Array.isArray(l.value)&&l.value.length===2?c=l.value[0]:c=l.value),!s)return c;try{return U(c,s)}catch(u){return console.error(u),c}},n),{default:({value:n})=>n})}function kM(e,t){const n={};return t.map(s=>{const i=Vt(s,e);n[s.name]=rt(s,i)}),n}function TM(e,t){return e.x_axes.map(({min:n,max:s,...i},a)=>{let l=i.position;return l||(l=a>0?"bottom":"top"),te.getYAxis({...i,type:"value",min:n||void 0,max:s||void 0,position:l,axisLabel:{show:!0,margin:2,formatter:t[a]??t.default},nameLocation:"center",nameGap:15})})}function DM(e,t){const n=t.every(l=>!Number.isNaN(Number(l))),{overflow:s,...i}=e.y_axis.axisLabel,a=dt(s.on_axis);return[te.getXAxis({data:t,name:e.y_axis.name??"",nameLocation:"end",nameTextStyle:{align:"center"},id:"main-y-axis",type:n?"value":"category",axisLabel:{...i,...a,formatter:Ye(i.formatter)},z:5})]}function MM(e,t,n){if(!e.y_axis.data_key)return{};const s=kM(t,n),i=SM(e),a=O(e.y_axis.data_key),l=v.uniq(t[a.queryID].map(p=>p[a.columnKey])),c=l.every(p=>!Number.isNaN(Number(p))),u=jM(e,l,c,t,i,n,s);return{xAxis:TM(e,i),yAxis:DM(e,l),series:u,tooltip:CM(e,u,i),grid:hM(e),legend:gM(u)}}function zM({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=Dn(t,e.y_axis.data_key),c=st(i.triggerManager,mo.id),u=g.useCallback(h=>{const f=v.get(l,h.name,{error:"rowData is not found"});c.forEach(m=>{i.runInteraction(m.id,{...h,rowData:f})})},[l,c,i]),d=g.useMemo(()=>({click:u}),[u]),p=g.useMemo(()=>MM(e,t,a),[e,t]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function IM({context:e,instance:t}){const n=it({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,No),[s]),l=e.data,{width:c,height:u}=e.viewport;return!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(zM,{variables:i,width:wt(c),height:Ct(u),data:l,conf:a,interactionManager:n})})}function EM({control:e,index:t,watch:n,variableOptions:s,xAxisOptions:i}){const{t:a}=_.useTranslation(),l=n(`reference_lines.${t}.orientation`);return r.jsxs(o.Stack,{my:0,p:0,pt:10,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>r.jsx(o.Select,{label:a("common.data_field"),required:!0,data:s,sx:{flex:1},...c})})]}),r.jsx(b.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.hint"),sx:{flex:1},...c})}),r.jsxs(o.Group,{grow:!0,children:[r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>r.jsx(yn,{sx:{flex:1},...c})}),l==="vertical"&&r.jsx(o.Text,{mt:-10,color:"dimmed",size:12,children:a("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&r.jsx(b.Controller,{name:`reference_lines.${t}.xAxisIndex`,control:e,render:({field:c})=>r.jsx(o.Select,{label:a("chart.x_axis.label"),data:i,disabled:i.length===0,sx:{flex:1},...c})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.style.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>r.jsx(tr,{sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>r.jsx(o.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:a("chart.color.label")}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>r.jsx(Be,{...c})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.behavior.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`reference_lines.${t}.show_in_legend`,control:e,render:({field:c})=>r.jsx(o.Checkbox,{label:a("chart.legend.show_in_legend"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})]})}function AM({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>pM(),a=g.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=t("x_axes"),c=g.useMemo(()=>l.map(({name:d},p)=>({label:d,value:p.toString()})),[l]),u=(d,p)=>{const h=d.name.trim();return h||p+1};return r.jsx(ge,{control:e,watch:t,name:"reference_lines",getItem:i,addButtonText:s("chart.reference_line.add"),deleteButtonText:s("chart.reference_line.delete"),renderTabName:u,children:({field:d,index:p})=>r.jsx(EM,{control:e,index:p,watch:t,variableOptions:a,xAxisOptions:c})})}function PM({control:e,index:t,seriesItem:n}){const{t:s,i18n:i}=_.useTranslation(),a=!!n.barWidth.trim(),l=g.useMemo(()=>[{label:s("chart.series.bar.bar_gap.no_gap"),value:"0%"},{label:s("chart.series.bar.bar_gap.overlap"),value:"-100%"}],[i.language]);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.stack`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.stack"),placeholder:s("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.barGap`,control:e,render:({field:c})=>r.jsx(o.Select,{label:s("chart.series.bar.bar_gap.label"),data:l,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.barMinWidth`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.bar_width.min"),disabled:a,sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.barWidth`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.bar_width.exact"),sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.barMaxWidth`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.bar_width.max"),disabled:a,sx:{flexGrow:1},...c})})]})]})}function OM({control:e,index:t,seriesItem:n,xAxisOptions:s}){const{t:i}=_.useTranslation();return r.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.name`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:i("common.name"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:`series.${t}.xAxisIndex`,control:e,render:({field:a})=>r.jsx(o.Select,{label:i("chart.x_axis.label"),data:s,disabled:s.length===0,sx:{flex:1},...a})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.data_key`,control:e,render:({field:a})=>r.jsx(F,{label:i("common.data_field"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:`series.${t}.aggregation_on_value`,control:e,render:({field:a})=>r.jsx(jo,{label:i("viz.horizontal_bar_chart.series.aggregation.label"),value:a.value??qn,onChange:a.onChange,pt:0,withFallback:!1})})]}),r.jsx(o.Group,{grow:!0,children:r.jsx(b.Controller,{name:`series.${t}.group_by_key`,control:e,render:({field:a})=>r.jsx(F,{label:i("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...a})})}),r.jsx(PM,{index:t,control:e,seriesItem:n}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.style.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`series.${t}.label_position`,control:e,render:({field:a})=>r.jsx(nr,{label:i("chart.label_position.label"),...a,withOffOption:!0,onChange:l=>{l&&a.onChange(l)}})}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:i("chart.color.label")}),r.jsx(b.Controller,{name:`series.${t}.color`,control:e,render:({field:a})=>r.jsx(Be,{...a})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.behavior.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`series.${t}.hide_in_legend`,control:e,render:({field:a})=>r.jsx(o.Checkbox,{label:i("chart.legend.hide_in_legend"),checked:a.value,onChange:l=>a.onChange(l.currentTarget.checked)})}),r.jsx(b.Controller,{name:`series.${t}.invisible`,control:e,render:({field:a})=>r.jsx(o.Checkbox,{label:i("chart.behavior.invisible"),checked:a.value,onChange:l=>a.onChange(l.currentTarget.checked)})})]})}function LM({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>dM(),i=(c,u)=>{const d=c.name.trim();return d||u+1},a=t("x_axes"),l=g.useMemo(()=>a.map(({name:c},u)=>({label:c,value:u.toString()})),[a]);return r.jsx(ge,{control:e,watch:t,name:"series",getItem:s,addButtonText:n("chart.series.add"),deleteButtonText:n("chart.series.delete"),renderTabName:i,children:({field:c,index:u})=>r.jsx(OM,{control:e,index:u,seriesItem:c,xAxisOptions:l})})}const BM=g.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=g.useMemo(()=>[{label:a("chart.x_axis.position.top"),value:"top"},{label:a("chart.x_axis.position.bottom"),value:"bottom"}],[l.language]);return r.jsx(o.Select,{ref:i,label:e??a("chart.x_axis.position.label"),data:c,value:t,onChange:n,sx:s})});function qM({control:e,index:t}){const{t:n}=_.useTranslation();return r.jsxs(o.Stack,{my:10,p:"0",sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`x_axes.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`x_axes.${t}.position`,control:e,render:({field:s})=>r.jsx(BM,{sx:{flex:1},...s})})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.x_axis.label_format"),labelPosition:"center"}),r.jsx(b.Controller,{name:`x_axes.${t}.label_formatter`,control:e,render:({field:s})=>r.jsx(gt,{...s})})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.x_axis.value_range"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`x_axes.${t}.min`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.x_axis.value_min"),...s})}),r.jsx(b.Controller,{name:`x_axes.${t}.max`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.x_axis.value_max"),...s})})]})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:n("chart.x_axis.behavior"),labelPosition:"center"}),r.jsx(b.Controller,{name:`x_axes.${t}.show`,control:e,render:({field:s})=>r.jsx(o.Checkbox,{label:n("chart.x_axis.visible"),checked:s.value,onChange:i=>s.onChange(i.currentTarget.checked)})})]})}function VM({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>uM(),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsx(ge,{control:e,watch:t,name:"x_axes",getItem:s,addButtonText:n("chart.x_axis.add"),deleteButtonText:n("chart.x_axis.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(qM,{control:e,index:l})})}function NM({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["y_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"y_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),variant:"dashed",labelPosition:"center"}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(kt,{...s})})}),r.jsx(b.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(Tt,{...s})})]})}function $M({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaultsDeep({},n,No),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]),u([]);const h=d(),f=g.useMemo(()=>!v.isEqual(h,a),[h,a]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:c(s),children:[r.jsx(ke,{canSubmit:f}),r.jsxs(o.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axes",children:t("chart.x_axis.labels")}),r.jsx(o.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Series",children:t("chart.series.label")}),r.jsx(o.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")})]}),r.jsx(o.Tabs.Panel,{value:"X Axes",children:r.jsx(VM,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(NM,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Series",children:r.jsx(LM,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(AM,{variables:i,control:l,watch:u})})]})]})})}const FM=[{lang:"en",resources:{horizontal_bar_chart:{viz_name:"Horizontal Bar Chart",series:{aggregation:{label:"Aggregation on Value"}}}}},{lang:"zh",resources:{horizontal_bar_chart:{viz_name:"水平方向柱图",series:{aggregation:{label:"聚合数据"}}}}}];function GM(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis:i,y_axis:a,series:l,...c}=e;return{...c,x_axis:{...i,data_key:s(i.data_key)},y_axis:{...a,data_key:s(a.data_key)},series:l.map(u=>({...u,data_key:s(u.data_key),group_by_key:s(u.group_by_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class WM extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:GM(i,s)}})}}const RM={displayName:"viz.horizontal_bar_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new WM,name:"horizontalBarChart",viewRender:IM,configRender:$M,createConfig:()=>({version:2,config:No}),translation:FM},$o={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,formatter:Le()}},deviation:{name:"",data_keys:{estimated_value:"",actual_value:""}},metrics:[]};function QM(){return[{top:20,left:30,right:60,height:40,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{top:70,left:30,right:60,height:100,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{top:180,left:30,right:60,bottom:130,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{left:30,right:60,bottom:20,height:100,containLabel:!1,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0}]}const Ch=({value:e})=>{try{return U(e[2],{output:"percent",mantissa:0,absolute:!1})}catch(t){return console.error(t),e}};function UM(e,t,n){return{type:"heatmap",name:"准确估算比例",xAxisIndex:0,yAxisIndex:0,data:t.map(i=>{const a=n[i].length,u=(v.countBy(n[i],d=>d.level.diff===0).true??0)/a;return[i,"_y",u]}),label:{show:!0,formatter:Ch},labelLayout:{hideOverlap:!0},visualMapIndex:0,tooltip:{trigger:"item",formatter:({color:i,value:a})=>`
|
|
352
|
+
`}})}function kM(e){return e.x_axes.reduce((n,{label_formatter:s},i)=>(n[i]=function(l){let c=l;if(typeof l=="object"&&(Array.isArray(l.value)&&l.value.length===2?c=l.value[0]:c=l.value),!s)return c;try{return U(c,s)}catch(u){return console.error(u),c}},n),{default:({value:n})=>n})}function TM(e,t){const n={};return t.map(s=>{const i=Vt(s,e);n[s.name]=rt(s,i)}),n}function DM(e,t){return e.x_axes.map(({min:n,max:s,...i},a)=>{let l=i.position;return l||(l=a>0?"bottom":"top"),te.getYAxis({...i,type:"value",min:n||void 0,max:s||void 0,position:l,axisLabel:{show:!0,margin:2,formatter:t[a]??t.default},nameLocation:"center",nameGap:15})})}function MM(e,t){const n=t.every(l=>!Number.isNaN(Number(l))),{overflow:s,...i}=e.y_axis.axisLabel,a=dt(s.on_axis);return[te.getXAxis({data:t,name:e.y_axis.name??"",nameLocation:"end",nameTextStyle:{align:"center"},id:"main-y-axis",type:n?"value":"category",axisLabel:{...i,...a,formatter:Ye(i.formatter)},z:5})]}function zM(e,t,n){if(!e.y_axis.data_key)return{};const s=TM(t,n),i=kM(e),a=O(e.y_axis.data_key),l=v.uniq(t[a.queryID].map(p=>p[a.columnKey])),c=l.every(p=>!Number.isNaN(Number(p))),u=wM(e,l,c,t,i,n,s);return{xAxis:DM(e,i),yAxis:MM(e,l),series:u,tooltip:SM(e,u,i),grid:fM(e),legend:mM(u)}}function IM({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=Dn(t,e.y_axis.data_key),c=st(i.triggerManager,mo.id),u=g.useCallback(h=>{const f=v.get(l,h.name,{error:"rowData is not found"});c.forEach(m=>{i.runInteraction(m.id,{...h,rowData:f})})},[l,c,i]),d=g.useMemo(()=>({click:u}),[u]),p=g.useMemo(()=>zM(e,t,a),[e,t]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function EM({context:e,instance:t}){const n=it({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,No),[s]),l=e.data,{width:c,height:u}=e.viewport;return!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(IM,{variables:i,width:wt(c),height:Ct(u),data:l,conf:a,interactionManager:n})})}function AM({control:e,index:t,watch:n,variableOptions:s,xAxisOptions:i}){const{t:a}=_.useTranslation(),l=n(`reference_lines.${t}.orientation`);return r.jsxs(o.Stack,{my:0,p:0,pt:10,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>r.jsx(o.Select,{label:a("common.data_field"),required:!0,data:s,sx:{flex:1},...c})})]}),r.jsx(b.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.hint"),sx:{flex:1},...c})}),r.jsxs(o.Group,{grow:!0,children:[r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>r.jsx(yn,{sx:{flex:1},...c})}),l==="vertical"&&r.jsx(o.Text,{mt:-10,color:"dimmed",size:12,children:a("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&r.jsx(b.Controller,{name:`reference_lines.${t}.xAxisIndex`,control:e,render:({field:c})=>r.jsx(o.Select,{label:a("chart.x_axis.label"),data:i,disabled:i.length===0,sx:{flex:1},...c})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.style.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>r.jsx(tr,{sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>r.jsx(o.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:a("chart.color.label")}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>r.jsx(Be,{...c})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.behavior.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`reference_lines.${t}.show_in_legend`,control:e,render:({field:c})=>r.jsx(o.Checkbox,{label:a("chart.legend.show_in_legend"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})]})}function PM({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>hM(),a=g.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=t("x_axes"),c=g.useMemo(()=>l.map(({name:d},p)=>({label:d,value:p.toString()})),[l]),u=(d,p)=>{const h=d.name.trim();return h||p+1};return r.jsx(ge,{control:e,watch:t,name:"reference_lines",getItem:i,addButtonText:s("chart.reference_line.add"),deleteButtonText:s("chart.reference_line.delete"),renderTabName:u,children:({field:d,index:p})=>r.jsx(AM,{control:e,index:p,watch:t,variableOptions:a,xAxisOptions:c})})}function OM({control:e,index:t,seriesItem:n}){const{t:s,i18n:i}=_.useTranslation(),a=!!n.barWidth.trim(),l=g.useMemo(()=>[{label:s("chart.series.bar.bar_gap.no_gap"),value:"0%"},{label:s("chart.series.bar.bar_gap.overlap"),value:"-100%"}],[i.language]);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.stack`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.stack"),placeholder:s("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.barGap`,control:e,render:({field:c})=>r.jsx(o.Select,{label:s("chart.series.bar.bar_gap.label"),data:l,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.barMinWidth`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.bar_width.min"),disabled:a,sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.barWidth`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.bar_width.exact"),sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.barMaxWidth`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.bar_width.max"),disabled:a,sx:{flexGrow:1},...c})})]})]})}function LM({control:e,index:t,seriesItem:n,xAxisOptions:s}){const{t:i}=_.useTranslation();return r.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.name`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:i("common.name"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:`series.${t}.xAxisIndex`,control:e,render:({field:a})=>r.jsx(o.Select,{label:i("chart.x_axis.label"),data:s,disabled:s.length===0,sx:{flex:1},...a})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.data_key`,control:e,render:({field:a})=>r.jsx(F,{label:i("common.data_field"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:`series.${t}.aggregation_on_value`,control:e,render:({field:a})=>r.jsx(jo,{label:i("viz.horizontal_bar_chart.series.aggregation.label"),value:a.value??qn,onChange:a.onChange,pt:0,withFallback:!1})})]}),r.jsx(o.Group,{grow:!0,children:r.jsx(b.Controller,{name:`series.${t}.group_by_key`,control:e,render:({field:a})=>r.jsx(F,{label:i("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...a})})}),r.jsx(OM,{index:t,control:e,seriesItem:n}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.style.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`series.${t}.label_position`,control:e,render:({field:a})=>r.jsx(nr,{label:i("chart.label_position.label"),...a,withOffOption:!0,onChange:l=>{l&&a.onChange(l)}})}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:i("chart.color.label")}),r.jsx(b.Controller,{name:`series.${t}.color`,control:e,render:({field:a})=>r.jsx(Be,{...a})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.behavior.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`series.${t}.hide_in_legend`,control:e,render:({field:a})=>r.jsx(o.Checkbox,{label:i("chart.legend.hide_in_legend"),checked:a.value,onChange:l=>a.onChange(l.currentTarget.checked)})}),r.jsx(b.Controller,{name:`series.${t}.invisible`,control:e,render:({field:a})=>r.jsx(o.Checkbox,{label:i("chart.behavior.invisible"),checked:a.value,onChange:l=>a.onChange(l.currentTarget.checked)})})]})}function BM({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>pM(),i=(c,u)=>{const d=c.name.trim();return d||u+1},a=t("x_axes"),l=g.useMemo(()=>a.map(({name:c},u)=>({label:c,value:u.toString()})),[a]);return r.jsx(ge,{control:e,watch:t,name:"series",getItem:s,addButtonText:n("chart.series.add"),deleteButtonText:n("chart.series.delete"),renderTabName:i,children:({field:c,index:u})=>r.jsx(LM,{control:e,index:u,seriesItem:c,xAxisOptions:l})})}const qM=g.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=g.useMemo(()=>[{label:a("chart.x_axis.position.top"),value:"top"},{label:a("chart.x_axis.position.bottom"),value:"bottom"}],[l.language]);return r.jsx(o.Select,{ref:i,label:e??a("chart.x_axis.position.label"),data:c,value:t,onChange:n,sx:s})});function VM({control:e,index:t}){const{t:n}=_.useTranslation();return r.jsxs(o.Stack,{my:10,p:"0",sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`x_axes.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`x_axes.${t}.position`,control:e,render:({field:s})=>r.jsx(qM,{sx:{flex:1},...s})})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.x_axis.label_format"),labelPosition:"center"}),r.jsx(b.Controller,{name:`x_axes.${t}.label_formatter`,control:e,render:({field:s})=>r.jsx(gt,{...s})})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.x_axis.value_range"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`x_axes.${t}.min`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.x_axis.value_min"),...s})}),r.jsx(b.Controller,{name:`x_axes.${t}.max`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.x_axis.value_max"),...s})})]})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:n("chart.x_axis.behavior"),labelPosition:"center"}),r.jsx(b.Controller,{name:`x_axes.${t}.show`,control:e,render:({field:s})=>r.jsx(o.Checkbox,{label:n("chart.x_axis.visible"),checked:s.value,onChange:i=>s.onChange(i.currentTarget.checked)})})]})}function NM({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>dM(),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsx(ge,{control:e,watch:t,name:"x_axes",getItem:s,addButtonText:n("chart.x_axis.add"),deleteButtonText:n("chart.x_axis.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(VM,{control:e,index:l})})}function $M({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["y_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"y_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),variant:"dashed",labelPosition:"center"}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(kt,{...s})})}),r.jsx(b.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(Tt,{...s})})]})}function FM({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaultsDeep({},n,No),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]),u([]);const h=d(),f=g.useMemo(()=>!v.isEqual(h,a),[h,a]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:c(s),children:[r.jsx(ke,{canSubmit:f}),r.jsxs(o.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axes",children:t("chart.x_axis.labels")}),r.jsx(o.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Series",children:t("chart.series.label")}),r.jsx(o.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")})]}),r.jsx(o.Tabs.Panel,{value:"X Axes",children:r.jsx(NM,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx($M,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Series",children:r.jsx(BM,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(PM,{variables:i,control:l,watch:u})})]})]})})}const GM=[{lang:"en",resources:{horizontal_bar_chart:{viz_name:"Horizontal Bar Chart",series:{aggregation:{label:"Aggregation on Value"}}}}},{lang:"zh",resources:{horizontal_bar_chart:{viz_name:"水平方向柱图",series:{aggregation:{label:"聚合数据"}}}}}];function WM(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis:i,y_axis:a,series:l,...c}=e;return{...c,x_axis:{...i,data_key:s(i.data_key)},y_axis:{...a,data_key:s(a.data_key)},series:l.map(u=>({...u,data_key:s(u.data_key),group_by_key:s(u.group_by_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class RM extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:WM(i,s)}})}}const QM={displayName:"viz.horizontal_bar_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new RM,name:"horizontalBarChart",viewRender:EM,configRender:FM,createConfig:()=>({version:2,config:No}),translation:GM},$o={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,formatter:Le()}},deviation:{name:"",data_keys:{estimated_value:"",actual_value:""}},metrics:[]};function UM(){return[{top:20,left:30,right:60,height:40,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{top:70,left:30,right:60,height:100,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{top:180,left:30,right:60,bottom:130,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{left:30,right:60,bottom:20,height:100,containLabel:!1,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0}]}const Ch=({value:e})=>{try{return U(e[2],{output:"percent",mantissa:0,absolute:!1})}catch(t){return console.error(t),e}};function YM(e,t,n){return{type:"heatmap",name:"准确估算比例",xAxisIndex:0,yAxisIndex:0,data:t.map(i=>{const a=n[i].length,u=(v.countBy(n[i],d=>d.level.diff===0).true??0)/a;return[i,"_y",u]}),label:{show:!0,formatter:Ch},labelLayout:{hideOverlap:!0},visualMapIndex:0,tooltip:{trigger:"item",formatter:({color:i,value:a})=>`
|
|
353
353
|
<table style="width: auto">
|
|
354
354
|
<thead>
|
|
355
355
|
<tr colspan="2">
|
|
@@ -371,7 +371,7 @@ Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(
|
|
|
371
371
|
</tr>
|
|
372
372
|
</tbody>
|
|
373
373
|
</table>
|
|
374
|
-
`},show_in_legend:!1}}function Sh(e){const t=[`background-color: ${e}`];return e==="rgba(255, 255, 255, 1)"&&t.push("box-shadow: 0px 0px 1px 0px rgba(0,0,0,.5)"),t.join(";")}function
|
|
374
|
+
`},show_in_legend:!1}}function Sh(e){const t=[`background-color: ${e}`];return e==="rgba(255, 255, 255, 1)"&&t.push("box-shadow: 0px 0px 1px 0px rgba(0,0,0,.5)"),t.join(";")}function KM([e,t]){const n={x:e,v:`${t}`};try{n.v=U(t,{output:"number",mantissa:2,trimMantissa:!0,absolute:!1})}catch{}return n}function XM(e,t,n,s){var u,d;const i=t.map(p=>{const h=n[p],f=v.sumBy(h,m=>m.level.diff);return[p,f/h.length]}),a=Number(((u=v.maxBy(i,p=>p[1]))==null?void 0:u[1])??0),l=Number(((d=v.minBy(i,p=>p[1]))==null?void 0:d[1])??0),c=nn.interpolate([a,0,l],["#D15A40","#FFF","#418AAF"]);return{type:"bar",name:"平均偏差",xAxisIndex:1,yAxisIndex:1,...s,data:i,itemStyle:{color:({value:p})=>{try{return c(p[1])}catch{return"#FFF"}}},label:{position:"outside",show:!0,formatter:({value:p})=>{try{return U(p[1],{output:"number",mantissa:1,trimMantissa:!0,absolute:!1})}catch{return p[1]}}},tooltip:{trigger:"item",formatter:({color:p,value:h})=>{const{x:f,v:m}=KM(h);return`
|
|
375
375
|
<table style="width: auto">
|
|
376
376
|
<thead>
|
|
377
377
|
<tr colspan="2">
|
|
@@ -393,7 +393,7 @@ Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(
|
|
|
393
393
|
</tr>
|
|
394
394
|
</tbody>
|
|
395
395
|
</table>
|
|
396
|
-
`}},show_in_legend:!1}}function
|
|
396
|
+
`}},show_in_legend:!1}}function JM([e,t,n,s]){const i={x:e,percentage:`${t}`,count:n,sum:s};try{i.percentage=U(t,{output:"percent",mantissa:2,trimMantissa:!0,absolute:!1})}catch{}return i}function ZM(e,t,n,s){const i={};t.forEach(p=>{const h=v.countBy(n[p],m=>m.level.diff),f=v.sum(Object.values(h));Object.entries(h).forEach(([m,y])=>{i[m]||(i[m]=[]);const j=y/f;i[m].push([p,j,y,f])})});const a=Object.entries(i).map(([p])=>Number(p)).sort((p,h)=>p-h),l=Math.max(...a),c=Math.min(...a),u=nn.interpolate([l,0,c],["#D15A40","#FFF","#418AAF"]);return a.map(p=>({type:"bar",name:p,xAxisIndex:2,yAxisIndex:2,stack:1,...s,color:u(p),data:i[p],tooltip:{trigger:"item",formatter:({color:h,value:f})=>{const{x:m,percentage:y,count:j,sum:k}=JM(f);return`
|
|
397
397
|
<table style="width: auto">
|
|
398
398
|
<thead>
|
|
399
399
|
<tr colspan="2">
|
|
@@ -428,7 +428,7 @@ Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(
|
|
|
428
428
|
</tr>
|
|
429
429
|
</tbody>
|
|
430
430
|
</table>
|
|
431
|
-
`}},show_in_legend:!0}))}function ZM(e,t,n,s){const i=O(t.data_key),a=t.name,l=n.map(c=>{const u=v.sumBy(s[c],i.columnKey);return[c,u]});return{type:"line",name:a,xAxisIndex:3,yAxisIndex:3,color:"#b41529",data:l,show_in_legend:!1}}function HM(e,t,n,s){const l={barMinWidth:5,barMaxWidth:20};return[UM(e,n,s),KM(e,n,s,l),...JM(e,n,s,l),ZM(e,t,n,s)]}function ez(e,t){const{axisLabel:n}=e.x_axis;return[{data:t,id:"准确估算比例",gridIndex:0,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"平均偏差",gridIndex:1,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!0,lineStyle:{color:"#FFFFFF",width:2}},type:"category"},{data:t,id:"数量占比",gridIndex:2,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"代码当量",gridIndex:3,axisTick:{show:!1},type:"category",axisLabel:{...n,formatter:Ye(n.formatter)},axisLine:{show:!1}}]}function tz(e){return[{type:"category",name:"准确估算比例",nameRotate:0,nameGap:5,nameLocation:"end",nameTextStyle:{align:"left"},gridIndex:0,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"平均偏差",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:1,boundaryGap:[1,1],axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"数量占比",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:2,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1},min:0,max:1},{type:"value",gridIndex:3,position:"right",splitNumber:3,axisLabel:{show:!0,verticalAlign:"top",showMinLabel:!1,lineHeight:14},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:e.name,nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:3,position:"left",axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}}]}function Fo(e){return e==1||e==2?1:Fo(e-2)+Fo(e-1)}const nz=Array.from(new Array(20),(e,t)=>Fo(t+1));function kh(e){return e<=1?e:nz.findIndex(t=>e<=t)-1}function rz(e,t){const{x_axis:n,deviation:s}=e,i=O(n.data_key),a=O(s.data_keys.estimated_value),l=O(s.data_keys.actual_value);return t[i.queryID].map(c=>{const u=kh(c[a.columnKey]),d=kh(c[l.columnKey]),p=u-d;return{...c,level:{estimated:u,actual:d,diff:p}}})}function sz(e){return e==="rgba(255, 255, 255, 1)"?{borderColor:"rgba(0,0,0,.1)",borderWidth:1}:{}}function iz(e){return{show:!0,orient:"vertical",top:"middle",right:0,data:e.filter(n=>n.show_in_legend).reverse().map(n=>({name:`${n.name}`,color:n.color,itemStyle:sz(n.color)})),tooltip:{show:!0,formatter:"档位偏差:{a}"}}}const az={tooltip:{trigger:"axis"}};function oz(e,t){const{deviation:n,metrics:s}=e,i=s.find(l=>l.data_key===t);if(i)return i;const a=n.data_keys.actual_value;return{id:a,name:n.name,data_key:a}}function lz(e,t,n){const s=rz(e,n),i=O(e.x_axis.data_key),a=v.uniqBy(n[i.queryID],i.columnKey).map(p=>p[i.columnKey]),l=v.groupBy(s,i.columnKey),c=oz(e,t),u=HM(e,c,a,l),d={xAxis:ez(e,a),yAxis:tz(c),series:u,grid:QM(),visualMap:[{min:0,max:1,calculable:!0,show:!1,seriesIndex:0,color:["#F0F0F0","#418AAF"]}],legend:iz(u)};return v.defaultsDeep({},d,az)}const cz={input:{border:"none !important",paddingLeft:0,lineHeight:"1.55 !important"}},uz=({conf:e,metricKey:t,setMetricKey:n})=>{const{deviation:s,metrics:i}=e,a=g.useMemo(()=>{const l=i.map(c=>({label:c.name,value:c.data_key}));return l.push({label:s.name?s.name:s.data_keys.actual_value,value:s.data_keys.actual_value}),l},[s,i]);return r.jsxs(o.Group,{spacing:1,children:[r.jsx(o.Text,{size:12,color:"dimmed",sx:{cursor:"default",userSelect:"none"},children:"基线指标"}),r.jsx(o.NativeSelect,{size:"xs",data:a,value:t,onChange:l=>n(l.currentTarget.value),styles:cz})]})},dz={"tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function pz(){return r.jsxs(o.HoverCard,{width:400,shadow:"md",children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:r.jsx(M.IconInfoCircle,{size:14}),children:"指标说明"})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(o.Table,{fontSize:14,sx:dz,children:r.jsxs("tbody",{children:[r.jsxs("tr",{children:[r.jsx("th",{children:"估算偏差"}),r.jsx("td",{children:"使用斐波那契数列(1,2,3,5,8,13)估算故事点,每个数位为一个档位,计算issue实际故事点与估算故事点的档位偏差,即为估算偏差。如估算故事点为5,实际故事点为8,则估算偏差为-1。"})]}),r.jsxs("tr",{children:[r.jsx("th",{children:"准确估算比例"}),r.jsx("td",{children:"偏差在 ± 1 档位内的 issue 均为准确估算,以此计算准确估算的比例。"})]})]})})})]})}function hz(e){return r.jsxs(o.Group,{position:"apart",children:[r.jsx(pz,{}),r.jsx(uz,{...e})]})}function fz({conf:e,data:t,width:n,height:s,metricKey:i}){const a=g.useMemo(()=>lz(e,i,t),[e,t,i]);return r.jsx(Pe,{echarts:Ae,option:a,style:{width:n,height:s},notMerge:!0,theme:"merico-light"})}function gz({context:e}){const{value:t}=$(e.instanceData,"config"),n=g.useMemo(()=>v.defaults({},t,$o),[t]),s=e.data,{width:i,height:a}=e.viewport,{x_axis:l,deviation:c}=n,{estimated_value:u,actual_value:d}=c.data_keys,[p,h]=g.useState(d);if(g.useEffect(()=>{h(y=>y||d)},[d]),!l.data_key||!u||!d||!i||!a)return null;const f=Math.max(wt(i),300),m=Math.max(Ct(a),370);return r.jsxs(o.Box,{pt:Qe.top,pr:Qe.right,pb:Qe.bottom,pl:Qe.left,sx:{overflow:"hidden",height:a,width:i},children:[r.jsx(hz,{conf:n,metricKey:p,setMetricKey:h}),r.jsx(fz,{width:f,height:m-30,data:s,conf:n,metricKey:p})]})}function mz({control:e,watch:t}){return t(["deviation"]),r.jsxs(o.Stack,{children:[r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"deviation.name",control:e,render:({field:n})=>r.jsx(o.TextInput,{label:"指标名称",sx:{flex:1},...n})})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"deviation.data_keys.estimated_value",control:e,render:({field:n})=>r.jsx(F,{label:"估算值字段",required:!0,sx:{flex:1},...n})}),r.jsx(b.Controller,{name:"deviation.data_keys.actual_value",control:e,render:({field:n})=>r.jsx(F,{label:"实际值字段",required:!0,sx:{flex:1},...n})})]})]})}const xz=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},yz=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:"设置可以展示在基线图的指标,例如代码当量"})]}),r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(ge,{control:e,watch:t,name:"metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(xz,{control:e,index:l})})]})};function bz({control:e,watch:t}){return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:n})=>r.jsx(F,{label:"数据字段",required:!0,sx:{flex:1},...n})}),r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:n})=>r.jsx(o.TextInput,{label:"X轴名称",sx:{flex:1},...n})})]}),r.jsx(o.Divider,{mb:-15,label:"点位文案",labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>r.jsx(Zt,{sx:{width:"48%"},...n})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>r.jsx(kt,{...n})})]})]})}function vz({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=g.useMemo(()=>v.defaultsDeep({},t,$o),[t]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});g.useEffect(()=>{u(s)},[s]),l([]);const d=c(),p=g.useMemo(()=>!v.isEqual(d,s),[d,s]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(ke,{canSubmit:p}),r.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"12px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:"X轴"}),r.jsx(o.Tabs.Tab,{value:"Deviation",children:"偏差"}),r.jsx(o.Tabs.Tab,{value:"Additional Metrics",children:"指标"})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx(bz,{control:i,watch:l})}),r.jsx(o.Tabs.Panel,{value:"Deviation",children:r.jsx(mz,{control:i,watch:l})}),r.jsx(o.Tabs.Panel,{value:"Additional Metrics",children:r.jsx(yz,{control:i,watch:l})})]})]})})}const _z=[{lang:"en",resources:{merico_estimation_chart:{viz_name:"Merico Estimation Chart"}}},{lang:"zh",resources:{merico_estimation_chart:{viz_name:"思码逸估算分析图"}}}];function jz(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis:i,deviation:a,metrics:l,...c}=e;return{...c,x_axis:{...i,data_key:s(i.data_key)},deviation:{...a,data_keys:{estimated_value:s(a.data_keys.estimated_value),actual_value:s(a.data_keys.actual_value)}},metrics:l.map(u=>({...u,data_key:s(u.data_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class wz extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:jz(i,s)}})}}const Cz={displayName:"viz.merico_estimation_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new wz,name:"mericoEstimationChart",viewRender:gz,configRender:vz,createConfig:()=>({version:2,config:$o}),translation:_z},Go={styles:{justify:"space-around",align:"start"},metrics:[]};function Sz(){return{id:new Date().getTime().toString(),names:{value:"Value",basis:"Basis"},data_keys:{value:"",basis:""},formatter:Me,postfix:{type:"text",value:""}}}const Th=({postfix:e})=>e?r.jsxs(r.Fragment,{children:[r.jsx(o.Text,{size:"12px",color:"#818388",sx:{lineHeight:1},children:"/"}),r.jsx(o.Text,{size:"12px",color:"#818388",sx:{lineHeight:1},children:e})]}):null,kz=D.observer(({metric:e,variableValueMap:t})=>{const{names:n,data_keys:s,formatter:i,postfix:a}=e,l=_e(),c=g.useMemo(()=>{if(a.type==="text"&&a.value)return a.value;if(a.type==="filter-option-label"&&a.value){const u=l.filters.getSelectOption(a.value);return u?u.label:null}return null},[a,l]);return r.jsxs(o.Stack,{spacing:18,children:[r.jsxs(o.Stack,{spacing:12,children:[r.jsx(o.Text,{size:"14px",color:"#818388",children:n.value}),r.jsxs(o.Group,{spacing:"2px",align:"baseline",children:[r.jsx(o.Text,{size:"24px",fw:"bold",color:"#3D3E45",sx:{lineHeight:1},children:U(t[s.value],i)}),r.jsx(Th,{postfix:c})]})]}),r.jsxs(o.Stack,{spacing:12,children:[r.jsx(o.Text,{size:"14px",color:"#818388",children:n.basis}),r.jsxs(o.Group,{spacing:"2px",align:"baseline",children:[r.jsx(o.Text,{size:"12px",color:"#3D3E45",sx:{lineHeight:1},children:U(t[s.basis],i)}),r.jsx(Th,{postfix:c})]})]})]})}),Tz=D.observer(({context:e,instance:t})=>{const{value:n}=$(e.instanceData,"config"),{variables:s}=e,i=g.useMemo(()=>v.defaults({},n,Go),[n]),a=e.data,l=g.useMemo(()=>bo(a,s),[s,a]),{width:c,height:u}=e.viewport;return!c||!u||!i?null:r.jsx(o.Flex,{w:`${c}px`,h:`${u}px`,justify:i.styles.justify,align:i.styles.align,direction:"row",wrap:"nowrap",sx:{overflow:"hidden"},children:i.metrics.map(d=>r.jsx(kz,{metric:d,variableValueMap:l},d.id))})}),Dz=D.observer(g.forwardRef(({value:e,onChange:t},n)=>{const{t:s,i18n:i}=_.useTranslation(),l=Y().filters.selects,c=p=>{t({type:p,value:e.value})},u=p=>{t({type:e.type,value:p})},d=g.useMemo(()=>[{label:s("viz.merico_stats.metric.postfix_type.text"),value:"text"},{label:s("viz.merico_stats.metric.postfix_type.filter"),value:"filter-option-label"}],[i.language]);return r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.Select,{label:s("viz.merico_stats.metric.postfix_type.label"),data:d,value:e.type,onChange:c}),e.type==="text"&&r.jsx(o.TextInput,{label:s("viz.merico_stats.metric.postfix_content"),value:e.value,onChange:p=>{u(p.currentTarget.value)}}),e.type==="filter-option-label"&&r.jsx(o.Select,{label:s("viz.merico_stats.metric.postfix_filter"),value:e.value,onChange:u,data:l})]})}));function Mz({control:e,index:t,watch:n,variableOptions:s}){const{t:i}=_.useTranslation();return n(`metrics.${t}.postfix`),r.jsxs(o.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`metrics.${t}.names.value`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:i("viz.merico_stats.metric.metric_name"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:`metrics.${t}.data_keys.value`,control:e,render:({field:a})=>r.jsx(o.Select,{label:i("viz.merico_stats.metric.metric_data_field"),required:!0,data:s,sx:{flex:1},...a})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`metrics.${t}.names.basis`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:i("viz.merico_stats.metric.basis_name"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:`metrics.${t}.data_keys.basis`,control:e,render:({field:a})=>r.jsx(o.Select,{label:i("viz.merico_stats.metric.basis_data_field"),required:!0,data:s,sx:{flex:1},...a})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:i("numbro.format.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`metrics.${t}.formatter`,control:e,render:({field:a})=>r.jsx(gt,{...a})}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:i("viz.merico_stats.metric.others"),labelPosition:"center"}),r.jsx(b.Controller,{name:`metrics.${t}.postfix`,control:e,render:({field:a})=>r.jsx(Dz,{...a})})]})}const zz=({control:e,watch:t,variables:n})=>{const{t:s}=_.useTranslation(),i=()=>Sz(),a=(u,d)=>{const p=u.names.value.trim();return p||d+1},l=({field:u,index:d,fields:p})=>p.length<=1,c=g.useMemo(()=>n.map(u=>({label:u.name,value:u.name})),[n]);return r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mt:15,variant:"dashed",label:s("viz.merico_stats.metric.labels"),labelPosition:"center"}),r.jsx(ge,{control:e,watch:t,name:"metrics",getItem:i,addButtonText:s("chart.tooltip.additional_metrics.add"),deleteButtonText:s("chart.tooltip.additional_metrics.delete"),renderTabName:a,deleteDisalbed:l,children:({field:u,index:d})=>r.jsx(Mz,{control:e,index:d,variableOptions:c,watch:t})})]})};function Iz({control:e,watch:t}){const{t:n}=_.useTranslation();return t("styles"),r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mt:15,variant:"dashed",label:n("style.label"),labelPosition:"center"}),r.jsxs(o.Group,{children:[r.jsx(b.Controller,{name:"styles.justify",control:e,render:({field:s})=>r.jsx(qv,{sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"styles.align",control:e,render:({field:s})=>r.jsx(Vv,{label:n("viz.merico_stats.align_items.label"),sx:{flex:1},...s})})]})]})}function Ez({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),{variables:s}=e,i=g.useMemo(()=>v.defaultsDeep({},t,Go),[t]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d}=b.useForm({defaultValues:i});g.useEffect(()=>{d(i)},[i]);const p=u(),h=g.useMemo(()=>!v.isEqual(p,i),[p,i]);return r.jsx("form",{onSubmit:l(n),children:r.jsxs(o.Stack,{spacing:"xs",children:[r.jsx(ke,{canSubmit:h}),r.jsx(Iz,{control:a,watch:c}),r.jsx(zz,{control:a,watch:c,variables:s})]})})}function Az(e){const{metrics:t,...n}=e;return{...n,metrics:t.map(s=>({...s,postfix:s.postfix??{type:"text",value:""}}))}}const Pz=[{lang:"en",resources:{merico_stats:{viz_name:"Merico Stats",align_items:{label:"Vertical Align"},metric:{labels:"Metrics",metric_name:"Metric Name",metric_data_field:"Metric Data Field",basis_name:"Basis Name",basis_data_field:"Basis Data Field",others:"Others",postfix_type:{label:"Postfix Type",text:"Text",filter:"Filter Option Label"},postfix_content:"Postfix Content",postfix_filter:"Postfix Filter"}}}},{lang:"zh",resources:{merico_stats:{viz_name:"思码逸数据指标",align_items:{label:"垂直对齐方式"},metric:{labels:"指标",metric_name:"指标名称",metric_data_field:"指标数据字段",basis_name:"基准名",basis_data_field:"基准数据字段",others:"其他",postfix_type:{label:"后缀类型",text:"文本",filter:"筛选器选项文案"},postfix_content:"后缀文案",postfix_filter:"筛选器"}}}}];class Oz extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({...n,version:1,config:n.config})),this.version(2,n=>({...n,version:2,config:Az(n.config)}))}}const Lz={displayName:"viz.merico_stats.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Oz,name:"merico-stats",viewRender:Tz,configRender:Ez,createConfig:()=>({version:2,config:Go}),translation:Pz},Wo={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,overflow:Ke(),formatter:Le()}},y_axis:{name:"Y Axis",data_key:"",nameAlignment:"center",axisLabel:{rotate:0,overflow:Ke(),formatter:Le()}},heat_block:{name:"Value",data_key:"",value_formatter:Me,label:{show:!1,fontSize:10}},tooltip:{metrics:[]},visualMap:Ht()};function Bz({control:e,watch:t}){const{t:n}=_.useTranslation();t(["heat_block"]);const s=t("heat_block.label.show");return r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"heat_block.data_key",control:e,render:({field:i})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...i})}),r.jsx(b.Controller,{name:"heat_block.name",control:e,render:({field:i})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...i})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"heat_block.value_formatter",control:e,render:({field:i})=>r.jsx(gt,{...i})}),r.jsx(o.Divider,{mb:-5,variant:"dashed",label:n("chart.label.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"heat_block.label.show",control:e,render:({field:i})=>r.jsx(o.Switch,{label:n("chart.heatmap.heatblock.show_label"),checked:i.value,onChange:a=>i.onChange(a.currentTarget.checked),sx:{flexGrow:1}})}),r.jsx(b.Controller,{name:"heat_block.label.fontSize",control:e,render:({field:i})=>r.jsx(o.NumberInput,{size:"xs",icon:r.jsx(M.IconTextSize,{size:16}),disabled:!s,...i})})]})]})}const qz=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},Vz=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(ge,{control:e,watch:t,name:"tooltip.metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(qz,{control:e,index:l})})]})};function Nz({control:e,watch:t}){return r.jsx(Vz,{control:e,watch:t})}function $z({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(Tt,{...s})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Zt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(kt,{...s})})]})]})}function Fz({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["y_axis"]),r.jsxs(o.Stack,{my:0,p:"0",sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"y_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})})]}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"y_axis.nameAlignment",control:e,render:({field:s})=>r.jsx(bn,{sx:{flex:1},...s})})}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(Tt,{...s})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Zt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(kt,{...s})})]})]})}function Gz({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>n?v.defaults({},n):Wo,[n]),a=g.useMemo(()=>v.cloneDeep(i),[i]);g.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const l=b.useForm({defaultValues:a}),{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=l;g.useEffect(()=>{h(a)},[a]);const f=p(),m=g.useMemo(()=>!v.isEqual(f,i),[f,i]);return r.jsx("form",{onSubmit:u(s),style:{flexGrow:1},children:r.jsxs(o.Stack,{spacing:"xs",sx:{height:"100%"},children:[r.jsx(ke,{canSubmit:m}),r.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),r.jsx(o.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),r.jsx(o.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx($z,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(Fz,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Heat Block",children:r.jsx(Bz,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Visual Map",children:r.jsx(So,{form:l})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(Nz,{control:c,watch:d})})]})]})})}function Wz(e){return r.jsx(r.Fragment,{})}function Rz(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.merico_heatmap.click_heatmap.heatblock.label")})}const Dh={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:Rz,configRender:Wz,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Qz(e){const t=Ye(e.x_axis.axisLabel.formatter),n=Ye(e.y_axis.axisLabel.formatter);return{x_axis:t,y_axis:n}}function Uz(e){return{heat_block:function(s){if(!e.heat_block.value_formatter)return s;try{return U(s,e.heat_block.value_formatter)}catch(i){return console.error(i),s}}}}function Yz(e){let t=0;return e.x_axis.name&&(t+=20),{top:45,left:5,right:5,bottom:t,containLabel:!0,borderColor:"none",backgroundColor:"#E7E7E9",z:1}}function Kz(e,t){const{heat_block:n}=e;return{type:"heatmap",name:n.name,xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{borderWidth:0},data:t,label:n.label,labelLayout:{hideOverlap:!0},z:2}}const Xz=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Jz({conf:e,labelFormatters:t,valueFormatters:n,dataDict:s,params:i}){const{value:a,dataIndex:l}=i,[c,u,d]=a,p={label:e.x_axis.name?e.x_axis.name:"X Axis",value:t.x_axis(c,l),style:{label:"",value:ut(e.x_axis.axisLabel.overflow.in_tooltip)}},h={label:e.y_axis.name?e.y_axis.name:"Y Axis",value:t.y_axis(u,l),style:{label:"",value:ut(e.y_axis.axisLabel.overflow.in_tooltip)}},f={label:e.heat_block.name,value:n.heat_block(d),style:{label:"",value:""}},m=[p,h,f],y=s[`${c}---${u}`];return y&&e.tooltip.metrics.forEach(j=>{const k=O(j.data_key);m.push({label:j.name,value:Xz(v.get(y,k.columnKey,"")),style:{label:"",value:""}})}),m}function Zz(e,t,n,s){const{x_axis:i,y_axis:a,heat_block:l}=e,c=O(i.data_key),u=O(a.data_key);O(l.data_key);const d=v.keyBy(t[c.queryID],p=>`${p[c.columnKey]}---${p[u.columnKey]}`);return te.getTooltip({formatter:function(p){const f=Jz({conf:e,labelFormatters:n,valueFormatters:s,dataDict:d,params:p}).map(y=>`
|
|
431
|
+
`}},show_in_legend:!0}))}function HM(e,t,n,s){const i=O(t.data_key),a=t.name,l=n.map(c=>{const u=v.sumBy(s[c],i.columnKey);return[c,u]});return{type:"line",name:a,xAxisIndex:3,yAxisIndex:3,color:"#b41529",data:l,show_in_legend:!1}}function ez(e,t,n,s){const l={barMinWidth:5,barMaxWidth:20};return[YM(e,n,s),XM(e,n,s,l),...ZM(e,n,s,l),HM(e,t,n,s)]}function tz(e,t){const{axisLabel:n}=e.x_axis;return[{data:t,id:"准确估算比例",gridIndex:0,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"平均偏差",gridIndex:1,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!0,lineStyle:{color:"#FFFFFF",width:2}},type:"category"},{data:t,id:"数量占比",gridIndex:2,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"代码当量",gridIndex:3,axisTick:{show:!1},type:"category",axisLabel:{...n,formatter:Ye(n.formatter)},axisLine:{show:!1}}]}function nz(e){return[{type:"category",name:"准确估算比例",nameRotate:0,nameGap:5,nameLocation:"end",nameTextStyle:{align:"left"},gridIndex:0,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"平均偏差",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:1,boundaryGap:[1,1],axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"数量占比",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:2,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1},min:0,max:1},{type:"value",gridIndex:3,position:"right",splitNumber:3,axisLabel:{show:!0,verticalAlign:"top",showMinLabel:!1,lineHeight:14},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:e.name,nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:3,position:"left",axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}}]}function Fo(e){return e==1||e==2?1:Fo(e-2)+Fo(e-1)}const rz=Array.from(new Array(20),(e,t)=>Fo(t+1));function kh(e){return e<=1?e:rz.findIndex(t=>e<=t)-1}function sz(e,t){const{x_axis:n,deviation:s}=e,i=O(n.data_key),a=O(s.data_keys.estimated_value),l=O(s.data_keys.actual_value);return t[i.queryID].map(c=>{const u=kh(c[a.columnKey]),d=kh(c[l.columnKey]),p=u-d;return{...c,level:{estimated:u,actual:d,diff:p}}})}function iz(e){return e==="rgba(255, 255, 255, 1)"?{borderColor:"rgba(0,0,0,.1)",borderWidth:1}:{}}function az(e){return{show:!0,orient:"vertical",top:"middle",right:0,data:e.filter(n=>n.show_in_legend).reverse().map(n=>({name:`${n.name}`,color:n.color,itemStyle:iz(n.color)})),tooltip:{show:!0,formatter:"档位偏差:{a}"}}}const oz={tooltip:{trigger:"axis"}};function lz(e,t){const{deviation:n,metrics:s}=e,i=s.find(l=>l.data_key===t);if(i)return i;const a=n.data_keys.actual_value;return{id:a,name:n.name,data_key:a}}function cz(e,t,n){const s=sz(e,n),i=O(e.x_axis.data_key),a=v.uniqBy(n[i.queryID],i.columnKey).map(p=>p[i.columnKey]),l=v.groupBy(s,i.columnKey),c=lz(e,t),u=ez(e,c,a,l),d={xAxis:tz(e,a),yAxis:nz(c),series:u,grid:UM(),visualMap:[{min:0,max:1,calculable:!0,show:!1,seriesIndex:0,color:["#F0F0F0","#418AAF"]}],legend:az(u)};return v.defaultsDeep({},d,oz)}const uz={input:{border:"none !important",paddingLeft:0,lineHeight:"1.55 !important"}},dz=({conf:e,metricKey:t,setMetricKey:n})=>{const{deviation:s,metrics:i}=e,a=g.useMemo(()=>{const l=i.map(c=>({label:c.name,value:c.data_key}));return l.push({label:s.name?s.name:s.data_keys.actual_value,value:s.data_keys.actual_value}),l},[s,i]);return r.jsxs(o.Group,{spacing:1,children:[r.jsx(o.Text,{size:12,color:"dimmed",sx:{cursor:"default",userSelect:"none"},children:"基线指标"}),r.jsx(o.NativeSelect,{size:"xs",data:a,value:t,onChange:l=>n(l.currentTarget.value),styles:uz})]})},pz={"tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function hz(){return r.jsxs(o.HoverCard,{width:400,shadow:"md",children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:r.jsx(M.IconInfoCircle,{size:14}),children:"指标说明"})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(o.Table,{fontSize:14,sx:pz,children:r.jsxs("tbody",{children:[r.jsxs("tr",{children:[r.jsx("th",{children:"估算偏差"}),r.jsx("td",{children:"使用斐波那契数列(1,2,3,5,8,13)估算故事点,每个数位为一个档位,计算issue实际故事点与估算故事点的档位偏差,即为估算偏差。如估算故事点为5,实际故事点为8,则估算偏差为-1。"})]}),r.jsxs("tr",{children:[r.jsx("th",{children:"准确估算比例"}),r.jsx("td",{children:"偏差在 ± 1 档位内的 issue 均为准确估算,以此计算准确估算的比例。"})]})]})})})]})}function fz(e){return r.jsxs(o.Group,{position:"apart",children:[r.jsx(hz,{}),r.jsx(dz,{...e})]})}function gz({conf:e,data:t,width:n,height:s,metricKey:i}){const a=g.useMemo(()=>cz(e,i,t),[e,t,i]);return r.jsx(Pe,{echarts:Ae,option:a,style:{width:n,height:s},notMerge:!0,theme:"merico-light"})}function mz({context:e}){const{value:t}=$(e.instanceData,"config"),n=g.useMemo(()=>v.defaults({},t,$o),[t]),s=e.data,{width:i,height:a}=e.viewport,{x_axis:l,deviation:c}=n,{estimated_value:u,actual_value:d}=c.data_keys,[p,h]=g.useState(d);if(g.useEffect(()=>{h(y=>y||d)},[d]),!l.data_key||!u||!d||!i||!a)return null;const f=Math.max(wt(i),300),m=Math.max(Ct(a),370);return r.jsxs(o.Box,{pt:Qe.top,pr:Qe.right,pb:Qe.bottom,pl:Qe.left,sx:{overflow:"hidden",height:a,width:i},children:[r.jsx(fz,{conf:n,metricKey:p,setMetricKey:h}),r.jsx(gz,{width:f,height:m-30,data:s,conf:n,metricKey:p})]})}function xz({control:e,watch:t}){return t(["deviation"]),r.jsxs(o.Stack,{children:[r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"deviation.name",control:e,render:({field:n})=>r.jsx(o.TextInput,{label:"指标名称",sx:{flex:1},...n})})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"deviation.data_keys.estimated_value",control:e,render:({field:n})=>r.jsx(F,{label:"估算值字段",required:!0,sx:{flex:1},...n})}),r.jsx(b.Controller,{name:"deviation.data_keys.actual_value",control:e,render:({field:n})=>r.jsx(F,{label:"实际值字段",required:!0,sx:{flex:1},...n})})]})]})}const yz=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},bz=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:"设置可以展示在基线图的指标,例如代码当量"})]}),r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(ge,{control:e,watch:t,name:"metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(yz,{control:e,index:l})})]})};function vz({control:e,watch:t}){return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:n})=>r.jsx(F,{label:"数据字段",required:!0,sx:{flex:1},...n})}),r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:n})=>r.jsx(o.TextInput,{label:"X轴名称",sx:{flex:1},...n})})]}),r.jsx(o.Divider,{mb:-15,label:"点位文案",labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>r.jsx(Zt,{sx:{width:"48%"},...n})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>r.jsx(kt,{...n})})]})]})}function _z({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=g.useMemo(()=>v.defaultsDeep({},t,$o),[t]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});g.useEffect(()=>{u(s)},[s]),l([]);const d=c(),p=g.useMemo(()=>!v.isEqual(d,s),[d,s]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(ke,{canSubmit:p}),r.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"12px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:"X轴"}),r.jsx(o.Tabs.Tab,{value:"Deviation",children:"偏差"}),r.jsx(o.Tabs.Tab,{value:"Additional Metrics",children:"指标"})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx(vz,{control:i,watch:l})}),r.jsx(o.Tabs.Panel,{value:"Deviation",children:r.jsx(xz,{control:i,watch:l})}),r.jsx(o.Tabs.Panel,{value:"Additional Metrics",children:r.jsx(bz,{control:i,watch:l})})]})]})})}const jz=[{lang:"en",resources:{merico_estimation_chart:{viz_name:"Merico Estimation Chart"}}},{lang:"zh",resources:{merico_estimation_chart:{viz_name:"思码逸估算分析图"}}}];function wz(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis:i,deviation:a,metrics:l,...c}=e;return{...c,x_axis:{...i,data_key:s(i.data_key)},deviation:{...a,data_keys:{estimated_value:s(a.data_keys.estimated_value),actual_value:s(a.data_keys.actual_value)}},metrics:l.map(u=>({...u,data_key:s(u.data_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class Cz extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:wz(i,s)}})}}const Sz={displayName:"viz.merico_estimation_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Cz,name:"mericoEstimationChart",viewRender:mz,configRender:_z,createConfig:()=>({version:2,config:$o}),translation:jz},Go={styles:{justify:"space-around",align:"start"},metrics:[]};function kz(){return{id:new Date().getTime().toString(),names:{value:"Value",basis:"Basis"},data_keys:{value:"",basis:""},formatter:Me,postfix:{type:"text",value:""}}}const Th=({postfix:e})=>e?r.jsxs(r.Fragment,{children:[r.jsx(o.Text,{size:"12px",color:"#818388",sx:{lineHeight:1},children:"/"}),r.jsx(o.Text,{size:"12px",color:"#818388",sx:{lineHeight:1},children:e})]}):null,Tz=D.observer(({metric:e,variableValueMap:t})=>{const{names:n,data_keys:s,formatter:i,postfix:a}=e,l=_e(),c=g.useMemo(()=>{if(a.type==="text"&&a.value)return a.value;if(a.type==="filter-option-label"&&a.value){const u=l.filters.getSelectOption(a.value);return u?u.label:null}return null},[a,l]);return r.jsxs(o.Stack,{spacing:18,children:[r.jsxs(o.Stack,{spacing:12,children:[r.jsx(o.Text,{size:"14px",color:"#818388",children:n.value}),r.jsxs(o.Group,{spacing:"2px",align:"baseline",children:[r.jsx(o.Text,{size:"24px",fw:"bold",color:"#3D3E45",sx:{lineHeight:1},children:U(t[s.value],i)}),r.jsx(Th,{postfix:c})]})]}),r.jsxs(o.Stack,{spacing:12,children:[r.jsx(o.Text,{size:"14px",color:"#818388",children:n.basis}),r.jsxs(o.Group,{spacing:"2px",align:"baseline",children:[r.jsx(o.Text,{size:"12px",color:"#3D3E45",sx:{lineHeight:1},children:U(t[s.basis],i)}),r.jsx(Th,{postfix:c})]})]})]})}),Dz=D.observer(({context:e,instance:t})=>{const{value:n}=$(e.instanceData,"config"),{variables:s}=e,i=g.useMemo(()=>v.defaults({},n,Go),[n]),a=e.data,l=g.useMemo(()=>bo(a,s),[s,a]),{width:c,height:u}=e.viewport;return!c||!u||!i?null:r.jsx(o.Flex,{w:`${c}px`,h:`${u}px`,justify:i.styles.justify,align:i.styles.align,direction:"row",wrap:"nowrap",sx:{overflow:"hidden"},children:i.metrics.map(d=>r.jsx(Tz,{metric:d,variableValueMap:l},d.id))})}),Mz=D.observer(g.forwardRef(({value:e,onChange:t},n)=>{const{t:s,i18n:i}=_.useTranslation(),l=Y().filters.selects,c=p=>{t({type:p,value:e.value})},u=p=>{t({type:e.type,value:p})},d=g.useMemo(()=>[{label:s("viz.merico_stats.metric.postfix_type.text"),value:"text"},{label:s("viz.merico_stats.metric.postfix_type.filter"),value:"filter-option-label"}],[i.language]);return r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.Select,{label:s("viz.merico_stats.metric.postfix_type.label"),data:d,value:e.type,onChange:c}),e.type==="text"&&r.jsx(o.TextInput,{label:s("viz.merico_stats.metric.postfix_content"),value:e.value,onChange:p=>{u(p.currentTarget.value)}}),e.type==="filter-option-label"&&r.jsx(o.Select,{label:s("viz.merico_stats.metric.postfix_filter"),value:e.value,onChange:u,data:l})]})}));function zz({control:e,index:t,watch:n,variableOptions:s}){const{t:i}=_.useTranslation();return n(`metrics.${t}.postfix`),r.jsxs(o.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`metrics.${t}.names.value`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:i("viz.merico_stats.metric.metric_name"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:`metrics.${t}.data_keys.value`,control:e,render:({field:a})=>r.jsx(o.Select,{label:i("viz.merico_stats.metric.metric_data_field"),required:!0,data:s,sx:{flex:1},...a})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`metrics.${t}.names.basis`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:i("viz.merico_stats.metric.basis_name"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:`metrics.${t}.data_keys.basis`,control:e,render:({field:a})=>r.jsx(o.Select,{label:i("viz.merico_stats.metric.basis_data_field"),required:!0,data:s,sx:{flex:1},...a})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:i("numbro.format.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`metrics.${t}.formatter`,control:e,render:({field:a})=>r.jsx(gt,{...a})}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:i("viz.merico_stats.metric.others"),labelPosition:"center"}),r.jsx(b.Controller,{name:`metrics.${t}.postfix`,control:e,render:({field:a})=>r.jsx(Mz,{...a})})]})}const Iz=({control:e,watch:t,variables:n})=>{const{t:s}=_.useTranslation(),i=()=>kz(),a=(u,d)=>{const p=u.names.value.trim();return p||d+1},l=({field:u,index:d,fields:p})=>p.length<=1,c=g.useMemo(()=>n.map(u=>({label:u.name,value:u.name})),[n]);return r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mt:15,variant:"dashed",label:s("viz.merico_stats.metric.labels"),labelPosition:"center"}),r.jsx(ge,{control:e,watch:t,name:"metrics",getItem:i,addButtonText:s("chart.tooltip.additional_metrics.add"),deleteButtonText:s("chart.tooltip.additional_metrics.delete"),renderTabName:a,deleteDisalbed:l,children:({field:u,index:d})=>r.jsx(zz,{control:e,index:d,variableOptions:c,watch:t})})]})};function Ez({control:e,watch:t}){const{t:n}=_.useTranslation();return t("styles"),r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mt:15,variant:"dashed",label:n("style.label"),labelPosition:"center"}),r.jsxs(o.Group,{children:[r.jsx(b.Controller,{name:"styles.justify",control:e,render:({field:s})=>r.jsx(qv,{sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"styles.align",control:e,render:({field:s})=>r.jsx(Vv,{label:n("viz.merico_stats.align_items.label"),sx:{flex:1},...s})})]})]})}function Az({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),{variables:s}=e,i=g.useMemo(()=>v.defaultsDeep({},t,Go),[t]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d}=b.useForm({defaultValues:i});g.useEffect(()=>{d(i)},[i]);const p=u(),h=g.useMemo(()=>!v.isEqual(p,i),[p,i]);return r.jsx("form",{onSubmit:l(n),children:r.jsxs(o.Stack,{spacing:"xs",children:[r.jsx(ke,{canSubmit:h}),r.jsx(Ez,{control:a,watch:c}),r.jsx(Iz,{control:a,watch:c,variables:s})]})})}function Pz(e){const{metrics:t,...n}=e;return{...n,metrics:t.map(s=>({...s,postfix:s.postfix??{type:"text",value:""}}))}}const Oz=[{lang:"en",resources:{merico_stats:{viz_name:"Merico Stats",align_items:{label:"Vertical Align"},metric:{labels:"Metrics",metric_name:"Metric Name",metric_data_field:"Metric Data Field",basis_name:"Basis Name",basis_data_field:"Basis Data Field",others:"Others",postfix_type:{label:"Postfix Type",text:"Text",filter:"Filter Option Label"},postfix_content:"Postfix Content",postfix_filter:"Postfix Filter"}}}},{lang:"zh",resources:{merico_stats:{viz_name:"思码逸数据指标",align_items:{label:"垂直对齐方式"},metric:{labels:"指标",metric_name:"指标名称",metric_data_field:"指标数据字段",basis_name:"基准名",basis_data_field:"基准数据字段",others:"其他",postfix_type:{label:"后缀类型",text:"文本",filter:"筛选器选项文案"},postfix_content:"后缀文案",postfix_filter:"筛选器"}}}}];class Lz extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({...n,version:1,config:n.config})),this.version(2,n=>({...n,version:2,config:Pz(n.config)}))}}const Bz={displayName:"viz.merico_stats.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Lz,name:"merico-stats",viewRender:Dz,configRender:Az,createConfig:()=>({version:2,config:Go}),translation:Oz},Wo={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,overflow:Ke(),formatter:Le()}},y_axis:{name:"Y Axis",data_key:"",nameAlignment:"center",axisLabel:{rotate:0,overflow:Ke(),formatter:Le()}},heat_block:{name:"Value",data_key:"",value_formatter:Me,label:{show:!1,fontSize:10}},tooltip:{metrics:[]},visualMap:Ht()};function qz({control:e,watch:t}){const{t:n}=_.useTranslation();t(["heat_block"]);const s=t("heat_block.label.show");return r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"heat_block.data_key",control:e,render:({field:i})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...i})}),r.jsx(b.Controller,{name:"heat_block.name",control:e,render:({field:i})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...i})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"heat_block.value_formatter",control:e,render:({field:i})=>r.jsx(gt,{...i})}),r.jsx(o.Divider,{mb:-5,variant:"dashed",label:n("chart.label.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"heat_block.label.show",control:e,render:({field:i})=>r.jsx(o.Switch,{label:n("chart.heatmap.heatblock.show_label"),checked:i.value,onChange:a=>i.onChange(a.currentTarget.checked),sx:{flexGrow:1}})}),r.jsx(b.Controller,{name:"heat_block.label.fontSize",control:e,render:({field:i})=>r.jsx(o.NumberInput,{size:"xs",icon:r.jsx(M.IconTextSize,{size:16}),disabled:!s,...i})})]})]})}const Vz=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},Nz=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(ge,{control:e,watch:t,name:"tooltip.metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(Vz,{control:e,index:l})})]})};function $z({control:e,watch:t}){return r.jsx(Nz,{control:e,watch:t})}function Fz({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(Tt,{...s})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Zt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(kt,{...s})})]})]})}function Gz({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["y_axis"]),r.jsxs(o.Stack,{my:0,p:"0",sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"y_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})})]}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"y_axis.nameAlignment",control:e,render:({field:s})=>r.jsx(bn,{sx:{flex:1},...s})})}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(Tt,{...s})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Zt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(kt,{...s})})]})]})}function Wz({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>n?v.defaults({},n):Wo,[n]),a=g.useMemo(()=>v.cloneDeep(i),[i]);g.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const l=b.useForm({defaultValues:a}),{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=l;g.useEffect(()=>{h(a)},[a]);const f=p(),m=g.useMemo(()=>!v.isEqual(f,i),[f,i]);return r.jsx("form",{onSubmit:u(s),style:{flexGrow:1},children:r.jsxs(o.Stack,{spacing:"xs",sx:{height:"100%"},children:[r.jsx(ke,{canSubmit:m}),r.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),r.jsx(o.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),r.jsx(o.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx(Fz,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(Gz,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Heat Block",children:r.jsx(qz,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Visual Map",children:r.jsx(So,{form:l})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx($z,{control:c,watch:d})})]})]})})}function Rz(e){return r.jsx(r.Fragment,{})}function Qz(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.merico_heatmap.click_heatmap.heatblock.label")})}const Dh={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:Qz,configRender:Rz,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Uz(e){const t=Ye(e.x_axis.axisLabel.formatter),n=Ye(e.y_axis.axisLabel.formatter);return{x_axis:t,y_axis:n}}function Yz(e){return{heat_block:function(s){if(!e.heat_block.value_formatter)return s;try{return U(s,e.heat_block.value_formatter)}catch(i){return console.error(i),s}}}}function Kz(e){let t=0;return e.x_axis.name&&(t+=20),{top:45,left:5,right:5,bottom:t,containLabel:!0,borderColor:"none",backgroundColor:"#E7E7E9",z:1}}function Xz(e,t){const{heat_block:n}=e;return{type:"heatmap",name:n.name,xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{borderWidth:0},data:t,label:n.label,labelLayout:{hideOverlap:!0},z:2}}const Jz=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Zz({conf:e,labelFormatters:t,valueFormatters:n,dataDict:s,params:i}){const{value:a,dataIndex:l}=i,[c,u,d]=a,p={label:e.x_axis.name?e.x_axis.name:"X Axis",value:t.x_axis(c,l),style:{label:"",value:ut(e.x_axis.axisLabel.overflow.in_tooltip)}},h={label:e.y_axis.name?e.y_axis.name:"Y Axis",value:t.y_axis(u,l),style:{label:"",value:ut(e.y_axis.axisLabel.overflow.in_tooltip)}},f={label:e.heat_block.name,value:n.heat_block(d),style:{label:"",value:""}},m=[p,h,f],y=s[`${c}---${u}`];return y&&e.tooltip.metrics.forEach(j=>{const k=O(j.data_key);m.push({label:j.name,value:Jz(v.get(y,k.columnKey,"")),style:{label:"",value:""}})}),m}function Hz(e,t,n,s){const{x_axis:i,y_axis:a,heat_block:l}=e,c=O(i.data_key),u=O(a.data_key);O(l.data_key);const d=v.keyBy(t[c.queryID],p=>`${p[c.columnKey]}---${p[u.columnKey]}`);return te.getTooltip({formatter:function(p){const f=Zz({conf:e,labelFormatters:n,valueFormatters:s,dataDict:d,params:p}).map(y=>`
|
|
432
432
|
<tr>
|
|
433
433
|
<th style="text-align: right;">
|
|
434
434
|
<div style="${y.style.label}">${y.label}</div>
|
|
@@ -449,19 +449,19 @@ Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(
|
|
|
449
449
|
</thead>
|
|
450
450
|
<tbody>${f.join("")}</tbody>
|
|
451
451
|
</table>
|
|
452
|
-
`}})}function Hz(e,t,n){const{overflow:s,rotate:i}=e.x_axis.axisLabel,a=dt(s.on_axis);return te.getXAxis({id:"main-x-axis",type:"category",data:t,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:i,...a,formatter:n},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:3})}function eI(e,t,n){const{nameAlignment:s,data_key:i,...a}=e.y_axis,{overflow:l,rotate:c}=e.y_axis.axisLabel,u=dt(l.on_axis);return te.getYAxis({...a,type:"category",data:t,axisLabel:{rotate:c,...u,formatter:n},axisLine:{show:!0,lineStyle:{width:3}},axisTick:{show:!0,alignWithLabel:!0},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameTextStyle:{fontWeight:"bold",align:s},nameLocation:"end",nameGap:15,z:3})}function tI(e,t,n){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const s=n.reduce((k,S)=>{const T=Vt(S,t);return k[S.name]=rt(S,T),k},{}),i=Qz(e),a=Uz(e),l=Xs(e.visualMap,s),{min:c,max:u}=l,d=O(e.x_axis.data_key),p=O(e.y_axis.data_key),h=O(e.heat_block.data_key),f=v.uniq(t[d.queryID].map(k=>k[d.columnKey])),m=v.uniq(t[d.queryID].map(k=>k[p.columnKey])),y=t[d.queryID].map(k=>{const S=v.get(k,d.columnKey),T=v.get(k,p.columnKey),z=v.get(k,h.columnKey),I={value:[S,T,z]},{followVisualMap:E,color:N}=Co(z,c,u,e.visualMap);return E||(I.visualMap=!1,I.itemStyle={color:N}),I});return{xAxis:Hz(e,f,i.x_axis),yAxis:eI(e,m,i.y_axis),series:Kz(e,y),tooltip:Zz(e,t,i,a),grid:Yz(e),visualMap:l}}function nI({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=g.useMemo(()=>{const h=O(e.x_axis.data_key),f=O(e.y_axis.data_key);return v.keyBy(t[h.queryID],m=>`${m[h.columnKey]}---${m[f.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),c=st(i.triggerManager,Dh.id),u=g.useCallback(h=>{const[f,m]=h.value,y=v.get(l,`${f}---${m}`,{error:"rowData is not found"});c.forEach(j=>{i.runInteraction(j.id,{...h,rowData:y})})},[l,c,i]),d=g.useMemo(()=>({click:u}),[u]),p=g.useMemo(()=>tI(e,t,a),[e,t]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function rI({context:e,instance:t}){const n=it({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,Wo),[s]),l=e.data,{width:c,height:u}=e.viewport;return!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(nI,{variables:i,width:wt(c),height:Ct(u),data:l,conf:a,interactionManager:n})})}const sI=[{lang:"en",resources:{merico_heatmap:{viz_name:"Merico Heatmap",click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{merico_heatmap:{viz_name:"思码逸热力图",click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function iI(e){const{visualMap:t=Ht(),heat_block:{min:n,max:s,...i},...a}=e;return{...a,heat_block:i,visualMap:{...Ht(),min:n,max:s}}}class aI extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:iI(n.config)}))}}const oI={displayName:"viz.merico_heatmap.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new aI,name:"merico-heatmap",viewRender:rI,configRender:Gz,createConfig:()=>({version:2,config:Wo}),triggers:[Dh],translation:sI},lI=[{value:"#25262B",name:"Dark"},{value:"#868E96",name:"Gray"},{value:"#FA5252",name:"Red"},{value:"#E64980",name:"Pink"},{value:"#BE4BDB",name:"Grape"},{value:"#7950F2",name:"Violet"},{value:"#4C6EF5",name:"Indigo"},{value:"#228BE6",name:"Blue"},{value:"#15AABF",name:"Cyan"},{value:"#12B886",name:"Teal"},{value:"#40C057",name:"Green"},{value:"#82C91E",name:"Lime"},{value:"#FAB005",name:"Yellow"},{value:"#FD7E14",name:"Orange"}].map(e=>({name:e.name,value:e.value,type:"single",category:"basic"})),cI=[Ry,Qy,Ky,Yy,Uy,Xy],Mh=[Oo,c1,SD,Kk,z1,WS,RM,ub,aw,sC,XC,cM,ES,V0,UT,mk,Wk,PD,Cz,oI,Lz,xw],zh=()=>({id:"dashboard",version:xu,manifest:{viz:Mh,color:[...lI,...cI]}}),Wr=new eb,je={pluginManager:Kt("pluginManager"),vizManager:Kt("vizManager"),colorManager:Kt("colorManager"),instanceScope:{panelModel:Kt("panelModel"),vizInstance:Kt("vizInstance"),interactionManager:Kt("interactionManager"),migrator:Kt("migrator"),operationManager:Kt("operationManager"),triggerManager:Kt("triggerManager")}},Ro=()=>{try{Wr.install(zh())}catch{}const e=new Fy(Wr),t=new Hy(Wr);return{pluginManager:Wr,vizManager:e,colorManager:t}},Gt=g.createContext(Ro());try{Wr.install(zh())}catch{}const Qo=g.createContext(null);function si(e){const t=g.useContext(Qo),n=W.useCreation(()=>e.configure(t||new Ji),[e.configure]),s=W.usePrevious(n);return s&&s!==n&&s.dispose(),r.jsx(Qo.Provider,{value:n,children:e.children})}function Ih(){return g.useContext(Qo)}const uI=({description:e,isDescriptionEmpty:t})=>t?null:r.jsx(o.Tooltip,{color:"white",label:r.jsx(vr,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:r.jsx(o.Box,{sx:{height:"16px",alignSelf:"center"},children:r.jsx(M.IconInfoCircle,{size:16,color:"gray"})})}),dI=D.observer(({label:e,config:{default_value:t,description:n,isDescriptionEmpty:s,...i},value:a,onChange:l})=>r.jsxs(o.Box,{children:[r.jsx(o.Text,{children:" "}),r.jsx(o.Checkbox,{label:r.jsxs(o.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[r.jsx(o.Box,{sx:{flexGrow:1},children:e}),r.jsx(uI,{description:n,isDescriptionEmpty:s})]}),checked:a||!1,onChange:c=>l(c.currentTarget.checked),...i,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),pI=({value:e,onChange:t,close:n,max_days:s,allowSingleDateInRange:i})=>{const{i18n:a}=_.useTranslation(),[l,c]=e,u=g.useMemo(()=>l||new Date,[l]),d=g.useMemo(()=>{if(l&&!c)return l},[l,c]),p=g.useMemo(()=>{if(l&&!c&&s>0)return P(l).add(s-1,"days").toDate()},[l,c,s]),h=f=>{const[m,y]=f;t(f),m&&y&&n()};return r.jsx(uc.DatePicker,{defaultDate:u,numberOfColumns:2,type:"range",value:e,onChange:h,onNextMonth:console.log,minDate:d,maxDate:p,allowSingleDateInRange:i,locale:a.language})},hI=({begin:e,end:t})=>{const{t:n}=_.useTranslation(),s=g.useMemo(()=>P(t).diff(P(e),"days")+1,[e,t]);if(Number.isNaN(s))return r.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const i=s===1?n("filter.widget.date_range.one_day"):n("filter.widget.date_range.x_days",{count:s});return r.jsx(o.Tooltip,{label:i,children:r.jsx(o.Badge,{size:"sm",children:s})})},fI=({max_days:e})=>{const{t}=_.useTranslation();return e?r.jsxs(r.Fragment,{children:[r.jsx(o.Group,{position:"right",children:r.jsx(o.Badge,{size:"xs",children:t("filter.widget.date_range.x_max_days",{max_days:e})})}),r.jsx(o.Divider,{variant:"dashed",my:10})]}):null},Uo=()=>[{key:"d",value:"yesterday",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"w",value:"last week",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"week").startOf("week").toDate(),P(e).subtract(1,"week").endOf("week").toDate()]}},{key:"m",value:"last month",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"month").startOf("month").toDate(),P(e).subtract(1,"month").endOf("month").toDate()]}},{key:"m2",value:"last 2 months",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(2,"month").startOf("month").toDate(),P(e).subtract(1,"month").endOf("month").toDate()]}},{key:"m3",value:"last 3 months",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(3,"month").startOf("month").toDate(),P(e).subtract(1,"month").endOf("month").toDate()]}},{key:"y",value:"last year",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"year").startOf("year").toDate(),P(e).subtract(1,"year").endOf("year").toDate()]}},{key:"d7",value:"recent 7 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(7,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d30",value:"recent 30 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(30,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d60",value:"recent 60 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(60,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d90",value:"recent 90 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(90,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d180",value:"recent 180 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(180,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d365",value:"recent 365 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(365,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d",value:"today",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("day").toDate(),P(e).endOf("day").toDate()]}},{key:"w",value:"this week",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("week").toDate(),P(e).endOf("week").toDate()]}},{key:"m",value:"this month",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("month").toDate(),P(e).endOf("month").toDate()]}},{key:"y",value:"this year",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("year").toDate(),P(e).endOf("year").toDate()]}},{key:"w",value:"this week so far",group:"this_so_far",getRange:()=>{const e=Date.now();return[P(e).startOf("week").toDate(),P(e).toDate()]}},{key:"m",value:"this month so far",group:"this_so_far",getRange:()=>{const e=Date.now();return[P(e).startOf("month").toDate(),P(e).toDate()]}},{key:"y",value:"this year so far",group:"this_so_far",getRange:()=>{const e=Date.now();return[P(e).startOf("year").toDate(),P(e).toDate()]}}];function Eh(e){const n=Uo().find(s=>s.value===e);return n?n.getRange():null}const gI=({onChange:e})=>{const{t,i18n:n}=_.useTranslation(),s=l=>()=>{const c=l();e(c)},i=g.useMemo(()=>v.groupBy(Uo(),"group"),[]),a=n.language==="zh";return r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(o.Table,{withBorder:!1,sx:{"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:r.jsx("tbody",{children:Object.entries(i).map(([l,c])=>r.jsxs("tr",{children:[r.jsx("th",{children:r.jsx(o.Text,{size:"xs",color:"#555",children:t(`filter.widget.date_range.shortcut.${l}.label`)})}),c.map(({key:u,value:d,getRange:p})=>r.jsx("td",{children:r.jsx(o.Button,{compact:!0,size:"xs",variant:"subtle",onClick:s(p),children:t(`filter.widget.date_range.shortcut.${l}.${a?"full.":""}${u}`)})},u))]},l))})})]})},Ah=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),mI=({label:e,required:t,value:n,onChange:s,max_days:i,allowSingleDateInRange:a,inputFormat:l})=>{const{t:c}=_.useTranslation(),[u,{open:d,close:p}]=he.useDisclosure(!1),[h,f]=n,m=h?P(h).format(l):"",y=f?P(f).format(l):"";return r.jsxs(o.Popover,{opened:u,onClose:p,position:"bottom-start",shadow:"md",children:[r.jsxs(o.Group,{position:"left",grow:!0,noWrap:!0,spacing:0,w:"288px",sx:{marginTop:"3px"},children:[r.jsx(o.Popover.Target,{children:r.jsx(o.TextInput,{label:e,labelProps:{title:e},required:t,icon:r.jsx(M.IconCalendar,{size:16}),placeholder:c("filter.widget.date_range.start_date"),readOnly:!0,value:m,onFocus:d,styles:Ah(u),sx:{".mantine-TextInput-label":{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",width:"calc(240px)",position:"relative",zIndex:1},".mantine-Input-input":{borderRight:"none",borderTopRightRadius:0,borderBottomRightRadius:0}}})}),r.jsx(o.TextInput,{label:r.jsx(o.Group,{position:"right",children:r.jsx(hI,{begin:h,end:f})}),icon:r.jsx(M.IconMinus,{size:16}),placeholder:c("filter.widget.date_range.end_date"),readOnly:!0,disabled:!h,value:y,onFocus:d,styles:Ah(u),sx:{".mantine-Input-icon":{transform:"translateX(-22px)"},".mantine-Input-input":{borderLeft:"none",borderTopLeftRadius:0,borderBottomLeftRadius:0},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to right, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})]}),r.jsxs(o.Popover.Dropdown,{p:"sm",children:[r.jsx(fI,{max_days:i}),r.jsx(pI,{value:n,onChange:s,close:p,allowSingleDateInRange:a,max_days:i}),r.jsx(gI,{onChange:s})]})]})},Ph=D.observer(({label:e,config:t,value:n=[null,null],onChange:s})=>{const{inputFormat:i,required:a,max_days:l,allowSingleDateInRange:c}=t,u=Array.isArray(n)?n.map(p=>p?P(p).toDate():null):[null,null],d=p=>{s(p.map(h=>h&&P(h).format(i)))};return r.jsx(mI,{label:e,value:u,onChange:d,inputFormat:i,allowSingleDateInRange:c,max_days:l,required:a})}),xI=o.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-select.rc-select-open":{borderColor:"#228be6 !important",".rc-select-selection-overflow-item-rest":{display:"none"},".rc-select-selection-overflow-item-suffix":{display:"block"}},".rc-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-select-selection-search-mirror":{display:"none"},".rc-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,backgroundColor:"#fff",border:"1px solid #e9ecef",marginTop:6,padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px","&.rc-select-dropdown-slide-up-leave-active":{display:"none"},".rc-select-item-empty":{padding:"8px 12px"},".rc-select-item-option":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px 8px 2px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},flexDirection:"row-reverse",".rc-select-item-option-state":{flexGrow:0,flexShrink:0,width:"30px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},".rc-select-item-option-content":{width:"calc(100% - 30px)",overflow:"hidden",'div[data-role="label"]':{overflowWrap:"break-word"}}},".rc-virtual-list-holder-inner":{alignItems:"flex-start"}}})),Yo=({errorMessage:e})=>{const{t}=_.useTranslation();return e?r.jsx(o.Text,{color:"red",size:12,children:e}):r.jsx(o.Text,{color:"dimmed",size:12,children:t("filter.widget.common.selector_option_empty")})},yI=({disabled:e,classNames:t,styles:n,unstyled:s,radius:i,style:a,label:l,value:c,onChange:u,options:d,errorMessage:p,required:h})=>{const{t:f}=_.useTranslation(),{classes:m,cx:y}=xI({radius:i},{name:"MultiSelectWidget",classNames:t,styles:n,unstyled:s}),[j,k]=g.useState(!1),S=N=>{k(N)},T=j&&(c==null?void 0:c.length)>0,[z,I]=g.useState(""),E=g.useMemo(()=>{if(!z)return d;const N=z.toLowerCase(),R=pe=>{var ie;return((ie=pe.description)==null?void 0:ie.toLowerCase().includes(N))||pe.label.toLowerCase().includes(N)};return d.filter(R)},[z,d]);return r.jsxs(o.Stack,{spacing:3,children:[r.jsxs(o.Group,{position:"apart",children:[r.jsxs(o.Text,{className:m.label,children:[l,h&&r.jsx("span",{className:m.required,"aria-hidden":"true",children:"*"})]}),T&&r.jsx(o.Tooltip,{label:f("filter.widget.common.x_selected",{count:c.length}),children:r.jsx(o.Badge,{children:c.length})})]}),r.jsx(dc,{disabled:e,allowClear:!0,className:y(m.root,"check-select"),dropdownClassName:y(m.dropdown,""),onDropdownVisibleChange:S,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:a,clearIcon:()=>r.jsx(o.CloseButton,{}),value:c,onChange:u,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:r.jsx(Yo,{errorMessage:p}),maxTagTextLength:10,maxTagPlaceholder:N=>f("filter.widget.common.x_selected",{count:N.length}),searchValue:z,onSearch:I,filterOption:!1,children:E.map(N=>r.jsxs(dc.Option,{title:N.label,children:[r.jsx(o.Text,{size:"sm","data-role":"label",children:N.label}),N.description&&r.jsx(o.Text,{size:"xs",color:"dimmed","data-role":"description",children:N.description})]},N.value))})]})},bI=D.observer(({label:e,config:t,value:n,onChange:s})=>{const i=_e(),a=!!t.options_query_id,{state:l,error:c}=i.getDataStuffByID(t.options_query_id),u=l==="loading",d=t.min_width?t.min_width:"200px",p=a?u:!1,h=f=>s(f,!1);return r.jsx(yI,{label:e,options:t.options,style:{minWidth:"160px",width:d,maxWidth:p?d:"unset",borderColor:"#e9ecef"},disabled:p,value:n,onChange:h,errorMessage:c,required:t.required})}),vI=g.forwardRef(({label:e,description:t,...n},s)=>r.jsx("div",{ref:s,...n,children:r.jsx(o.Group,{noWrap:!0,children:r.jsxs("div",{children:[r.jsx(o.Text,{size:"sm","data-role":"label",children:e}),r.jsx(o.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),_I=D.observer(({label:e,config:t,value:n,onChange:s})=>{const i=_e(),a=!!t.options_query_id,{state:l,error:c}=i.getDataStuffByID(t.options_query_id),u=l==="loading";return r.jsx(o.Select,{label:e,data:t.options,disabled:a?u:!1,value:n,onChange:s,maxDropdownHeight:500,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"},".mantine-Select-nothingFound":{fontSize:"0.75rem",textAlign:"left",padding:"4px 10px"}},itemComponent:vI,searchable:!c,nothingFound:r.jsx(Yo,{errorMessage:c}),clearable:t.clearable})});function jI({label:e,config:t,value:n,onChange:s}){return r.jsx(o.TextInput,{label:e,value:n||"",onChange:i=>s(i.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const wI=({rotate:e,onClick:t})=>r.jsx("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:r.jsx("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),CI=({expanded:e,isLeaf:t,value:n,onClick:s,...i})=>(n==="0-0-value"&&console.log(i),t?r.jsx("span",{style:{width:"14px",display:"inline-block"}}):r.jsx(wI,{rotate:e?"0":"-90",onClick:s,...i})),SI=({onClick:e})=>r.jsxs("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),r.jsx("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),r.jsx("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),r.jsx("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),kI=({onClick:e,...t})=>r.jsx(SI,{onClick:e,...t}),TI=o.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),DI=({disabled:e,classNames:t,styles:n,unstyled:s,radius:i,style:a,label:l,value:c,onChange:u,treeData:d,errorMessage:p,required:h,treeCheckStrictly:f})=>{const{t:m}=_.useTranslation(),{classes:y,cx:j}=TI({radius:i},{name:"FilterTreeSelectWidget",classNames:t,styles:n,unstyled:s}),[k,S]=g.useState(!1),T=I=>{S(I)},z=k&&(c==null?void 0:c.length)>0;return r.jsxs(o.Stack,{spacing:3,children:[r.jsxs(o.Group,{position:"apart",children:[r.jsxs(o.Text,{className:y.label,children:[l,h&&r.jsx("span",{className:y.required,"aria-hidden":"true",children:"*"})]}),z&&r.jsx(o.Tooltip,{label:m("filter.widget.common.x_selected",{count:c.length}),children:r.jsx(o.Badge,{children:c.length})})]}),r.jsx(pc,{disabled:e,allowClear:!0,treeCheckStrictly:f,labelInValue:!0,className:j(y.root,"check-select"),dropdownClassName:j(y.dropdown,""),onDropdownVisibleChange:T,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:a,listHeight:510,treeLine:!0,clearIcon:()=>r.jsx(o.CloseButton,{}),switcherIcon:CI,treeIcon:kI,maxTagTextLength:10,value:c,treeData:d,notFoundContent:r.jsx(Yo,{errorMessage:p}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:pc.SHOW_PARENT,onChange:u,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:()=>m("filter.widget.common.x_selected",{count:c.length})})]})},MI=D.observer(({label:e,config:t,value:n,onChange:s})=>{const{treeData:i,treeDataLoading:a,errorMessage:l}=t,c=f=>{const m=f.map(y=>y.value);s(m,!1)},u=g.useMemo(()=>t.initialSelection(n),[n,t.initialSelection]),d=t.min_width?t.min_width:"200px",h=!!t.options_query_id?a:!1;return r.jsx(DI,{disabled:h,style:{minWidth:"160px",width:d,maxWidth:h?d:"unset",borderColor:"#e9ecef"},value:[...u],onChange:c,treeData:i,errorMessage:l,label:e,required:t.required,treeCheckStrictly:t.treeCheckStrictly})}),zI=D.observer(({filter:{type:e,config:t,key:n,...s},formFieldProps:i})=>{switch(e){case"select":return r.jsx(_I,{...s,...i,config:t});case"multi-select":return r.jsx(bI,{...s,...i,config:t});case"tree-select":return r.jsx(MI,{...s,...i,config:t});case"text-input":return r.jsx(jI,{...s,...i,config:t});case"date-range":return r.jsx(Ph,{...s,...i,config:t});case"checkbox":return r.jsx(dI,{...s,...i,config:t});default:return null}}),II=D.observer(g.forwardRef(({filter:e,...t},n)=>r.jsx("div",{className:"filter-root",ref:n,children:r.jsx(ze,{children:r.jsx(zI,{filter:e,formFieldProps:t})})}))),EI=({disabled:e})=>{const{searchButtonProps:t}=_u(),{children:n="Search",type:s,...i}=t;return r.jsx(o.Button,{color:"blue",size:"sm",type:"submit",...i,disabled:e||i.disabled,children:n})};function AI(e){const t=Y();g.useEffect(()=>{var n,s;(s=(n=t.filters).updatePreviewValues)==null||s.call(n,e)},[e])}const PI=({opened:e,toggle:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Group,{position:"right",ml:-4,mt:-4,mb:e?4:0,children:r.jsx(o.Button,{size:"xs",compact:!0,variant:"subtle",color:e?"gray":"blue",leftIcon:e?r.jsx(M.IconChevronsUp,{size:14}):r.jsx(M.IconChevronsDown,{size:14}),onClick:t,children:n(e?"filter.hide_filters":"filter.show_filters")})})},Oh=D.observer(function({view:t}){const[n,{toggle:s}]=he.useDisclosure(!0),i=_e(),{control:a,handleSubmit:l,reset:c}=b.useForm({defaultValues:i.filters.values,reValidateMode:"onBlur"}),u=b.useWatch({control:a});g.useEffect(()=>{c(i.filters.values)},[i.filters.values,c]),AI(u);const d=i.filters.visibleInView(t.id),p=g.useMemo(()=>d.every(y=>y.should_auto_submit),[d]),h=g.useMemo(()=>d.filter(y=>v.get(y,"config.required",!1)),[d]),f=g.useMemo(()=>h.length===0?!1:h.some(y=>!y.requiredAndPass(u[y.key])),[u,h]);if(d.length===0)return null;const m=(y,j)=>(k,S)=>{j(k),(y.should_auto_submit||S)&&i.filters.setValueByKey(y.key,k)};return r.jsxs("form",{onSubmit:l(i.filters.setValues),children:[r.jsx(PI,{opened:n,toggle:s}),r.jsx(o.Collapse,{in:n,children:r.jsxs(o.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:p?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[r.jsx(o.Group,{align:"flex-start",children:d.map(y=>r.jsx(b.Controller,{name:y.key,control:a,render:({field:j})=>r.jsx(II,{filter:y,value:j.value,onChange:m(y,j.onChange)})},y.id))}),!p&&r.jsx(o.Group,{sx:{alignSelf:"flex-end"},children:r.jsx(EI,{disabled:f})})]})})]})}),OI={viewPanelInFullScreen:v.noop,inFullScreen:!1},ii=g.createContext(OI),Ko=x.types.model("MockContextMeta",{current:x.types.optional(x.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get keySet(){return new Set(this.keys)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},defaults(t){e.current={...t,...e.current}},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function Xo(e){return{current:e}}const LI=x.types.model("PanelStyleBorderMeta",{enabled:x.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),Lh=x.types.model("PanelStyleMeta",{border:LI}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),Bh=x.types.model("PanelTitleMeta",{show:x.types.optional(x.types.boolean,!0)}).views(e=>({get json(){const{show:t}=e;return{show:t}}})).actions(e=>({setShow(t){e.show=t}})),qh=x.types.model("VariableMeta",{name:x.types.string,size:x.types.string,weight:x.types.string,color:x.types.union(x.types.model({type:x.types.literal("static"),staticColor:x.types.string}),x.types.model({type:x.types.literal("continuous"),valueRange:x.types.array(x.types.number),colorRange:x.types.array(x.types.string)}),x.types.model({type:x.types.literal("piecewise")})),formatter:x.types.model({output:x.types.enumeration("Output",["number","percent"]),average:x.types.optional(x.types.boolean,!1),mantissa:x.types.number,trimMantissa:x.types.optional(x.types.boolean,!1),absolute:x.types.optional(x.types.boolean,!1)}),data_field:x.types.string,aggregation:x.types.union(x.types.model({type:x.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:x.types.frozen(),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("quantile"),config:x.types.model({p:x.types.number}),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("pick_record"),config:x.types.model({method:x.types.enumeration("Pick Record Method",["first","last"])}),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("custom"),config:x.types.model({func:x.types.string}),fallback:x.types.optional(x.types.string,"0")}))}).views(e=>({get json(){const{name:t,size:n,weight:s,color:i,formatter:a,data_field:l,aggregation:c}=e;return v.cloneDeep({name:t,size:n,color:i,weight:s,formatter:a,data_field:l,aggregation:c})}})),Vh=x.types.model("PanelVizMeta",{type:x.types.string,conf:x.types.frozen()}).views(e=>({get json(){return{conf:e.conf,type:e.type}}})).actions(e=>({setType(t){e.type=t},setConf(t){e.conf=t}})),Nh=x.types.model({id:x.types.string,name:x.types.optional(x.types.string,""),title:Bh,description:x.types.string,queryIDs:x.types.array(x.types.string),viz:Vh,style:Lh,variables:x.types.optional(x.types.array(qh),[])}).views(e=>({get json(){const{id:t,name:n,title:s,description:i,queryIDs:a}=e;return{id:t,viz:e.viz.json,name:n,style:e.style.json,title:s.json,queryIDs:[...a],variables:e.variables.map(l=>l.json),description:i}},get queryIDSet(){return new Set(e.queryIDs)}})).actions(e=>({setID(t){e.id=t},setName(t){e.name=t},setDescription(t){e.description=t},addQueryID(t){e.queryIDSet.has(t)||e.queryIDs.push(t)},removeQueryID(t){if(!e.queryIDSet.has(t))return;const n=new Set(e.queryIDSet);n.delete(t),e.queryIDs=x.cast(Array.from(n))},setQueryIDs(t){e.queryIDs=x.cast(t)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)}}));var ye=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e.Transform="transform",e))(ye||{});const $h=x.types.model("QueryMeta",{id:x.types.string,name:x.types.string,type:x.types.enumeration("DataSourceType",[ye.Postgresql,ye.MySQL,ye.HTTP,ye.Transform]),key:x.types.string,sql:x.types.string,pre_process:x.types.optional(x.types.string,""),post_process:x.types.optional(x.types.string,""),run_by:x.types.optional(x.types.array(x.types.string),[]),react_to:x.types.optional(x.types.array(x.types.string),[]),dep_query_ids:x.types.optional(x.types.array(x.types.string),[])}).views(e=>({get valid(){return e.id&&e.type&&e.key&&e.name?e.type===ye.HTTP?!!e.pre_process:!!e.sql:!1},get json(){const{id:t,name:n,type:s,key:i,sql:a,run_by:l,react_to:c,pre_process:u,post_process:d,dep_query_ids:p}=e;return $n({id:t,key:i,sql:a,name:n,type:s,run_by:l,react_to:c,pre_process:u,post_process:d,dep_query_ids:p})}})).actions(e=>({setName(t){e.name=t},setKey(t){e.key=t},setType(t){e.type=t},setSQL(t){e.sql=t},setRunBy(t){e.run_by.length=0,e.run_by.push(...t)},setReactTo(t){e.react_to.length=0,e.react_to.push(...t)},setPreProcess(t){e.pre_process=t},setPostProcess(t){e.post_process=t},setDependantQueryIDs(t){e.dep_query_ids.length=0,e.dep_query_ids.push(...t)}})),Fh=x.types.model("LayoutItemMeta",{id:x.types.identifier,panelID:x.types.string,x:x.types.number,y:x.types.maybeNull(x.types.number),w:x.types.number,h:x.types.number,moved:x.types.optional(x.types.boolean,!1),static:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{id:t,panelID:n,x:s,y:i,w:a,h:l,moved:c}=e;return{h:l,w:a,x:s,y:i===null?0:i,id:t,moved:c,static:e.static,panelID:n}},get contentModel(){return x.getRoot(e).content},get panel(){const{panelID:t}=e;return this.contentModel.panels.findByID(t)},get layoutProperies(){const{id:t,x:n,y:s,w:i,h:a,moved:l}=e;return{id:t,i:t,x:n,y:s===null?1/0:s,w:i,h:a,moved:l,static:e.static}}})).actions(e=>({set(t){const{isDraggable:n,x:s,y:i,w:a,h:l,moved:c}=t;e.x=s,e.y=i,e.w=a,e.h=l,e.moved=!!c,e.static=!!t.static},setWidth(t){e.w=t},setHeight(t){e.h=t}})),Gh=x.types.model("LayoutSetMeta",{id:x.types.identifier,name:x.types.string,breakpoint:x.types.number,list:x.types.optional(x.types.array(Fh),[])}).views(e=>({get json(){const{id:t,name:n,breakpoint:s,list:i}=e;return{id:t,name:n,breakpoint:s,list:i.map(a=>$n(a.json))}},jsonByPanelIDSet(t){const{id:n,name:s,breakpoint:i,list:a}=e;return{id:n,name:s,breakpoint:i,list:a.filter(l=>t.has(l.panelID)).map(l=>$n(l.json))}},findByID(t){return e.list.find(n=>n.id===t)},findByPanelID(t){return e.list.find(n=>n.panelID===t)}})).actions(e=>({setName(t){e.name=t},setBreakpoint(t){e.breakpoint=t},addLayout(t){e.list.push(t)},addNewLayout(t){e.list.push({id:Ut.v4(),panelID:t,x:0,y:1/0,w:18,h:300,static:!1,moved:!1})},removeByPanelID(t){const n=e.list.findIndex(s=>s.panelID===t);n>=0&&e.list.splice(n,1)},updateLayoutItem(t){const n=e.list.find(s=>s.id===t.i);if(!n){console.error("Trying to update a layout that doesn't exist"),console.log({strangeLayoutItem:t});return}n.set(t)}})),Wh=x.types.model("SQLSnippetMeta",{key:x.types.string,value:x.types.string}).views(e=>({get json(){const{key:t,value:n}=e;return{key:t,value:n}}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.value=t}}));var ce=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(ce||{});const Jo=x.types.model("FilterCheckboxConfigMeta",{_name:x.types.literal("checkbox"),description:x.types.optional(x.types.string,""),default_value:x.types.boolean}).views(e=>({get json(){const{_name:t,description:n,default_value:s}=e;return{_name:t,description:n,default_value:s}},get isDescriptionEmpty(){const{description:t}=e;return t===""||t==="<p></p>"}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDescription(t){e.description=t}})),Rh=()=>Jo.create({_name:"checkbox",description:"",default_value:!1});function Qh(e,t){return e.map(n=>{try{return n?P.tz(n,"UTC").format(t):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}const BI=x.types.model("FilterDateRangeConfigMeta",{_name:x.types.literal("date-range"),required:x.types.boolean,inputFormat:x.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:x.types.optional(x.types.array(x.types.union(x.types.string,x.types.null)),[null,null]),default_shortcut:x.types.optional(x.types.string,""),clearable:x.types.boolean,max_days:x.types.optional(x.types.number,0),allowSingleDateInRange:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{_name:t,max_days:n,required:s,clearable:i,inputFormat:a,default_value:l,default_shortcut:c,allowSingleDateInRange:u}=e;return{_name:t,max_days:n,required:s,clearable:i,inputFormat:a,default_value:Qh(l,a),default_shortcut:c,allowSingleDateInRange:u}},truthy(t){return Array.isArray(t)&&t.length===2&&t.every(n=>!!n)}})).actions(e=>({setFilterValue(t){try{const n=x.getParent(e);x.getParent(n,2).setValueByKey(n.key,t)}catch(n){console.error(n)}}})).actions(e=>({setRequired(t){e.required=t},setClearable(t){e.clearable=t},setInputFormat(t){e.inputFormat=t},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t),e.setFilterValue(t)},setDefaultShortcut(t){if(e.default_shortcut=t,!t)return;const n=Eh(e.default_shortcut);if(console.log(n),n){const s=n.map(i=>P(i).format(e.inputFormat));e.setFilterValue(s)}},setMaxDays(t){e.max_days=t,t>0&&(e.clearable=!0)},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),Zo=x.types.snapshotProcessor(BI,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>n===null?null:P.tz(n,"UTC").toISOString())}},postProcessor(e){const{default_value:t,...n}=e;return{...n,default_value:Qh(t,n.inputFormat)}}}),Uh=()=>Zo.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),qI=x.types.model({label:x.types.string,value:x.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),Ho=x.types.model("FilterConfigModel_BaseSelect",{static_options:x.types.optional(x.types.array(qI),[]),options_query_id:x.types.optional(x.types.string,""),default_selection_count:x.types.optional(x.types.number,0),required:x.types.optional(x.types.boolean,!1)}).views(e=>({get contentModel(){return x.getRoot(e).content},get filter(){return x.getParent(e)},get usingQuery(){return!!e.options_query_id}})).views(e=>({get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:n}=e.contentModel.getDataStuffByID(e.options_query_id);return n==="error"?[]:Array.isArray(t)?t.filter(s=>"label"in s&&"value"in s):[]}})).actions(e=>({setRequired(t){e.required=t},addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},setDefaultSelectionCount(t){e.default_selection_count=t},setOptionsQueryID(t){e.options_query_id=t??""}})),el=x.types.compose("FilterMultiSelectConfigMeta",x.types.model({_name:x.types.literal("multi-select"),min_width:x.types.optional(x.types.string,""),default_value:x.types.optional(x.types.array(x.types.string),[])}),Ho).views(e=>({get json(){const{_name:t,default_value:n,required:s,min_width:i,static_options:a,options_query_id:l,default_selection_count:c}=e;return $n({_name:t,required:!!s,min_width:i,default_value:n,static_options:a,options_query_id:l,default_selection_count:c})},get default_selection(){return e.usingQuery?e.options.slice(0,e.default_selection_count).map(t=>t.value):e.filter.formattedDefaultValue},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=x.cast(t)},setMinWidth(t){e.min_width=t},setDefaultSelection(){const t=x.getRoot(e).content.filters,n=x.getParent(e).key,s=new Set(e.options.map(a=>a.value)),i=(t.values[n]??[]).filter(a=>s.has(a));i.length>0?t.setValueByKey(n,i):t.setValueByKey(n,e.default_selection)}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>X.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),Yh=()=>el.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),tl=x.types.compose("FilterConfigModel_Select",x.types.model({_name:x.types.literal("select"),default_value:x.types.string,width:x.types.optional(x.types.string,""),clearable:x.types.optional(x.types.boolean,!1)}),Ho).views(e=>({get json(){const{_name:t,clearable:n,default_value:s,required:i,width:a,static_options:l,options_query_id:c,default_selection_count:u}=e;return $n({_name:t,width:a,required:i,clearable:n,default_value:s,static_options:l,options_query_id:c,default_selection_count:u})},truthy(t){return!!t},getSelectOption(t){return e.options.find(n=>n.value===t)},get default_selection(){return e.usingQuery?e.default_selection_count>0&&e.options.length>0?e.options[0].value:"":e.filter.formattedDefaultValue}})).actions(e=>({setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t},setClearable(t){e.clearable=t},setDefaultSelection(){var a;const t=x.getRoot(e).content.filters,n=x.getParent(e).key,s=t.values[n],i=(a=e.options.find(l=>l.value===s))==null?void 0:a.value;i?t.setValueByKey(n,i):t.setValueByKey(n,e.default_selection)}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>X.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!1,delay:0}))}})),Kh=()=>tl.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),nl=x.types.model("FilterTextInputConfigMeta",{_name:x.types.literal("text-input"),required:x.types.boolean,default_value:x.types.string}).views(e=>({get json(){const{_name:t,required:n,default_value:s}=e;return{_name:t,required:n,default_value:s}},truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),rl=()=>nl.create({_name:"text-input",required:!1,default_value:""});function VI(e){return Pg.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function NI(e){return e.map(t=>{const{label:n,description:s,...i}=t,a={...i,filterBasis:`${n}___${s??""}`,description:s,label:n};return s&&(a.label=g.createElement("div",{},[g.createElement(o.Text,{key:0,title:t.label},t.label),g.createElement(o.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description},t.description)])),a})}const sl=x.types.compose("FilterTreeSelectConfigMeta",x.types.model({_name:x.types.literal("tree-select"),min_width:x.types.optional(x.types.string,""),default_value:x.types.optional(x.types.array(x.types.string),[]),treeCheckStrictly:x.types.optional(x.types.boolean,!1)}),Ho).views(e=>({get json(){const{_name:t,default_value:n,required:s,min_width:i,static_options:a,options_query_id:l,default_selection_count:c,treeCheckStrictly:u}=e;return{_name:t,required:!!s,min_width:i,default_value:n,static_options:a,options_query_id:l,treeCheckStrictly:u,default_selection_count:c}},get plainData(){const{data:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeData(){const t=this.plainData,n=NI(t);return VI(n)},get errorMessage(){const{error:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeDataLoading(){const{state:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t==="loading"},get defaultSelection(){const t=e.filter.formattedDefaultValue;if(Array.isArray(t)&&t.length>0)return t;const{default_selection_count:n}=e;return n?this.treeData.slice(0,n).map(i=>i.value):[]},valueObjects(t){const n=new Set(t);return this.plainData.filter(s=>n.has(s.value))},initialSelection(t){return t?this.valueObjects(t):this.valueObjects(this.defaultSelection)},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=x.cast(t)},setMinWidth(t){e.min_width=t},setTreeCheckStrictly(t){e.treeCheckStrictly=t},applyDefaultSelection(){const t=x.getParent(e,1).key,n=e.contentModel.filters,s=n.values[t],i=new Set(e.plainData.map(l=>l.value)),a=(s??[]).filter(l=>i.has(l));a.length>0?n.setValueByKey(t,a):n.setValueByKey(t,e.defaultSelection)},afterCreate(){x.addDisposer(e,X.reaction(()=>JSON.stringify(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!0,delay:0}))}})),Xh=()=>sl.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),il=x.types.model("FilterMeta",{id:x.types.identifier,key:x.types.string,label:x.types.string,order:x.types.number,visibleInViewsIDs:x.types.array(x.types.string),auto_submit:x.types.optional(x.types.boolean,!1),default_value_func:x.types.optional(x.types.string,""),type:x.types.enumeration("DashboardFilterType",[ce.Select,ce.MultiSelect,ce.TreeSelect,ce.TextInput,ce.Checkbox,ce.DateRange]),config:x.types.union(tl,el,sl,nl,Jo,Zo)}).views(e=>({get contentModel(){return x.getRoot(e).content},get filters(){return this.contentModel.filters},get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==ce.TreeSelect},get usingDefaultValueFunc(){return!!e.default_value_func},get formattedDefaultValue(){return this.filters.formattedDefaultValues[e.key]},get auto_submit_supported(){return[ce.Select,ce.Checkbox,ce.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:n,label:s,order:i,visibleInViewsIDs:a,default_value_func:l,auto_submit:c,type:u,config:d}=e;return{id:t,key:n,type:u,label:s,order:i,config:d.json,auto_submit:c,visibleInViewsIDs:X.toJS(a),default_value_func:l}},get visibleInViewsIDSet(){return new Set(e.visibleInViewsIDs)},get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return v.get(e.config,"required",!1)?v.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setLabel(t){e.label=t},setOrder(t){e.order=t},setType(t){switch(t){case ce.Select:e.config=Kh();break;case ce.MultiSelect:e.config=Yh();break;case ce.TreeSelect:e.config=Xh();break;case ce.TextInput:e.config=rl();break;case ce.Checkbox:e.config=Rh();break;case ce.DateRange:e.config=Uh();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t},setDefaultValueFunc(t){e.default_value_func=t}}));var q=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(q||{});const al=x.types.model("ViewDivisionConfig",{_name:x.types.literal(q.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})),Jh=()=>al.create({_name:q.Division}),$I=x.types.model("CustomModalTitleModel",{enabled:x.types.optional(x.types.boolean,!1),func_content:x.types.optional(x.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:n}=e;return{enabled:t,func_content:n}},get value(){const{enabled:t,func_content:n}=e,s=x.getParent(e,2),i=x.getRoot(e);if(!t)return s.name;try{const a={filters:i.content.filters.values,context:i.context.current};return new Function(`return ${n}`)()(a)}catch(a){return console.error(a),s.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:n}){e.enabled=t,e.func_content=n}})),ai={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
453
|
-
`)},ol=x.types.model("ViewModalConfig",{_name:x.types.literal(q.Modal),width:x.types.string,height:x.types.string,custom_modal_title:x.types.optional($I,ai)}).views(e=>({get json(){const{_name:t,width:n,height:s,custom_modal_title:i}=e;return{_name:t,width:n,height:s,custom_modal_title:i.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),Zh=()=>ol.create({_name:q.Modal,width:"90vw",height:"90vh"}),FI=x.types.model("ViewTabsTabModel",{id:x.types.identifier,name:x.types.string,view_id:x.types.string,color:x.types.optional(x.types.string,""),order:x.types.optional(x.types.number,0)}).views(e=>({get json(){const{id:t,name:n,view_id:s,color:i,order:a}=e;return{id:t,name:n,color:i,order:a,view_id:s}}})).actions(e=>({setName(t){e.name=t},setViewID(t){e.view_id=t},setColor(t){e.color=t},setOrder(t){e.order=t}})),ll=x.types.model("ViewTabsConfig",{_name:x.types.literal(q.Modal),tabs:x.types.optional(x.types.array(FI),[]),variant:x.types.optional(x.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:x.types.optional(x.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:n,orientation:s,tabs:i,grow:a}=e;return{grow:a,tabs:i.map(l=>l.json),_name:t,variant:n,orientation:s}},get tabsInOrder(){return v.sortBy(e.tabs,"order")}})).actions(e=>({setVariant(t){e.variant=t},setOrientation(t){e.orientation=t},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=x.cast(t)},addTab(){const t=he.randomId(),n={id:t,name:t,view_id:""};e.tabs.push(n)},removeTab(t){e.tabs.splice(t,1)}})),Hh=()=>ll.create({_name:q.Modal,tabs:[]}),ef=x.types.model({id:x.types.identifier,name:x.types.string,type:x.types.enumeration("EViewComponentType",[q.Division,q.Modal,q.Tabs]),config:x.types.union(al,ol,ll),panelIDs:x.types.optional(x.types.array(x.types.string),[])}).views(e=>({get json(){const{id:t,name:n,type:s,config:i}=e;return{id:t,name:n,type:s,config:i.json,panelIDs:e.panelIDs.map(a=>a)}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case q.Division:e.config=Jh();break;case q.Modal:e.config=Zh();break;case q.Tabs:e.config=Hh();break}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},appendPanelIDs(t){e.panelIDs.push(...t)},removePanelID(t){const n=e.panelIDs.filter(s=>s!==t);e.panelIDs.length=0,e.panelIDs.push(...n)}})),en="11.10.0",GI={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:q.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:en,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},cl=x.types.model("DataSourceMetaModel",{id:x.types.string,type:x.types.enumeration("DataSourceType",[ye.HTTP,ye.MySQL,ye.Postgresql]),key:x.types.string,config:x.types.frozen()}),tf=x.types.model("DataSourcesMetaModel",{list:x.types.optional(x.types.array(cl),[])}).views(e=>({find({type:t,key:n}){return e.list.find(s=>s.key===n&&s.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),nf=x.types.model({id:x.types.string,content:x.types.string,create_time:x.types.string,update_time:x.types.string,is_preset:x.types.boolean}),ul=x.types.model("GlobalSQLSnippetsMeta",{list:x.types.optional(x.types.array(nf),[])}).views(e=>({find(t){return e.list.find(n=>n.id===t)},get options(){return e.list.map(t=>({value:t.id,label:t.id}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),oi=x.types.model("ContextMeta",{current:x.types.optional(x.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function dl(e){return oi.create({current:e})}const pl=x.types.compose("ViewRenderModel",ef,x.types.model({tab:x.types.optional(x.types.string,"")})).views(e=>({get tabs(){return e.config.tabs},get tabInfo(){const t=this.tabs.find(n=>n.id===e.tab);return t?{id:t.id,name:t.name}:null},get tabView(){return e.type!==q.Tabs?null:this.tabs.find(t=>t.id===e.tab)},get tabViewID(){return this.tabView?this.tabView.view_id??"":""},get contentModel(){return x.getParent(e,3)},get panels(){if(e.type!==q.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs);const t=this.tabViewID,n=this.contentModel.views.findByID(t);return(n==null?void 0:n.panels)??[]},get renderViewIDs(){const t=[e.id];return e.type===q.Tabs&&t.push(this.tabViewID),t},async downloadScreenshot(t){const n=t.offsetWidth*2+10,s=t.offsetHeight*2+10,i=new fc,a=new Date().getTime(),l=await hc.toBlob(t,{bgcolor:"white",width:n,height:s,style:{transformOrigin:"0 0",transform:"scale(2)"}});i.file(`${e.name}_${a}.png`,l),i.file(`dashboard_state_${a}.json`,JSON.stringify(this.contentModel.dashboardState,null,4)),i.generateAsync({type:"blob"}).then(c=>{ts.saveAs(c,`${e.name}_${a}.zip`)}).catch(c=>{console.error(c),sn.notifications.show({color:"red",title:"Failed to download screenshot with dashboard state",message:c.message})})}})).actions(e=>({setTab(t){e.tab=t??""},setTabByTabInfo(t){e.tab=t.id??""}})),hl=x.types.model("ViewsRenderModel",{current:x.types.optional(x.types.array(pl),[]),visibleViewIDs:x.types.array(x.types.string)}).views(e=>({get json(){return e.current.map(t=>$n(t.json))},get idMap(){const t=new Map;return e.current.forEach(n=>{t.set(n.id,n)}),t},findByID(t){return e.current.find(n=>n.id===t)},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:n})=>n===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:n})=>t.has(n))},get firstVisibleTabsView(){return this.visibleViews.find(t=>t.type===q.Tabs)},get firstVisibleTabsViewActiveTab(){const t=this.firstVisibleTabsView;return t?t.tabInfo:null}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(s=>s)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const n=e.visibleViewIDs.findIndex(s=>s===t);n!==-1&&e.visibleViewIDs.splice(n,1)},setFirstVisibleTabsViewActiveTab(t){if(!t)return;const n=e.firstVisibleTabsView;n==null||n.setTabByTabInfo(t)}}));function rf(e,t){const n=e.length>0?[e[0].id]:[],s=e.map(i=>{const{_name:a=i.type}=i.config,l={...i,tab:"",config:{...i.config,_name:a},panelIDs:i.panelIDs};if(i.type===q.Tabs){const c=v.minBy(i.config.tabs,u=>u.order);l.tab=(c==null?void 0:c.id)??""}return l});return t&&(s[0].tab=t.id),{current:s,visibleViewIDs:n}}const WI=new Og.AsyncParser({withBOM:!0});async function sf(e){return!Array.isArray(e)||e.length===0?"":await WI.parse(e).promise()}async function RI(e,t){const n=await sf(t),s=new Blob([n],{type:"text/csv"});ts.saveAs(s,`${e}.csv`)}function af(e){const t=new fc,n=e.map(async({id:s,data:i})=>{const a=await sf(i);t.file(`${s}.csv`,a)});Promise.all(n).then(()=>{t.generateAsync({type:"blob"}).then(s=>{ts.saveAs(s,"dashboard_data.zip")})}).catch(s=>{console.error(s),sn.notifications.show({color:"red",title:"Failed to download data",message:s.message})})}function ir(e,t){const n=new Blob([t],{type:"application/json"});ts.saveAs(n,`${e}.json`)}const fl=Nh.views(e=>({get contentModel(){return x.getRoot(e).content}})).views(e=>({get queries(){return e.contentModel.queries.findByIDSet(e.queryIDSet)},get firstQuery(){return this.queries.length>0?this.queries[0]:null},get firstQueryData(){return this.firstQuery?this.firstQuery.data:[]},queryByID(t){return this.queries.find(n=>n.id===t)},get data(){return this.queries.reduce((t,n)=>(t[n.id]=n.data,t),{})},get variableStrings(){return cu(e.variables,this.data)},get variableValueMap(){const t={},n=this.data;return e.variables.reduce((s,i)=>{const a=Vt(i,n);return s[i.name]=rt(i,a),s},t),t},get variableStyleMap(){const t=this.variableValueMap,n={};return e.variables.reduce((s,i)=>{const a=_y(i.color,t[i.name]);return s[i.name]={color:a,"font-size":i.size,"font-weight":i.weight,variable:i},s},n),n},get dataLoading(){return this.queries.some(t=>t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(a=>!a.runByConditionsMet);if(t.length===0)return"";const n=new Set,s=new Set;t.forEach(a=>{const l=a.conditionNames;l.context.forEach(c=>n.add(c)),l.filters.forEach(c=>s.add(c))});const i=[];return n.size>0&&(console.log(n),i.push(`context: ${Array.from(n).join(", ")}`)),s.size>0&&i.push(`filter${s.size>1?"s":""}: ${Array.from(s).join(", ")}`),i.length===2&&i.splice(1,0,"and"),i.unshift("Waiting for"),i.join(" ")},get queryErrors(){return this.queries.map(t=>t.error).filter(t=>!!t)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading}})).actions(e=>({refreshData(){e.queries.forEach(t=>t.fetchData(!0))},downloadData(){e.contentModel.queries.downloadDataByQueryIDs(e.queryIDs)},getSchema(){const t=e.json;return t.viz.conf={...t.viz.conf,__INTERACTIONS:{},__OPERATIONS:{},__TRIGGERS:{}},{panel:t,queries:e.queries.map(n=>n.json),layouts:e.contentModel.layouts.jsonByPanelIDSet(new Set([e.id]))}},downloadSchema(){const{panel:t,queries:n,layouts:s}=this.getSchema(),a=JSON.stringify({panels:[t],definition:{queries:n},layouts:s,version:en},null,2),l=e.name;ir(l,a)}}));function of(e){return{id:e,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:Oo.name,conf:Oo.createConfig()},style:{border:{enabled:!0}}}}const gl=x.types.model("PanelsRenderModel",{list:x.types.optional(x.types.array(fl),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(n=>n.id===t)},get idMap(){const t=new Map;return e.list.forEach(n=>{t.set(n.id,n)}),t}})).views(e=>({panelsByIDs(t){const n=[];return t.forEach(s=>{const i=e.idMap.get(s);i?n.push(i):console.warn(`Panel is not found, id:${s}`)}),n}}));function lf(e){const t=e.config,n=t.default_value;if(n===void 0)return n;if(t._name==="date-range")try{if(t.default_shortcut){const i=Eh(t.default_shortcut);if(i)return i.map(a=>P(a).format(t.inputFormat))}const[...s]=n;return s.map(i=>i===null?i:P.tz(i,"UTC").format(t.inputFormat)??i)}catch(s){return console.error(s),n}return n}function QI(e,t){const n=e.default_value_func;try{return new Function(`return ${n}`)()(e,vt,t)}catch(s){return console.error(s),lf(e)}}function cf(e,t){var n;return(n=e.default_value_func)!=null&&n.trim()?QI(e,t):lf(e)}function uf(e,t){return e.reduce((n,s)=>(n[s.key]=cf(s,t),n),{})}const ml=x.types.model("FiltersRenderModel",{current:x.types.optional(x.types.array(il),[]),values:x.types.optional(x.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get valuesString(){return JSON.stringify(e.values)},get contentModel(){return x.getRoot(e).content},get context(){return this.contentModel.payloadForSQL.context},get initialValuesDep(){return JSON.stringify({filters:e.current.map(({default_value_func:t,config:n})=>({default_value_func:t,config:n})),context:this.contentModel.payloadForSQL.context})},get formattedDefaultValues(){return uf(this.json,this.contentModel.context)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get inOrder(){return v.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return v.sortBy(e.current.filter(n=>n.visibleInViewsIDSet.has(t)),"order")},get firstFilterValueKey(){return Object.keys(e.values)[0]??""},get keySet(){return new Set(e.current.map(t=>t.key))},get keyLabelMap(){return e.current.reduce((t,n)=>(t[n.key]=n.label,t),{})},getSelectOption(t){const n=this.findByID(t);if(!n||!("getSelectOption"in n.config))return null;const s=e.values[n.key];return n.config.getSelectOption(s)}})).actions(e=>({setValues(t){e.values=t},patchValues(t){e.values=v.defaults({},t,e.values)},setValueByKey(t,n){e.values={...e.values,[t]:n}},applyValuesPatch(t){e.values={...e.values,...t}},getValueByKey(t){return e.values[t]},getSchema(t,n){return{filters:e.findByIDSet(new Set(t)).map(a=>({...a.json,visibleInViewsIDs:n?a.json.visibleInViewsIDs:[]})),version:en}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t,!1),null,2);ir("Filters",n)}}));function xl(e,t,n,s){const i=v.defaults({},s,uf(e,{...n,...t}));return{current:e,values:i}}const df=$h.views(e=>({get rootModel(){return x.getRoot(e)},get contentModel(){return this.rootModel.content},get conditionOptions(){if(!x.isAlive(e))return[];const{context:t}=this.contentModel.payloadForSQL,n=Object.keys(t).map(l=>({group:"Context",label:l,value:`context.${l}`,description:void 0})),s=this.contentModel.filters.keyLabelOptions.map(l=>({group:"Filters",label:l.label,value:`filters.${l.value}`,description:l.value})),i=[...n,...s],a=new Set(i.map(l=>l.value));return e.run_by.forEach(l=>{a.has(l)||i.push({group:"Invalid",label:l,value:l})}),i},get unmetRunByConditions(){if(!x.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const n=this.contentModel.payloadForSQL;return t.filter(s=>{const i=v.get(n,s);return Array.isArray(i)?i.length===0:typeof i=="number"?Number.isNaN(i):!i})}})).views(e=>({get payload(){return e.contentModel.payloadForSQL},get formattedSQL(){return Ci(e.sql,this.payload)},get httpConfigString(){const{context:t,filters:n}=this.payload,{name:s,pre_process:i}=e.json,a=Iy(i,t,n);return console.groupCollapsed(`Request config for: ${s}`),console.log(a),console.groupEnd(),JSON.stringify(a)},get typedAsSQL(){return[ye.Postgresql,ye.MySQL].includes(e.type)},get typedAsHTTP(){return[ye.HTTP].includes(e.type)},get isTransform(){return e.type===ye.Transform},get reQueryKey(){const{react_to:t=[]}=e;if(t.length===0)return"";const n=e.contentModel.payloadForSQL,s=[...t].reduce((i,a)=>(i[a]=v.get(n,a),i),{});return JSON.stringify(s)},get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=e.contentModel.filters,n=e.unmetRunByConditions.filter(i=>i.startsWith("context.")).map(i=>i.replace("context.","")),s=e.unmetRunByConditions.filter(i=>i.startsWith("filters.")).map(i=>v.get({filters:t},i,i.replace("filters.",""))).filter(i=>!!i);return{context:n,filters:s}},get queries(){return x.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)},get dependencies(){if(!this.typedAsSQL)return[];const t=v.uniq(e.sql.match(vs.sqlSnippet)),n=v.uniq(e.sql.match(vs.filter)),s=v.uniq(e.sql.match(vs.context)),i=[];return t.forEach(a=>{i.push({type:"sql_snippet",key:a,valid:e.contentModel.sqlSnippets.keySet.has(a)})}),n.forEach(a=>{i.push({type:"filter",key:a,valid:e.contentModel.filters.keySet.has(a)})}),s.forEach(a=>{i.push({type:"context",key:a,valid:e.contentModel.mock_context.keySet.has(a)})}),i}})),yl=x.types.compose("QueryRenderModel",df,x.types.model({state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),data:x.types.optional(x.types.frozen([]),[]),error:x.types.frozen()})).views(e=>({get datasource(){const{key:t,type:n}=e;return e.rootModel.datasources.find({type:n,key:t})},get additionalQueryInfo(){return e.contentModel.getAdditionalQueryInfo(e.id)},get depQueryModels(){return e.contentModel.queries.findByIDSet(new Set(e.dep_query_ids))},get depQueryModelStates(){return this.depQueryModels.map(t=>t.state)},get depQueryModelStatesString(){return this.depQueryModelStates.toString()}})).views(e=>({get stateMessage(){if(e.state!=="idle")return"";if(!e.runByConditionsMet){const{context:t,filters:n}=e.conditionNames;if(t.length===0&&n.length===0)return"Waiting";const s=[];return t.length>0&&s.push(`context: ${t.join(", ")}`),n.length>0&&s.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),s.length===2&&s.splice(1,0,"and"),s.unshift("Waiting for"),s.join(" ")}return e.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:x.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const n=e.payload;e.data=yield*x.toGenerator(Vy({payload:n,name:e.name,query:e.json,additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(!At.isCancel(n)){e.data=[];const s=v.get(n,"message","unkown error");e.error=v.get(n,"response.data.detail.message",s),e.state="error"}}}}),runHTTP:x.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{type:n,key:s,post_process:i}=e.json;let a=JSON.parse(e.httpConfigString);a=Ey(e.datasource,a);const l=yield*x.toGenerator(Ny({type:n,key:s,configString:JSON.stringify(a),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=Ay(e.datasource,l),u=Py(i,c,e.contentModel.dashboardState);e.data=u,e.state="idle",e.error=null}catch(n){if(console.error(n),!At.isCancel(n)){e.data=[];const s=v.get(n,"message","unkown error");e.error=v.get(n,"response.data.detail.message",s),e.state="error"}}}}),runTransformation(){e.state="loading";try{const n=e.contentModel.queries.findByIDSet(new Set(e.dep_query_ids)).map(l=>({id:l.id,name:l.name,data:v.cloneDeep(l.data)})),s=e.contentModel.dashboardState,i=e.pre_process,a=new Function(`return ${i}`)()(n,s,vt);e.data=a,e.state="idle",e.error=null}catch(t){e.data=[],e.error=t.message,e.state="error"}}})).actions(e=>({fetchData:t=>{if(!e.inUse&&!t){console.debug(`🟡 Skipping query[${e.name}]`);return}return console.debug(`🔵 Running query[${e.name}]`),e.isTransform?e.runTransformation():e.typedAsHTTP?e.runHTTP():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>{var n;return e.isTransform?[e.inUse,e.id,e.key,e.dep_query_ids.toString(),e.pre_process,e.depQueryModelStatesString].join("--"):e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(n=e.datasource)==null?void 0:n.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},()=>e.fetchData(!1),{fireImmediately:!0,delay:0}))}})),bl=x.types.model("QueriesRenderModel",{current:x.types.optional(x.types.array(yl),[])}).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get contentModel(){return x.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:n,queries:s}=this.contentModel,i=[];t.visibleViews.forEach(c=>{c.panels.forEach(u=>{i.push(...u.queryIDs)})});const a=v.uniq(t.visibleViews.map(c=>c.renderViewIDs).flat());n.current.forEach(c=>{const u=v.get(c,"config.options_query_id");if(!u)return;a.some(p=>c.visibleInViewsIDSet.has(p))&&i.push(u)}),s.findByIDSet(new Set(i)).forEach(c=>{!c.isTransform||c.dep_query_ids.length===0||i.push(...c.dep_query_ids)});const l=new Set(i);return console.debug("QueryIDs:",l),l},isQueryInUse(t){return this.visibleQueryIDSet.has(t)}})).actions(e=>({downloadAllData(){const t=e.current.map(({name:n,data:s})=>({id:n,data:s}));af(t)},downloadDataByQueryIDs(t){const n=new Set(t),s=e.current.filter(i=>n.has(i.id)).map(({name:i,data:a})=>({id:i,data:a}));af(s)},downloadDataByQueryID(t){const n=e.findByID(t);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:s,data:i}=n;RI(s,i)},refetchDataByQueryID(t){const n=e.findByID(t);if(!n){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return n.fetchData(!0)},getSchema(t){return{definition:{queries:e.findByIDSet(new Set(t)).map(i=>i.json)},version:en}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t),null,2);ir("Queries",n)}}));function pf(e){return{current:e}}function hf({min:e,max:t}){const n=`${e}px`,s=Number.isFinite(t)?`${t}px`:"∞";return`[${n}, ${s})`}const vl=x.types.model("LayoutsRenderModel",{list:x.types.array(Gh),currentBreakpoint:x.types.string}).views(e=>({get json(){return e.list.map(t=>t.json)},jsonByPanelIDSet(t){return e.list.map(n=>n.jsonByPanelIDSet(t))},get root(){return x.getRoot(e)},get contentModel(){return this.root.content},get basisLayoutSet(){return e.list.find(t=>t.id==="basis")},get currentLayoutSet(){return e.list.find(t=>t.id===e.currentBreakpoint)},get currentLayoutRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentRangeText(){const t=this.currentLayoutRange;return hf(t)},get cols(){const t={};return e.list.forEach(n=>{t[n.id]=36}),t},get breakpoints(){const t={};return e.list.forEach(n=>{t[n.id]=n.breakpoint}),t},get breakpointNameRecord(){const t={};return e.list.forEach(n=>{t[n.name]=n.breakpoint}),t},get breakpointRanges(){const t=e.list.map(n=>({id:n.id,name:n.name,min:n.breakpoint,max:1/0,text:""}));return t.sort((n,s)=>n.min-s.min).forEach((n,s)=>{s!==t.length-1&&(n.max=t[s+1].min)}),t.forEach(n=>{n.text=hf(n)}),t},get breakpointsInfo(){return e.list.map(t=>({id:t.id,name:t.name,breakpoint:t.breakpoint})).sort((t,n)=>t.breakpoint-n.breakpoint)},get currentBreakpointRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentLayoutPreviewWidth(){const t=this.currentBreakpointRange;if(t)return t.max===1/0?t.min===0?void 0:t.min+1:t.max},items(t){const n=new Set(t);return this.currentLayoutSet.list.filter(i=>n.has(i.panelID))},gridLayouts(t){const n=new Set(t),s={};return e.list.forEach(i=>{s[i.id]=i.list.filter(a=>n.has(a.panelID)).map(a=>a.layoutProperies)}),s},findItemByPanelID(t){return this.currentLayoutSet.findByPanelID(t)}})).actions(e=>({setCurrentBreakpoint(t){console.log("🔴 onBreakpointChange:",t),e.currentBreakpoint=t},afterCreate(){x.addDisposer(e,X.reaction(()=>e.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),ff=Wh.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!x.getParent(e,2).findByKey(t)}})),_l=x.types.model("SQLSnippetsRenderModel",{current:x.types.optional(x.types.array(ff),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,n)=>(t[n.key]=n.value,t),{})},get keySet(){return new Set(e.current.map(t=>t.key))},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(n=>n.key===t)},findByKeySet(t){return e.current.filter(n=>t.has(n.key))}})).actions(e=>({getSchema(t){return{definition:{sqlSnippets:e.findByKeySet(new Set(t)).map(i=>i.json)},version:en}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t),null,2);ir("SQL Snippets",n)}}));function gf(e){return{current:e}}function Rr(e,t,n,s){return e.reduce((i,a)=>{try{i[a[t]]=wi(a[n],s)}catch(l){i[a[t]]=l.message}return i},{})}class mf{constructor(t){B(this,"origin");B(this,"copy");this.origin=t,this.copy=x.clone(t),X.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!v.isEqual(x.getSnapshot(this.origin),x.getSnapshot(this.copy))}commit(){x.applySnapshot(this.origin,x.getSnapshot(this.copy))}reset(){x.applySnapshot(this.copy,x.getSnapshot(this.origin))}update(t){x.applySnapshot(this.copy,t)}}const xf=e=>new mf(e),UI=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),{panel:n}=Ge(),s=n.realQueryOptions,i=a=>{t.editor.open(["_QUERIES_",a])};return s.length===0?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{label:e(s.length>1?"query.labels":"query.label"),labelPosition:"center"}),s.map(a=>r.jsx(o.Menu.Item,{onClick:()=>i(a.value),icon:r.jsx(M.IconDatabase,{size:14}),children:a.label},a.value))]})}),YI=D.observer(({view:e,title:t})=>{const{t:n}=_.useTranslation(),s=Z(),i=Y(),a=lt.useModals(),{panel:l,downloadPanelScreenshot:c}=Ge(),{id:u}=l,{viewPanelInFullScreen:d,inFullScreen:p}=g.useContext(ii),h=()=>{i.duplicatePanelByID(u,e.id)},f=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u])},m=()=>a.openConfirmModal({title:`${n("panel.delete")}?`,labels:{confirm:n("common.actions.confirm"),cancel:n("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.removePanelByID(u,e.id),confirmProps:{color:"red"},zIndex:320}),y=g.useCallback(()=>{d(u)},[u,d]),j=!p&&e.type!==q.Modal;return r.jsx(r.Fragment,{children:r.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:r.jsxs(o.Menu,{withinPortal:!0,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{onClick:l.refreshData,icon:r.jsx(V.Refresh,{size:14}),children:n("common.actions.refresh")}),r.jsx(o.Menu.Item,{onClick:l.downloadData,icon:r.jsx(V.Download,{size:14}),children:n("common.actions.download_data")}),r.jsx(o.Menu.Item,{onClick:l.downloadSchema,icon:r.jsx(M.IconCode,{size:14}),children:n("common.actions.download_schema")}),r.jsx(o.Menu.Item,{onClick:c,icon:r.jsx(M.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),j&&r.jsx(o.Menu.Item,{onClick:y,icon:r.jsx(V.ArrowsMaximize,{size:14}),disabled:!0,children:n("common.actions.enter_fullscreen")}),r.jsx(UI,{}),r.jsx(o.Divider,{label:n("common.actions.edit"),labelPosition:"center"}),r.jsx(o.Menu.Item,{onClick:f,icon:r.jsx(V.Settings,{size:14}),children:n("common.titles.settings")}),r.jsx(o.Menu.Item,{onClick:h,icon:r.jsx(V.Copy,{size:14}),children:n("common.actions.duplicate")}),r.jsx(o.Menu.Item,{color:"red",onClick:m,icon:r.jsx(V.Trash,{size:14}),children:n("common.actions.delete")})]})]})})})});function KI(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const jl=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState(!1),{panel:s}=St();return KI(s.description)?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:()=>n(!1),title:s.title.show?s.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:r.jsx(vr,{value:s.description,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}}})}),r.jsx(o.Tooltip,{label:e("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:r.jsx(V.InfoCircle,{size:20})})})]})}),qL="",XI=D.observer(function(){const{panel:t}=St(),{name:n,title:s}=t;return s.show?r.jsx(o.Group,{grow:!0,position:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:r.jsx(o.Text,{align:"center",lineClamp:1,className:"panel-title-text",children:n})}):null});function JI(e){const t=g.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const s=t.current;if(!s)return;const i=s.offsetWidth*2,a=s.offsetHeight*2;hc.toBlob(t.current,{bgcolor:"white",width:i,height:a,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(l=>{window.saveAs(l,`${e.name?e.name:e.viz.type}.png`)})}}}var yf=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(yf||{}),li=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(li||{});class ZI{constructor(t){B(this,"vizInstance");B(this,"operationManager");B(this,"triggerManager");B(this,"vizManager");B(this,"runningMigration");B(this,"panelModel");B(this,"status","notStarted");this.panelModel=t.getRequired(je.instanceScope.panelModel),this.vizInstance=t.getRequired(je.instanceScope.vizInstance),this.operationManager=t.getRequired(je.instanceScope.operationManager),this.triggerManager=t.getRequired(je.instanceScope.triggerManager),this.vizManager=t.getRequired(je.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(t=>(this.status="done",t))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(n)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return t.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function bf(e){const{panel:t}=St();return g.useCallback(n=>{const s=n.getRequired(je.vizManager),i=s.resolveComponent(e.viz.type);return n.createScoped().provideFactory(je.instanceScope.vizInstance,()=>s.getOrCreateInstance(e)).provideFactory(je.instanceScope.interactionManager,a=>{const l=a.getRequired(je.instanceScope.vizInstance);return new la(l,i,Cs)}).provideFactory(je.instanceScope.operationManager,a=>a.getRequired(je.instanceScope.interactionManager).operationManager).provideFactory(je.instanceScope.triggerManager,a=>a.getRequired(je.instanceScope.interactionManager).triggerManager).provideValue(je.instanceScope.panelModel,t).provideFactory(je.instanceScope.migrator,a=>new ZI(a))},[e.viz.type,e.viz.conf])}function vf(e){const[t,n]=g.useState(!1),s=Ih().getRequired(je.instanceScope.migrator);return W.useAsyncEffect(async()=>{const i=s.status===li.notStarted;n(s.status===li.done),s.status===li.notStarted&&s.runMigration().then(a=>{a===yf.migrated&&i&&(e==null||e())}).finally(()=>{n(!0)})},[s]),t}function _f(e,t){const n=Ih().getRequired(je.instanceScope.vizInstance);return g.useEffect(()=>(n.instanceData.setItem(null,t.viz.conf),n.instanceData.watchItem(null,s=>{e(s)})),[e,t.viz.type]),n}function HI({setVizConf:e,...t}){const{panel:n}=t,s=_f(e,n),i=vf(()=>{sn.showNotification({title:`${n.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return W.useAsyncEffect(async()=>{await s.instanceData.setItem(null,n.viz.conf)},[s,n.viz.type]),i?r.jsx(Wy,{...t}):r.jsx(o.Text,{children:"Checking update..."})}function eE(e){const{panel:t,setVizConf:n}=e;_f(n,t);const{inEditMode:s}=g.useContext(js);return vf(()=>{s&&sn.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?r.jsx(Gy,{...e}):r.jsx(o.Text,{children:"Checking update"})}const VL="";function tE(e,t){const{vizManager:n}=g.useContext(Gt),{panel:{viz:s,title:i,id:a,name:l,description:c,queryIDs:u,variables:d}}=St(),p={id:a,name:l,title:i,description:c,queryIDs:u,viz:s},h=bf(p);try{return n.resolveComponent(s.type),r.jsx(si,{configure:h,children:r.jsx(eE,{setVizConf:s.setConf,panel:p,measure:t,data:e,variables:d,vizManager:n})})}catch(f){return console.info(v.get(f,"message")),null}}const jf=D.observer(function({data:t}){const{ref:n,width:s,height:i}=he.useElementSize(),a=tE(t,{w:s,h:i}),l=s>0&&i>0;return r.jsx("div",{className:"viz-root",ref:n,children:r.jsx(o.Box,{sx:{width:s,height:i,overflow:"hidden"},children:l&&r.jsx(ze,{children:a})})})}),wf=D.observer(({panel:e})=>r.jsxs(o.Stack,{children:[e.queryErrors.map((t,n)=>r.jsx(o.Text,{color:"red",size:"sm",align:"center",sx:{fontFamily:"monospace"},children:t},`${n}-${t}`)),r.jsx(o.Text,{color:"gray",align:"center",size:"sm",children:e.queryStateMessages})]})),wl=D.observer(({panel:e})=>r.jsxs(o.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[r.jsx(o.LoadingOverlay,{visible:e.dataLoading,exitTransitionDuration:0}),!e.canRenderViz&&r.jsx(wf,{panel:e}),e.canRenderViz&&r.jsx(jf,{data:e.data})]})),nE={border:"1px solid #e9ecef"},Cf=D.observer(({panel:e,panelStyle:t,dropdownContent:n})=>{const{ref:s,downloadPanelScreenshot:i}=JI(e);return e.title.show,r.jsx(ra,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:i},children:r.jsxs(o.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,ref:s,p:0,sx:{...nE,...t},children:[r.jsx(o.Box,{className:"panel-description-popover-wrapper",children:r.jsx(jl,{})}),n,r.jsx(XI,{}),r.jsx(wl,{panel:e})]})})}),rE={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function sE(e){return e.style.border.enabled?{}:rE}const Sf=D.observer(function({panel:t,view:n}){const s=sE(t);return r.jsx(Cf,{panel:t,panelStyle:s,dropdownContent:r.jsx(YI,{view:n,title:t.name})})});function iE(e){return!["richText","button"].includes(e)}const aE=D.observer(({view:e,title:t})=>{const{t:n}=_.useTranslation(),{panel:s,downloadPanelScreenshot:i}=St(),{id:a}=s,{viewPanelInFullScreen:l,inFullScreen:c}=g.useContext(ii),u=g.useCallback(()=>{l(a)},[a,l]),d=!c&&e.type!==q.Modal;return iE(s.viz.type)?r.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:r.jsxs(o.Menu,{withinPortal:!0,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Box,{className:"panel-dropdown-target"})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{onClick:s.refreshData,icon:r.jsx(V.Refresh,{size:14}),children:n("common.actions.refresh")}),r.jsx(o.Menu.Item,{onClick:s.downloadData,icon:r.jsx(V.Download,{size:14}),children:n("common.actions.download_data")}),r.jsx(o.Menu.Item,{onClick:i,icon:r.jsx(M.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),d&&r.jsx(o.Menu.Item,{onClick:u,icon:r.jsx(V.ArrowsMaximize,{size:14}),children:n("common.actions.enter_fullscreen")})]})]})}):null});function oE(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const Cl=D.observer(({panel:e,view:t})=>{const n=oE(e);return r.jsx(Cf,{panel:e,panelStyle:n,dropdownContent:r.jsx(aE,{title:e.name,view:t})})}),lE={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},kf=D.observer(function({view:t,panel:n,exitFullScreen:s}){return r.jsx(o.Modal,{opened:!0,fullScreen:!0,onClose:s,title:r.jsx(o.Button,{color:"blue",size:"xs",onClick:s,leftIcon:r.jsx(V.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:lE,children:r.jsx(o.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:r.jsx(Cl,{view:t,panel:n})})})});function Tf(e,t,n){const{panels:s}=_e(),i=e.id==="Main",[a,l]=g.useState(()=>i&&s.findByID(t)?t:null),c=g.useCallback(h=>{l(h),i&&n(h)},[i,n]),u=g.useCallback(()=>{l(null),i&&n("")},[i,n]),d=a?s.findByID(a):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const NL="",cE=g.forwardRef(({h:e},t)=>r.jsx(o.ActionIcon,{ref:t,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:e>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:r.jsx(V.ArrowsMove,{size:16})})),uE=g.forwardRef(({handleAxis:e,...t},n)=>r.jsx(o.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:r.jsx(V.ChevronDownRight,{size:16})})),dE=es.WidthProvider(es.Responsive),pE=D.observer(({view:e,className:t="layout"})=>{const s=Y().layouts,i=s.items(e.panelIDs),a=s.gridLayouts(e.panelIDs),l=(d,p,h,f)=>{console.log("🔴 onResize",d),h.h<30&&(h.h=30,f.h=30),h.w<4&&(h.w=4,f.w=4)},c=(d,p,h)=>{console.log("🔴 onResizeStop",{layouts:d,oldItem:p,newItem:h}),s.updateCurrentLayoutItem(h)},u=(d,p,h)=>{console.log("🔴 onDragStop",{layouts:d,oldItem:p,newItem:h}),s.updateCurrentLayoutItems(d)};return r.jsx(dE,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:s.cols,layouts:a,draggableHandle:".react-grid-customDragHandle",resizeHandle:r.jsx(uE,{}),onResize:l,breakpoints:s.breakpoints,onBreakpointChange:s.setCurrentBreakpoint,onResizeStop:c,onDragStop:u,width:s.currentLayoutPreviewWidth,children:i.map(d=>r.jsxs("div",{"data-grid":d.layoutProperies,className:"panel-grid-item",children:[r.jsx(cE,{h:d.h}),r.jsx(Sf,{view:e,panel:d.panel})]},d.id))})}),hE=es.WidthProvider(es.Responsive),fE=D.observer(({view:e,className:t="layout"})=>{const n=_e(),s=n.layouts.items(e.panelIDs),i=n.layouts.gridLayouts(e.panelIDs);return r.jsx(hE,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:n.layouts.cols,layouts:i,breakpoints:n.layouts.breakpoints,onBreakpointChange:n.layouts.setCurrentBreakpoint,children:s.map(a=>r.jsx("div",{"data-grid":a.layoutProperies,className:"panel-grid-item",children:r.jsx(Cl,{view:e,panel:a.panel})},a.id))})});function Sl(e){const t=g.useRef(null);return{ref:t,downloadScreenshot:()=>{var i;const s=(i=t.current)==null?void 0:i.querySelector(".react-grid-layout");s&&e.downloadScreenshot(s)}}}const gE=D.observer(({downloadScreenshot:e})=>{const{t}=_.useTranslation(),[n,{setTrue:s,setFalse:i}]=W.useBoolean(!1),a=bu(),l=_e(),c=()=>{const u=JSON.stringify(l.contentJSON,null,2),d=`${a.name}__${l.name}`;ir(d,u)};return r.jsxs(o.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:r.jsx(o.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:s,onMouseLeave:i,sx:{opacity:n?1:.6,transform:`translateX(${n?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:r.jsx(M.IconShare3,{size:"1rem"})})})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{icon:r.jsx(M.IconCamera,{size:14}),onClick:e,children:t("common.actions.download_screenshot")}),r.jsx(o.Menu.Divider,{}),r.jsx(o.Menu.Item,{icon:r.jsx(M.IconDownload,{size:14}),onClick:l.queries.downloadAllData,children:t("common.actions.download_data")}),r.jsx(o.Menu.Item,{icon:r.jsx(M.IconCode,{size:14}),onClick:c,children:t("common.actions.download_schema")})]})]})}),Df=D.observer(({children:e,view:t,sx:n={}})=>{const{ref:s,downloadScreenshot:i}=Sl(t);return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{ref:s,pt:10,pb:10,sx:n,children:e}),r.jsx(gE,{downloadScreenshot:i})]})}),Mf=D.observer(({downloadScreenshot:e})=>r.jsx(o.ActionIcon,{className:"download-screenshot-button",color:"blue",onClick:e,children:r.jsx(M.IconCamera,{size:14})})),mE=D.observer(({children:e,view:t})=>{const n=_e(),s=t.config,i=n.views.visibleViewIDs.includes(t.id),a=()=>n.views.rmVisibleViewID(t.id),{ref:l,downloadScreenshot:c}=Sl(t);return r.jsx(o.Modal,{size:s.width,centered:!0,opened:i,onClose:a,withCloseButton:!1,title:r.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[r.jsx(o.Box,{children:s.custom_modal_title.value}),r.jsx(Mf,{downloadScreenshot:c})]}),trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:s.height,overflow:"auto",position:"relative",paddingBottom:10},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:r.jsx(o.Box,{ref:l,children:e})})}),xE=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},yE=D.observer(({view:e})=>{const t=_e(),n=e.config;return r.jsxs(o.Tabs,{className:"render-view-tabs",variant:n.variant,orientation:n.orientation,value:e.tab,onTabChange:e.setTab,styles:{root:{height:"100%",overflow:n.orientation==="horizontal"?"hidden":"auto"},panel:{padding:n.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[r.jsx(o.Tabs.List,{grow:n.grow,children:n.tabsInOrder.map(s=>r.jsx(o.Tabs.Tab,{value:s.id,sx:xE(s),disabled:!s.view_id,children:s.name??s.id},s.id))}),n.tabsInOrder.map(s=>{const i=t.views.findByID(s.view_id);return i?r.jsx(o.Tabs.Panel,{value:s.id,children:r.jsx(ci,{view:i})},s.id):null})]})}),bE=D.observer(({view:e,children:t})=>{switch(e.type){case q.Modal:return r.jsx(mE,{view:e,children:t});case q.Tabs:return r.jsx(yE,{view:e});case q.Division:default:return r.jsx(Df,{view:e,children:t})}}),vE=D.observer(({children:e,view:t})=>{const s=Y().layouts,[i,a]=he.useResizeObserver();return g.useEffect(()=>{s.setCurrentLayoutWrapperWidth(a.width)},[a.width]),r.jsx(o.Box,{sx:{height:"100%"},ref:i,children:r.jsx(o.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:s.currentLayoutPreviewWidth??"100%",transform:`scale(${s.divisionPreviewScale})`,transformOrigin:"0 0"},children:r.jsx(Df,{view:t,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:e})})})});function zf(e){return e.replace(/(vw|vh)/,"%")}const _E=D.observer(({children:e,view:t})=>{const n=t.config,{width:s,height:i}=g.useMemo(()=>({width:zf(n.width),height:zf(n.height)}),[n.width,n.height]),{ref:a,downloadScreenshot:l}=Sl(t);return r.jsx(o.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:r.jsx(o.Modal,{size:n.width,opened:!0,onClose:v.noop,withCloseButton:!1,title:r.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[r.jsx(o.Box,{children:n.custom_modal_title.value}),r.jsx(Mf,{downloadScreenshot:l})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:s,height:i,maxHeight:i},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:r.jsx(o.Box,{ref:a,children:e})})})}),jE=({variant:e,orientation:t})=>{const n={root:{height:"100%",overflow:"hidden"},tabsList:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(n.tab.paddingTop="6px",n.tab.paddingBottom="6px"),t==="vertical"&&(n.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},n.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),n},wE=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},CE=D.observer(({view:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Y(),i=g.useMemo(()=>s.views.options.filter(u=>u.type===q.Division),[e.id,s.views.options]),a=e.config,l=u=>n.openConfirmModal({title:`${t("view.component.tabs.tab.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{a.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),c=a.tabs.length===0;return r.jsxs(o.Tabs,{className:"preview-view-tabs",variant:a.variant,orientation:a.orientation,value:e.tab,onTabChange:e.setTab,styles:jE(a),children:[r.jsxs(o.Tabs.List,{grow:a.grow,children:[a.tabsInOrder.map(u=>r.jsx(o.Tabs.Tab,{value:u.id,sx:wE(u),children:u.name??u.id},u.id)),r.jsx(o.Tabs.Tab,{onClick:a.addTab,value:"add",className:"add-a-tab",children:r.jsx(V.Plus,{size:18,color:"#228be6"})})]}),a.tabsInOrder.map((u,d)=>{const p=s.views.findByID(u.view_id);return r.jsxs(o.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[r.jsxs(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[r.jsx(o.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),r.jsxs(o.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[r.jsx(o.TextInput,{label:t("view.component.tabs.tab.name"),required:!0,value:u.name,onChange:h=>u.setName(h.currentTarget.value)}),r.jsx(o.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:i}),r.jsx(o.NumberInput,{label:t("view.component.tabs.tab.order"),required:!0,value:u.order,onChange:h=>u.setOrder(h||0),min:0,max:1e3,step:1}),r.jsx(o.ColorInput,{label:t("view.component.tabs.tab.color"),value:u.color,onChange:u.setColor,disabled:a.variant!=="default"}),p&&r.jsx(o.Button,{mt:20,variant:"gradient",leftIcon:r.jsx(M.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>s.views.setIDOfVIE(p.id),children:t("view.component.tabs.tab.switch_to_view",{name:p.name})}),r.jsx(o.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>l(d),disabled:c,leftIcon:r.jsx(M.IconTrash,{size:14}),children:t("view.component.tabs.tab.delete")})]})]}),p&&r.jsx(ci,{view:p})]},u.id)})]})}),SE=D.observer(({view:e,children:t})=>{switch(e.type){case q.Modal:return r.jsx(_E,{view:e,children:t});case q.Tabs:return r.jsx(CE,{view:e});case q.Division:default:return r.jsx(vE,{view:e,children:t})}}),If=D.observer(function({view:t}){const s=Y().layouts.divisionPreviewScale!==1;return r.jsx(ii.Provider,{value:{viewPanelInFullScreen:v.noop,inFullScreen:!1},children:r.jsx(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:s?"transparent":"#efefef"},children:r.jsx(SE,{view:t,children:r.jsxs(o.Box,{sx:{position:"relative"},children:[r.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:r.jsx(Oh,{view:t})}),r.jsx(pE,{view:t})]})})})})}),ci=D.observer(function({view:t}){const{fullScreenPanelID:n,setFullScreenPanelID:s}=ku(),{viewPanelInFullScreen:i,exitFullScreen:a,inFullScreen:l,fullScreenPanel:c}=Tf(t,n,s);return r.jsx(ii.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:l},children:r.jsxs(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===q.Modal?"0 !important":"100%"},children:[l&&r.jsx(kf,{view:t,panel:c,exitFullScreen:a}),r.jsx(bE,{view:t,children:r.jsxs(o.Box,{sx:{position:"relative"},children:[!l&&r.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:r.jsx(Oh,{view:t})}),!l&&r.jsx(fE,{view:t})]})})]})})});var Ef=(e=>(e.Use="use",e.Edit="edit",e))(Ef||{});const kE={[q.Division]:"Division",[q.Tabs]:"Tabs",[q.Modal]:"Modal"},Af={[q.Division]:"rgba(255, 0, 0, 0.2)",[q.Modal]:"rgba(0, 0, 0, 0.2)",[q.Tabs]:"rgba(255, 200, 100, 0.4)"},TE={[q.Division]:"#ff4000",[q.Modal]:"#000",[q.Tabs]:"#ffad18"};function DE(e,t,n){x.addDisposer(e,x.addMiddleware(e,(s,i)=>{i(s,()=>{x.getType(s.context)===t&&s.type==="action"&&n(s.name,s.context)})}))}const Pf=x.types.compose("FiltersModel",ml,x.types.model("FiltersModel",{previewValues:x.types.optional(x.types.frozen(),{})})).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get keySet(){return new Set(e.current.map(t=>t.key))},get options(){return e.current.map(t=>({label:t.label??t.id,value:t.id,_type:"filter"}))},get selects(){return e.current.filter(t=>t.type===ce.Select).map(t=>({label:t.label??t.id,value:t.id}))},get keyLabelOptions(){return e.current.map(t=>({label:t.label??t.key,value:t.key}))},get sortedList(){return v.sortBy(e.current,t=>t.label.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.idSet.has(s.id));e.current.push(...n)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(s=>s.id===t);n>=0&&e.current.splice(n,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){DE(e.current,il,(n,s)=>{if(n==="setType"){const i=cf(s.config.default_value,s.config);e.setValueByKey(s.key,i),e.updatePreviewValues({...e.previewValues,[s.key]:i})}})}return{afterCreate(){t()}}}),Of=yl.views(e=>({get canPreviewData(){return e.isTransform?e.dep_query_ids.length>0&&!!e.pre_process:!!e.datasource},get guideToPreviewData(){return e.isTransform?"Need to complete settings in Transform tab":"Need to pick a Data Source first"}})),Lf=x.types.compose("QueriesModel",bl,x.types.model({current:x.types.optional(x.types.array(Of),[])})).views(e=>({get options(){const t=e.current.map(n=>({value:n.id,label:n.name,_type:"query"}));return v.sortBy(t,n=>n.label.toLowerCase())},get optionsWithoutTransform(){const t=e.current.filter(n=>n.type!==ye.Transform).map(n=>({value:n.id,label:n.name,_type:"query"}));return v.sortBy(t,n=>n.label.toLowerCase())},get sortedList(){return v.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.idSet.has(s.id));e.current.push(...n)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},removeQuery(t){const n=e.current.find(s=>s.id===t);n&&(x.detach(n),e.current.remove(n))},removeQueries(t){const n=new Set(t);e.current.forEach(i=>{n.has(i.id)&&x.detach(i)});const s=[...e.current];v.remove(s,i=>n.has(i.id)),e.current=x.cast(s)}})),Bf=_l.views(e=>({get sortedList(){return v.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(n=>({label:n.key,value:n.key,_type:"sql_snippet"}));return v.sortBy(t,n=>n.label.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.keySet.has(s.key));e.current.push(...n)},remove(t){e.current.splice(t,1)},removeByKey(t){const n=e.current.findIndex(s=>s.key===t);n>=0&&e.current.splice(n,1)},removeByKeys(t){const n=new Set(t);e.current.forEach(i=>{n.has(i.key)&&x.detach(i)});const s=[...e.current];v.remove(s,i=>n.has(i.key)),e.current=x.cast(s)},replaceByIndex(t,n){e.current.splice(t,1,n)}})),ME=x.types.model({data:x.types.optional(x.types.frozen(),[]),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),zE=x.types.model({data:x.types.optional(x.types.frozen(),[]),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),IE=x.types.model({page:x.types.optional(x.types.number,1),limit:x.types.optional(x.types.number,20),data:x.types.optional(x.types.frozen(),[]),total:x.types.optional(x.types.number,0),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get keywords(){return x.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:n}=x.getParent(e,1);return`${n}||${t}`}})).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0},get maxPage(){return Math.ceil(e.total/e.limit)},get offset(){return(e.page-1)*e.limit},get countSql(){const{table_name:t,table_schema:n}=e.keywords;return`
|
|
452
|
+
`}})}function eI(e,t,n){const{overflow:s,rotate:i}=e.x_axis.axisLabel,a=dt(s.on_axis);return te.getXAxis({id:"main-x-axis",type:"category",data:t,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:i,...a,formatter:n},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:3})}function tI(e,t,n){const{nameAlignment:s,data_key:i,...a}=e.y_axis,{overflow:l,rotate:c}=e.y_axis.axisLabel,u=dt(l.on_axis);return te.getYAxis({...a,type:"category",data:t,axisLabel:{rotate:c,...u,formatter:n},axisLine:{show:!0,lineStyle:{width:3}},axisTick:{show:!0,alignWithLabel:!0},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameTextStyle:{fontWeight:"bold",align:s},nameLocation:"end",nameGap:15,z:3})}function nI(e,t,n){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const s=n.reduce((k,S)=>{const T=Vt(S,t);return k[S.name]=rt(S,T),k},{}),i=Uz(e),a=Yz(e),l=Xs(e.visualMap,s),{min:c,max:u}=l,d=O(e.x_axis.data_key),p=O(e.y_axis.data_key),h=O(e.heat_block.data_key),f=v.uniq(t[d.queryID].map(k=>k[d.columnKey])),m=v.uniq(t[d.queryID].map(k=>k[p.columnKey])),y=t[d.queryID].map(k=>{const S=v.get(k,d.columnKey),T=v.get(k,p.columnKey),z=v.get(k,h.columnKey),I={value:[S,T,z]},{followVisualMap:E,color:N}=Co(z,c,u,e.visualMap);return E||(I.visualMap=!1,I.itemStyle={color:N}),I});return{xAxis:eI(e,f,i.x_axis),yAxis:tI(e,m,i.y_axis),series:Xz(e,y),tooltip:Hz(e,t,i,a),grid:Kz(e),visualMap:l}}function rI({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=g.useMemo(()=>{const h=O(e.x_axis.data_key),f=O(e.y_axis.data_key);return v.keyBy(t[h.queryID],m=>`${m[h.columnKey]}---${m[f.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),c=st(i.triggerManager,Dh.id),u=g.useCallback(h=>{const[f,m]=h.value,y=v.get(l,`${f}---${m}`,{error:"rowData is not found"});c.forEach(j=>{i.runInteraction(j.id,{...h,rowData:y})})},[l,c,i]),d=g.useMemo(()=>({click:u}),[u]),p=g.useMemo(()=>nI(e,t,a),[e,t]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function sI({context:e,instance:t}){const n=it({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,Wo),[s]),l=e.data,{width:c,height:u}=e.viewport;return!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(rI,{variables:i,width:wt(c),height:Ct(u),data:l,conf:a,interactionManager:n})})}const iI=[{lang:"en",resources:{merico_heatmap:{viz_name:"Merico Heatmap",click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{merico_heatmap:{viz_name:"思码逸热力图",click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function aI(e){const{visualMap:t=Ht(),heat_block:{min:n,max:s,...i},...a}=e;return{...a,heat_block:i,visualMap:{...Ht(),min:n,max:s}}}class oI extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:aI(n.config)}))}}const lI={displayName:"viz.merico_heatmap.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new oI,name:"merico-heatmap",viewRender:sI,configRender:Wz,createConfig:()=>({version:2,config:Wo}),triggers:[Dh],translation:iI},cI=[{value:"#25262B",name:"Dark"},{value:"#868E96",name:"Gray"},{value:"#FA5252",name:"Red"},{value:"#E64980",name:"Pink"},{value:"#BE4BDB",name:"Grape"},{value:"#7950F2",name:"Violet"},{value:"#4C6EF5",name:"Indigo"},{value:"#228BE6",name:"Blue"},{value:"#15AABF",name:"Cyan"},{value:"#12B886",name:"Teal"},{value:"#40C057",name:"Green"},{value:"#82C91E",name:"Lime"},{value:"#FAB005",name:"Yellow"},{value:"#FD7E14",name:"Orange"}].map(e=>({name:e.name,value:e.value,type:"single",category:"basic"})),uI=[Ry,Qy,Ky,Yy,Uy,Xy],Mh=[Oo,u1,kD,Kk,I1,WS,QM,ub,aw,sC,XC,uM,ES,V0,UT,mk,Wk,OD,Sz,lI,Bz,xw],zh=()=>({id:"dashboard",version:xu,manifest:{viz:Mh,color:[...cI,...uI]}}),Wr=new eb,je={pluginManager:Kt("pluginManager"),vizManager:Kt("vizManager"),colorManager:Kt("colorManager"),instanceScope:{panelModel:Kt("panelModel"),vizInstance:Kt("vizInstance"),interactionManager:Kt("interactionManager"),migrator:Kt("migrator"),operationManager:Kt("operationManager"),triggerManager:Kt("triggerManager")}},Ro=()=>{try{Wr.install(zh())}catch{}const e=new Fy(Wr),t=new Hy(Wr);return{pluginManager:Wr,vizManager:e,colorManager:t}},Gt=g.createContext(Ro());try{Wr.install(zh())}catch{}const Qo=g.createContext(null);function si(e){const t=g.useContext(Qo),n=W.useCreation(()=>e.configure(t||new Ji),[e.configure]),s=W.usePrevious(n);return s&&s!==n&&s.dispose(),r.jsx(Qo.Provider,{value:n,children:e.children})}function Ih(){return g.useContext(Qo)}const dI=({description:e,isDescriptionEmpty:t})=>t?null:r.jsx(o.Tooltip,{color:"white",label:r.jsx(vr,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:r.jsx(o.Box,{sx:{height:"16px",alignSelf:"center"},children:r.jsx(M.IconInfoCircle,{size:16,color:"gray"})})}),pI=D.observer(({label:e,config:{default_value:t,description:n,isDescriptionEmpty:s,...i},value:a,onChange:l})=>r.jsxs(o.Box,{children:[r.jsx(o.Text,{children:" "}),r.jsx(o.Checkbox,{label:r.jsxs(o.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[r.jsx(o.Box,{sx:{flexGrow:1},children:e}),r.jsx(dI,{description:n,isDescriptionEmpty:s})]}),checked:a||!1,onChange:c=>l(c.currentTarget.checked),...i,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),hI=({value:e,onChange:t,close:n,max_days:s,allowSingleDateInRange:i})=>{const{i18n:a}=_.useTranslation(),[l,c]=e,u=g.useMemo(()=>l||new Date,[l]),d=g.useMemo(()=>{if(l&&!c)return l},[l,c]),p=g.useMemo(()=>{if(l&&!c&&s>0)return P(l).add(s-1,"days").toDate()},[l,c,s]),h=f=>{const[m,y]=f;t(f),m&&y&&n()};return r.jsx(uc.DatePicker,{defaultDate:u,numberOfColumns:2,type:"range",value:e,onChange:h,onNextMonth:console.log,minDate:d,maxDate:p,allowSingleDateInRange:i,locale:a.language})},fI=({begin:e,end:t})=>{const{t:n}=_.useTranslation(),s=g.useMemo(()=>P(t).diff(P(e),"days")+1,[e,t]);if(Number.isNaN(s))return r.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const i=s===1?n("filter.widget.date_range.one_day"):n("filter.widget.date_range.x_days",{count:s});return r.jsx(o.Tooltip,{label:i,children:r.jsx(o.Badge,{size:"sm",children:s})})},gI=({max_days:e})=>{const{t}=_.useTranslation();return e?r.jsxs(r.Fragment,{children:[r.jsx(o.Group,{position:"right",children:r.jsx(o.Badge,{size:"xs",children:t("filter.widget.date_range.x_max_days",{max_days:e})})}),r.jsx(o.Divider,{variant:"dashed",my:10})]}):null},Uo=()=>[{key:"d",value:"yesterday",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"w",value:"last week",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"week").startOf("week").toDate(),P(e).subtract(1,"week").endOf("week").toDate()]}},{key:"m",value:"last month",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"month").startOf("month").toDate(),P(e).subtract(1,"month").endOf("month").toDate()]}},{key:"m2",value:"last 2 months",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(2,"month").startOf("month").toDate(),P(e).subtract(1,"month").endOf("month").toDate()]}},{key:"m3",value:"last 3 months",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(3,"month").startOf("month").toDate(),P(e).subtract(1,"month").endOf("month").toDate()]}},{key:"y",value:"last year",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"year").startOf("year").toDate(),P(e).subtract(1,"year").endOf("year").toDate()]}},{key:"d7",value:"recent 7 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(7,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d30",value:"recent 30 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(30,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d60",value:"recent 60 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(60,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d90",value:"recent 90 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(90,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d180",value:"recent 180 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(180,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d365",value:"recent 365 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(365,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d",value:"today",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("day").toDate(),P(e).endOf("day").toDate()]}},{key:"w",value:"this week",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("week").toDate(),P(e).endOf("week").toDate()]}},{key:"m",value:"this month",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("month").toDate(),P(e).endOf("month").toDate()]}},{key:"y",value:"this year",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("year").toDate(),P(e).endOf("year").toDate()]}},{key:"w",value:"this week so far",group:"this_so_far",getRange:()=>{const e=Date.now();return[P(e).startOf("week").toDate(),P(e).toDate()]}},{key:"m",value:"this month so far",group:"this_so_far",getRange:()=>{const e=Date.now();return[P(e).startOf("month").toDate(),P(e).toDate()]}},{key:"y",value:"this year so far",group:"this_so_far",getRange:()=>{const e=Date.now();return[P(e).startOf("year").toDate(),P(e).toDate()]}}];function Eh(e){const n=Uo().find(s=>s.value===e);return n?n.getRange():null}const mI=({onChange:e})=>{const{t,i18n:n}=_.useTranslation(),s=l=>()=>{const c=l();e(c)},i=g.useMemo(()=>v.groupBy(Uo(),"group"),[]),a=n.language==="zh";return r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(o.Table,{withBorder:!1,sx:{"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:r.jsx("tbody",{children:Object.entries(i).map(([l,c])=>r.jsxs("tr",{children:[r.jsx("th",{children:r.jsx(o.Text,{size:"xs",color:"#555",children:t(`filter.widget.date_range.shortcut.${l}.label`)})}),c.map(({key:u,value:d,getRange:p})=>r.jsx("td",{children:r.jsx(o.Button,{compact:!0,size:"xs",variant:"subtle",onClick:s(p),children:t(`filter.widget.date_range.shortcut.${l}.${a?"full.":""}${u}`)})},u))]},l))})})]})},Ah=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),xI=({label:e,required:t,value:n,onChange:s,max_days:i,allowSingleDateInRange:a,inputFormat:l})=>{const{t:c}=_.useTranslation(),[u,{open:d,close:p}]=he.useDisclosure(!1),[h,f]=n,m=h?P(h).format(l):"",y=f?P(f).format(l):"";return r.jsxs(o.Popover,{opened:u,onClose:p,position:"bottom-start",shadow:"md",children:[r.jsxs(o.Group,{position:"left",grow:!0,noWrap:!0,spacing:0,w:"288px",sx:{marginTop:"3px"},children:[r.jsx(o.Popover.Target,{children:r.jsx(o.TextInput,{label:e,labelProps:{title:e},required:t,icon:r.jsx(M.IconCalendar,{size:16}),placeholder:c("filter.widget.date_range.start_date"),readOnly:!0,value:m,onFocus:d,styles:Ah(u),sx:{".mantine-TextInput-label":{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",width:"calc(240px)",position:"relative",zIndex:1},".mantine-Input-input":{borderRight:"none",borderTopRightRadius:0,borderBottomRightRadius:0}}})}),r.jsx(o.TextInput,{label:r.jsx(o.Group,{position:"right",children:r.jsx(fI,{begin:h,end:f})}),icon:r.jsx(M.IconMinus,{size:16}),placeholder:c("filter.widget.date_range.end_date"),readOnly:!0,disabled:!h,value:y,onFocus:d,styles:Ah(u),sx:{".mantine-Input-icon":{transform:"translateX(-22px)"},".mantine-Input-input":{borderLeft:"none",borderTopLeftRadius:0,borderBottomLeftRadius:0},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to right, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})]}),r.jsxs(o.Popover.Dropdown,{p:"sm",children:[r.jsx(gI,{max_days:i}),r.jsx(hI,{value:n,onChange:s,close:p,allowSingleDateInRange:a,max_days:i}),r.jsx(mI,{onChange:s})]})]})},Ph=D.observer(({label:e,config:t,value:n=[null,null],onChange:s})=>{const{inputFormat:i,required:a,max_days:l,allowSingleDateInRange:c}=t,u=Array.isArray(n)?n.map(p=>p?P(p).toDate():null):[null,null],d=p=>{s(p.map(h=>h&&P(h).format(i)))};return r.jsx(xI,{label:e,value:u,onChange:d,inputFormat:i,allowSingleDateInRange:c,max_days:l,required:a})}),yI=o.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-select.rc-select-open":{borderColor:"#228be6 !important",".rc-select-selection-overflow-item-rest":{display:"none"},".rc-select-selection-overflow-item-suffix":{display:"block"}},".rc-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-select-selection-search-mirror":{display:"none"},".rc-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,backgroundColor:"#fff",border:"1px solid #e9ecef",marginTop:6,padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px","&.rc-select-dropdown-slide-up-leave-active":{display:"none"},".rc-select-item-empty":{padding:"8px 12px"},".rc-select-item-option":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px 8px 2px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},flexDirection:"row-reverse",".rc-select-item-option-state":{flexGrow:0,flexShrink:0,width:"30px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},".rc-select-item-option-content":{width:"calc(100% - 30px)",overflow:"hidden",'div[data-role="label"]':{overflowWrap:"break-word"}}},".rc-virtual-list-holder-inner":{alignItems:"flex-start"}}})),Yo=({errorMessage:e})=>{const{t}=_.useTranslation();return e?r.jsx(o.Text,{color:"red",size:12,children:e}):r.jsx(o.Text,{color:"dimmed",size:12,children:t("filter.widget.common.selector_option_empty")})},bI=({disabled:e,classNames:t,styles:n,unstyled:s,radius:i,style:a,label:l,value:c,onChange:u,options:d,errorMessage:p,required:h})=>{const{t:f}=_.useTranslation(),{classes:m,cx:y}=yI({radius:i},{name:"MultiSelectWidget",classNames:t,styles:n,unstyled:s}),[j,k]=g.useState(!1),S=N=>{k(N)},T=j&&(c==null?void 0:c.length)>0,[z,I]=g.useState(""),E=g.useMemo(()=>{if(!z)return d;const N=z.toLowerCase(),R=pe=>{var ie;return((ie=pe.description)==null?void 0:ie.toLowerCase().includes(N))||pe.label.toLowerCase().includes(N)};return d.filter(R)},[z,d]);return r.jsxs(o.Stack,{spacing:3,children:[r.jsxs(o.Group,{position:"apart",children:[r.jsxs(o.Text,{className:m.label,children:[l,h&&r.jsx("span",{className:m.required,"aria-hidden":"true",children:"*"})]}),T&&r.jsx(o.Tooltip,{label:f("filter.widget.common.x_selected",{count:c.length}),children:r.jsx(o.Badge,{children:c.length})})]}),r.jsx(dc,{disabled:e,allowClear:!0,className:y(m.root,"check-select"),dropdownClassName:y(m.dropdown,""),onDropdownVisibleChange:S,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:a,clearIcon:()=>r.jsx(o.CloseButton,{}),value:c,onChange:u,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:r.jsx(Yo,{errorMessage:p}),maxTagTextLength:10,maxTagPlaceholder:N=>f("filter.widget.common.x_selected",{count:N.length}),searchValue:z,onSearch:I,filterOption:!1,children:E.map(N=>r.jsxs(dc.Option,{title:N.label,children:[r.jsx(o.Text,{size:"sm","data-role":"label",children:N.label}),N.description&&r.jsx(o.Text,{size:"xs",color:"dimmed","data-role":"description",children:N.description})]},N.value))})]})},vI=D.observer(({label:e,config:t,value:n,onChange:s})=>{const i=_e(),a=!!t.options_query_id,{state:l,error:c}=i.getDataStuffByID(t.options_query_id),u=l==="loading",d=t.min_width?t.min_width:"200px",p=a?u:!1,h=f=>s(f,!1);return r.jsx(bI,{label:e,options:t.options,style:{minWidth:"160px",width:d,maxWidth:p?d:"unset",borderColor:"#e9ecef"},disabled:p,value:n,onChange:h,errorMessage:c,required:t.required})}),_I=g.forwardRef(({label:e,description:t,...n},s)=>r.jsx("div",{ref:s,...n,children:r.jsx(o.Group,{noWrap:!0,children:r.jsxs("div",{children:[r.jsx(o.Text,{size:"sm","data-role":"label",children:e}),r.jsx(o.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),jI=D.observer(({label:e,config:t,value:n,onChange:s})=>{const i=_e(),a=!!t.options_query_id,{state:l,error:c}=i.getDataStuffByID(t.options_query_id),u=l==="loading";return r.jsx(o.Select,{label:e,data:t.options,disabled:a?u:!1,value:n,onChange:s,maxDropdownHeight:500,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"},".mantine-Select-nothingFound":{fontSize:"0.75rem",textAlign:"left",padding:"4px 10px"}},itemComponent:_I,searchable:!c,nothingFound:r.jsx(Yo,{errorMessage:c}),clearable:t.clearable})});function wI({label:e,config:t,value:n,onChange:s}){return r.jsx(o.TextInput,{label:e,value:n||"",onChange:i=>s(i.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const CI=({rotate:e,onClick:t})=>r.jsx("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:r.jsx("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),SI=({expanded:e,isLeaf:t,value:n,onClick:s,...i})=>(n==="0-0-value"&&console.log(i),t?r.jsx("span",{style:{width:"14px",display:"inline-block"}}):r.jsx(CI,{rotate:e?"0":"-90",onClick:s,...i})),kI=({onClick:e})=>r.jsxs("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),r.jsx("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),r.jsx("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),r.jsx("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),TI=({onClick:e,...t})=>r.jsx(kI,{onClick:e,...t}),DI=o.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),MI=({disabled:e,classNames:t,styles:n,unstyled:s,radius:i,style:a,label:l,value:c,onChange:u,treeData:d,errorMessage:p,required:h,treeCheckStrictly:f})=>{const{t:m}=_.useTranslation(),{classes:y,cx:j}=DI({radius:i},{name:"FilterTreeSelectWidget",classNames:t,styles:n,unstyled:s}),[k,S]=g.useState(!1),T=I=>{S(I)},z=k&&(c==null?void 0:c.length)>0;return r.jsxs(o.Stack,{spacing:3,children:[r.jsxs(o.Group,{position:"apart",children:[r.jsxs(o.Text,{className:y.label,children:[l,h&&r.jsx("span",{className:y.required,"aria-hidden":"true",children:"*"})]}),z&&r.jsx(o.Tooltip,{label:m("filter.widget.common.x_selected",{count:c.length}),children:r.jsx(o.Badge,{children:c.length})})]}),r.jsx(pc,{disabled:e,allowClear:!0,treeCheckStrictly:f,labelInValue:!0,className:j(y.root,"check-select"),dropdownClassName:j(y.dropdown,""),onDropdownVisibleChange:T,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:a,listHeight:510,treeLine:!0,clearIcon:()=>r.jsx(o.CloseButton,{}),switcherIcon:SI,treeIcon:TI,maxTagTextLength:10,value:c,treeData:d,notFoundContent:r.jsx(Yo,{errorMessage:p}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:pc.SHOW_PARENT,onChange:u,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:()=>m("filter.widget.common.x_selected",{count:c.length})})]})},zI=D.observer(({label:e,config:t,value:n,onChange:s})=>{const{treeData:i,treeDataLoading:a,errorMessage:l}=t,c=f=>{const m=f.map(y=>y.value);s(m,!1)},u=g.useMemo(()=>t.initialSelection(n),[n,t.initialSelection]),d=t.min_width?t.min_width:"200px",h=!!t.options_query_id?a:!1;return r.jsx(MI,{disabled:h,style:{minWidth:"160px",width:d,maxWidth:h?d:"unset",borderColor:"#e9ecef"},value:[...u],onChange:c,treeData:i,errorMessage:l,label:e,required:t.required,treeCheckStrictly:t.treeCheckStrictly})}),II=D.observer(({filter:{type:e,config:t,key:n,...s},formFieldProps:i})=>{switch(e){case"select":return r.jsx(jI,{...s,...i,config:t});case"multi-select":return r.jsx(vI,{...s,...i,config:t});case"tree-select":return r.jsx(zI,{...s,...i,config:t});case"text-input":return r.jsx(wI,{...s,...i,config:t});case"date-range":return r.jsx(Ph,{...s,...i,config:t});case"checkbox":return r.jsx(pI,{...s,...i,config:t});default:return null}}),EI=D.observer(g.forwardRef(({filter:e,...t},n)=>r.jsx("div",{className:"filter-root",ref:n,children:r.jsx(ze,{children:r.jsx(II,{filter:e,formFieldProps:t})})}))),AI=({disabled:e})=>{const{searchButtonProps:t}=_u(),{children:n="Search",type:s,...i}=t;return r.jsx(o.Button,{color:"blue",size:"sm",type:"submit",...i,disabled:e||i.disabled,children:n})};function PI(e){const t=Y();g.useEffect(()=>{var n,s;(s=(n=t.filters).updatePreviewValues)==null||s.call(n,e)},[e])}const OI=({opened:e,toggle:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Group,{position:"right",ml:-4,mt:-4,mb:e?4:0,children:r.jsx(o.Button,{size:"xs",compact:!0,variant:"subtle",color:e?"gray":"blue",leftIcon:e?r.jsx(M.IconChevronsUp,{size:14}):r.jsx(M.IconChevronsDown,{size:14}),onClick:t,children:n(e?"filter.hide_filters":"filter.show_filters")})})},Oh=D.observer(function({view:t}){const[n,{toggle:s}]=he.useDisclosure(!0),i=_e(),{control:a,handleSubmit:l,reset:c}=b.useForm({defaultValues:i.filters.values,reValidateMode:"onBlur"}),u=b.useWatch({control:a});g.useEffect(()=>{c(i.filters.values)},[i.filters.values,c]),PI(u);const d=i.filters.visibleInView(t.id),p=g.useMemo(()=>d.every(y=>y.should_auto_submit),[d]),h=g.useMemo(()=>d.filter(y=>v.get(y,"config.required",!1)),[d]),f=g.useMemo(()=>h.length===0?!1:h.some(y=>!y.requiredAndPass(u[y.key])),[u,h]);if(d.length===0)return null;const m=(y,j)=>(k,S)=>{j(k),(y.should_auto_submit||S)&&i.filters.setValueByKey(y.key,k)};return r.jsxs("form",{onSubmit:l(i.filters.setValues),children:[r.jsx(OI,{opened:n,toggle:s}),r.jsx(o.Collapse,{in:n,children:r.jsxs(o.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:p?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[r.jsx(o.Group,{align:"flex-start",children:d.map(y=>r.jsx(b.Controller,{name:y.key,control:a,render:({field:j})=>r.jsx(EI,{filter:y,value:j.value,onChange:m(y,j.onChange)})},y.id))}),!p&&r.jsx(o.Group,{sx:{alignSelf:"flex-end"},children:r.jsx(AI,{disabled:f})})]})})]})}),LI={viewPanelInFullScreen:v.noop,inFullScreen:!1},ii=g.createContext(LI),Ko=x.types.model("MockContextMeta",{current:x.types.optional(x.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get keySet(){return new Set(this.keys)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},defaults(t){e.current={...t,...e.current}},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function Xo(e){return{current:e}}const BI=x.types.model("PanelStyleBorderMeta",{enabled:x.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),Lh=x.types.model("PanelStyleMeta",{border:BI}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),Bh=x.types.model("PanelTitleMeta",{show:x.types.optional(x.types.boolean,!0)}).views(e=>({get json(){const{show:t}=e;return{show:t}}})).actions(e=>({setShow(t){e.show=t}})),qh=x.types.model("VariableMeta",{name:x.types.string,size:x.types.string,weight:x.types.string,color:x.types.union(x.types.model({type:x.types.literal("static"),staticColor:x.types.string}),x.types.model({type:x.types.literal("continuous"),valueRange:x.types.array(x.types.number),colorRange:x.types.array(x.types.string)}),x.types.model({type:x.types.literal("piecewise")})),formatter:x.types.model({output:x.types.enumeration("Output",["number","percent"]),average:x.types.optional(x.types.boolean,!1),mantissa:x.types.number,trimMantissa:x.types.optional(x.types.boolean,!1),absolute:x.types.optional(x.types.boolean,!1)}),data_field:x.types.string,aggregation:x.types.union(x.types.model({type:x.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:x.types.frozen(),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("quantile"),config:x.types.model({p:x.types.number}),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("pick_record"),config:x.types.model({method:x.types.enumeration("Pick Record Method",["first","last"])}),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("custom"),config:x.types.model({func:x.types.string}),fallback:x.types.optional(x.types.string,"0")}))}).views(e=>({get json(){const{name:t,size:n,weight:s,color:i,formatter:a,data_field:l,aggregation:c}=e;return v.cloneDeep({name:t,size:n,color:i,weight:s,formatter:a,data_field:l,aggregation:c})}})),Vh=x.types.model("PanelVizMeta",{type:x.types.string,conf:x.types.frozen()}).views(e=>({get json(){return{conf:e.conf,type:e.type}}})).actions(e=>({setType(t){e.type=t},setConf(t){e.conf=t}})),Nh=x.types.model({id:x.types.string,name:x.types.optional(x.types.string,""),title:Bh,description:x.types.string,queryIDs:x.types.array(x.types.string),viz:Vh,style:Lh,variables:x.types.optional(x.types.array(qh),[])}).views(e=>({get json(){const{id:t,name:n,title:s,description:i,queryIDs:a}=e;return{id:t,viz:e.viz.json,name:n,style:e.style.json,title:s.json,queryIDs:[...a],variables:e.variables.map(l=>l.json),description:i}},get queryIDSet(){return new Set(e.queryIDs)}})).actions(e=>({setID(t){e.id=t},setName(t){e.name=t},setDescription(t){e.description=t},addQueryID(t){e.queryIDSet.has(t)||e.queryIDs.push(t)},removeQueryID(t){if(!e.queryIDSet.has(t))return;const n=new Set(e.queryIDSet);n.delete(t),e.queryIDs=x.cast(Array.from(n))},setQueryIDs(t){e.queryIDs=x.cast(t)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)}}));var ye=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e.Transform="transform",e))(ye||{});const $h=x.types.model("QueryMeta",{id:x.types.string,name:x.types.string,type:x.types.enumeration("DataSourceType",[ye.Postgresql,ye.MySQL,ye.HTTP,ye.Transform]),key:x.types.string,sql:x.types.string,pre_process:x.types.optional(x.types.string,""),post_process:x.types.optional(x.types.string,""),run_by:x.types.optional(x.types.array(x.types.string),[]),react_to:x.types.optional(x.types.array(x.types.string),[]),dep_query_ids:x.types.optional(x.types.array(x.types.string),[])}).views(e=>({get valid(){return e.id&&e.type&&e.key&&e.name?e.type===ye.HTTP?!!e.pre_process:!!e.sql:!1},get json(){const{id:t,name:n,type:s,key:i,sql:a,run_by:l,react_to:c,pre_process:u,post_process:d,dep_query_ids:p}=e;return $n({id:t,key:i,sql:a,name:n,type:s,run_by:l,react_to:c,pre_process:u,post_process:d,dep_query_ids:p})}})).actions(e=>({setName(t){e.name=t},setKey(t){e.key=t},setType(t){e.type=t},setSQL(t){e.sql=t},setRunBy(t){e.run_by.length=0,e.run_by.push(...t)},setReactTo(t){e.react_to.length=0,e.react_to.push(...t)},setPreProcess(t){e.pre_process=t},setPostProcess(t){e.post_process=t},setDependantQueryIDs(t){e.dep_query_ids.length=0,e.dep_query_ids.push(...t)}})),Fh=x.types.model("LayoutItemMeta",{id:x.types.identifier,panelID:x.types.string,x:x.types.number,y:x.types.maybeNull(x.types.number),w:x.types.number,h:x.types.number,moved:x.types.optional(x.types.boolean,!1),static:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{id:t,panelID:n,x:s,y:i,w:a,h:l,moved:c}=e;return{h:l,w:a,x:s,y:i===null?0:i,id:t,moved:c,static:e.static,panelID:n}},get contentModel(){return x.getRoot(e).content},get panel(){const{panelID:t}=e;return this.contentModel.panels.findByID(t)},get layoutProperies(){const{id:t,x:n,y:s,w:i,h:a,moved:l}=e;return{id:t,i:t,x:n,y:s===null?1/0:s,w:i,h:a,moved:l,static:e.static}}})).actions(e=>({set(t){const{isDraggable:n,x:s,y:i,w:a,h:l,moved:c}=t;e.x=s,e.y=i,e.w=a,e.h=l,e.moved=!!c,e.static=!!t.static},setWidth(t){e.w=t},setHeight(t){e.h=t}})),Gh=x.types.model("LayoutSetMeta",{id:x.types.identifier,name:x.types.string,breakpoint:x.types.number,list:x.types.optional(x.types.array(Fh),[])}).views(e=>({get json(){const{id:t,name:n,breakpoint:s,list:i}=e;return{id:t,name:n,breakpoint:s,list:i.map(a=>$n(a.json))}},jsonByPanelIDSet(t){const{id:n,name:s,breakpoint:i,list:a}=e;return{id:n,name:s,breakpoint:i,list:a.filter(l=>t.has(l.panelID)).map(l=>$n(l.json))}},findByID(t){return e.list.find(n=>n.id===t)},findByPanelID(t){return e.list.find(n=>n.panelID===t)}})).actions(e=>({setName(t){e.name=t},setBreakpoint(t){e.breakpoint=t},addLayout(t){e.list.push(t)},addNewLayout(t){e.list.push({id:Ut.v4(),panelID:t,x:0,y:1/0,w:18,h:300,static:!1,moved:!1})},removeByPanelID(t){const n=e.list.findIndex(s=>s.panelID===t);n>=0&&e.list.splice(n,1)},updateLayoutItem(t){const n=e.list.find(s=>s.id===t.i);if(!n){console.error("Trying to update a layout that doesn't exist"),console.log({strangeLayoutItem:t});return}n.set(t)}})),Wh=x.types.model("SQLSnippetMeta",{key:x.types.string,value:x.types.string}).views(e=>({get json(){const{key:t,value:n}=e;return{key:t,value:n}}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.value=t}}));var ce=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(ce||{});const Jo=x.types.model("FilterCheckboxConfigMeta",{_name:x.types.literal("checkbox"),description:x.types.optional(x.types.string,""),default_value:x.types.boolean}).views(e=>({get json(){const{_name:t,description:n,default_value:s}=e;return{_name:t,description:n,default_value:s}},get isDescriptionEmpty(){const{description:t}=e;return t===""||t==="<p></p>"}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDescription(t){e.description=t}})),Rh=()=>Jo.create({_name:"checkbox",description:"",default_value:!1});function Qh(e,t){return e.map(n=>{try{return n?P.tz(n,"UTC").format(t):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}const qI=x.types.model("FilterDateRangeConfigMeta",{_name:x.types.literal("date-range"),required:x.types.boolean,inputFormat:x.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:x.types.optional(x.types.array(x.types.union(x.types.string,x.types.null)),[null,null]),default_shortcut:x.types.optional(x.types.string,""),clearable:x.types.boolean,max_days:x.types.optional(x.types.number,0),allowSingleDateInRange:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{_name:t,max_days:n,required:s,clearable:i,inputFormat:a,default_value:l,default_shortcut:c,allowSingleDateInRange:u}=e;return{_name:t,max_days:n,required:s,clearable:i,inputFormat:a,default_value:Qh(l,a),default_shortcut:c,allowSingleDateInRange:u}},truthy(t){return Array.isArray(t)&&t.length===2&&t.every(n=>!!n)}})).actions(e=>({setFilterValue(t){try{const n=x.getParent(e);x.getParent(n,2).setValueByKey(n.key,t)}catch(n){console.error(n)}}})).actions(e=>({setRequired(t){e.required=t},setClearable(t){e.clearable=t},setInputFormat(t){e.inputFormat=t},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t),e.setFilterValue(t)},setDefaultShortcut(t){if(e.default_shortcut=t,!t)return;const n=Eh(e.default_shortcut);if(console.log(n),n){const s=n.map(i=>P(i).format(e.inputFormat));e.setFilterValue(s)}},setMaxDays(t){e.max_days=t,t>0&&(e.clearable=!0)},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),Zo=x.types.snapshotProcessor(qI,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>n===null?null:P.tz(n,"UTC").toISOString())}},postProcessor(e){const{default_value:t,...n}=e;return{...n,default_value:Qh(t,n.inputFormat)}}}),Uh=()=>Zo.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),VI=x.types.model({label:x.types.string,value:x.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),Ho=x.types.model("FilterConfigModel_BaseSelect",{static_options:x.types.optional(x.types.array(VI),[]),options_query_id:x.types.optional(x.types.string,""),default_selection_count:x.types.optional(x.types.number,0),required:x.types.optional(x.types.boolean,!1)}).views(e=>({get contentModel(){return x.getRoot(e).content},get filter(){return x.getParent(e)},get usingQuery(){return!!e.options_query_id}})).views(e=>({get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:n}=e.contentModel.getDataStuffByID(e.options_query_id);return n==="error"?[]:Array.isArray(t)?t.filter(s=>"label"in s&&"value"in s):[]}})).actions(e=>({setRequired(t){e.required=t},addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},setDefaultSelectionCount(t){e.default_selection_count=t},setOptionsQueryID(t){e.options_query_id=t??""}})),el=x.types.compose("FilterMultiSelectConfigMeta",x.types.model({_name:x.types.literal("multi-select"),min_width:x.types.optional(x.types.string,""),default_value:x.types.optional(x.types.array(x.types.string),[])}),Ho).views(e=>({get json(){const{_name:t,default_value:n,required:s,min_width:i,static_options:a,options_query_id:l,default_selection_count:c}=e;return $n({_name:t,required:!!s,min_width:i,default_value:n,static_options:a,options_query_id:l,default_selection_count:c})},get default_selection(){return e.usingQuery?e.options.slice(0,e.default_selection_count).map(t=>t.value):e.filter.formattedDefaultValue},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=x.cast(t)},setMinWidth(t){e.min_width=t},setDefaultSelection(){const t=x.getRoot(e).content.filters,n=x.getParent(e).key,s=new Set(e.options.map(a=>a.value)),i=(t.values[n]??[]).filter(a=>s.has(a));i.length>0?t.setValueByKey(n,i):t.setValueByKey(n,e.default_selection)}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>X.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),Yh=()=>el.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),tl=x.types.compose("FilterConfigModel_Select",x.types.model({_name:x.types.literal("select"),default_value:x.types.string,width:x.types.optional(x.types.string,""),clearable:x.types.optional(x.types.boolean,!1)}),Ho).views(e=>({get json(){const{_name:t,clearable:n,default_value:s,required:i,width:a,static_options:l,options_query_id:c,default_selection_count:u}=e;return $n({_name:t,width:a,required:i,clearable:n,default_value:s,static_options:l,options_query_id:c,default_selection_count:u})},truthy(t){return!!t},getSelectOption(t){return e.options.find(n=>n.value===t)},get default_selection(){return e.usingQuery?e.default_selection_count>0&&e.options.length>0?e.options[0].value:"":e.filter.formattedDefaultValue}})).actions(e=>({setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t},setClearable(t){e.clearable=t},setDefaultSelection(){var a;const t=x.getRoot(e).content.filters,n=x.getParent(e).key,s=t.values[n],i=(a=e.options.find(l=>l.value===s))==null?void 0:a.value;i?t.setValueByKey(n,i):t.setValueByKey(n,e.default_selection)}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>X.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!1,delay:0}))}})),Kh=()=>tl.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),nl=x.types.model("FilterTextInputConfigMeta",{_name:x.types.literal("text-input"),required:x.types.boolean,default_value:x.types.string}).views(e=>({get json(){const{_name:t,required:n,default_value:s}=e;return{_name:t,required:n,default_value:s}},truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),rl=()=>nl.create({_name:"text-input",required:!1,default_value:""});function NI(e){return Pg.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function $I(e){return e.map(t=>{const{label:n,description:s,...i}=t,a={...i,filterBasis:`${n}___${s??""}`,description:s,label:n};return s&&(a.label=g.createElement("div",{},[g.createElement(o.Text,{key:0,title:t.label},t.label),g.createElement(o.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description},t.description)])),a})}const sl=x.types.compose("FilterTreeSelectConfigMeta",x.types.model({_name:x.types.literal("tree-select"),min_width:x.types.optional(x.types.string,""),default_value:x.types.optional(x.types.array(x.types.string),[]),treeCheckStrictly:x.types.optional(x.types.boolean,!1)}),Ho).views(e=>({get json(){const{_name:t,default_value:n,required:s,min_width:i,static_options:a,options_query_id:l,default_selection_count:c,treeCheckStrictly:u}=e;return{_name:t,required:!!s,min_width:i,default_value:n,static_options:a,options_query_id:l,treeCheckStrictly:u,default_selection_count:c}},get plainData(){const{data:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeData(){const t=this.plainData,n=$I(t);return NI(n)},get errorMessage(){const{error:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeDataLoading(){const{state:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t==="loading"},get defaultSelection(){const t=e.filter.formattedDefaultValue;if(Array.isArray(t)&&t.length>0)return t;const{default_selection_count:n}=e;return n?this.treeData.slice(0,n).map(i=>i.value):[]},valueObjects(t){const n=new Set(t);return this.plainData.filter(s=>n.has(s.value))},initialSelection(t){return t?this.valueObjects(t):this.valueObjects(this.defaultSelection)},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=x.cast(t)},setMinWidth(t){e.min_width=t},setTreeCheckStrictly(t){e.treeCheckStrictly=t},applyDefaultSelection(){const t=x.getParent(e,1).key,n=e.contentModel.filters,s=n.values[t],i=new Set(e.plainData.map(l=>l.value)),a=(s??[]).filter(l=>i.has(l));a.length>0?n.setValueByKey(t,a):n.setValueByKey(t,e.defaultSelection)},afterCreate(){x.addDisposer(e,X.reaction(()=>JSON.stringify(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!0,delay:0}))}})),Xh=()=>sl.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),il=x.types.model("FilterMeta",{id:x.types.identifier,key:x.types.string,label:x.types.string,order:x.types.number,visibleInViewsIDs:x.types.array(x.types.string),auto_submit:x.types.optional(x.types.boolean,!1),default_value_func:x.types.optional(x.types.string,""),type:x.types.enumeration("DashboardFilterType",[ce.Select,ce.MultiSelect,ce.TreeSelect,ce.TextInput,ce.Checkbox,ce.DateRange]),config:x.types.union(tl,el,sl,nl,Jo,Zo)}).views(e=>({get contentModel(){return x.getRoot(e).content},get filters(){return this.contentModel.filters},get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==ce.TreeSelect},get usingDefaultValueFunc(){return!!e.default_value_func},get formattedDefaultValue(){return this.filters.formattedDefaultValues[e.key]},get auto_submit_supported(){return[ce.Select,ce.Checkbox,ce.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:n,label:s,order:i,visibleInViewsIDs:a,default_value_func:l,auto_submit:c,type:u,config:d}=e;return{id:t,key:n,type:u,label:s,order:i,config:d.json,auto_submit:c,visibleInViewsIDs:X.toJS(a),default_value_func:l}},get visibleInViewsIDSet(){return new Set(e.visibleInViewsIDs)},get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return v.get(e.config,"required",!1)?v.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setLabel(t){e.label=t},setOrder(t){e.order=t},setType(t){switch(t){case ce.Select:e.config=Kh();break;case ce.MultiSelect:e.config=Yh();break;case ce.TreeSelect:e.config=Xh();break;case ce.TextInput:e.config=rl();break;case ce.Checkbox:e.config=Rh();break;case ce.DateRange:e.config=Uh();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t},setDefaultValueFunc(t){e.default_value_func=t}}));var q=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(q||{});const al=x.types.model("ViewDivisionConfig",{_name:x.types.literal(q.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})),Jh=()=>al.create({_name:q.Division}),FI=x.types.model("CustomModalTitleModel",{enabled:x.types.optional(x.types.boolean,!1),func_content:x.types.optional(x.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:n}=e;return{enabled:t,func_content:n}},get value(){const{enabled:t,func_content:n}=e,s=x.getParent(e,2),i=x.getRoot(e);if(!t)return s.name;try{const a={filters:i.content.filters.values,context:i.context.current};return new Function(`return ${n}`)()(a)}catch(a){return console.error(a),s.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:n}){e.enabled=t,e.func_content=n}})),ai={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
453
|
+
`)},ol=x.types.model("ViewModalConfig",{_name:x.types.literal(q.Modal),width:x.types.string,height:x.types.string,custom_modal_title:x.types.optional(FI,ai)}).views(e=>({get json(){const{_name:t,width:n,height:s,custom_modal_title:i}=e;return{_name:t,width:n,height:s,custom_modal_title:i.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),Zh=()=>ol.create({_name:q.Modal,width:"90vw",height:"90vh"}),GI=x.types.model("ViewTabsTabModel",{id:x.types.identifier,name:x.types.string,view_id:x.types.string,color:x.types.optional(x.types.string,""),order:x.types.optional(x.types.number,0)}).views(e=>({get json(){const{id:t,name:n,view_id:s,color:i,order:a}=e;return{id:t,name:n,color:i,order:a,view_id:s}}})).actions(e=>({setName(t){e.name=t},setViewID(t){e.view_id=t},setColor(t){e.color=t},setOrder(t){e.order=t}})),ll=x.types.model("ViewTabsConfig",{_name:x.types.literal(q.Modal),tabs:x.types.optional(x.types.array(GI),[]),variant:x.types.optional(x.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:x.types.optional(x.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:n,orientation:s,tabs:i,grow:a}=e;return{grow:a,tabs:i.map(l=>l.json),_name:t,variant:n,orientation:s}},get tabsInOrder(){return v.sortBy(e.tabs,"order")}})).actions(e=>({setVariant(t){e.variant=t},setOrientation(t){e.orientation=t},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=x.cast(t)},addTab(){const t=he.randomId(),n={id:t,name:t,view_id:""};e.tabs.push(n)},removeTab(t){e.tabs.splice(t,1)}})),Hh=()=>ll.create({_name:q.Modal,tabs:[]}),ef=x.types.model({id:x.types.identifier,name:x.types.string,type:x.types.enumeration("EViewComponentType",[q.Division,q.Modal,q.Tabs]),config:x.types.union(al,ol,ll),panelIDs:x.types.optional(x.types.array(x.types.string),[])}).views(e=>({get json(){const{id:t,name:n,type:s,config:i}=e;return{id:t,name:n,type:s,config:i.json,panelIDs:e.panelIDs.map(a=>a)}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case q.Division:e.config=Jh();break;case q.Modal:e.config=Zh();break;case q.Tabs:e.config=Hh();break}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},appendPanelIDs(t){e.panelIDs.push(...t)},removePanelID(t){const n=e.panelIDs.filter(s=>s!==t);e.panelIDs.length=0,e.panelIDs.push(...n)}})),en="11.10.0",WI={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:q.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:en,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},cl=x.types.model("DataSourceMetaModel",{id:x.types.string,type:x.types.enumeration("DataSourceType",[ye.HTTP,ye.MySQL,ye.Postgresql]),key:x.types.string,config:x.types.frozen()}),tf=x.types.model("DataSourcesMetaModel",{list:x.types.optional(x.types.array(cl),[])}).views(e=>({find({type:t,key:n}){return e.list.find(s=>s.key===n&&s.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),nf=x.types.model({id:x.types.string,content:x.types.string,create_time:x.types.string,update_time:x.types.string,is_preset:x.types.boolean}),ul=x.types.model("GlobalSQLSnippetsMeta",{list:x.types.optional(x.types.array(nf),[])}).views(e=>({find(t){return e.list.find(n=>n.id===t)},get options(){return e.list.map(t=>({value:t.id,label:t.id}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),oi=x.types.model("ContextMeta",{current:x.types.optional(x.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function dl(e){return oi.create({current:e})}const pl=x.types.compose("ViewRenderModel",ef,x.types.model({tab:x.types.optional(x.types.string,"")})).views(e=>({get tabs(){return e.config.tabs},get tabInfo(){const t=this.tabs.find(n=>n.id===e.tab);return t?{id:t.id,name:t.name}:null},get tabView(){return e.type!==q.Tabs?null:this.tabs.find(t=>t.id===e.tab)},get tabViewID(){return this.tabView?this.tabView.view_id??"":""},get contentModel(){return x.getParent(e,3)},get panels(){if(e.type!==q.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs);const t=this.tabViewID,n=this.contentModel.views.findByID(t);return(n==null?void 0:n.panels)??[]},get renderViewIDs(){const t=[e.id];return e.type===q.Tabs&&t.push(this.tabViewID),t},async downloadScreenshot(t){const n=t.offsetWidth*2+10,s=t.offsetHeight*2+10,i=new fc,a=new Date().getTime(),l=await hc.toBlob(t,{bgcolor:"white",width:n,height:s,style:{transformOrigin:"0 0",transform:"scale(2)"}});i.file(`${e.name}_${a}.png`,l),i.file(`dashboard_state_${a}.json`,JSON.stringify(this.contentModel.dashboardState,null,4)),i.generateAsync({type:"blob"}).then(c=>{ts.saveAs(c,`${e.name}_${a}.zip`)}).catch(c=>{console.error(c),sn.notifications.show({color:"red",title:"Failed to download screenshot with dashboard state",message:c.message})})}})).actions(e=>({setTab(t){e.tab=t??""},setTabByTabInfo(t){e.tab=t.id??""}})),hl=x.types.model("ViewsRenderModel",{current:x.types.optional(x.types.array(pl),[]),visibleViewIDs:x.types.array(x.types.string)}).views(e=>({get json(){return e.current.map(t=>$n(t.json))},get idMap(){const t=new Map;return e.current.forEach(n=>{t.set(n.id,n)}),t},findByID(t){return e.current.find(n=>n.id===t)},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:n})=>n===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:n})=>t.has(n))},get firstVisibleTabsView(){return this.visibleViews.find(t=>t.type===q.Tabs)},get firstVisibleTabsViewActiveTab(){const t=this.firstVisibleTabsView;return t?t.tabInfo:null}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(s=>s)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const n=e.visibleViewIDs.findIndex(s=>s===t);n!==-1&&e.visibleViewIDs.splice(n,1)},setFirstVisibleTabsViewActiveTab(t){if(!t)return;const n=e.firstVisibleTabsView;n==null||n.setTabByTabInfo(t)}}));function rf(e,t){const n=e.length>0?[e[0].id]:[],s=e.map(i=>{const{_name:a=i.type}=i.config,l={...i,tab:"",config:{...i.config,_name:a},panelIDs:i.panelIDs};if(i.type===q.Tabs){const c=v.minBy(i.config.tabs,u=>u.order);l.tab=(c==null?void 0:c.id)??""}return l});return t&&(s[0].tab=t.id),{current:s,visibleViewIDs:n}}const RI=new Og.AsyncParser({withBOM:!0});async function sf(e){return!Array.isArray(e)||e.length===0?"":await RI.parse(e).promise()}async function QI(e,t){const n=await sf(t),s=new Blob([n],{type:"text/csv"});ts.saveAs(s,`${e}.csv`)}function af(e){const t=new fc,n=e.map(async({id:s,data:i})=>{const a=await sf(i);t.file(`${s}.csv`,a)});Promise.all(n).then(()=>{t.generateAsync({type:"blob"}).then(s=>{ts.saveAs(s,"dashboard_data.zip")})}).catch(s=>{console.error(s),sn.notifications.show({color:"red",title:"Failed to download data",message:s.message})})}function ir(e,t){const n=new Blob([t],{type:"application/json"});ts.saveAs(n,`${e}.json`)}const fl=Nh.views(e=>({get contentModel(){return x.getRoot(e).content}})).views(e=>({get queries(){return e.contentModel.queries.findByIDSet(e.queryIDSet)},get firstQuery(){return this.queries.length>0?this.queries[0]:null},get firstQueryData(){return this.firstQuery?this.firstQuery.data:[]},queryByID(t){return this.queries.find(n=>n.id===t)},get data(){return this.queries.reduce((t,n)=>(t[n.id]=n.data,t),{})},get variableStrings(){return cu(e.variables,this.data)},get variableValueMap(){const t={},n=this.data;return e.variables.reduce((s,i)=>{const a=Vt(i,n);return s[i.name]=rt(i,a),s},t),t},get variableStyleMap(){const t=this.variableValueMap,n={};return e.variables.reduce((s,i)=>{const a=_y(i.color,t[i.name]);return s[i.name]={color:a,"font-size":i.size,"font-weight":i.weight,variable:i},s},n),n},get dataLoading(){return this.queries.some(t=>t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(a=>!a.runByConditionsMet);if(t.length===0)return"";const n=new Set,s=new Set;t.forEach(a=>{const l=a.conditionNames;l.context.forEach(c=>n.add(c)),l.filters.forEach(c=>s.add(c))});const i=[];return n.size>0&&(console.log(n),i.push(`context: ${Array.from(n).join(", ")}`)),s.size>0&&i.push(`filter${s.size>1?"s":""}: ${Array.from(s).join(", ")}`),i.length===2&&i.splice(1,0,"and"),i.unshift("Waiting for"),i.join(" ")},get queryErrors(){return this.queries.map(t=>t.error).filter(t=>!!t)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading}})).actions(e=>({refreshData(){e.queries.forEach(t=>t.fetchData(!0))},downloadData(){e.contentModel.queries.downloadDataByQueryIDs(e.queryIDs)},getSchema(){const t=e.json;return t.viz.conf={...t.viz.conf,__INTERACTIONS:{},__OPERATIONS:{},__TRIGGERS:{}},{panel:t,queries:e.queries.map(n=>n.json),layouts:e.contentModel.layouts.jsonByPanelIDSet(new Set([e.id]))}},downloadSchema(){const{panel:t,queries:n,layouts:s}=this.getSchema(),a=JSON.stringify({panels:[t],definition:{queries:n},layouts:s,version:en},null,2),l=e.name;ir(l,a)}}));function of(e){return{id:e,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:Oo.name,conf:Oo.createConfig()},style:{border:{enabled:!0}}}}const gl=x.types.model("PanelsRenderModel",{list:x.types.optional(x.types.array(fl),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(n=>n.id===t)},get idMap(){const t=new Map;return e.list.forEach(n=>{t.set(n.id,n)}),t}})).views(e=>({panelsByIDs(t){const n=[];return t.forEach(s=>{const i=e.idMap.get(s);i?n.push(i):console.warn(`Panel is not found, id:${s}`)}),n}}));function lf(e){const t=e.config,n=t.default_value;if(n===void 0)return n;if(t._name==="date-range")try{if(t.default_shortcut){const i=Eh(t.default_shortcut);if(i)return i.map(a=>P(a).format(t.inputFormat))}const[...s]=n;return s.map(i=>i===null?i:P.tz(i,"UTC").format(t.inputFormat)??i)}catch(s){return console.error(s),n}return n}function UI(e,t){const n=e.default_value_func;try{return new Function(`return ${n}`)()(e,vt,t)}catch(s){return console.error(s),lf(e)}}function cf(e,t){var n;return(n=e.default_value_func)!=null&&n.trim()?UI(e,t):lf(e)}function uf(e,t){return e.reduce((n,s)=>(n[s.key]=cf(s,t),n),{})}const ml=x.types.model("FiltersRenderModel",{current:x.types.optional(x.types.array(il),[]),values:x.types.optional(x.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get valuesString(){return JSON.stringify(e.values)},get contentModel(){return x.getRoot(e).content},get context(){return this.contentModel.payloadForSQL.context},get initialValuesDep(){return JSON.stringify({filters:e.current.map(({default_value_func:t,config:n})=>({default_value_func:t,config:n})),context:this.contentModel.payloadForSQL.context})},get formattedDefaultValues(){return uf(this.json,this.contentModel.context)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get inOrder(){return v.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return v.sortBy(e.current.filter(n=>n.visibleInViewsIDSet.has(t)),"order")},get firstFilterValueKey(){return Object.keys(e.values)[0]??""},get keySet(){return new Set(e.current.map(t=>t.key))},get keyLabelMap(){return e.current.reduce((t,n)=>(t[n.key]=n.label,t),{})},getSelectOption(t){const n=this.findByID(t);if(!n||!("getSelectOption"in n.config))return null;const s=e.values[n.key];return n.config.getSelectOption(s)}})).actions(e=>({setValues(t){e.values=t},patchValues(t){e.values=v.defaults({},t,e.values)},setValueByKey(t,n){e.values={...e.values,[t]:n}},applyValuesPatch(t){e.values={...e.values,...t}},getValueByKey(t){return e.values[t]},getSchema(t,n){return{filters:e.findByIDSet(new Set(t)).map(a=>({...a.json,visibleInViewsIDs:n?a.json.visibleInViewsIDs:[]})),version:en}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t,!1),null,2);ir("Filters",n)}}));function xl(e,t,n,s){const i=v.defaults({},s,uf(e,{...n,...t}));return{current:e,values:i}}const df=$h.views(e=>({get rootModel(){return x.getRoot(e)},get contentModel(){return this.rootModel.content},get conditionOptions(){if(!x.isAlive(e))return[];const{context:t}=this.contentModel.payloadForSQL,n=Object.keys(t).map(l=>({group:"Context",label:l,value:`context.${l}`,description:void 0})),s=this.contentModel.filters.keyLabelOptions.map(l=>({group:"Filters",label:l.label,value:`filters.${l.value}`,description:l.value})),i=[...n,...s],a=new Set(i.map(l=>l.value));return e.run_by.forEach(l=>{a.has(l)||i.push({group:"Invalid",label:l,value:l})}),i},get unmetRunByConditions(){if(!x.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const n=this.contentModel.payloadForSQL;return t.filter(s=>{const i=v.get(n,s);return Array.isArray(i)?i.length===0:typeof i=="number"?Number.isNaN(i):!i})}})).views(e=>({get payload(){return e.contentModel.payloadForSQL},get formattedSQL(){return Ci(e.sql,this.payload)},get httpConfigString(){const{context:t,filters:n}=this.payload,{name:s,pre_process:i}=e.json,a=Iy(i,t,n);return console.groupCollapsed(`Request config for: ${s}`),console.log(a),console.groupEnd(),JSON.stringify(a)},get typedAsSQL(){return[ye.Postgresql,ye.MySQL].includes(e.type)},get typedAsHTTP(){return[ye.HTTP].includes(e.type)},get isTransform(){return e.type===ye.Transform},get reQueryKey(){const{react_to:t=[]}=e;if(t.length===0)return"";const n=e.contentModel.payloadForSQL,s=[...t].reduce((i,a)=>(i[a]=v.get(n,a),i),{});return JSON.stringify(s)},get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=e.contentModel.filters,n=e.unmetRunByConditions.filter(i=>i.startsWith("context.")).map(i=>i.replace("context.","")),s=e.unmetRunByConditions.filter(i=>i.startsWith("filters.")).map(i=>v.get({filters:t},i,i.replace("filters.",""))).filter(i=>!!i);return{context:n,filters:s}},get queries(){return x.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)},get dependencies(){if(!this.typedAsSQL)return[];const t=v.uniq(e.sql.match(vs.sqlSnippet)),n=v.uniq(e.sql.match(vs.filter)),s=v.uniq(e.sql.match(vs.context)),i=[];return t.forEach(a=>{i.push({type:"sql_snippet",key:a,valid:e.contentModel.sqlSnippets.keySet.has(a)})}),n.forEach(a=>{i.push({type:"filter",key:a,valid:e.contentModel.filters.keySet.has(a)})}),s.forEach(a=>{i.push({type:"context",key:a,valid:e.contentModel.mock_context.keySet.has(a)})}),i}})),yl=x.types.compose("QueryRenderModel",df,x.types.model({state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),data:x.types.optional(x.types.frozen([]),[]),error:x.types.frozen()})).views(e=>({get datasource(){const{key:t,type:n}=e;return e.rootModel.datasources.find({type:n,key:t})},get additionalQueryInfo(){return e.contentModel.getAdditionalQueryInfo(e.id)},get depQueryModels(){return e.contentModel.queries.findByIDSet(new Set(e.dep_query_ids))},get depQueryModelStates(){return this.depQueryModels.map(t=>t.state)},get depQueryModelStatesString(){return this.depQueryModelStates.toString()}})).views(e=>({get stateMessage(){if(e.state!=="idle")return"";if(!e.runByConditionsMet){const{context:t,filters:n}=e.conditionNames;if(t.length===0&&n.length===0)return"Waiting";const s=[];return t.length>0&&s.push(`context: ${t.join(", ")}`),n.length>0&&s.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),s.length===2&&s.splice(1,0,"and"),s.unshift("Waiting for"),s.join(" ")}return e.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:x.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const n=e.payload;e.data=yield*x.toGenerator(Vy({payload:n,name:e.name,query:e.json,additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(!At.isCancel(n)){e.data=[];const s=v.get(n,"message","unkown error");e.error=v.get(n,"response.data.detail.message",s),e.state="error"}}}}),runHTTP:x.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{type:n,key:s,post_process:i}=e.json;let a=JSON.parse(e.httpConfigString);a=Ey(e.datasource,a);const l=yield*x.toGenerator(Ny({type:n,key:s,configString:JSON.stringify(a),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=Ay(e.datasource,l),u=Py(i,c,e.contentModel.dashboardState);e.data=u,e.state="idle",e.error=null}catch(n){if(console.error(n),!At.isCancel(n)){e.data=[];const s=v.get(n,"message","unkown error");e.error=v.get(n,"response.data.detail.message",s),e.state="error"}}}}),runTransformation(){e.state="loading";try{const n=e.contentModel.queries.findByIDSet(new Set(e.dep_query_ids)).map(l=>({id:l.id,name:l.name,data:v.cloneDeep(l.data)})),s=e.contentModel.dashboardState,i=e.pre_process,a=new Function(`return ${i}`)()(n,s,vt);e.data=a,e.state="idle",e.error=null}catch(t){e.data=[],e.error=t.message,e.state="error"}}})).actions(e=>({fetchData:t=>{if(!e.inUse&&!t){console.debug(`🟡 Skipping query[${e.name}]`);return}return console.debug(`🔵 Running query[${e.name}]`),e.isTransform?e.runTransformation():e.typedAsHTTP?e.runHTTP():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>{var n;return e.isTransform?[e.inUse,e.id,e.key,e.dep_query_ids.toString(),e.pre_process,e.depQueryModelStatesString].join("--"):e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(n=e.datasource)==null?void 0:n.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},()=>e.fetchData(!1),{fireImmediately:!0,delay:0}))}})),bl=x.types.model("QueriesRenderModel",{current:x.types.optional(x.types.array(yl),[])}).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get contentModel(){return x.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:n,queries:s}=this.contentModel,i=[];t.visibleViews.forEach(c=>{c.panels.forEach(u=>{i.push(...u.queryIDs)})});const a=v.uniq(t.visibleViews.map(c=>c.renderViewIDs).flat());n.current.forEach(c=>{const u=v.get(c,"config.options_query_id");if(!u)return;a.some(p=>c.visibleInViewsIDSet.has(p))&&i.push(u)}),s.findByIDSet(new Set(i)).forEach(c=>{!c.isTransform||c.dep_query_ids.length===0||i.push(...c.dep_query_ids)});const l=new Set(i);return console.debug("QueryIDs:",l),l},isQueryInUse(t){return this.visibleQueryIDSet.has(t)}})).actions(e=>({downloadAllData(){const t=e.current.map(({name:n,data:s})=>({id:n,data:s}));af(t)},downloadDataByQueryIDs(t){const n=new Set(t),s=e.current.filter(i=>n.has(i.id)).map(({name:i,data:a})=>({id:i,data:a}));af(s)},downloadDataByQueryID(t){const n=e.findByID(t);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:s,data:i}=n;QI(s,i)},refetchDataByQueryID(t){const n=e.findByID(t);if(!n){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return n.fetchData(!0)},getSchema(t){return{definition:{queries:e.findByIDSet(new Set(t)).map(i=>i.json)},version:en}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t),null,2);ir("Queries",n)}}));function pf(e){return{current:e}}function hf({min:e,max:t}){const n=`${e}px`,s=Number.isFinite(t)?`${t}px`:"∞";return`[${n}, ${s})`}const vl=x.types.model("LayoutsRenderModel",{list:x.types.array(Gh),currentBreakpoint:x.types.string}).views(e=>({get json(){return e.list.map(t=>t.json)},jsonByPanelIDSet(t){return e.list.map(n=>n.jsonByPanelIDSet(t))},get root(){return x.getRoot(e)},get contentModel(){return this.root.content},get basisLayoutSet(){return e.list.find(t=>t.id==="basis")},get currentLayoutSet(){return e.list.find(t=>t.id===e.currentBreakpoint)},get currentLayoutRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentRangeText(){const t=this.currentLayoutRange;return hf(t)},get cols(){const t={};return e.list.forEach(n=>{t[n.id]=36}),t},get breakpoints(){const t={};return e.list.forEach(n=>{t[n.id]=n.breakpoint}),t},get breakpointNameRecord(){const t={};return e.list.forEach(n=>{t[n.name]=n.breakpoint}),t},get breakpointRanges(){const t=e.list.map(n=>({id:n.id,name:n.name,min:n.breakpoint,max:1/0,text:""}));return t.sort((n,s)=>n.min-s.min).forEach((n,s)=>{s!==t.length-1&&(n.max=t[s+1].min)}),t.forEach(n=>{n.text=hf(n)}),t},get breakpointsInfo(){return e.list.map(t=>({id:t.id,name:t.name,breakpoint:t.breakpoint})).sort((t,n)=>t.breakpoint-n.breakpoint)},get currentBreakpointRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentLayoutPreviewWidth(){const t=this.currentBreakpointRange;if(t)return t.max===1/0?t.min===0?void 0:t.min+1:t.max},items(t){const n=new Set(t);return this.currentLayoutSet.list.filter(i=>n.has(i.panelID))},gridLayouts(t){const n=new Set(t),s={};return e.list.forEach(i=>{s[i.id]=i.list.filter(a=>n.has(a.panelID)).map(a=>a.layoutProperies)}),s},findItemByPanelID(t){return this.currentLayoutSet.findByPanelID(t)}})).actions(e=>({setCurrentBreakpoint(t){console.log("🔴 onBreakpointChange:",t),e.currentBreakpoint=t},afterCreate(){x.addDisposer(e,X.reaction(()=>e.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),ff=Wh.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!x.getParent(e,2).findByKey(t)}})),_l=x.types.model("SQLSnippetsRenderModel",{current:x.types.optional(x.types.array(ff),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,n)=>(t[n.key]=n.value,t),{})},get keySet(){return new Set(e.current.map(t=>t.key))},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(n=>n.key===t)},findByKeySet(t){return e.current.filter(n=>t.has(n.key))}})).actions(e=>({getSchema(t){return{definition:{sqlSnippets:e.findByKeySet(new Set(t)).map(i=>i.json)},version:en}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t),null,2);ir("SQL Snippets",n)}}));function gf(e){return{current:e}}function Rr(e,t,n,s){return e.reduce((i,a)=>{try{i[a[t]]=wi(a[n],s)}catch(l){i[a[t]]=l.message}return i},{})}class mf{constructor(t){B(this,"origin");B(this,"copy");this.origin=t,this.copy=x.clone(t),X.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!v.isEqual(x.getSnapshot(this.origin),x.getSnapshot(this.copy))}commit(){x.applySnapshot(this.origin,x.getSnapshot(this.copy))}reset(){x.applySnapshot(this.copy,x.getSnapshot(this.origin))}update(t){x.applySnapshot(this.copy,t)}}const xf=e=>new mf(e),YI=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),{panel:n}=Ge(),s=n.realQueryOptions,i=a=>{t.editor.open(["_QUERIES_",a])};return s.length===0?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{label:e(s.length>1?"query.labels":"query.label"),labelPosition:"center"}),s.map(a=>r.jsx(o.Menu.Item,{onClick:()=>i(a.value),icon:r.jsx(M.IconDatabase,{size:14}),children:a.label},a.value))]})}),KI=D.observer(({view:e,title:t})=>{const{t:n}=_.useTranslation(),s=Z(),i=Y(),a=lt.useModals(),{panel:l,downloadPanelScreenshot:c}=Ge(),{id:u}=l,{viewPanelInFullScreen:d,inFullScreen:p}=g.useContext(ii),h=()=>{i.duplicatePanelByID(u,e.id)},f=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u])},m=()=>a.openConfirmModal({title:`${n("panel.delete")}?`,labels:{confirm:n("common.actions.confirm"),cancel:n("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.removePanelByID(u,e.id),confirmProps:{color:"red"},zIndex:320}),y=g.useCallback(()=>{d(u)},[u,d]),j=!p&&e.type!==q.Modal;return r.jsx(r.Fragment,{children:r.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:r.jsxs(o.Menu,{withinPortal:!0,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{onClick:l.refreshData,icon:r.jsx(V.Refresh,{size:14}),children:n("common.actions.refresh")}),r.jsx(o.Menu.Item,{onClick:l.downloadData,icon:r.jsx(V.Download,{size:14}),children:n("common.actions.download_data")}),r.jsx(o.Menu.Item,{onClick:l.downloadSchema,icon:r.jsx(M.IconCode,{size:14}),children:n("common.actions.download_schema")}),r.jsx(o.Menu.Item,{onClick:c,icon:r.jsx(M.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),j&&r.jsx(o.Menu.Item,{onClick:y,icon:r.jsx(V.ArrowsMaximize,{size:14}),disabled:!0,children:n("common.actions.enter_fullscreen")}),r.jsx(YI,{}),r.jsx(o.Divider,{label:n("common.actions.edit"),labelPosition:"center"}),r.jsx(o.Menu.Item,{onClick:f,icon:r.jsx(V.Settings,{size:14}),children:n("common.titles.settings")}),r.jsx(o.Menu.Item,{onClick:h,icon:r.jsx(V.Copy,{size:14}),children:n("common.actions.duplicate")}),r.jsx(o.Menu.Item,{color:"red",onClick:m,icon:r.jsx(V.Trash,{size:14}),children:n("common.actions.delete")})]})]})})})});function XI(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const jl=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState(!1),{panel:s}=St();return XI(s.description)?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:()=>n(!1),title:s.title.show?s.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:r.jsx(vr,{value:s.description,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}}})}),r.jsx(o.Tooltip,{label:e("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:r.jsx(V.InfoCircle,{size:20})})})]})}),VL="",JI=D.observer(function(){const{panel:t}=St(),{name:n,title:s}=t;return s.show?r.jsx(o.Group,{grow:!0,position:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:r.jsx(o.Text,{align:"center",lineClamp:1,className:"panel-title-text",children:n})}):null});function ZI(e){const t=g.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const s=t.current;if(!s)return;const i=s.offsetWidth*2,a=s.offsetHeight*2;hc.toBlob(t.current,{bgcolor:"white",width:i,height:a,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(l=>{window.saveAs(l,`${e.name?e.name:e.viz.type}.png`)})}}}var yf=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(yf||{}),li=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(li||{});class HI{constructor(t){B(this,"vizInstance");B(this,"operationManager");B(this,"triggerManager");B(this,"vizManager");B(this,"runningMigration");B(this,"panelModel");B(this,"status","notStarted");this.panelModel=t.getRequired(je.instanceScope.panelModel),this.vizInstance=t.getRequired(je.instanceScope.vizInstance),this.operationManager=t.getRequired(je.instanceScope.operationManager),this.triggerManager=t.getRequired(je.instanceScope.triggerManager),this.vizManager=t.getRequired(je.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(t=>(this.status="done",t))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(n)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return t.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function bf(e){const{panel:t}=St();return g.useCallback(n=>{const s=n.getRequired(je.vizManager),i=s.resolveComponent(e.viz.type);return n.createScoped().provideFactory(je.instanceScope.vizInstance,()=>s.getOrCreateInstance(e)).provideFactory(je.instanceScope.interactionManager,a=>{const l=a.getRequired(je.instanceScope.vizInstance);return new la(l,i,Cs)}).provideFactory(je.instanceScope.operationManager,a=>a.getRequired(je.instanceScope.interactionManager).operationManager).provideFactory(je.instanceScope.triggerManager,a=>a.getRequired(je.instanceScope.interactionManager).triggerManager).provideValue(je.instanceScope.panelModel,t).provideFactory(je.instanceScope.migrator,a=>new HI(a))},[e.viz.type,e.viz.conf])}function vf(e){const[t,n]=g.useState(!1),s=Ih().getRequired(je.instanceScope.migrator);return W.useAsyncEffect(async()=>{const i=s.status===li.notStarted;n(s.status===li.done),s.status===li.notStarted&&s.runMigration().then(a=>{a===yf.migrated&&i&&(e==null||e())}).finally(()=>{n(!0)})},[s]),t}function _f(e,t){const n=Ih().getRequired(je.instanceScope.vizInstance);return g.useEffect(()=>(n.instanceData.setItem(null,t.viz.conf),n.instanceData.watchItem(null,s=>{e(s)})),[e,t.viz.type]),n}function eE({setVizConf:e,...t}){const{panel:n}=t,s=_f(e,n),i=vf(()=>{sn.showNotification({title:`${n.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return W.useAsyncEffect(async()=>{await s.instanceData.setItem(null,n.viz.conf)},[s,n.viz.type]),i?r.jsx(Wy,{...t}):r.jsx(o.Text,{children:"Checking update..."})}function tE(e){const{panel:t,setVizConf:n}=e;_f(n,t);const{inEditMode:s}=g.useContext(js);return vf(()=>{s&&sn.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?r.jsx(Gy,{...e}):r.jsx(o.Text,{children:"Checking update"})}const NL="";function nE(e,t){const{vizManager:n}=g.useContext(Gt),{panel:{viz:s,title:i,id:a,name:l,description:c,queryIDs:u,variables:d}}=St(),p={id:a,name:l,title:i,description:c,queryIDs:u,viz:s},h=bf(p);try{return n.resolveComponent(s.type),r.jsx(si,{configure:h,children:r.jsx(tE,{setVizConf:s.setConf,panel:p,measure:t,data:e,variables:d,vizManager:n})})}catch(f){return console.info(v.get(f,"message")),null}}const jf=D.observer(function({data:t}){const{ref:n,width:s,height:i}=he.useElementSize(),a=nE(t,{w:s,h:i}),l=s>0&&i>0;return r.jsx("div",{className:"viz-root",ref:n,children:r.jsx(o.Box,{sx:{width:s,height:i,overflow:"hidden"},children:l&&r.jsx(ze,{children:a})})})}),wf=D.observer(({panel:e})=>r.jsxs(o.Stack,{children:[e.queryErrors.map((t,n)=>r.jsx(o.Text,{color:"red",size:"sm",align:"center",sx:{fontFamily:"monospace"},children:t},`${n}-${t}`)),r.jsx(o.Text,{color:"gray",align:"center",size:"sm",children:e.queryStateMessages})]})),wl=D.observer(({panel:e})=>r.jsxs(o.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[r.jsx(o.LoadingOverlay,{visible:e.dataLoading,exitTransitionDuration:0}),!e.canRenderViz&&r.jsx(wf,{panel:e}),e.canRenderViz&&r.jsx(jf,{data:e.data})]})),rE={border:"1px solid #e9ecef"},Cf=D.observer(({panel:e,panelStyle:t,dropdownContent:n})=>{const{ref:s,downloadPanelScreenshot:i}=ZI(e);return e.title.show,r.jsx(ra,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:i},children:r.jsxs(o.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,ref:s,p:0,sx:{...rE,...t},children:[r.jsx(o.Box,{className:"panel-description-popover-wrapper",children:r.jsx(jl,{})}),n,r.jsx(JI,{}),r.jsx(wl,{panel:e})]})})}),sE={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function iE(e){return e.style.border.enabled?{}:sE}const Sf=D.observer(function({panel:t,view:n}){const s=iE(t);return r.jsx(Cf,{panel:t,panelStyle:s,dropdownContent:r.jsx(KI,{view:n,title:t.name})})});function aE(e){return!["richText","button"].includes(e)}const oE=D.observer(({view:e,title:t})=>{const{t:n}=_.useTranslation(),{panel:s,downloadPanelScreenshot:i}=St(),{id:a}=s,{viewPanelInFullScreen:l,inFullScreen:c}=g.useContext(ii),u=g.useCallback(()=>{l(a)},[a,l]),d=!c&&e.type!==q.Modal;return aE(s.viz.type)?r.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:r.jsxs(o.Menu,{withinPortal:!0,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Box,{className:"panel-dropdown-target"})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{onClick:s.refreshData,icon:r.jsx(V.Refresh,{size:14}),children:n("common.actions.refresh")}),r.jsx(o.Menu.Item,{onClick:s.downloadData,icon:r.jsx(V.Download,{size:14}),children:n("common.actions.download_data")}),r.jsx(o.Menu.Item,{onClick:i,icon:r.jsx(M.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),d&&r.jsx(o.Menu.Item,{onClick:u,icon:r.jsx(V.ArrowsMaximize,{size:14}),children:n("common.actions.enter_fullscreen")})]})]})}):null});function lE(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const Cl=D.observer(({panel:e,view:t})=>{const n=lE(e);return r.jsx(Cf,{panel:e,panelStyle:n,dropdownContent:r.jsx(oE,{title:e.name,view:t})})}),cE={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},kf=D.observer(function({view:t,panel:n,exitFullScreen:s}){return r.jsx(o.Modal,{opened:!0,fullScreen:!0,onClose:s,title:r.jsx(o.Button,{color:"blue",size:"xs",onClick:s,leftIcon:r.jsx(V.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:cE,children:r.jsx(o.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:r.jsx(Cl,{view:t,panel:n})})})});function Tf(e,t,n){const{panels:s}=_e(),i=e.id==="Main",[a,l]=g.useState(()=>i&&s.findByID(t)?t:null),c=g.useCallback(h=>{l(h),i&&n(h)},[i,n]),u=g.useCallback(()=>{l(null),i&&n("")},[i,n]),d=a?s.findByID(a):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const $L="",uE=g.forwardRef(({h:e},t)=>r.jsx(o.ActionIcon,{ref:t,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:e>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:r.jsx(V.ArrowsMove,{size:16})})),dE=g.forwardRef(({handleAxis:e,...t},n)=>r.jsx(o.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:r.jsx(V.ChevronDownRight,{size:16})})),pE=es.WidthProvider(es.Responsive),hE=D.observer(({view:e,className:t="layout"})=>{const s=Y().layouts,i=s.items(e.panelIDs),a=s.gridLayouts(e.panelIDs),l=(d,p,h,f)=>{console.log("🔴 onResize",d),h.h<30&&(h.h=30,f.h=30),h.w<4&&(h.w=4,f.w=4)},c=(d,p,h)=>{console.log("🔴 onResizeStop",{layouts:d,oldItem:p,newItem:h}),s.updateCurrentLayoutItem(h)},u=(d,p,h)=>{console.log("🔴 onDragStop",{layouts:d,oldItem:p,newItem:h}),s.updateCurrentLayoutItems(d)};return r.jsx(pE,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:s.cols,layouts:a,draggableHandle:".react-grid-customDragHandle",resizeHandle:r.jsx(dE,{}),onResize:l,breakpoints:s.breakpoints,onBreakpointChange:s.setCurrentBreakpoint,onResizeStop:c,onDragStop:u,width:s.currentLayoutPreviewWidth,children:i.map(d=>r.jsxs("div",{"data-grid":d.layoutProperies,className:"panel-grid-item",children:[r.jsx(uE,{h:d.h}),r.jsx(Sf,{view:e,panel:d.panel})]},d.id))})}),fE=es.WidthProvider(es.Responsive),gE=D.observer(({view:e,className:t="layout"})=>{const n=_e(),s=n.layouts.items(e.panelIDs),i=n.layouts.gridLayouts(e.panelIDs);return r.jsx(fE,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:n.layouts.cols,layouts:i,breakpoints:n.layouts.breakpoints,onBreakpointChange:n.layouts.setCurrentBreakpoint,children:s.map(a=>r.jsx("div",{"data-grid":a.layoutProperies,className:"panel-grid-item",children:r.jsx(Cl,{view:e,panel:a.panel})},a.id))})});function Sl(e){const t=g.useRef(null);return{ref:t,downloadScreenshot:()=>{var i;const s=(i=t.current)==null?void 0:i.querySelector(".react-grid-layout");s&&e.downloadScreenshot(s)}}}const mE=D.observer(({downloadScreenshot:e})=>{const{t}=_.useTranslation(),[n,{setTrue:s,setFalse:i}]=W.useBoolean(!1),a=bu(),l=_e(),c=()=>{const u=JSON.stringify(l.contentJSON,null,2),d=`${a.name}__${l.name}`;ir(d,u)};return r.jsxs(o.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:r.jsx(o.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:s,onMouseLeave:i,sx:{opacity:n?1:.6,transform:`translateX(${n?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:r.jsx(M.IconShare3,{size:"1rem"})})})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{icon:r.jsx(M.IconCamera,{size:14}),onClick:e,children:t("common.actions.download_screenshot")}),r.jsx(o.Menu.Divider,{}),r.jsx(o.Menu.Item,{icon:r.jsx(M.IconDownload,{size:14}),onClick:l.queries.downloadAllData,children:t("common.actions.download_data")}),r.jsx(o.Menu.Item,{icon:r.jsx(M.IconCode,{size:14}),onClick:c,children:t("common.actions.download_schema")})]})]})}),Df=D.observer(({children:e,view:t,sx:n={}})=>{const{ref:s,downloadScreenshot:i}=Sl(t);return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{ref:s,pt:10,pb:10,sx:n,children:e}),r.jsx(mE,{downloadScreenshot:i})]})}),Mf=D.observer(({downloadScreenshot:e})=>r.jsx(o.ActionIcon,{className:"download-screenshot-button",color:"blue",onClick:e,children:r.jsx(M.IconCamera,{size:14})})),xE=D.observer(({children:e,view:t})=>{const n=_e(),s=t.config,i=n.views.visibleViewIDs.includes(t.id),a=()=>n.views.rmVisibleViewID(t.id),{ref:l,downloadScreenshot:c}=Sl(t);return r.jsx(o.Modal,{size:s.width,centered:!0,opened:i,onClose:a,withCloseButton:!1,title:r.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[r.jsx(o.Box,{children:s.custom_modal_title.value}),r.jsx(Mf,{downloadScreenshot:c})]}),trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:s.height,overflow:"auto",position:"relative",paddingBottom:10},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:r.jsx(o.Box,{ref:l,children:e})})}),yE=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},bE=D.observer(({view:e})=>{const t=_e(),n=e.config;return r.jsxs(o.Tabs,{className:"render-view-tabs",variant:n.variant,orientation:n.orientation,value:e.tab,onTabChange:e.setTab,styles:{root:{height:"100%",overflow:n.orientation==="horizontal"?"hidden":"auto"},panel:{padding:n.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[r.jsx(o.Tabs.List,{grow:n.grow,children:n.tabsInOrder.map(s=>r.jsx(o.Tabs.Tab,{value:s.id,sx:yE(s),disabled:!s.view_id,children:s.name??s.id},s.id))}),n.tabsInOrder.map(s=>{const i=t.views.findByID(s.view_id);return i?r.jsx(o.Tabs.Panel,{value:s.id,children:r.jsx(ci,{view:i})},s.id):null})]})}),vE=D.observer(({view:e,children:t})=>{switch(e.type){case q.Modal:return r.jsx(xE,{view:e,children:t});case q.Tabs:return r.jsx(bE,{view:e});case q.Division:default:return r.jsx(Df,{view:e,children:t})}}),_E=D.observer(({children:e,view:t})=>{const s=Y().layouts,[i,a]=he.useResizeObserver();return g.useEffect(()=>{s.setCurrentLayoutWrapperWidth(a.width)},[a.width]),r.jsx(o.Box,{sx:{height:"100%"},ref:i,children:r.jsx(o.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:s.currentLayoutPreviewWidth??"100%",transform:`scale(${s.divisionPreviewScale})`,transformOrigin:"0 0"},children:r.jsx(Df,{view:t,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:e})})})});function zf(e){return e.replace(/(vw|vh)/,"%")}const jE=D.observer(({children:e,view:t})=>{const n=t.config,{width:s,height:i}=g.useMemo(()=>({width:zf(n.width),height:zf(n.height)}),[n.width,n.height]),{ref:a,downloadScreenshot:l}=Sl(t);return r.jsx(o.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:r.jsx(o.Modal,{size:n.width,opened:!0,onClose:v.noop,withCloseButton:!1,title:r.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[r.jsx(o.Box,{children:n.custom_modal_title.value}),r.jsx(Mf,{downloadScreenshot:l})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:s,height:i,maxHeight:i},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:r.jsx(o.Box,{ref:a,children:e})})})}),wE=({variant:e,orientation:t})=>{const n={root:{height:"100%",overflow:"hidden"},tabsList:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(n.tab.paddingTop="6px",n.tab.paddingBottom="6px"),t==="vertical"&&(n.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},n.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),n},CE=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},SE=D.observer(({view:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Y(),i=g.useMemo(()=>s.views.options.filter(u=>u.type===q.Division),[e.id,s.views.options]),a=e.config,l=u=>n.openConfirmModal({title:`${t("view.component.tabs.tab.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{a.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),c=a.tabs.length===0;return r.jsxs(o.Tabs,{className:"preview-view-tabs",variant:a.variant,orientation:a.orientation,value:e.tab,onTabChange:e.setTab,styles:wE(a),children:[r.jsxs(o.Tabs.List,{grow:a.grow,children:[a.tabsInOrder.map(u=>r.jsx(o.Tabs.Tab,{value:u.id,sx:CE(u),children:u.name??u.id},u.id)),r.jsx(o.Tabs.Tab,{onClick:a.addTab,value:"add",className:"add-a-tab",children:r.jsx(V.Plus,{size:18,color:"#228be6"})})]}),a.tabsInOrder.map((u,d)=>{const p=s.views.findByID(u.view_id);return r.jsxs(o.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[r.jsxs(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[r.jsx(o.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),r.jsxs(o.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[r.jsx(o.TextInput,{label:t("view.component.tabs.tab.name"),required:!0,value:u.name,onChange:h=>u.setName(h.currentTarget.value)}),r.jsx(o.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:i}),r.jsx(o.NumberInput,{label:t("view.component.tabs.tab.order"),required:!0,value:u.order,onChange:h=>u.setOrder(h||0),min:0,max:1e3,step:1}),r.jsx(o.ColorInput,{label:t("view.component.tabs.tab.color"),value:u.color,onChange:u.setColor,disabled:a.variant!=="default"}),p&&r.jsx(o.Button,{mt:20,variant:"gradient",leftIcon:r.jsx(M.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>s.views.setIDOfVIE(p.id),children:t("view.component.tabs.tab.switch_to_view",{name:p.name})}),r.jsx(o.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>l(d),disabled:c,leftIcon:r.jsx(M.IconTrash,{size:14}),children:t("view.component.tabs.tab.delete")})]})]}),p&&r.jsx(ci,{view:p})]},u.id)})]})}),kE=D.observer(({view:e,children:t})=>{switch(e.type){case q.Modal:return r.jsx(jE,{view:e,children:t});case q.Tabs:return r.jsx(SE,{view:e});case q.Division:default:return r.jsx(_E,{view:e,children:t})}}),If=D.observer(function({view:t}){const s=Y().layouts.divisionPreviewScale!==1;return r.jsx(ii.Provider,{value:{viewPanelInFullScreen:v.noop,inFullScreen:!1},children:r.jsx(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:s?"transparent":"#efefef"},children:r.jsx(kE,{view:t,children:r.jsxs(o.Box,{sx:{position:"relative"},children:[r.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:r.jsx(Oh,{view:t})}),r.jsx(hE,{view:t})]})})})})}),ci=D.observer(function({view:t}){const{fullScreenPanelID:n,setFullScreenPanelID:s}=ku(),{viewPanelInFullScreen:i,exitFullScreen:a,inFullScreen:l,fullScreenPanel:c}=Tf(t,n,s);return r.jsx(ii.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:l},children:r.jsxs(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===q.Modal?"0 !important":"100%"},children:[l&&r.jsx(kf,{view:t,panel:c,exitFullScreen:a}),r.jsx(vE,{view:t,children:r.jsxs(o.Box,{sx:{position:"relative"},children:[!l&&r.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:r.jsx(Oh,{view:t})}),!l&&r.jsx(gE,{view:t})]})})]})})});var Ef=(e=>(e.Use="use",e.Edit="edit",e))(Ef||{});const TE={[q.Division]:"Division",[q.Tabs]:"Tabs",[q.Modal]:"Modal"},Af={[q.Division]:"rgba(255, 0, 0, 0.2)",[q.Modal]:"rgba(0, 0, 0, 0.2)",[q.Tabs]:"rgba(255, 200, 100, 0.4)"},DE={[q.Division]:"#ff4000",[q.Modal]:"#000",[q.Tabs]:"#ffad18"};function ME(e,t,n){x.addDisposer(e,x.addMiddleware(e,(s,i)=>{i(s,()=>{x.getType(s.context)===t&&s.type==="action"&&n(s.name,s.context)})}))}const Pf=x.types.compose("FiltersModel",ml,x.types.model("FiltersModel",{previewValues:x.types.optional(x.types.frozen(),{})})).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get keySet(){return new Set(e.current.map(t=>t.key))},get options(){return e.current.map(t=>({label:t.label??t.id,value:t.id,_type:"filter"}))},get selects(){return e.current.filter(t=>t.type===ce.Select).map(t=>({label:t.label??t.id,value:t.id}))},get keyLabelOptions(){return e.current.map(t=>({label:t.label??t.key,value:t.key}))},get sortedList(){return v.sortBy(e.current,t=>t.label.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.idSet.has(s.id));e.current.push(...n)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(s=>s.id===t);n>=0&&e.current.splice(n,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){ME(e.current,il,(n,s)=>{if(n==="setType"){const i=cf(s.config.default_value,s.config);e.setValueByKey(s.key,i),e.updatePreviewValues({...e.previewValues,[s.key]:i})}})}return{afterCreate(){t()}}}),Of=yl.views(e=>({get canPreviewData(){return e.isTransform?e.dep_query_ids.length>0&&!!e.pre_process:!!e.datasource},get guideToPreviewData(){return e.isTransform?"Need to complete settings in Transform tab":"Need to pick a Data Source first"}})),Lf=x.types.compose("QueriesModel",bl,x.types.model({current:x.types.optional(x.types.array(Of),[])})).views(e=>({get options(){const t=e.current.map(n=>({value:n.id,label:n.name,_type:"query"}));return v.sortBy(t,n=>n.label.toLowerCase())},get optionsWithoutTransform(){const t=e.current.filter(n=>n.type!==ye.Transform).map(n=>({value:n.id,label:n.name,_type:"query"}));return v.sortBy(t,n=>n.label.toLowerCase())},get sortedList(){return v.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.idSet.has(s.id));e.current.push(...n)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},removeQuery(t){const n=e.current.find(s=>s.id===t);n&&(x.detach(n),e.current.remove(n))},removeQueries(t){const n=new Set(t);e.current.forEach(i=>{n.has(i.id)&&x.detach(i)});const s=[...e.current];v.remove(s,i=>n.has(i.id)),e.current=x.cast(s)}})),Bf=_l.views(e=>({get sortedList(){return v.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(n=>({label:n.key,value:n.key,_type:"sql_snippet"}));return v.sortBy(t,n=>n.label.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.keySet.has(s.key));e.current.push(...n)},remove(t){e.current.splice(t,1)},removeByKey(t){const n=e.current.findIndex(s=>s.key===t);n>=0&&e.current.splice(n,1)},removeByKeys(t){const n=new Set(t);e.current.forEach(i=>{n.has(i.key)&&x.detach(i)});const s=[...e.current];v.remove(s,i=>n.has(i.key)),e.current=x.cast(s)},replaceByIndex(t,n){e.current.splice(t,1,n)}})),zE=x.types.model({data:x.types.optional(x.types.frozen(),[]),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),IE=x.types.model({data:x.types.optional(x.types.frozen(),[]),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),EE=x.types.model({page:x.types.optional(x.types.number,1),limit:x.types.optional(x.types.number,20),data:x.types.optional(x.types.frozen(),[]),total:x.types.optional(x.types.number,0),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get keywords(){return x.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:n}=x.getParent(e,1);return`${n}||${t}`}})).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0},get maxPage(){return Math.ceil(e.total/e.limit)},get offset(){return(e.page-1)*e.limit},get countSql(){const{table_name:t,table_schema:n}=e.keywords;return`
|
|
454
454
|
SELECT count(*) AS total
|
|
455
455
|
FROM ${n}.${t}
|
|
456
|
-
`}})).actions(e=>({setPage(t){e.page=t},resetPage(){e.page=1},setLimit(t){e.limit=t}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>e.keywordString,e.resetPage,{fireImmediately:!1,delay:0})),x.addDisposer(e,X.reaction(()=>e.limit,e.resetPage,{fireImmediately:!1,delay:0}))}})),EE=x.types.model({data:x.types.optional(x.types.frozen(),{}),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return Object.keys(e.data).length===0}})),AE=x.types.compose("DataSourceModel",cl,x.types.model({tables:x.types.optional(EE,{}),columns:x.types.optional(ME,{}),tableData:x.types.optional(IE,{}),indexes:x.types.optional(zE,{}),table_schema:x.types.optional(x.types.string,""),table_name:x.types.optional(x.types.string,"")})).views(e=>({get sqlDataSourceType(){return e.type},get reloadConditionString(){const{type:t,table_name:n,table_schema:s}=e;return`${t};${n};${s}`}})).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(e=>({setKeywords(t,n){e.table_schema=t,e.table_name=n}})).actions(e=>({initKeywords(){if(e.tables.empty)return;const t=Object.keys(e.tables.data)[0],n=e.tables.data[t][0].table_name;e.setKeywords(t,n)}})).actions(e=>{const t=x.flow(function*(){var n;(n=e.controllers.tables)==null||n.abort(),e.controllers.tables=new AbortController,e.tables.state="loading";try{const s=yield*x.toGenerator(Ot.structure(e.controllers.tables.signal)({query_type:"TABLES",type:e.sqlDataSourceType,key:e.key,table_schema:"",table_name:""},{params:{query_type:"TABLES"}}));e.tables.data=v.groupBy(s,"table_schema"),e.tables.state="idle",e.tables.error=null,e.initKeywords()}catch(s){if(!At.isCancel(s)){e.tables.data={};const i=v.get(s,"message","unkown error");e.tables.error=v.get(s,"response.data.detail.message",i),e.tables.state="error"}}});return{loadTables:t,loadTablesIfEmpty(){e.tables.empty&&t()},loadColumns:x.flow(function*(){var n;(n=e.controllers.columns)==null||n.abort(),e.controllers.columns=new AbortController,e.columns.state="loading";try{e.columns.data=yield*x.toGenerator(Ot.structure(e.controllers.columns.signal)({query_type:"COLUMNS",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"COLUMNS"}})),e.columns.state="idle",e.columns.error=null}catch(s){if(At.isCancel(s))e.columns.state="idle",e.columns.error=null;else{e.columns.data=[];const i=v.get(s,"message","unkown error");e.columns.error=v.get(s,"response.data.detail.message",i),e.columns.state="error"}}}),loadIndexes:x.flow(function*(){var n;(n=e.controllers.indexes)==null||n.abort(),e.controllers.indexes=new AbortController,e.indexes.state="loading";try{e.indexes.data=yield*x.toGenerator(Ot.structure(e.controllers.indexes.signal)({query_type:"INDEXES",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"INDEXES"}})),e.indexes.state="idle",e.indexes.error=null}catch(s){if(At.isCancel(s))e.indexes.state="idle",e.indexes.error=null;else{e.indexes.data=[];const i=v.get(s,"message","unkown error");e.indexes.error=v.get(s,"response.data.detail.message",i),e.indexes.state="error"}}}),loadTableData:x.flow(function*(){var s;(s=e.controllers.tableData)==null||s.abort(),e.controllers.tableData=new AbortController;const n=e.tableData;n.state="loading";try{n.data=yield*x.toGenerator(Ot.structure(e.controllers.tableData.signal)({query_type:"DATA",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name,limit:n.limit,offset:n.offset},{params:{query_type:"DATA"}}));const[{total:i}]=yield*x.toGenerator(Ot.structure(e.controllers.tableData.signal)({query_type:"COUNT",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"COUNT"}}));n.total=Number(i),n.state="idle",n.error=null}catch(i){if(At.isCancel(i))n.state="idle",n.error=null;else{n.data=[];const a=v.get(i,"message","unkown error");n.error=v.get(i,"response.data.detail.message",a),n.state="error"}}})}}).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>e.reloadConditionString,e.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>e.reloadConditionString,e.loadIndexes,{fireImmediately:!1,delay:500})),x.addDisposer(e,X.reaction(()=>`${e.reloadConditionString};limit:${e.tableData.limit};offset:${e.tableData.offset}`,e.loadTableData,{fireImmediately:!1,delay:0}))}})),PE=x.types.model("DataSourcesModel",{list:x.types.optional(x.types.array(AE),[])}).views(e=>({find({type:t,key:n}){return e.list.find(s=>s.key===n&&s.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}}));function In(e){return{label:e,value:e,_type:"ACTION",_action_type:e,Icon:null,children:null}}function OE(e){switch(e._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",e.value];case"sql_snippet":return["_SQL_SNIPPETS_",e.value];case"query":return["_QUERIES_",e.value];case"view":return["_VIEWS_",e.value];case"panel":return e.parentID?["_VIEWS_",e.parentID,"_PANELS_",e.value]:(console.error("[getPathFromOption] parentID is required"),null)}}const LE=x.types.model("EditorModel",{path:x.types.optional(x.types.frozen(),[]),settings_open:x.types.optional(x.types.boolean,!1)}).views(e=>({get navOptions(){const{content:t}=x.getRoot(e),{filters:n,views:s,sqlSnippets:i,queries:a}=t;return[{label:"query_variable.labels",value:"_QUERY_VARS_",_type:"query_variables",Icon:M.IconVariable},{label:"mock_context.label",value:"_MOCK_CONTEXT_",Icon:M.IconCodeDots,_type:"mock_context"},{label:"filter.labels",value:"_FILTERS_",Icon:M.IconFilter,children:[In("_FILTERS_SETTINGS_"),...n.options,In("_Add_A_Filter_")],_type:"GROUP"},{label:"sql_snippet.labels",value:"_SQL_SNIPPETS_",Icon:M.IconCopy,children:[In("_SQL_SNIPPETS_SETTINGS_"),...i.options,In("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"query.labels",value:"_QUERIES_",Icon:M.IconDatabase,children:[In("_QUERIES_SETTINGS_"),...a.options,In("_Add_A_QUERY_")],_type:"GROUP"},{label:"view.labels",value:"_VIEWS_",Icon:M.IconBoxMultiple,children:[...s.editorOptions,In("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(t,n){return t.length===0?!1:t[t.length-1]===n.value},isOptionOpened(t){const{path:n}=e;return n.length===0||!t.children||t.children.length===0?!1:n.includes(t.value)}})).actions(e=>({setPath(t){e.path=t},setSettingsOpen(t){e.settings_open=t}})).actions(e=>({open(t){e.setPath(t),e.setSettingsOpen(!0)},close(){e.setSettingsOpen(!1)},navigate(t){const n=OE(t);n&&e.setPath(n)}})),BE=x.types.compose("LayoutsModel",vl,x.types.model({currentLayoutWrapperWidth:x.types.optional(x.types.number,0)})).views(e=>({get divisionPreviewScale(){const t=e.currentLayoutPreviewWidth,n=e.currentLayoutWrapperWidth;return!t||!n||t<=n?1:n/t}})).actions(e=>({addALayoutItem(t){e.list.forEach(n=>{n.addNewLayout(t)})},duplicateLayoutItemsByPanelID(t,n){e.list.forEach(s=>{const i=s.findByPanelID(t);if(!i){console.error(`Can't find a layout item by panelID[${t}] in layoutSet[${s.name}]`);return}s.list.push({...i,id:Ut.v4(),panelID:n,y:1/0})})},removeByPanelID(t){e.list.forEach(n=>{n.removeByPanelID(t)})},setCurrentLayoutWrapperWidth(t){e.currentLayoutWrapperWidth=t},addALayoutSet(t,n,s){const i=e.basisLayoutSet,a={id:t,name:n,breakpoint:s,list:i.json.list.map(l=>({...l,id:Ut.v4()}))};e.list.push(a)},updateLayoutSetsInfo(t){const n=v.keyBy(e.list,"id");t.forEach(a=>{const l=n[a.id];if(l){l.setName(a.name),l.setBreakpoint(a.breakpoint),delete n[a.id];return}this.addALayoutSet(a.id,a.name,a.breakpoint)});const s=new Set(Object.keys(n)),i=s.size>0;s.forEach(a=>{const l=e.list.findIndex(c=>c.id===a);e.list.splice(l,1)}),i&&e.setCurrentBreakpoint("basis")},updateCurrentLayoutItem(t){e.currentLayoutSet.updateLayoutItem(t)},updateCurrentLayoutItems(t){t.forEach(n=>{e.currentLayoutSet.updateLayoutItem(n)})},append(t){e.list.push(t)},appendMultiple(t){t.length!==0&&e.list.push(...t)},remove(t){e.list.splice(t,1)},removeByID(t){const n=e.list.findIndex(s=>s.id===t);n!==-1&&e.list.splice(n,1)},removeByIDs(t){t.forEach(n=>{this.removeByID(n)})}})),qf=fl.views(e=>({get realDataFieldOptions(){return e.queryIDs.length===0?[]:e.queries.map(t=>{const n=t.data;return n.length===0?[]:Object.keys(n[0]).map(i=>({label:i,value:`${t.id}.${i}`,group:t.name,group_id:t.id,disabled:!1}))}).flat()},get realQueryOptions(){return e.queryIDs.length===0?[]:e.queries.map(t=>({label:t.name,value:t.id,disabled:!1}))},queryOptions(t,n){const s=[...this.realQueryOptions];return t&&!s.find(i=>i.value===t)&&s.unshift({label:t,value:t,disabled:!0}),n&&s.unshift({label:"unset",value:"",disabled:!1}),s},dataFieldOptions(t,n,s){let i=[...this.realDataFieldOptions];if(s&&(i=i.filter(a=>a.group_id===s)),t&&!i.find(a=>a.value===t)){const a=O(t),l=e.queryByID(a.queryID);i.unshift({label:a.columnKey,value:t,group:l?l.name:a.queryID,group_id:l?l.id:"",disabled:!0})}return n&&i.unshift({label:"unset",value:"",group:"",group_id:"",disabled:!1}),i},explainDataKey(t){const{queryID:n,columnKey:s}=O(t),i=e.queries.find(a=>a.id===n);return i?{queryID:n,queryName:i.name,columnKey:s}:{queryID:n,queryName:null,columnKey:s}}})).actions(e=>({removeSelf(){x.getParent(e,2).removeByID(e.id)}})).actions(e=>({moveToView(t,n){x.getRoot(e).content.views.findByID(t).removePanelID(e.id),x.getRoot(e).content.views.findByID(n).appendPanelID(e.id),x.getRoot(e).editor.setPath(["_VIEWS_",n,"_PANELS_",e.id])}})),Vf=x.types.compose("PanelsModel",gl,x.types.model({list:x.types.optional(x.types.array(qf),[])})).views(e=>({get contentModel(){return x.getRoot(e).content},editorOptions(t,n){const s=e.panelsByIDs(n);s.length!==n.length&&console.warn(`Unfulfilled panels for View[${t}]`);const i=s.map(l=>({label:l.name,value:l.id,_type:"panel",parentID:t})),a="_Add_A_PANEL_";return i.push({label:a,value:a,_type:"ACTION",_action_type:a,parentID:t,Icon:null,children:null}),i}})).actions(e=>({replace(t){e.list=x.castToSnapshot(t)},append(t){e.list.push(t)},appendMultiple(t){t.length!==0&&e.list.push(...t)},remove(t){e.list.splice(t,1)},removeByID(t){const n=e.list.findIndex(s=>s.id===t);n!==-1&&e.list.splice(n,1)},removeByIDs(t){t.forEach(n=>{this.removeByID(n)})},duplicateByID(t){const n=e.list.find(i=>i.id===t);if(!n){console.error(new Error(`[duplicate panel] Can't find a panel by id[${t}]`));return}const s=new Date().getTime().toString();return e.list.push({...n.json,id:s,title:{...n.json.title}}),e.contentModel.layouts.duplicateLayoutItemsByPanelID(n.id,s),s},replaceByIndex(t,n){e.list.splice(t,1,n)}})),qE=pl.actions(e=>({getSchema(){const t=e.json,n=[],s=[];e.panels.forEach(l=>{const c=l.getSchema();n.push(c.panel),c.queries.length>0&&s.push(...c.queries)});const i=e.contentModel.layouts.jsonByPanelIDSet(new Set(e.panelIDs));return{views:[t],panels:n,definition:{queries:v.uniqBy(s,l=>l.id)},layouts:i,version:en}},downloadSchema(){if(e.type===q.Tabs){console.error(new Error("Please choose a tab first"));return}const t=JSON.stringify(this.getSchema(),null,2),n=e.name;ir(n,t)}})),Nf=x.types.compose("ViewsModel",hl,x.types.model({current:x.types.optional(x.types.array(qE),[]),idOfVIE:x.types.string})).views(e=>({get isVIETheFirstView(){return e.current.length===0||!e.idOfVIE?!1:e.current[0].id===e.idOfVIE},get VIE(){return e.current.find(({id:t})=>t===e.idOfVIE)},get options(){return e.current.map(t=>({label:t.name,value:t.id,type:t.type}))},get editorOptions(){const t=x.getRoot(e).content.panels;return e.current.map(n=>({label:n.name,value:n.id,_type:"view",children:t.editorOptions(n.id,n.panelIDs)}))}})).actions(e=>({setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},replace(t){e.current.replace(t)},addANewView(t,n,s,i){e.current.push({id:t,name:n,type:s,config:i,panelIDs:[]})},append(t){e.current.push(t)},appendMultiple(t){t.length!==0&&e.current.push(...t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(a=>a.id===t);if(n===-1)return;const s=e.current[n];x.getRoot(e).content.panels.removeByIDs(s.panelIDs),e.current.splice(n,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},addARandomNewView(){const t=new Date().getTime().toString();this.addANewView(t,q.Division,q.Division,{_name:q.Division}),this.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(this.removeByID(e.idOfVIE),this.setIDOfVIE(e.current[0].id))}}));function kl(e){const t=e.length>0?[e[0].id]:[],n=e.length>0?e[0].id:"";return{current:e.map(i=>{const{_name:a=i.type}=i.config;return{...i,config:{...i.config,_name:a},panelIDs:i.panelIDs}}),visibleViewIDs:t,idOfVIE:n}}const VE=x.types.model({id:x.types.string,name:x.types.string,dashboard_id:x.types.string,create_time:x.types.string,update_time:x.types.string,version:x.types.string,filters:Pf,queries:Lf,sqlSnippets:Bf,views:Nf,panels:Vf,layouts:BE,mock_context:Ko,origin:x.types.maybe(x.types.frozen())}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get filtersChanged(){const t="filters.current";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get queriesChanged(){const t="queries.current",n=x.getSnapshot(v.get(e,t)).map(s=>v.pick(s,["id","name","key","type","sql","run_by","react_to","pre_process","post_process","dep_query_ids"]));return!v.isEqual(n,v.get(e.origin,t))},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get viewsChanged(){const t="views.current";return!v.isEqual(e.views.json,v.get(e.origin,t))},get panelsChanged(){const t="panels.list";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get layoutsChanged(){const t="layouts.list";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get mockContextChanged(){const t="mock_context.current";return!v.isEqual(v.get(e,t),v.get(e.origin,t))},get context(){const t=x.getParent(e).context.current;return{...e.mock_context.current,...t}},get payloadForSQL(){const t=x.getParent(e).globalSQLSnippets,n={context:this.context,filters:e.filters.values};return{...n,sql_snippets:Rr(e.sqlSnippets.current,"key","value",n),global_sql_snippets:Rr(t.list,"id","content",n)}},get payloadForViz(){const t=x.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.values}},get dashboardState(){return Ki(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardState}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.layoutsChanged||this.mockContextChanged},get data(){return e.queries.current.map(({id:n,data:s})=>({id:n,data:s})).reduce((n,s)=>(n[s.id]=s.data,n),{})},getDataStuffByID(t){const n=e.queries.findByID(t);return n?{data:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).views(e=>({get queriesUsage(){const t=e.panels.idMap,n=[];e.views.current.forEach(i=>{i.panelIDs.forEach(a=>{const l=t.get(a);if(!l)return;const c="panel",u=l.name,d=[{id:i.id,label:i.name}];l.queryIDs.forEach(p=>{n.push({id:a,queryID:p,type:c,type_label:"panel.label",label:u,views:d})})})});const s=e.views.idMap;return e.filters.current.filter(i=>!!v.get(i,"config.options_query_id")).forEach(i=>{n.push({type:"filter",type_label:"filter.label",id:i.id,queryID:v.get(i,"config.options_query_id"),label:i.label,views:i.visibleInViewsIDs.map(a=>{var l;return{id:a,label:((l=s.get(a))==null?void 0:l.name)??a}})})}),e.queries.current.forEach(i=>{i.isTransform&&i.dep_query_ids.forEach(a=>{n.push({type:"transform-query",type_label:"query.transform.full_label",id:i.id,queryID:a,label:i.name,views:[]})})}),v.groupBy(n,"queryID")},get hasUnusedQueries(){return e.queries.current.length>Object.keys(this.queriesUsage).length},findQueryUsage(t){return this.queriesUsage[t]??[]},get sqlSnippetsUsage(){const t=[];return e.queries.current.forEach(n=>{if(!n.typedAsSQL)return;v.uniq(n.sql.match(vs.sqlSnippet)).forEach(i=>{t.push({queryID:n.id,sqlSnippetKey:i,queryName:n.name})})}),v.groupBy(t,"sqlSnippetKey")},get hasUnusedSQLSnippets(){return e.sqlSnippets.current.length>Object.keys(this.sqlSnippetsUsage).length},findSQLSnippetUsage(t){return this.sqlSnippetsUsage[t]??[]}})).actions(e=>({removeUnusedQueries(){const t=new Set(Object.keys(e.queriesUsage)),n=e.queries.current.filter(s=>!t.has(s.id)).map(s=>s.id);e.queries.removeQueries(n)},removeUnusedSQLSnippets(){const t=new Set(Object.keys(e.sqlSnippetsUsage)),n=e.sqlSnippets.current.filter(s=>!t.has(s.key)).map(s=>s.key);e.sqlSnippets.removeByKeys(n)},duplicatePanelByID(t,n){var i;const s=e.panels.duplicateByID(t);s&&((i=e.views.findByID(n))==null||i.appendPanelID(s))},removePanelByID(t,n){var s;e.panels.removeByID(t),e.layouts.removeByPanelID(t),(s=e.views.findByID(n))==null||s.removePanelID(t)},addANewPanel(t){var s;const n=Ut.v4();e.panels.append(of(n)),(s=e.views.findByID(t))==null||s.appendPanelID(n),e.layouts.addALayoutItem(n)},applyJSONSchema(t){var h;const{views:n,panels:s,filters:i,definition:a={},layouts:l}=t,{queries:c,sqlSnippets:u,mock_context:d}=a,p=new Map;if(Array.isArray(s)){const f=s.map(m=>{const y=Ut.v4();return p.set(m.id,y),{...m,id:y}});if(e.panels.appendMultiple(f),!Array.isArray(n)||n.length===0){const m=f.map(y=>y.id);(h=e.views.VIE)==null||h.appendPanelIDs(m)}}if(Array.isArray(n)){const f=n.map(m=>{const y=m.panelIDs.map(j=>p.get(j)??j);return{...m,id:Ut.v4(),panelIDs:y}});e.views.appendMultiple(f)}if(Array.isArray(l)){const f=(j,k)=>e.layouts.breakpointNameRecord[j]===k;let m=[];const y=l.filter(j=>f(j.name,j.breakpoint));y.forEach(j=>{j.id==="basis"&&(m=j.list),j.list.forEach(k=>{const S=p.get(k.panelID);k.id=Ut.v4(),k.panelID=S})}),e.layouts.list.forEach(j=>{const k=y.find(S=>S.name===j.name&&S.breakpoint===j.breakpoint);if(!k){m.forEach(S=>{j.addLayout(S)});return}k.list.forEach(S=>{j.addLayout(S)})})}Array.isArray(i)&&e.filters.appendMultiple(i),Array.isArray(c)&&e.queries.appendMultiple(c),Array.isArray(u)&&e.sqlSnippets.appendMultiple(u),d&&Object.keys(d).length>0&&e.mock_context.defaults(d)}})).actions(e=>({reset(){x.applySnapshot(e.filters.current,e.origin.filters.current),x.applySnapshot(e.queries.current,e.origin.queries.current),x.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),x.applySnapshot(e.views.current,e.origin.views.current),x.applySnapshot(e.panels.list,e.origin.panels.list),x.applySnapshot(e.layouts.list,e.origin.layouts.list),e.mock_context.current=e.origin.mock_context.current},resetFilters(){x.applySnapshot(e.filters.current,e.origin.filters.current)},updateCurrent(t){const{id:n,name:s,content:i}=t;if(!i)throw new Error("unexpected null content when updating a content model");const{version:a,filters:l,views:c,panels:u,definition:{queries:d,sqlSnippets:p,mock_context:h={}}}=i;e.id=n,e.name=s,e.version=a,x.applySnapshot(e.filters.current,l),x.applySnapshot(e.views.current,kl(c).current),x.applySnapshot(e.panels.list,u),x.applySnapshot(e.queries.current,d),x.applySnapshot(e.sqlSnippets.current,p),e.mock_context.current=h}})),Tl=x.types.snapshotProcessor(VE,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=x.castToSnapshot(e.queries.current.map(n=>v.pick(n,["id","key","type","sql"])));return v.defaults({},{queries:{current:t}},e)}});function NE(e,t){t.filters&&x.applySnapshot(e.filters.current,t.filters)}function $f({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,content:a},l,c){if(!a)throw new Error("unexpected null content when creating a content model");const{version:u,filters:d,views:p,panels:h,layouts:f,definition:{queries:m,sqlSnippets:y,mock_context:j={}}}=a;return Tl.create({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,version:u,filters:xl(d,l,j,c),queries:{current:m},sqlSnippets:{current:y},mock_context:Xo(j),views:kl(p),panels:{list:h},layouts:{list:f,currentBreakpoint:f[0].id}})}const Ff=x.types.model({id:x.types.identifier,name:x.types.string,group:x.types.string,content:Tl,content_id:x.types.string,datasources:PE,globalSQLSnippets:ul,context:oi,editor:LE}).views(e=>({get json(){return{id:e.id,name:e.name,group:e.group,content_id:e.content_id}}})).actions(e=>({updateCurrentContent(t){e.content.updateCurrent(t)},updateCurrent(t,n){const{id:s,name:i,group:a,content_id:l}=t;e.id=s,e.name=i,e.group=a,e.content_id=l,this.updateCurrentContent(n)}}));function Gf({id:e,name:t,group:n,content_id:s},i,a,l,c,u){return Ff.create({id:e,name:t,group:n,content_id:s,content:$f(i,c,u),datasources:{list:a},globalSQLSnippets:{list:l},context:dl(c),editor:{}})}const $E={translation:{filter:{label:"Filter",labels:"Filters",add:"Add a Filter",manage:"Manage Filters",show_filters:"Show Filters",hide_filters:"Hide Filters",field:{widget:"Widget",visible_in:"Visible in...",key_placeholder:"A unique key to refer",label_placeholder:"Label for this field",auto_submit:"Submit automatically",order:"Placement Order",custom_default_value:{trigger:"Custom",title:"Custom default value",tips:"Tips",tip_1:"Function has the highest priority of getting filter's default value",tip_2:"Leave this editor empty to disable this feature"}},widget:{names:{select:"Select",multi_select:"Multi Select",tree_select:"Tree Select",text_input:"Text Input",checkbox:"Checkbox",date_range:"Date Range"},common:{use_query_data_as_options:"Use query data as options",fetch_options_from_datasource:"Fetch options from datasource",or_fetch_options_from_datasource:"Or fetch options from datasource",selector_option_empty:"Not found",see_data_structure:"Click to see expected data structure",using_query:"Using query",default_selection_count:"Select first N options by default",min_width:"Min width",x_selected:"{{count}} selected"},text_input:{default_value:"Default Value",required:"Required"},select:{width:"Width",required:"Required",clearable:"Clearable",configure_options:"Configure options",default_selection:"Default Selection",no_default_selection:"none",select_first_option_by_default:"Select the first option by default"},multi_select:{width_description:"At least 160px"},tree_select:{strictly:"Parent and children nodes are not associated"},checkbox:{description:"Description",default_checked:"Default checked"},date_range:{required:"Required",allow_single_date:"Allow choosing 1 day",display_format:"Display format",max_days:"Max days",one_day:"1 day",x_days:"{{count}} days",x_max_days:"{{max_days}} days max",default_value:"Default value",default_by_shortcut:"Default by shortcut",default_by_shortcut_placeholder:"Priors default value",start_date:"Start date",end_date:"End date",shortcut:{last:{label:"last",d:"yesterday",w:"week",m:"month",m2:"2 months",m3:"3 months",y:"year",full:{d:"yesterday",w:"last week",m:"last month",m2:"last 2 months",m3:"last 3 months",y:"last year"}},recent:{label:"recent",d7:"7 days",d30:"30 days",d60:"60 days",d90:"90 days",d180:"180 days",d365:"365 days",full:{d7:"recent 7 days",d30:"recent 30 days",d60:"recent 60 days",d90:"recent 90 days",d180:"recent 180 days",d365:"recent 365 days"}},this:{label:"this",d:"today",w:"week",m:"month",y:"year",full:{d:"today",w:"this week",m:"this month",y:"this year"}},this_so_far:{label:"this...so far",w:"week",m:"month",y:"year",full:{w:"this week so far",m:"this month so far",y:"this year so far"}}}}}},view:{label:"View",labels:"Views",add:"Add a View",delete:"Delete this View",download_schema:"Download this View",component:{div:{label:"Division"},tabs:{label:"Tabs",tabs_settings:"Tabs Settings",tab:{name:"Tab Name",view:"View",order:"Placement Order",color:"Color",delete:"Delete this tab",switch_to_view:"Swith to View: {{name}}"}},modal:{label:"Modal",modal_settings:"Modal settings",title:"Modal Title",custom_title:"Customize modal title",width:"Width",height:"Height"}}},interactions:{label:"Interactions",add:"Add an interaction",interactions_viewer:"Interactions Viewer",unavailable:"Unavailable",unavailable_reason:"This visualization does not have available interactions to choose from",trigger:{setup:"Setup Trigger",label:"Trigger",payload:"Payload"},operation:{setup:"Operation Settings",label:"Operation",settings:"Settings",variables:"Variables",console_log:{label:"console.log | debug",log_content:"log content"},open_link:{label:"Open Link",url:"URL",open_in_new_tab:"Open in new tab"},open_view:{label:"Open View",view:"View"},set_filter_values:{label:"Set Filter Values",set_filter:"Set filter",with:"with"},clear_filter_values:{label:"Clear Filter Values",select_filter:"Select filters to clear"}}},query_variable:{label:"Query Variable",labels:"Query Variables",add:"Add a Variable",guide:{tabs:{guide:"Guide",variables_in_this_dashboard:"Variables in this dashboard",global_sql_snippets:"Global SQL Snippets"}},open:"See Query Variables"},sql_snippet:{label:"SQL Snippet",labels:"SQL Snippets",add:"Add a SQL Snippet",delete:"Delete this SQL Snippet",delete_unused:"Delete unused SQL Snippets",manage:"Manage SQL Snippets",key:"Key",key_occupied:"This key is occupied by another snippet",edit_snippet:"Edit SQL Snippet",preview_snippet:"Preview SQL Snippet",usage:{label:"Usage"}},global_sql_snippet:{label:"Global SQL Snippet",labels:"Global SQL Snippets",description:"SQL snippets worth sharing between dashboards are managed in System Settings by admins."},common:{titles:{settings:"Settings",edit:"Edit",config:"Config"},pagination:{page_size:"Page Size",total:"Total",total_rows:"Total {{total}} row(s)"},align:{horizontal:{label:"Horizontal Align",left:"left",center:"center",right:"right"},vertical:{label:"Vertical Align",left:"top",center:"center",right:"bottom"}},id:"ID",name:"Name",key:"Key",label:"Label",value:"Value",type:"Type",info:"Info",min:"Min",max:"Max",data_field:"Data Field",name_data_field:"Name Data Field",value_data_field:"Value Data Field",color_data_field:"Color Data Field",enabled:"Enabled",copied:"Copied to clipboard",action:"Action",actions:{open:"Open",close:"Close",save:"Save",save_changes:"Save Changes",revert:"Revert",revert_changes:"Revert Changes",reset_to_default:"Reset to default",init_with_default:"Init with default",select_all:"Select All",clear_selection:"Clear Selection",refresh:"Refresh",download_data:"Download Data",download_schema:"Download Schema",download_screenshot:"Screenshot",enter_fullscreen:"Full Screen",duplicate:"Duplicate",delete:"Delete",cancel:"Cancel",confirm:"Confirm",add_an_option:"Add an Option",edit:"Edit",end_editing:"End editing <1>{{name}}</1>"},tabs:{variant:{label:"Variant",default:"Default",outline:"Outline",pills:"Pills"},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},grow_tabs:"Grow Tabs"},choose_a_tab_first:"Please choose a tab first"},breakpoint:{label_one:"Screen size",label_other:"Screen sizes",add:"Add a screen size",manage:"Manage screen sizes",breakpoint:"Min Width"},context:{label:"Context"},mock_context:{label:"Mock Context",hint:"A valid json string is required"},panel:{label:"Panel",labels:"Panels",add:"Add a Panel",delete:"Delete This Panel",panel_name:"Panel Name",panel_description:"Description",panel_description_click:"Click to see description",show_title:"Show title",use_name_as_title:"Use name as title",settings:{change_view:"Move into Another View",change_view_title:"Move panel into another view",choose_queries:"Choose queries",need_to_choose_queries:"Choose at least 1 query for its data"},style:{label:"Style",width:"Width",width_postfix:"of 36 columns",height:"Height",height_postfix:"px",border:"Border"},variable:{label:"Variable",labels:"Variables",add:"Add a Variable",delete:"Delete this Variable",aggregation:{label:"Aggregation",fallback_value:"Fallback Value",fallback_value_description:"Used when data is empty or the aggregation yields NaN"}}},style:{label:"Style",font_size:{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"Font Weight"},size:{xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl"},flex:{justify_content:{label:"Justify Content",left:"Left",center:"Center",right:"Right",space_between:"Space Between",space_around:"Space Around",space_evenly:"Space Evenly"},align_items:{label:"Align Items",start:"Start",center:"Center",end:"End",stretch:"Stretch"}},color:{type:{label:"Color Type",static:"Static",interpolation:"Interpolation",none:"None"},interpolation:{setup:"Setup color interpolation",palette:{label:"Palette",category:{sequential:"Sequential",diverging:"Diverging"},red_green:"Red / Green",yellow_blue:"Yellow / Blue",red:"Red",green:"Green",blue:"Blue",orange:"Orange",mapping:{value_input_label:"Map a value to this color"}}}}},query:{label:"Query",labels:"Queries",add:"Add a Query",delete:"Delete this Query",cant_delete:"Can't delete this query for it's being used, check out Usage tab for details",delete_unused:"Delete unused queries",name:"Name",name_description:"A unique name",manage:"Manage Queries",open:"Open this query",configurations:"Configurations",basics:"Basics",conditions:"Conditions",run_by_condition:{label:"Run query when these are truthy",unset:"Always run this query on load"},re_run_condition:{label:"Re-run query when these changed",unset:"Leave it empty to never re-run this query"},dependency:{label:"Dependency",has_none:"This query has no dependency"},edit_sql:"Edit SQL",preview_sql:"Preview SQL",request:"Request",build_request:"Build Request",process_request:"Process Request",process_result:"Process Result",usage:{label:"Usage",in_views:"In View(s)",unused_description:"This query is not used by any filter or panel"},transform:{label:"Transform",full_label:"Transform Query",data_source:"Use other queries' data",guide:{pick_queries:"Pick queries for data input",write_function:"Write a function for making new data"}}},data:{label:"Data",preview_data:"Preview Data",empty_data:"Empty Data",requires_data:"Requires data"},data_source:{label:"Data Source",explore:"Explore Data Source",explorer:"Data Source Explorer",table_structure:"Table Structure",table_structure_short:"Structure",see_table_structure:"See Table Structure"},visualization:{label:"Visualization",component:"Visualization",label_short:"Viz"},numbro:{format:{label:"Format",absolute:"Absolute",absolute_description:"Non-negative",abbreviation:"Abbreviation",abbreviation_description:"like 1.23k, 1.23m",mantissa:"Mantissa",trim_mantissa:"Trim mantissa",trim_mantissa_description:"hide trailing zero(s)",preview:{open:"Open Preview",close:"Close Preview",input:"In",output:"Out"}}},import:{label:"Import...",title:"Import content with schema json",json_file:"JSON File",this_dashboard:"This dashboard",this_file:"This file"},function_utils:{trigger_text:"About parameter 'utils'",modal_title:"About FunctionUtils",description:"Parameter <code>utils</code> is <code>FunctionUtils</code>, which contains:",document:"Document"},aggregation:{option:{none:"None",sum:"Sum",mean:"Mean",median:"Median",min:"Min",max:"Max",cov:"Coefficient of Variation",std:"Standard Variation",quantile:{label:"Quantile",label_with_hint:"Quantile(99%, 95%, ...)"},custom:{label:"Custom",label_trigger:"Edit Function",title:"Custom Aggregation"},pick_record:{label:"Pick Record",method:{label:"Record",first:"First Record",last:"Last Record"}}}},rich_text:{label:"Rich Text",content:{label:"Content"},dynamic_color:{label:"Dynamic Color",edit:"Edit dynamic color"}},chart:{chart_config:"Chart Config",data_field:"Data Field",groups:{merico_suite:"Merico suite",echarts_based_charts:"ECharts-based charts",others:"Others"},label:{label:"Label",label_full:"Label",label_style:"Label Style",label_format:"Label Format"},label_position:{label:"Label Position",off:"Off",top:"Top",left:"Left",right:"Right",bottom:"Bottom",inside:"Inside",inside_top:"Inside Top",inside_left:"Inside Left",inside_center:"Inside Center",inside_right:"Inside Right",inside_bottom:"Inside Bottom",inside_top_left:"Inside Top Left",inside_top_right:"Inside Top Right",inside_bottom_left:"Inside Bottom Left",inside_bottom_right:"Inside Bottom Right",outside:"Outside"},visual_map:{label:"Visual Map",continuous:{label:"Continuous"},piecewise:{label:"Piecewise",mode:{pieces:"Pieces",categories:"Categories"},add_a_piece:"Add a piece",interval:"Interval",piece_label:"Label"},bar_width:"Bar Width",bar_height:"Bar Height",item_width:"Item Width",item_height:"Item Height",calculable:"Show drag handle",min_value:"Min Value",max_value:"Max Value",min_text:"Min Text",max_text:"Max Text",use_palette_x:'Use palette "{{x}}"',built_in_palettes:"Built-in Palettes",precision:"Data Precision",skip_range:{lt_min:"Color for smaller values than min value",min:"Color for min value",max:"Color for max value",gt_max:"Color for greater values than max value",follow_visual_map:"follow gradient rule"}},number_or_dynamic_value:{type:{static:"Static",dynamic:"Dynamic"},dynamic:{setup:"Setup",setup_title:"Setup dynamic value",guide:"Dyanmic by a custom function"}},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},symbol_size:{label:"Symbol Size",static:"Static",dynamic:"Dynamic",setup:{label:"Setup",title:"Setup dynamic size",description:"Dynamic by a custom function"}},series:{label:"Series",name:"Name",y_axis:"Y Axis",data_field:"Data Field",add:"Add a series",delete:"Delete this series",line:{label:"Line",line_settings:"Line Settings",line_style:"Line Style",type:{label:"Line Type",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},line_width:"Line Width",step:{label:"Step",off:"Off",start:"Start",middle:"Middle",end:"End"},smooth_line:"Smooth Line",show_name_on_line:"Display Name on Line",show_symbol_on_line:"Show Symbol on Line"},bar:{label:"Bar",stack:"Stack",stack_hint:"Stack bars by this ID",bar_gap:{label:"Bar Gap",no_gap:"No gap between bars",overlap:"Bars overlapping on each other"},bar_width:{min:"Bar Width(min)",exact:"Bar Width",max:"Bar Width(max)"}},scatter:{label:"Scatter"},group_by:{label:"Split into multiple seires by this field...",label_line:"Split into multiple lines by this field..."}},axis:{tick_label:"Tick Label",customize_label:"Customize Label",overflow:{label:"Overflow",max_width:"Max Width",truncate:"Truncate",break_line:"Break Line",break_word:"Break Word",ellipsis:"Ellipsis",section_title:{on_axis:"Overflow on Axis",in_tooltip:"Overflow in Tooltip"}},section_title:{label_format:"Label Format"},type:{value:"Value",category:"Category",time:"Time",log:"Log",click_to_learn_more:"Click <1>here</1> to learn more about these options"}},name_text:{align:{label:"Name Anchor",left:"Left",center:"Center",right:"Right"}},rotate:"Rotate",degree:"degree",padding:"Padding",content_template:{label:"Content Template",hint:"Average: ${avg}"},x_axis:{label:"X Axis",labels:"X Axes",label_format:"Label Format",add:"Add an X Axis",delete:"Delete this X Axis",x_axis_name:"X Axis Name",x_axis_data_field:"X Axis Data Field",x_axis_type:"X Axis Type",layout:"Layout",position:{label:"Position",top:"Top",bottom:"Bottom"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},y_axis:{label:"Y Axis",labels:"Y Axes",label_format:"Label Format",add:"Add a Y Axis",delete:"Delete this Y Axis",y_axis_name:"Y Axis Name",y_axis_name_anchor:"Name Anchor",y_axis_data_field:"Y Axis Data Field",layout:"Layout",position:{label:"Position",left:"Left",right:"Right"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},stats:{label:"Stats",template:{above_chart:"Template for stats above the chart",under_chart:"Template for stats under the chart"}},legend:{label:"Legend",show_legend:"Show Legend",show_in_legend:"Show in legend",hide_in_legend:"Hide in legend",orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"}},tooltip:{label:"Tooltip",additional_metrics:{description:"Set additional metrics to show in scatter's tooltip",add:"Add a metic",delete:"Delete this Metric"},trigger:{label:"Trigger",scatter_point:"Scatter Point",x_axis:"X Axis"}},style:{label:"Style"},color:{label:"Color",or:"or",set_any_color:"Set any color",pick_a_theme_color:"Pick a theme color",background_color:"Background Color",text_color:"Text Color",click_to_add_a_color:"Click to add a color",color_gradient:"Color Gradient"},behavior:{label:"Behavior",invisible:"Invisible"},heatmap:{heatblock:{label:"Heat Block",show_label:"Show Label"}},reference_line:{label:"Reference Line",labels:"Reference Lines",add:"Add a reference line",name_placeholder:"Average Reference Line",delete:"Remove this Reference Line",orientation:{vertical_hint:"Works only when xAxis values are numbers"}},regression_line:{label:"Regression Line",labels:"Regression Lines",add:"Add a line",delete:"Delete this line",method:{label:"Method",linear:"Linear",exponential:"Exponential",logistic:"Logistic",polynomial:"Polynomial",polynomial_order:"Order"}},reference_area:{label:"Reference Area",labels:"Reference Areas",add:"Add a reference area",delete:"Remove this reference area",type:{label:"Type",rectangle:"Rectangle"},direction:{label:"Direction",horizontal:"Horizontal"},boundary:{upper:"Upper Boundary",lower:"Lower Boundary"},content:{label:"Content",content_text:"Content Text",text_position:"Text Position"},endpoint:{labels:"Endpoints",left_bottom_point:"Left-Bottom Point",right_top_point:"Right-Top Point"}},zooming:{label:"Zooming",scroll:{label:"Scroll to zoom",x_axis:"Enable on X Axis",y_axis:"Enable on Y Axis"},slider:{label:"Slider for zooming",x_axis:"Slider for X Axis",y_axis:"Slider for Y Axis",y_axis_disabled:"Not available for now, will overlap y-axis's label"}}},viz:{viz_config_banner:"Visualization Settings"},validation:{number:{require_a_number:"A number is required"}}}},FE={translation:{filter:{label:"筛选器",labels:"筛选器",add:"新增筛选器",manage:"管理筛选器",show_filters:"展开筛选器",hide_filters:"收起筛选器",field:{widget:"控件",visible_in:"在...视图中可见",key_placeholder:"用于引用此筛选器,需保持唯一",label_placeholder:"用于展示的标签文案",auto_submit:"自动提交",order:"排列次序",custom_default_value:{trigger:"自定义",title:"自定义默认值",tips:"提示",tip_1:"在指定筛选器默认值这事上,自定义函数具备最高优先级",tip_2:"清空下方编辑器来禁用本功能"}},widget:{names:{select:"单选",multi_select:"多选",tree_select:"树形选择器",text_input:"文本框",checkbox:"勾选框",date_range:"日期范围"},common:{use_query_data_as_options:"使用所查数据为选项",fetch_options_from_datasource:"从数据源查选项",or_fetch_options_from_datasource:"或从数据源查选项",selector_option_empty:"无选项可用",see_data_structure:"点击查看期望的数据格式",using_query:"在用查询获取选项",default_selection_count:"默认选中前N项",min_width:"控件最小宽度",x_selected:"已选数:{{count}}"},text_input:{default_value:"默认值",required:"必填"},select:{width:"控件宽度",required:"必选",clearable:"可取消选择",configure_options:"配置选项",default_selection:"默认选项",no_default_selection:"无",select_first_option_by_default:"默认选中第一个选项"},multi_select:{width_description:"至少160px"},tree_select:{strictly:"枝叶节点不相关,各选各的"},checkbox:{description:"描述信息",default_checked:"默认勾选"},date_range:{required:"必选",allow_single_date:"允许选一天作为范围",display_format:"展示格式",max_days:"最大选择天数",one_day:"1天",x_days:"{{count}}天",x_max_days:"最多可选{{max_days}}天",default_value:"默认日期范围(具体)",default_by_shortcut:"默认日期范围(快捷方式)",default_by_shortcut_placeholder:"优先于左侧",start_date:"开始日期",end_date:"结束日期",shortcut:{last:{label:"过往整周期",d:"昨天",w:"周",m:"月",m2:"两个月",m3:"三个月",y:"年",full:{d:"昨天",w:"上周",m:"上个月",m2:"上两月",m3:"上三月",y:"去年"}},recent:{label:"最近",d7:"7天",d30:"30天",d60:"60天",d90:"90天",d180:"180天",d365:"365天",full:{d7:"近7天",d30:"近30天",d60:"近60天",d90:"近90天",d180:"近180天",d365:"近365天"}},this:{label:"当前整周期",d:"今天",w:"周",m:"月",y:"年",full:{d:"今天",w:"本周",m:"本月",y:"今年"}},this_so_far:{label:"至今",w:"周",m:"月",y:"年",full:{w:"本周至今",m:"本月至今",y:"本年至今"}}}}}},view:{label:"视图",labels:"视图",add:"新增视图",delete:"删除此视图",download_schema:"下载此视图描述文件",component:{div:{label:"内容"},tabs:{label:"标签页",tabs_settings:"标签页设置",tab:{name:"名称",view:"内容视图",order:"排列次序",color:"颜色",delete:"删除这个标签页",switch_to_view:"打开视图: {{name}}"}},modal:{label:"弹窗",modal_settings:"弹窗设置",title:"弹窗标题",custom_title:"自定义弹窗标题",width:"宽度",height:"高度"}}},interactions:{label:"交互",add:"新增交互",interactions_viewer:"纵览交互",unavailable:"不可用",unavailable_reason:"此可视化组件没有交互功能",trigger:{setup:"设置触发动作",label:"触发动作",payload:"触发时的参数"},operation:{setup:"操作设置",label:"操作",settings:"设置",variables:"变量",console_log:{label:"console.log | 调试用",log_content:"打印内容"},open_link:{label:"打开链接",url:"URL",open_in_new_tab:"在新标签页中打开"},open_view:{label:"唤出视图",view:"视图"},set_filter_values:{label:"设置筛选器值",set_filter:"将筛选器的值",with:"设为"},clear_filter_values:{label:"清除筛选器值",select_filter:"选择筛选器以清除其值"}}},query_variable:{label:"查询变量",labels:"查询变量",add:"新增变量",guide:{tabs:{guide:"使用指南",variables_in_this_dashboard:"本看板中的查询变量",global_sql_snippets:"全局SQL片段"}},open:"查看查询变量"},sql_snippet:{label:"SQL片段",labels:"SQL片段",add:"新增SQL片段",delete:"删除这个SQL片段",delete_unused:"删除未用到的SQL片段",manage:"管理SQL片段",key:"键",key_occupied:"此键已被其他SQL片段占用",edit_snippet:"编辑SQL片段",preview_snippet:"预览SQL片段",usage:{label:"使用情况"}},global_sql_snippet:{label:"全局SQL片段",labels:"全局SQL片段",description:"管理员负责在系统设置中维护全局SQL片段"},common:{titles:{settings:"设置",edit:"编辑",config:"配置"},pagination:{page_size:"页容量",total:"共",total_rows:"共 {{total}} 行"},align:{horizontal:{label:"水平对齐",left:"居左",center:"居中",right:"居右"},vertical:{label:"垂直对齐",left:"居上",center:"居中",right:"居下"}},id:"ID",name:"名称",key:"键",label:"标签",value:"值",type:"类型",info:"信息",min:"最小值",max:"最大值",data_field:"数据字段",name_data_field:"名称字段",value_data_field:"值字段",color_data_field:"颜色字段",enabled:"启用",copied:"已复制到剪切板",action:"操作",actions:{open:"打开",close:"关闭",save:"保存",save_changes:"保存改动",revert:"还原",revert_changes:"还原改动",reset_to_default:"重置为初始值",init_with_default:"初始化",select_all:"全选",clear_selection:"撤销选择",refresh:"刷新",download_data:"下载数据",download_schema:"下载描述文件",download_screenshot:"下载截图",enter_fullscreen:"全屏",duplicate:"复制",delete:"删除",cancel:"取消",confirm:"确认",add_an_option:"新增选项",edit:"编辑",end_editing:"结束编辑 <1>{{name}}</1>"},tabs:{variant:{label:"风格",default:"默认",outline:"轮廓",pills:"胶囊"},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},grow_tabs:"拉伸标签卡宽度"},choose_a_tab_first:"请先选择一个标签页"},breakpoint:{label_one:"屏幕尺寸",label_other:"屏幕尺寸",add:"新增屏幕尺寸",manage:"管理屏幕尺寸",breakpoint:"最小宽度"},context:{label:"上下文"},mock_context:{label:"模拟上下文",hint:"内容格式为JSON"},panel:{label:"卡片",labels:"卡片",add:"新增卡片",delete:"删除这个卡片",panel_name:"卡片名",panel_description:"卡片描述",panel_description_click:"点击查看卡片描述",show_title:"展示卡片标题",use_name_as_title:"使用卡片名作为标题",settings:{change_view:"移至另一个视图下",change_view_title:"移动此卡片至另一个视图下",choose_queries:"关联查询",need_to_choose_queries:"请关联至少一个查询以使用其数据"},style:{label:"样式",width:"宽",width_postfix:"之 36 栏",height:"高",height_postfix:"px",border:"边框"},variable:{label:"变量",labels:"变量",add:"新增变量",delete:"删除此变量",aggregation:{label:"聚合",fallback_value:"兜底值",fallback_value_description:"当数据为空或聚合结果非数字时,使用此兜底值"}}},style:{label:"样式",font_size:{label:"字号",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"字重"},size:{xs:"特小",sm:"小",md:"中",lg:"大",xl:"特大"},flex:{justify_content:{label:"内容分布",left:"从左起",center:"居中",right:"从右起",space_between:"均匀分布,首尾顶格",space_around:"均匀分布,首尾留空一半",space_evenly:"均匀分布,首尾留空"},align_items:{label:"对齐位置",start:"起点对齐",center:"居中对齐",end:"末端对齐",stretch:"拉伸对齐"}},color:{type:{label:"颜色类型",static:"单色",interpolation:"插值取色",none:"无"},interpolation:{setup:"设置取色方案",palette:{label:"色板",category:{sequential:"单色渐变",diverging:"双色渐变"},red_green:"红 / 绿",yellow_blue:"黄 / 蓝",red:"红",green:"绿",blue:"蓝",orange:"橙",mapping:{value_input_label:"映射一个值到此颜色"}}}}},query:{label:"查询",labels:"查询",add:"新增查询",delete:"删除这个查询",cant_delete:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",delete_unused:"删除未用到的查询",name:"名称",name_description:"唯一名称",manage:"管理查询",open:"打开此查询",configurations:"配置",basics:"基本信息",conditions:"条件",run_by_condition:{label:"以下条件满足时,才运行本查询",unset:"看板加载时便运行本查询"},re_run_condition:{label:"当以下条件改变时,重新运行此查询",unset:"留空则永不重新运行此查询"},dependency:{label:"依赖",has_none:"此查询无依赖"},edit_sql:"编辑SQL",preview_sql:"预览SQL",request:"请求",build_request:"构造请求",process_request:"加工请求",process_result:"加工结果",usage:{label:"使用情况",in_views:"所在视图",unused_description:"此查询未被任何筛选器或卡片用到"},transform:{label:"查询变形",full_label:"查询变形",data_source:"基于其他查询的数据,加工出新数据",guide:{pick_queries:"选择一至多个查询作为数据输入",write_function:"编写函数,返回新数据"}}},data:{label:"数据",preview_data:"预览数据",empty_data:"无数据",requires_data:"请先关联查询"},data_source:{label:"数据源",explore:"查看数据源",explorer:"数据源查看器",table_structure:"数据表结构",table_structure_short:"表结构",see_table_structure:"查看数据表结构"},visualization:{label:"可视化",component:"可视化组件",label_short:"可视化"},numbro:{format:{label:"格式",absolute:"绝对值",absolute_description:"非负",abbreviation:"缩写",abbreviation_description:"如1.23k、1.23m",mantissa:"小数",trim_mantissa:"抹零",trim_mantissa_description:"省略末尾的零",preview:{open:"展开预览",close:"收起预览",input:"输入",output:"输出"}}},import:{label:"导入...",title:"自描述文件导入看板内容",json_file:"描述文件(JSON格式)",this_dashboard:"此看板",this_file:"此文件"},function_utils:{trigger_text:"关于utils参数",modal_title:"关于utils参数",description:"参数 <code>utils</code> 是 <code>FunctionUtils</code>,包含以下内容:",document:"文档"},aggregation:{option:{none:"无",sum:"和",mean:"平均值",median:"中位数",min:"最小值",max:"最大值",cov:"变异系数",std:"标准差",quantile:{label:"分位",label_with_hint:"分位(99%, 95%, ...)"},custom:{label:"自定义",label_trigger:"编写函数",title:"自定义聚合方式"},pick_record:{label:"直接选择数据",method:{label:"数据记录",first:"第一条",last:"最后一条"}}}},rich_text:{label:"富文本",content:{label:"内容"},dynamic_color:{label:"动态颜色",edit:"编辑动态颜色"}},chart:{chart_config:"图表设置",data_field:"数据字段",groups:{merico_suite:"思码逸套件",echarts_based_charts:"基于ECharts的图表",others:"其他"},label:{label:"文案",label_full:"标签文案",label_style:"标签文案样式",label_format:"标签文案格式"},label_position:{label:"文案位置",off:"不显示文案",top:"上",left:"左",right:"右",bottom:"下",inside:"内",inside_top:"内-上",inside_left:"内-左",inside_center:"内-中",inside_right:"内-右",inside_bottom:"内-下",inside_top_left:"内-上-左",inside_top_right:"内-上-右",inside_bottom_left:"内-下-左",inside_bottom_right:"内-下-右",outside:"外"},visual_map:{label:"视觉映射",continuous:{label:"连续型"},piecewise:{label:"分段型",mode:{pieces:"连续数据",categories:"离散数据"},add_a_piece:"加一个分段",interval:"值区间",piece_label:"文案"},bar_width:"长条的宽度",bar_height:"长条的高度",item_width:"小块的宽度",item_height:"小块的高度",calculable:"显示拖拽手柄",min_value:"最小值",max_value:"最大值",min_text:"最小值文案",max_text:"最大值文案",use_palette_x:'使用配色方案"{{x}}"',built_in_palettes:"内置配色方案",precision:"数据精度",skip_range:{lt_min:"小于最小值时的颜色",min:"最小值的颜色",max:"最大值的颜色",gt_max:"大于最大值时的颜色",follow_visual_map:"颜色跟随渐变规则"}},number_or_dynamic_value:{type:{static:"具体值",dynamic:"动态值"},dynamic:{setup:"设置",setup_title:"设置动态值",guide:"由函数确定动态值"}},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},symbol_size:{label:"标记点大小",static:"固定值",dynamic:"动态值",setup:{label:"设置",title:"设置动态值",description:"由函数确定动态值"}},series:{label:"系列",name:"名称",y_axis:"Y轴",data_field:"数据字段",add:"增加一个系列",delete:"删除这个系列",line:{label:"线",line_settings:"线段设置",line_style:"线条样式",type:{label:"类型",solid:"实线",dashed:"方虚线",dotted:"圆点虚线"},line_width:"线宽",step:{label:"阶梯状",off:"不启用",start:"在当前点拐弯",middle:"在当前点与下个点中间拐弯",end:"在下个点拐弯"},smooth_line:"平滑曲线",show_name_on_line:"显示标签文案",show_symbol_on_line:"显示标记点"},bar:{label:"柱",stack:"堆放",stack_hint:"此值相同的柱系列会堆叠在一起",bar_gap:{label:"柱间隔",no_gap:"柱子之间无间隔",overlap:"柱子可互相重叠"},bar_width:{min:"最大柱宽",exact:"柱宽",max:"最大柱宽"}},scatter:{label:"散点"},group_by:{label:"按此字段拆分为多个系列",label_line:"按此字段拆分为多条线"}},axis:{tick_label:"刻度文案",customize_label:"自定义文案",overflow:{label:"溢出",max_width:"最大宽度",truncate:"截断",break_line:"换行",break_word:"断词换行",ellipsis:"省略符",section_title:{on_axis:"轴刻度上文案的溢出",in_tooltip:"提示框中的文案溢出"}},section_title:{label_format:"文案格式"},type:{value:"数值轴",category:"类目轴",time:"时间轴",log:"对数轴",click_to_learn_more:"点击 <1>这里</1> 以进一步了解这些选项"}},name_text:{align:{label:"名称贴靠侧",left:"左",center:"中",right:"右"}},rotate:"旋转",degree:"度",padding:"内间距",content_template:{label:"内容模板",hint:"均值: ${avg}"},x_axis:{label:"X轴",labels:"X轴",label_format:"刻度文案格式",add:"增加一条X轴",delete:"删除这条X轴",x_axis_name:"X轴名称",x_axis_data_field:"X轴数据字段",x_axis_type:"X轴类型",layout:"布局",position:{label:"位置",top:"上",bottom:"下"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},y_axis:{label:"Y轴",labels:"Y轴",label_format:"刻度文案格式",add:"增加一条Y轴",delete:"删除这条Y轴",y_axis_name:"Y轴名称",y_axis_name_anchor:"名称贴靠侧",y_axis_data_field:"Y轴数据字段",layout:"布局",position:{label:"位置",left:"左",right:"右"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},stats:{label:"统计内容",template:{above_chart:"统计内容模板(图表上方)",under_chart:"统计内容模板(图表下方)"}},legend:{label:"图例",show_legend:"显示图例",show_in_legend:"显示在图例中",hide_in_legend:"不显示在图例中",orientation:{label:"布局朝向",horizontal:"横向",vertical:"纵向"}},tooltip:{label:"提示框",additional_metrics:{description:"在此设置更多指标,来展示在散点的提示框",add:"增加一个指标",delete:"删除这个指标"},trigger:{label:"触发者",scatter_point:"散点",x_axis:"X轴"}},style:{label:"样式"},color:{label:"颜色",or:"或",set_any_color:"输入色号",pick_a_theme_color:"选择一个主题色",background_color:"背景色",text_color:"文字颜色",click_to_add_a_color:"点击增加一个颜色",color_gradient:"颜色渐变"},behavior:{label:"表现",invisible:"隐藏不可见"},heatmap:{heatblock:{label:"热力块",show_label:"展示值文案"}},reference_line:{label:"参考线",labels:"参考线",add:"增加一条参考线",name_placeholder:"均值参考线",delete:"删除这条参考线",orientation:{vertical_hint:"仅当X轴值为数字时可绘制"}},regression_line:{label:"回归线",labels:"回归线",add:"增加一条回归线",delete:"删除这条回归线",method:{label:"方法",linear:"线性回归",exponential:"指数回归",logistic:"指数回归",polynomial:"多项式回归",polynomial_order:"次"}},reference_area:{label:"参考区域",labels:"参考区域",add:"增加一面参考区域",delete:"删除这面参考区域",type:{label:"形状",rectangle:"矩形"},direction:{label:"方向",horizontal:"水平"},boundary:{upper:"上边界",lower:"下边界"},content:{label:"内容",content_text:"内容文字",text_position:"文字位置"},endpoint:{labels:"端点",left_bottom_point:"左下点",right_top_point:"右上点"}},zooming:{label:"缩放",scroll:{label:"滚轮缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用"},slider:{label:"滚动条缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用",y_axis_disabled:"暂不可用,会与Y轴刻度文字重叠"}}},viz:{viz_config_banner:"可视化参数配置"},validation:{number:{require_a_number:"请填写一个数字"}}}},ui=gm.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:$E,zh:FE}}).use(mm).use(_.initReactI18next);ui.init(),Mh.forEach(e=>{var t;(t=e.translation)==null||t.forEach(n=>{ui.addResourceBundle(n.lang,"translation",{viz:n.resources},!0,!0)})});function Wf({lang:e,children:t}){return g.useEffect(()=>{ui.changeLanguage(e)},[e]),r.jsx(_.I18nextProvider,{i18n:ui,children:t})}function di(e){console.groupCollapsed("Running operation ",e.type),console.log(e),console.groupEnd()}function Rf(e,t){g.useEffect(()=>{const n=s=>{di(s);const{viewID:i}=s.detail;if(!i){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(i),t&&e.views.setIDOfVIE(i)};return window.addEventListener("open-view",n),()=>{window.removeEventListener("open-view",n)}},[e,t]),g.useEffect(()=>{const n=s=>{di(s);const{dictionary:i,payload:a}=s.detail;if(!a||Object.keys(a).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}const l={};Object.entries(i).forEach(([c,u])=>{const d=v.get(a,u);l[c]=d}),e.filters.applyValuesPatch(l)};return window.addEventListener("set-filter-values",n),()=>{window.removeEventListener("set-filter-values",n)}},[e]),g.useEffect(()=>{function n(i){return Array.isArray(i)?[]:typeof i=="object"?{}:typeof i=="boolean"?!1:typeof i=="string"?"":typeof i=="number"?0:i}const s=i=>{di(i);const a={},{filter_keys:l}=i.detail;l.forEach(c=>{const u=v.get(e.filters.values,c),d=n(u);a[c]=d}),e.filters.applyValuesPatch(a)};return window.addEventListener("clear-filter-values",s),()=>{window.removeEventListener("clear-filter-values",s)}},[e]),g.useEffect(()=>{const n=s=>{di(s);const{urlTemplate:i,openInNewTab:a,enableEncoding:l=!1,payload:c}=s.detail;if(!i){console.error(new Error("[Open Link] URL is empty"));return}function u(h){return v.cloneDeepWith(h,m=>{if(l&&typeof m=="string")return encodeURIComponent(m)})}const p=v.template(i||"")(u({...c,filters:e.payloadForSQL.filters,context:e.payloadForSQL.context}));window.open(p,a?"_blank":"_self","noopener")};return window.addEventListener("open-link",n),()=>{window.removeEventListener("open-link",n)}},[e])}function Qf(e){return g.useCallback(t=>t.provideValue(je.pluginManager,e.pluginManager).provideValue(je.vizManager,e.vizManager).provideValue(je.colorManager,e.colorManager),[])}const $L="",GE=D.observer(({saveDashboardChanges:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Y(),i=()=>{n.openConfirmModal({title:r.jsxs(o.Group,{position:"left",children:[r.jsx(M.IconAlertTriangle,{size:18,color:"red"}),r.jsx(o.Text,{children:"You are reverting changes"})]}),labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>s.reset(),zIndex:320,withCloseButton:!1})},a=s.changed;return r.jsxs(o.Group,{spacing:0,children:[r.jsx(o.Button,{color:"green",variant:"filled",size:"xs",leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),onClick:e,disabled:!a,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:t("common.actions.save_changes")}),r.jsxs(o.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!a,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.ActionIcon,{variant:"default",disabled:!a,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:r.jsx(M.IconCaretDown,{size:18})})}),r.jsx(o.Menu.Dropdown,{children:r.jsx(o.Menu.Item,{icon:r.jsx(M.IconRecycle,{size:14,color:"red"}),disabled:!a,onClick:i,children:t("common.actions.revert_changes")})})]})]})}),WE=D.observer(({saveDashboardChanges:e,onExit:t,headerSlot:n=null})=>{_.useTranslation();const s=Z(),i=s.content.changed,a=()=>{t({hasChanges:i,dashboardId:s.id})};return r.jsx(o.Header,{height:60,px:"md",py:0,sx:{zIndex:299},children:r.jsxs(o.Group,{position:"apart",sx:{height:60,minWidth:"1000px",position:"relative"},children:[r.jsxs(o.Group,{children:[r.jsx(o.Button,{size:"xs",color:i?"red":"green",leftIcon:r.jsx(M.IconArrowLeft,{size:20}),onClick:a,children:r.jsx(o.Group,{spacing:4,children:r.jsxs(_.Trans,{i18nKey:"common.actions.end_editing",values:{name:s.name},children:["End Editing ",r.jsx(o.Text,{td:"underline",children:s.name})]})})}),r.jsx(GE,{saveDashboardChanges:e})]}),r.jsx(o.Group,{position:"right",sx:{flexGrow:1},children:n})]})})}),Uf={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},RE=D.observer(()=>{var i;const{t:e}=_.useTranslation(),t=Y(),n=((i=t.views.VIE)==null?void 0:i.type)===q.Tabs,s=()=>t.addANewPanel(t.views.idOfVIE);return n?r.jsx(o.Tooltip,{label:e("common.choose_a_tab_first"),children:r.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:r.jsx(M.IconPlaylistAdd,{size:20}),sx:{...Uf,transform:"none !important"},children:e("panel.add")})}):r.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:s,leftIcon:r.jsx(M.IconPlaylistAdd,{size:20}),sx:{...Uf,background:"rgb(231, 245, 255)"},children:e("panel.add")})}),QE=D.observer(({done:e})=>{var E,N;const{t}=_.useTranslation(),s=Y().layouts,i=g.useMemo(()=>({list:s.breakpointsInfo}),[s.breakpointsInfo]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d,formState:p}=b.useForm({defaultValues:i}),{fields:h,append:f,remove:m}=b.useFieldArray({control:a,name:"list",rules:{validate:R=>{if(console.log({values:R}),v.uniqBy(R,"breakpoint").length!==R.length)return"Screen sizes should be unique by min width"}}}),y=c("list"),j=h.map((R,pe)=>({...R,...y[pe]})),k=()=>{f({id:Ut.v4(),name:"",breakpoint:""})},S=({list:R})=>{const pe=R.filter(ie=>Number.isFinite(ie.breakpoint));s.updateLayoutSetsInfo(pe),e()},T=u(),z=g.useMemo(()=>{const R={list:T.list.filter(pe=>!!pe.name&&Number.isFinite(pe.breakpoint))};return!v.isEqual(R,i)},[T,i]),I=(N=(E=p.errors.list)==null?void 0:E.root)==null?void 0:N.message;return r.jsx(r.Fragment,{children:r.jsxs("form",{onSubmit:l(S),children:[r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,withBorder:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"340px"},children:t("common.name")}),r.jsx("th",{style:{width:"160px"},children:t("breakpoint.breakpoint")}),r.jsx("th",{})]})}),r.jsxs("tbody",{children:[j.map((R,pe)=>r.jsxs("tr",{children:[r.jsx("th",{children:R.id==="basis"?R.name:r.jsx(b.Controller,{name:`list.${pe}.name`,control:a,render:({field:ie})=>r.jsx(o.TextInput,{size:"xs",label:"",required:!0,sx:{flex:1},...ie})})}),r.jsx("td",{children:R.id==="basis"?r.jsxs(o.Text,{ff:"monospace",children:[R.breakpoint,"px"]}):r.jsx(b.Controller,{name:`list.${pe}.breakpoint`,control:a,render:({field:ie})=>r.jsx(o.NumberInput,{size:"xs",label:"",required:!0,max:1e4,hideControls:!0,rightSection:r.jsx(o.Text,{color:"dimmed",children:"px"}),rightSectionProps:{style:{width:"30px"}},sx:{flex:1,fontFamily:"monospace"},styles:{input:{paddingRight:"30px"}},...ie})})}),r.jsx("td",{children:R.id!=="basis"&&r.jsx(o.ActionIcon,{mx:"auto",size:"xs",variant:"subtle",color:"red",onClick:()=>m(pe),children:r.jsx(M.IconTrash,{})})})]},R.id)),r.jsx("tr",{style:{backgroundColor:"transparent"},children:r.jsx("td",{colSpan:3,style:{padding:"0"},children:r.jsx(o.Tooltip,{label:t("breakpoint.add"),children:r.jsx(o.ActionIcon,{variant:"subtle",size:"md",color:"blue",onClick:k,sx:{width:"100%"},children:r.jsx(M.IconPlus,{size:18})})})})})]})]}),r.jsx(o.Text,{mt:6,ta:"right",size:"xs",color:"red",children:I??" "}),r.jsxs(o.Group,{mt:6,position:"apart",children:[r.jsx(o.Button,{color:"orange",size:"xs",onClick:()=>d(),leftIcon:r.jsx(M.IconRecycle,{size:18}),disabled:!z,children:t("common.actions.revert")}),r.jsx(o.Button,{color:"green",size:"xs",type:"submit",leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),disabled:!z,children:t("common.actions.save_changes")})]})]})})}),UE=D.observer(()=>{const{t:e}=_.useTranslation(),[t,{open:n,close:s}]=he.useDisclosure(!1),i=Y(),a=i.layouts.currentBreakpoint,l=i.layouts.currentLayoutRange,c=()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},u=()=>{s(),c()};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{children:[r.jsxs(o.Menu,{withArrow:!0,withinPortal:!0,zIndex:320,trigger:"hover",children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Button,{size:"xs",variant:"subtle",leftIcon:r.jsx(M.IconDevices,{size:16}),sx:{borderRadius:0},children:r.jsxs(o.Group,{spacing:6,children:[r.jsx(o.Text,{size:"xs",fw:"normal",children:l.name}),r.jsx(o.Text,{size:"xs",color:"#777",children:i.layouts.currentRangeText})]})})}),r.jsxs(o.Menu.Dropdown,{children:[i.layouts.breakpointRanges.map(d=>r.jsx(o.Menu.Item,{onClick:()=>i.layouts.setCurrentBreakpoint(d.id),disabled:a===d.id,children:r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Text,{size:"sm",children:d.name}),r.jsx(o.Text,{size:"xs",color:"dimmed",children:d.text})]})},d.id)),r.jsx(o.Menu.Divider,{}),r.jsx(o.Menu.Item,{color:"blue",icon:r.jsx(M.IconSettings,{size:14}),onClick:n,children:r.jsx(o.Text,{size:"sm",children:e("breakpoint.manage")})})]})]}),i.layouts.divisionPreviewScale<1&&r.jsx(o.Text,{size:"xs",color:"dimmed",children:Zr(i.layouts.divisionPreviewScale).format({output:"percent",mantissa:0})})]}),r.jsx(o.Modal,{opened:t,onClose:u,title:e("breakpoint.label",{count:2}),withinPortal:!0,zIndex:320,size:600,closeOnClickOutside:!1,children:r.jsx(QE,{done:u})})]})}),Yf={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},YE=D.observer(()=>{var i;const{t:e}=_.useTranslation(),t=Y(),n=((i=t.views.VIE)==null?void 0:i.type)===q.Tabs,s=()=>{var a;return(a=t.views.VIE)==null?void 0:a.downloadSchema()};return n?r.jsx(o.Tooltip,{label:e("common.choose_a_tab_first"),children:r.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:r.jsx(M.IconCode,{size:16}),sx:{...Yf,transform:"none !important"},children:e("view.download_schema")})}):r.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:s,leftIcon:r.jsx(M.IconCode,{size:16}),sx:{...Yf},children:e("view.download_schema")})}),pi=({headers:e,rows:t})=>r.jsxs(o.Table,{fontSize:"xs",highlightOnHover:!0,sx:{tableLayout:"fixed",fontFamily:"monospace"},children:[r.jsx("thead",{children:e}),r.jsx("tbody",{children:t})]}),KE=({content:e})=>{const{t}=_.useTranslation(),n=e.views;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("view.labels")}),r.jsx(pi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.name")}),r.jsx("th",{children:t("common.type")})]}),rows:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.id}),r.jsx("td",{children:s.name}),r.jsx("td",{children:t(`view.component.${s.type}.label`)})]},s.id))})]})},XE=({content:e})=>{const{t}=_.useTranslation(),n=e.filters;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("filter.labels")}),r.jsx(pi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.key")}),r.jsx("th",{children:t("common.label")})]}),rows:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.id}),r.jsx("td",{children:s.key}),r.jsx("td",{children:s.label})]},s.id))})]})},JE=({content:e})=>{const{t}=_.useTranslation(),n=e.panels;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("panel.labels")}),r.jsx(pi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.name")}),r.jsx("th",{children:t("visualization.component")})]}),rows:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.id}),r.jsx("td",{children:s.name}),r.jsx("td",{children:s.viz.type})]},s.id))})]})},ZE=({content:e})=>{var s;const{t}=_.useTranslation(),n=(s=e.definition)==null?void 0:s.queries;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("query.labels")}),r.jsx(pi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.name")}),r.jsx("th",{style:{width:"140px"},children:t("common.type")}),r.jsx("th",{style:{width:"260px"},children:t("data_source.label")})]}),rows:n.map(i=>r.jsxs("tr",{children:[r.jsx("td",{children:i.id}),r.jsx("td",{children:i.name}),r.jsx("td",{children:i.type}),r.jsx("td",{children:i.key})]},i.id))})]})},HE=({content:e})=>{var s;const{t}=_.useTranslation(),n=(s=e.definition)==null?void 0:s.sqlSnippets;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("sql_snippet.labels")}),r.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:r.jsx(M.IconPointFilled,{size:10}),children:n.map(i=>r.jsx(o.List.Item,{children:i.key},i.key))})]})},eA=({content:e})=>{var s;const{t}=_.useTranslation(),n=Object.keys(((s=e.definition)==null?void 0:s.mock_context)??{});return n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("mock_context.label")}),r.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:r.jsx(M.IconPointFilled,{size:10}),children:n.map(i=>r.jsx(o.List.Item,{children:i},i))})]})},tA=({content:e})=>e?r.jsxs(o.Box,{children:[r.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(o.Text,{ta:"left",c:"dimmed",children:"Preview"}),r.jsxs(o.Stack,{children:[r.jsx(KE,{content:e}),r.jsx(XE,{content:e}),r.jsx(JE,{content:e}),r.jsx(ZE,{content:e}),r.jsx(HE,{content:e}),r.jsx(eA,{content:e})]})]}):null;function nA(e){if(e.target===null)throw new Error("FileReader failed with null result");if(typeof e.target.result!="string")throw new Error(`Unparsable file content of type: ${typeof e.target.result}`);let t=JSON.parse(e.target.result);if("content"in t&&(t=t.content),t.version!==en)throw new Error("Schema version mismatch");return t}const rA=D.observer(({onSuccess:e,stretchModal:t,shrinkModal:n})=>{var S,T;const{t:s}=_.useTranslation(),i=Y(),{handleSubmit:a,formState:{errors:l},setValue:c,watch:u,setError:d,clearErrors:p}=b.useForm({defaultValues:{content:null}}),h=({content:z})=>{try{if(!z)throw new Error("please use a valid json file");i.applyJSONSchema(z),sn.showNotification({title:"Successful",message:"",color:"green"}),e()}catch(I){console.error(I),sn.showNotification({title:"Failed",message:I.message,color:"red"})}},[f,m]=g.useState(null);g.useEffect(()=>{if(!f)return;const z=new FileReader;z.readAsText(f,"UTF-8"),z.onload=I=>{try{const E=nA(I);c("content",E),p("content")}catch(E){console.error(E),d("content",{type:"custom",message:E.message})}},z.onabort=()=>console.log("🟨 abort"),z.onerror=()=>{z.error&&(console.error(z.error),d("content",{type:"custom",message:z.error.message}))}},[f]);const[y]=u(["content"]),j=!y,k=(S=l==null?void 0:l.content)==null?void 0:S.message;return g.useEffect(()=>{!y||k?n():t()},[y,k]),r.jsx(o.Box,{mx:"auto",sx:{position:"relative"},children:r.jsxs("form",{onSubmit:a(h),children:[r.jsx(o.FileInput,{label:s("import.json_file"),required:!0,value:f,onChange:m,error:(T=l==null?void 0:l.content)==null?void 0:T.message,sx:{maxWidth:500}}),k?r.jsx(o.Table,{fontSize:12,mt:10,children:r.jsxs("tbody",{children:[r.jsxs("tr",{children:[r.jsx("th",{children:s("import.this_dashboard")}),r.jsx("td",{children:en})]}),r.jsxs("tr",{children:[r.jsx("th",{children:s("import.this_file")}),r.jsx("td",{style:{color:"red"},children:y==null?void 0:y.version})]})]})}):r.jsxs(r.Fragment,{children:[r.jsx(tA,{content:y}),r.jsx(o.Group,{position:"right",my:"md",children:r.jsx(o.Button,{type:"submit",color:"green",disabled:j,children:s("common.actions.confirm")})})]})]})})}),Kf={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},sA=D.observer(()=>{var d;const{t:e}=_.useTranslation(),[t,{open:n,close:s}]=he.useDisclosure(!1),[i,{setTrue:a,setFalse:l}]=W.useBoolean(!1),u=((d=Z().content.views.VIE)==null?void 0:d.type)===q.Tabs;return u?r.jsx(o.Tooltip,{label:e("common.choose_a_tab_first"),children:r.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:r.jsx(M.IconFileImport,{size:16}),sx:{...Kf,transform:"none !important"},children:e("import.label")})}):r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"subtle",color:"blue",radius:0,size:"xs",disabled:u||t,onClick:n,leftIcon:r.jsx(M.IconFileImport,{size:16}),sx:{...Kf},children:e("import.label")}),r.jsx(o.Modal,{opened:t,onClose:s,title:e("import.title"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},withinPortal:!0,zIndex:320,size:i?"90vw":500,children:r.jsx(rA,{onSuccess:s,stretchModal:a,shrinkModal:l})})]})}),iA={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},aA=D.observer(()=>r.jsx(o.Box,{sx:iA,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:r.jsxs(o.Group,{position:"apart",align:"center",sx:{height:"30px"},children:[r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(RE,{}),r.jsx(sA,{})]}),r.jsx(UE,{}),r.jsx(o.Group,{position:"right",spacing:0,children:r.jsx(YE,{})})]})})),oA=D.observer(e=>r.jsxs(r.Fragment,{children:[r.jsx(WE,{...e}),r.jsx(aA,{})]})),FL="";function lA(e,t,n){const s=[];return e.filter(i=>"__INTERACTIONS"in i.viz.conf).forEach((i,a)=>{const l=t[i.id];l.data.interactions=v.get(l,"data.interactions",[]);const{__INTERACTIONS:c,__OPERATIONS:u,__TRIGGERS:d}=i.viz.conf;Object.entries(u).forEach(([p,h])=>{const{schemaRef:f,data:m}=h,{config:y}=m;switch(f){case"builtin:op:open-link":let j=y.urlTemplate.substring(0,100);y.urlTemplate.length>=20&&(j+="..."),l.type="interaction",l.data.interactions.push({schemaRef:f,urlTemplate:y.urlTemplate,shortURLTemplate:j});return;case"builtin:op:open_view":s.push({id:`OPERATION--${p}`,source:i.id,target:y.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:f,filters:Object.keys(y.dictionary).map(k=>({key:k,label:n[k]}))});return;case"builtin:op:clear_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:f,filters:y.filter_keys.map(k=>({key:k,label:n[k]}))});return;default:return}})}),s}function cA(e,t){const n=e.filters.keyLabelMap;return{edges:lA(e.panels.list,t,n),edgeNodes:[]}}function Xf(e,t,n){return e*t+e*n}function uA(e,t,n){return e*t+(e-1)*n}const hi=25,Dl=40,Jf=25,Ml=350,dA=150,pA=150,Zf=150,Hf=300,fi=40,eg=25,hA=300;function fA(e,t){const n=v.keyBy(t,i=>i.id),s=[];return e.current.forEach((i,a)=>{i.panelIDs.forEach((l,c)=>{const u=Xf(c,fi,eg)+Dl,d=n[l];if(!d){s.push({id:l,_node_type:"panel",parentNode:i.id,data:{label:`!: ${l}`},position:{x:hi,y:u},sourcePosition:Ee.Position.Right,targetPosition:Ee.Position.Left,style:{width:Hf,height:fi}});return}const p=d.name;s.push({id:d.id,_node_type:"panel",parentNode:i.id,data:{label:p},position:{x:hi,y:u},sourcePosition:Ee.Position.Right,targetPosition:Ee.Position.Left,style:{width:Hf,height:fi}})})}),s}const gA={[q.Division]:"Div",[q.Modal]:"Modal",[q.Tabs]:"Tabs"},mA=Af;function xA(e){return e.current.map((n,s)=>{const i=uA(n.panelIDs.length,fi,eg)+Dl+Jf;let a=[];return n.type===q.Tabs&&(a=n.config.tabsInOrder.map(c=>c.view_id)),{id:n.id,_node_type:"view-root",_view_type:n.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:a,data:{label:`${gA[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:Ee.Position.Right,targetPosition:Ee.Position.Left,className:"light",style:{backgroundColor:mA[n.type],width:Ml,height:i}}})}function yA(e){const t=v.keyBy(e,n=>n.id);e.forEach(n=>{n._node_type!=="view-root"||n._view_type!==q.Tabs||n._tab_view_ids.forEach(s=>{t[s].parentNode=n.id})})}function bA(e){const t=xA(e.views);yA(t);const n=fA(e.views,e.panels.list);return[...t,...n]}function vA({nodeMap:e,nodes:t,edges:n}){t.forEach(s=>{s._node_type!=="view-root"||s._view_type!==q.Tabs||(s.sourcePosition=Ee.Position.Bottom,s.style.width=Ml+hi*2,s.style.height=Jf+s._tab_view_ids.reduce((i,a)=>{const l=e[a];l.position.y=i,l.position.x=hi;const c=l.style.height;return i+c+20},Dl))})}function _A({nodeMap:e,nodes:t,edges:n}){n.filter(s=>s.label==="Open View").forEach(s=>{const i=e[s.source],a=e[s.target];if(!i||!a||!i.parentNode)return;const l=e[i.parentNode];l._node_type!=="view-root"||a._node_type!=="view-root"||(a._view_level+=1+l._view_level,l._sub_view_ids.push(a.id))}),t.sort((s,i)=>s._node_type==="view-root"&&i._node_type==="view-root"?s._view_level-i._view_level:s._node_type!=="view-root"&&i._node_type!=="view-root"?0:s._node_type==="view-root"?-1:1)}function jA({nodeMap:e,nodes:t,edges:n}){const s={};n.forEach(i=>{if(i.label!=="Open View")return;const a=e[i.source],l=e[i.target];if(a&&l&&a.parentNode){const c=e[a.parentNode],u=c.position.x,d=Number(v.get(l,"style.height",0)),p=Number(c.style.width);l.position.x=u+p+hA,c._view_level===0&&l._sub_view_ids.length===0&&(a.sourcePosition=Ee.Position.Left,l.targetPosition=Ee.Position.Right,l.position.x*=-1);const f=l.position.x,m=v.get(s,f,0);l.position.y=m,s[f]=m+d+Zf}})}function wA({nodeMap:e,nodes:t,edges:n}){const s=new Set,i=new Set;n.forEach(l=>{s.add(l.source),i.add(l.target)}),t.filter(l=>l._node_type!=="view-root"||l.id==="Main"||l.parentNode?!1:!s.has(l.id)&&!i.has(l.id)).forEach((l,c)=>{l.position.x=Xf(c,Ml,pA),l.position.y=0-dA-Zf})}function CA({nodeMap:e,nodes:t,edges:n}){const s={nodeMap:e,nodes:t,edges:n};return wA(s),_A(s),vA(s),jA(s),{nodes:t,edges:n}}function SA(e){const t=bA(e),n=v.keyBy(t,u=>u.id),{edges:s,edgeNodes:i}=cA(e,n),a=[...t,...i],l=v.keyBy(a,u=>u.id),c={edges:v.uniqBy(s,u=>u.id),nodes:a,nodeMap:l};return CA(c)}const GL="",zl={"builtin:op:open-link":r.jsx(o.ThemeIcon,{color:"blue",size:20,radius:"xl",children:r.jsx(M.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":r.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:r.jsx(M.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":r.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:r.jsx(M.IconCircleOff,{size:14})})};function kA(e){const t=[];return e.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":t.push({key:n.urlTemplate,icon:zl[n.schemaRef],text:r.jsxs(o.Group,{spacing:4,children:[r.jsx(o.Text,{children:"Open: "}),r.jsx(o.Text,{color:"dimmed",children:n.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":n.filters.forEach(({key:s,label:i})=>{t.push({key:n.schemaRef+s,icon:zl[n.schemaRef],text:r.jsx(o.Group,{spacing:4,children:r.jsxs(o.Text,{children:["Set Filter: ",i]})})})});return;case"builtin:op:clear_filter_values":n.filters.forEach(({key:s,label:i})=>{t.push({key:n.schemaRef+s,icon:zl[n.schemaRef],text:r.jsx(o.Group,{spacing:4,children:r.jsxs(o.Text,{children:["Clear Filter: ",i]})})})});return}}),t}const TA=g.memo(({data:e,isConnectable:t,sourcePosition:n=Ee.Position.Right,targetPosition:s=Ee.Position.Left,...i})=>{const a=g.useMemo(()=>kA(e.interactions),[e.interactions]);return r.jsxs(r.Fragment,{children:[r.jsx(Ee.Handle,{type:"target",position:s,isConnectable:t}),r.jsx(o.Box,{sx:{position:"absolute",top:0,right:0},children:r.jsx(V.ChevronsUpRight,{size:12})}),r.jsxs(o.HoverCard,{shadow:"xl",withinPortal:!0,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Text,{children:e.label})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(o.List,{spacing:"xs",size:"sm",center:!0,children:a.map(l=>r.jsx(o.List.Item,{icon:l.icon,children:l.text},l.key))})})]}),r.jsx(Ee.Handle,{type:"source",position:n,isConnectable:t})]})}),WL="",DA={interaction:TA},MA=D.observer(()=>{const e=_e(),{edges:t,nodes:n}=SA(e);return r.jsxs(Ee,{nodes:n,edges:t,onNodesChange:v.noop,onEdgesChange:v.noop,onConnect:v.noop,className:"interactions-viewer",fitView:!0,nodeTypes:DA,children:[r.jsx(Ee.MiniMap,{}),r.jsx(Ee.Controls,{}),r.jsx(Ee.Background,{})]})}),zA=D.observer(({opened:e,close:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Modal,{size:"96vw",opened:e,onClose:t,title:n("interactions.interactions_viewer"),trapFocus:!0,onDragStart:s=>{s.stopPropagation()},styles:{body:{height:"calc(90vh - 54px)"},content:{transform:"none !important"}},zIndex:300,children:r.jsx(MA,{})})}),IA={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}};function EA({onClick:e,name:t,active:n,openSettings:s}){return r.jsxs(o.Box,{sx:{position:"relative"},children:[r.jsx(o.UnstyledButton,{sx:i=>({display:"block",width:"100%",padding:i.spacing.xs,borderRadius:0,position:"relative",color:i.black,"&:hover":{backgroundColor:i.colors.gray[0]},backgroundColor:n?i.colors.gray[2]:"transparent"}),children:r.jsx(o.Group,{sx:{width:"calc(100% - 28px)"},onClick:e,children:r.jsx(o.Text,{size:"sm",children:t})})}),n&&r.jsx(o.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:r.jsx(o.ActionIcon,{onClick:s,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:r.jsx(M.IconAdjustments,{size:16})})})]})}const AA=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=Y(),s=g.useCallback(a=>()=>n.views.setIDOfVIE(a),[n]),i=a=>{t.editor.open(["_VIEWS_",a])};return r.jsxs(o.Box,{sx:{position:"relative"},children:[n.views.options.map(a=>r.jsx(EA,{active:n.views.idOfVIE===a.value,name:a.label,onClick:s(a.value),openSettings:()=>i(a.value)},a.value)),r.jsx(o.Divider,{variant:"dashed"}),r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:n.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:e("view.add")})]})}),PA=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=Y(),s=()=>{if(!n.queries.firstID){t.editor.open(["_QUERIES_",""]);return}t.editor.open(["_QUERIES_",n.queries.firstID])},i=()=>{if(!n.filters.firstID){t.editor.open(["_FILTERS_",""]);return}t.editor.open(["_FILTERS_",n.filters.firstID])},[a,l]=g.useState(!1),c=()=>l(!0),u=()=>l(!1);return r.jsxs(o.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},zIndex:299,children:[r.jsxs(o.Navbar.Section,{children:[r.jsxs(o.Group,{grow:!0,spacing:0,sx:{...IA,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[r.jsx(o.Tooltip,{label:e("filter.labels"),withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:i,children:r.jsx(M.IconFilter,{size:18})})}),r.jsx(o.Tooltip,{label:e("query.labels"),withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:s,children:r.jsx(M.IconDatabase,{size:18})})}),r.jsx(o.Tooltip,{label:e("interactions.interactions_viewer"),withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:c,children:r.jsx(M.IconLink,{size:18})})})]}),r.jsx(zA,{opened:a,close:u})]}),r.jsx(o.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:e("view.labels")})}),r.jsx(o.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:r.jsx(AA,{})}),r.jsx(o.Navbar.Section,{children:r.jsx(o.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:r.jsx(o.Button,{size:"xs",leftIcon:r.jsx(M.IconSettings,{size:20}),onClick:()=>t.editor.open([]),children:e("common.titles.settings")})})})]})}),OA={[ce.Checkbox]:"true",[ce.DateRange]:"[new Date('2023-01-01 00:00:00'), new Date('2024-01-01 00:00:00')]",[ce.MultiSelect]:"[]",[ce.Select]:'""',[ce.TreeSelect]:"[]",[ce.TextInput]:'""'},LA=e=>["function getDefaultValue(filter, utils, context) {",` return ${OA[e]};`,"}"].join(`
|
|
457
|
-
`),ar=D.observer(({filter:e})=>{const{t}=_.useTranslation();return r.jsx(Ri,{label:"",title:t("filter.field.custom_default_value.title"),triggerLabel:t("filter.field.custom_default_value.trigger"),value:e.default_value_func,onChange:e.setDefaultValueFunc,defaultValue:
|
|
456
|
+
`}})).actions(e=>({setPage(t){e.page=t},resetPage(){e.page=1},setLimit(t){e.limit=t}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>e.keywordString,e.resetPage,{fireImmediately:!1,delay:0})),x.addDisposer(e,X.reaction(()=>e.limit,e.resetPage,{fireImmediately:!1,delay:0}))}})),AE=x.types.model({data:x.types.optional(x.types.frozen(),{}),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return Object.keys(e.data).length===0}})),PE=x.types.compose("DataSourceModel",cl,x.types.model({tables:x.types.optional(AE,{}),columns:x.types.optional(zE,{}),tableData:x.types.optional(EE,{}),indexes:x.types.optional(IE,{}),table_schema:x.types.optional(x.types.string,""),table_name:x.types.optional(x.types.string,"")})).views(e=>({get sqlDataSourceType(){return e.type},get reloadConditionString(){const{type:t,table_name:n,table_schema:s}=e;return`${t};${n};${s}`}})).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(e=>({setKeywords(t,n){e.table_schema=t,e.table_name=n}})).actions(e=>({initKeywords(){if(e.tables.empty)return;const t=Object.keys(e.tables.data)[0],n=e.tables.data[t][0].table_name;e.setKeywords(t,n)}})).actions(e=>{const t=x.flow(function*(){var n;(n=e.controllers.tables)==null||n.abort(),e.controllers.tables=new AbortController,e.tables.state="loading";try{const s=yield*x.toGenerator(Ot.structure(e.controllers.tables.signal)({query_type:"TABLES",type:e.sqlDataSourceType,key:e.key,table_schema:"",table_name:""},{params:{query_type:"TABLES"}}));e.tables.data=v.groupBy(s,"table_schema"),e.tables.state="idle",e.tables.error=null,e.initKeywords()}catch(s){if(!At.isCancel(s)){e.tables.data={};const i=v.get(s,"message","unkown error");e.tables.error=v.get(s,"response.data.detail.message",i),e.tables.state="error"}}});return{loadTables:t,loadTablesIfEmpty(){e.tables.empty&&t()},loadColumns:x.flow(function*(){var n;(n=e.controllers.columns)==null||n.abort(),e.controllers.columns=new AbortController,e.columns.state="loading";try{e.columns.data=yield*x.toGenerator(Ot.structure(e.controllers.columns.signal)({query_type:"COLUMNS",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"COLUMNS"}})),e.columns.state="idle",e.columns.error=null}catch(s){if(At.isCancel(s))e.columns.state="idle",e.columns.error=null;else{e.columns.data=[];const i=v.get(s,"message","unkown error");e.columns.error=v.get(s,"response.data.detail.message",i),e.columns.state="error"}}}),loadIndexes:x.flow(function*(){var n;(n=e.controllers.indexes)==null||n.abort(),e.controllers.indexes=new AbortController,e.indexes.state="loading";try{e.indexes.data=yield*x.toGenerator(Ot.structure(e.controllers.indexes.signal)({query_type:"INDEXES",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"INDEXES"}})),e.indexes.state="idle",e.indexes.error=null}catch(s){if(At.isCancel(s))e.indexes.state="idle",e.indexes.error=null;else{e.indexes.data=[];const i=v.get(s,"message","unkown error");e.indexes.error=v.get(s,"response.data.detail.message",i),e.indexes.state="error"}}}),loadTableData:x.flow(function*(){var s;(s=e.controllers.tableData)==null||s.abort(),e.controllers.tableData=new AbortController;const n=e.tableData;n.state="loading";try{n.data=yield*x.toGenerator(Ot.structure(e.controllers.tableData.signal)({query_type:"DATA",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name,limit:n.limit,offset:n.offset},{params:{query_type:"DATA"}}));const[{total:i}]=yield*x.toGenerator(Ot.structure(e.controllers.tableData.signal)({query_type:"COUNT",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"COUNT"}}));n.total=Number(i),n.state="idle",n.error=null}catch(i){if(At.isCancel(i))n.state="idle",n.error=null;else{n.data=[];const a=v.get(i,"message","unkown error");n.error=v.get(i,"response.data.detail.message",a),n.state="error"}}})}}).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>e.reloadConditionString,e.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>e.reloadConditionString,e.loadIndexes,{fireImmediately:!1,delay:500})),x.addDisposer(e,X.reaction(()=>`${e.reloadConditionString};limit:${e.tableData.limit};offset:${e.tableData.offset}`,e.loadTableData,{fireImmediately:!1,delay:0}))}})),OE=x.types.model("DataSourcesModel",{list:x.types.optional(x.types.array(PE),[])}).views(e=>({find({type:t,key:n}){return e.list.find(s=>s.key===n&&s.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}}));function In(e){return{label:e,value:e,_type:"ACTION",_action_type:e,Icon:null,children:null}}function LE(e){switch(e._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",e.value];case"sql_snippet":return["_SQL_SNIPPETS_",e.value];case"query":return["_QUERIES_",e.value];case"view":return["_VIEWS_",e.value];case"panel":return e.parentID?["_VIEWS_",e.parentID,"_PANELS_",e.value]:(console.error("[getPathFromOption] parentID is required"),null)}}const BE=x.types.model("EditorModel",{path:x.types.optional(x.types.frozen(),[]),settings_open:x.types.optional(x.types.boolean,!1)}).views(e=>({get navOptions(){const{content:t}=x.getRoot(e),{filters:n,views:s,sqlSnippets:i,queries:a}=t;return[{label:"query_variable.labels",value:"_QUERY_VARS_",_type:"query_variables",Icon:M.IconVariable},{label:"mock_context.label",value:"_MOCK_CONTEXT_",Icon:M.IconCodeDots,_type:"mock_context"},{label:"filter.labels",value:"_FILTERS_",Icon:M.IconFilter,children:[In("_FILTERS_SETTINGS_"),...n.options,In("_Add_A_Filter_")],_type:"GROUP"},{label:"sql_snippet.labels",value:"_SQL_SNIPPETS_",Icon:M.IconCopy,children:[In("_SQL_SNIPPETS_SETTINGS_"),...i.options,In("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"query.labels",value:"_QUERIES_",Icon:M.IconDatabase,children:[In("_QUERIES_SETTINGS_"),...a.options,In("_Add_A_QUERY_")],_type:"GROUP"},{label:"view.labels",value:"_VIEWS_",Icon:M.IconBoxMultiple,children:[...s.editorOptions,In("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(t,n){return t.length===0?!1:t[t.length-1]===n.value},isOptionOpened(t){const{path:n}=e;return n.length===0||!t.children||t.children.length===0?!1:n.includes(t.value)}})).actions(e=>({setPath(t){e.path=t},setSettingsOpen(t){e.settings_open=t}})).actions(e=>({open(t){e.setPath(t),e.setSettingsOpen(!0)},close(){e.setSettingsOpen(!1)},navigate(t){const n=LE(t);n&&e.setPath(n)}})),qE=x.types.compose("LayoutsModel",vl,x.types.model({currentLayoutWrapperWidth:x.types.optional(x.types.number,0)})).views(e=>({get divisionPreviewScale(){const t=e.currentLayoutPreviewWidth,n=e.currentLayoutWrapperWidth;return!t||!n||t<=n?1:n/t}})).actions(e=>({addALayoutItem(t){e.list.forEach(n=>{n.addNewLayout(t)})},duplicateLayoutItemsByPanelID(t,n){e.list.forEach(s=>{const i=s.findByPanelID(t);if(!i){console.error(`Can't find a layout item by panelID[${t}] in layoutSet[${s.name}]`);return}s.list.push({...i,id:Ut.v4(),panelID:n,y:1/0})})},removeByPanelID(t){e.list.forEach(n=>{n.removeByPanelID(t)})},setCurrentLayoutWrapperWidth(t){e.currentLayoutWrapperWidth=t},addALayoutSet(t,n,s){const i=e.basisLayoutSet,a={id:t,name:n,breakpoint:s,list:i.json.list.map(l=>({...l,id:Ut.v4()}))};e.list.push(a)},updateLayoutSetsInfo(t){const n=v.keyBy(e.list,"id");t.forEach(a=>{const l=n[a.id];if(l){l.setName(a.name),l.setBreakpoint(a.breakpoint),delete n[a.id];return}this.addALayoutSet(a.id,a.name,a.breakpoint)});const s=new Set(Object.keys(n)),i=s.size>0;s.forEach(a=>{const l=e.list.findIndex(c=>c.id===a);e.list.splice(l,1)}),i&&e.setCurrentBreakpoint("basis")},updateCurrentLayoutItem(t){e.currentLayoutSet.updateLayoutItem(t)},updateCurrentLayoutItems(t){t.forEach(n=>{e.currentLayoutSet.updateLayoutItem(n)})},append(t){e.list.push(t)},appendMultiple(t){t.length!==0&&e.list.push(...t)},remove(t){e.list.splice(t,1)},removeByID(t){const n=e.list.findIndex(s=>s.id===t);n!==-1&&e.list.splice(n,1)},removeByIDs(t){t.forEach(n=>{this.removeByID(n)})}})),qf=fl.views(e=>({get realDataFieldOptions(){return e.queryIDs.length===0?[]:e.queries.map(t=>{const n=t.data;return n.length===0?[]:Object.keys(n[0]).map(i=>({label:i,value:`${t.id}.${i}`,group:t.name,group_id:t.id,disabled:!1}))}).flat()},get realQueryOptions(){return e.queryIDs.length===0?[]:e.queries.map(t=>({label:t.name,value:t.id,disabled:!1}))},queryOptions(t,n){const s=[...this.realQueryOptions];return t&&!s.find(i=>i.value===t)&&s.unshift({label:t,value:t,disabled:!0}),n&&s.unshift({label:"unset",value:"",disabled:!1}),s},dataFieldOptions(t,n,s){let i=[...this.realDataFieldOptions];if(s&&(i=i.filter(a=>a.group_id===s)),t&&!i.find(a=>a.value===t)){const a=O(t),l=e.queryByID(a.queryID);i.unshift({label:a.columnKey,value:t,group:l?l.name:a.queryID,group_id:l?l.id:"",disabled:!0})}return n&&i.unshift({label:"unset",value:"",group:"",group_id:"",disabled:!1}),i},explainDataKey(t){const{queryID:n,columnKey:s}=O(t),i=e.queries.find(a=>a.id===n);return i?{queryID:n,queryName:i.name,columnKey:s}:{queryID:n,queryName:null,columnKey:s}}})).actions(e=>({removeSelf(){x.getParent(e,2).removeByID(e.id)}})).actions(e=>({moveToView(t,n){x.getRoot(e).content.views.findByID(t).removePanelID(e.id),x.getRoot(e).content.views.findByID(n).appendPanelID(e.id),x.getRoot(e).editor.setPath(["_VIEWS_",n,"_PANELS_",e.id])}})),Vf=x.types.compose("PanelsModel",gl,x.types.model({list:x.types.optional(x.types.array(qf),[])})).views(e=>({get contentModel(){return x.getRoot(e).content},editorOptions(t,n){const s=e.panelsByIDs(n);s.length!==n.length&&console.warn(`Unfulfilled panels for View[${t}]`);const i=s.map(l=>({label:l.name,value:l.id,_type:"panel",parentID:t})),a="_Add_A_PANEL_";return i.push({label:a,value:a,_type:"ACTION",_action_type:a,parentID:t,Icon:null,children:null}),i}})).actions(e=>({replace(t){e.list=x.castToSnapshot(t)},append(t){e.list.push(t)},appendMultiple(t){t.length!==0&&e.list.push(...t)},remove(t){e.list.splice(t,1)},removeByID(t){const n=e.list.findIndex(s=>s.id===t);n!==-1&&e.list.splice(n,1)},removeByIDs(t){t.forEach(n=>{this.removeByID(n)})},duplicateByID(t){const n=e.list.find(i=>i.id===t);if(!n){console.error(new Error(`[duplicate panel] Can't find a panel by id[${t}]`));return}const s=new Date().getTime().toString();return e.list.push({...n.json,id:s,title:{...n.json.title}}),e.contentModel.layouts.duplicateLayoutItemsByPanelID(n.id,s),s},replaceByIndex(t,n){e.list.splice(t,1,n)}})),VE=pl.actions(e=>({getSchema(){const t=e.json,n=[],s=[];e.panels.forEach(l=>{const c=l.getSchema();n.push(c.panel),c.queries.length>0&&s.push(...c.queries)});const i=e.contentModel.layouts.jsonByPanelIDSet(new Set(e.panelIDs));return{views:[t],panels:n,definition:{queries:v.uniqBy(s,l=>l.id)},layouts:i,version:en}},downloadSchema(){if(e.type===q.Tabs){console.error(new Error("Please choose a tab first"));return}const t=JSON.stringify(this.getSchema(),null,2),n=e.name;ir(n,t)}})),Nf=x.types.compose("ViewsModel",hl,x.types.model({current:x.types.optional(x.types.array(VE),[]),idOfVIE:x.types.string})).views(e=>({get isVIETheFirstView(){return e.current.length===0||!e.idOfVIE?!1:e.current[0].id===e.idOfVIE},get VIE(){return e.current.find(({id:t})=>t===e.idOfVIE)},get options(){return e.current.map(t=>({label:t.name,value:t.id,type:t.type}))},get editorOptions(){const t=x.getRoot(e).content.panels;return e.current.map(n=>({label:n.name,value:n.id,_type:"view",children:t.editorOptions(n.id,n.panelIDs)}))}})).actions(e=>({setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},replace(t){e.current.replace(t)},addANewView(t,n,s,i){e.current.push({id:t,name:n,type:s,config:i,panelIDs:[]})},append(t){e.current.push(t)},appendMultiple(t){t.length!==0&&e.current.push(...t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(a=>a.id===t);if(n===-1)return;const s=e.current[n];x.getRoot(e).content.panels.removeByIDs(s.panelIDs),e.current.splice(n,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},addARandomNewView(){const t=new Date().getTime().toString();this.addANewView(t,q.Division,q.Division,{_name:q.Division}),this.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(this.removeByID(e.idOfVIE),this.setIDOfVIE(e.current[0].id))}}));function kl(e){const t=e.length>0?[e[0].id]:[],n=e.length>0?e[0].id:"";return{current:e.map(i=>{const{_name:a=i.type}=i.config;return{...i,config:{...i.config,_name:a},panelIDs:i.panelIDs}}),visibleViewIDs:t,idOfVIE:n}}const NE=x.types.model({id:x.types.string,name:x.types.string,dashboard_id:x.types.string,create_time:x.types.string,update_time:x.types.string,version:x.types.string,filters:Pf,queries:Lf,sqlSnippets:Bf,views:Nf,panels:Vf,layouts:qE,mock_context:Ko,origin:x.types.maybe(x.types.frozen())}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get filtersChanged(){const t="filters.current";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get queriesChanged(){const t="queries.current",n=x.getSnapshot(v.get(e,t)).map(s=>v.pick(s,["id","name","key","type","sql","run_by","react_to","pre_process","post_process","dep_query_ids"]));return!v.isEqual(n,v.get(e.origin,t))},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get viewsChanged(){const t="views.current";return!v.isEqual(e.views.json,v.get(e.origin,t))},get panelsChanged(){const t="panels.list";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get layoutsChanged(){const t="layouts.list";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get mockContextChanged(){const t="mock_context.current";return!v.isEqual(v.get(e,t),v.get(e.origin,t))},get context(){const t=x.getParent(e).context.current;return{...e.mock_context.current,...t}},get payloadForSQL(){const t=x.getParent(e).globalSQLSnippets,n={context:this.context,filters:e.filters.values};return{...n,sql_snippets:Rr(e.sqlSnippets.current,"key","value",n),global_sql_snippets:Rr(t.list,"id","content",n)}},get payloadForViz(){const t=x.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.values}},get dashboardState(){return Ki(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardState}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.layoutsChanged||this.mockContextChanged},get data(){return e.queries.current.map(({id:n,data:s})=>({id:n,data:s})).reduce((n,s)=>(n[s.id]=s.data,n),{})},getDataStuffByID(t){const n=e.queries.findByID(t);return n?{data:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).views(e=>({get queriesUsage(){const t=e.panels.idMap,n=[];e.views.current.forEach(i=>{i.panelIDs.forEach(a=>{const l=t.get(a);if(!l)return;const c="panel",u=l.name,d=[{id:i.id,label:i.name}];l.queryIDs.forEach(p=>{n.push({id:a,queryID:p,type:c,type_label:"panel.label",label:u,views:d})})})});const s=e.views.idMap;return e.filters.current.filter(i=>!!v.get(i,"config.options_query_id")).forEach(i=>{n.push({type:"filter",type_label:"filter.label",id:i.id,queryID:v.get(i,"config.options_query_id"),label:i.label,views:i.visibleInViewsIDs.map(a=>{var l;return{id:a,label:((l=s.get(a))==null?void 0:l.name)??a}})})}),e.queries.current.forEach(i=>{i.isTransform&&i.dep_query_ids.forEach(a=>{n.push({type:"transform-query",type_label:"query.transform.full_label",id:i.id,queryID:a,label:i.name,views:[]})})}),v.groupBy(n,"queryID")},get hasUnusedQueries(){return e.queries.current.length>Object.keys(this.queriesUsage).length},findQueryUsage(t){return this.queriesUsage[t]??[]},get sqlSnippetsUsage(){const t=[];return e.queries.current.forEach(n=>{if(!n.typedAsSQL)return;v.uniq(n.sql.match(vs.sqlSnippet)).forEach(i=>{t.push({queryID:n.id,sqlSnippetKey:i,queryName:n.name})})}),v.groupBy(t,"sqlSnippetKey")},get hasUnusedSQLSnippets(){return e.sqlSnippets.current.length>Object.keys(this.sqlSnippetsUsage).length},findSQLSnippetUsage(t){return this.sqlSnippetsUsage[t]??[]}})).actions(e=>({removeUnusedQueries(){const t=new Set(Object.keys(e.queriesUsage)),n=e.queries.current.filter(s=>!t.has(s.id)).map(s=>s.id);e.queries.removeQueries(n)},removeUnusedSQLSnippets(){const t=new Set(Object.keys(e.sqlSnippetsUsage)),n=e.sqlSnippets.current.filter(s=>!t.has(s.key)).map(s=>s.key);e.sqlSnippets.removeByKeys(n)},duplicatePanelByID(t,n){var i;const s=e.panels.duplicateByID(t);s&&((i=e.views.findByID(n))==null||i.appendPanelID(s))},removePanelByID(t,n){var s;e.panels.removeByID(t),e.layouts.removeByPanelID(t),(s=e.views.findByID(n))==null||s.removePanelID(t)},addANewPanel(t){var s;const n=Ut.v4();e.panels.append(of(n)),(s=e.views.findByID(t))==null||s.appendPanelID(n),e.layouts.addALayoutItem(n)},applyJSONSchema(t){var h;const{views:n,panels:s,filters:i,definition:a={},layouts:l}=t,{queries:c,sqlSnippets:u,mock_context:d}=a,p=new Map;if(Array.isArray(s)){const f=s.map(m=>{const y=Ut.v4();return p.set(m.id,y),{...m,id:y}});if(e.panels.appendMultiple(f),!Array.isArray(n)||n.length===0){const m=f.map(y=>y.id);(h=e.views.VIE)==null||h.appendPanelIDs(m)}}if(Array.isArray(n)){const f=n.map(m=>{const y=m.panelIDs.map(j=>p.get(j)??j);return{...m,id:Ut.v4(),panelIDs:y}});e.views.appendMultiple(f)}if(Array.isArray(l)){const f=(j,k)=>e.layouts.breakpointNameRecord[j]===k;let m=[];const y=l.filter(j=>f(j.name,j.breakpoint));y.forEach(j=>{j.id==="basis"&&(m=j.list),j.list.forEach(k=>{const S=p.get(k.panelID);k.id=Ut.v4(),k.panelID=S})}),e.layouts.list.forEach(j=>{const k=y.find(S=>S.name===j.name&&S.breakpoint===j.breakpoint);if(!k){m.forEach(S=>{j.addLayout(S)});return}k.list.forEach(S=>{j.addLayout(S)})})}Array.isArray(i)&&e.filters.appendMultiple(i),Array.isArray(c)&&e.queries.appendMultiple(c),Array.isArray(u)&&e.sqlSnippets.appendMultiple(u),d&&Object.keys(d).length>0&&e.mock_context.defaults(d)}})).actions(e=>({reset(){x.applySnapshot(e.filters.current,e.origin.filters.current),x.applySnapshot(e.queries.current,e.origin.queries.current),x.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),x.applySnapshot(e.views.current,e.origin.views.current),x.applySnapshot(e.panels.list,e.origin.panels.list),x.applySnapshot(e.layouts.list,e.origin.layouts.list),e.mock_context.current=e.origin.mock_context.current},resetFilters(){x.applySnapshot(e.filters.current,e.origin.filters.current)},updateCurrent(t){const{id:n,name:s,content:i}=t;if(!i)throw new Error("unexpected null content when updating a content model");const{version:a,filters:l,views:c,panels:u,definition:{queries:d,sqlSnippets:p,mock_context:h={}}}=i;e.id=n,e.name=s,e.version=a,x.applySnapshot(e.filters.current,l),x.applySnapshot(e.views.current,kl(c).current),x.applySnapshot(e.panels.list,u),x.applySnapshot(e.queries.current,d),x.applySnapshot(e.sqlSnippets.current,p),e.mock_context.current=h}})),Tl=x.types.snapshotProcessor(NE,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=x.castToSnapshot(e.queries.current.map(n=>v.pick(n,["id","key","type","sql"])));return v.defaults({},{queries:{current:t}},e)}});function $E(e,t){t.filters&&x.applySnapshot(e.filters.current,t.filters)}function $f({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,content:a},l,c){if(!a)throw new Error("unexpected null content when creating a content model");const{version:u,filters:d,views:p,panels:h,layouts:f,definition:{queries:m,sqlSnippets:y,mock_context:j={}}}=a;return Tl.create({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,version:u,filters:xl(d,l,j,c),queries:{current:m},sqlSnippets:{current:y},mock_context:Xo(j),views:kl(p),panels:{list:h},layouts:{list:f,currentBreakpoint:f[0].id}})}const Ff=x.types.model({id:x.types.identifier,name:x.types.string,group:x.types.string,content:Tl,content_id:x.types.string,datasources:OE,globalSQLSnippets:ul,context:oi,editor:BE}).views(e=>({get json(){return{id:e.id,name:e.name,group:e.group,content_id:e.content_id}}})).actions(e=>({updateCurrentContent(t){e.content.updateCurrent(t)},updateCurrent(t,n){const{id:s,name:i,group:a,content_id:l}=t;e.id=s,e.name=i,e.group=a,e.content_id=l,this.updateCurrentContent(n)}}));function Gf({id:e,name:t,group:n,content_id:s},i,a,l,c,u){return Ff.create({id:e,name:t,group:n,content_id:s,content:$f(i,c,u),datasources:{list:a},globalSQLSnippets:{list:l},context:dl(c),editor:{}})}const FE={translation:{filter:{label:"Filter",labels:"Filters",add:"Add a Filter",manage:"Manage Filters",show_filters:"Show Filters",hide_filters:"Hide Filters",field:{widget:"Widget",visible_in:"Visible in...",key_placeholder:"A unique key to refer",label_placeholder:"Label for this field",auto_submit:"Submit automatically",order:"Placement Order",custom_default_value:{trigger:"Custom",title:"Custom default value",tips:"Tips",tip_1:"Function has the highest priority of getting filter's default value",tip_2:"Leave this editor empty to disable this feature"}},widget:{names:{select:"Select",multi_select:"Multi Select",tree_select:"Tree Select",text_input:"Text Input",checkbox:"Checkbox",date_range:"Date Range"},common:{use_query_data_as_options:"Use query data as options",fetch_options_from_datasource:"Fetch options from datasource",or_fetch_options_from_datasource:"Or fetch options from datasource",selector_option_empty:"Not found",see_data_structure:"Click to see expected data structure",using_query:"Using query",default_selection_count:"Select first N options by default",min_width:"Min width",x_selected:"{{count}} selected"},text_input:{default_value:"Default Value",required:"Required"},select:{width:"Width",required:"Required",clearable:"Clearable",configure_options:"Configure options",default_selection:"Default Selection",no_default_selection:"none",select_first_option_by_default:"Select the first option by default"},multi_select:{width_description:"At least 160px"},tree_select:{strictly:"Parent and children nodes are not associated"},checkbox:{description:"Description",default_checked:"Default checked"},date_range:{required:"Required",allow_single_date:"Allow choosing 1 day",display_format:"Display format",max_days:"Max days",one_day:"1 day",x_days:"{{count}} days",x_max_days:"{{max_days}} days max",default_value:"Default value",default_by_shortcut:"Default by shortcut",default_by_shortcut_placeholder:"Priors default value",start_date:"Start date",end_date:"End date",shortcut:{last:{label:"last",d:"yesterday",w:"week",m:"month",m2:"2 months",m3:"3 months",y:"year",full:{d:"yesterday",w:"last week",m:"last month",m2:"last 2 months",m3:"last 3 months",y:"last year"}},recent:{label:"recent",d7:"7 days",d30:"30 days",d60:"60 days",d90:"90 days",d180:"180 days",d365:"365 days",full:{d7:"recent 7 days",d30:"recent 30 days",d60:"recent 60 days",d90:"recent 90 days",d180:"recent 180 days",d365:"recent 365 days"}},this:{label:"this",d:"today",w:"week",m:"month",y:"year",full:{d:"today",w:"this week",m:"this month",y:"this year"}},this_so_far:{label:"this...so far",w:"week",m:"month",y:"year",full:{w:"this week so far",m:"this month so far",y:"this year so far"}}}}}},view:{label:"View",labels:"Views",add:"Add a View",delete:"Delete this View",download_schema:"Download this View",component:{div:{label:"Division"},tabs:{label:"Tabs",tabs_settings:"Tabs Settings",tab:{name:"Tab Name",view:"View",order:"Placement Order",color:"Color",delete:"Delete this tab",switch_to_view:"Swith to View: {{name}}"}},modal:{label:"Modal",modal_settings:"Modal settings",title:"Modal Title",custom_title:"Customize modal title",width:"Width",height:"Height"}}},interactions:{label:"Interactions",add:"Add an interaction",interactions_viewer:"Interactions Viewer",unavailable:"Unavailable",unavailable_reason:"This visualization does not have available interactions to choose from",trigger:{setup:"Setup Trigger",label:"Trigger",payload:"Payload"},operation:{setup:"Operation Settings",label:"Operation",settings:"Settings",variables:"Variables",console_log:{label:"console.log | debug",log_content:"log content"},open_link:{label:"Open Link",url:"URL",open_in_new_tab:"Open in new tab"},open_view:{label:"Open View",view:"View"},set_filter_values:{label:"Set Filter Values",set_filter:"Set filter",with:"with"},clear_filter_values:{label:"Clear Filter Values",select_filter:"Select filters to clear"}}},query_variable:{label:"Query Variable",labels:"Query Variables",add:"Add a Variable",guide:{tabs:{guide:"Guide",variables_in_this_dashboard:"Variables in this dashboard",global_sql_snippets:"Global SQL Snippets"}},open:"See Query Variables"},sql_snippet:{label:"SQL Snippet",labels:"SQL Snippets",add:"Add a SQL Snippet",delete:"Delete this SQL Snippet",delete_unused:"Delete unused SQL Snippets",manage:"Manage SQL Snippets",key:"Key",key_occupied:"This key is occupied by another snippet",edit_snippet:"Edit SQL Snippet",preview_snippet:"Preview SQL Snippet",usage:{label:"Usage"}},global_sql_snippet:{label:"Global SQL Snippet",labels:"Global SQL Snippets",description:"SQL snippets worth sharing between dashboards are managed in System Settings by admins."},common:{titles:{settings:"Settings",edit:"Edit",config:"Config"},pagination:{page_size:"Page Size",total:"Total",total_rows:"Total {{total}} row(s)"},align:{horizontal:{label:"Horizontal Align",left:"left",center:"center",right:"right"},vertical:{label:"Vertical Align",top:"top",center:"center",bottom:"bottom"}},id:"ID",name:"Name",key:"Key",label:"Label",value:"Value",type:"Type",info:"Info",min:"Min",max:"Max",data_field:"Data Field",name_data_field:"Name Data Field",value_data_field:"Value Data Field",color_data_field:"Color Data Field",enabled:"Enabled",copied:"Copied to clipboard",action:"Action",actions:{open:"Open",close:"Close",save:"Save",save_changes:"Save Changes",revert:"Revert",revert_changes:"Revert Changes",reset_to_default:"Reset to default",init_with_default:"Init with default",select_all:"Select All",clear_selection:"Clear Selection",refresh:"Refresh",download_data:"Download Data",download_schema:"Download Schema",download_screenshot:"Screenshot",enter_fullscreen:"Full Screen",duplicate:"Duplicate",delete:"Delete",cancel:"Cancel",confirm:"Confirm",add_an_option:"Add an Option",edit:"Edit",end_editing:"End editing <1>{{name}}</1>"},tabs:{variant:{label:"Variant",default:"Default",outline:"Outline",pills:"Pills"},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},grow_tabs:"Grow Tabs"},choose_a_tab_first:"Please choose a tab first"},breakpoint:{label_one:"Screen size",label_other:"Screen sizes",add:"Add a screen size",manage:"Manage screen sizes",breakpoint:"Min Width"},context:{label:"Context"},mock_context:{label:"Mock Context",hint:"A valid json string is required"},panel:{label:"Panel",labels:"Panels",add:"Add a Panel",delete:"Delete This Panel",panel_name:"Panel Name",panel_description:"Description",panel_description_click:"Click to see description",show_title:"Show title",use_name_as_title:"Use name as title",settings:{change_view:"Move into Another View",change_view_title:"Move panel into another view",choose_queries:"Choose queries",need_to_choose_queries:"Choose at least 1 query for its data"},style:{label:"Style",width:"Width",width_postfix:"of 36 columns",height:"Height",height_postfix:"px",border:"Border"},variable:{label:"Variable",labels:"Variables",add:"Add a Variable",delete:"Delete this Variable",aggregation:{label:"Aggregation",fallback_value:"Fallback Value",fallback_value_description:"Used when data is empty or the aggregation yields NaN"}}},style:{label:"Style",font_size:{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"Font Weight"},size:{xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl"},flex:{justify_content:{label:"Justify Content",left:"Left",center:"Center",right:"Right",space_between:"Space Between",space_around:"Space Around",space_evenly:"Space Evenly"},align_items:{label:"Align Items",start:"Start",center:"Center",end:"End",stretch:"Stretch"}},color:{type:{label:"Color Type",static:"Static",interpolation:"Interpolation",none:"None"},interpolation:{setup:"Setup color interpolation",palette:{label:"Palette",category:{sequential:"Sequential",diverging:"Diverging"},red_green:"Red / Green",yellow_blue:"Yellow / Blue",red:"Red",green:"Green",blue:"Blue",orange:"Orange",mapping:{value_input_label:"Map a value to this color"}}}}},query:{label:"Query",labels:"Queries",add:"Add a Query",delete:"Delete this Query",cant_delete:"Can't delete this query for it's being used, check out Usage tab for details",delete_unused:"Delete unused queries",name:"Name",name_description:"A unique name",manage:"Manage Queries",open:"Open this query",configurations:"Configurations",basics:"Basics",conditions:"Conditions",run_by_condition:{label:"Run query when these are truthy",unset:"Always run this query on load"},re_run_condition:{label:"Re-run query when these changed",unset:"Leave it empty to never re-run this query"},dependency:{label:"Dependency",has_none:"This query has no dependency"},edit_sql:"Edit SQL",preview_sql:"Preview SQL",request:"Request",build_request:"Build Request",process_request:"Process Request",process_result:"Process Result",usage:{label:"Usage",in_views:"In View(s)",unused_description:"This query is not used by any filter or panel"},transform:{label:"Transform",full_label:"Transform Query",data_source:"Use other queries' data",guide:{pick_queries:"Pick queries for data input",write_function:"Write a function for making new data"}}},data:{label:"Data",preview_data:"Preview Data",empty_data:"Empty Data",requires_data:"Requires data"},data_source:{label:"Data Source",explore:"Explore Data Source",explorer:"Data Source Explorer",table_structure:"Table Structure",table_structure_short:"Structure",see_table_structure:"See Table Structure"},visualization:{label:"Visualization",component:"Visualization",label_short:"Viz"},numbro:{format:{label:"Format",absolute:"Absolute",absolute_description:"Non-negative",abbreviation:"Abbreviation",abbreviation_description:"like 1.23k, 1.23m",mantissa:"Mantissa",trim_mantissa:"Trim mantissa",trim_mantissa_description:"hide trailing zero(s)",preview:{open:"Open Preview",close:"Close Preview",input:"In",output:"Out"}}},import:{label:"Import...",title:"Import content with schema json",json_file:"JSON File",this_dashboard:"This dashboard",this_file:"This file"},function_utils:{trigger_text:"About parameter 'utils'",modal_title:"About FunctionUtils",description:"Parameter <code>utils</code> is <code>FunctionUtils</code>, which contains:",document:"Document"},aggregation:{option:{none:"None",sum:"Sum",mean:"Mean",median:"Median",min:"Min",max:"Max",cov:"Coefficient of Variation",std:"Standard Variation",quantile:{label:"Quantile",label_with_hint:"Quantile(99%, 95%, ...)"},custom:{label:"Custom",label_trigger:"Edit Function",title:"Custom Aggregation"},pick_record:{label:"Pick Record",method:{label:"Record",first:"First Record",last:"Last Record"}}}},rich_text:{label:"Rich Text",content:{label:"Content"},dynamic_color:{label:"Dynamic Color",edit:"Edit dynamic color"}},chart:{chart_config:"Chart Config",data_field:"Data Field",groups:{merico_suite:"Merico suite",echarts_based_charts:"ECharts-based charts",others:"Others"},label:{label:"Label",label_full:"Label",label_style:"Label Style",label_format:"Label Format"},label_position:{label:"Label Position",off:"Off",top:"Top",left:"Left",right:"Right",bottom:"Bottom",inside:"Inside",inside_top:"Inside Top",inside_left:"Inside Left",inside_center:"Inside Center",inside_right:"Inside Right",inside_bottom:"Inside Bottom",inside_top_left:"Inside Top Left",inside_top_right:"Inside Top Right",inside_bottom_left:"Inside Bottom Left",inside_bottom_right:"Inside Bottom Right",outside:"Outside"},visual_map:{label:"Visual Map",continuous:{label:"Continuous"},piecewise:{label:"Piecewise",mode:{pieces:"Pieces",categories:"Categories"},add_a_piece:"Add a piece",interval:"Interval",piece_label:"Label"},bar_width:"Bar Width",bar_height:"Bar Height",item_width:"Item Width",item_height:"Item Height",calculable:"Show drag handle",min_value:"Min Value",max_value:"Max Value",min_text:"Min Text",max_text:"Max Text",use_palette_x:'Use palette "{{x}}"',built_in_palettes:"Built-in Palettes",precision:"Data Precision",skip_range:{lt_min:"Color for smaller values than min value",min:"Color for min value",max:"Color for max value",gt_max:"Color for greater values than max value",follow_visual_map:"follow gradient rule"}},number_or_dynamic_value:{type:{static:"Static",dynamic:"Dynamic"},dynamic:{setup:"Setup",setup_title:"Setup dynamic value",guide:"Dyanmic by a custom function"}},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},symbol_size:{label:"Symbol Size",static:"Static",dynamic:"Dynamic",setup:{label:"Setup",title:"Setup dynamic size",description:"Dynamic by a custom function"}},series:{label:"Series",name:"Name",y_axis:"Y Axis",data_field:"Data Field",add:"Add a series",delete:"Delete this series",line:{label:"Line",line_settings:"Line Settings",line_style:"Line Style",type:{label:"Line Type",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},line_width:"Line Width",step:{label:"Step",off:"Off",start:"Start",middle:"Middle",end:"End"},smooth_line:"Smooth Line",show_name_on_line:"Display Name on Line",show_symbol_on_line:"Show Symbol on Line"},bar:{label:"Bar",stack:"Stack",stack_hint:"Stack bars by this ID",bar_gap:{label:"Bar Gap",no_gap:"No gap between bars",overlap:"Bars overlapping on each other"},bar_width:{min:"Bar Width(min)",exact:"Bar Width",max:"Bar Width(max)"}},scatter:{label:"Scatter"},group_by:{label:"Split into multiple seires by this field...",label_line:"Split into multiple lines by this field..."}},axis:{tick_label:"Tick Label",customize_label:"Customize Label",overflow:{label:"Overflow",max_width:"Max Width",truncate:"Truncate",break_line:"Break Line",break_word:"Break Word",ellipsis:"Ellipsis",section_title:{on_axis:"Overflow on Axis",in_tooltip:"Overflow in Tooltip"}},section_title:{label_format:"Label Format"},type:{value:"Value",category:"Category",time:"Time",log:"Log",click_to_learn_more:"Click <1>here</1> to learn more about these options"}},name_text:{align:{label:"Name Anchor",left:"Left",center:"Center",right:"Right"}},rotate:"Rotate",degree:"degree",padding:"Padding",content_template:{label:"Content Template",hint:"Average: ${avg}"},x_axis:{label:"X Axis",labels:"X Axes",label_format:"Label Format",add:"Add an X Axis",delete:"Delete this X Axis",x_axis_name:"X Axis Name",x_axis_data_field:"X Axis Data Field",x_axis_type:"X Axis Type",layout:"Layout",position:{label:"Position",top:"Top",bottom:"Bottom"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},y_axis:{label:"Y Axis",labels:"Y Axes",label_format:"Label Format",add:"Add a Y Axis",delete:"Delete this Y Axis",y_axis_name:"Y Axis Name",y_axis_name_anchor:"Name Anchor",y_axis_data_field:"Y Axis Data Field",layout:"Layout",position:{label:"Position",left:"Left",right:"Right"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},stats:{label:"Stats",template:{above_chart:"Template for stats above the chart",under_chart:"Template for stats under the chart"}},legend:{label:"Legend",show_legend:"Show Legend",show_in_legend:"Show in legend",hide_in_legend:"Hide in legend",orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"}},tooltip:{label:"Tooltip",additional_metrics:{description:"Set additional metrics to show in scatter's tooltip",add:"Add a metic",delete:"Delete this Metric"},trigger:{label:"Trigger",scatter_point:"Scatter Point",x_axis:"X Axis"}},style:{label:"Style"},color:{label:"Color",or:"or",set_any_color:"Set any color",pick_a_theme_color:"Pick a theme color",background_color:"Background Color",text_color:"Text Color",click_to_add_a_color:"Click to add a color",color_gradient:"Color Gradient"},behavior:{label:"Behavior",invisible:"Invisible"},heatmap:{heatblock:{label:"Heat Block",show_label:"Show Label"}},reference_line:{label:"Reference Line",labels:"Reference Lines",add:"Add a reference line",name_placeholder:"Average Reference Line",delete:"Remove this Reference Line",orientation:{vertical_hint:"Works only when xAxis values are numbers"}},regression_line:{label:"Regression Line",labels:"Regression Lines",add:"Add a line",delete:"Delete this line",method:{label:"Method",linear:"Linear",exponential:"Exponential",logistic:"Logistic",polynomial:"Polynomial",polynomial_order:"Order"}},reference_area:{label:"Reference Area",labels:"Reference Areas",add:"Add a reference area",delete:"Remove this reference area",type:{label:"Type",rectangle:"Rectangle"},direction:{label:"Direction",horizontal:"Horizontal"},boundary:{upper:"Upper Boundary",lower:"Lower Boundary"},content:{label:"Content",content_text:"Content Text",text_position:"Text Position"},endpoint:{labels:"Endpoints",left_bottom_point:"Left-Bottom Point",right_top_point:"Right-Top Point"}},zooming:{label:"Zooming",scroll:{label:"Scroll to zoom",x_axis:"Enable on X Axis",y_axis:"Enable on Y Axis"},slider:{label:"Slider for zooming",x_axis:"Slider for X Axis",y_axis:"Slider for Y Axis",y_axis_disabled:"Not available for now, will overlap y-axis's label"}}},viz:{viz_config_banner:"Visualization Settings"},validation:{number:{require_a_number:"A number is required"}}}},GE={translation:{filter:{label:"筛选器",labels:"筛选器",add:"新增筛选器",manage:"管理筛选器",show_filters:"展开筛选器",hide_filters:"收起筛选器",field:{widget:"控件",visible_in:"在...视图中可见",key_placeholder:"用于引用此筛选器,需保持唯一",label_placeholder:"用于展示的标签文案",auto_submit:"自动提交",order:"排列次序",custom_default_value:{trigger:"自定义",title:"自定义默认值",tips:"提示",tip_1:"在指定筛选器默认值这事上,自定义函数具备最高优先级",tip_2:"清空下方编辑器来禁用本功能"}},widget:{names:{select:"单选",multi_select:"多选",tree_select:"树形选择器",text_input:"文本框",checkbox:"勾选框",date_range:"日期范围"},common:{use_query_data_as_options:"使用所查数据为选项",fetch_options_from_datasource:"从数据源查选项",or_fetch_options_from_datasource:"或从数据源查选项",selector_option_empty:"无选项可用",see_data_structure:"点击查看期望的数据格式",using_query:"在用查询获取选项",default_selection_count:"默认选中前N项",min_width:"控件最小宽度",x_selected:"已选数:{{count}}"},text_input:{default_value:"默认值",required:"必填"},select:{width:"控件宽度",required:"必选",clearable:"可取消选择",configure_options:"配置选项",default_selection:"默认选项",no_default_selection:"无",select_first_option_by_default:"默认选中第一个选项"},multi_select:{width_description:"至少160px"},tree_select:{strictly:"枝叶节点不相关,各选各的"},checkbox:{description:"描述信息",default_checked:"默认勾选"},date_range:{required:"必选",allow_single_date:"允许选一天作为范围",display_format:"展示格式",max_days:"最大选择天数",one_day:"1天",x_days:"{{count}}天",x_max_days:"最多可选{{max_days}}天",default_value:"默认日期范围(具体)",default_by_shortcut:"默认日期范围(快捷方式)",default_by_shortcut_placeholder:"优先于左侧",start_date:"开始日期",end_date:"结束日期",shortcut:{last:{label:"过往整周期",d:"昨天",w:"周",m:"月",m2:"两个月",m3:"三个月",y:"年",full:{d:"昨天",w:"上周",m:"上个月",m2:"上两月",m3:"上三月",y:"去年"}},recent:{label:"最近",d7:"7天",d30:"30天",d60:"60天",d90:"90天",d180:"180天",d365:"365天",full:{d7:"近7天",d30:"近30天",d60:"近60天",d90:"近90天",d180:"近180天",d365:"近365天"}},this:{label:"当前整周期",d:"今天",w:"周",m:"月",y:"年",full:{d:"今天",w:"本周",m:"本月",y:"今年"}},this_so_far:{label:"至今",w:"周",m:"月",y:"年",full:{w:"本周至今",m:"本月至今",y:"本年至今"}}}}}},view:{label:"视图",labels:"视图",add:"新增视图",delete:"删除此视图",download_schema:"下载此视图描述文件",component:{div:{label:"内容"},tabs:{label:"标签页",tabs_settings:"标签页设置",tab:{name:"名称",view:"内容视图",order:"排列次序",color:"颜色",delete:"删除这个标签页",switch_to_view:"打开视图: {{name}}"}},modal:{label:"弹窗",modal_settings:"弹窗设置",title:"弹窗标题",custom_title:"自定义弹窗标题",width:"宽度",height:"高度"}}},interactions:{label:"交互",add:"新增交互",interactions_viewer:"纵览交互",unavailable:"不可用",unavailable_reason:"此可视化组件没有交互功能",trigger:{setup:"设置触发动作",label:"触发动作",payload:"触发时的参数"},operation:{setup:"操作设置",label:"操作",settings:"设置",variables:"变量",console_log:{label:"console.log | 调试用",log_content:"打印内容"},open_link:{label:"打开链接",url:"URL",open_in_new_tab:"在新标签页中打开"},open_view:{label:"唤出视图",view:"视图"},set_filter_values:{label:"设置筛选器值",set_filter:"将筛选器的值",with:"设为"},clear_filter_values:{label:"清除筛选器值",select_filter:"选择筛选器以清除其值"}}},query_variable:{label:"查询变量",labels:"查询变量",add:"新增变量",guide:{tabs:{guide:"使用指南",variables_in_this_dashboard:"本看板中的查询变量",global_sql_snippets:"全局SQL片段"}},open:"查看查询变量"},sql_snippet:{label:"SQL片段",labels:"SQL片段",add:"新增SQL片段",delete:"删除这个SQL片段",delete_unused:"删除未用到的SQL片段",manage:"管理SQL片段",key:"键",key_occupied:"此键已被其他SQL片段占用",edit_snippet:"编辑SQL片段",preview_snippet:"预览SQL片段",usage:{label:"使用情况"}},global_sql_snippet:{label:"全局SQL片段",labels:"全局SQL片段",description:"管理员负责在系统设置中维护全局SQL片段"},common:{titles:{settings:"设置",edit:"编辑",config:"配置"},pagination:{page_size:"页容量",total:"共",total_rows:"共 {{total}} 行"},align:{horizontal:{label:"水平对齐",left:"居左",center:"居中",right:"居右"},vertical:{label:"垂直对齐",top:"居上",center:"居中",bottom:"居下"}},id:"ID",name:"名称",key:"键",label:"标签",value:"值",type:"类型",info:"信息",min:"最小值",max:"最大值",data_field:"数据字段",name_data_field:"名称字段",value_data_field:"值字段",color_data_field:"颜色字段",enabled:"启用",copied:"已复制到剪切板",action:"操作",actions:{open:"打开",close:"关闭",save:"保存",save_changes:"保存改动",revert:"还原",revert_changes:"还原改动",reset_to_default:"重置为初始值",init_with_default:"初始化",select_all:"全选",clear_selection:"撤销选择",refresh:"刷新",download_data:"下载数据",download_schema:"下载描述文件",download_screenshot:"下载截图",enter_fullscreen:"全屏",duplicate:"复制",delete:"删除",cancel:"取消",confirm:"确认",add_an_option:"新增选项",edit:"编辑",end_editing:"结束编辑 <1>{{name}}</1>"},tabs:{variant:{label:"风格",default:"默认",outline:"轮廓",pills:"胶囊"},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},grow_tabs:"拉伸标签卡宽度"},choose_a_tab_first:"请先选择一个标签页"},breakpoint:{label_one:"屏幕尺寸",label_other:"屏幕尺寸",add:"新增屏幕尺寸",manage:"管理屏幕尺寸",breakpoint:"最小宽度"},context:{label:"上下文"},mock_context:{label:"模拟上下文",hint:"内容格式为JSON"},panel:{label:"卡片",labels:"卡片",add:"新增卡片",delete:"删除这个卡片",panel_name:"卡片名",panel_description:"卡片描述",panel_description_click:"点击查看卡片描述",show_title:"展示卡片标题",use_name_as_title:"使用卡片名作为标题",settings:{change_view:"移至另一个视图下",change_view_title:"移动此卡片至另一个视图下",choose_queries:"关联查询",need_to_choose_queries:"请关联至少一个查询以使用其数据"},style:{label:"样式",width:"宽",width_postfix:"之 36 栏",height:"高",height_postfix:"px",border:"边框"},variable:{label:"变量",labels:"变量",add:"新增变量",delete:"删除此变量",aggregation:{label:"聚合",fallback_value:"兜底值",fallback_value_description:"当数据为空或聚合结果非数字时,使用此兜底值"}}},style:{label:"样式",font_size:{label:"字号",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"字重"},size:{xs:"特小",sm:"小",md:"中",lg:"大",xl:"特大"},flex:{justify_content:{label:"内容分布",left:"从左起",center:"居中",right:"从右起",space_between:"均匀分布,首尾顶格",space_around:"均匀分布,首尾留空一半",space_evenly:"均匀分布,首尾留空"},align_items:{label:"对齐位置",start:"起点对齐",center:"居中对齐",end:"末端对齐",stretch:"拉伸对齐"}},color:{type:{label:"颜色类型",static:"单色",interpolation:"插值取色",none:"无"},interpolation:{setup:"设置取色方案",palette:{label:"色板",category:{sequential:"单色渐变",diverging:"双色渐变"},red_green:"红 / 绿",yellow_blue:"黄 / 蓝",red:"红",green:"绿",blue:"蓝",orange:"橙",mapping:{value_input_label:"映射一个值到此颜色"}}}}},query:{label:"查询",labels:"查询",add:"新增查询",delete:"删除这个查询",cant_delete:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",delete_unused:"删除未用到的查询",name:"名称",name_description:"唯一名称",manage:"管理查询",open:"打开此查询",configurations:"配置",basics:"基本信息",conditions:"条件",run_by_condition:{label:"以下条件满足时,才运行本查询",unset:"看板加载时便运行本查询"},re_run_condition:{label:"当以下条件改变时,重新运行此查询",unset:"留空则永不重新运行此查询"},dependency:{label:"依赖",has_none:"此查询无依赖"},edit_sql:"编辑SQL",preview_sql:"预览SQL",request:"请求",build_request:"构造请求",process_request:"加工请求",process_result:"加工结果",usage:{label:"使用情况",in_views:"所在视图",unused_description:"此查询未被任何筛选器或卡片用到"},transform:{label:"查询变形",full_label:"查询变形",data_source:"基于其他查询的数据,加工出新数据",guide:{pick_queries:"选择一至多个查询作为数据输入",write_function:"编写函数,返回新数据"}}},data:{label:"数据",preview_data:"预览数据",empty_data:"无数据",requires_data:"请先关联查询"},data_source:{label:"数据源",explore:"查看数据源",explorer:"数据源查看器",table_structure:"数据表结构",table_structure_short:"表结构",see_table_structure:"查看数据表结构"},visualization:{label:"可视化",component:"可视化组件",label_short:"可视化"},numbro:{format:{label:"格式",absolute:"绝对值",absolute_description:"非负",abbreviation:"缩写",abbreviation_description:"如1.23k、1.23m",mantissa:"小数",trim_mantissa:"抹零",trim_mantissa_description:"省略末尾的零",preview:{open:"展开预览",close:"收起预览",input:"输入",output:"输出"}}},import:{label:"导入...",title:"自描述文件导入看板内容",json_file:"描述文件(JSON格式)",this_dashboard:"此看板",this_file:"此文件"},function_utils:{trigger_text:"关于utils参数",modal_title:"关于utils参数",description:"参数 <code>utils</code> 是 <code>FunctionUtils</code>,包含以下内容:",document:"文档"},aggregation:{option:{none:"无",sum:"和",mean:"平均值",median:"中位数",min:"最小值",max:"最大值",cov:"变异系数",std:"标准差",quantile:{label:"分位",label_with_hint:"分位(99%, 95%, ...)"},custom:{label:"自定义",label_trigger:"编写函数",title:"自定义聚合方式"},pick_record:{label:"直接选择数据",method:{label:"数据记录",first:"第一条",last:"最后一条"}}}},rich_text:{label:"富文本",content:{label:"内容"},dynamic_color:{label:"动态颜色",edit:"编辑动态颜色"}},chart:{chart_config:"图表设置",data_field:"数据字段",groups:{merico_suite:"思码逸套件",echarts_based_charts:"基于ECharts的图表",others:"其他"},label:{label:"文案",label_full:"标签文案",label_style:"标签文案样式",label_format:"标签文案格式"},label_position:{label:"文案位置",off:"不显示文案",top:"上",left:"左",right:"右",bottom:"下",inside:"内",inside_top:"内-上",inside_left:"内-左",inside_center:"内-中",inside_right:"内-右",inside_bottom:"内-下",inside_top_left:"内-上-左",inside_top_right:"内-上-右",inside_bottom_left:"内-下-左",inside_bottom_right:"内-下-右",outside:"外"},visual_map:{label:"视觉映射",continuous:{label:"连续型"},piecewise:{label:"分段型",mode:{pieces:"连续数据",categories:"离散数据"},add_a_piece:"加一个分段",interval:"值区间",piece_label:"文案"},bar_width:"长条的宽度",bar_height:"长条的高度",item_width:"小块的宽度",item_height:"小块的高度",calculable:"显示拖拽手柄",min_value:"最小值",max_value:"最大值",min_text:"最小值文案",max_text:"最大值文案",use_palette_x:'使用配色方案"{{x}}"',built_in_palettes:"内置配色方案",precision:"数据精度",skip_range:{lt_min:"小于最小值时的颜色",min:"最小值的颜色",max:"最大值的颜色",gt_max:"大于最大值时的颜色",follow_visual_map:"颜色跟随渐变规则"}},number_or_dynamic_value:{type:{static:"具体值",dynamic:"动态值"},dynamic:{setup:"设置",setup_title:"设置动态值",guide:"由函数确定动态值"}},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},symbol_size:{label:"标记点大小",static:"固定值",dynamic:"动态值",setup:{label:"设置",title:"设置动态值",description:"由函数确定动态值"}},series:{label:"系列",name:"名称",y_axis:"Y轴",data_field:"数据字段",add:"增加一个系列",delete:"删除这个系列",line:{label:"线",line_settings:"线段设置",line_style:"线条样式",type:{label:"类型",solid:"实线",dashed:"方虚线",dotted:"圆点虚线"},line_width:"线宽",step:{label:"阶梯状",off:"不启用",start:"在当前点拐弯",middle:"在当前点与下个点中间拐弯",end:"在下个点拐弯"},smooth_line:"平滑曲线",show_name_on_line:"显示标签文案",show_symbol_on_line:"显示标记点"},bar:{label:"柱",stack:"堆放",stack_hint:"此值相同的柱系列会堆叠在一起",bar_gap:{label:"柱间隔",no_gap:"柱子之间无间隔",overlap:"柱子可互相重叠"},bar_width:{min:"最小柱宽",exact:"柱宽",max:"最大柱宽"}},scatter:{label:"散点"},group_by:{label:"按此字段拆分为多个系列",label_line:"按此字段拆分为多条线"}},axis:{tick_label:"刻度文案",customize_label:"自定义文案",overflow:{label:"溢出",max_width:"最大宽度",truncate:"截断",break_line:"换行",break_word:"断词换行",ellipsis:"省略符",section_title:{on_axis:"轴刻度上文案的溢出",in_tooltip:"提示框中的文案溢出"}},section_title:{label_format:"文案格式"},type:{value:"数值轴",category:"类目轴",time:"时间轴",log:"对数轴",click_to_learn_more:"点击 <1>这里</1> 以进一步了解这些选项"}},name_text:{align:{label:"名称贴靠侧",left:"左",center:"中",right:"右"}},rotate:"旋转",degree:"度",padding:"内间距",content_template:{label:"内容模板",hint:"均值: ${avg}"},x_axis:{label:"X轴",labels:"X轴",label_format:"刻度文案格式",add:"增加一条X轴",delete:"删除这条X轴",x_axis_name:"X轴名称",x_axis_data_field:"X轴数据字段",x_axis_type:"X轴类型",layout:"布局",position:{label:"位置",top:"上",bottom:"下"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},y_axis:{label:"Y轴",labels:"Y轴",label_format:"刻度文案格式",add:"增加一条Y轴",delete:"删除这条Y轴",y_axis_name:"Y轴名称",y_axis_name_anchor:"名称贴靠侧",y_axis_data_field:"Y轴数据字段",layout:"布局",position:{label:"位置",left:"左",right:"右"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},stats:{label:"统计内容",template:{above_chart:"统计内容模板(图表上方)",under_chart:"统计内容模板(图表下方)"}},legend:{label:"图例",show_legend:"显示图例",show_in_legend:"显示在图例中",hide_in_legend:"不显示在图例中",orientation:{label:"布局朝向",horizontal:"横向",vertical:"纵向"}},tooltip:{label:"提示框",additional_metrics:{description:"在此设置更多指标,来展示在散点的提示框",add:"增加一个指标",delete:"删除这个指标"},trigger:{label:"触发者",scatter_point:"散点",x_axis:"X轴"}},style:{label:"样式"},color:{label:"颜色",or:"或",set_any_color:"输入色号",pick_a_theme_color:"选择一个主题色",background_color:"背景色",text_color:"文字颜色",click_to_add_a_color:"点击增加一个颜色",color_gradient:"颜色渐变"},behavior:{label:"表现",invisible:"隐藏不可见"},heatmap:{heatblock:{label:"热力块",show_label:"展示值文案"}},reference_line:{label:"参考线",labels:"参考线",add:"增加一条参考线",name_placeholder:"均值参考线",delete:"删除这条参考线",orientation:{vertical_hint:"仅当X轴值为数字时可绘制"}},regression_line:{label:"回归线",labels:"回归线",add:"增加一条回归线",delete:"删除这条回归线",method:{label:"方法",linear:"线性回归",exponential:"指数回归",logistic:"指数回归",polynomial:"多项式回归",polynomial_order:"次"}},reference_area:{label:"参考区域",labels:"参考区域",add:"增加一面参考区域",delete:"删除这面参考区域",type:{label:"形状",rectangle:"矩形"},direction:{label:"方向",horizontal:"水平"},boundary:{upper:"上边界",lower:"下边界"},content:{label:"内容",content_text:"内容文字",text_position:"文字位置"},endpoint:{labels:"端点",left_bottom_point:"左下点",right_top_point:"右上点"}},zooming:{label:"缩放",scroll:{label:"滚轮缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用"},slider:{label:"滚动条缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用",y_axis_disabled:"暂不可用,会与Y轴刻度文字重叠"}}},viz:{viz_config_banner:"可视化参数配置"},validation:{number:{require_a_number:"请填写一个数字"}}}},ui=gm.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:FE,zh:GE}}).use(mm).use(_.initReactI18next);ui.init(),Mh.forEach(e=>{var t;(t=e.translation)==null||t.forEach(n=>{ui.addResourceBundle(n.lang,"translation",{viz:n.resources},!0,!0)})});function Wf({lang:e,children:t}){return g.useEffect(()=>{ui.changeLanguage(e)},[e]),r.jsx(_.I18nextProvider,{i18n:ui,children:t})}function di(e){console.groupCollapsed("Running operation ",e.type),console.log(e),console.groupEnd()}function Rf(e,t){g.useEffect(()=>{const n=s=>{di(s);const{viewID:i}=s.detail;if(!i){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(i),t&&e.views.setIDOfVIE(i)};return window.addEventListener("open-view",n),()=>{window.removeEventListener("open-view",n)}},[e,t]),g.useEffect(()=>{const n=s=>{di(s);const{dictionary:i,payload:a}=s.detail;if(!a||Object.keys(a).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}const l={};Object.entries(i).forEach(([c,u])=>{const d=v.get(a,u);l[c]=d}),e.filters.applyValuesPatch(l)};return window.addEventListener("set-filter-values",n),()=>{window.removeEventListener("set-filter-values",n)}},[e]),g.useEffect(()=>{function n(i){return Array.isArray(i)?[]:typeof i=="object"?{}:typeof i=="boolean"?!1:typeof i=="string"?"":typeof i=="number"?0:i}const s=i=>{di(i);const a={},{filter_keys:l}=i.detail;l.forEach(c=>{const u=v.get(e.filters.values,c),d=n(u);a[c]=d}),e.filters.applyValuesPatch(a)};return window.addEventListener("clear-filter-values",s),()=>{window.removeEventListener("clear-filter-values",s)}},[e]),g.useEffect(()=>{const n=s=>{di(s);const{urlTemplate:i,openInNewTab:a,enableEncoding:l=!1,payload:c}=s.detail;if(!i){console.error(new Error("[Open Link] URL is empty"));return}function u(h){return v.cloneDeepWith(h,m=>{if(l&&typeof m=="string")return encodeURIComponent(m)})}const p=v.template(i||"")(u({...c,filters:e.payloadForSQL.filters,context:e.payloadForSQL.context}));window.open(p,a?"_blank":"_self","noopener")};return window.addEventListener("open-link",n),()=>{window.removeEventListener("open-link",n)}},[e])}function Qf(e){return g.useCallback(t=>t.provideValue(je.pluginManager,e.pluginManager).provideValue(je.vizManager,e.vizManager).provideValue(je.colorManager,e.colorManager),[])}const FL="",WE=D.observer(({saveDashboardChanges:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Y(),i=()=>{n.openConfirmModal({title:r.jsxs(o.Group,{position:"left",children:[r.jsx(M.IconAlertTriangle,{size:18,color:"red"}),r.jsx(o.Text,{children:"You are reverting changes"})]}),labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>s.reset(),zIndex:320,withCloseButton:!1})},a=s.changed;return r.jsxs(o.Group,{spacing:0,children:[r.jsx(o.Button,{color:"green",variant:"filled",size:"xs",leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),onClick:e,disabled:!a,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:t("common.actions.save_changes")}),r.jsxs(o.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!a,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.ActionIcon,{variant:"default",disabled:!a,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:r.jsx(M.IconCaretDown,{size:18})})}),r.jsx(o.Menu.Dropdown,{children:r.jsx(o.Menu.Item,{icon:r.jsx(M.IconRecycle,{size:14,color:"red"}),disabled:!a,onClick:i,children:t("common.actions.revert_changes")})})]})]})}),RE=D.observer(({saveDashboardChanges:e,onExit:t,headerSlot:n=null})=>{_.useTranslation();const s=Z(),i=s.content.changed,a=()=>{t({hasChanges:i,dashboardId:s.id})};return r.jsx(o.Header,{height:60,px:"md",py:0,sx:{zIndex:299},children:r.jsxs(o.Group,{position:"apart",sx:{height:60,minWidth:"1000px",position:"relative"},children:[r.jsxs(o.Group,{children:[r.jsx(o.Button,{size:"xs",color:i?"red":"green",leftIcon:r.jsx(M.IconArrowLeft,{size:20}),onClick:a,children:r.jsx(o.Group,{spacing:4,children:r.jsxs(_.Trans,{i18nKey:"common.actions.end_editing",values:{name:s.name},children:["End Editing ",r.jsx(o.Text,{td:"underline",children:s.name})]})})}),r.jsx(WE,{saveDashboardChanges:e})]}),r.jsx(o.Group,{position:"right",sx:{flexGrow:1},children:n})]})})}),Uf={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},QE=D.observer(()=>{var i;const{t:e}=_.useTranslation(),t=Y(),n=((i=t.views.VIE)==null?void 0:i.type)===q.Tabs,s=()=>t.addANewPanel(t.views.idOfVIE);return n?r.jsx(o.Tooltip,{label:e("common.choose_a_tab_first"),children:r.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:r.jsx(M.IconPlaylistAdd,{size:20}),sx:{...Uf,transform:"none !important"},children:e("panel.add")})}):r.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:s,leftIcon:r.jsx(M.IconPlaylistAdd,{size:20}),sx:{...Uf,background:"rgb(231, 245, 255)"},children:e("panel.add")})}),UE=D.observer(({done:e})=>{var E,N;const{t}=_.useTranslation(),s=Y().layouts,i=g.useMemo(()=>({list:s.breakpointsInfo}),[s.breakpointsInfo]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d,formState:p}=b.useForm({defaultValues:i}),{fields:h,append:f,remove:m}=b.useFieldArray({control:a,name:"list",rules:{validate:R=>{if(console.log({values:R}),v.uniqBy(R,"breakpoint").length!==R.length)return"Screen sizes should be unique by min width"}}}),y=c("list"),j=h.map((R,pe)=>({...R,...y[pe]})),k=()=>{f({id:Ut.v4(),name:"",breakpoint:""})},S=({list:R})=>{const pe=R.filter(ie=>Number.isFinite(ie.breakpoint));s.updateLayoutSetsInfo(pe),e()},T=u(),z=g.useMemo(()=>{const R={list:T.list.filter(pe=>!!pe.name&&Number.isFinite(pe.breakpoint))};return!v.isEqual(R,i)},[T,i]),I=(N=(E=p.errors.list)==null?void 0:E.root)==null?void 0:N.message;return r.jsx(r.Fragment,{children:r.jsxs("form",{onSubmit:l(S),children:[r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,withBorder:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"340px"},children:t("common.name")}),r.jsx("th",{style:{width:"160px"},children:t("breakpoint.breakpoint")}),r.jsx("th",{})]})}),r.jsxs("tbody",{children:[j.map((R,pe)=>r.jsxs("tr",{children:[r.jsx("th",{children:R.id==="basis"?R.name:r.jsx(b.Controller,{name:`list.${pe}.name`,control:a,render:({field:ie})=>r.jsx(o.TextInput,{size:"xs",label:"",required:!0,sx:{flex:1},...ie})})}),r.jsx("td",{children:R.id==="basis"?r.jsxs(o.Text,{ff:"monospace",children:[R.breakpoint,"px"]}):r.jsx(b.Controller,{name:`list.${pe}.breakpoint`,control:a,render:({field:ie})=>r.jsx(o.NumberInput,{size:"xs",label:"",required:!0,max:1e4,hideControls:!0,rightSection:r.jsx(o.Text,{color:"dimmed",children:"px"}),rightSectionProps:{style:{width:"30px"}},sx:{flex:1,fontFamily:"monospace"},styles:{input:{paddingRight:"30px"}},...ie})})}),r.jsx("td",{children:R.id!=="basis"&&r.jsx(o.ActionIcon,{mx:"auto",size:"xs",variant:"subtle",color:"red",onClick:()=>m(pe),children:r.jsx(M.IconTrash,{})})})]},R.id)),r.jsx("tr",{style:{backgroundColor:"transparent"},children:r.jsx("td",{colSpan:3,style:{padding:"0"},children:r.jsx(o.Tooltip,{label:t("breakpoint.add"),children:r.jsx(o.ActionIcon,{variant:"subtle",size:"md",color:"blue",onClick:k,sx:{width:"100%"},children:r.jsx(M.IconPlus,{size:18})})})})})]})]}),r.jsx(o.Text,{mt:6,ta:"right",size:"xs",color:"red",children:I??" "}),r.jsxs(o.Group,{mt:6,position:"apart",children:[r.jsx(o.Button,{color:"orange",size:"xs",onClick:()=>d(),leftIcon:r.jsx(M.IconRecycle,{size:18}),disabled:!z,children:t("common.actions.revert")}),r.jsx(o.Button,{color:"green",size:"xs",type:"submit",leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),disabled:!z,children:t("common.actions.save_changes")})]})]})})}),YE=D.observer(()=>{const{t:e}=_.useTranslation(),[t,{open:n,close:s}]=he.useDisclosure(!1),i=Y(),a=i.layouts.currentBreakpoint,l=i.layouts.currentLayoutRange,c=()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},u=()=>{s(),c()};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{children:[r.jsxs(o.Menu,{withArrow:!0,withinPortal:!0,zIndex:320,trigger:"hover",children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Button,{size:"xs",variant:"subtle",leftIcon:r.jsx(M.IconDevices,{size:16}),sx:{borderRadius:0},children:r.jsxs(o.Group,{spacing:6,children:[r.jsx(o.Text,{size:"xs",fw:"normal",children:l.name}),r.jsx(o.Text,{size:"xs",color:"#777",children:i.layouts.currentRangeText})]})})}),r.jsxs(o.Menu.Dropdown,{children:[i.layouts.breakpointRanges.map(d=>r.jsx(o.Menu.Item,{onClick:()=>i.layouts.setCurrentBreakpoint(d.id),disabled:a===d.id,children:r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Text,{size:"sm",children:d.name}),r.jsx(o.Text,{size:"xs",color:"dimmed",children:d.text})]})},d.id)),r.jsx(o.Menu.Divider,{}),r.jsx(o.Menu.Item,{color:"blue",icon:r.jsx(M.IconSettings,{size:14}),onClick:n,children:r.jsx(o.Text,{size:"sm",children:e("breakpoint.manage")})})]})]}),i.layouts.divisionPreviewScale<1&&r.jsx(o.Text,{size:"xs",color:"dimmed",children:Zr(i.layouts.divisionPreviewScale).format({output:"percent",mantissa:0})})]}),r.jsx(o.Modal,{opened:t,onClose:u,title:e("breakpoint.label",{count:2}),withinPortal:!0,zIndex:320,size:600,closeOnClickOutside:!1,children:r.jsx(UE,{done:u})})]})}),Yf={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},KE=D.observer(()=>{var i;const{t:e}=_.useTranslation(),t=Y(),n=((i=t.views.VIE)==null?void 0:i.type)===q.Tabs,s=()=>{var a;return(a=t.views.VIE)==null?void 0:a.downloadSchema()};return n?r.jsx(o.Tooltip,{label:e("common.choose_a_tab_first"),children:r.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:r.jsx(M.IconCode,{size:16}),sx:{...Yf,transform:"none !important"},children:e("view.download_schema")})}):r.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:s,leftIcon:r.jsx(M.IconCode,{size:16}),sx:{...Yf},children:e("view.download_schema")})}),pi=({headers:e,rows:t})=>r.jsxs(o.Table,{fontSize:"xs",highlightOnHover:!0,sx:{tableLayout:"fixed",fontFamily:"monospace"},children:[r.jsx("thead",{children:e}),r.jsx("tbody",{children:t})]}),XE=({content:e})=>{const{t}=_.useTranslation(),n=e.views;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("view.labels")}),r.jsx(pi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.name")}),r.jsx("th",{children:t("common.type")})]}),rows:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.id}),r.jsx("td",{children:s.name}),r.jsx("td",{children:t(`view.component.${s.type}.label`)})]},s.id))})]})},JE=({content:e})=>{const{t}=_.useTranslation(),n=e.filters;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("filter.labels")}),r.jsx(pi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.key")}),r.jsx("th",{children:t("common.label")})]}),rows:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.id}),r.jsx("td",{children:s.key}),r.jsx("td",{children:s.label})]},s.id))})]})},ZE=({content:e})=>{const{t}=_.useTranslation(),n=e.panels;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("panel.labels")}),r.jsx(pi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.name")}),r.jsx("th",{children:t("visualization.component")})]}),rows:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.id}),r.jsx("td",{children:s.name}),r.jsx("td",{children:s.viz.type})]},s.id))})]})},HE=({content:e})=>{var s;const{t}=_.useTranslation(),n=(s=e.definition)==null?void 0:s.queries;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("query.labels")}),r.jsx(pi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.name")}),r.jsx("th",{style:{width:"140px"},children:t("common.type")}),r.jsx("th",{style:{width:"260px"},children:t("data_source.label")})]}),rows:n.map(i=>r.jsxs("tr",{children:[r.jsx("td",{children:i.id}),r.jsx("td",{children:i.name}),r.jsx("td",{children:i.type}),r.jsx("td",{children:i.key})]},i.id))})]})},eA=({content:e})=>{var s;const{t}=_.useTranslation(),n=(s=e.definition)==null?void 0:s.sqlSnippets;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("sql_snippet.labels")}),r.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:r.jsx(M.IconPointFilled,{size:10}),children:n.map(i=>r.jsx(o.List.Item,{children:i.key},i.key))})]})},tA=({content:e})=>{var s;const{t}=_.useTranslation(),n=Object.keys(((s=e.definition)==null?void 0:s.mock_context)??{});return n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("mock_context.label")}),r.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:r.jsx(M.IconPointFilled,{size:10}),children:n.map(i=>r.jsx(o.List.Item,{children:i},i))})]})},nA=({content:e})=>e?r.jsxs(o.Box,{children:[r.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(o.Text,{ta:"left",c:"dimmed",children:"Preview"}),r.jsxs(o.Stack,{children:[r.jsx(XE,{content:e}),r.jsx(JE,{content:e}),r.jsx(ZE,{content:e}),r.jsx(HE,{content:e}),r.jsx(eA,{content:e}),r.jsx(tA,{content:e})]})]}):null;function rA(e){if(e.target===null)throw new Error("FileReader failed with null result");if(typeof e.target.result!="string")throw new Error(`Unparsable file content of type: ${typeof e.target.result}`);let t=JSON.parse(e.target.result);if("content"in t&&(t=t.content),t.version!==en)throw new Error("Schema version mismatch");return t}const sA=D.observer(({onSuccess:e,stretchModal:t,shrinkModal:n})=>{var S,T;const{t:s}=_.useTranslation(),i=Y(),{handleSubmit:a,formState:{errors:l},setValue:c,watch:u,setError:d,clearErrors:p}=b.useForm({defaultValues:{content:null}}),h=({content:z})=>{try{if(!z)throw new Error("please use a valid json file");i.applyJSONSchema(z),sn.showNotification({title:"Successful",message:"",color:"green"}),e()}catch(I){console.error(I),sn.showNotification({title:"Failed",message:I.message,color:"red"})}},[f,m]=g.useState(null);g.useEffect(()=>{if(!f)return;const z=new FileReader;z.readAsText(f,"UTF-8"),z.onload=I=>{try{const E=rA(I);c("content",E),p("content")}catch(E){console.error(E),d("content",{type:"custom",message:E.message})}},z.onabort=()=>console.log("🟨 abort"),z.onerror=()=>{z.error&&(console.error(z.error),d("content",{type:"custom",message:z.error.message}))}},[f]);const[y]=u(["content"]),j=!y,k=(S=l==null?void 0:l.content)==null?void 0:S.message;return g.useEffect(()=>{!y||k?n():t()},[y,k]),r.jsx(o.Box,{mx:"auto",sx:{position:"relative"},children:r.jsxs("form",{onSubmit:a(h),children:[r.jsx(o.FileInput,{label:s("import.json_file"),required:!0,value:f,onChange:m,error:(T=l==null?void 0:l.content)==null?void 0:T.message,sx:{maxWidth:500}}),k?r.jsx(o.Table,{fontSize:12,mt:10,children:r.jsxs("tbody",{children:[r.jsxs("tr",{children:[r.jsx("th",{children:s("import.this_dashboard")}),r.jsx("td",{children:en})]}),r.jsxs("tr",{children:[r.jsx("th",{children:s("import.this_file")}),r.jsx("td",{style:{color:"red"},children:y==null?void 0:y.version})]})]})}):r.jsxs(r.Fragment,{children:[r.jsx(nA,{content:y}),r.jsx(o.Group,{position:"right",my:"md",children:r.jsx(o.Button,{type:"submit",color:"green",disabled:j,children:s("common.actions.confirm")})})]})]})})}),Kf={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},iA=D.observer(()=>{var d;const{t:e}=_.useTranslation(),[t,{open:n,close:s}]=he.useDisclosure(!1),[i,{setTrue:a,setFalse:l}]=W.useBoolean(!1),u=((d=Z().content.views.VIE)==null?void 0:d.type)===q.Tabs;return u?r.jsx(o.Tooltip,{label:e("common.choose_a_tab_first"),children:r.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:r.jsx(M.IconFileImport,{size:16}),sx:{...Kf,transform:"none !important"},children:e("import.label")})}):r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"subtle",color:"blue",radius:0,size:"xs",disabled:u||t,onClick:n,leftIcon:r.jsx(M.IconFileImport,{size:16}),sx:{...Kf},children:e("import.label")}),r.jsx(o.Modal,{opened:t,onClose:s,title:e("import.title"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},withinPortal:!0,zIndex:320,size:i?"90vw":500,children:r.jsx(sA,{onSuccess:s,stretchModal:a,shrinkModal:l})})]})}),aA={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},oA=D.observer(()=>r.jsx(o.Box,{sx:aA,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:r.jsxs(o.Group,{position:"apart",align:"center",sx:{height:"30px"},children:[r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(QE,{}),r.jsx(iA,{})]}),r.jsx(YE,{}),r.jsx(o.Group,{position:"right",spacing:0,children:r.jsx(KE,{})})]})})),lA=D.observer(e=>r.jsxs(r.Fragment,{children:[r.jsx(RE,{...e}),r.jsx(oA,{})]})),GL="";function cA(e,t,n){const s=[];return e.filter(i=>"__INTERACTIONS"in i.viz.conf).forEach((i,a)=>{const l=t[i.id];l.data.interactions=v.get(l,"data.interactions",[]);const{__INTERACTIONS:c,__OPERATIONS:u,__TRIGGERS:d}=i.viz.conf;Object.entries(u).forEach(([p,h])=>{const{schemaRef:f,data:m}=h,{config:y}=m;switch(f){case"builtin:op:open-link":let j=y.urlTemplate.substring(0,100);y.urlTemplate.length>=20&&(j+="..."),l.type="interaction",l.data.interactions.push({schemaRef:f,urlTemplate:y.urlTemplate,shortURLTemplate:j});return;case"builtin:op:open_view":s.push({id:`OPERATION--${p}`,source:i.id,target:y.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:f,filters:Object.keys(y.dictionary).map(k=>({key:k,label:n[k]}))});return;case"builtin:op:clear_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:f,filters:y.filter_keys.map(k=>({key:k,label:n[k]}))});return;default:return}})}),s}function uA(e,t){const n=e.filters.keyLabelMap;return{edges:cA(e.panels.list,t,n),edgeNodes:[]}}function Xf(e,t,n){return e*t+e*n}function dA(e,t,n){return e*t+(e-1)*n}const hi=25,Dl=40,Jf=25,Ml=350,pA=150,hA=150,Zf=150,Hf=300,fi=40,eg=25,fA=300;function gA(e,t){const n=v.keyBy(t,i=>i.id),s=[];return e.current.forEach((i,a)=>{i.panelIDs.forEach((l,c)=>{const u=Xf(c,fi,eg)+Dl,d=n[l];if(!d){s.push({id:l,_node_type:"panel",parentNode:i.id,data:{label:`!: ${l}`},position:{x:hi,y:u},sourcePosition:Ee.Position.Right,targetPosition:Ee.Position.Left,style:{width:Hf,height:fi}});return}const p=d.name;s.push({id:d.id,_node_type:"panel",parentNode:i.id,data:{label:p},position:{x:hi,y:u},sourcePosition:Ee.Position.Right,targetPosition:Ee.Position.Left,style:{width:Hf,height:fi}})})}),s}const mA={[q.Division]:"Div",[q.Modal]:"Modal",[q.Tabs]:"Tabs"},xA=Af;function yA(e){return e.current.map((n,s)=>{const i=dA(n.panelIDs.length,fi,eg)+Dl+Jf;let a=[];return n.type===q.Tabs&&(a=n.config.tabsInOrder.map(c=>c.view_id)),{id:n.id,_node_type:"view-root",_view_type:n.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:a,data:{label:`${mA[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:Ee.Position.Right,targetPosition:Ee.Position.Left,className:"light",style:{backgroundColor:xA[n.type],width:Ml,height:i}}})}function bA(e){const t=v.keyBy(e,n=>n.id);e.forEach(n=>{n._node_type!=="view-root"||n._view_type!==q.Tabs||n._tab_view_ids.forEach(s=>{t[s].parentNode=n.id})})}function vA(e){const t=yA(e.views);bA(t);const n=gA(e.views,e.panels.list);return[...t,...n]}function _A({nodeMap:e,nodes:t,edges:n}){t.forEach(s=>{s._node_type!=="view-root"||s._view_type!==q.Tabs||(s.sourcePosition=Ee.Position.Bottom,s.style.width=Ml+hi*2,s.style.height=Jf+s._tab_view_ids.reduce((i,a)=>{const l=e[a];l.position.y=i,l.position.x=hi;const c=l.style.height;return i+c+20},Dl))})}function jA({nodeMap:e,nodes:t,edges:n}){n.filter(s=>s.label==="Open View").forEach(s=>{const i=e[s.source],a=e[s.target];if(!i||!a||!i.parentNode)return;const l=e[i.parentNode];l._node_type!=="view-root"||a._node_type!=="view-root"||(a._view_level+=1+l._view_level,l._sub_view_ids.push(a.id))}),t.sort((s,i)=>s._node_type==="view-root"&&i._node_type==="view-root"?s._view_level-i._view_level:s._node_type!=="view-root"&&i._node_type!=="view-root"?0:s._node_type==="view-root"?-1:1)}function wA({nodeMap:e,nodes:t,edges:n}){const s={};n.forEach(i=>{if(i.label!=="Open View")return;const a=e[i.source],l=e[i.target];if(a&&l&&a.parentNode){const c=e[a.parentNode],u=c.position.x,d=Number(v.get(l,"style.height",0)),p=Number(c.style.width);l.position.x=u+p+fA,c._view_level===0&&l._sub_view_ids.length===0&&(a.sourcePosition=Ee.Position.Left,l.targetPosition=Ee.Position.Right,l.position.x*=-1);const f=l.position.x,m=v.get(s,f,0);l.position.y=m,s[f]=m+d+Zf}})}function CA({nodeMap:e,nodes:t,edges:n}){const s=new Set,i=new Set;n.forEach(l=>{s.add(l.source),i.add(l.target)}),t.filter(l=>l._node_type!=="view-root"||l.id==="Main"||l.parentNode?!1:!s.has(l.id)&&!i.has(l.id)).forEach((l,c)=>{l.position.x=Xf(c,Ml,hA),l.position.y=0-pA-Zf})}function SA({nodeMap:e,nodes:t,edges:n}){const s={nodeMap:e,nodes:t,edges:n};return CA(s),jA(s),_A(s),wA(s),{nodes:t,edges:n}}function kA(e){const t=vA(e),n=v.keyBy(t,u=>u.id),{edges:s,edgeNodes:i}=uA(e,n),a=[...t,...i],l=v.keyBy(a,u=>u.id),c={edges:v.uniqBy(s,u=>u.id),nodes:a,nodeMap:l};return SA(c)}const WL="",zl={"builtin:op:open-link":r.jsx(o.ThemeIcon,{color:"blue",size:20,radius:"xl",children:r.jsx(M.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":r.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:r.jsx(M.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":r.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:r.jsx(M.IconCircleOff,{size:14})})};function TA(e){const t=[];return e.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":t.push({key:n.urlTemplate,icon:zl[n.schemaRef],text:r.jsxs(o.Group,{spacing:4,children:[r.jsx(o.Text,{children:"Open: "}),r.jsx(o.Text,{color:"dimmed",children:n.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":n.filters.forEach(({key:s,label:i})=>{t.push({key:n.schemaRef+s,icon:zl[n.schemaRef],text:r.jsx(o.Group,{spacing:4,children:r.jsxs(o.Text,{children:["Set Filter: ",i]})})})});return;case"builtin:op:clear_filter_values":n.filters.forEach(({key:s,label:i})=>{t.push({key:n.schemaRef+s,icon:zl[n.schemaRef],text:r.jsx(o.Group,{spacing:4,children:r.jsxs(o.Text,{children:["Clear Filter: ",i]})})})});return}}),t}const DA=g.memo(({data:e,isConnectable:t,sourcePosition:n=Ee.Position.Right,targetPosition:s=Ee.Position.Left,...i})=>{const a=g.useMemo(()=>TA(e.interactions),[e.interactions]);return r.jsxs(r.Fragment,{children:[r.jsx(Ee.Handle,{type:"target",position:s,isConnectable:t}),r.jsx(o.Box,{sx:{position:"absolute",top:0,right:0},children:r.jsx(V.ChevronsUpRight,{size:12})}),r.jsxs(o.HoverCard,{shadow:"xl",withinPortal:!0,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Text,{children:e.label})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(o.List,{spacing:"xs",size:"sm",center:!0,children:a.map(l=>r.jsx(o.List.Item,{icon:l.icon,children:l.text},l.key))})})]}),r.jsx(Ee.Handle,{type:"source",position:n,isConnectable:t})]})}),RL="",MA={interaction:DA},zA=D.observer(()=>{const e=_e(),{edges:t,nodes:n}=kA(e);return r.jsxs(Ee,{nodes:n,edges:t,onNodesChange:v.noop,onEdgesChange:v.noop,onConnect:v.noop,className:"interactions-viewer",fitView:!0,nodeTypes:MA,children:[r.jsx(Ee.MiniMap,{}),r.jsx(Ee.Controls,{}),r.jsx(Ee.Background,{})]})}),IA=D.observer(({opened:e,close:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Modal,{size:"96vw",opened:e,onClose:t,title:n("interactions.interactions_viewer"),trapFocus:!0,onDragStart:s=>{s.stopPropagation()},styles:{body:{height:"calc(90vh - 54px)"},content:{transform:"none !important"}},zIndex:300,children:r.jsx(zA,{})})}),EA={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}};function AA({onClick:e,name:t,active:n,openSettings:s}){return r.jsxs(o.Box,{sx:{position:"relative"},children:[r.jsx(o.UnstyledButton,{sx:i=>({display:"block",width:"100%",padding:i.spacing.xs,borderRadius:0,position:"relative",color:i.black,"&:hover":{backgroundColor:i.colors.gray[0]},backgroundColor:n?i.colors.gray[2]:"transparent"}),children:r.jsx(o.Group,{sx:{width:"calc(100% - 28px)"},onClick:e,children:r.jsx(o.Text,{size:"sm",children:t})})}),n&&r.jsx(o.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:r.jsx(o.ActionIcon,{onClick:s,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:r.jsx(M.IconAdjustments,{size:16})})})]})}const PA=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=Y(),s=g.useCallback(a=>()=>n.views.setIDOfVIE(a),[n]),i=a=>{t.editor.open(["_VIEWS_",a])};return r.jsxs(o.Box,{sx:{position:"relative"},children:[n.views.options.map(a=>r.jsx(AA,{active:n.views.idOfVIE===a.value,name:a.label,onClick:s(a.value),openSettings:()=>i(a.value)},a.value)),r.jsx(o.Divider,{variant:"dashed"}),r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:n.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:e("view.add")})]})}),OA=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=Y(),s=()=>{if(!n.queries.firstID){t.editor.open(["_QUERIES_",""]);return}t.editor.open(["_QUERIES_",n.queries.firstID])},i=()=>{if(!n.filters.firstID){t.editor.open(["_FILTERS_",""]);return}t.editor.open(["_FILTERS_",n.filters.firstID])},[a,l]=g.useState(!1),c=()=>l(!0),u=()=>l(!1);return r.jsxs(o.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},zIndex:299,children:[r.jsxs(o.Navbar.Section,{children:[r.jsxs(o.Group,{grow:!0,spacing:0,sx:{...EA,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[r.jsx(o.Tooltip,{label:e("filter.labels"),withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:i,children:r.jsx(M.IconFilter,{size:18})})}),r.jsx(o.Tooltip,{label:e("query.labels"),withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:s,children:r.jsx(M.IconDatabase,{size:18})})}),r.jsx(o.Tooltip,{label:e("interactions.interactions_viewer"),withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:c,children:r.jsx(M.IconLink,{size:18})})})]}),r.jsx(IA,{opened:a,close:u})]}),r.jsx(o.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:e("view.labels")})}),r.jsx(o.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:r.jsx(PA,{})}),r.jsx(o.Navbar.Section,{children:r.jsx(o.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:r.jsx(o.Button,{size:"xs",leftIcon:r.jsx(M.IconSettings,{size:20}),onClick:()=>t.editor.open([]),children:e("common.titles.settings")})})})]})}),LA={[ce.Checkbox]:"true",[ce.DateRange]:"[new Date('2023-01-01 00:00:00'), new Date('2024-01-01 00:00:00')]",[ce.MultiSelect]:"[]",[ce.Select]:'""',[ce.TreeSelect]:"[]",[ce.TextInput]:'""'},BA=e=>["function getDefaultValue(filter, utils, context) {",` return ${LA[e]};`,"}"].join(`
|
|
457
|
+
`),ar=D.observer(({filter:e})=>{const{t}=_.useTranslation();return r.jsx(Ri,{label:"",title:t("filter.field.custom_default_value.title"),triggerLabel:t("filter.field.custom_default_value.trigger"),value:e.default_value_func,onChange:e.setDefaultValueFunc,defaultValue:BA(e.type),triggerButtonProps:{size:"xs",color:"grape",sx:{flexGrow:0,alignSelf:"flex-start"},leftIcon:r.jsx(M.IconMathFunction,{size:16})},description:r.jsx(o.Alert,{title:t("filter.field.custom_default_value.tips"),color:"gray",mb:16,children:r.jsxs(o.List,{size:13,type:"ordered",children:[r.jsx(o.List.Item,{children:t("filter.field.custom_default_value.tip_1")}),r.jsx(o.List.Item,{children:t("filter.field.custom_default_value.tip_2")})]})})})}),qA=D.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config;return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Checkbox,{checked:s.default_value,onChange:i=>s.setDefaultValue(i.currentTarget.checked),label:n("filter.widget.checkbox.default_checked")}),r.jsx(ar,{filter:t})]}),r.jsx(ys,{label:n("filter.widget.checkbox.description"),value:s.description,onChange:s.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}})]})}),VA=[{label:"2022",value:"YYYY"},{label:"202201",value:"YYYYMM"},{label:"20220101",value:"YYYYMMDD"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],NA=D.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config,i=g.useMemo(()=>Uo().map(({key:a,value:l,group:c})=>({label:n(`filter.widget.date_range.shortcut.${c}.full.${a}`),value:l,group:n(`filter.widget.date_range.shortcut.${c}.label`)})),[]);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{children:[r.jsx(o.Checkbox,{checked:s.required,onChange:a=>s.setRequired(a.currentTarget.checked),label:n("filter.widget.date_range.required")}),r.jsx(o.Checkbox,{checked:s.allowSingleDateInRange,onChange:a=>s.setAllowSingleDateInRange(a.currentTarget.checked),label:n("filter.widget.date_range.allow_single_date")})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(o.Select,{data:VA,label:n("filter.widget.date_range.display_format"),value:s.inputFormat,onChange:s.setInputFormat}),r.jsx(o.NumberInput,{label:n("filter.widget.date_range.max_days"),min:0,value:s.max_days,onChange:s.setMaxDays,hideControls:!0})]}),r.jsxs(o.Group,{children:[r.jsx(Ph,{label:n("filter.widget.date_range.default_value"),config:s,value:s.default_value,onChange:s.setDefaultValue,disabled:!!s.default_shortcut}),r.jsx(o.Select,{data:i,label:n("filter.widget.date_range.default_by_shortcut"),value:s.default_shortcut,onChange:s.setDefaultShortcut,placeholder:n("filter.widget.date_range.default_by_shortcut_placeholder"),clearable:!0,sx:{flexGrow:1},maxDropdownHeight:500})]}),r.jsx(ar,{filter:t})]})}),Il=D.observer(({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),s=Z(),i=Y(),a=g.useMemo(()=>i.queries.options,[i.queries.current]),l=a.length===0,c=u=>{s.editor.setPath(["_QUERIES_",u])};return r.jsx(o.Select,{label:r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Text,{children:n("filter.widget.common.use_query_data_as_options")}),e&&r.jsx(o.Button,{size:"xs",leftIcon:r.jsx(M.IconArrowCurveRight,{size:16}),variant:"subtle",color:"blue",onClick:()=>c(e),children:n("query.open")})]}),data:a,value:e,onChange:t,allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:l,error:l?"You need to add a query in Data Settings":void 0,styles:{label:{display:"block"}}})}),$A=`
|
|
458
458
|
// row
|
|
459
459
|
{
|
|
460
460
|
label: string;
|
|
461
461
|
value: string;
|
|
462
462
|
description?: string; // optional
|
|
463
463
|
}
|
|
464
|
-
`,tg=()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"subtle",compact:!0,onClick:()=>n(s=>!s),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),r.jsx(o.Collapse,{in:t,children:r.jsx(an.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children
|
|
464
|
+
`,tg=()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"subtle",compact:!0,onClick:()=>n(s=>!s),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),r.jsx(o.Collapse,{in:t,children:r.jsx(an.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:$A})})]})},FA=D.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config,i=()=>{s.addStaticOption({label:"",value:""})},a=s.static_options,l=[...a];return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Checkbox,{checked:s.required,onChange:c=>s.setRequired(c.currentTarget.checked),label:n("filter.widget.select.required")}),r.jsx(ar,{filter:t})]}),r.jsx(o.TextInput,{label:n("filter.widget.select.width"),description:n("filter.widget.multi_select.width_description"),value:s.min_width,onChange:c=>s.setMinWidth(c.currentTarget.value),placeholder:"200px"}),r.jsx(o.Divider,{label:n("filter.widget.select.configure_options"),labelPosition:"center"}),r.jsxs(o.Stack,{spacing:10,sx:{position:"relative",minHeight:"50px"},children:[s.usingQuery&&r.jsxs(r.Fragment,{children:[r.jsx(o.Overlay,{opacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),r.jsx(o.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:r.jsx(o.Text,{color:"white",size:16,children:n("filter.widget.common.using_query")})})]}),a.length>0&&r.jsx(o.MultiSelect,{label:n("filter.widget.select.default_selection"),data:l,value:[...s.default_value],onChange:s.setDefaultValue}),a.map((c,u)=>r.jsxs(o.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[r.jsx(o.TextInput,{label:n("common.label"),required:!0,value:s.static_options[u].label,onChange:d=>{s.static_options[u].setLabel(d.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(o.TextInput,{label:n("common.value"),required:!0,value:s.static_options[u].value,onChange:d=>{s.static_options[u].setValue(d.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(o.ActionIcon,{color:"red",variant:"subtle",onClick:()=>s.removeStaticOption(u),sx:{position:"absolute",top:28,right:5},children:r.jsx(V.Trash,{size:16})})]},u)),r.jsx(o.Button,{mt:10,size:"xs",color:"blue",leftIcon:r.jsx(V.PlaylistAdd,{size:20}),onClick:i,sx:{width:"50%"},mx:"auto",children:n("common.actions.add_an_option")})]}),r.jsx(o.Divider,{label:n("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),r.jsx(o.NumberInput,{value:s.default_selection_count,onChange:s.setDefaultSelectionCount,label:n("filter.widget.common.default_selection_count")}),r.jsx(Il,{value:s.options_query_id,onChange:s.setOptionsQueryID}),r.jsx(tg,{})]})}),GA=D.observer(function({filter:t}){const{t:n,i18n:s}=_.useTranslation(),i=t.config,a=()=>{i.addStaticOption({label:"",value:""})},l=i.static_options,c=g.useMemo(()=>[{label:n("filter.widget.select.no_default_selection"),value:""},...l],[s.language,l]);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Checkbox,{checked:i.required,onChange:u=>i.setRequired(u.currentTarget.checked),label:n("filter.widget.select.required")}),r.jsx(o.Checkbox,{checked:i.clearable,onChange:u=>i.setClearable(u.currentTarget.checked),label:n("filter.widget.select.clearable")}),r.jsx(ar,{filter:t})]}),r.jsx(o.TextInput,{label:n("filter.widget.select.width"),value:i.width,onChange:u=>i.setWidth(u.currentTarget.value),placeholder:"200px"}),r.jsx(o.Divider,{label:n("filter.widget.select.configure_options"),labelPosition:"center"}),r.jsxs(o.Stack,{spacing:10,sx:{position:"relative",minHeight:"50px"},children:[i.usingQuery&&r.jsxs(r.Fragment,{children:[r.jsx(o.Overlay,{opacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),r.jsx(o.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:r.jsx(o.Text,{color:"white",size:16,children:n("filter.widget.common.using_query")})})]}),l.length>0&&r.jsx(o.Select,{label:n("filter.widget.select.default_selection"),data:c,value:i.default_value,onChange:i.setDefaultValue}),l.map((u,d)=>r.jsxs(o.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[r.jsx(o.TextInput,{label:n("common.label"),required:!0,value:i.static_options[d].label,onChange:p=>{i.static_options[d].setLabel(p.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(o.TextInput,{label:n("common.value"),required:!0,value:i.static_options[d].value,onChange:p=>{i.static_options[d].setValue(p.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(o.ActionIcon,{color:"red",variant:"subtle",onClick:()=>i.removeStaticOption(d),sx:{position:"absolute",top:28,right:5},children:r.jsx(V.Trash,{size:16})})]},d)),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(V.PlaylistAdd,{size:20}),onClick:a,sx:{width:"50%"},mx:"auto",children:n("common.actions.add_an_option")})]}),r.jsx(o.Divider,{label:n("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),r.jsx(o.Checkbox,{checked:i.default_selection_count===1,onChange:u=>i.setDefaultSelectionCount(u.currentTarget.checked?1:0),label:n("filter.widget.select.select_first_option_by_default")}),r.jsx(Il,{value:i.options_query_id,onChange:i.setOptionsQueryID}),r.jsx(tg,{})]})}),WA=D.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config;return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{children:[r.jsx(o.TextInput,{label:n("filter.widget.text_input.default_value"),value:s.default_value,onChange:i=>{s.setDefaultValue(i.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(o.Box,{mt:22,children:r.jsx(ar,{filter:t})})]}),r.jsx(o.Checkbox,{checked:s.required,onChange:i=>s.setRequired(i.currentTarget.checked),label:n("filter.widget.text_input.required")})]})}),RA=`
|
|
465
465
|
// row
|
|
466
466
|
{
|
|
467
467
|
label: string;
|
|
@@ -469,7 +469,7 @@ Check the top-level render call using <`+L+">.")}return A}}function jg(C,A){{if(
|
|
|
469
469
|
parent_value: string;
|
|
470
470
|
description?: string;
|
|
471
471
|
}
|
|
472
|
-
`,RA=()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"subtle",compact:!0,onClick:()=>n(s=>!s),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),r.jsx(o.Collapse,{in:t,children:r.jsx(an.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:WA})})]})},QA=D.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config;return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Checkbox,{checked:s.required,onChange:i=>s.setRequired(i.currentTarget.checked),label:n("filter.widget.select.required")}),r.jsx(ar,{filter:t})]}),r.jsx(o.TextInput,{label:n("filter.widget.common.min_width"),value:s.min_width,onChange:i=>s.setMinWidth(i.currentTarget.value),placeholder:"200px"}),r.jsx(o.Divider,{label:n("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),r.jsx(o.Checkbox,{checked:s.treeCheckStrictly,onChange:i=>s.setTreeCheckStrictly(i.currentTarget.checked),label:n("filter.widget.tree_select.strictly")}),r.jsx(o.NumberInput,{value:s.default_selection_count,onChange:s.setDefaultSelectionCount,label:n("filter.widget.common.default_selection_count")}),r.jsx(Il,{value:s.options_query_id,onChange:s.setOptionsQueryID}),r.jsx(RA,{})]})}),UA=D.observer(function({filter:t}){const{t:n}=_.useTranslation();return r.jsxs(o.Box,{sx:{maxWidth:"480px"},children:[r.jsx(o.Text,{pt:"0",pb:"md",color:"gray",children:n("common.titles.config")}),r.jsx(an.Prism,{mt:22,language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),YA={select:FA,"multi-select":$A,"tree-select":QA,"text-input":GA,checkbox:BA,"date-range":VA},En={select:"filter.widget.names.select","multi-select":"filter.widget.names.multi_select","tree-select":"filter.widget.names.tree_select","text-input":"filter.widget.names.text_input",checkbox:"filter.widget.names.checkbox","date-range":"filter.widget.names.date_range"},KA=D.observer(function({filter:t}){const{t:n,i18n:s}=_.useTranslation(),i=Y(),a=g.useMemo(()=>YA[t.type],[t.type]),l=g.useMemo(()=>[{label:n(En.select),value:"select"},{label:n(En["multi-select"]),value:"multi-select"},{label:n(En["tree-select"]),value:"tree-select"},{label:n(En["text-input"]),value:"text-input"},{label:n(En.checkbox),value:"checkbox"},{label:n(En["date-range"]),value:"date-range"}],[s.language]);return r.jsxs(o.Group,{grow:!0,spacing:20,align:"top",children:[r.jsxs(o.Box,{sx:{maxWidth:"600px"},children:[r.jsx(o.Text,{pb:"md",color:"gray",children:n("common.titles.edit")}),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{noWrap:!0,children:[r.jsx(o.NumberInput,{label:n("filter.field.order"),required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&r.jsx(o.Checkbox,{label:n("filter.field.auto_submit"),checked:t.auto_submit,onChange:c=>t.setAutoSubmit(c.currentTarget.checked),mt:22})]}),r.jsx(o.MultiSelect,{label:n("filter.field.visible_in"),data:i.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),r.jsx(o.TextInput,{label:n("common.key"),placeholder:n("filter.field.key_placeholder"),required:!0,value:t.key,onChange:c=>{t.setKey(c.currentTarget.value)}}),r.jsx(o.TextInput,{label:n("common.label"),placeholder:n("filter.field.label_placeholder"),required:!0,value:t.label,onChange:c=>{t.setLabel(c.currentTarget.value)}}),r.jsx(o.Select,{label:n("filter.field.widget"),data:l,required:!0,value:t.type,onChange:t.setType,maxDropdownHeight:500}),r.jsx(o.Divider,{mb:0,mt:10,variant:"dashed",labelPosition:"center"}),r.jsx(a,{filter:t})]})]}),r.jsx(UA,{filter:t})]})}),XA=D.observer(({id:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Z(),i=Y();if(e==="")return null;const a=i.filters.findByID(e);if(!a)return r.jsxs(o.Text,{size:14,children:["Filter by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_FILTERS_",""])},c=()=>{n.openConfirmModal({title:`${t("filter.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.filters.removeByID(e),l()},confirmProps:{color:"red"},zIndex:320})};return r.jsxs(o.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[r.jsx(o.Group,{position:"right",pt:10,children:r.jsx(o.Button,{size:"xs",color:"red",leftIcon:r.jsx(V.Trash,{size:16}),onClick:c,children:t("filter.delete")})}),r.jsx(o.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:r.jsx(KA,{filter:a})})]})}),JA=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState([]),s=Z(),i=d=>{s.editor.setPath(["_FILTERS_",d])},a=()=>{s.content.filters.downloadSchema(t)},l=g.useMemo(()=>s.content.filters.sortedList.map(d=>d.id),[s.content.filters.sortedList]),c=()=>{n(l)},u=()=>{n([])};return r.jsxs(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[r.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:e("filter.manage")})}),r.jsx(o.Flex,{justify:"space-between",align:"center",px:12,children:r.jsxs(o.Group,{position:"left",children:[r.jsxs(o.Button.Group,{children:[r.jsx(o.Button,{variant:"default",size:"xs",onClick:c,children:e("common.actions.select_all")}),r.jsx(o.Button,{variant:"default",size:"xs",onClick:u,children:e("common.actions.clear_selection")})]}),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(M.IconCode,{size:14}),disabled:t.length===0,onClick:a,children:e("common.actions.download_schema")})]})}),r.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(o.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"40px"}}),r.jsx("th",{style:{width:"300px"},children:e("common.label")}),r.jsx("th",{children:e("common.key")}),r.jsx("th",{style:{width:"100px"},children:e("filter.field.widget")}),r.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx("tbody",{children:s.content.filters.sortedList.map(d=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx(o.Checkbox,{value:d.id,styles:{input:{cursor:"pointer"}}})}),r.jsx("td",{children:d.label}),r.jsx("td",{children:d.key}),r.jsx("td",{children:e(En[d.type])}),r.jsx("td",{children:r.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>i(d.id),children:e("common.actions.open")})})]},d.id))})]})})})]})}),ZA=D.observer(()=>{const{t:e}=_.useTranslation(),t=Y(),[n,s]=g.useState(()=>JSON.stringify(t.mock_context.current,null,4)),i=()=>{try{t.mock_context.replace(JSON.parse(n))}catch(l){sn.showNotification({title:"Failed",message:l.message,color:"red"})}},a=g.useMemo(()=>{try{return JSON.stringify(JSON.parse(n))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[n,t.mock_context.current]);return r.jsxs(o.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[r.jsx(o.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:r.jsx(o.Text,{weight:500,children:e("mock_context.label")})}),r.jsxs(o.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[r.jsxs(o.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[r.jsx(o.Text,{children:e("mock_context.hint")}),r.jsx(o.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:n,onChange:s,sx:{flexGrow:1}})]}),r.jsx(o.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!a,onClick:i,children:r.jsx(V.DeviceFloppy,{size:20})})]})]})}),HA=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge();return r.jsx(ys,{label:e("panel.panel_description"),value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}})}),eP=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge(),n=_e().layouts.findItemByPanelID(t.id),{style:s}=t;return r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mb:-10,label:e("panel.style.label"),labelPosition:"center",variant:"dashed"}),r.jsxs(o.Stack,{spacing:20,children:[r.jsxs(o.Group,{grow:!0,align:"top",children:[r.jsx(o.NumberInput,{label:e("panel.style.width"),min:1,max:36,step:1,precision:0,rightSection:r.jsx(o.Text,{size:12,children:e("panel.style.width_postfix")}),styles:{rightSection:{width:"auto",maxWidth:"100px",paddingRight:"14px",justifyContent:"flex-end"}},value:n.w,onChange:i=>{i&&n.setWidth(i)}}),r.jsx(o.NumberInput,{label:e("panel.style.height"),rightSection:r.jsx(o.Text,{size:12,children:e("panel.style.height_postfix")}),styles:{rightSection:{width:"40px"}},value:n.h,onChange:i=>{i&&n.setHeight(i)}})]}),r.jsx(o.Checkbox,{ml:6,label:e("panel.style.border"),checked:s.border.enabled,onChange:i=>s.border.setEnabled(i.currentTarget.checked)})]})]})}),tP=()=>r.jsxs("span",{className:"mantine-103svbs mantine-InputWrapper-required mantine-Select-required","aria-hidden":"true",children:[" ","*"]}),nP=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge(),{name:n}=t,[s,i]=he.useInputState(n),a=n!==s,l=g.useCallback(()=>{a&&t.setName(s)},[a,s]);g.useEffect(()=>{i(n)},[n]);const c=!s.trim();return r.jsxs(o.Stack,{spacing:4,children:[r.jsxs(o.Group,{align:"center",children:[r.jsxs(o.Text,{size:14,fw:500,children:[e("panel.panel_name"),r.jsx(tP,{})]}),r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",disabled:!a||c,onClick:l,children:r.jsx(M.IconDeviceFloppy,{size:18})})]}),r.jsx(o.TextInput,{value:s,onChange:i,required:!0})]})}),rP=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge();return r.jsx(o.Stack,{spacing:6,mb:10,children:r.jsxs(o.Group,{pl:6,position:"left",spacing:20,children:[r.jsx(o.Checkbox,{size:"sm",checked:t.title.show,onChange:n=>t.title.setShow(n.currentTarget.checked),label:e("panel.show_title"),sx:{userSelect:"none"}}),r.jsx(o.Checkbox,{size:"sm",checked:!0,disabled:!0,label:e("panel.use_name_as_title")})]})})});function sP(){const{t:e}=_.useTranslation();return r.jsxs(o.Stack,{sx:{height:"100%"},children:[r.jsx(eP,{}),r.jsx(o.Divider,{label:e("common.info"),labelPosition:"center",variant:"dashed"}),r.jsx(nP,{}),r.jsx(rP,{}),r.jsx(HA,{})]})}const iP={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},"th, td":{wordBreak:"break-word"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function ng({data:e}){const t=g.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const s=bt.createColumnHelper();return Object.keys(e[0]).map(i=>s.accessor(i,{cell:a=>a.getValue()}))},[e]),n=bt.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:bt.getCoreRowModel()});return e.length===0?r.jsx(o.Box,{sx:{height:"5em"}}):r.jsx(ze,{children:r.jsxs(o.Table,{sx:iP,children:[r.jsx("thead",{children:n.getHeaderGroups().map(s=>r.jsx("tr",{children:s.headers.map(i=>r.jsxs("th",{style:{width:i.getSize()},children:[i.isPlaceholder?null:bt.flexRender(i.column.columnDef.header,i.getContext()),r.jsx(o.ActionIcon,{onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:r.jsx(V.ArrowBarToRight,{})})]},i.id))},s.id))}),r.jsx("tbody",{children:n.getRowModel().rows.map(s=>r.jsx("tr",{children:s.getVisibleCells().map(i=>r.jsx("td",{children:r.jsx(ze,{children:typeof i.getValue()=="object"?r.jsx("pre",{children:JSON.stringify(i.getValue(),null,2)}):bt.flexRender(i.column.columnDef.cell,i.getContext())})},i.id))},s.id))})]})})}const aP=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],oP={icon:{width:"80px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"80px"}}},lP=({data:e,page:t,setPage:n,limit:s,setLimit:i})=>{const{t:a}=_.useTranslation(),l=e.length,c=Math.ceil(l/s),u=p=>{n(1),i(Number(p))};if(l===0)return null;const d=c===1&&l<=10;return r.jsxs(o.Group,{pt:10,px:10,position:"apart",children:[r.jsxs(o.Group,{position:"left",children:[c>1&&r.jsx(o.Pagination,{size:"sm",value:t,onChange:n,total:c,withEdges:c>7,styles:{control:{height:"30px"}}}),!d&&r.jsx(o.Select,{icon:r.jsx(o.Text,{ta:"center",color:"dimmed",size:14,children:a("common.pagination.page_size")}),size:"xs",styles:oP,data:aP,value:String(s),onChange:u})]}),r.jsx(o.Group,{position:"right",children:r.jsx(o.Text,{color:"dimmed",my:0,size:14,children:a("common.pagination.total_rows",{total:l})})})]})},cP=My(({data:e,loading:t})=>{const[n,s]=g.useState(1),[i,a]=g.useState(20),l=g.useMemo(()=>{const c=(n-1)*i,u=c+i;return e.slice(c,u)},[e,n,i]);return r.jsxs(ze,{children:[r.jsx(lP,{data:e,page:n,setPage:s,limit:i,setLimit:a}),r.jsxs(o.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[r.jsx(o.LoadingOverlay,{visible:t,overlayBlur:2}),r.jsx(ng,{data:l})]})]})}),uP=({queryID:e})=>{const t=_e(),{state:n,error:s}=t.getDataStuffByID(e),i=g.useMemo(()=>t.queries.findByID(e),[t,e]);return n==="loading"?null:s?r.jsx(o.Text,{mt:10,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:s}):i!=null&&i.stateMessage?r.jsx(o.Text,{mt:10,color:"gray",align:"center",children:i.stateMessage}):null},El=D.observer(({id:e,moreActions:t,refreshOnMount:n})=>{const{t:s}=_.useTranslation(),i=_e(),{data:a,state:l}=i.getDataStuffByID(e),c=l==="loading",u=g.useCallback(()=>{i.queries.refetchDataByQueryID(e)},[e,i]),d=()=>{i.queries.downloadDataByQueryID(e)};g.useEffect(()=>{n&&u()},[u,n]);const p=!Array.isArray(a)||a.length===0;return r.jsxs(o.Stack,{spacing:0,sx:{height:"100%",border:"1px solid #eee"},children:[r.jsxs(o.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[r.jsx(o.Group,{position:"left",children:r.jsx(o.Text,{weight:500,children:s("data.preview_data")})}),r.jsxs(o.Group,{pr:15,children:[t,r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",disabled:c,onClick:u,children:r.jsx(V.Refresh,{size:16})}),r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",disabled:c||p,onClick:d,children:r.jsx(V.Download,{size:16})})]})]}),r.jsxs(o.Box,{pb:20,sx:{position:"relative",flexGrow:1,overflow:"auto"},children:[r.jsx(uP,{queryID:e}),r.jsx(cP,{data:a,loading:c})]})]})}),dP=D.observer(function(){const{t}=_.useTranslation(),n=Z(),s=Y(),{panel:i}=Ge(),[a,l]=g.useState(!1),c=d=>{n.editor.setPath(["_QUERIES_",d])},u=i.queryIDs.length;return r.jsxs(r.Fragment,{children:[r.jsx(o.Drawer,{opened:a,onClose:()=>l(!1),title:t("panel.settings.choose_queries"),padding:"xl",size:500,zIndex:320,children:r.jsx(o.Checkbox.Group,{value:[...i.queryIDs],onChange:i.setQueryIDs,children:r.jsx(o.Stack,{spacing:"lg",children:s.queries.options.map(d=>r.jsx(o.Checkbox,{label:d.label,value:d.value},d.value))})})}),r.jsxs(o.Stack,{spacing:6,children:[r.jsx(o.Group,{position:"left",children:r.jsx(o.Button,{variant:"light",size:"sm",leftIcon:r.jsx(M.IconLine,{size:16}),onClick:()=>l(!0),children:t(u===0?"panel.settings.need_to_choose_queries":"panel.settings.choose_queries")})}),u===1&&r.jsx(El,{id:i.queryIDs[0],moreActions:r.jsx(o.Tooltip,{label:t("query.open"),children:r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(i.queryIDs[0]),children:r.jsx(M.IconArrowCurveRight,{size:16})})})}),u>1&&r.jsxs(o.Tabs,{defaultValue:i.queryIDs[0],children:[r.jsx(o.Tabs.List,{children:i.queries.map(d=>r.jsx(o.Tabs.Tab,{value:d.id,children:d.name},d.id))}),i.queries.map(d=>r.jsx(o.Tabs.Panel,{value:d.id,children:r.jsx(El,{id:d.id,moreActions:r.jsx(o.Tooltip,{label:t("query.open"),children:r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(d.id),children:r.jsx(M.IconArrowCurveRight,{size:16})})})})},d.id))]})]})]})}),pP=D.observer(()=>{const{panel:e}=St();return r.jsx(ze,{children:r.jsx(o.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:r.jsxs(o.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:e.style.border.enabled?"1px":"0px"},children:[r.jsxs(o.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[r.jsx(o.Group,{children:r.jsx(jl,{})}),r.jsx(o.Group,{grow:!0,position:"center",children:r.jsx(o.Text,{lineClamp:1,weight:"bold",children:e.title.show?e.name:""})}),r.jsx(o.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),r.jsx(o.Group,{px:5,pb:5,sx:{flexGrow:1,".panel-viz-section":{height:"calc(100% - 28px)"}},children:r.jsx(wl,{panel:e})})]})})})}),Al={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{},fallback:"0"},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class hP{constructor(t){B(this,"panel");B(this,"selected");this.panel=t,t.variables.length>0&&(this.selected=t.variables[0]),X.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}get variableOptions(){return this.panel.variables.map(t=>({label:t.name,value:t.name,description:t.aggregation.type}))}addNew(){const t=this.panel.variables.filter(n=>n.name.startsWith(Al.name)).length;this.panel.addVariable(v.cloneDeep({...Al,name:`${Al.name}${t||""}`})),this.selected=v.last(this.panel.variables)}select(t){this.selected=t}selectByName(t){if(!t){console.warn("Unexpected null name when calling selectByName");return}const n=this.variables.find(s=>s.name===t);if(!n){console.error(`Variable by name[${t}] not found`);return}this.selected=n}remove(t){this.selected===t&&(this.selected=void 0);const n=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!v.isEmpty(this.panel.variables)){const s=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[s]}}}function fP(){const{panel:e}=Ge();return W.useCreation(()=>new hP(e),[e])}function gP({label:e,value:t,onChange:n},s){const[i,a]=g.useState(Array.isArray(t)?[...t]:[]),l=g.useCallback(()=>{a(f=>[...f,""])},[a]),c=g.useCallback(f=>{a(m=>(m.splice(f,1),[...m]))},[a]),u=g.useMemo(()=>!v.isEqual(i,t),[i,t]),d=()=>{n(i.map(f=>f.toString()))},p=o.useMantineTheme(),h=g.useMemo(()=>Object.entries(p.colors).map(([f,m])=>m[6]),[p]);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"left",ref:s,children:[r.jsx(o.Text,{children:e}),r.jsx(o.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:d,children:r.jsx(V.DeviceFloppy,{size:20})})]}),r.jsxs(o.Group,{children:[i.map((f,m)=>r.jsx(o.ColorInput,{value:f,onChange:y=>{a(j=>(j.splice(m,1,y),[...j]))},swatches:h,rightSection:r.jsx(o.ActionIcon,{onClick:()=>c(m),color:"red",children:r.jsx(V.Trash,{size:14})}),sx:{width:"45%"}})),r.jsx(o.ActionIcon,{onClick:l,color:"blue",variant:"outline",children:r.jsx(V.PlaylistAdd,{size:20})})]})]})}const mP=g.forwardRef(gP);function xP({label:e,value:t,onChange:n,type:s},i){const[a,l]=g.useState(Array.isArray(t)?[...t]:[]),c=g.useCallback(()=>{l(h=>[...h,""])},[l]),u=g.useCallback(h=>{l(f=>(f.splice(h,1),[...f]))},[l]),d=g.useMemo(()=>!v.isEqual(a.map(String),t.map(String)),[a,t]),p=()=>{n(a.map(h=>s==="number"?Number(h):h.toString()))};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"left",ref:i,children:[r.jsx(o.Text,{children:e}),r.jsx(o.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:p,children:r.jsx(V.DeviceFloppy,{size:20})})]}),r.jsxs(o.Group,{children:[a.map((h,f)=>r.jsx(o.TextInput,{type:s,value:h,onChange:m=>{const y=m.currentTarget.value;l(j=>(j.splice(f,1,y),[...j]))},rightSection:r.jsx(o.ActionIcon,{onClick:()=>u(f),color:"red",children:r.jsx(V.Trash,{size:14})}),sx:{width:"45%"}})),r.jsx(o.ActionIcon,{onClick:c,color:"blue",variant:"outline",children:r.jsx(V.PlaylistAdd,{size:20})})]})]})}const yP=g.forwardRef(xP),bP=g.forwardRef(function({value:t,onChange:n},s){const{t:i}=_.useTranslation(),a=t.color.type,l=(u,d)=>{const p=v.cloneDeep(t);v.set(p,u,d),n(p)},c=u=>{if(u==="static"){n({...t,color:{type:"static",staticColor:"#25262B"}});return}n({...t,color:{type:"continuous",colorRange:[],valueRange:[]}})};return r.jsxs(r.Fragment,{children:[r.jsx(o.Stack,{children:r.jsx(o.TextInput,{label:i("style.font_size.label"),placeholder:i("styles.font_size.placeholder"),sx:{flex:1},value:t.size,onChange:u=>l("size",u.currentTarget.value)})}),r.jsx(o.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:r.jsx(vh,{label:i("style.font_weight.label"),value:t.weight,onChange:u=>l("weight",u)})}),r.jsx(o.Divider,{mt:"lg",mb:0,variant:"dashed",label:i("style.label"),labelPosition:"center"}),r.jsxs(o.Stack,{children:[r.jsx(o.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:t.color.type,onChange:c}),a==="static"&&r.jsx(Be,{value:t.color.staticColor,onChange:u=>l("color.staticColor",u)}),a==="continuous"&&r.jsxs(r.Fragment,{children:[r.jsx(yP,{label:"Value Range",value:t.color.valueRange,type:"number",onChange:u=>l("color.valueRange",u)}),r.jsx(mP,{label:"Color Range",value:t.color.colorRange,onChange:u=>l("color.colorRange",u)})]})]})]})}),vP=g.forwardRef(function({value:t,onChange:n,withStyle:s=!0,remove:i},a){const{t:l}=_.useTranslation(),c=(u,d)=>{const p=v.cloneDeep(t);v.set(p,u,d),n(p)};return r.jsxs(o.Stack,{ref:a,children:[r.jsxs(o.Stack,{spacing:"xs",px:"sm",py:"md",sx:{border:"1px solid #e9ecef"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.TextInput,{label:l("common.name"),required:!0,value:t.name,onChange:u=>c("name",u.currentTarget.value)}),r.jsx(F,{label:l("common.data_field"),required:!0,value:t.data_field,onChange:u=>c("data_field",u)})]}),r.jsx(jo,{label:l("panel.variable.aggregation.label"),pt:0,value:t.aggregation,onChange:u=>c("aggregation",u),withFallback:!0}),t.aggregation.type!=="custom"&&r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mt:"xl",mb:0,label:l("numbro.format.label"),labelPosition:"center",variant:"dashed"}),r.jsx(gt,{value:t.formatter,onChange:u=>c("formatter",u)})]})]}),s&&r.jsx(o.Accordion,{variant:"contained",children:r.jsxs(o.Accordion.Item,{value:"Styles",children:[r.jsx(o.Accordion.Control,{icon:r.jsx(o.Text,{size:"xl",children:"🖼️"}),children:l("style.label")}),r.jsx(o.Accordion.Panel,{children:r.jsx(bP,{value:t,onChange:n})})]})}),r.jsx(o.Button,{mt:20,leftIcon:r.jsx(M.IconTrash,{size:16}),color:"red",variant:"light",onClick:i,children:l("panel.variable.delete")})]})}),_P=D.observer(e=>{const{t}=_.useTranslation(),n=W.useCreation(()=>xf(e.variable),[e.variable]),s=()=>e.uiModel.remove(e.variable);return r.jsxs(o.Stack,{"data-testid":"variable-editor",align:"stretch",children:[r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{variant:"subtle",size:"xs",disabled:!n.changed,color:"red",onClick:n.reset,leftIcon:r.jsx(M.IconRecycle,{size:18}),children:t("common.actions.revert_changes")}),r.jsx(o.Button,{variant:"filled",size:"xs",disabled:!n.changed,color:"green",onClick:n.commit,leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),children:t("common.actions.save_changes")})]}),r.jsx(vP,{value:x.getSnapshot(n.copy),onChange:n.update,remove:s})]})});D.observer(e=>{const{uiModel:t}=e;return r.jsx(o.Stack,{className:"var-list",children:t.variables.map(n=>r.jsx(o.Button,{variant:t.selected===n?"filled":"subtle",color:"gray",onClick:()=>t.select(n),children:n.name},n.name))})});const jP=D.observer(({model:e})=>{const{t}=_.useTranslation();return r.jsx(o.Overlay,{color:"#fff",opacity:1,sx:{position:"absolute"},children:r.jsx(o.Button,{variant:"light",size:"xs",leftIcon:r.jsx(M.IconPlus,{size:16}),onClick:e.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:t("panel.variable.add")})})}),wP=D.observer(()=>{var n;const{t:e}=_.useTranslation(),t=fP();return t.variableOptions.length===0?r.jsx(jP,{model:t}):r.jsxs(o.Stack,{pb:20,children:[r.jsxs(o.Group,{position:"left",children:[r.jsx(o.Select,{label:e("panel.variable.labels"),data:t.variableOptions,value:(n=t.selected)==null?void 0:n.name,onChange:t.selectByName,maxDropdownHeight:600,sx:{flexGrow:1}}),r.jsx(o.Button,{variant:"light",size:"xs",leftIcon:r.jsx(M.IconPlus,{size:16}),onClick:t.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:e("panel.variable.add")})]}),r.jsx(o.Divider,{variant:"dashed"}),t.selected?r.jsx(_P,{uiModel:t,variable:t.selected}):r.jsx("span",{children:"Select or create a new variable on right side"})]})}),CP=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge();return Object.keys(t.variableStrings).length===0?null:r.jsxs(o.Stack,{mt:22,spacing:4,children:[r.jsx(o.Text,{size:"sm",fw:500,color:"dimmed",children:e("panel.variable.labels")}),r.jsx(an.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t.variableStrings,null,4)})]})});function SP(){const{t:e}=_.useTranslation(),{vizManager:t}=g.useContext(Gt);return g.useMemo(()=>{const n=t.availableVizList.map(s=>({value:s.name,label:e(s.displayName??s.name),group:e(s.displayGroup??"")}));return v.orderBy(n,[s=>s.group,s=>s.label],["asc","asc"])},[t])}const kP=D.observer(({value:e,submit:t})=>{const{t:n}=_.useTranslation(),[s,i]=he.useInputState(e);g.useEffect(()=>{i(e)},[e]);const a=SP(),l=e!==s;return r.jsx(o.Select,{label:n("visualization.component"),value:s,searchable:!0,onChange:i,data:a,rightSection:r.jsx(o.ActionIcon,{variant:"filled",color:"green",disabled:!l,onClick:()=>t(s),children:r.jsx(V.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),rg=[];function TP(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function DP(){const{data:e,panel:{variables:t,viz:n,title:s,name:i,queryIDs:a,description:l,id:c}}=Ge(),{vizManager:u}=g.useContext(Gt),d={name:i,title:s,description:l,viz:n,queryIDs:a,id:c},p=bf(d);try{return u.resolveComponent(d.viz.type),r.jsx(si,{configure:p,children:r.jsx(HI,{variables:t,setVizConf:n.setConf,panel:d,vizManager:u,data:e})})}catch(h){return console.info(v.get(h,"message")),null}}const MP=D.observer(()=>{const{data:e,panel:{viz:t}}=Ge(),{vizManager:n}=g.useContext(Gt),s=g.useCallback(d=>{if(d===t.type)return;const p=TP(n,d);t.setType(d),t.setConf(p||{})},[t.type]),i=d=>{try{t.setConf(JSON.parse(d))}catch(p){console.error(p)}},a=g.useMemo(()=>{var d;return(d=rg.find(p=>p.value===t.type))==null?void 0:d.Panel},[t.type,rg]),l=DP(),c=a?g.createElement(a,{data:e,conf:t.conf,setConf:t.setConf}):null,u=l||c;return r.jsxs(o.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[r.jsx(kP,{submit:s,value:t.type}),r.jsxs(ze,{children:[r.jsx(o.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:u}),!u&&r.jsx(o.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:i})]})]})}),zP=D.observer(({panel:e,sourceViewID:t})=>{const{t:n}=_.useTranslation(),s=Y(),[i,a]=g.useState(t);g.useEffect(()=>{a(t)},[t]);const[l,{open:c,close:u}]=he.useDisclosure(!1),d=()=>{e.moveToView(t,i),u()};return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{size:"xs",variant:"subtle",color:"blue",onClick:c,leftIcon:r.jsx(M.IconBoxMultiple,{size:14}),children:n("panel.settings.change_view")}),r.jsx(o.Modal,{opened:l,onClose:u,title:n("panel.settings.change_view_title"),zIndex:320,children:r.jsxs(o.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[r.jsx(o.Radio.Group,{value:i,onChange:a,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:r.jsx(o.Stack,{spacing:"xs",children:s.views.options.map(p=>r.jsx(o.Radio,{value:p.value,label:p.label},p.value))})}),r.jsxs(o.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[r.jsx(o.Button,{size:"xs",color:"red",leftIcon:r.jsx(M.IconX,{size:14}),onClick:u,children:n("common.actions.cancel")}),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(M.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:n("common.actions.confirm")})]})]})})]})}),IP={root:{flexGrow:1,width:"100%",minWidth:"1200px",overflow:"hidden"},panel:{width:"100%",minWidth:"1200px",height:"calc(100% - 44px)",padding:10,overflow:"auto"}},Pl=({children:e})=>r.jsxs(o.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"100%",position:"relative"},children:[r.jsx(o.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),r.jsxs(o.Stack,{justify:"flex-start",sx:{alignSelf:"flex-start",width:"600px",flexGrow:0,flexShrink:0},children:[r.jsx(pP,{}),r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(CP,{})})]})]});function EP(e){return!["richText","button"].includes(e)}const AP=D.observer(({panel:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Z(),i=Y(),[a,l]=g.useState("Data"),c=e.queries,d=EP(e.viz.type)&&e.dataLoading,p=d||e.queryErrors.length>0||e.queryStateMessages!==""||c.length===0,h=s.editor.path[1];g.useEffect(()=>{l(y=>p&&y==="Visualization"?"Data":y)},[e.id,p]);const f=()=>{s.editor.setPath(["_VIEWS_",h])},m=()=>n.openConfirmModal({title:`${t("panel.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.removePanelByID(e.id,h),f()},confirmProps:{color:"red"},zIndex:320});return r.jsxs(ra,{value:{panel:e,data:e.data,loading:d,errors:e.queryErrors,downloadPanelScreenshot:()=>{}},children:[r.jsxs(o.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[r.jsx(o.Text,{pt:9,pb:8,children:e.name}),r.jsxs(o.Group,{position:"right",noWrap:!0,children:[r.jsx(zP,{panel:e,sourceViewID:h}),r.jsx(o.Button,{size:"xs",variant:"subtle",color:"red",onClick:m,leftIcon:r.jsx(M.IconTrash,{size:14}),children:t("panel.delete")})]})]}),r.jsxs(o.Tabs,{value:a,onTabChange:l,keepMounted:!1,styles:IP,children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Data",disabled:d,children:t("data.label")}),r.jsx(o.Tabs.Tab,{value:"Panel",children:t("panel.label")}),r.jsx(o.Tabs.Tab,{value:"Variables",disabled:p,children:r.jsx(o.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:r.jsx(o.Text,{children:t("panel.variable.labels")})})}),r.jsx(o.Tabs.Tab,{value:"Visualization",disabled:p,children:r.jsx(o.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:r.jsx(o.Text,{children:t("visualization.label")})})}),r.jsx(o.Tabs.Tab,{value:"Interactions",children:t("interactions.label")})]}),r.jsxs(o.Tabs.Panel,{value:"Data",children:[r.jsx(o.LoadingOverlay,{visible:d,exitTransitionDuration:0}),r.jsx(dP,{})]}),r.jsx(o.Tabs.Panel,{value:"Panel",children:r.jsx(Pl,{children:r.jsx(sP,{})})}),r.jsx(o.Tabs.Panel,{value:"Variables",children:r.jsx(Pl,{children:r.jsx(wP,{})})}),r.jsx(o.Tabs.Panel,{value:"Visualization",children:r.jsx(ze,{children:r.jsx(Pl,{children:r.jsx(MP,{})})})}),r.jsx(o.Tabs.Panel,{value:"Interactions",children:r.jsx(ze,{children:r.jsx(nv,{})})})]})]})}),PP=D.observer(({viewID:e,panelID:t})=>{const n=Y();if(!n.views.findByID(e))return r.jsxs(o.Text,{size:14,children:["View by ID[",e,"] is not found"]});const i=n.panels.findByID(t);return i?r.jsx(AP,{panel:i}):r.jsxs(o.Text,{size:14,children:["Panel by ID[",t,"] is not found"]})}),OP=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState([]),s=lt.useModals(),i=Z(),a=f=>{i.editor.setPath(["_QUERIES_",f])},l=()=>{s.openConfirmModal({title:"Delete ununsed queries?",children:r.jsx(o.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.removeUnusedQueries(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.queries.downloadSchema(t)},u=g.useMemo(()=>i.content.queries.sortedList.map(f=>f.id),[i.content.queries.sortedList]),d=()=>{n(u)},p=()=>{n([])},h=i.content.queriesUsage;return r.jsxs(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[r.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:e("query.manage")})}),r.jsxs(o.Flex,{justify:"space-between",align:"center",px:12,children:[r.jsxs(o.Group,{position:"left",children:[r.jsxs(o.Button.Group,{children:[r.jsx(o.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),r.jsx(o.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(M.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),r.jsx(o.Button,{variant:"subtle",size:"xs",color:"red",leftIcon:r.jsx(M.IconTrash,{size:14}),disabled:!i.content.hasUnusedQueries,onClick:l,children:e("query.delete_unused")})]}),r.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(o.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"40px"}}),r.jsx("th",{children:e("common.name")}),r.jsx("th",{style:{width:"200px"},children:e("data_source.label")}),r.jsx("th",{style:{width:"100px",textAlign:"right"},children:e("common.type")}),r.jsx("th",{style:{width:"100px",textAlign:"center"},children:e("query.usage.label")}),r.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx("tbody",{children:i.content.queries.sortedList.map(f=>{var y;const m=((y=h[f.id])==null?void 0:y.length)??0;return r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx(o.Checkbox,{value:f.id,styles:{input:{cursor:"pointer"}}})}),r.jsx("td",{children:f.name}),r.jsx("td",{children:f.key}),r.jsx("td",{style:{textAlign:"right"},children:f.type}),r.jsx("td",{style:{color:m===0?"#ff0000":"#000",fontWeight:m===0?"bold":"normal",textAlign:"center"},children:m}),r.jsx("td",{children:r.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>a(f.id),children:e("common.actions.open")})})]},f.id)})})]})})})]})}),LP=e=>{const{t}=_.useTranslation(),{queryModel:n}=e,s=Z(),i=Y(),l=i.findQueryUsage(n.id).length>0,c=lt.useModals(),u=()=>{c.openConfirmModal({title:`${t("query.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.queries.removeQuery(n.id),s.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return l?r.jsx(o.Tooltip,{label:t("query.cant_delete"),withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"top-end",children:r.jsx(o.Box,{sx:{alignSelf:"flex-end"},children:r.jsx(o.Button,{disabled:!0,size:"xs",leftIcon:r.jsx(M.IconTrash,{size:16}),children:t("query.delete")})})}):r.jsx(o.Button,{color:"red",size:"xs",onClick:u,leftIcon:r.jsx(M.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:t("query.delete")})},BP=D.observer(LP),sg=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:n,count:s,spacing:i=16,pl:a=0})=>r.jsxs(o.Stack,{spacing:i,mt:6,pl:a,children:[Array.from(new Array(s-1),(l,c)=>r.jsx(o.Skeleton,{width:e,height:n,radius:"xs"},c)),r.jsx(o.Skeleton,{width:t,height:n,radius:"xs"})]}),Qr=({value:e})=>e===null||e===""?null:r.jsx(o.Tooltip,{label:e,disabled:!e,multiline:!0,children:r.jsx(o.ActionIcon,{children:r.jsx(M.IconInfoCircle,{size:14})})}),qP=({column:e})=>{const{column_key:t,column_key_text:n}=e;return t?r.jsx(o.Tooltip,{label:n,disabled:!n,children:r.jsx(o.Badge,{children:t})}):null},VP=D.observer(({dataSource:e})=>{const{columns:t}=e;return t.loading?r.jsx(sg,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:r.jsxs(o.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{width:50}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:30}}),r.jsx("col",{style:{width:70}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{minWidth:80,width:80}}),r.jsx("col",{style:{minWidth:120,width:120}})]}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"#"}),r.jsx("th",{children:"Column Name"}),r.jsx("th",{}),r.jsx("th",{}),r.jsx("th",{children:"Type"}),r.jsx("th",{children:"Nullable"}),r.jsx("th",{children:"Default Value"})]})}),r.jsx("tbody",{children:t.data.map(n=>r.jsxs("tr",{children:[r.jsx("td",{children:n.ordinal_position}),r.jsx("td",{children:n.column_name}),r.jsx("td",{children:r.jsx(Qr,{value:n.column_comment})}),r.jsx("td",{children:r.jsx(qP,{column:n})}),r.jsx("td",{children:n.column_type}),r.jsx("td",{children:n.is_nullable}),r.jsx("td",{children:r.jsx(Qr,{value:n.column_default})})]},n.column_name))})]})}),NP=D.observer(({dataSource:e})=>{const{indexes:t}=e,n=t.data;return r.jsxs(o.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:250}})]}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Index Length"}),r.jsx("th",{children:"Index Name"}),r.jsx("th",{children:"Index Algorithm"}),r.jsx("th",{children:"Unique"}),r.jsx("th",{children:"Column Name"})]})}),r.jsx("tbody",{children:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.index_length}),r.jsx("td",{children:s.index_name}),r.jsx("td",{children:s.index_algorithm}),r.jsx("td",{children:s.is_unique?"YES":"NO"}),r.jsx("td",{children:s.column_name})]},s.index_name))})]})}),$P=D.observer(({dataSource:e})=>{const{indexes:t}=e,n=t.data;return r.jsxs(o.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}})]}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Index Name"}),r.jsx("th",{children:"Index Algorithm"}),r.jsx("th",{children:"Unique"}),r.jsx("th",{children:"Definition"}),r.jsx("th",{children:"Condition"}),r.jsx("th",{children:"Comment"})]})}),r.jsx("tbody",{children:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.index_name}),r.jsx("td",{children:s.index_algorithm}),r.jsx("td",{children:s.is_unique?"YES":"NO"}),r.jsx("td",{children:r.jsx(Qr,{value:s.index_definition})}),r.jsx("td",{children:r.jsx(Qr,{value:s.condition})}),r.jsx("td",{children:r.jsx(Qr,{value:s.comment})})]},s.index_name))})]})}),FP=D.observer(({dataSource:e})=>{const{indexes:t}=e;return t.loading||t.empty?null:e.type===ye.MySQL?r.jsx(NP,{dataSource:e}):e.type===ye.Postgresql?r.jsx($P,{dataSource:e}):null}),GP=D.observer(({dataSource:e})=>r.jsxs(o.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[r.jsx(ze,{children:r.jsx(VP,{dataSource:e})}),r.jsx(ze,{children:r.jsx(FP,{dataSource:e})})]}));function WP({table_type:e}){return e==="VIEW"?r.jsx(M.IconEye,{size:14}):e==="BASE TABLE"?r.jsx(M.IconTable,{size:14}):null}const RP=D.observer(({dataSource:e})=>{const{tables:t}=e;return t.loading?r.jsx(sg,{height:"24px",lastWidth:"50%",count:15}):r.jsx(o.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(t.data).map(([n,s])=>r.jsx(o.NavLink,{label:n,icon:r.jsx(M.IconDatabase,{size:14}),defaultOpened:e.table_schema===n,pl:0,childrenOffset:14,children:s.map(i=>r.jsx(o.NavLink,{label:i.table_name,icon:r.jsx(WP,{table_type:i.table_type}),onClick:()=>{e.setKeywords(n,i.table_name)},active:e.table_name===i.table_name},i.table_name))},n))})}),QP=({visible:e})=>r.jsx(o.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:r.jsx(o.LoadingOverlay,{visible:e})}),UP=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],YP={icon:{width:"50px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"50px"}}},KP=D.observer(({dataSource:e})=>{const{t}=_.useTranslation(),{tableData:n}=e;return r.jsxs(o.Group,{pt:10,px:10,position:"apart",children:[r.jsxs(o.Group,{position:"left",children:[n.maxPage>1&&r.jsx(o.Pagination,{size:"sm",value:n.page,onChange:n.setPage,total:n.maxPage,withEdges:n.maxPage>7,styles:{control:{height:"30px"}}}),r.jsx(o.Select,{icon:r.jsx(o.Text,{ta:"center",color:"dimmed",size:14,children:t("common.pagination.page_size")}),size:"xs",styles:YP,data:UP,value:String(n.limit),onChange:s=>n.setLimit(Number(s))})]}),r.jsx(o.Group,{position:"right",children:r.jsx(o.Text,{color:"dimmed",my:0,size:14,children:t("common.pagination.total_rows",{total:n.total})})})]})}),XP=D.observer(({dataSource:e})=>{const t=e.tableData;return t.maxPage===0?r.jsx(o.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):t.error?r.jsx(o.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:t.error}):t.page===1&&t.loading?r.jsx(QP,{visible:!0}):r.jsxs(ze,{children:[r.jsx(KP,{dataSource:e}),r.jsxs(o.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[r.jsx(o.LoadingOverlay,{visible:t.loading,overlayBlur:2}),r.jsx(ng,{data:t.data})]})]})}),JP={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},ZP=D.observer(({dataSource:e})=>{const{t}=_.useTranslation();return g.useEffect(()=>{e.loadTablesIfEmpty()},[e]),e.tables.error?r.jsx(o.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.tables.error}):r.jsxs(o.Flex,{sx:{height:"100%"},children:[r.jsx(o.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:r.jsx(ze,{children:r.jsx(RP,{dataSource:e})})}),r.jsxs(o.Tabs,{defaultValue:"structure",styles:JP,children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"structure",icon:r.jsx(M.IconColumns,{size:14}),children:t("data_source.table_structure_short")}),r.jsx(o.Tabs.Tab,{value:"data",icon:r.jsx(M.IconDatabase,{size:14}),children:t("data.label")})]}),r.jsx(o.Tabs.Panel,{value:"structure",children:r.jsx(GP,{dataSource:e})}),r.jsx(o.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:r.jsx(XP,{dataSource:e})})]})]})}),HP={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"20px 20px 10px",borderBottom:"1px solid #efefef",gap:"20px"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},ig=D.observer(({dataSource:e,triggerButtonProps:t={}})=>{const{t:n}=_.useTranslation(),[s,i]=g.useState(!1);return e.type==="http"?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:s,onClose:()=>i(!1),title:r.jsxs(o.Group,{position:"apart",sx:{flexGrow:1},children:[r.jsx(o.Text,{fw:500,children:n("data_source.explorer")}),r.jsxs(o.Group,{spacing:7,children:[r.jsx(o.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),r.jsx(o.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",styles:HP,children:r.jsx(o.Box,{sx:{height:"calc(100vh - 220px)"},children:r.jsx(ZP,{dataSource:e})})}),r.jsx(o.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:n("data_source.see_table_structure")})]})}),e2=g.forwardRef(({label:e,type:t,...n},s)=>t===ye.Transform?r.jsxs(o.Group,{className:"transform-query-option",position:"left",ref:s,...n,sx:{'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}},children:[r.jsx(M.IconVectorTriangle,{size:14,color:"#228be6"}),r.jsx(o.Text,{color:"blue",children:e})]}):r.jsxs(o.Group,{position:"apart",ref:s,...n,children:[r.jsx(o.Text,{children:e}),r.jsx(o.Text,{children:t})]})),t2=D.observer(({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),s=Z(),{data:i=[],loading:a}=W.useRequest(Xi,{refreshDeps:[]},[]),l=g.useMemo(()=>{const p=i.map(h=>({label:h.key,value:h.key,type:h.type}));return p.push({label:n("query.transform.data_source"),value:ye.Transform,type:ye.Transform}),p},[i]),c=g.useMemo(()=>l.reduce((p,h)=>(p[h.value]=h.type,p),{}),[l]),u=p=>{p!==null&&t({key:p,type:c[p]})},d=g.useMemo(()=>s.datasources.find(e),[s,e]);return r.jsx(o.Select,{data:l,label:r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Box,{children:n("data_source.label")}),d&&r.jsx(ig,{dataSource:d,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:e2,rightSection:d?r.jsx(o.Text,{size:"xs",color:"dimmed",children:d.type}):void 0,rightSectionWidth:85,maxDropdownHeight:500,styles:{root:{flex:1},label:{display:"block"},rightSection:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:a,value:e.key,onChange:u})}),n2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),[n,s]=g.useState(e.name);return g.useEffect(()=>{s(e.name)},[e.name]),r.jsx(o.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:r.jsxs(o.Stack,{spacing:10,sx:{width:"100%"},children:[r.jsx(o.Divider,{mb:-10,variant:"dashed",label:t("query.basics"),labelPosition:"center"}),r.jsx(o.TextInput,{placeholder:t("query.name_description"),label:t("query.name"),required:!0,sx:{flex:1},value:n,onChange:i=>{s(i.currentTarget.value)},rightSection:r.jsx(o.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>e.setName(n),disabled:n===e.name,children:r.jsx(M.IconDeviceFloppy,{size:16})}),onBlur:()=>{e.setName(n)}}),r.jsx(t2,{value:{type:e.type,key:e.key},onChange:({type:i,key:a})=>{e.setKey(a),e.setType(i)}}),r.jsx(o.Divider,{mt:10,mb:-10,variant:"dashed",label:t("query.conditions"),labelPosition:"center"}),r.jsx(o.MultiSelect,{label:t("query.run_by_condition.label"),placeholder:t("query.run_by_condition.unset"),data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy,itemComponent:au,maxDropdownHeight:500}),e.typedAsHTTP&&r.jsx(o.MultiSelect,{label:t("query.re_run_condition.label"),placeholder:t("query.re_run_condition.label"),data:e.conditionOptions,value:[...e.react_to],onChange:e.setReactTo,itemComponent:au,maxDropdownHeight:500}),r.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(BP,{queryModel:e})]})})});function r2({content:e}){return r.jsxs(o.HoverCard,{width:"60vw",shadow:"md",children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.ActionIcon,{size:16,color:"blue",children:r.jsx(M.IconEye,{})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(an.Prism,{language:"sql",noCopy:!0,withLineNumbers:!0,children:e})})]})}const s2=D.observer(()=>{const t=[...Z().globalSQLSnippets.list];return t.length===0?null:r.jsxs(o.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fontSize:"sm",highlightOnHover:!0,children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Key"}),r.jsx("th",{children:"Value"})]})}),r.jsx("tbody",{children:t.map(n=>{const{id:s,content:i}=n;return r.jsxs("tr",{children:[r.jsx("td",{children:s}),r.jsx("td",{width:200,children:r.jsx(r2,{content:i})})]},s)})})]})}),i2=`
|
|
472
|
+
`,QA=()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"subtle",compact:!0,onClick:()=>n(s=>!s),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),r.jsx(o.Collapse,{in:t,children:r.jsx(an.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:RA})})]})},UA=D.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config;return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Checkbox,{checked:s.required,onChange:i=>s.setRequired(i.currentTarget.checked),label:n("filter.widget.select.required")}),r.jsx(ar,{filter:t})]}),r.jsx(o.TextInput,{label:n("filter.widget.common.min_width"),value:s.min_width,onChange:i=>s.setMinWidth(i.currentTarget.value),placeholder:"200px"}),r.jsx(o.Divider,{label:n("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),r.jsx(o.Checkbox,{checked:s.treeCheckStrictly,onChange:i=>s.setTreeCheckStrictly(i.currentTarget.checked),label:n("filter.widget.tree_select.strictly")}),r.jsx(o.NumberInput,{value:s.default_selection_count,onChange:s.setDefaultSelectionCount,label:n("filter.widget.common.default_selection_count")}),r.jsx(Il,{value:s.options_query_id,onChange:s.setOptionsQueryID}),r.jsx(QA,{})]})}),YA=D.observer(function({filter:t}){const{t:n}=_.useTranslation();return r.jsxs(o.Box,{sx:{maxWidth:"480px"},children:[r.jsx(o.Text,{pt:"0",pb:"md",color:"gray",children:n("common.titles.config")}),r.jsx(an.Prism,{mt:22,language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),KA={select:GA,"multi-select":FA,"tree-select":UA,"text-input":WA,checkbox:qA,"date-range":NA},En={select:"filter.widget.names.select","multi-select":"filter.widget.names.multi_select","tree-select":"filter.widget.names.tree_select","text-input":"filter.widget.names.text_input",checkbox:"filter.widget.names.checkbox","date-range":"filter.widget.names.date_range"},XA=D.observer(function({filter:t}){const{t:n,i18n:s}=_.useTranslation(),i=Y(),a=g.useMemo(()=>KA[t.type],[t.type]),l=g.useMemo(()=>[{label:n(En.select),value:"select"},{label:n(En["multi-select"]),value:"multi-select"},{label:n(En["tree-select"]),value:"tree-select"},{label:n(En["text-input"]),value:"text-input"},{label:n(En.checkbox),value:"checkbox"},{label:n(En["date-range"]),value:"date-range"}],[s.language]);return r.jsxs(o.Group,{grow:!0,spacing:20,align:"top",children:[r.jsxs(o.Box,{sx:{maxWidth:"600px"},children:[r.jsx(o.Text,{pb:"md",color:"gray",children:n("common.titles.edit")}),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{noWrap:!0,children:[r.jsx(o.NumberInput,{label:n("filter.field.order"),required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&r.jsx(o.Checkbox,{label:n("filter.field.auto_submit"),checked:t.auto_submit,onChange:c=>t.setAutoSubmit(c.currentTarget.checked),mt:22})]}),r.jsx(o.MultiSelect,{label:n("filter.field.visible_in"),data:i.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),r.jsx(o.TextInput,{label:n("common.key"),placeholder:n("filter.field.key_placeholder"),required:!0,value:t.key,onChange:c=>{t.setKey(c.currentTarget.value)}}),r.jsx(o.TextInput,{label:n("common.label"),placeholder:n("filter.field.label_placeholder"),required:!0,value:t.label,onChange:c=>{t.setLabel(c.currentTarget.value)}}),r.jsx(o.Select,{label:n("filter.field.widget"),data:l,required:!0,value:t.type,onChange:t.setType,maxDropdownHeight:500}),r.jsx(o.Divider,{mb:0,mt:10,variant:"dashed",labelPosition:"center"}),r.jsx(a,{filter:t})]})]}),r.jsx(YA,{filter:t})]})}),JA=D.observer(({id:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Z(),i=Y();if(e==="")return null;const a=i.filters.findByID(e);if(!a)return r.jsxs(o.Text,{size:14,children:["Filter by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_FILTERS_",""])},c=()=>{n.openConfirmModal({title:`${t("filter.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.filters.removeByID(e),l()},confirmProps:{color:"red"},zIndex:320})};return r.jsxs(o.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[r.jsx(o.Group,{position:"right",pt:10,children:r.jsx(o.Button,{size:"xs",color:"red",leftIcon:r.jsx(V.Trash,{size:16}),onClick:c,children:t("filter.delete")})}),r.jsx(o.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:r.jsx(XA,{filter:a})})]})}),ZA=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState([]),s=Z(),i=d=>{s.editor.setPath(["_FILTERS_",d])},a=()=>{s.content.filters.downloadSchema(t)},l=g.useMemo(()=>s.content.filters.sortedList.map(d=>d.id),[s.content.filters.sortedList]),c=()=>{n(l)},u=()=>{n([])};return r.jsxs(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[r.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:e("filter.manage")})}),r.jsx(o.Flex,{justify:"space-between",align:"center",px:12,children:r.jsxs(o.Group,{position:"left",children:[r.jsxs(o.Button.Group,{children:[r.jsx(o.Button,{variant:"default",size:"xs",onClick:c,children:e("common.actions.select_all")}),r.jsx(o.Button,{variant:"default",size:"xs",onClick:u,children:e("common.actions.clear_selection")})]}),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(M.IconCode,{size:14}),disabled:t.length===0,onClick:a,children:e("common.actions.download_schema")})]})}),r.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(o.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"40px"}}),r.jsx("th",{style:{width:"300px"},children:e("common.label")}),r.jsx("th",{children:e("common.key")}),r.jsx("th",{style:{width:"100px"},children:e("filter.field.widget")}),r.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx("tbody",{children:s.content.filters.sortedList.map(d=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx(o.Checkbox,{value:d.id,styles:{input:{cursor:"pointer"}}})}),r.jsx("td",{children:d.label}),r.jsx("td",{children:d.key}),r.jsx("td",{children:e(En[d.type])}),r.jsx("td",{children:r.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>i(d.id),children:e("common.actions.open")})})]},d.id))})]})})})]})}),HA=D.observer(()=>{const{t:e}=_.useTranslation(),t=Y(),[n,s]=g.useState(()=>JSON.stringify(t.mock_context.current,null,4)),i=()=>{try{t.mock_context.replace(JSON.parse(n))}catch(l){sn.showNotification({title:"Failed",message:l.message,color:"red"})}},a=g.useMemo(()=>{try{return JSON.stringify(JSON.parse(n))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[n,t.mock_context.current]);return r.jsxs(o.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[r.jsx(o.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:r.jsx(o.Text,{weight:500,children:e("mock_context.label")})}),r.jsxs(o.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[r.jsxs(o.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[r.jsx(o.Text,{children:e("mock_context.hint")}),r.jsx(o.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:n,onChange:s,sx:{flexGrow:1}})]}),r.jsx(o.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!a,onClick:i,children:r.jsx(V.DeviceFloppy,{size:20})})]})]})}),eP=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge();return r.jsx(ys,{label:e("panel.panel_description"),value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}})}),tP=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge(),n=_e().layouts.findItemByPanelID(t.id),{style:s}=t;return r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mb:-10,label:e("panel.style.label"),labelPosition:"center",variant:"dashed"}),r.jsxs(o.Stack,{spacing:20,children:[r.jsxs(o.Group,{grow:!0,align:"top",children:[r.jsx(o.NumberInput,{label:e("panel.style.width"),min:1,max:36,step:1,precision:0,rightSection:r.jsx(o.Text,{size:12,children:e("panel.style.width_postfix")}),styles:{rightSection:{width:"auto",maxWidth:"100px",paddingRight:"14px",justifyContent:"flex-end"}},value:n.w,onChange:i=>{i&&n.setWidth(i)}}),r.jsx(o.NumberInput,{label:e("panel.style.height"),rightSection:r.jsx(o.Text,{size:12,children:e("panel.style.height_postfix")}),styles:{rightSection:{width:"40px"}},value:n.h,onChange:i=>{i&&n.setHeight(i)}})]}),r.jsx(o.Checkbox,{ml:6,label:e("panel.style.border"),checked:s.border.enabled,onChange:i=>s.border.setEnabled(i.currentTarget.checked)})]})]})}),nP=()=>r.jsxs("span",{className:"mantine-103svbs mantine-InputWrapper-required mantine-Select-required","aria-hidden":"true",children:[" ","*"]}),rP=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge(),{name:n}=t,[s,i]=he.useInputState(n),a=n!==s,l=g.useCallback(()=>{a&&t.setName(s)},[a,s]);g.useEffect(()=>{i(n)},[n]);const c=!s.trim();return r.jsxs(o.Stack,{spacing:4,children:[r.jsxs(o.Group,{align:"center",children:[r.jsxs(o.Text,{size:14,fw:500,children:[e("panel.panel_name"),r.jsx(nP,{})]}),r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",disabled:!a||c,onClick:l,children:r.jsx(M.IconDeviceFloppy,{size:18})})]}),r.jsx(o.TextInput,{value:s,onChange:i,required:!0})]})}),sP=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge();return r.jsx(o.Stack,{spacing:6,mb:10,children:r.jsxs(o.Group,{pl:6,position:"left",spacing:20,children:[r.jsx(o.Checkbox,{size:"sm",checked:t.title.show,onChange:n=>t.title.setShow(n.currentTarget.checked),label:e("panel.show_title"),sx:{userSelect:"none"}}),r.jsx(o.Checkbox,{size:"sm",checked:!0,disabled:!0,label:e("panel.use_name_as_title")})]})})});function iP(){const{t:e}=_.useTranslation();return r.jsxs(o.Stack,{sx:{height:"100%"},children:[r.jsx(tP,{}),r.jsx(o.Divider,{label:e("common.info"),labelPosition:"center",variant:"dashed"}),r.jsx(rP,{}),r.jsx(sP,{}),r.jsx(eP,{})]})}const aP={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},"th, td":{wordBreak:"break-word"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function ng({data:e}){const t=g.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const s=bt.createColumnHelper();return Object.keys(e[0]).map(i=>s.accessor(i,{cell:a=>a.getValue()}))},[e]),n=bt.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:bt.getCoreRowModel()});return e.length===0?r.jsx(o.Box,{sx:{height:"5em"}}):r.jsx(ze,{children:r.jsxs(o.Table,{sx:aP,children:[r.jsx("thead",{children:n.getHeaderGroups().map(s=>r.jsx("tr",{children:s.headers.map(i=>r.jsxs("th",{style:{width:i.getSize()},children:[i.isPlaceholder?null:bt.flexRender(i.column.columnDef.header,i.getContext()),r.jsx(o.ActionIcon,{onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:r.jsx(V.ArrowBarToRight,{})})]},i.id))},s.id))}),r.jsx("tbody",{children:n.getRowModel().rows.map(s=>r.jsx("tr",{children:s.getVisibleCells().map(i=>r.jsx("td",{children:r.jsx(ze,{children:typeof i.getValue()=="object"?r.jsx("pre",{children:JSON.stringify(i.getValue(),null,2)}):bt.flexRender(i.column.columnDef.cell,i.getContext())})},i.id))},s.id))})]})})}const oP=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],lP={icon:{width:"80px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"80px"}}},cP=({data:e,page:t,setPage:n,limit:s,setLimit:i})=>{const{t:a}=_.useTranslation(),l=e.length,c=Math.ceil(l/s),u=p=>{n(1),i(Number(p))};if(l===0)return null;const d=c===1&&l<=10;return r.jsxs(o.Group,{pt:10,px:10,position:"apart",children:[r.jsxs(o.Group,{position:"left",children:[c>1&&r.jsx(o.Pagination,{size:"sm",value:t,onChange:n,total:c,withEdges:c>7,styles:{control:{height:"30px"}}}),!d&&r.jsx(o.Select,{icon:r.jsx(o.Text,{ta:"center",color:"dimmed",size:14,children:a("common.pagination.page_size")}),size:"xs",styles:lP,data:oP,value:String(s),onChange:u})]}),r.jsx(o.Group,{position:"right",children:r.jsx(o.Text,{color:"dimmed",my:0,size:14,children:a("common.pagination.total_rows",{total:l})})})]})},uP=My(({data:e,loading:t})=>{const[n,s]=g.useState(1),[i,a]=g.useState(20),l=g.useMemo(()=>{const c=(n-1)*i,u=c+i;return e.slice(c,u)},[e,n,i]);return r.jsxs(ze,{children:[r.jsx(cP,{data:e,page:n,setPage:s,limit:i,setLimit:a}),r.jsxs(o.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[r.jsx(o.LoadingOverlay,{visible:t,overlayBlur:2}),r.jsx(ng,{data:l})]})]})}),dP=({queryID:e})=>{const t=_e(),{state:n,error:s}=t.getDataStuffByID(e),i=g.useMemo(()=>t.queries.findByID(e),[t,e]);return n==="loading"?null:s?r.jsx(o.Text,{mt:10,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:s}):i!=null&&i.stateMessage?r.jsx(o.Text,{mt:10,color:"gray",align:"center",children:i.stateMessage}):null},El=D.observer(({id:e,moreActions:t,refreshOnMount:n})=>{const{t:s}=_.useTranslation(),i=_e(),{data:a,state:l}=i.getDataStuffByID(e),c=l==="loading",u=g.useCallback(()=>{i.queries.refetchDataByQueryID(e)},[e,i]),d=()=>{i.queries.downloadDataByQueryID(e)};g.useEffect(()=>{n&&u()},[u,n]);const p=!Array.isArray(a)||a.length===0;return r.jsxs(o.Stack,{spacing:0,sx:{height:"100%",border:"1px solid #eee"},children:[r.jsxs(o.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[r.jsx(o.Group,{position:"left",children:r.jsx(o.Text,{weight:500,children:s("data.preview_data")})}),r.jsxs(o.Group,{pr:15,children:[t,r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",disabled:c,onClick:u,children:r.jsx(V.Refresh,{size:16})}),r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",disabled:c||p,onClick:d,children:r.jsx(V.Download,{size:16})})]})]}),r.jsxs(o.Box,{pb:20,sx:{position:"relative",flexGrow:1,overflow:"auto"},children:[r.jsx(dP,{queryID:e}),r.jsx(uP,{data:a,loading:c})]})]})}),pP=D.observer(function(){const{t}=_.useTranslation(),n=Z(),s=Y(),{panel:i}=Ge(),[a,l]=g.useState(!1),c=d=>{n.editor.setPath(["_QUERIES_",d])},u=i.queryIDs.length;return r.jsxs(r.Fragment,{children:[r.jsx(o.Drawer,{opened:a,onClose:()=>l(!1),title:t("panel.settings.choose_queries"),padding:"xl",size:500,zIndex:320,children:r.jsx(o.Checkbox.Group,{value:[...i.queryIDs],onChange:i.setQueryIDs,children:r.jsx(o.Stack,{spacing:"lg",children:s.queries.options.map(d=>r.jsx(o.Checkbox,{label:d.label,value:d.value},d.value))})})}),r.jsxs(o.Stack,{spacing:6,children:[r.jsx(o.Group,{position:"left",children:r.jsx(o.Button,{variant:"light",size:"sm",leftIcon:r.jsx(M.IconLine,{size:16}),onClick:()=>l(!0),children:t(u===0?"panel.settings.need_to_choose_queries":"panel.settings.choose_queries")})}),u===1&&r.jsx(El,{id:i.queryIDs[0],moreActions:r.jsx(o.Tooltip,{label:t("query.open"),children:r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(i.queryIDs[0]),children:r.jsx(M.IconArrowCurveRight,{size:16})})})}),u>1&&r.jsxs(o.Tabs,{defaultValue:i.queryIDs[0],children:[r.jsx(o.Tabs.List,{children:i.queries.map(d=>r.jsx(o.Tabs.Tab,{value:d.id,children:d.name},d.id))}),i.queries.map(d=>r.jsx(o.Tabs.Panel,{value:d.id,children:r.jsx(El,{id:d.id,moreActions:r.jsx(o.Tooltip,{label:t("query.open"),children:r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(d.id),children:r.jsx(M.IconArrowCurveRight,{size:16})})})})},d.id))]})]})]})}),hP=D.observer(()=>{const{panel:e}=St();return r.jsx(ze,{children:r.jsx(o.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:r.jsxs(o.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:e.style.border.enabled?"1px":"0px"},children:[r.jsxs(o.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[r.jsx(o.Group,{children:r.jsx(jl,{})}),r.jsx(o.Group,{grow:!0,position:"center",children:r.jsx(o.Text,{lineClamp:1,weight:"bold",children:e.title.show?e.name:""})}),r.jsx(o.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),r.jsx(o.Group,{px:5,pb:5,sx:{flexGrow:1,".panel-viz-section":{height:"calc(100% - 28px)"}},children:r.jsx(wl,{panel:e})})]})})})}),Al={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{},fallback:"0"},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class fP{constructor(t){B(this,"panel");B(this,"selected");this.panel=t,t.variables.length>0&&(this.selected=t.variables[0]),X.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}get variableOptions(){return this.panel.variables.map(t=>({label:t.name,value:t.name,description:t.aggregation.type}))}addNew(){const t=this.panel.variables.filter(n=>n.name.startsWith(Al.name)).length;this.panel.addVariable(v.cloneDeep({...Al,name:`${Al.name}${t||""}`})),this.selected=v.last(this.panel.variables)}select(t){this.selected=t}selectByName(t){if(!t){console.warn("Unexpected null name when calling selectByName");return}const n=this.variables.find(s=>s.name===t);if(!n){console.error(`Variable by name[${t}] not found`);return}this.selected=n}remove(t){this.selected===t&&(this.selected=void 0);const n=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!v.isEmpty(this.panel.variables)){const s=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[s]}}}function gP(){const{panel:e}=Ge();return W.useCreation(()=>new fP(e),[e])}function mP({label:e,value:t,onChange:n},s){const[i,a]=g.useState(Array.isArray(t)?[...t]:[]),l=g.useCallback(()=>{a(f=>[...f,""])},[a]),c=g.useCallback(f=>{a(m=>(m.splice(f,1),[...m]))},[a]),u=g.useMemo(()=>!v.isEqual(i,t),[i,t]),d=()=>{n(i.map(f=>f.toString()))},p=o.useMantineTheme(),h=g.useMemo(()=>Object.entries(p.colors).map(([f,m])=>m[6]),[p]);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"left",ref:s,children:[r.jsx(o.Text,{children:e}),r.jsx(o.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:d,children:r.jsx(V.DeviceFloppy,{size:20})})]}),r.jsxs(o.Group,{children:[i.map((f,m)=>r.jsx(o.ColorInput,{value:f,onChange:y=>{a(j=>(j.splice(m,1,y),[...j]))},swatches:h,rightSection:r.jsx(o.ActionIcon,{onClick:()=>c(m),color:"red",children:r.jsx(V.Trash,{size:14})}),sx:{width:"45%"}})),r.jsx(o.ActionIcon,{onClick:l,color:"blue",variant:"outline",children:r.jsx(V.PlaylistAdd,{size:20})})]})]})}const xP=g.forwardRef(mP);function yP({label:e,value:t,onChange:n,type:s},i){const[a,l]=g.useState(Array.isArray(t)?[...t]:[]),c=g.useCallback(()=>{l(h=>[...h,""])},[l]),u=g.useCallback(h=>{l(f=>(f.splice(h,1),[...f]))},[l]),d=g.useMemo(()=>!v.isEqual(a.map(String),t.map(String)),[a,t]),p=()=>{n(a.map(h=>s==="number"?Number(h):h.toString()))};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"left",ref:i,children:[r.jsx(o.Text,{children:e}),r.jsx(o.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:p,children:r.jsx(V.DeviceFloppy,{size:20})})]}),r.jsxs(o.Group,{children:[a.map((h,f)=>r.jsx(o.TextInput,{type:s,value:h,onChange:m=>{const y=m.currentTarget.value;l(j=>(j.splice(f,1,y),[...j]))},rightSection:r.jsx(o.ActionIcon,{onClick:()=>u(f),color:"red",children:r.jsx(V.Trash,{size:14})}),sx:{width:"45%"}})),r.jsx(o.ActionIcon,{onClick:c,color:"blue",variant:"outline",children:r.jsx(V.PlaylistAdd,{size:20})})]})]})}const bP=g.forwardRef(yP),vP=g.forwardRef(function({value:t,onChange:n},s){const{t:i}=_.useTranslation(),a=t.color.type,l=(u,d)=>{const p=v.cloneDeep(t);v.set(p,u,d),n(p)},c=u=>{if(u==="static"){n({...t,color:{type:"static",staticColor:"#25262B"}});return}n({...t,color:{type:"continuous",colorRange:[],valueRange:[]}})};return r.jsxs(r.Fragment,{children:[r.jsx(o.Stack,{children:r.jsx(o.TextInput,{label:i("style.font_size.label"),placeholder:i("styles.font_size.placeholder"),sx:{flex:1},value:t.size,onChange:u=>l("size",u.currentTarget.value)})}),r.jsx(o.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:r.jsx(vh,{label:i("style.font_weight.label"),value:t.weight,onChange:u=>l("weight",u)})}),r.jsx(o.Divider,{mt:"lg",mb:0,variant:"dashed",label:i("style.label"),labelPosition:"center"}),r.jsxs(o.Stack,{children:[r.jsx(o.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:t.color.type,onChange:c}),a==="static"&&r.jsx(Be,{value:t.color.staticColor,onChange:u=>l("color.staticColor",u)}),a==="continuous"&&r.jsxs(r.Fragment,{children:[r.jsx(bP,{label:"Value Range",value:t.color.valueRange,type:"number",onChange:u=>l("color.valueRange",u)}),r.jsx(xP,{label:"Color Range",value:t.color.colorRange,onChange:u=>l("color.colorRange",u)})]})]})]})}),_P=g.forwardRef(function({value:t,onChange:n,withStyle:s=!0,remove:i},a){const{t:l}=_.useTranslation(),c=(u,d)=>{const p=v.cloneDeep(t);v.set(p,u,d),n(p)};return r.jsxs(o.Stack,{ref:a,children:[r.jsxs(o.Stack,{spacing:"xs",px:"sm",py:"md",sx:{border:"1px solid #e9ecef"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.TextInput,{label:l("common.name"),required:!0,value:t.name,onChange:u=>c("name",u.currentTarget.value)}),r.jsx(F,{label:l("common.data_field"),required:!0,value:t.data_field,onChange:u=>c("data_field",u)})]}),r.jsx(jo,{label:l("panel.variable.aggregation.label"),pt:0,value:t.aggregation,onChange:u=>c("aggregation",u),withFallback:!0}),t.aggregation.type!=="custom"&&r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mt:"xl",mb:0,label:l("numbro.format.label"),labelPosition:"center",variant:"dashed"}),r.jsx(gt,{value:t.formatter,onChange:u=>c("formatter",u)})]})]}),s&&r.jsx(o.Accordion,{variant:"contained",children:r.jsxs(o.Accordion.Item,{value:"Styles",children:[r.jsx(o.Accordion.Control,{icon:r.jsx(o.Text,{size:"xl",children:"🖼️"}),children:l("style.label")}),r.jsx(o.Accordion.Panel,{children:r.jsx(vP,{value:t,onChange:n})})]})}),r.jsx(o.Button,{mt:20,leftIcon:r.jsx(M.IconTrash,{size:16}),color:"red",variant:"light",onClick:i,children:l("panel.variable.delete")})]})}),jP=D.observer(e=>{const{t}=_.useTranslation(),n=W.useCreation(()=>xf(e.variable),[e.variable]),s=()=>e.uiModel.remove(e.variable);return r.jsxs(o.Stack,{"data-testid":"variable-editor",align:"stretch",children:[r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{variant:"subtle",size:"xs",disabled:!n.changed,color:"red",onClick:n.reset,leftIcon:r.jsx(M.IconRecycle,{size:18}),children:t("common.actions.revert_changes")}),r.jsx(o.Button,{variant:"filled",size:"xs",disabled:!n.changed,color:"green",onClick:n.commit,leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),children:t("common.actions.save_changes")})]}),r.jsx(_P,{value:x.getSnapshot(n.copy),onChange:n.update,remove:s})]})});D.observer(e=>{const{uiModel:t}=e;return r.jsx(o.Stack,{className:"var-list",children:t.variables.map(n=>r.jsx(o.Button,{variant:t.selected===n?"filled":"subtle",color:"gray",onClick:()=>t.select(n),children:n.name},n.name))})});const wP=D.observer(({model:e})=>{const{t}=_.useTranslation();return r.jsx(o.Overlay,{color:"#fff",opacity:1,sx:{position:"absolute"},children:r.jsx(o.Button,{variant:"light",size:"xs",leftIcon:r.jsx(M.IconPlus,{size:16}),onClick:e.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:t("panel.variable.add")})})}),CP=D.observer(()=>{var n;const{t:e}=_.useTranslation(),t=gP();return t.variableOptions.length===0?r.jsx(wP,{model:t}):r.jsxs(o.Stack,{pb:20,children:[r.jsxs(o.Group,{position:"left",children:[r.jsx(o.Select,{label:e("panel.variable.labels"),data:t.variableOptions,value:(n=t.selected)==null?void 0:n.name,onChange:t.selectByName,maxDropdownHeight:600,sx:{flexGrow:1}}),r.jsx(o.Button,{variant:"light",size:"xs",leftIcon:r.jsx(M.IconPlus,{size:16}),onClick:t.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:e("panel.variable.add")})]}),r.jsx(o.Divider,{variant:"dashed"}),t.selected?r.jsx(jP,{uiModel:t,variable:t.selected}):r.jsx("span",{children:"Select or create a new variable on right side"})]})}),SP=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge();return Object.keys(t.variableStrings).length===0?null:r.jsxs(o.Stack,{mt:22,spacing:4,children:[r.jsx(o.Text,{size:"sm",fw:500,color:"dimmed",children:e("panel.variable.labels")}),r.jsx(an.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t.variableStrings,null,4)})]})});function kP(){const{t:e}=_.useTranslation(),{vizManager:t}=g.useContext(Gt);return g.useMemo(()=>{const n=t.availableVizList.map(s=>({value:s.name,label:e(s.displayName??s.name),group:e(s.displayGroup??"")}));return v.orderBy(n,[s=>s.group,s=>s.label],["asc","asc"])},[t])}const TP=D.observer(({value:e,submit:t})=>{const{t:n}=_.useTranslation(),[s,i]=he.useInputState(e);g.useEffect(()=>{i(e)},[e]);const a=kP(),l=e!==s;return r.jsx(o.Select,{label:n("visualization.component"),value:s,searchable:!0,onChange:i,data:a,rightSection:r.jsx(o.ActionIcon,{variant:"filled",color:"green",disabled:!l,onClick:()=>t(s),children:r.jsx(V.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),rg=[];function DP(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function MP(){const{data:e,panel:{variables:t,viz:n,title:s,name:i,queryIDs:a,description:l,id:c}}=Ge(),{vizManager:u}=g.useContext(Gt),d={name:i,title:s,description:l,viz:n,queryIDs:a,id:c},p=bf(d);try{return u.resolveComponent(d.viz.type),r.jsx(si,{configure:p,children:r.jsx(eE,{variables:t,setVizConf:n.setConf,panel:d,vizManager:u,data:e})})}catch(h){return console.info(v.get(h,"message")),null}}const zP=D.observer(()=>{const{data:e,panel:{viz:t}}=Ge(),{vizManager:n}=g.useContext(Gt),s=g.useCallback(d=>{if(d===t.type)return;const p=DP(n,d);t.setType(d),t.setConf(p||{})},[t.type]),i=d=>{try{t.setConf(JSON.parse(d))}catch(p){console.error(p)}},a=g.useMemo(()=>{var d;return(d=rg.find(p=>p.value===t.type))==null?void 0:d.Panel},[t.type,rg]),l=MP(),c=a?g.createElement(a,{data:e,conf:t.conf,setConf:t.setConf}):null,u=l||c;return r.jsxs(o.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[r.jsx(TP,{submit:s,value:t.type}),r.jsxs(ze,{children:[r.jsx(o.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:u}),!u&&r.jsx(o.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:i})]})]})}),IP=D.observer(({panel:e,sourceViewID:t})=>{const{t:n}=_.useTranslation(),s=Y(),[i,a]=g.useState(t);g.useEffect(()=>{a(t)},[t]);const[l,{open:c,close:u}]=he.useDisclosure(!1),d=()=>{e.moveToView(t,i),u()};return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{size:"xs",variant:"subtle",color:"blue",onClick:c,leftIcon:r.jsx(M.IconBoxMultiple,{size:14}),children:n("panel.settings.change_view")}),r.jsx(o.Modal,{opened:l,onClose:u,title:n("panel.settings.change_view_title"),zIndex:320,children:r.jsxs(o.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[r.jsx(o.Radio.Group,{value:i,onChange:a,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:r.jsx(o.Stack,{spacing:"xs",children:s.views.options.map(p=>r.jsx(o.Radio,{value:p.value,label:p.label},p.value))})}),r.jsxs(o.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[r.jsx(o.Button,{size:"xs",color:"red",leftIcon:r.jsx(M.IconX,{size:14}),onClick:u,children:n("common.actions.cancel")}),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(M.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:n("common.actions.confirm")})]})]})})]})}),EP={root:{flexGrow:1,width:"100%",minWidth:"1200px",overflow:"hidden"},panel:{width:"100%",minWidth:"1200px",height:"calc(100% - 44px)",padding:10,overflow:"auto"}},Pl=({children:e})=>r.jsxs(o.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"100%",position:"relative"},children:[r.jsx(o.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),r.jsxs(o.Stack,{justify:"flex-start",sx:{alignSelf:"flex-start",width:"600px",flexGrow:0,flexShrink:0},children:[r.jsx(hP,{}),r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(SP,{})})]})]});function AP(e){return!["richText","button"].includes(e)}const PP=D.observer(({panel:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Z(),i=Y(),[a,l]=g.useState("Data"),c=e.queries,d=AP(e.viz.type)&&e.dataLoading,p=d||e.queryErrors.length>0||e.queryStateMessages!==""||c.length===0,h=s.editor.path[1];g.useEffect(()=>{l(y=>p&&y==="Visualization"?"Data":y)},[e.id,p]);const f=()=>{s.editor.setPath(["_VIEWS_",h])},m=()=>n.openConfirmModal({title:`${t("panel.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.removePanelByID(e.id,h),f()},confirmProps:{color:"red"},zIndex:320});return r.jsxs(ra,{value:{panel:e,data:e.data,loading:d,errors:e.queryErrors,downloadPanelScreenshot:()=>{}},children:[r.jsxs(o.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[r.jsx(o.Text,{pt:9,pb:8,children:e.name}),r.jsxs(o.Group,{position:"right",noWrap:!0,children:[r.jsx(IP,{panel:e,sourceViewID:h}),r.jsx(o.Button,{size:"xs",variant:"subtle",color:"red",onClick:m,leftIcon:r.jsx(M.IconTrash,{size:14}),children:t("panel.delete")})]})]}),r.jsxs(o.Tabs,{value:a,onTabChange:l,keepMounted:!1,styles:EP,children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Data",disabled:d,children:t("data.label")}),r.jsx(o.Tabs.Tab,{value:"Panel",children:t("panel.label")}),r.jsx(o.Tabs.Tab,{value:"Variables",disabled:p,children:r.jsx(o.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:r.jsx(o.Text,{children:t("panel.variable.labels")})})}),r.jsx(o.Tabs.Tab,{value:"Visualization",disabled:p,children:r.jsx(o.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:r.jsx(o.Text,{children:t("visualization.label")})})}),r.jsx(o.Tabs.Tab,{value:"Interactions",children:t("interactions.label")})]}),r.jsxs(o.Tabs.Panel,{value:"Data",children:[r.jsx(o.LoadingOverlay,{visible:d,exitTransitionDuration:0}),r.jsx(pP,{})]}),r.jsx(o.Tabs.Panel,{value:"Panel",children:r.jsx(Pl,{children:r.jsx(iP,{})})}),r.jsx(o.Tabs.Panel,{value:"Variables",children:r.jsx(Pl,{children:r.jsx(CP,{})})}),r.jsx(o.Tabs.Panel,{value:"Visualization",children:r.jsx(ze,{children:r.jsx(Pl,{children:r.jsx(zP,{})})})}),r.jsx(o.Tabs.Panel,{value:"Interactions",children:r.jsx(ze,{children:r.jsx(nv,{})})})]})]})}),OP=D.observer(({viewID:e,panelID:t})=>{const n=Y();if(!n.views.findByID(e))return r.jsxs(o.Text,{size:14,children:["View by ID[",e,"] is not found"]});const i=n.panels.findByID(t);return i?r.jsx(PP,{panel:i}):r.jsxs(o.Text,{size:14,children:["Panel by ID[",t,"] is not found"]})}),LP=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState([]),s=lt.useModals(),i=Z(),a=f=>{i.editor.setPath(["_QUERIES_",f])},l=()=>{s.openConfirmModal({title:"Delete ununsed queries?",children:r.jsx(o.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.removeUnusedQueries(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.queries.downloadSchema(t)},u=g.useMemo(()=>i.content.queries.sortedList.map(f=>f.id),[i.content.queries.sortedList]),d=()=>{n(u)},p=()=>{n([])},h=i.content.queriesUsage;return r.jsxs(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[r.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:e("query.manage")})}),r.jsxs(o.Flex,{justify:"space-between",align:"center",px:12,children:[r.jsxs(o.Group,{position:"left",children:[r.jsxs(o.Button.Group,{children:[r.jsx(o.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),r.jsx(o.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(M.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),r.jsx(o.Button,{variant:"subtle",size:"xs",color:"red",leftIcon:r.jsx(M.IconTrash,{size:14}),disabled:!i.content.hasUnusedQueries,onClick:l,children:e("query.delete_unused")})]}),r.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(o.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"40px"}}),r.jsx("th",{children:e("common.name")}),r.jsx("th",{style:{width:"200px"},children:e("data_source.label")}),r.jsx("th",{style:{width:"100px",textAlign:"right"},children:e("common.type")}),r.jsx("th",{style:{width:"100px",textAlign:"center"},children:e("query.usage.label")}),r.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx("tbody",{children:i.content.queries.sortedList.map(f=>{var y;const m=((y=h[f.id])==null?void 0:y.length)??0;return r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx(o.Checkbox,{value:f.id,styles:{input:{cursor:"pointer"}}})}),r.jsx("td",{children:f.name}),r.jsx("td",{children:f.key}),r.jsx("td",{style:{textAlign:"right"},children:f.type}),r.jsx("td",{style:{color:m===0?"#ff0000":"#000",fontWeight:m===0?"bold":"normal",textAlign:"center"},children:m}),r.jsx("td",{children:r.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>a(f.id),children:e("common.actions.open")})})]},f.id)})})]})})})]})}),BP=e=>{const{t}=_.useTranslation(),{queryModel:n}=e,s=Z(),i=Y(),l=i.findQueryUsage(n.id).length>0,c=lt.useModals(),u=()=>{c.openConfirmModal({title:`${t("query.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.queries.removeQuery(n.id),s.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return l?r.jsx(o.Tooltip,{label:t("query.cant_delete"),withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"top-end",children:r.jsx(o.Box,{sx:{alignSelf:"flex-end"},children:r.jsx(o.Button,{disabled:!0,size:"xs",leftIcon:r.jsx(M.IconTrash,{size:16}),children:t("query.delete")})})}):r.jsx(o.Button,{color:"red",size:"xs",onClick:u,leftIcon:r.jsx(M.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:t("query.delete")})},qP=D.observer(BP),sg=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:n,count:s,spacing:i=16,pl:a=0})=>r.jsxs(o.Stack,{spacing:i,mt:6,pl:a,children:[Array.from(new Array(s-1),(l,c)=>r.jsx(o.Skeleton,{width:e,height:n,radius:"xs"},c)),r.jsx(o.Skeleton,{width:t,height:n,radius:"xs"})]}),Qr=({value:e})=>e===null||e===""?null:r.jsx(o.Tooltip,{label:e,disabled:!e,multiline:!0,children:r.jsx(o.ActionIcon,{children:r.jsx(M.IconInfoCircle,{size:14})})}),VP=({column:e})=>{const{column_key:t,column_key_text:n}=e;return t?r.jsx(o.Tooltip,{label:n,disabled:!n,children:r.jsx(o.Badge,{children:t})}):null},NP=D.observer(({dataSource:e})=>{const{columns:t}=e;return t.loading?r.jsx(sg,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:r.jsxs(o.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{width:50}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:30}}),r.jsx("col",{style:{width:70}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{minWidth:80,width:80}}),r.jsx("col",{style:{minWidth:120,width:120}})]}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"#"}),r.jsx("th",{children:"Column Name"}),r.jsx("th",{}),r.jsx("th",{}),r.jsx("th",{children:"Type"}),r.jsx("th",{children:"Nullable"}),r.jsx("th",{children:"Default Value"})]})}),r.jsx("tbody",{children:t.data.map(n=>r.jsxs("tr",{children:[r.jsx("td",{children:n.ordinal_position}),r.jsx("td",{children:n.column_name}),r.jsx("td",{children:r.jsx(Qr,{value:n.column_comment})}),r.jsx("td",{children:r.jsx(VP,{column:n})}),r.jsx("td",{children:n.column_type}),r.jsx("td",{children:n.is_nullable}),r.jsx("td",{children:r.jsx(Qr,{value:n.column_default})})]},n.column_name))})]})}),$P=D.observer(({dataSource:e})=>{const{indexes:t}=e,n=t.data;return r.jsxs(o.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:250}})]}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Index Length"}),r.jsx("th",{children:"Index Name"}),r.jsx("th",{children:"Index Algorithm"}),r.jsx("th",{children:"Unique"}),r.jsx("th",{children:"Column Name"})]})}),r.jsx("tbody",{children:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.index_length}),r.jsx("td",{children:s.index_name}),r.jsx("td",{children:s.index_algorithm}),r.jsx("td",{children:s.is_unique?"YES":"NO"}),r.jsx("td",{children:s.column_name})]},s.index_name))})]})}),FP=D.observer(({dataSource:e})=>{const{indexes:t}=e,n=t.data;return r.jsxs(o.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}})]}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Index Name"}),r.jsx("th",{children:"Index Algorithm"}),r.jsx("th",{children:"Unique"}),r.jsx("th",{children:"Definition"}),r.jsx("th",{children:"Condition"}),r.jsx("th",{children:"Comment"})]})}),r.jsx("tbody",{children:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.index_name}),r.jsx("td",{children:s.index_algorithm}),r.jsx("td",{children:s.is_unique?"YES":"NO"}),r.jsx("td",{children:r.jsx(Qr,{value:s.index_definition})}),r.jsx("td",{children:r.jsx(Qr,{value:s.condition})}),r.jsx("td",{children:r.jsx(Qr,{value:s.comment})})]},s.index_name))})]})}),GP=D.observer(({dataSource:e})=>{const{indexes:t}=e;return t.loading||t.empty?null:e.type===ye.MySQL?r.jsx($P,{dataSource:e}):e.type===ye.Postgresql?r.jsx(FP,{dataSource:e}):null}),WP=D.observer(({dataSource:e})=>r.jsxs(o.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[r.jsx(ze,{children:r.jsx(NP,{dataSource:e})}),r.jsx(ze,{children:r.jsx(GP,{dataSource:e})})]}));function RP({table_type:e}){return e==="VIEW"?r.jsx(M.IconEye,{size:14}):e==="BASE TABLE"?r.jsx(M.IconTable,{size:14}):null}const QP=D.observer(({dataSource:e})=>{const{tables:t}=e;return t.loading?r.jsx(sg,{height:"24px",lastWidth:"50%",count:15}):r.jsx(o.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(t.data).map(([n,s])=>r.jsx(o.NavLink,{label:n,icon:r.jsx(M.IconDatabase,{size:14}),defaultOpened:e.table_schema===n,pl:0,childrenOffset:14,children:s.map(i=>r.jsx(o.NavLink,{label:i.table_name,icon:r.jsx(RP,{table_type:i.table_type}),onClick:()=>{e.setKeywords(n,i.table_name)},active:e.table_name===i.table_name},i.table_name))},n))})}),UP=({visible:e})=>r.jsx(o.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:r.jsx(o.LoadingOverlay,{visible:e})}),YP=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],KP={icon:{width:"50px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"50px"}}},XP=D.observer(({dataSource:e})=>{const{t}=_.useTranslation(),{tableData:n}=e;return r.jsxs(o.Group,{pt:10,px:10,position:"apart",children:[r.jsxs(o.Group,{position:"left",children:[n.maxPage>1&&r.jsx(o.Pagination,{size:"sm",value:n.page,onChange:n.setPage,total:n.maxPage,withEdges:n.maxPage>7,styles:{control:{height:"30px"}}}),r.jsx(o.Select,{icon:r.jsx(o.Text,{ta:"center",color:"dimmed",size:14,children:t("common.pagination.page_size")}),size:"xs",styles:KP,data:YP,value:String(n.limit),onChange:s=>n.setLimit(Number(s))})]}),r.jsx(o.Group,{position:"right",children:r.jsx(o.Text,{color:"dimmed",my:0,size:14,children:t("common.pagination.total_rows",{total:n.total})})})]})}),JP=D.observer(({dataSource:e})=>{const t=e.tableData;return t.maxPage===0?r.jsx(o.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):t.error?r.jsx(o.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:t.error}):t.page===1&&t.loading?r.jsx(UP,{visible:!0}):r.jsxs(ze,{children:[r.jsx(XP,{dataSource:e}),r.jsxs(o.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[r.jsx(o.LoadingOverlay,{visible:t.loading,overlayBlur:2}),r.jsx(ng,{data:t.data})]})]})}),ZP={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},HP=D.observer(({dataSource:e})=>{const{t}=_.useTranslation();return g.useEffect(()=>{e.loadTablesIfEmpty()},[e]),e.tables.error?r.jsx(o.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.tables.error}):r.jsxs(o.Flex,{sx:{height:"100%"},children:[r.jsx(o.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:r.jsx(ze,{children:r.jsx(QP,{dataSource:e})})}),r.jsxs(o.Tabs,{defaultValue:"structure",styles:ZP,children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"structure",icon:r.jsx(M.IconColumns,{size:14}),children:t("data_source.table_structure_short")}),r.jsx(o.Tabs.Tab,{value:"data",icon:r.jsx(M.IconDatabase,{size:14}),children:t("data.label")})]}),r.jsx(o.Tabs.Panel,{value:"structure",children:r.jsx(WP,{dataSource:e})}),r.jsx(o.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:r.jsx(JP,{dataSource:e})})]})]})}),e2={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"20px 20px 10px",borderBottom:"1px solid #efefef",gap:"20px"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},ig=D.observer(({dataSource:e,triggerButtonProps:t={}})=>{const{t:n}=_.useTranslation(),[s,i]=g.useState(!1);return e.type==="http"?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:s,onClose:()=>i(!1),title:r.jsxs(o.Group,{position:"apart",sx:{flexGrow:1},children:[r.jsx(o.Text,{fw:500,children:n("data_source.explorer")}),r.jsxs(o.Group,{spacing:7,children:[r.jsx(o.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),r.jsx(o.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",styles:e2,children:r.jsx(o.Box,{sx:{height:"calc(100vh - 220px)"},children:r.jsx(HP,{dataSource:e})})}),r.jsx(o.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:n("data_source.see_table_structure")})]})}),t2=g.forwardRef(({label:e,type:t,...n},s)=>t===ye.Transform?r.jsxs(o.Group,{className:"transform-query-option",position:"left",ref:s,...n,sx:{'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}},children:[r.jsx(M.IconVectorTriangle,{size:14,color:"#228be6"}),r.jsx(o.Text,{color:"blue",children:e})]}):r.jsxs(o.Group,{position:"apart",ref:s,...n,children:[r.jsx(o.Text,{children:e}),r.jsx(o.Text,{children:t})]})),n2=D.observer(({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),s=Z(),{data:i=[],loading:a}=W.useRequest(Xi,{refreshDeps:[]},[]),l=g.useMemo(()=>{const p=i.map(h=>({label:h.key,value:h.key,type:h.type}));return p.push({label:n("query.transform.data_source"),value:ye.Transform,type:ye.Transform}),p},[i]),c=g.useMemo(()=>l.reduce((p,h)=>(p[h.value]=h.type,p),{}),[l]),u=p=>{p!==null&&t({key:p,type:c[p]})},d=g.useMemo(()=>s.datasources.find(e),[s,e]);return r.jsx(o.Select,{data:l,label:r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Box,{children:n("data_source.label")}),d&&r.jsx(ig,{dataSource:d,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:t2,rightSection:d?r.jsx(o.Text,{size:"xs",color:"dimmed",children:d.type}):void 0,rightSectionWidth:85,maxDropdownHeight:500,styles:{root:{flex:1},label:{display:"block"},rightSection:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:a,value:e.key,onChange:u})}),r2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),[n,s]=g.useState(e.name);return g.useEffect(()=>{s(e.name)},[e.name]),r.jsx(o.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:r.jsxs(o.Stack,{spacing:10,sx:{width:"100%"},children:[r.jsx(o.Divider,{mb:-10,variant:"dashed",label:t("query.basics"),labelPosition:"center"}),r.jsx(o.TextInput,{placeholder:t("query.name_description"),label:t("query.name"),required:!0,sx:{flex:1},value:n,onChange:i=>{s(i.currentTarget.value)},rightSection:r.jsx(o.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>e.setName(n),disabled:n===e.name,children:r.jsx(M.IconDeviceFloppy,{size:16})}),onBlur:()=>{e.setName(n)}}),r.jsx(n2,{value:{type:e.type,key:e.key},onChange:({type:i,key:a})=>{e.setKey(a),e.setType(i)}}),r.jsx(o.Divider,{mt:10,mb:-10,variant:"dashed",label:t("query.conditions"),labelPosition:"center"}),r.jsx(o.MultiSelect,{label:t("query.run_by_condition.label"),placeholder:t("query.run_by_condition.unset"),data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy,itemComponent:au,maxDropdownHeight:500}),e.typedAsHTTP&&r.jsx(o.MultiSelect,{label:t("query.re_run_condition.label"),placeholder:t("query.re_run_condition.label"),data:e.conditionOptions,value:[...e.react_to],onChange:e.setReactTo,itemComponent:au,maxDropdownHeight:500}),r.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(qP,{queryModel:e})]})})});function s2({content:e}){return r.jsxs(o.HoverCard,{width:"60vw",shadow:"md",children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.ActionIcon,{size:16,color:"blue",children:r.jsx(M.IconEye,{})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(an.Prism,{language:"sql",noCopy:!0,withLineNumbers:!0,children:e})})]})}const i2=D.observer(()=>{const t=[...Z().globalSQLSnippets.list];return t.length===0?null:r.jsxs(o.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fontSize:"sm",highlightOnHover:!0,children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Key"}),r.jsx("th",{children:"Value"})]})}),r.jsx("tbody",{children:t.map(n=>{const{id:s,content:i}=n;return r.jsxs("tr",{children:[r.jsx("td",{children:s}),r.jsx("td",{width:200,children:r.jsx(s2,{content:i})})]},s)})})]})}),a2=`
|
|
473
473
|
-- You may reference query variables in SQL or VizConfig.
|
|
474
474
|
SELECT *
|
|
475
475
|
FROM commit
|
|
@@ -482,9 +482,9 @@ WHERE
|
|
|
482
482
|
AND \${sql_snippets.author_email_condition}
|
|
483
483
|
-- Global SQL snippets (shared between dashboards)
|
|
484
484
|
AND \${global_sql_snippets.account_condition}
|
|
485
|
-
`,ag=D.observer(function({showSQLSnippets:t=!0,sx:n={}}){const{t:s}=_.useTranslation(),i=Z(),a=Y(),l=i.context.current,c=(()=>{const u={context:{...a.mock_context.current,...l},filters:a.filters.previewValues};return t&&(u.sql_snippets=a.sqlSnippets.record),JSON.stringify(u,null,2)})();return r.jsx(o.Stack,{sx:{overflow:"hidden",...n},children:r.jsxs(o.Tabs,{defaultValue:"guide",keepMounted:!1,children:[r.jsxs(o.Tabs.List,{grow:!0,children:[r.jsx(o.Tabs.Tab,{value:"guide",icon:r.jsx(M.IconAlertCircle,{size:14}),children:s("query_variable.guide.tabs.guide")}),r.jsx(o.Tabs.Tab,{value:"local_query_vars",icon:r.jsx(M.IconVariable,{size:14}),children:s("query_variable.guide.tabs.variables_in_this_dashboard")}),r.jsx(o.Tabs.Tab,{value:"global_sql_snippets",icon:r.jsx(M.IconVariablePlus,{size:14}),children:s("query_variable.guide.tabs.global_sql_snippets")})]}),r.jsx(o.Tabs.Panel,{value:"guide",pt:"xs",children:r.jsx(an.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:
|
|
485
|
+
`,ag=D.observer(function({showSQLSnippets:t=!0,sx:n={}}){const{t:s}=_.useTranslation(),i=Z(),a=Y(),l=i.context.current,c=(()=>{const u={context:{...a.mock_context.current,...l},filters:a.filters.previewValues};return t&&(u.sql_snippets=a.sqlSnippets.record),JSON.stringify(u,null,2)})();return r.jsx(o.Stack,{sx:{overflow:"hidden",...n},children:r.jsxs(o.Tabs,{defaultValue:"guide",keepMounted:!1,children:[r.jsxs(o.Tabs.List,{grow:!0,children:[r.jsx(o.Tabs.Tab,{value:"guide",icon:r.jsx(M.IconAlertCircle,{size:14}),children:s("query_variable.guide.tabs.guide")}),r.jsx(o.Tabs.Tab,{value:"local_query_vars",icon:r.jsx(M.IconVariable,{size:14}),children:s("query_variable.guide.tabs.variables_in_this_dashboard")}),r.jsx(o.Tabs.Tab,{value:"global_sql_snippets",icon:r.jsx(M.IconVariablePlus,{size:14}),children:s("query_variable.guide.tabs.global_sql_snippets")})]}),r.jsx(o.Tabs.Panel,{value:"guide",pt:"xs",children:r.jsx(an.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:a2})}),r.jsx(o.Tabs.Panel,{value:"local_query_vars",pt:"xs",children:r.jsx(an.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:c})}),r.jsx(o.Tabs.Panel,{value:"global_sql_snippets",pt:"xs",children:r.jsxs(o.Stack,{spacing:10,children:[r.jsx(o.Alert,{icon:r.jsx(M.IconAlertCircle,{size:16}),title:s("global_sql_snippet.labels"),children:s("global_sql_snippet.description")}),r.jsx(i2,{})]})})]})})}),Ol=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:()=>n(!1),title:e("query_variable.labels"),zIndex:320,size:"800px",children:r.jsx(ag,{})}),r.jsx(o.Button,{variant:"subtle",onClick:()=>n(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},children:e("query_variable.open")})]})}),og={pre:["function build_request({ context, filters }, utils) {"," // build the quest"," return { method: 'POST', url: '/', params: {}, headers: {}, data: {} }","}"].join(`
|
|
486
486
|
`),post:["function process_result(resp, utils, state) {"," return resp.data","}"].join(`
|
|
487
|
-
`)},
|
|
487
|
+
`)},o2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation();return e.typedAsHTTP?r.jsxs(o.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"pre_process",children:t("query.build_request")}),r.jsx(o.Tabs.Tab,{value:"post_process",children:t("query.process_result")}),r.jsx(Ol,{})]}),r.jsx(o.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:r.jsx(Nn,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:og.pre})}),r.jsx(o.Tabs.Panel,{value:"post_process",p:"sm",children:r.jsx(Nn,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:og.post})})]}):null}),l2=D.observer(({queryID:e,usage:t})=>{const{t:n}=_.useTranslation(),s=Z().editor,i=l=>{if(l.type==="filter"){s.setPath(["_FILTERS_",l.id]);return}if(l.type==="panel"){const c=l.views[0].id;s.setPath(["_VIEWS_",c,"_PANELS_",l.id]);return}},a=l=>{s.setPath(["_VIEWS_",l])};return r.jsx(o.Stack,{py:"sm",px:"md",children:r.jsxs(o.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:100},children:n("common.type")}),r.jsx("th",{style:{width:"calc(50% - 50px)"},children:n("common.name")}),r.jsx("th",{children:n("query.usage.in_views")})]})}),r.jsx("tbody",{children:t.map(l=>r.jsxs("tr",{children:[r.jsx("td",{children:n(l.type_label)}),r.jsx("td",{children:r.jsx(o.Anchor,{component:"button",type:"button",onClick:()=>i(l),children:l.label})}),r.jsx("td",{children:r.jsxs(o.Stack,{align:"flex-start",justify:"flex-start",spacing:2,children:[l.views.map(c=>r.jsx(o.Anchor,{component:"button",type:"button",onClick:()=>a(c.id),children:r.jsx(o.Box,{children:c.label})},c.id)),l.views.length===0&&r.jsx(o.Box,{children:"--"})]})})]},l.id))})]})})}),c2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),n=g.useMemo(()=>v.groupBy(e.dependencies,"type"),[e.dependencies]),s=g.useMemo(()=>e.dependencies.some(a=>!a.valid),[e.dependencies]),i=e.dependencies.length>0;return i?r.jsxs(o.HoverCard,{withinPortal:!0,zIndex:340,shadow:"md",disabled:!i,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Button,{size:"xs",variant:"subtle",color:s?"red":"green",disabled:!i,leftIcon:s?r.jsx(M.IconAlertTriangle,{size:16}):r.jsx(M.IconDiscountCheckFilled,{size:16}),children:t("query.dependency.label")})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(o.List,{spacing:"md",size:14,listStyleType:"none",children:Object.entries(n).map(([a,l])=>r.jsxs(o.List.Item,{children:[r.jsx(o.Text,{fw:"bold",ff:"monospace",children:t(`${a}.label`)}),r.jsx(o.List,{withPadding:!0,size:14,sx:{fontFamily:"monospace",svg:{verticalAlign:"middle"}},children:l.map(c=>r.jsx(o.List.Item,{icon:r.jsx(o.Box,{sx:{path:{fill:c.valid?"rgb(18, 184, 134)":"rgb(250, 82, 82)"}},children:r.jsx(M.IconPointFilled,{size:12})}),children:c.key},c.key))})]},a))})})]}):r.jsx(o.Tooltip,{label:t("query.dependency.has_none"),children:r.jsx(o.Button,{size:"xs",variant:"subtle",color:"gray",leftIcon:r.jsx(M.IconHierarchy,{size:16,style:{transform:"rotate(180deg)"}}),sx:{transform:"none !important"},children:t("query.dependency.label")})})}),u2="SELECT 1",d2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),[n,s]=g.useState(e.sql),i=()=>{e.setSQL(n)},a=()=>{s(e.sql)},l=()=>{s(u2)};g.useEffect(()=>{s(e.sql)},[e.sql]);const c=n!==e.sql;return r.jsxs(o.Stack,{spacing:4,sx:{height:"100%"},children:[r.jsxs(o.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[r.jsx(o.Group,{position:"left",children:r.jsx(c2,{queryModel:e})}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:l,size:"xs",variant:"default",leftIcon:r.jsx(M.IconPlayerSkipBack,{size:16}),children:t("common.actions.reset_to_default")}),r.jsx(o.Button,{onClick:a,color:"red",size:"xs",disabled:!c,leftIcon:r.jsx(M.IconRecycle,{size:16}),children:t("common.actions.revert_changes")}),r.jsx(o.Button,{color:"green",size:"xs",onClick:i,disabled:!c,leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),children:t("common.actions.save_changes")})]})]}),r.jsx(Qi,{height:"100%",value:n,onChange:s,theme:"sql-dark",defaultLanguage:"sql"})]})}),p2=({value:e,height:t="200px",defaultLanguage:n="sql"})=>r.jsx(et,{className:"preview-sql-in-monaco-editor",height:t,defaultLanguage:n,value:e,onChange:void 0,theme:"vs-light",options:{lineNumbers:"on",folding:!0,lineDecorationsWidth:20,wordWrap:"on",minimap:{enabled:!1},readOnly:!0}}),h2=D.observer(({value:e})=>{const n=_e().payloadForSQL,s=g.useMemo(()=>Ci(e,n),[e,n]);return r.jsx(p2,{height:"100%",value:s})}),lg={pre:["function process_request({ context, filters, sql }, utils) {"," // modify and return sql"," return sql","}"].join(`
|
|
488
488
|
`),post:["function process_result(data, utils, state) {"," // process data and return the result"," return data","}"].join(`
|
|
489
|
-
`)},
|
|
490
|
-
`),post:""},g2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),n=Y();return e.isTransform?r.jsxs(o.Stack,{py:20,px:20,sx:{height:"100%"},children:[r.jsx(o.Text,{size:"sm",children:t("query.transform.guide.pick_queries")}),r.jsx(o.MultiSelect,{data:n.queries.optionsWithoutTransform,value:[...e.dep_query_ids],onChange:e.setDependantQueryIDs,maxDropdownHeight:800}),r.jsx(o.Text,{size:"sm",children:t("query.transform.guide.write_function")}),r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(Nn,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:f2.pre})})]}):null}),Ur={height:"calc(100% - 44px)",padding:0},m2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),n=Y(),s=g.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),[i,a]=g.useState(s);g.useEffect(()=>{a(u=>u!=="Configurations"&&s==="Configurations"?"Configurations":u)},[s]);const l=n.findQueryUsage(e.id),c=l.length===0;return r.jsxs(o.Tabs,{value:i,onTabChange:a,defaultValue:s,orientation:"horizontal",keepMounted:!1,sx:{height:"100vh"},children:[r.jsxs(o.Tabs.List,{grow:!0,children:[r.jsx(o.Tabs.Tab,{value:"Configurations",children:t("query.configurations")}),e.typedAsSQL&&r.jsx(o.Tabs.Tab,{value:"SQL",children:t("query.request")}),e.typedAsHTTP&&r.jsx(o.Tabs.Tab,{value:"HTTP",children:t("query.request")}),e.isTransform&&r.jsx(o.Tabs.Tab,{value:"Transform",children:t("query.transform.label")}),r.jsx(o.Tabs.Tab,{value:"Data",disabled:!e.canPreviewData,children:r.jsx(o.Tooltip,{label:e.guideToPreviewData,disabled:e.canPreviewData,withinPortal:!0,children:r.jsx(o.Text,{children:t("data.preview_data")})})}),r.jsx(o.Tabs.Tab,{value:"Usage",disabled:c,children:r.jsx(o.Tooltip,{label:t("query.usage.unused_description"),disabled:!c,withinPortal:!0,children:r.jsx(o.Text,{children:t("query.usage.label")})})})]}),r.jsx(o.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:r.jsx(n2,{queryModel:e})}),e.typedAsSQL&&r.jsx(o.Tabs.Panel,{value:"SQL",sx:Ur,children:r.jsx(o.Stack,{sx:{height:"100%"},children:r.jsx(h2,{queryModel:e})})}),e.typedAsHTTP&&r.jsx(o.Tabs.Panel,{value:"HTTP",sx:Ur,children:r.jsx(o.Stack,{sx:{height:"100%"},children:r.jsx(a2,{queryModel:e})})}),e.isTransform&&r.jsx(o.Tabs.Panel,{value:"Transform",sx:Ur,children:r.jsx(o.Stack,{sx:{height:"100%"},children:r.jsx(g2,{queryModel:e})})}),r.jsx(o.Tabs.Panel,{value:"Data",sx:{...Ur,overflow:"hidden"},children:r.jsx(El,{id:e.id,moreActions:null,refreshOnMount:!0})}),r.jsx(o.Tabs.Panel,{value:"Usage",sx:{...Ur,overflow:"hidden"},children:r.jsx(o2,{queryID:e.id,usage:l})})]})}),x2=D.observer(({id:e})=>{const n=Y().queries.findByID(e);return e===""?null:n?r.jsx(m2,{queryModel:n}):r.jsx(o.Text,{size:14,color:"red",children:"Invalid Query ID"})}),y2=D.observer(({value:e})=>{const n=_e().payloadForSQL,s=g.useMemo(()=>Ci(e,n),[e,n]);return r.jsx(Qi,{height:"100%",value:s})}),b2=D.observer(({item:e,remove:t,onKeyChanged:n})=>{const{t:s}=_.useTranslation(),[i,a]=g.useState("SQL"),[l,c]=g.useState(e.key),u=()=>{e.setKey(l),n(l)},d=l!==e.key,p=e.isADuplicatedKey(l),[h,f]=g.useState(e.value),m=()=>{e.setValue(h)};g.useEffect(()=>{c(e.key),f(e.value)},[e]);const y=h!==e.value,j=lt.useModals(),k=()=>{j.openConfirmModal({title:`${s("sql_snippet.delete")}?`,labels:{confirm:s("common.actions.confirm"),cancel:s("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:t,confirmProps:{color:"red"},zIndex:320})};return r.jsxs(o.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[r.jsxs(o.Group,{sx:{alignItems:"end"},spacing:40,children:[r.jsx(o.TextInput,{label:s(p?"sql_snippet.key_occupied":"sql_snippet.key"),value:l,onChange:S=>{c(S.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:r.jsx(o.ActionIcon,{color:"blue",variant:"subtle",onClick:u,disabled:!d||p,children:r.jsx(V.DeviceFloppy,{size:16})}),error:p}),r.jsx(o.Button,{leftIcon:r.jsx(V.Trash,{size:16}),color:"red",variant:"light",onClick:k,children:s("sql_snippet.delete")})]}),r.jsxs(o.Tabs,{value:i,onTabChange:a,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[r.jsxs(o.Tabs.List,{sx:{position:"relative"},children:[r.jsx(o.Tabs.Tab,{value:"SQL",children:s("sql_snippet.edit_snippet")}),r.jsx(o.Tabs.Tab,{value:"Preview",children:s("sql_snippet.preview_snippet")}),r.jsx(Ol,{}),r.jsx(o.ActionIcon,{color:"blue",variant:"filled",onClick:m,disabled:!y,sx:{position:"absolute",top:0,right:10},children:r.jsx(V.DeviceFloppy,{size:18})})]}),r.jsx(o.Tabs.Panel,{value:"SQL",pt:"sm",children:r.jsx(Qi,{height:"100%",value:h,onChange:f,defaultLanguage:"sql",theme:"sql-dark"})}),r.jsx(o.Tabs.Panel,{value:"Preview",pt:"sm",children:r.jsx(y2,{value:h})})]})]})}),v2=D.observer(({id:e})=>{const t=Z(),n=Y(),s=g.useMemo(()=>n.sqlSnippets.findByKey(e),[e]);if(!e)return null;if(!s)return r.jsxs(o.Text,{size:14,children:["SQL Snippet by key[",e,"] is not found"]});const i=()=>{t.editor.setPath(["_SQL_SNIPPETS_",""])},a=()=>{n.sqlSnippets.removeByKey(e),i()},l=c=>{t.editor.setPath(["_SQL_SNIPPETS_",c])};return r.jsx(b2,{item:s,remove:a,onKeyChanged:l})}),_2=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState([]),s=lt.useModals(),i=Z(),a=f=>{i.editor.setPath(["_SQL_SNIPPETS_",f])},l=()=>{s.openConfirmModal({title:"Delete ununsed SQL snippets?",children:r.jsx(o.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.removeUnusedSQLSnippets(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.sqlSnippets.downloadSchema(t)},u=g.useMemo(()=>i.content.sqlSnippets.sortedList.map(f=>f.key),[i.content.sqlSnippets.sortedList]),d=()=>{n(u)},p=()=>{n([])},h=i.content.sqlSnippetsUsage;return r.jsxs(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[r.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:e("sql_snippet.manage")})}),r.jsxs(o.Flex,{justify:"space-between",align:"center",px:12,children:[r.jsxs(o.Group,{position:"left",children:[r.jsxs(o.Button.Group,{children:[r.jsx(o.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),r.jsx(o.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(M.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),r.jsx(o.Button,{variant:"subtle",size:"xs",color:"red",leftIcon:r.jsx(M.IconTrash,{size:14}),disabled:!i.content.hasUnusedSQLSnippets,onClick:l,children:e("sql_snippet.delete_unused")})]}),r.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(o.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"40px"}}),r.jsx("th",{children:e("common.key")}),r.jsx("th",{style:{width:"100px",textAlign:"center"},children:e("sql_snippet.usage.label")}),r.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx("tbody",{children:i.content.sqlSnippets.sortedList.map(f=>{var y;const m=((y=h[f.key])==null?void 0:y.length)??0;return r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx(o.Checkbox,{value:f.key,styles:{input:{cursor:"pointer"}}})}),r.jsx("td",{children:f.key}),r.jsx("td",{style:{color:m===0?"#ff0000":"#000",fontWeight:m===0?"bold":"normal",textAlign:"center"},children:m}),r.jsx("td",{children:r.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>a(f.key),children:e("common.actions.open")})})]},f.key)})})]})})})]})}),j2=D.observer(({view:e})=>!e||e.type!==q.Division?null:r.jsx(o.Stack,{})),w2=D.observer(({view:e})=>{const{t,i18n:n}=_.useTranslation(),s=g.useMemo(()=>[{value:"default",label:t("common.tabs.variant.default")},{value:"outline",label:t("common.tabs.variant.outline")},{value:"pills",label:t("common.tabs.variant.pills")}],[n.language]),i=g.useMemo(()=>[{value:"horizontal",label:t("common.tabs.orientation.horizontal")},{value:"vertical",label:t("common.tabs.orientation.vertical")}],[n.language]);if(!e||e.type!==q.Tabs)return null;const a=e.config;return r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mt:8,mb:0,label:t("view.component.tabs.tabs_settings"),labelPosition:"center"}),r.jsx(o.Select,{label:t("common.tabs.variant.label"),value:a.variant,onChange:a.setVariant,data:s}),r.jsx(o.Select,{label:t("common.tabs.orientation.label"),value:a.orientation,onChange:a.setOrientation,data:i}),r.jsx(o.Switch,{label:t("common.tabs.grow_tabs"),checked:a.grow,onChange:l=>a.setGrow(l.currentTarget.checked)})]})}),C2=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(o.Box,{sx:{position:"relative"},children:[e&&r.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},S2=({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),[s,{setTrue:i,setFalse:a}]=W.useBoolean(),[l,c]=g.useState(e??ai),u=m=>{c({...l,enabled:m})},d=()=>{a();const{enabled:m,func_content:y}=l,j={enabled:m,func_content:y};c(j),t(j)},p=()=>{a(),c(e)},h=m=>{c(y=>({...y,func_content:m}))},f=()=>{h(ai.func_content)};return r.jsxs(r.Fragment,{children:[r.jsx(o.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:i,sx:{flexGrow:0},children:r.jsx(V.Settings,{size:14})}),r.jsx(o.Modal,{size:800,title:n("view.component.modal.custom_title"),opened:s,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&r.jsxs(o.Stack,{children:[r.jsx(o.Checkbox,{mt:10,label:n("common.enabled"),checked:l.enabled,onChange:m=>u(m.currentTarget.checked)}),r.jsx(C2,{value:l.func_content,onChange:h,disabled:!l.enabled}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:f,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:n("common.actions.revert")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:p,variant:"subtle",children:n("common.actions.cancel")}),r.jsx(o.Button,{onClick:d,children:n("common.actions.save")})]})]})]})})]})},k2=D.observer(({view:e})=>{const{t}=_.useTranslation();if(!e||e.type!==q.Modal)return null;const n=e.config,s=n.custom_modal_title.value;return r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mt:8,label:t("view.component.modal.modal_settings"),labelPosition:"center"}),r.jsxs(o.Flex,{gap:10,children:[r.jsx(o.TextInput,{label:t("view.component.modal.title"),value:s,onChange:v.noop,disabled:!0,sx:{flexGrow:1}}),r.jsx(S2,{value:n.custom_modal_title,onChange:n.custom_modal_title.replace})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(o.TextInput,{label:t("view.component.modal.width"),value:n.width,onChange:i=>n.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),r.jsx(o.TextInput,{label:t("view.component.modal.height"),value:n.height,onChange:i=>n.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),T2=D.observer(({view:e})=>r.jsxs(r.Fragment,{children:[r.jsx(j2,{view:e}),r.jsx(k2,{view:e}),r.jsx(w2,{view:e})]})),D2=D.observer(({view:e})=>{const{t,i18n:n}=_.useTranslation(),s=g.useMemo(()=>[{label:t("view.component.div.label"),value:q.Division},{label:t("view.component.modal.label"),value:q.Modal},{label:t("view.component.tabs.label"),value:q.Tabs}],[n.language]);return e?r.jsxs(o.Stack,{sx:{position:"relative"},children:[r.jsx(o.TextInput,{label:t("common.name"),value:e.name,onChange:i=>{e.setName(i.currentTarget.value)}}),r.jsx(o.Select,{label:t("common.type"),withinPortal:!0,zIndex:320,value:e.type,onChange:e.setType,data:s}),r.jsx(T2,{view:e})]}):null}),M2=D.observer(({id:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Z(),i=Y();if(e==="")return null;const a=i.views.findByID(e);if(!a)return r.jsxs(o.Text,{size:14,children:["View by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_VIEWS_",""])},c=()=>{n.openConfirmModal({title:`${t("view.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.views.removeByID(e),l()},zIndex:320})};return r.jsxs(o.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[r.jsx(o.Group,{position:"right",pt:10,children:r.jsx(o.Button,{size:"xs",color:"red",leftIcon:r.jsx(V.Trash,{size:16}),onClick:c,children:t("view.delete")})}),r.jsx(o.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:r.jsx(D2,{view:a})})]})});function z2(e){return e.length===1&&e[0]==="_QUERY_VARS_"}function I2(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function E2(e){return e.length===1&&e[0]==="_FILTERS_"}function A2(e){return e.length===2&&e[0]==="_FILTERS_"}function P2(e){return e.length===1&&e[0]==="_SQL_SNIPPETS_"}function O2(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function L2(e){return e.length===2&&e[0]==="_QUERIES_"}function B2(e){return e.length===1&&e[0]==="_QUERIES_"}function q2(e){return e.length===2&&e[0]==="_VIEWS_"}function V2(e){return e.length===4&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}const N2=D.observer(()=>r.jsx(o.Stack,{sx:{height:"100%"},p:"sm",children:r.jsx(ag,{})})),$2=D.observer(()=>{const e=Z().editor,t=e.path;return z2(t)?r.jsx(N2,{}):I2(t)?r.jsx(ZA,{}):E2(t)?r.jsx(JA,{}):A2(t)?r.jsx(o.Box,{p:"xs",pl:20,children:r.jsx(XA,{id:t[1]})}):P2(t)?r.jsx(_2,{}):O2(t)?r.jsx(v2,{id:t[1]}):B2(t)?r.jsx(OP,{}):L2(t)?r.jsx(x2,{id:t[1]}):q2(t)?r.jsx(o.Box,{p:"xs",pl:20,children:r.jsx(M2,{id:t[1]})}):V2(t)?r.jsx(PP,{viewID:t[1],panelID:t[3]}):r.jsx(o.Box,{children:e.path})}),F2=D.observer(()=>r.jsx($2,{})),G2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=()=>{const s=new Date().getTime().toString(),i={id:s,key:s,label:s,order:t.content.filters.current.length+1,type:ce.TextInput,config:rl(),visibleInViewsIDs:["Main"],auto_submit:!1};t.content.filters.append(i),t.editor.setPath(["_FILTERS_",s])};return r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("filter.add")})}),W2=D.observer(({parentID:e})=>{const{t}=_.useTranslation(),n=Y();if(!e)return null;const s=n.views.findByID(e);return!s||s.type===q.Tabs?null:r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>n.addANewPanel(s.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("panel.add")})}),R2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=()=>{const s=new Date().getTime().toString(),i={id:s,name:s,type:ye.Postgresql,key:"",sql:""};t.content.queries.append(i),t.editor.setPath(["_QUERIES_",s])};return r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("query.add")})}),Q2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=()=>{const s=new Date().getTime().toString(),i={key:s,value:""};t.content.sqlSnippets.append(i),t.editor.setPath(["_SQL_SNIPPETS_",s])};return r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("sql_snippet.add")})}),U2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Y();return r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("view.add")})}),Y2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z();return r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_QUERIES_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("query.manage")})}),K2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z();return r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_SQL_SNIPPETS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("sql_snippet.manage")})}),X2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z();return r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_FILTERS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("filter.manage")})}),J2=D.observer(({action_type:e,parentID:t})=>e==="_Add_A_Filter_"?r.jsx(G2,{}):e==="_Add_A_SQL_SNIPPET_"?r.jsx(Q2,{}):e==="_Add_A_QUERY_"?r.jsx(R2,{}):e==="_Add_A_VIEW_"?r.jsx(U2,{}):e==="_Add_A_PANEL_"?r.jsx(W2,{parentID:t}):e==="_QUERIES_SETTINGS_"?r.jsx(Y2,{}):e==="_SQL_SNIPPETS_SETTINGS_"?r.jsx(K2,{}):e==="_FILTERS_SETTINGS_"?r.jsx(X2,{}):null),cg=D.observer(({option:e})=>{var p;const{t}=_.useTranslation(),n=Z().editor,s=n.isOptionActive,i=s(n.path,e),a=n.isOptionOpened,l=n.navigate,c=a(e),[u,d]=g.useState(c);return g.useEffect(()=>{d(c)},[c]),r.jsx(o.NavLink,{active:i,defaultOpened:c,opened:u,onChange:d,label:t(e.label),onClick:()=>l(e),icon:e.Icon?r.jsx(e.Icon,{size:18}):null,children:(p=e.children)==null?void 0:p.map(h=>h._type==="ACTION"?r.jsx(J2,{action_type:h._action_type,parentID:h.parentID},`_ADD_${h.value}_`):r.jsx(cg,{option:h},h.value))},e.label)}),Z2=D.observer(()=>{const e=Z();return r.jsx(o.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>r.jsx(cg,{option:t},t.value))})}),H2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z();return r.jsxs(o.Navbar,{p:0,width:{base:220,xs:220,sm:240,md:260,lg:300,xl:320},sx:{height:"100vh - 60px - 60px",".mantine-NavLink-body":{wordWrap:"break-word"}},children:[r.jsx(o.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:e("common.titles.settings")})}),r.jsx(o.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:r.jsx(Z2,{})}),r.jsx(o.Navbar.Section,{children:r.jsx(o.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:r.jsx(o.Button,{size:"xs",color:"red",leftIcon:r.jsx(M.IconX,{size:18}),onClick:()=>t.editor.close(),children:e("common.actions.close")})})})]})}),eO={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"calc(var(--mantine-navbar-width, 0px) + 1200px)"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},tO=D.observer(()=>{const e=Z().editor;return r.jsx(o.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionProps:{duration:0},withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{body:{padding:"0 !important"},content:{overflowY:"hidden !important"}},children:r.jsx(o.AppShell,{padding:0,navbar:r.jsx(H2,{}),styles:eO,children:r.jsx(F2,{})})})}),nO=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function rO(e){g.useEffect(()=>{if(et.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const n=nO(e);et.loader.config({paths:{vs:n}}),et.loader.init().then(s=>console.log("monaco instance:",s))},[])}uu(),du();const sO={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},iO=({context:e,dashboard:t,content:n,update:s,className:i="dashboard",config:a,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h},f)=>{rO(a.monacoPath),Si(a);const{data:m=[]}=W.useRequest(Xi),{data:y=[]}=W.useRequest(hu),j=g.useMemo(()=>Gf(t,n,m,y,e,u??{}),[t,n]);g.useImperativeHandle(f,()=>j,[j]),Rf(j.content,!0),g.useEffect(()=>{j.context.replace(e)},[e]),g.useEffect(()=>{j.datasources.replace(m)},[m]),g.useEffect(()=>{j.globalSQLSnippets.replace(y)},[y]),g.useEffect(()=>{d==null||d(j.content.filters.values)},[d,j.content.filters.values]),g.useEffect(()=>{u&&j.content.filters.patchValues(u)},[u,j.content.filters.patchValues]),g.useEffect(()=>X.reaction(()=>X.toJS(j.json),z=>{l==null||l(z)}),[j]);const k=async()=>{await s(j.json,j.content.json)},S=W.useCreation(Ro,[]),T=Qf(S);return W.useWhyDidYouUpdate("@devtable/dashboard editor",{context:e,dashboard:t,content:n,update:s,className:i,config:a,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h}),r.jsx(Wf,{lang:h,children:r.jsx(lt.ModalsProvider,{children:r.jsx(ia,{children:r.jsx(ta,{value:{searchButtonProps:a.searchButtonProps},children:r.jsx(Hi,{value:j,children:r.jsx(na,{value:j.content,children:r.jsx(js.Provider,{value:{inEditMode:!0},children:r.jsx(Gt.Provider,{value:S,children:r.jsxs(si,{configure:T,children:[r.jsx(o.AppShell,{padding:0,header:r.jsx(oA,{onExit:p,saveDashboardChanges:k,headerSlot:c}),navbar:r.jsx(PA,{}),styles:sO,children:r.jsx(o.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:j.content.views.visibleViews.map(z=>r.jsx(If,{view:z},z.id))})}),r.jsx(tO,{})]})})})})})})})})})},aO=D.observer(g.forwardRef(iO)),RL="",Ll=x.types.model({id:x.types.string,name:x.types.string,dashboard_id:x.types.string,create_time:x.types.string,update_time:x.types.string,version:x.types.string,filters:ml,queries:bl,sqlSnippets:_l,views:hl,panels:gl,layouts:vl,mock_context:Ko}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get payloadForSQL(){const t=x.getParent(e).context.current,n=x.getParent(e).globalSQLSnippets,s={context:{...e.mock_context.current,...t},filters:e.filters.values};return{...s,sql_snippets:Rr(e.sqlSnippets.current,"key","value",s),global_sql_snippets:Rr(n.list,"id","content",s)}},get payloadForViz(){const t=x.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.values}},get dashboardState(){return Ki(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardState}},get data(){return e.queries.current.map(({id:n,data:s})=>({id:n,data:s})).reduce((n,s)=>(n[s.id]=s.data,n),{})},getDataStuffByID(t){const n=e.queries.findByID(t);return n?{data:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).actions(e=>({}));function ug({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,content:a},l,c,u){if(!a)throw new Error("unexpected null content when creating a content model");const{version:d,filters:p,views:h,panels:f,layouts:m,definition:{queries:y,sqlSnippets:j,mock_context:k={}}}=a;return Ll.create({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,version:d,filters:xl(p,l,k,c),queries:pf(y),sqlSnippets:gf(j),mock_context:Xo(k),views:rf(h,u),panels:{list:f},layouts:{list:m,currentBreakpoint:m[0].id}})}const dg=x.types.model({id:x.types.identifier,name:x.types.string,group:x.types.string,content:Ll,content_id:x.types.string,datasources:tf,globalSQLSnippets:ul,context:oi});function pg({id:e,name:t,group:n,content_id:s},i,a,l,c,u,d){return dg.create({id:e,name:t,group:n,content_id:s,content:ug(i,c,u,d),datasources:{list:a},globalSQLSnippets:{list:l},context:dl(c)})}uu(),du();const oO=({context:e,dashboard:t,content:n,className:s="dashboard",config:i,fullScreenPanelID:a,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h})=>{Si(i);const{data:f=[]}=W.useRequest(Xi),{data:m=[]}=W.useRequest(hu),y=g.useMemo(()=>pg(t,n,f,m,e,c??{},d??null),[t,n,d]);Rf(y.content,!1),g.useEffect(()=>{y.context.replace(e)},[e]),g.useEffect(()=>{y.datasources.replace(f)},[f]),g.useEffect(()=>{y.globalSQLSnippets.replace(m)},[m]),g.useEffect(()=>{u==null||u(y.content.filters.values)},[u,y.content.filters.valuesString]),g.useEffect(()=>{c&&y.content.filters.patchValues(c)},[c,y.content.filters.patchValues]),g.useEffect(()=>{p==null||p(y.content.views.firstVisibleTabsViewActiveTab)},[p,y.content.views.firstVisibleTabsViewActiveTab]),g.useEffect(()=>{d&&y.content.views.setFirstVisibleTabsViewActiveTab(d)},[d,y.content.views.setFirstVisibleTabsViewActiveTab]);const j=W.useCreation(Ro,[]),k=Qf(j);return W.useWhyDidYouUpdate("@devtable/dashboard render",{context:e,dashboard:t,content:n,className:s,config:i,fullScreenPanelID:a,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h}),r.jsx(Wf,{lang:h,children:r.jsx(lt.ModalsProvider,{children:r.jsx(ia,{children:r.jsx(ta,{value:{searchButtonProps:i.searchButtonProps},children:r.jsx(Hi,{value:y,children:r.jsx(na,{value:y.content,children:r.jsx(sa.Provider,{value:{fullScreenPanelID:a,setFullScreenPanelID:l},children:r.jsx(js.Provider,{value:{inEditMode:!1},children:r.jsx(o.Box,{className:`${s} dashboard-root`,children:r.jsx(Gt.Provider,{value:j,children:r.jsx(si,{configure:k,children:y.content.views.visibleViews.map(S=>r.jsx(ci,{view:S},S.id))})})})})})})})})})})})},lO=D.observer(oO);P.extend(Lg),P.extend(Bg),P.extend(qg),P.extend(Vg),P.extend(Ng),P.extend($g),P.extend(Fg),P.extend(Gg),P.extend(Wg),P.extend(Rg),P.extend(Yg),P.extend(Kg),P.extend(Xg),P.extend(Jg),P.extend(Zg),P.extend(Qg),P.extend(Ug),P.extend(Hg),P.extend(em),P.extend(tm),P.extend(nm),P.extend(rm),P.extend(sm),P.extend(im),P.extend(am),P.extend(om),P.extend(lm),P.extend(cm),P.extend(um),P.extend(dm),P.extend(hm),P.extend(fm),P.extend(pm),P.tz.setDefault("UTC"),P.updateLocale("en",{weekStart:1});const cO=()=>Promise.resolve().then(()=>Zy).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));w.APIClient=Ot,w.CURRENT_SCHEMA_VERSION=en,w.ContentModel=Tl,w.ContentModelContextProvider=na,w.ContentRenderModel=Ll,w.ContextMeta=oi,w.DEFAULT_CUSTOM_MODAL_TITLE=ai,w.DashboardApiClient=yc,w.DashboardApiFacadeClient=bc,w.DashboardEditor=aO,w.DashboardFilterType=ce,w.DashboardMode=Ef,w.DashboardModel=Ff,w.DashboardModelContextProvider=Hi,w.DashboardRenderModel=dg,w.DashboardThemeContextProvider=ta,w.DashboardViewEditor=If,w.DashboardViewRender=ci,w.DataSourceMetaModel=cl,w.DataSourceType=ye,w.DataSourcesMetaModel=tf,w.DatesProvider=ia,w.DefaultApiClient=xc,w.DescriptionPopover=jl,w.DraftModel=mf,w.EViewComponentType=q,w.FacadeApiClient=Mm,w.FilterCheckboxConfigMeta=Jo,w.FilterDateRangeConfigMeta=Zo,w.FilterMeta=il,w.FilterMultiSelectConfigMeta=el,w.FilterSelectConfigMeta=tl,w.FilterTextInputConfigMeta=nl,w.FilterTreeSelectConfigMeta=sl,w.FiltersModel=Pf,w.FiltersRenderModel=ml,w.FullScreenPanel=kf,w.FullScreenPanelContext=sa,w.GlobalSQLSnippetMeta=nf,w.GlobalSQLSnippetsMeta=ul,w.LayoutItemMeta=Fh,w.LayoutSetMeta=Gh,w.LayoutStateContext=js,w.LayoutsRenderModel=vl,w.MockContextMeta=Ko,w.MuteQueryModel=df,w.Panel=Sf,w.PanelContextProvider=ra,w.PanelErrorOrStateMessage=wf,w.PanelMeta=Nh,w.PanelModel=qf,w.PanelRender=Cl,w.PanelRenderModel=fl,w.PanelStyleMeta=Lh,w.PanelTitleMeta=Bh,w.PanelVizMeta=Vh,w.PanelVizSection=wl,w.PanelsModel=Vf,w.PanelsRenderModel=gl,w.QueriesModel=Lf,w.QueriesRenderModel=bl,w.QueryMeta=$h,w.QueryModel=Of,w.QueryRenderModel=yl,w.ReadOnlyDashboard=lO,w.SQLSnippetMeta=Wh,w.SQLSnippetRenderModel=ff,w.SQLSnippetsModel=Bf,w.SQLSnippetsRenderModel=_l,w.VariableMeta=qh,w.ViewComponentTypeBackground=Af,w.ViewComponentTypeColor=TE,w.ViewComponentTypeName=kE,w.ViewDivisionConfig=al,w.ViewMeta=ef,w.ViewModalConfig=ol,w.ViewRenderModel=pl,w.ViewTabsConfig=ll,w.ViewsModel=Nf,w.ViewsRenderModel=hl,w.Viz=jf,w.applyPartialDashboard=NE,w.configureAPIClient=Si,w.createContentModel=$f,w.createContentRenderModel=ug,w.createContextMeta=dl,w.createDashboardModel=Gf,w.createDashboardRenderModel=pg,w.createDraft=xf,w.createFilterCheckboxConfig=Rh,w.createFilterDateRangeConfig=Uh,w.createFilterMultiSelectConfig=Yh,w.createFilterSelectConfig=Kh,w.createFilterTextInputConfig=rl,w.createFilterTreeSelectConfig=Xh,w.createViewDivisionConfig=Jh,w.createViewModalConfig=Zh,w.createViewTabsConfig=Hh,w.facadeApiClient=vc,w.formatSQLSnippet=Rr,w.getInitialDashboardViewsModel=kl,w.getInitialFiltersConfig=xl,w.getInitialMockContextMeta=Xo,w.getInitialQueriesRenderModel=pf,w.getInitialSQLSnippetsRenderModel=gf,w.getInitialViewsRenderModel=rf,w.getNewPanel=of,w.getVersion=cO,w.initialDashboardContent=GI,w.useDashboardContext=ea,w.useDashboardThemeContext=_u,w.useEditContentModelContext=Y,w.useEditDashboardContext=Z,w.useEditPanelContext=Ge,w.useFullScreenPanelContext=ku,w.usePanelFullScreen=Tf,w.useRenderContentModelContext=_e,w.useRenderDashboardContext=bu,w.useRenderPanelContext=St,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
|
489
|
+
`)},f2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation();return e.typedAsSQL?r.jsxs(o.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Edit",children:r.jsx(o.Group,{spacing:14,position:"apart",children:t("query.edit_sql")})}),r.jsx(o.Tabs.Tab,{value:"Preview",children:t("query.preview_sql")}),r.jsx(o.Tabs.Tab,{value:"pre_process",children:t("query.process_request")}),r.jsx(o.Tabs.Tab,{value:"post_process",children:t("query.process_result")}),r.jsx(Ol,{}),e.datasource&&r.jsx(ig,{dataSource:e.datasource})]}),r.jsx(o.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:r.jsx(d2,{queryModel:e})}),r.jsx(o.Tabs.Panel,{value:"Preview",p:0,pl:4,children:r.jsx(h2,{value:e.sql})}),r.jsx(o.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:r.jsx(Nn,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:lg.pre})}),r.jsx(o.Tabs.Panel,{value:"post_process",p:"sm",children:r.jsx(Nn,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:lg.post})})]}):null}),g2={pre:["function transform(queries, state, utils) {"," // use queries & dashboar state to build new data"," const data = []"," return data","}"].join(`
|
|
490
|
+
`),post:""},m2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),n=Y();return e.isTransform?r.jsxs(o.Stack,{py:20,px:20,sx:{height:"100%"},children:[r.jsx(o.Text,{size:"sm",children:t("query.transform.guide.pick_queries")}),r.jsx(o.MultiSelect,{data:n.queries.optionsWithoutTransform,value:[...e.dep_query_ids],onChange:e.setDependantQueryIDs,maxDropdownHeight:800}),r.jsx(o.Text,{size:"sm",children:t("query.transform.guide.write_function")}),r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(Nn,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:g2.pre})})]}):null}),Ur={height:"calc(100% - 44px)",padding:0},x2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),n=Y(),s=g.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),[i,a]=g.useState(s);g.useEffect(()=>{a(u=>u!=="Configurations"&&s==="Configurations"?"Configurations":u)},[s]);const l=n.findQueryUsage(e.id),c=l.length===0;return r.jsxs(o.Tabs,{value:i,onTabChange:a,defaultValue:s,orientation:"horizontal",keepMounted:!1,sx:{height:"100vh"},children:[r.jsxs(o.Tabs.List,{grow:!0,children:[r.jsx(o.Tabs.Tab,{value:"Configurations",children:t("query.configurations")}),e.typedAsSQL&&r.jsx(o.Tabs.Tab,{value:"SQL",children:t("query.request")}),e.typedAsHTTP&&r.jsx(o.Tabs.Tab,{value:"HTTP",children:t("query.request")}),e.isTransform&&r.jsx(o.Tabs.Tab,{value:"Transform",children:t("query.transform.label")}),r.jsx(o.Tabs.Tab,{value:"Data",disabled:!e.canPreviewData,children:r.jsx(o.Tooltip,{label:e.guideToPreviewData,disabled:e.canPreviewData,withinPortal:!0,children:r.jsx(o.Text,{children:t("data.preview_data")})})}),r.jsx(o.Tabs.Tab,{value:"Usage",disabled:c,children:r.jsx(o.Tooltip,{label:t("query.usage.unused_description"),disabled:!c,withinPortal:!0,children:r.jsx(o.Text,{children:t("query.usage.label")})})})]}),r.jsx(o.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:r.jsx(r2,{queryModel:e})}),e.typedAsSQL&&r.jsx(o.Tabs.Panel,{value:"SQL",sx:Ur,children:r.jsx(o.Stack,{sx:{height:"100%"},children:r.jsx(f2,{queryModel:e})})}),e.typedAsHTTP&&r.jsx(o.Tabs.Panel,{value:"HTTP",sx:Ur,children:r.jsx(o.Stack,{sx:{height:"100%"},children:r.jsx(o2,{queryModel:e})})}),e.isTransform&&r.jsx(o.Tabs.Panel,{value:"Transform",sx:Ur,children:r.jsx(o.Stack,{sx:{height:"100%"},children:r.jsx(m2,{queryModel:e})})}),r.jsx(o.Tabs.Panel,{value:"Data",sx:{...Ur,overflow:"hidden"},children:r.jsx(El,{id:e.id,moreActions:null,refreshOnMount:!0})}),r.jsx(o.Tabs.Panel,{value:"Usage",sx:{...Ur,overflow:"hidden"},children:r.jsx(l2,{queryID:e.id,usage:l})})]})}),y2=D.observer(({id:e})=>{const n=Y().queries.findByID(e);return e===""?null:n?r.jsx(x2,{queryModel:n}):r.jsx(o.Text,{size:14,color:"red",children:"Invalid Query ID"})}),b2=D.observer(({value:e})=>{const n=_e().payloadForSQL,s=g.useMemo(()=>Ci(e,n),[e,n]);return r.jsx(Qi,{height:"100%",value:s})}),v2=D.observer(({item:e,remove:t,onKeyChanged:n})=>{const{t:s}=_.useTranslation(),[i,a]=g.useState("SQL"),[l,c]=g.useState(e.key),u=()=>{e.setKey(l),n(l)},d=l!==e.key,p=e.isADuplicatedKey(l),[h,f]=g.useState(e.value),m=()=>{e.setValue(h)};g.useEffect(()=>{c(e.key),f(e.value)},[e]);const y=h!==e.value,j=lt.useModals(),k=()=>{j.openConfirmModal({title:`${s("sql_snippet.delete")}?`,labels:{confirm:s("common.actions.confirm"),cancel:s("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:t,confirmProps:{color:"red"},zIndex:320})};return r.jsxs(o.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[r.jsxs(o.Group,{sx:{alignItems:"end"},spacing:40,children:[r.jsx(o.TextInput,{label:s(p?"sql_snippet.key_occupied":"sql_snippet.key"),value:l,onChange:S=>{c(S.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:r.jsx(o.ActionIcon,{color:"blue",variant:"subtle",onClick:u,disabled:!d||p,children:r.jsx(V.DeviceFloppy,{size:16})}),error:p}),r.jsx(o.Button,{leftIcon:r.jsx(V.Trash,{size:16}),color:"red",variant:"light",onClick:k,children:s("sql_snippet.delete")})]}),r.jsxs(o.Tabs,{value:i,onTabChange:a,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[r.jsxs(o.Tabs.List,{sx:{position:"relative"},children:[r.jsx(o.Tabs.Tab,{value:"SQL",children:s("sql_snippet.edit_snippet")}),r.jsx(o.Tabs.Tab,{value:"Preview",children:s("sql_snippet.preview_snippet")}),r.jsx(Ol,{}),r.jsx(o.ActionIcon,{color:"blue",variant:"filled",onClick:m,disabled:!y,sx:{position:"absolute",top:0,right:10},children:r.jsx(V.DeviceFloppy,{size:18})})]}),r.jsx(o.Tabs.Panel,{value:"SQL",pt:"sm",children:r.jsx(Qi,{height:"100%",value:h,onChange:f,defaultLanguage:"sql",theme:"sql-dark"})}),r.jsx(o.Tabs.Panel,{value:"Preview",pt:"sm",children:r.jsx(b2,{value:h})})]})]})}),_2=D.observer(({id:e})=>{const t=Z(),n=Y(),s=g.useMemo(()=>n.sqlSnippets.findByKey(e),[e]);if(!e)return null;if(!s)return r.jsxs(o.Text,{size:14,children:["SQL Snippet by key[",e,"] is not found"]});const i=()=>{t.editor.setPath(["_SQL_SNIPPETS_",""])},a=()=>{n.sqlSnippets.removeByKey(e),i()},l=c=>{t.editor.setPath(["_SQL_SNIPPETS_",c])};return r.jsx(v2,{item:s,remove:a,onKeyChanged:l})}),j2=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState([]),s=lt.useModals(),i=Z(),a=f=>{i.editor.setPath(["_SQL_SNIPPETS_",f])},l=()=>{s.openConfirmModal({title:"Delete ununsed SQL snippets?",children:r.jsx(o.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.removeUnusedSQLSnippets(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.sqlSnippets.downloadSchema(t)},u=g.useMemo(()=>i.content.sqlSnippets.sortedList.map(f=>f.key),[i.content.sqlSnippets.sortedList]),d=()=>{n(u)},p=()=>{n([])},h=i.content.sqlSnippetsUsage;return r.jsxs(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[r.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:e("sql_snippet.manage")})}),r.jsxs(o.Flex,{justify:"space-between",align:"center",px:12,children:[r.jsxs(o.Group,{position:"left",children:[r.jsxs(o.Button.Group,{children:[r.jsx(o.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),r.jsx(o.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(M.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),r.jsx(o.Button,{variant:"subtle",size:"xs",color:"red",leftIcon:r.jsx(M.IconTrash,{size:14}),disabled:!i.content.hasUnusedSQLSnippets,onClick:l,children:e("sql_snippet.delete_unused")})]}),r.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(o.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"40px"}}),r.jsx("th",{children:e("common.key")}),r.jsx("th",{style:{width:"100px",textAlign:"center"},children:e("sql_snippet.usage.label")}),r.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx("tbody",{children:i.content.sqlSnippets.sortedList.map(f=>{var y;const m=((y=h[f.key])==null?void 0:y.length)??0;return r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx(o.Checkbox,{value:f.key,styles:{input:{cursor:"pointer"}}})}),r.jsx("td",{children:f.key}),r.jsx("td",{style:{color:m===0?"#ff0000":"#000",fontWeight:m===0?"bold":"normal",textAlign:"center"},children:m}),r.jsx("td",{children:r.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>a(f.key),children:e("common.actions.open")})})]},f.key)})})]})})})]})}),w2=D.observer(({view:e})=>!e||e.type!==q.Division?null:r.jsx(o.Stack,{})),C2=D.observer(({view:e})=>{const{t,i18n:n}=_.useTranslation(),s=g.useMemo(()=>[{value:"default",label:t("common.tabs.variant.default")},{value:"outline",label:t("common.tabs.variant.outline")},{value:"pills",label:t("common.tabs.variant.pills")}],[n.language]),i=g.useMemo(()=>[{value:"horizontal",label:t("common.tabs.orientation.horizontal")},{value:"vertical",label:t("common.tabs.orientation.vertical")}],[n.language]);if(!e||e.type!==q.Tabs)return null;const a=e.config;return r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mt:8,mb:0,label:t("view.component.tabs.tabs_settings"),labelPosition:"center"}),r.jsx(o.Select,{label:t("common.tabs.variant.label"),value:a.variant,onChange:a.setVariant,data:s}),r.jsx(o.Select,{label:t("common.tabs.orientation.label"),value:a.orientation,onChange:a.setOrientation,data:i}),r.jsx(o.Switch,{label:t("common.tabs.grow_tabs"),checked:a.grow,onChange:l=>a.setGrow(l.currentTarget.checked)})]})}),S2=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(o.Box,{sx:{position:"relative"},children:[e&&r.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(et,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},k2=({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),[s,{setTrue:i,setFalse:a}]=W.useBoolean(),[l,c]=g.useState(e??ai),u=m=>{c({...l,enabled:m})},d=()=>{a();const{enabled:m,func_content:y}=l,j={enabled:m,func_content:y};c(j),t(j)},p=()=>{a(),c(e)},h=m=>{c(y=>({...y,func_content:m}))},f=()=>{h(ai.func_content)};return r.jsxs(r.Fragment,{children:[r.jsx(o.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:i,sx:{flexGrow:0},children:r.jsx(V.Settings,{size:14})}),r.jsx(o.Modal,{size:800,title:n("view.component.modal.custom_title"),opened:s,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&r.jsxs(o.Stack,{children:[r.jsx(o.Checkbox,{mt:10,label:n("common.enabled"),checked:l.enabled,onChange:m=>u(m.currentTarget.checked)}),r.jsx(S2,{value:l.func_content,onChange:h,disabled:!l.enabled}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:f,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:n("common.actions.revert")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:p,variant:"subtle",children:n("common.actions.cancel")}),r.jsx(o.Button,{onClick:d,children:n("common.actions.save")})]})]})]})})]})},T2=D.observer(({view:e})=>{const{t}=_.useTranslation();if(!e||e.type!==q.Modal)return null;const n=e.config,s=n.custom_modal_title.value;return r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mt:8,label:t("view.component.modal.modal_settings"),labelPosition:"center"}),r.jsxs(o.Flex,{gap:10,children:[r.jsx(o.TextInput,{label:t("view.component.modal.title"),value:s,onChange:v.noop,disabled:!0,sx:{flexGrow:1}}),r.jsx(k2,{value:n.custom_modal_title,onChange:n.custom_modal_title.replace})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(o.TextInput,{label:t("view.component.modal.width"),value:n.width,onChange:i=>n.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),r.jsx(o.TextInput,{label:t("view.component.modal.height"),value:n.height,onChange:i=>n.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),D2=D.observer(({view:e})=>r.jsxs(r.Fragment,{children:[r.jsx(w2,{view:e}),r.jsx(T2,{view:e}),r.jsx(C2,{view:e})]})),M2=D.observer(({view:e})=>{const{t,i18n:n}=_.useTranslation(),s=g.useMemo(()=>[{label:t("view.component.div.label"),value:q.Division},{label:t("view.component.modal.label"),value:q.Modal},{label:t("view.component.tabs.label"),value:q.Tabs}],[n.language]);return e?r.jsxs(o.Stack,{sx:{position:"relative"},children:[r.jsx(o.TextInput,{label:t("common.name"),value:e.name,onChange:i=>{e.setName(i.currentTarget.value)}}),r.jsx(o.Select,{label:t("common.type"),withinPortal:!0,zIndex:320,value:e.type,onChange:e.setType,data:s}),r.jsx(D2,{view:e})]}):null}),z2=D.observer(({id:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Z(),i=Y();if(e==="")return null;const a=i.views.findByID(e);if(!a)return r.jsxs(o.Text,{size:14,children:["View by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_VIEWS_",""])},c=()=>{n.openConfirmModal({title:`${t("view.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.views.removeByID(e),l()},zIndex:320})};return r.jsxs(o.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[r.jsx(o.Group,{position:"right",pt:10,children:r.jsx(o.Button,{size:"xs",color:"red",leftIcon:r.jsx(V.Trash,{size:16}),onClick:c,children:t("view.delete")})}),r.jsx(o.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:r.jsx(M2,{view:a})})]})});function I2(e){return e.length===1&&e[0]==="_QUERY_VARS_"}function E2(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function A2(e){return e.length===1&&e[0]==="_FILTERS_"}function P2(e){return e.length===2&&e[0]==="_FILTERS_"}function O2(e){return e.length===1&&e[0]==="_SQL_SNIPPETS_"}function L2(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function B2(e){return e.length===2&&e[0]==="_QUERIES_"}function q2(e){return e.length===1&&e[0]==="_QUERIES_"}function V2(e){return e.length===2&&e[0]==="_VIEWS_"}function N2(e){return e.length===4&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}const $2=D.observer(()=>r.jsx(o.Stack,{sx:{height:"100%"},p:"sm",children:r.jsx(ag,{})})),F2=D.observer(()=>{const e=Z().editor,t=e.path;return I2(t)?r.jsx($2,{}):E2(t)?r.jsx(HA,{}):A2(t)?r.jsx(ZA,{}):P2(t)?r.jsx(o.Box,{p:"xs",pl:20,children:r.jsx(JA,{id:t[1]})}):O2(t)?r.jsx(j2,{}):L2(t)?r.jsx(_2,{id:t[1]}):q2(t)?r.jsx(LP,{}):B2(t)?r.jsx(y2,{id:t[1]}):V2(t)?r.jsx(o.Box,{p:"xs",pl:20,children:r.jsx(z2,{id:t[1]})}):N2(t)?r.jsx(OP,{viewID:t[1],panelID:t[3]}):r.jsx(o.Box,{children:e.path})}),G2=D.observer(()=>r.jsx(F2,{})),W2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=()=>{const s=new Date().getTime().toString(),i={id:s,key:s,label:s,order:t.content.filters.current.length+1,type:ce.TextInput,config:rl(),visibleInViewsIDs:["Main"],auto_submit:!1};t.content.filters.append(i),t.editor.setPath(["_FILTERS_",s])};return r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("filter.add")})}),R2=D.observer(({parentID:e})=>{const{t}=_.useTranslation(),n=Y();if(!e)return null;const s=n.views.findByID(e);return!s||s.type===q.Tabs?null:r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>n.addANewPanel(s.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("panel.add")})}),Q2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=()=>{const s=new Date().getTime().toString(),i={id:s,name:s,type:ye.Postgresql,key:"",sql:""};t.content.queries.append(i),t.editor.setPath(["_QUERIES_",s])};return r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("query.add")})}),U2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=()=>{const s=new Date().getTime().toString(),i={key:s,value:""};t.content.sqlSnippets.append(i),t.editor.setPath(["_SQL_SNIPPETS_",s])};return r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("sql_snippet.add")})}),Y2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Y();return r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("view.add")})}),K2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z();return r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_QUERIES_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("query.manage")})}),X2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z();return r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_SQL_SNIPPETS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("sql_snippet.manage")})}),J2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z();return r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_FILTERS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("filter.manage")})}),Z2=D.observer(({action_type:e,parentID:t})=>e==="_Add_A_Filter_"?r.jsx(W2,{}):e==="_Add_A_SQL_SNIPPET_"?r.jsx(U2,{}):e==="_Add_A_QUERY_"?r.jsx(Q2,{}):e==="_Add_A_VIEW_"?r.jsx(Y2,{}):e==="_Add_A_PANEL_"?r.jsx(R2,{parentID:t}):e==="_QUERIES_SETTINGS_"?r.jsx(K2,{}):e==="_SQL_SNIPPETS_SETTINGS_"?r.jsx(X2,{}):e==="_FILTERS_SETTINGS_"?r.jsx(J2,{}):null),cg=D.observer(({option:e})=>{var p;const{t}=_.useTranslation(),n=Z().editor,s=n.isOptionActive,i=s(n.path,e),a=n.isOptionOpened,l=n.navigate,c=a(e),[u,d]=g.useState(c);return g.useEffect(()=>{d(c)},[c]),r.jsx(o.NavLink,{active:i,defaultOpened:c,opened:u,onChange:d,label:t(e.label),onClick:()=>l(e),icon:e.Icon?r.jsx(e.Icon,{size:18}):null,children:(p=e.children)==null?void 0:p.map(h=>h._type==="ACTION"?r.jsx(Z2,{action_type:h._action_type,parentID:h.parentID},`_ADD_${h.value}_`):r.jsx(cg,{option:h},h.value))},e.label)}),H2=D.observer(()=>{const e=Z();return r.jsx(o.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>r.jsx(cg,{option:t},t.value))})}),eO=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z();return r.jsxs(o.Navbar,{p:0,width:{base:220,xs:220,sm:240,md:260,lg:300,xl:320},sx:{height:"100vh - 60px - 60px",".mantine-NavLink-body":{wordWrap:"break-word"}},children:[r.jsx(o.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:e("common.titles.settings")})}),r.jsx(o.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:r.jsx(H2,{})}),r.jsx(o.Navbar.Section,{children:r.jsx(o.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:r.jsx(o.Button,{size:"xs",color:"red",leftIcon:r.jsx(M.IconX,{size:18}),onClick:()=>t.editor.close(),children:e("common.actions.close")})})})]})}),tO={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"calc(var(--mantine-navbar-width, 0px) + 1200px)"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},nO=D.observer(()=>{const e=Z().editor;return r.jsx(o.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionProps:{duration:0},withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{body:{padding:"0 !important"},content:{overflowY:"hidden !important"}},children:r.jsx(o.AppShell,{padding:0,navbar:r.jsx(eO,{}),styles:tO,children:r.jsx(G2,{})})})}),rO=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function sO(e){g.useEffect(()=>{if(et.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const n=rO(e);et.loader.config({paths:{vs:n}}),et.loader.init().then(s=>console.log("monaco instance:",s))},[])}uu(),du();const iO={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},aO=({context:e,dashboard:t,content:n,update:s,className:i="dashboard",config:a,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h},f)=>{sO(a.monacoPath),Si(a);const{data:m=[]}=W.useRequest(Xi),{data:y=[]}=W.useRequest(hu),j=g.useMemo(()=>Gf(t,n,m,y,e,u??{}),[t,n]);g.useImperativeHandle(f,()=>j,[j]),Rf(j.content,!0),g.useEffect(()=>{j.context.replace(e)},[e]),g.useEffect(()=>{j.datasources.replace(m)},[m]),g.useEffect(()=>{j.globalSQLSnippets.replace(y)},[y]),g.useEffect(()=>{d==null||d(j.content.filters.values)},[d,j.content.filters.values]),g.useEffect(()=>{u&&j.content.filters.patchValues(u)},[u,j.content.filters.patchValues]),g.useEffect(()=>X.reaction(()=>X.toJS(j.json),z=>{l==null||l(z)}),[j]);const k=async()=>{await s(j.json,j.content.json)},S=W.useCreation(Ro,[]),T=Qf(S);return W.useWhyDidYouUpdate("@devtable/dashboard editor",{context:e,dashboard:t,content:n,update:s,className:i,config:a,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h}),r.jsx(Wf,{lang:h,children:r.jsx(lt.ModalsProvider,{children:r.jsx(ia,{children:r.jsx(ta,{value:{searchButtonProps:a.searchButtonProps},children:r.jsx(Hi,{value:j,children:r.jsx(na,{value:j.content,children:r.jsx(js.Provider,{value:{inEditMode:!0},children:r.jsx(Gt.Provider,{value:S,children:r.jsxs(si,{configure:T,children:[r.jsx(o.AppShell,{padding:0,header:r.jsx(lA,{onExit:p,saveDashboardChanges:k,headerSlot:c}),navbar:r.jsx(OA,{}),styles:iO,children:r.jsx(o.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:j.content.views.visibleViews.map(z=>r.jsx(If,{view:z},z.id))})}),r.jsx(nO,{})]})})})})})})})})})},oO=D.observer(g.forwardRef(aO)),QL="",Ll=x.types.model({id:x.types.string,name:x.types.string,dashboard_id:x.types.string,create_time:x.types.string,update_time:x.types.string,version:x.types.string,filters:ml,queries:bl,sqlSnippets:_l,views:hl,panels:gl,layouts:vl,mock_context:Ko}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get payloadForSQL(){const t=x.getParent(e).context.current,n=x.getParent(e).globalSQLSnippets,s={context:{...e.mock_context.current,...t},filters:e.filters.values};return{...s,sql_snippets:Rr(e.sqlSnippets.current,"key","value",s),global_sql_snippets:Rr(n.list,"id","content",s)}},get payloadForViz(){const t=x.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.values}},get dashboardState(){return Ki(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardState}},get data(){return e.queries.current.map(({id:n,data:s})=>({id:n,data:s})).reduce((n,s)=>(n[s.id]=s.data,n),{})},getDataStuffByID(t){const n=e.queries.findByID(t);return n?{data:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).actions(e=>({}));function ug({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,content:a},l,c,u){if(!a)throw new Error("unexpected null content when creating a content model");const{version:d,filters:p,views:h,panels:f,layouts:m,definition:{queries:y,sqlSnippets:j,mock_context:k={}}}=a;return Ll.create({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,version:d,filters:xl(p,l,k,c),queries:pf(y),sqlSnippets:gf(j),mock_context:Xo(k),views:rf(h,u),panels:{list:f},layouts:{list:m,currentBreakpoint:m[0].id}})}const dg=x.types.model({id:x.types.identifier,name:x.types.string,group:x.types.string,content:Ll,content_id:x.types.string,datasources:tf,globalSQLSnippets:ul,context:oi});function pg({id:e,name:t,group:n,content_id:s},i,a,l,c,u,d){return dg.create({id:e,name:t,group:n,content_id:s,content:ug(i,c,u,d),datasources:{list:a},globalSQLSnippets:{list:l},context:dl(c)})}uu(),du();const lO=({context:e,dashboard:t,content:n,className:s="dashboard",config:i,fullScreenPanelID:a,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h})=>{Si(i);const{data:f=[]}=W.useRequest(Xi),{data:m=[]}=W.useRequest(hu),y=g.useMemo(()=>pg(t,n,f,m,e,c??{},d??null),[t,n,d]);Rf(y.content,!1),g.useEffect(()=>{y.context.replace(e)},[e]),g.useEffect(()=>{y.datasources.replace(f)},[f]),g.useEffect(()=>{y.globalSQLSnippets.replace(m)},[m]),g.useEffect(()=>{u==null||u(y.content.filters.values)},[u,y.content.filters.valuesString]),g.useEffect(()=>{c&&y.content.filters.patchValues(c)},[c,y.content.filters.patchValues]),g.useEffect(()=>{p==null||p(y.content.views.firstVisibleTabsViewActiveTab)},[p,y.content.views.firstVisibleTabsViewActiveTab]),g.useEffect(()=>{d&&y.content.views.setFirstVisibleTabsViewActiveTab(d)},[d,y.content.views.setFirstVisibleTabsViewActiveTab]);const j=W.useCreation(Ro,[]),k=Qf(j);return W.useWhyDidYouUpdate("@devtable/dashboard render",{context:e,dashboard:t,content:n,className:s,config:i,fullScreenPanelID:a,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h}),r.jsx(Wf,{lang:h,children:r.jsx(lt.ModalsProvider,{children:r.jsx(ia,{children:r.jsx(ta,{value:{searchButtonProps:i.searchButtonProps},children:r.jsx(Hi,{value:y,children:r.jsx(na,{value:y.content,children:r.jsx(sa.Provider,{value:{fullScreenPanelID:a,setFullScreenPanelID:l},children:r.jsx(js.Provider,{value:{inEditMode:!1},children:r.jsx(o.Box,{className:`${s} dashboard-root`,children:r.jsx(Gt.Provider,{value:j,children:r.jsx(si,{configure:k,children:y.content.views.visibleViews.map(S=>r.jsx(ci,{view:S},S.id))})})})})})})})})})})})},cO=D.observer(lO);P.extend(Lg),P.extend(Bg),P.extend(qg),P.extend(Vg),P.extend(Ng),P.extend($g),P.extend(Fg),P.extend(Gg),P.extend(Wg),P.extend(Rg),P.extend(Yg),P.extend(Kg),P.extend(Xg),P.extend(Jg),P.extend(Zg),P.extend(Qg),P.extend(Ug),P.extend(Hg),P.extend(em),P.extend(tm),P.extend(nm),P.extend(rm),P.extend(sm),P.extend(im),P.extend(am),P.extend(om),P.extend(lm),P.extend(cm),P.extend(um),P.extend(dm),P.extend(hm),P.extend(fm),P.extend(pm),P.tz.setDefault("UTC"),P.updateLocale("en",{weekStart:1});const uO=()=>Promise.resolve().then(()=>Zy).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));w.APIClient=Ot,w.CURRENT_SCHEMA_VERSION=en,w.ContentModel=Tl,w.ContentModelContextProvider=na,w.ContentRenderModel=Ll,w.ContextMeta=oi,w.DEFAULT_CUSTOM_MODAL_TITLE=ai,w.DashboardApiClient=yc,w.DashboardApiFacadeClient=bc,w.DashboardEditor=oO,w.DashboardFilterType=ce,w.DashboardMode=Ef,w.DashboardModel=Ff,w.DashboardModelContextProvider=Hi,w.DashboardRenderModel=dg,w.DashboardThemeContextProvider=ta,w.DashboardViewEditor=If,w.DashboardViewRender=ci,w.DataSourceMetaModel=cl,w.DataSourceType=ye,w.DataSourcesMetaModel=tf,w.DatesProvider=ia,w.DefaultApiClient=xc,w.DescriptionPopover=jl,w.DraftModel=mf,w.EViewComponentType=q,w.FacadeApiClient=Mm,w.FilterCheckboxConfigMeta=Jo,w.FilterDateRangeConfigMeta=Zo,w.FilterMeta=il,w.FilterMultiSelectConfigMeta=el,w.FilterSelectConfigMeta=tl,w.FilterTextInputConfigMeta=nl,w.FilterTreeSelectConfigMeta=sl,w.FiltersModel=Pf,w.FiltersRenderModel=ml,w.FullScreenPanel=kf,w.FullScreenPanelContext=sa,w.GlobalSQLSnippetMeta=nf,w.GlobalSQLSnippetsMeta=ul,w.LayoutItemMeta=Fh,w.LayoutSetMeta=Gh,w.LayoutStateContext=js,w.LayoutsRenderModel=vl,w.MockContextMeta=Ko,w.MuteQueryModel=df,w.Panel=Sf,w.PanelContextProvider=ra,w.PanelErrorOrStateMessage=wf,w.PanelMeta=Nh,w.PanelModel=qf,w.PanelRender=Cl,w.PanelRenderModel=fl,w.PanelStyleMeta=Lh,w.PanelTitleMeta=Bh,w.PanelVizMeta=Vh,w.PanelVizSection=wl,w.PanelsModel=Vf,w.PanelsRenderModel=gl,w.QueriesModel=Lf,w.QueriesRenderModel=bl,w.QueryMeta=$h,w.QueryModel=Of,w.QueryRenderModel=yl,w.ReadOnlyDashboard=cO,w.SQLSnippetMeta=Wh,w.SQLSnippetRenderModel=ff,w.SQLSnippetsModel=Bf,w.SQLSnippetsRenderModel=_l,w.VariableMeta=qh,w.ViewComponentTypeBackground=Af,w.ViewComponentTypeColor=DE,w.ViewComponentTypeName=TE,w.ViewDivisionConfig=al,w.ViewMeta=ef,w.ViewModalConfig=ol,w.ViewRenderModel=pl,w.ViewTabsConfig=ll,w.ViewsModel=Nf,w.ViewsRenderModel=hl,w.Viz=jf,w.applyPartialDashboard=$E,w.configureAPIClient=Si,w.createContentModel=$f,w.createContentRenderModel=ug,w.createContextMeta=dl,w.createDashboardModel=Gf,w.createDashboardRenderModel=pg,w.createDraft=xf,w.createFilterCheckboxConfig=Rh,w.createFilterDateRangeConfig=Uh,w.createFilterMultiSelectConfig=Yh,w.createFilterSelectConfig=Kh,w.createFilterTextInputConfig=rl,w.createFilterTreeSelectConfig=Xh,w.createViewDivisionConfig=Jh,w.createViewModalConfig=Zh,w.createViewTabsConfig=Hh,w.facadeApiClient=vc,w.formatSQLSnippet=Rr,w.getInitialDashboardViewsModel=kl,w.getInitialFiltersConfig=xl,w.getInitialMockContextMeta=Xo,w.getInitialQueriesRenderModel=pf,w.getInitialSQLSnippetsRenderModel=gf,w.getInitialViewsRenderModel=rf,w.getNewPanel=of,w.getVersion=uO,w.initialDashboardContent=WI,w.useDashboardContext=ea,w.useDashboardThemeContext=_u,w.useEditContentModelContext=Y,w.useEditDashboardContext=Z,w.useEditPanelContext=Ge,w.useFullScreenPanelContext=ku,w.usePanelFullScreen=Tf,w.useRenderContentModelContext=_e,w.useRenderDashboardContext=bu,w.useRenderPanelContext=St,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|