@devtable/dashboard 14.0.2 → 14.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- (function(w,f){typeof exports=="object"&&typeof module<"u"?f(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-table"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-table-row"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-underline"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("@mantine/dates"),require("@monaco-editor/react"),require("@tiptap/core"),require("d3-scale"),require("echarts/core"),require("react-hook-form"),require("@dnd-kit/helpers"),require("@dnd-kit/react"),require("react-dom"),require("uuid"),require("echarts/charts"),require("echarts/components"),require("echarts/renderers"),require("chroma-js"),require("js-base64"),require("eventemitter2"),require("echarts-for-react/lib/core"),require("echarts-gl"),require("@mantine/notifications"),require("@mantine/emotion"),require("d3-regression"),require("@mantine/code-highlight"),require("@tanstack/react-table"),require("@tanstack/react-virtual"),require("mobx-state-tree"),require("file-saver"),require("dom-to-image-more"),require("jszip"),require("@json2csv/whatwg"),require("rc-tree-select"),require("performant-array-to-tree"),require("rc-select"),require("react-grid-layout"),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("@mantine/spotlight"),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-table","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-table-row","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-underline","@tiptap/react","@tiptap/starter-kit","@mantine/dates","@monaco-editor/react","@tiptap/core","d3-scale","echarts/core","react-hook-form","@dnd-kit/helpers","@dnd-kit/react","react-dom","uuid","echarts/charts","echarts/components","echarts/renderers","chroma-js","js-base64","eventemitter2","echarts-for-react/lib/core","echarts-gl","@mantine/notifications","@mantine/emotion","d3-regression","@mantine/code-highlight","@tanstack/react-table","@tanstack/react-virtual","mobx-state-tree","file-saver","dom-to-image-more","jszip","@json2csv/whatwg","rc-tree-select","performant-array-to-tree","rc-select","react-grid-layout","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","@mantine/spotlight","reactflow"],f):(w=typeof globalThis<"u"?globalThis:w||self,f(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-table"],w["@tiptap/extension-table-cell"],w["@tiptap/extension-table-header"],w["@tiptap/extension-table-row"],w["@tiptap/extension-text-align"],w["@tiptap/extension-text-style"],w["@tiptap/extension-underline"],w["@tiptap/react"],w["@tiptap/starter-kit"],w["@mantine/dates"],w["@monaco-editor/react"],w["@tiptap/core"],w["d3-scale"],w["echarts/core"],w["react-hook-form"],w["@dnd-kit/helpers"],w["@dnd-kit/react"],w["react-dom"],w.uuid,w["echarts/charts"],w["echarts/components"],w["echarts/renderers"],w["chroma-js"],w["js-base64"],w.eventemitter2,w["echarts-for-react/lib/core"],w["echarts-gl"],w["@mantine/notifications"],w["@mantine/emotion"],w["d3-regression"],w["@mantine/code-highlight"],w["@tanstack/react-table"],w["@tanstack/react-virtual"],w["mobx-state-tree"],w["file-saver"],w["dom-to-image-more"],w.jszip,w["@json2csv/whatwg"],w["rc-tree-select"],w["performant-array-to-tree"],w["rc-select"],w["react-grid-layout"],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["@mantine/spotlight"],w.reactflow))})(this,function(w,f,a,dt,Y,te,k,tf,al,nr,A,v,nf,Lr,sn,pt,ze,C,_,Z,ol,ll,cl,ul,dl,pl,hl,gl,fl,xl,ml,bl,yl,vl,_l,ht,Us,rf,jl,y,sf,Or,af,Ut,qt,an,of,kt,wl,Cl,Qe,_6,Nt,on,lf,Dt,Re,cf,g,Vr,Sl,Tl,uf,Ys,df,kl,Br,pf,hf,gf,ff,xf,mf,bf,yf,vf,_f,jf,wf,Cf,Sf,Tf,kf,Df,zf,If,Mf,Ef,Pf,Af,Lf,Of,Vf,Bf,qf,Nf,$f,Gf,Ff,Qf,Rf,Wf,j6,_n,Ge){"use strict";var y6=Object.defineProperty;var v6=(w,f,a)=>f in w?y6(w,f,{enumerable:!0,configurable:!0,writable:!0,value:a}):w[f]=a;var N=(w,f,a)=>(v6(w,typeof f!="symbol"?f+"":f,a),a);function jn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const Uf=jn(al),Dl=jn(nr),Mn=jn(nf),Yf=jn(sn),Kf=jn(rf),Fe=jn(jl),ln=jn(lf);var Ks={exports:{}},rr={};/**
1
+ (function(w,f){typeof exports=="object"&&typeof module<"u"?f(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-table"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-table-row"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-underline"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("@mantine/dates"),require("@monaco-editor/react"),require("@tiptap/core"),require("d3-scale"),require("echarts/core"),require("react-hook-form"),require("@dnd-kit/helpers"),require("@dnd-kit/react"),require("react-dom"),require("uuid"),require("echarts/charts"),require("echarts/components"),require("echarts/renderers"),require("chroma-js"),require("js-base64"),require("eventemitter2"),require("echarts-for-react/lib/core"),require("echarts-gl"),require("@mantine/notifications"),require("@mantine/emotion"),require("d3-regression"),require("@mantine/code-highlight"),require("@tanstack/react-table"),require("@tanstack/react-virtual"),require("mobx-state-tree"),require("file-saver"),require("dom-to-image-more"),require("jszip"),require("@json2csv/whatwg"),require("rc-tree-select"),require("performant-array-to-tree"),require("rc-select"),require("react-grid-layout"),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("@mantine/spotlight"),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-table","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-table-row","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-underline","@tiptap/react","@tiptap/starter-kit","@mantine/dates","@monaco-editor/react","@tiptap/core","d3-scale","echarts/core","react-hook-form","@dnd-kit/helpers","@dnd-kit/react","react-dom","uuid","echarts/charts","echarts/components","echarts/renderers","chroma-js","js-base64","eventemitter2","echarts-for-react/lib/core","echarts-gl","@mantine/notifications","@mantine/emotion","d3-regression","@mantine/code-highlight","@tanstack/react-table","@tanstack/react-virtual","mobx-state-tree","file-saver","dom-to-image-more","jszip","@json2csv/whatwg","rc-tree-select","performant-array-to-tree","rc-select","react-grid-layout","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","@mantine/spotlight","reactflow"],f):(w=typeof globalThis<"u"?globalThis:w||self,f(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-table"],w["@tiptap/extension-table-cell"],w["@tiptap/extension-table-header"],w["@tiptap/extension-table-row"],w["@tiptap/extension-text-align"],w["@tiptap/extension-text-style"],w["@tiptap/extension-underline"],w["@tiptap/react"],w["@tiptap/starter-kit"],w["@mantine/dates"],w["@monaco-editor/react"],w["@tiptap/core"],w["d3-scale"],w["echarts/core"],w["react-hook-form"],w["@dnd-kit/helpers"],w["@dnd-kit/react"],w["react-dom"],w.uuid,w["echarts/charts"],w["echarts/components"],w["echarts/renderers"],w["chroma-js"],w["js-base64"],w.eventemitter2,w["echarts-for-react/lib/core"],w["echarts-gl"],w["@mantine/notifications"],w["@mantine/emotion"],w["d3-regression"],w["@mantine/code-highlight"],w["@tanstack/react-table"],w["@tanstack/react-virtual"],w["mobx-state-tree"],w["file-saver"],w["dom-to-image-more"],w.jszip,w["@json2csv/whatwg"],w["rc-tree-select"],w["performant-array-to-tree"],w["rc-select"],w["react-grid-layout"],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["@mantine/spotlight"],w.reactflow))})(this,function(w,f,a,dt,Y,te,k,tf,al,nr,A,v,nf,Lr,sn,pt,ze,C,_,Z,ol,ll,cl,ul,dl,pl,hl,gl,fl,xl,ml,bl,yl,vl,_l,ht,Us,rf,jl,y,sf,Or,af,Ut,qt,an,of,kt,wl,Cl,Qe,v6,Nt,on,lf,Dt,Re,cf,g,Vr,Sl,Tl,uf,Ys,df,kl,Br,pf,hf,gf,ff,xf,mf,bf,yf,vf,_f,jf,wf,Cf,Sf,Tf,kf,Df,zf,If,Mf,Ef,Pf,Af,Lf,Of,Vf,Bf,qf,Nf,$f,Gf,Ff,Qf,Rf,Wf,_6,_n,Ge){"use strict";var b6=Object.defineProperty;var y6=(w,f,a)=>f in w?b6(w,f,{enumerable:!0,configurable:!0,writable:!0,value:a}):w[f]=a;var N=(w,f,a)=>(y6(w,typeof f!="symbol"?f+"":f,a),a);function jn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const Uf=jn(al),Dl=jn(nr),Mn=jn(nf),Yf=jn(sn),Kf=jn(rf),Fe=jn(jl),ln=jn(lf);var Ks={exports:{}},rr={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -18,18 +18,18 @@
18
18
  `+ee+S}}var De=!1,ct;{var Me=typeof WeakMap=="function"?WeakMap:Map;ct=new Me}function Vt(S,E){if(!S||De)return"";{var q=ct.get(S);if(q!==void 0)return q}var X;De=!0;var ge=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var ve;ve=$.current,$.current=null,me();try{if(E){var le=function(){throw Error()};if(Object.defineProperty(le.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(le,[])}catch(ut){X=ut}Reflect.construct(S,[],le)}else{try{le.call()}catch(ut){X=ut}S.call(le.prototype)}}else{try{throw Error()}catch(ut){X=ut}S()}}catch(ut){if(ut&&X&&typeof ut.stack=="string"){for(var oe=ut.stack.split(`
19
19
  `),Je=X.stack.split(`
20
20
  `),Ee=oe.length-1,Ae=Je.length-1;Ee>=1&&Ae>=0&&oe[Ee]!==Je[Ae];)Ae--;for(;Ee>=1&&Ae>=0;Ee--,Ae--)if(oe[Ee]!==Je[Ae]){if(Ee!==1||Ae!==1)do if(Ee--,Ae--,Ae<0||oe[Ee]!==Je[Ae]){var Tt=`
21
- `+oe[Ee].replace(" at new "," at ");return S.displayName&&Tt.includes("<anonymous>")&&(Tt=Tt.replace("<anonymous>",S.displayName)),typeof S=="function"&&ct.set(S,Tt),Tt}while(Ee>=1&&Ae>=0);break}}}finally{De=!1,$.current=ve,ye(),Error.prepareStackTrace=ge}var tr=S?S.displayName||S.name:"",In=tr?de(tr):"";return typeof S=="function"&&ct.set(S,In),In}function Wt(S,E,q){return Vt(S,!1)}function Bt(S){var E=S.prototype;return!!(E&&E.isReactComponent)}function Qs(S,E,q){if(S==null)return"";if(typeof S=="function")return Vt(S,Bt(S));if(typeof S=="string")return de(S);switch(S){case d:return de("Suspense");case p:return de("SuspenseList")}if(typeof S=="object")switch(S.$$typeof){case u:return Wt(S.render);case h:return Qs(S.type,E,q);case x:{var X=S,ge=X._payload,ve=X._init;try{return Qs(ve(ge),E,q)}catch{}}}return""}var Pr=Object.prototype.hasOwnProperty,Gg={},Fg=T.ReactDebugCurrentFrame;function Rs(S){if(S){var E=S._owner,q=Qs(S.type,S._source,E?E.type:null);Fg.setExtraStackFrame(q)}else Fg.setExtraStackFrame(null)}function H4(S,E,q,X,ge){{var ve=Function.call.bind(Pr);for(var le in S)if(ve(S,le)){var oe=void 0;try{if(typeof S[le]!="function"){var Je=Error((X||"React class")+": "+q+" type `"+le+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof S[le]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Je.name="Invariant Violation",Je}oe=S[le](E,le,X,q,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Ee){oe=Ee}oe&&!(oe instanceof Error)&&(Rs(ge),z("%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).",X||"React class",q,le,typeof oe),Rs(null)),oe instanceof Error&&!(oe.message in Gg)&&(Gg[oe.message]=!0,Rs(ge),z("Failed %s type: %s",q,oe.message),Rs(null))}}}var Z4=Array.isArray;function Jo(S){return Z4(S)}function J4(S){{var E=typeof Symbol=="function"&&Symbol.toStringTag,q=E&&S[Symbol.toStringTag]||S.constructor.name||"Object";return q}}function e6(S){try{return Qg(S),!1}catch{return!0}}function Qg(S){return""+S}function Rg(S){if(e6(S))return z("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",J4(S)),Qg(S)}var Ar=T.ReactCurrentOwner,t6={key:!0,ref:!0,__self:!0,__source:!0},Wg,Ug,el;el={};function n6(S){if(Pr.call(S,"ref")){var E=Object.getOwnPropertyDescriptor(S,"ref").get;if(E&&E.isReactWarning)return!1}return S.ref!==void 0}function r6(S){if(Pr.call(S,"key")){var E=Object.getOwnPropertyDescriptor(S,"key").get;if(E&&E.isReactWarning)return!1}return S.key!==void 0}function s6(S,E){if(typeof S.ref=="string"&&Ar.current&&E&&Ar.current.stateNode!==E){var q=G(Ar.current.type);el[q]||(z('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',G(Ar.current.type),S.ref),el[q]=!0)}}function i6(S,E){{var q=function(){Wg||(Wg=!0,z("%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)",E))};q.isReactWarning=!0,Object.defineProperty(S,"key",{get:q,configurable:!0})}}function a6(S,E){{var q=function(){Ug||(Ug=!0,z("%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)",E))};q.isReactWarning=!0,Object.defineProperty(S,"ref",{get:q,configurable:!0})}}var o6=function(S,E,q,X,ge,ve,le){var oe={$$typeof:t,type:S,key:E,ref:q,props:le,_owner:ve};return oe._store={},Object.defineProperty(oe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(oe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:X}),Object.defineProperty(oe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ge}),Object.freeze&&(Object.freeze(oe.props),Object.freeze(oe)),oe};function l6(S,E,q,X,ge){{var ve,le={},oe=null,Je=null;q!==void 0&&(Rg(q),oe=""+q),r6(E)&&(Rg(E.key),oe=""+E.key),n6(E)&&(Je=E.ref,s6(E,ge));for(ve in E)Pr.call(E,ve)&&!t6.hasOwnProperty(ve)&&(le[ve]=E[ve]);if(S&&S.defaultProps){var Ee=S.defaultProps;for(ve in Ee)le[ve]===void 0&&(le[ve]=Ee[ve])}if(oe||Je){var Ae=typeof S=="function"?S.displayName||S.name||"Unknown":S;oe&&i6(le,Ae),Je&&a6(le,Ae)}return o6(S,oe,Je,ge,X,Ar.current,le)}}var tl=T.ReactCurrentOwner,Yg=T.ReactDebugCurrentFrame;function er(S){if(S){var E=S._owner,q=Qs(S.type,S._source,E?E.type:null);Yg.setExtraStackFrame(q)}else Yg.setExtraStackFrame(null)}var nl;nl=!1;function rl(S){return typeof S=="object"&&S!==null&&S.$$typeof===t}function Kg(){{if(tl.current){var S=G(tl.current.type);if(S)return`
21
+ `+oe[Ee].replace(" at new "," at ");return S.displayName&&Tt.includes("<anonymous>")&&(Tt=Tt.replace("<anonymous>",S.displayName)),typeof S=="function"&&ct.set(S,Tt),Tt}while(Ee>=1&&Ae>=0);break}}}finally{De=!1,$.current=ve,ye(),Error.prepareStackTrace=ge}var tr=S?S.displayName||S.name:"",In=tr?de(tr):"";return typeof S=="function"&&ct.set(S,In),In}function Wt(S,E,q){return Vt(S,!1)}function Bt(S){var E=S.prototype;return!!(E&&E.isReactComponent)}function Qs(S,E,q){if(S==null)return"";if(typeof S=="function")return Vt(S,Bt(S));if(typeof S=="string")return de(S);switch(S){case d:return de("Suspense");case p:return de("SuspenseList")}if(typeof S=="object")switch(S.$$typeof){case u:return Wt(S.render);case h:return Qs(S.type,E,q);case x:{var X=S,ge=X._payload,ve=X._init;try{return Qs(ve(ge),E,q)}catch{}}}return""}var Pr=Object.prototype.hasOwnProperty,Gg={},Fg=T.ReactDebugCurrentFrame;function Rs(S){if(S){var E=S._owner,q=Qs(S.type,S._source,E?E.type:null);Fg.setExtraStackFrame(q)}else Fg.setExtraStackFrame(null)}function X4(S,E,q,X,ge){{var ve=Function.call.bind(Pr);for(var le in S)if(ve(S,le)){var oe=void 0;try{if(typeof S[le]!="function"){var Je=Error((X||"React class")+": "+q+" type `"+le+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof S[le]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Je.name="Invariant Violation",Je}oe=S[le](E,le,X,q,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Ee){oe=Ee}oe&&!(oe instanceof Error)&&(Rs(ge),z("%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).",X||"React class",q,le,typeof oe),Rs(null)),oe instanceof Error&&!(oe.message in Gg)&&(Gg[oe.message]=!0,Rs(ge),z("Failed %s type: %s",q,oe.message),Rs(null))}}}var H4=Array.isArray;function Jo(S){return H4(S)}function Z4(S){{var E=typeof Symbol=="function"&&Symbol.toStringTag,q=E&&S[Symbol.toStringTag]||S.constructor.name||"Object";return q}}function J4(S){try{return Qg(S),!1}catch{return!0}}function Qg(S){return""+S}function Rg(S){if(J4(S))return z("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Z4(S)),Qg(S)}var Ar=T.ReactCurrentOwner,e6={key:!0,ref:!0,__self:!0,__source:!0},Wg,Ug,el;el={};function t6(S){if(Pr.call(S,"ref")){var E=Object.getOwnPropertyDescriptor(S,"ref").get;if(E&&E.isReactWarning)return!1}return S.ref!==void 0}function n6(S){if(Pr.call(S,"key")){var E=Object.getOwnPropertyDescriptor(S,"key").get;if(E&&E.isReactWarning)return!1}return S.key!==void 0}function r6(S,E){if(typeof S.ref=="string"&&Ar.current&&E&&Ar.current.stateNode!==E){var q=G(Ar.current.type);el[q]||(z('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',G(Ar.current.type),S.ref),el[q]=!0)}}function s6(S,E){{var q=function(){Wg||(Wg=!0,z("%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)",E))};q.isReactWarning=!0,Object.defineProperty(S,"key",{get:q,configurable:!0})}}function i6(S,E){{var q=function(){Ug||(Ug=!0,z("%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)",E))};q.isReactWarning=!0,Object.defineProperty(S,"ref",{get:q,configurable:!0})}}var a6=function(S,E,q,X,ge,ve,le){var oe={$$typeof:t,type:S,key:E,ref:q,props:le,_owner:ve};return oe._store={},Object.defineProperty(oe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(oe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:X}),Object.defineProperty(oe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ge}),Object.freeze&&(Object.freeze(oe.props),Object.freeze(oe)),oe};function o6(S,E,q,X,ge){{var ve,le={},oe=null,Je=null;q!==void 0&&(Rg(q),oe=""+q),n6(E)&&(Rg(E.key),oe=""+E.key),t6(E)&&(Je=E.ref,r6(E,ge));for(ve in E)Pr.call(E,ve)&&!e6.hasOwnProperty(ve)&&(le[ve]=E[ve]);if(S&&S.defaultProps){var Ee=S.defaultProps;for(ve in Ee)le[ve]===void 0&&(le[ve]=Ee[ve])}if(oe||Je){var Ae=typeof S=="function"?S.displayName||S.name||"Unknown":S;oe&&s6(le,Ae),Je&&i6(le,Ae)}return a6(S,oe,Je,ge,X,Ar.current,le)}}var tl=T.ReactCurrentOwner,Yg=T.ReactDebugCurrentFrame;function er(S){if(S){var E=S._owner,q=Qs(S.type,S._source,E?E.type:null);Yg.setExtraStackFrame(q)}else Yg.setExtraStackFrame(null)}var nl;nl=!1;function rl(S){return typeof S=="object"&&S!==null&&S.$$typeof===t}function Kg(){{if(tl.current){var S=G(tl.current.type);if(S)return`
22
22
 
23
- Check the render method of \``+S+"`."}return""}}function c6(S){{if(S!==void 0){var E=S.fileName.replace(/^.*[\\\/]/,""),q=S.lineNumber;return`
23
+ Check the render method of \``+S+"`."}return""}}function l6(S){{if(S!==void 0){var E=S.fileName.replace(/^.*[\\\/]/,""),q=S.lineNumber;return`
24
24
 
25
- Check your code at `+E+":"+q+"."}return""}}var Xg={};function u6(S){{var E=Kg();if(!E){var q=typeof S=="string"?S:S.displayName||S.name;q&&(E=`
25
+ Check your code at `+E+":"+q+"."}return""}}var Xg={};function c6(S){{var E=Kg();if(!E){var q=typeof S=="string"?S:S.displayName||S.name;q&&(E=`
26
26
 
27
- Check the top-level render call using <`+q+">.")}return E}}function Hg(S,E){{if(!S._store||S._store.validated||S.key!=null)return;S._store.validated=!0;var q=u6(E);if(Xg[q])return;Xg[q]=!0;var X="";S&&S._owner&&S._owner!==tl.current&&(X=" It was passed a child from "+G(S._owner.type)+"."),er(S),z('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',q,X),er(null)}}function Zg(S,E){{if(typeof S!="object")return;if(Jo(S))for(var q=0;q<S.length;q++){var X=S[q];rl(X)&&Hg(X,E)}else if(rl(S))S._store&&(S._store.validated=!0);else if(S){var ge=D(S);if(typeof ge=="function"&&ge!==S.entries)for(var ve=ge.call(S),le;!(le=ve.next()).done;)rl(le.value)&&Hg(le.value,E)}}}function d6(S){{var E=S.type;if(E==null||typeof E=="string")return;var q;if(typeof E=="function")q=E.propTypes;else if(typeof E=="object"&&(E.$$typeof===u||E.$$typeof===h))q=E.propTypes;else return;if(q){var X=G(E);H4(q,S.props,"prop",X,S)}else if(E.PropTypes!==void 0&&!nl){nl=!0;var ge=G(E);z("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ge||"Unknown")}typeof E.getDefaultProps=="function"&&!E.getDefaultProps.isReactClassApproved&&z("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function p6(S){{for(var E=Object.keys(S.props),q=0;q<E.length;q++){var X=E[q];if(X!=="children"&&X!=="key"){er(S),z("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",X),er(null);break}}S.ref!==null&&(er(S),z("Invalid attribute `ref` supplied to `React.Fragment`."),er(null))}}var Jg={};function ef(S,E,q,X,ge,ve){{var le=V(S);if(!le){var oe="";(S===void 0||typeof S=="object"&&S!==null&&Object.keys(S).length===0)&&(oe+=" 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 Je=c6(ge);Je?oe+=Je:oe+=Kg();var Ee;S===null?Ee="null":Jo(S)?Ee="array":S!==void 0&&S.$$typeof===t?(Ee="<"+(G(S.type)||"Unknown")+" />",oe=" Did you accidentally export a JSX literal instead of a component?"):Ee=typeof S,z("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ee,oe)}var Ae=l6(S,E,q,ge,ve);if(Ae==null)return Ae;if(le){var Tt=E.children;if(Tt!==void 0)if(X)if(Jo(Tt)){for(var tr=0;tr<Tt.length;tr++)Zg(Tt[tr],S);Object.freeze&&Object.freeze(Tt)}else z("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 Zg(Tt,S)}if(Pr.call(E,"key")){var In=G(S),ut=Object.keys(E).filter(function(b6){return b6!=="key"}),sl=ut.length>0?"{key: someKey, "+ut.join(": ..., ")+": ...}":"{key: someKey}";if(!Jg[In+sl]){var m6=ut.length>0?"{"+ut.join(": ..., ")+": ...}":"{}";z(`A props object containing a "key" prop is being spread into JSX:
27
+ Check the top-level render call using <`+q+">.")}return E}}function Hg(S,E){{if(!S._store||S._store.validated||S.key!=null)return;S._store.validated=!0;var q=c6(E);if(Xg[q])return;Xg[q]=!0;var X="";S&&S._owner&&S._owner!==tl.current&&(X=" It was passed a child from "+G(S._owner.type)+"."),er(S),z('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',q,X),er(null)}}function Zg(S,E){{if(typeof S!="object")return;if(Jo(S))for(var q=0;q<S.length;q++){var X=S[q];rl(X)&&Hg(X,E)}else if(rl(S))S._store&&(S._store.validated=!0);else if(S){var ge=D(S);if(typeof ge=="function"&&ge!==S.entries)for(var ve=ge.call(S),le;!(le=ve.next()).done;)rl(le.value)&&Hg(le.value,E)}}}function u6(S){{var E=S.type;if(E==null||typeof E=="string")return;var q;if(typeof E=="function")q=E.propTypes;else if(typeof E=="object"&&(E.$$typeof===u||E.$$typeof===h))q=E.propTypes;else return;if(q){var X=G(E);X4(q,S.props,"prop",X,S)}else if(E.PropTypes!==void 0&&!nl){nl=!0;var ge=G(E);z("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ge||"Unknown")}typeof E.getDefaultProps=="function"&&!E.getDefaultProps.isReactClassApproved&&z("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function d6(S){{for(var E=Object.keys(S.props),q=0;q<E.length;q++){var X=E[q];if(X!=="children"&&X!=="key"){er(S),z("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",X),er(null);break}}S.ref!==null&&(er(S),z("Invalid attribute `ref` supplied to `React.Fragment`."),er(null))}}var Jg={};function ef(S,E,q,X,ge,ve){{var le=V(S);if(!le){var oe="";(S===void 0||typeof S=="object"&&S!==null&&Object.keys(S).length===0)&&(oe+=" 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 Je=l6(ge);Je?oe+=Je:oe+=Kg();var Ee;S===null?Ee="null":Jo(S)?Ee="array":S!==void 0&&S.$$typeof===t?(Ee="<"+(G(S.type)||"Unknown")+" />",oe=" Did you accidentally export a JSX literal instead of a component?"):Ee=typeof S,z("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ee,oe)}var Ae=o6(S,E,q,ge,ve);if(Ae==null)return Ae;if(le){var Tt=E.children;if(Tt!==void 0)if(X)if(Jo(Tt)){for(var tr=0;tr<Tt.length;tr++)Zg(Tt[tr],S);Object.freeze&&Object.freeze(Tt)}else z("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 Zg(Tt,S)}if(Pr.call(E,"key")){var In=G(S),ut=Object.keys(E).filter(function(m6){return m6!=="key"}),sl=ut.length>0?"{key: someKey, "+ut.join(": ..., ")+": ...}":"{key: someKey}";if(!Jg[In+sl]){var x6=ut.length>0?"{"+ut.join(": ..., ")+": ...}":"{}";z(`A props object containing a "key" prop is being spread into JSX:
28
28
  let props = %s;
29
29
  <%s {...props} />
30
30
  React keys must be passed directly to JSX without using spread:
31
31
  let props = %s;
32
- <%s key={someKey} {...props} />`,sl,In,m6,In),Jg[In+sl]=!0}}return S===s?p6(Ae):d6(Ae),Ae}}function h6(S,E,q){return ef(S,E,q,!0)}function g6(S,E,q){return ef(S,E,q,!1)}var f6=g6,x6=h6;sr.Fragment=s,sr.jsx=f6,sr.jsxs=x6}()),sr}process.env.NODE_ENV==="production"?Ks.exports=Xf():Ks.exports=Hf();var n=Ks.exports;const zt={CryptoJS:al,d3Array:Dl,dayjs:A,lodash:v,numbro:Lr,mathjs:Mn,faker:tf.faker,popmotion:Yf},Zf=[{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.4"},{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.12.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"}],Jf=e=>`
32
+ <%s key={someKey} {...props} />`,sl,In,x6,In),Jg[In+sl]=!0}}return S===s?d6(Ae):u6(Ae),Ae}}function p6(S,E,q){return ef(S,E,q,!0)}function h6(S,E,q){return ef(S,E,q,!1)}var g6=h6,f6=p6;sr.Fragment=s,sr.jsx=g6,sr.jsxs=f6}()),sr}process.env.NODE_ENV==="production"?Ks.exports=Xf():Ks.exports=Hf();var n=Ks.exports;const zt={CryptoJS:al,d3Array:Dl,dayjs:A,lodash:v,numbro:Lr,mathjs:Mn,faker:tf.faker,popmotion:Yf},Zf=[{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.4"},{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.12.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"}],Jf=e=>`
33
33
  <tr>
34
34
  <td><code>${e.name}</code></td>
35
35
  <td>
@@ -89,7 +89,7 @@ React keys must be passed directly to JSX without using spread:
89
89
  ${Object.entries(t).map(([s,i])=>`const ${s} = '${i}';`).join(`
90
90
  `)}
91
91
  return ${e};
92
- `)(r)}catch(s){return console.error(s),console.log(e),e}}function fs(e,t,r,s){const i=dy(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=py(c);return hy(d,i,r)})}function gy(e,t){const r=wl.decode(t);r!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:r}),console.groupEnd())}async function fy({query:e,name:t,payload:r,additionals:s},i){if(!e.sql)return[];const{type:o,key:l,sql:c,pre_process:u,post_process:d}=e,p=Xs(c,r),h=tx({sql:p,pre_process:u}),x=wl.encode(h);gy(h,x);let b=await gt.query(i)({type:o,key:l,query:x,...s},{params:{name:t}});return b=nx(d,b,ma(r)),b}async function xy({type:e,key:t,configString:r,name:s,additionals:i},o){try{return await gt.httpDataSourceQuery(o)({type:e,key:t,query:r,...i},{params:{name:s}})}catch(l){if(pt.isCancel(l))throw l;return console.error(l),l}}async function my({key:e,configString:t,name:r,additionals:s},i){try{return await gt.mericoMetricQuery(i)({type:"merico_metric_system",key:e,query:t,...s},{params:{name:r}})}catch(o){throw o}}async function ba(){try{return(await gt.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function yd(){try{return(await gt.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class vd{constructor(t){N(this,"rootRef");this.rootRef=te.observable({current:t})}async deleteItem(t){te.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?te.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(v.isObject(r))te.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else te.runInAction(()=>{v.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,s){return te.reaction(()=>this.getValueFromRoot(t),(i,o)=>{r(i,o)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class by{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new Cl)}getChannel(t){const r=this.channels.get(t);if(r)return r;const s=new Cl;return this.channels.set(t,s),s}}class yy{constructor(t){N(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 r=this.instances.get(t.id);if(r)return r;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new by,instanceData:new vd(t.viz.conf)};return this.instances.set(t.id,s),s}}function _d(e,t,r,s){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new vd({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const vy=e=>{const{panel:t,measure:r,vizManager:s,data:i,variables:o}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={..._d(c,i,s,o),viewport:{width:r.w,height:r.h}},d=l.viewRender;return n.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},_y=e=>{const{vizManager:t,panel:r,data:s,variables:i}=e,o=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),c={..._d(l,s,t,i)},u=o.configRender;return n.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},jd=(e,t)=>{const r=kt.bezier(e),s=kt.bezier(t);return function(i){return i<50?r(i*2/100).hex():s((i-50)*2/100).hex()}},xs=e=>{const t=kt.bezier(e);return function(r){return t(r/100).hex()}},jy={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:jd(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},wy={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:jd(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Cy={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:xs(["#fff7f1","darkred"]),name:"red",category:"sequential"},Sy={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:xs(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ty={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:xs(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},ky={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:xs(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Dy{constructor(t){N(this,"symbol");this.symbol=Symbol(t)}}function Jt(e){return new Dy(e)}class ya{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const t=new ya;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 r=this.factoryRegistry.get(t.symbol);if(r){const s=r(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=v.get(t,"dispose");v.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const wd="14.0.2",zy=Object.freeze(Object.defineProperty({__proto__:null,version:wd},Symbol.toStringTag,{value:"Module"}));class Iy{constructor(t){N(this,"staticColors",new Map);N(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&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(r,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 My{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;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 r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class Ey{constructor(){N(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,s){var l;if(t.from===t.to)return r;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),o=v.orderBy(i,"version","asc");if(((l=v.last(o))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((c,u)=>u.handler(c,s),r)}}class ke extends Ey{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(s,i)=>({version:t,...r(s,i)}))}async migrate({configData:t,panelModel:r}){const s=await t.getItem(null),i=v.get(s,"version",0),o=this.run({from:i,to:this.VERSION},s,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return v.get(r,"version",0)<this.VERSION}}const R=(e,t)=>{const[r,{setFalse:s}]=Y.useBoolean(!0),[i,o]=f.useState();f.useEffect(()=>(e.getItem(t).then(c=>{o(c),s()}),e.watchItem(t,c=>{o(c)})));const l=f.useCallback(async c=>{await e.setItem(t,c),o(c)},[e,t]);return{loading:r,value:i,set:l}},st={top:16,right:16,bottom:16,left:16},Et=e=>Math.max(0,e-st.left-st.right),Pt=e=>Math.max(0,e-st.top-st.bottom),kr=(e,t)=>({width:Et(e),height:Pt(t)}),at=({width:e,height:t,children:r})=>n.jsx(a.Box,{pt:st.top,pr:st.right,pb:st.bottom,pl:st.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:r}),va={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 Py({context:e}){const{value:t}=R(e.instanceData,"config"),r=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=v.defaults({},t,va),h=f.useMemo(()=>qr(r,o),[r,o]),{x,y:b,z:m}=f.useMemo(()=>({x:O(o),y:O(l),z:O(c)}),[o,l,c]),{min:j,max:D}=f.useMemo(()=>{const z=v.minBy(h,M=>M[m.columnKey]),I=v.maxBy(h,M=>M[m.columnKey]);return{min:v.get(z,m.columnKey),max:v.get(I,m.columnKey)}},[h,m]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:D,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(z=>[z[x.columnKey],z[b.columnKey],z[m.columnKey]])}]};return t?n.jsx(at,{width:s,height:i,children:n.jsx(Qe,{echarts:Fe,option:T,style:kr(s,i),notMerge:!0,theme:"merico-light"})}):null}const W=k.observer(f.forwardRef(({label:e,required:t,description:r,value:s,onChange:i,queryID:o,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Le(),h=f.useMemo(()=>p.dataFieldOptionGroups(s,l,o),[s,l,o]);if(h.length===0){const x=p.explainDataKey(s);return n.jsxs(a.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.Box,{children:n.jsx(a.TextInput,{label:e,required:t,defaultValue:x.columnKey,readOnly:!0,disabled:!0})})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsxs(a.Group,{justify:"flex-start",gap:0,children:[n.jsx(a.Text,{size:"xs",c:x.queryName?"black":"red",ff:"monospace",children:x.queryName??x.queryID}),n.jsx(a.Text,{size:"xs",c:"black",ff:"monospace",children:"."}),n.jsx(a.Text,{size:"xs",c:"red",ff:"monospace",children:x.columnKey})]})})]})}return n.jsx(a.Select,{ref:d,label:e,description:r,data:h,value:s,onChange:Se(i),required:t,sx:c,maxDropdownHeight:500,...u})}));function Ay({context:e}){const{value:t,set:r}=R(e.instanceData,"config"),s=v.defaults({},t,va),{control:i,handleSubmit:o,reset:l}=y.useForm({defaultValues:s});return f.useEffect(()=>{l(s)},[t]),t?n.jsx(a.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:o(r),children:[n.jsx(a.Text,{size:"sm",children:"X Axis"}),n.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(y.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>n.jsx(W,{label:"Data Field",required:!0,...c})}),n.jsx(y.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>n.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(a.Text,{mt:"lg",size:"sm",children:"Y Axis"}),n.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(y.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>n.jsx(W,{label:"Data Field",required:!0,...c})}),n.jsx(y.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>n.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(a.Text,{mt:"lg",size:"sm",children:"Z Axis"}),n.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(y.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>n.jsx(W,{label:"Data Field",required:!0,...c})}),n.jsx(y.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>n.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(a.Group,{justify:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:n.jsxs(a.Button,{color:"blue",type:"submit",children:[n.jsx(C.IconDeviceFloppy,{size:20}),n.jsx(a.Text,{ml:"md",size:"sm",children:"Save"})]})})]})}):null}const Ly=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function Oy(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${r}.${u}`,{x_axis_data_key:i,y_axis_data_key:o,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(o),z_axis_data_key:s(l)}}catch(r){throw console.error("[Migration failed]",r),r}}class Vy extends ke{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,s)=>{const{config:i}=r;return{...r,version:2,config:Oy(i,s)}})}}const By={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Vy,name:"bar-3d",viewRender:Py,configRender:Ay,createConfig(){return{version:2,config:v.cloneDeep(va)}},translation:Ly},qy=({disabled:e,value:t,onChange:r})=>{const s=i=>{i&&r(i)};return n.jsxs(a.Box,{sx:{position:"relative"},children:[e&&n.jsx(a.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),n.jsx(ht,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function ot({enabled:e,func_content:t}){return(r,s)=>{if(!e)return r;try{return new Function(`return ${t}`)()(r,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),r}}}function Xe(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
92
+ `)(r)}catch(s){return console.error(s),console.log(e),e}}function fs(e,t,r,s){const i=dy(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=py(c);return hy(d,i,r)})}function gy(e,t){const r=wl.decode(t);r!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:r}),console.groupEnd())}async function fy({query:e,name:t,payload:r,additionals:s},i){if(!e.sql)return[];const{type:o,key:l,sql:c,pre_process:u,post_process:d}=e,p=Xs(c,r),h=tx({sql:p,pre_process:u}),x=wl.encode(h);gy(h,x);let b=await gt.query(i)({type:o,key:l,query:x,...s},{params:{name:t}});return b=nx(d,b,ma(r)),b}async function xy({type:e,key:t,configString:r,name:s,additionals:i},o){try{return await gt.httpDataSourceQuery(o)({type:e,key:t,query:r,...i},{params:{name:s}})}catch(l){if(pt.isCancel(l))throw l;return console.error(l),l}}async function my({key:e,configString:t,name:r,additionals:s},i){try{return await gt.mericoMetricQuery(i)({type:"merico_metric_system",key:e,query:t,...s},{params:{name:r}})}catch(o){throw o}}async function ba(){try{return(await gt.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function yd(){try{return(await gt.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class vd{constructor(t){N(this,"rootRef");this.rootRef=te.observable({current:t})}async deleteItem(t){te.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?te.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(v.isObject(r))te.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else te.runInAction(()=>{v.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,s){return te.reaction(()=>this.getValueFromRoot(t),(i,o)=>{r(i,o)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class by{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new Cl)}getChannel(t){const r=this.channels.get(t);if(r)return r;const s=new Cl;return this.channels.set(t,s),s}}class yy{constructor(t){N(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 r=this.instances.get(t.id);if(r)return r;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new by,instanceData:new vd(t.viz.conf)};return this.instances.set(t.id,s),s}}function _d(e,t,r,s){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new vd({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const vy=e=>{const{panel:t,measure:r,vizManager:s,data:i,variables:o}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={..._d(c,i,s,o),viewport:{width:r.w,height:r.h}},d=l.viewRender;return n.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},_y=e=>{const{vizManager:t,panel:r,data:s,variables:i}=e,o=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),c={..._d(l,s,t,i)},u=o.configRender;return n.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},jd=(e,t)=>{const r=kt.bezier(e),s=kt.bezier(t);return function(i){return i<50?r(i*2/100).hex():s((i-50)*2/100).hex()}},xs=e=>{const t=kt.bezier(e);return function(r){return t(r/100).hex()}},jy={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:jd(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},wy={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:jd(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Cy={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:xs(["#fff7f1","darkred"]),name:"red",category:"sequential"},Sy={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:xs(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ty={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:xs(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},ky={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:xs(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Dy{constructor(t){N(this,"symbol");this.symbol=Symbol(t)}}function Jt(e){return new Dy(e)}class ya{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const t=new ya;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 r=this.factoryRegistry.get(t.symbol);if(r){const s=r(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=v.get(t,"dispose");v.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const wd="14.1.0",zy=Object.freeze(Object.defineProperty({__proto__:null,version:wd},Symbol.toStringTag,{value:"Module"}));class Iy{constructor(t){N(this,"staticColors",new Map);N(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&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(r,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 My{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;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 r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class Ey{constructor(){N(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,s){var l;if(t.from===t.to)return r;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),o=v.orderBy(i,"version","asc");if(((l=v.last(o))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((c,u)=>u.handler(c,s),r)}}class ke extends Ey{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(s,i)=>({version:t,...r(s,i)}))}async migrate({configData:t,panelModel:r}){const s=await t.getItem(null),i=v.get(s,"version",0),o=this.run({from:i,to:this.VERSION},s,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return v.get(r,"version",0)<this.VERSION}}const R=(e,t)=>{const[r,{setFalse:s}]=Y.useBoolean(!0),[i,o]=f.useState();f.useEffect(()=>(e.getItem(t).then(c=>{o(c),s()}),e.watchItem(t,c=>{o(c)})));const l=f.useCallback(async c=>{await e.setItem(t,c),o(c)},[e,t]);return{loading:r,value:i,set:l}},st={top:16,right:16,bottom:16,left:16},Et=e=>Math.max(0,e-st.left-st.right),Pt=e=>Math.max(0,e-st.top-st.bottom),kr=(e,t)=>({width:Et(e),height:Pt(t)}),at=({width:e,height:t,children:r})=>n.jsx(a.Box,{pt:st.top,pr:st.right,pb:st.bottom,pl:st.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:r}),va={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 Py({context:e}){const{value:t}=R(e.instanceData,"config"),r=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=v.defaults({},t,va),h=f.useMemo(()=>qr(r,o),[r,o]),{x,y:b,z:m}=f.useMemo(()=>({x:O(o),y:O(l),z:O(c)}),[o,l,c]),{min:j,max:D}=f.useMemo(()=>{const z=v.minBy(h,M=>M[m.columnKey]),I=v.maxBy(h,M=>M[m.columnKey]);return{min:v.get(z,m.columnKey),max:v.get(I,m.columnKey)}},[h,m]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:D,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(z=>[z[x.columnKey],z[b.columnKey],z[m.columnKey]])}]};return t?n.jsx(at,{width:s,height:i,children:n.jsx(Qe,{echarts:Fe,option:T,style:kr(s,i),notMerge:!0,theme:"merico-light"})}):null}const W=k.observer(f.forwardRef(({label:e,required:t,description:r,value:s,onChange:i,queryID:o,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Le(),h=f.useMemo(()=>p.dataFieldOptionGroups(s,l,o),[s,l,o]);if(h.length===0){const x=p.explainDataKey(s);return n.jsxs(a.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.Box,{children:n.jsx(a.TextInput,{label:e,required:t,defaultValue:x.columnKey,readOnly:!0,disabled:!0})})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsxs(a.Group,{justify:"flex-start",gap:0,children:[n.jsx(a.Text,{size:"xs",c:x.queryName?"black":"red",ff:"monospace",children:x.queryName??x.queryID}),n.jsx(a.Text,{size:"xs",c:"black",ff:"monospace",children:"."}),n.jsx(a.Text,{size:"xs",c:"red",ff:"monospace",children:x.columnKey})]})})]})}return n.jsx(a.Select,{ref:d,label:e,description:r,data:h,value:s,onChange:Se(i),required:t,sx:c,maxDropdownHeight:500,...u})}));function Ay({context:e}){const{value:t,set:r}=R(e.instanceData,"config"),s=v.defaults({},t,va),{control:i,handleSubmit:o,reset:l}=y.useForm({defaultValues:s});return f.useEffect(()=>{l(s)},[t]),t?n.jsx(a.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:o(r),children:[n.jsx(a.Text,{size:"sm",children:"X Axis"}),n.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(y.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>n.jsx(W,{label:"Data Field",required:!0,...c})}),n.jsx(y.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>n.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(a.Text,{mt:"lg",size:"sm",children:"Y Axis"}),n.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(y.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>n.jsx(W,{label:"Data Field",required:!0,...c})}),n.jsx(y.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>n.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(a.Text,{mt:"lg",size:"sm",children:"Z Axis"}),n.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(y.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>n.jsx(W,{label:"Data Field",required:!0,...c})}),n.jsx(y.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>n.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(a.Group,{justify:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:n.jsxs(a.Button,{color:"blue",type:"submit",children:[n.jsx(C.IconDeviceFloppy,{size:20}),n.jsx(a.Text,{ml:"md",size:"sm",children:"Save"})]})})]})}):null}const Ly=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function Oy(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${r}.${u}`,{x_axis_data_key:i,y_axis_data_key:o,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(o),z_axis_data_key:s(l)}}catch(r){throw console.error("[Migration failed]",r),r}}class Vy extends ke{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,s)=>{const{config:i}=r;return{...r,version:2,config:Oy(i,s)}})}}const By={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Vy,name:"bar-3d",viewRender:Py,configRender:Ay,createConfig(){return{version:2,config:v.cloneDeep(va)}},translation:Ly},qy=({disabled:e,value:t,onChange:r})=>{const s=i=>{i&&r(i)};return n.jsxs(a.Box,{sx:{position:"relative"},children:[e&&n.jsx(a.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),n.jsx(ht,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function ot({enabled:e,func_content:t}){return(r,s)=>{if(!e)return r;try{return new Function(`return ${t}`)()(r,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),r}}}function Xe(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
93
93
  `)}}const At=f.forwardRef(({value:e,onChange:t,triggerButtonText:r},s)=>{const{t:i}=_.useTranslation(),[o,{setTrue:l,setFalse:c}]=Y.useBoolean(),[u,d]=f.useState(e);f.useEffect(()=>{d(e)},[e]);const p=D=>{d({...u,enabled:D})},h=()=>{c();const{enabled:D,func_content:T}=u,z={enabled:D,func_content:T};d(z),t(z)},x=()=>{c(),d(e)},b=D=>{d(T=>({...T,func_content:D}))},m=()=>{b(Xe().func_content)},j=r??i("chart.axis.customize_label");return n.jsxs(n.Fragment,{children:[n.jsx(a.Button,{variant:"filled",color:"grape",leftSection:n.jsx(C.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:j}),n.jsx(a.Modal,{size:800,title:j,opened:o,onClose:c,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:o&&n.jsxs(a.Stack,{children:[n.jsx(a.Checkbox,{mt:10,label:i("common.enabled"),checked:u.enabled,onChange:D=>p(D.currentTarget.checked)}),n.jsx(qy,{value:u.func_content,onChange:b,disabled:!u.enabled}),n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Button,{onClick:m,color:"red",leftSection:n.jsx(C.IconRecycle,{size:20}),children:i("common.actions.reset_to_default")}),n.jsxs(a.Group,{justify:"flex-end",children:[n.jsx(a.Button,{onClick:x,variant:"subtle",children:i("common.actions.cancel")}),n.jsx(a.Button,{color:"green",leftSection:n.jsx(C.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 Cd(){return v.cloneDeep(Tn)}const Ny=[{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:"点击箱体、散点或异常点"}}}}],Sd={id:"builtin:echarts:click-echart:series",displayName:"viz.boxplot.click_series.label",nameRender:Gy,configRender:$y,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 $y(e){return n.jsx(n.Fragment,{})}function Gy(e){const{t}=_.useTranslation();return n.jsx(a.Text,{size:"sm",children:t("viz.boxplot.click_series.label")})}const ms=f.forwardRef(({sectionTitle:e,value:t,onChange:r},s)=>{const{t:i,i18n:o}=_.useTranslation(),l=u=>d=>{const p=v.cloneDeep(t);v.set(p,u,d),r(p)},c=f.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"}],[o.language]);return n.jsxs(a.Stack,{gap:0,children:[e&&n.jsx(a.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",styles:{label:{color:"dimmed"}}}),n.jsxs(a.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(a.NumberInput,{label:i("chart.axis.overflow.max_width"),hideControls:!0,value:t.width,onChange:l("width")}),n.jsx(a.Select,{label:i("chart.axis.overflow.label"),data:c,value:t.overflow,onChange:l("overflow")}),n.jsx(a.TextInput,{label:i("chart.axis.overflow.ellipsis"),value:t.ellipsis,disabled:!0})]})]})}),Lt=f.forwardRef(({value:e,onChange:t},r)=>{const{t:s}=_.useTranslation(),i=l=>{t({...e,on_axis:l})},o=l=>{t({...e,in_tooltip:l})};return n.jsxs(a.Stack,{ref:r,gap:0,children:[n.jsx(ms,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.on_axis,onChange:i}),n.jsx(ms,{sectionTitle:s("chart.axis.overflow.section_title.in_tooltip"),value:e.in_tooltip,onChange:o})]})});function lt(){return{on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}}}function wt({overflow:e,width:t}){const r={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],s=e==="truncate"?"nowrap":"initial",i={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
94
94
  max-width: ${t}px;
95
95
  word-break: ${r};
@@ -477,8 +477,8 @@ React keys must be passed directly to JSX without using spread:
477
477
  }
478
478
  `,eh=()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(a.Button,{variant:"subtle",size:"compact-sm",onClick:()=>r(s=>!s),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),n.jsx(a.Collapse,{in:t,children:n.jsx(Dt.CodeHighlight,{language:"typescript",withCopyButton:!1,code:o3})})]})},l3={[Q.Checkbox]:"true",[Q.DateRange]:"[new Date('2023-01-01 00:00:00'), new Date('2024-01-01 00:00:00')]",[Q.MultiSelect]:"[]",[Q.Select]:'""',[Q.TreeSelect]:"[]",[Q.TreeSingleSelect]:'""',[Q.TextInput]:'""'},c3=e=>["function getDefaultValue(filter, utils, context) {",` return ${l3[e]};`,"}"].join(`
479
479
  `),Dn=k.observer(({filter:e})=>{const{t}=_.useTranslation();return n.jsx(ga,{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:c3(e.type),triggerButtonProps:{size:"xs",color:"grape",sx:{flexGrow:0,alignSelf:"flex-start"},leftSection:n.jsx(C.IconMathFunction,{size:16})},description:n.jsx(a.Alert,{title:t("filter.field.custom_default_value.tips"),color:"gray",mb:16,children:n.jsxs(a.List,{size:"xs",type:"ordered",children:[n.jsx(a.List.Item,{children:t("filter.field.custom_default_value.tip_1")}),n.jsx(a.List.Item,{children:t("filter.field.custom_default_value.tip_2")})]})})})}),Es=k.observer(({value:e,onChange:t})=>{const{t:r}=_.useTranslation(),s=se(),i=re(),o=f.useMemo(()=>i.queries.options,[i.queries.current]),l=o.length===0,c=u=>{s.editor.setPath(["_QUERIES_",u])};return n.jsx(a.Select,{label:n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Text,{fw:500,size:"sm",children:r("filter.widget.common.use_query_data_as_options")}),e&&n.jsx(a.Button,{size:"xs",leftSection:n.jsx(C.IconArrowCurveRight,{size:16}),variant:"subtle",color:"blue",onClick:()=>c(e),children:r("query.open")})]}),data:o,value:e,onChange:Se(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"}}})}),u3=k.observer(function({filter:t}){const{t:r}=_.useTranslation(),s=t.config;return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Checkbox,{checked:s.required,onChange:i=>s.setRequired(i.currentTarget.checked),label:r("filter.widget.select.required")}),n.jsx(Dn,{filter:t})]}),n.jsx(a.TextInput,{label:r("filter.widget.common.min_width"),value:s.min_width,onChange:i=>s.setMinWidth(i.currentTarget.value),placeholder:"200px"}),n.jsx(a.Divider,{label:r("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),n.jsx(a.Checkbox,{checked:s.treeCheckStrictly,onChange:i=>s.setTreeCheckStrictly(i.currentTarget.checked),label:r("filter.widget.tree_select.strictly")}),n.jsx(a.NumberInput,{value:s.default_selection_count,onChange:s.setDefaultSelectionCount,label:r("filter.widget.common.default_selection_count")}),n.jsx(Es,{value:s.options_query_id,onChange:s.setOptionsQueryID}),n.jsx(eh,{})]})}),xo=({errorMessage:e})=>{const{t}=_.useTranslation();return e?n.jsx(a.Text,{c:"red",size:"12px",children:e}):n.jsx(a.Text,{c:"dimmed",size:"12px",children:t("filter.widget.common.selector_option_empty")})},d3=({rotate:e,onClick:t})=>n.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:n.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"})}),th=({expanded:e,isLeaf:t,value:r,onClick:s,...i})=>t?n.jsx("span",{style:{width:"14px",display:"inline-block"}}):n.jsx(d3,{rotate:e?"0":"-90",onClick:s,...i}),p3=({onClick:e})=>n.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:[n.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),n.jsx("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),n.jsx("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),n.jsx("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),nh=({onClick:e,...t})=>n.jsx(p3,{onClick:e,...t}),h3=on.createStyles((e,{radius:t=4,width:r,name:s})=>({root:{borderRadius:a.getRadius(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",position:"absolute",width:`${r} !important`,"&.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:"0px 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-treenode-disabled":{color:"#aaa",".rc-tree-select-tree-title, .rc-tree-select-tree-iconEle":{cursor:"not-allowed"},".rc-tree-select-tree-iconEle":{"svg .border":{fill:"#ced4da"}}},".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",width:"100%",padding:"8px 0",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"}}}})),g3=({disabled:e,radius:t,style:r,label:s,value:i,onChange:o,treeData:l,errorMessage:c,required:u,treeCheckStrictly:d})=>{const{t:p}=_.useTranslation(),{classes:h,cx:x}=h3({radius:t,width:r.width,name:"FilterTreeSelectWidget"}),[b,m]=f.useState(!1),j=T=>{m(T)},D=b&&(i==null?void 0:i.length)>0;return n.jsxs(a.Stack,{gap:3,children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsxs(a.Text,{className:h.label,size:"sm",children:[s,u&&n.jsx("span",{className:h.required,"aria-hidden":"true",children:"*"})]}),D&&n.jsx(a.Tooltip,{label:p("filter.widget.common.x_selected",{count:i.length}),children:n.jsx(a.Badge,{variant:"light",children:i.length})})]}),n.jsx(Ys,{disabled:e,allowClear:{clearIcon:n.jsx(a.CloseButton,{size:"sm"})},treeCheckStrictly:d,labelInValue:!0,className:x(h.root,"check-select"),dropdownClassName:x(h.dropdown,""),onDropdownVisibleChange:j,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:r,listHeight:510,treeLine:!0,switcherIcon:th,treeIcon:nh,maxTagTextLength:10,value:i,treeData:l,notFoundContent:n.jsx(xo,{errorMessage:c}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:Ys.SHOW_PARENT,onChange:o,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:()=>p("filter.widget.common.x_selected",{count:i.length})})]})},f3=k.observer(({label:e,config:t,value:r,onChange:s})=>{const{treeData:i,treeDataLoading:o,errorMessage:l}=t,c=x=>{const b=x.map(m=>m.value);s(b,!1)},u=f.useMemo(()=>t.initialSelection(r),[r,t.initialSelection,o]),d=t.min_width?t.min_width:"200px",h=!!t.options_query_id?o:!1;return n.jsx(g3,{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})}),x3=k.observer(({filter:e})=>{const{t}=_.useTranslation(),r=e.config;return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Checkbox,{checked:r.required,onChange:s=>r.setRequired(s.currentTarget.checked),label:t("filter.widget.select.required")}),n.jsx(Dn,{filter:e})]}),n.jsx(a.TextInput,{label:t("filter.widget.common.min_width"),value:r.min_width,onChange:s=>r.setMinWidth(s.currentTarget.value),placeholder:"200px"}),n.jsx(a.Divider,{label:t("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),n.jsx(a.Checkbox,{checked:r.default_selection_count===1,onChange:s=>r.setDefaultSelectionCount(s.currentTarget.checked?1:0),label:t("filter.widget.tree_single_select.select_first_option_by_default")}),n.jsx(Es,{value:r.options_query_id,onChange:r.setOptionsQueryID}),n.jsx(eh,{})]})}),m3=on.createStyles((e,{radius:t=4,width:r,name:s})=>({root:{borderRadius:a.getRadius(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-focused":{".rc-tree-select-selection-item":{color:"#aaa"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"calc(2.25rem / 3)",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",position:"relative"},".rc-tree-select-selection-search":{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:1,".rc-tree-select-selection-search-input":{height:"36px",paddingLeft:"calc(2.25rem / 3)",textOverflow:"ellipsis"}},".rc-tree-select-selection-item":{position:"absolute",top:0,bottom:0,left:0,paddingLeft:"calc(2.25rem / 3)",color:"#000",lineHeight:"36px",fontSize:"0.875rem",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",transition:"color 200ms ease"},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",position:"absolute",width:`${r} !important`,"&.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:"0px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden",transition:"background-color 200ms ease","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-selected":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-disabled":{color:"#aaa",".rc-tree-select-tree-title, .rc-tree-select-tree-iconEle":{cursor:"not-allowed"},".rc-tree-select-tree-iconEle":{"svg .border":{fill:"#ced4da"}}},".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",width:"100%",padding:"8px 0","&: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"}}}})),b3=({disabled:e,radius:t,style:r,label:s,value:i,onChange:o,treeData:l,errorMessage:c,required:u})=>{_.useTranslation();const{classes:d,cx:p}=m3({radius:t,width:r.width,name:"FilterTreeSelectWidget"});return n.jsxs(a.Stack,{gap:3,children:[n.jsx(a.Group,{justify:"space-between",children:n.jsxs(a.Text,{className:d.label,size:"sm",children:[s,u&&n.jsx("span",{className:d.required,"aria-hidden":"true",children:"*"})]})}),n.jsx(Ys,{disabled:e,allowClear:{clearIcon:n.jsx(a.CloseButton,{size:"sm"})},multiple:!1,labelInValue:!0,className:p(d.root,"check-select"),dropdownClassName:p(d.dropdown,""),transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:r,listHeight:510,treeLine:!0,switcherIcon:th,treeIcon:nh,value:i,treeData:l,notFoundContent:n.jsx(xo,{errorMessage:c}),treeNodeFilterProp:"filterBasis",treeCheckable:!1,onChange:o,onSelect:console.log,showSearch:!0})]})},y3=k.observer(({label:e,config:t,value:r,onChange:s})=>{const{treeData:i,treeDataLoading:o,errorMessage:l}=t,c=x=>{s(x?x.value:null,!1)},u=f.useMemo(()=>t.initialSelection(r),[r,t.initialSelection,t.treeDataLoading]),d=t.min_width?t.min_width:"200px",h=!!t.options_query_id?o:!1;return n.jsx(b3,{disabled:h,style:{width:d,maxWidth:h?d:"unset",borderColor:"#e9ecef"},value:u,onChange:c,treeData:i,errorMessage:l,label:e,required:t.required})});function v3(e){return df.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function _3(e){return e.map(t=>{const{label:r,description:s,...i}=t,o={...i,filterBasis:`${r}___${s??""}`,description:s,label:r};return s&&(o.label=f.createElement("div",{},[f.createElement(a.Text,{key:0,title:t.label},t.label),f.createElement(a.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description},t.description)])),o})}const rh=g.types.compose("FilterConfigModel_BaseTreeSelect",g.types.model({min_width:g.types.optional(g.types.string,"")}),uo).views(e=>({get plainData(){const{data:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeData(){const t=this.plainData,r=_3(t);return v3(r)},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"}})).actions(e=>({setMinWidth(t){e.min_width=t}})),mo=g.types.compose("FilterTreeSelectConfigMeta",g.types.model({_name:g.types.literal("tree-select"),default_value:g.types.optional(g.types.array(g.types.string),[]),treeCheckStrictly:g.types.optional(g.types.boolean,!1)}),rh).views(e=>({get json(){const{_name:t,default_value:r,required:s,min_width:i,static_options:o,options_query_id:l,default_selection_count:c,treeCheckStrictly:u}=e;return{_name:t,required:!!s,min_width:i,default_value:r,static_options:o,options_query_id:l,treeCheckStrictly:u,default_selection_count:c}},get defaultSelection(){const t=e.filter.formattedDefaultValue;if(Array.isArray(t)&&t.length>0)return t;const{default_selection_count:r}=e;return r?e.treeData.slice(0,r).map(i=>i.value):[]},valueObjects(t){const r=new Set(t);return e.plainData.filter(s=>r.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=g.cast(t)},setTreeCheckStrictly(t){e.treeCheckStrictly=t},applyDefaultSelection(){if(e.optionsLoading)return;const t=e.filter.value,r=new Set(e.plainData.map(i=>i.value)),s=(t??[]).filter(i=>r.has(i));s.length>0?e.filter.setValue(s):e.filter.setValue(e.defaultSelection)},afterCreate(){g.addDisposer(e,te.reaction(()=>JSON.stringify(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!1,delay:0}))}})),sh=()=>mo.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),bo=g.types.compose("FilterTreeSingleSelectConfigMeta",g.types.model({_name:g.types.literal("tree-single-select"),default_value:g.types.optional(g.types.string,"")}),rh).views(e=>({get json(){const{_name:t,default_value:r,required:s,min_width:i,static_options:o,options_query_id:l,default_selection_count:c}=e;return{_name:t,required:!!s,min_width:i,default_value:r,static_options:o,options_query_id:l,default_selection_count:c}},get selectFirstByDefault(){return e.default_selection_count===1},get defaultSelection(){if(e.treeDataLoading)return"";const t=e.filter.formattedDefaultValue;return t||(this.selectFirstByDefault&&e.treeData.length>0?e.treeData[0].value:"")},valueObject(t){if(t)return e.plainData.find(r=>r.value===t)},initialSelection(t){if(t)return this.valueObject(t)},truthy(t){return typeof t=="string"&&t!==""}})).actions(e=>({setDefaultValue(t){e.default_value=t},applyDefaultSelection(){if(e.treeDataLoading)return;const t=e.filter.value;e.optionValuesSet.has(t)?e.filter.setValue(t):e.filter.setValue(e.defaultSelection)},afterCreate(){g.addDisposer(e,te.reaction(()=>te.toJS(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!1,delay:0}))}})),ih=()=>bo.create({_name:"tree-single-select",default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),yo=g.types.model("FilterMeta",{id:g.types.identifier,key:g.types.string,label:g.types.string,order:g.types.number,visibleInViewsIDs:g.types.array(g.types.string),auto_submit:g.types.optional(g.types.boolean,!1),default_value_func:g.types.optional(g.types.string,""),type:g.types.enumeration("DashboardFilterType",[Q.Select,Q.MultiSelect,Q.TreeSelect,Q.TreeSingleSelect,Q.TextInput,Q.Checkbox,Q.DateRange]),config:g.types.union(ho,po,mo,bo,go,oo,co)}).views(e=>({get contentModel(){return g.getRoot(e).content},get filters(){return this.contentModel.filters},get value(){return this.filters.values[e.key]},get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==Q.TreeSelect&&e.type!==Q.TreeSingleSelect},get usingDefaultValueFunc(){return!!e.default_value_func},get formattedDefaultValue(){return this.filters.formattedDefaultValues[e.key]},get auto_submit_supported(){return[Q.Select,Q.Checkbox,Q.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:r,label:s,order:i,visibleInViewsIDs:o,default_value_func:l,auto_submit:c,type:u,config:d}=e;return{id:t,key:r,type:u,label:s,order:i,config:d.json,auto_submit:c,visibleInViewsIDs:te.toJS(o),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},setValue(t){e.filters.setValueByKey(e.key,t)},setLabel(t){e.label=t},setOrder(t){const r=Number(t);Number.isFinite(r)&&(e.order=r)},setType(t){switch(t){case Q.Select:e.config=Jp();break;case Q.MultiSelect:e.config=Zp();break;case Q.TreeSelect:e.config=sh();break;case Q.TreeSingleSelect:e.config=ih();break;case Q.TextInput:e.config=fo();break;case Q.Checkbox:e.config=Rp();break;case Q.DateRange:e.config=Xp();break;default:return}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 F=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(F||{});const vo=g.types.model("ViewDivisionConfig",{_name:g.types.literal(F.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})),ah=()=>vo.create({_name:F.Division}),j3=g.types.model("CustomModalTitleModel",{enabled:g.types.optional(g.types.boolean,!1),func_content:g.types.optional(g.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:r}=e;return{enabled:t,func_content:r}},get value(){const{enabled:t,func_content:r}=e,s=g.getParent(e,2),i=g.getRoot(e);if(!t)return s.name;try{const o={filters:i.content.filters.valuesForPayload,context:i.context.current};return new Function(`return ${r}`)()(o)}catch(o){return console.error(o),s.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:r}){e.enabled=t,e.func_content=r}})),Ps={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
480
- `)},_o=g.types.model("ViewModalConfig",{_name:g.types.literal(F.Modal),width:g.types.string,height:g.types.string,custom_modal_title:g.types.optional(j3,Ps)}).views(e=>({get json(){const{_name:t,width:r,height:s,custom_modal_title:i}=e;return{_name:t,width:r,height:s,custom_modal_title:i.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),oh=()=>_o.create({_name:F.Modal,width:"90vw",height:"90vh"}),w3=g.types.model("ViewTabsTabModel",{id:g.types.identifier,name:g.types.string,view_id:g.types.string,color:g.types.optional(g.types.string,""),order:g.types.optional(g.types.number,0)}).views(e=>({get json(){const{id:t,name:r,view_id:s,color:i,order:o}=e;return{id:t,name:r,color:i,order:o,view_id:s}}})).actions(e=>({setName(t){e.name=t},setViewID(t){t&&(e.view_id=t)},setColor(t){e.color=t},setOrder(t){typeof t!="string"&&(e.order=t)}})),jo=g.types.model("ViewTabsConfig",{_name:g.types.literal(F.Modal),tabs:g.types.optional(g.types.array(w3),[]),variant:g.types.optional(g.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:g.types.optional(g.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:g.types.optional(g.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:r,orientation:s,tabs:i,grow:o}=e;return{grow:o,tabs:i.map(l=>l.json),_name:t,variant:r,orientation:s}},get tabsInOrder(){return v.sortBy(e.tabs,"order")}})).actions(e=>({setVariant(t){t&&(e.variant=t)},setOrientation(t){t&&(e.orientation=t)},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=g.cast(t)},addTab(){const t=ze.randomId(),r={id:t,name:t,view_id:""};e.tabs.push(r)},removeTab(t){e.tabs.splice(t,1)}})),lh=()=>jo.create({_name:F.Modal,tabs:[]}),ch=g.types.model({id:g.types.identifier,name:g.types.string,type:g.types.enumeration("EViewComponentType",[F.Division,F.Modal,F.Tabs]),config:g.types.union(vo,_o,jo),panelIDs:g.types.optional(g.types.array(g.types.string),[])}).views(e=>({get json(){const{id:t,name:r,type:s,config:i}=e;return{id:t,name:r,type:s,config:i.json,panelIDs:e.panelIDs.map(o=>o)}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case F.Division:e.config=ah();break;case F.Modal:e.config=oh();break;case F.Tabs:e.config=lh();break;default:return}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},appendPanelIDs(t){e.panelIDs.push(...t)},removePanelID(t){const r=e.panelIDs.filter(s=>s!==t);e.panelIDs.length=0,e.panelIDs.push(...r)}})),nn="13.45.0",C3={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:F.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:nn,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},wo=g.types.model("DataSourceMetaModel",{id:g.types.string,type:g.types.enumeration("DataSourceType",[J.HTTP,J.MySQL,J.Postgresql,J.MericoMetricSystem]),key:g.types.string,config:g.types.frozen()}),uh=g.types.model("DataSourcesMetaModel",{list:g.types.optional(g.types.array(wo),[])}).views(e=>({find({type:t,key:r}){return e.list.find(s=>s.key===r&&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)}})),dh=g.types.model({id:g.types.string,content:g.types.string,create_time:g.types.string,update_time:g.types.string,is_preset:g.types.boolean}),Co=g.types.model("GlobalSQLSnippetsMeta",{list:g.types.optional(g.types.array(dh),[])}).views(e=>({find(t){return e.list.find(r=>r.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)}})),As=g.types.model("ContextMeta",{current:g.types.optional(g.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,r){e.current[t]=r}}));function So(e){return As.create({current:e})}const To=g.types.compose("ViewRenderModel",ch,g.types.model({tab:g.types.optional(g.types.string,"")})).views(e=>({get tabs(){return e.config.tabs},get tabInfo(){const t=this.tabs.find(r=>r.id===e.tab);return t?{id:t.id,name:t.name}:null},get tabView(){return e.type!==F.Tabs?null:this.tabs.find(t=>t.id===e.tab)},get tabViewID(){return this.tabView?this.tabView.view_id??"":""},get contentModel(){return g.getParent(e,3)},get panels(){if(e.type!==F.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs);const t=this.tabViewID,r=this.contentModel.views.findByID(t);return(r==null?void 0:r.panels)??[]},get renderViewIDs(){const t=[e.id];return e.type===F.Tabs&&t.push(this.tabViewID),t},async downloadScreenshot(t){const r=t.offsetWidth*2+10,s=t.offsetHeight*2+10,i=new Tl,o=new Date().getTime(),l=await Sl.toBlob(t,{bgcolor:"white",width:r,height:s,style:{transformOrigin:"0 0",transform:"scale(2)"}});i.file(`${e.name}_${o}.png`,l),i.file(`dashboard_state_${o}.json`,JSON.stringify(this.contentModel.dashboardState,null,4)),i.generateAsync({type:"blob"}).then(c=>{Vr.saveAs(c,`${e.name}_${o}.zip`)}).catch(c=>{console.error(c),Nt.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??""}})),ko=g.types.model("ViewsRenderModel",{current:g.types.optional(g.types.array(To),[]),visibleViewIDs:g.types.array(g.types.string)}).views(e=>({get json(){return e.current.map(t=>Zt(t.json))},get idMap(){const t=new Map;return e.current.forEach(r=>{t.set(r.id,r)}),t},findByID(t){return e.current.find(r=>r.id===t)},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:r})=>r===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:r})=>t.has(r))},get firstVisibleTabsView(){return this.visibleViews.find(t=>t.type===F.Tabs)},get firstVisibleTabsViewActiveTab(){const t=this.firstVisibleTabsView;return t?t.tabInfo:null},get firstVisibleTabsViewActiveTabStr(){return JSON.stringify(this.firstVisibleTabsViewActiveTab)}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(s=>s)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const r=e.visibleViewIDs.findIndex(s=>s===t);r!==-1&&e.visibleViewIDs.splice(r,1)},setFirstVisibleTabsViewActiveTab(t){if(!t)return;const r=e.firstVisibleTabsView;r==null||r.setTabByTabInfo(t)}}));function ph(e,t){const r=e.length>0?[e[0].id]:[],s=e.map(i=>{const{_name:o=i.type}=i.config,l={...i,tab:"",config:{...i.config,_name:o},panelIDs:i.panelIDs};if(i.type===F.Tabs){let c=v.minBy(i.config.tabs,u=>u.order);!c&&i.config.tabs.length>0&&(c=i.config.tabs[0]),l.tab=(c==null?void 0:c.id)??""}return l});return t&&(s[0].tab=t.id),{current:s,visibleViewIDs:r}}const S3=new uf.AsyncParser({withBOM:!0});async function hh(e){return!Array.isArray(e)||e.length===0?"":await S3.parse(e).promise()}async function gh(e,t){const r=await hh(t),s=new Blob([r],{type:"text/csv"});Vr.saveAs(s,`${e}.csv`)}function fh(e){const t=new Tl,r=e.map(async({id:s,data:i})=>{const o=await hh(i);t.file(`${s}.csv`,o)});Promise.all(r).then(()=>{t.generateAsync({type:"blob"}).then(s=>{Vr.saveAs(s,"dashboard_data.zip")})}).catch(s=>{console.error(s),Nt.notifications.show({color:"red",title:"Failed to download data",message:s.message})})}function Jn(e,t){const r=new Blob([t],{type:"application/json"});Vr.saveAs(r,`${e}.json`)}const Do=Lp.views(e=>({get contentModel(){return g.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(r=>r.id===t)},get data(){return this.queries.reduce((t,r)=>(t[r.id]=r.data,t),{})},get variableStrings(){return fd(e.variables,this.data)},get variableAggValueMap(){const t={},r=this.data;return e.variables.reduce((s,i)=>(s[i.name]=Qt(i,r),s),t),t},get variableValueMap(){const t={},r=this.variableAggValueMap;return e.variables.reduce((s,i)=>(s[i.name]=jt(i,r[i.name]),s),t),t},get variableStyleMap(){const t=this.variableValueMap,r={};return e.variables.reduce((s,i)=>{const o=lx(i.color,t[i.name]);return s[i.name]={color:o,"font-size":i.size,"font-weight":i.weight,variable:i},s},r),r},get dataLoading(){return this.queries.some(t=>t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(o=>!o.runByConditionsMet);if(t.length===0)return"";const r=new Set,s=new Set;t.forEach(o=>{const l=o.conditionNames;l.context.forEach(c=>r.add(c)),l.filters.forEach(c=>s.add(c))});const i=[];return r.size>0&&i.push(`context: ${Array.from(r).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??t.metricQueryPayloadErrorString).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(r=>r.json),layouts:e.contentModel.layouts.jsonByPanelIDSet(new Set([e.id]))}},downloadSchema(){const{panel:t,queries:r,layouts:s}=this.getSchema(),o=JSON.stringify({panels:[t],definition:{queries:r},layouts:s,version:nn},null,2),l=e.name;Jn(l,o)}}));function xh(e){return{id:e,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:Ra.name,conf:Ra.createConfig()},style:{border:{enabled:!0}}}}const zo=g.types.model("PanelsRenderModel",{list:g.types.optional(g.types.array(Do),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(r=>r.id===t)},get idMap(){const t=new Map;return e.list.forEach(r=>{t.set(r.id,r)}),t}})).views(e=>({panelsByIDs(t){const r=[];return t.forEach(s=>{const i=e.idMap.get(s);i?r.push(i):console.warn(`Panel is not found, id:${s}`)}),r}}));function mh(e){const t=e.config,r=t.default_value;return r===void 0?r:t._name==="date-range"?Yp(t):r}function T3(e,t){const r=e.default_value_func;try{const s=new Function(`return ${r}`)()(e,zt,t);return e.config._name==="date-range"&&Array.isArray(s)?{value:s,shortcut:null}:s}catch(s){return console.error(s),mh(e)}}function bh(e,t){var r;return(r=e.default_value_func)!=null&&r.trim()?T3(e,t):mh(e)}function yh(e,t){return e.reduce((r,s)=>(r[s.key]=bh(s,t),r),{})}function vh(e,t){const r={};return Object.entries(t).forEach(([s,i])=>{const o=e[s];return typeof i=="object"&&"shortcut"in i&&Array.isArray(o)?r[s]={value:o,shortcut:null}:r[s]=o??i,r}),r}const Io=g.types.model("FiltersRenderModel",{current:g.types.optional(g.types.array(yo),[]),values:g.types.optional(g.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get valuesString(){return JSON.stringify(e.values)},get filter(){return g.getParent(e)},get valuesForPayload(){const t={};return Object.entries(e.values).forEach(([r,s])=>{t[r]=s;const i=this.findByKey(r);i&&i.config._name==="date-range"&&(t[r]=i.config.dateStringsValue)}),t},get contentModel(){return g.getRoot(e).content},get context(){return this.contentModel.payloadForSQL.context},get initialValuesDep(){return JSON.stringify({filters:e.current.map(({default_value_func:t,config:r})=>({default_value_func:t,config:r})),context:this.contentModel.payloadForSQL.context})},get formattedDefaultValues(){return yh(this.json,this.contentModel.context)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(r=>r.id===t)},findByKey(t){return e.current.find(r=>r.key===t)},findByIDSet(t){return e.current.filter(r=>t.has(r.id))},get inOrder(){return v.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return v.sortBy(e.current.filter(r=>r.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,r)=>(t[r.key]=r.label,t),{})},getSelectOption(t){const r=this.findByID(t);if(!r||!("getSelectOption"in r.config))return null;const s=e.values[r.key];return r.config.getSelectOption(s)}})).actions(e=>({setValues(t){console.debug("⚪️ setting filter values: ",JSON.stringify(t)),e.values=t},patchValues(t){console.debug("⚪️ patching filter values: ",JSON.stringify(t)),e.values=vh(t,e.values)},setValueByKey(t,r){console.debug(`⚪️ setting filter[${t}] to value: `,JSON.stringify(r)),e.values={...e.values,[t]:r}},applyValuesPatch(t){e.values={...e.values,...t}},getValueByKey(t){return e.values[t]},getSchema(t,r){return{filters:e.findByIDSet(new Set(t)).map(o=>({...o.json,visibleInViewsIDs:r?o.json.visibleInViewsIDs:[]})),version:nn}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t,!1),null,2);Jn("Filters",r)}}));function Mo(e,t,r,s){const i={...r,...t},o=yh(e,i),l=vh(s,o);return{current:e,values:l}}const _h=$p.views(e=>({get rootModel(){return g.getRoot(e)},get contentModel(){return this.rootModel.content},get conditionOptions(){if(!g.isAlive(e))return{optionGroups:[],validValues:new Set};const t=new Set,{context:r}=this.contentModel.payloadForSQL,s={group:"context.label",items:Object.keys(r).map(l=>{const c=`context.${l}`;return t.add(c),{label:l,value:c,description:void 0,type:"context"}})},i={group:"filter.labels",items:this.contentModel.filters.keyLabelOptions.map(l=>{const c=`filters.${l.value}`;return t.add(c),{label:l.label,value:c,description:l.value,type:"filter",widget:l.widget}})};return{optionGroups:[s,i],validValues:t}},getConditionOptionsWithInvalidValue(t){const{optionGroups:r,validValues:s}=this.conditionOptions;if(!t||s.has(t))return this.conditionOptions;const i={group:"common.invalid",items:[{label:t,value:t}]};return{optionGroups:[...r,i],validValues:s}},get conditionOptionsWithInvalidRunbys(){const{optionGroups:t,validValues:r}=this.conditionOptions,s={group:"common.invalid",items:[]};return e.run_by.forEach(i=>{r.has(i)||s.items.push({label:i,value:i})}),{optionGroups:[...t,s],validValues:r}},get unmetRunByConditions(){if(!g.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const r=this.contentModel.payloadForSQL;return t.filter(s=>{const i=v.get(r,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(){const t=v.get(e,"config.sql","");return Hs(t,this.payload)},get httpConfigString(){const{context:t,filters:r}=this.payload,{name:s,pre_process:i}=e.json,o=uy(i,t,r);return console.groupCollapsed(`Request config for: ${s}`),console.log(o),console.groupEnd(),JSON.stringify(o)},get typedAsSQL(){return[J.Postgresql,J.MySQL].includes(e.type)},get typedAsHTTP(){return[J.HTTP].includes(e.type)},get isMericoMetricQuery(){return e.type===J.MericoMetricSystem},get isTransform(){return e.type===J.Transform},get reQueryKey(){const t=v.get(e,"config.react_to",[]);if(t.length===0)return"";const r=e.contentModel.payloadForSQL,s=[...t].reduce((i,o)=>(i[o]=v.get(r,o),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,r=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:r,filters:s}},get queries(){return g.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)},get dependencies(){if(!this.typedAsSQL)return[];const t=v.get(e,"config.sql","");if(!t)return[];const r=v.uniq(t.match(gs.sqlSnippet)),s=v.uniq(t.match(gs.filter)),i=v.uniq(t.match(gs.context)),o=[];return r.forEach(l=>{o.push({type:"sql_snippet",key:l,valid:e.contentModel.sqlSnippets.keySet.has(l)})}),s.forEach(l=>{o.push({type:"filter",key:l,valid:e.contentModel.filters.keySet.has(l)})}),i.forEach(l=>{o.push({type:"context",key:l,valid:e.contentModel.mock_context.keySet.has(l)})}),o},get metricQueryPayload(){if(e.type!==J.MericoMetricSystem)return null;const t=this.payload,r=e.config,s=r.filters.reduce((p,h)=>(p[h.dimension]={eq:v.get(t,h.variable)},p),{}),i={id:r.id,type:r.type,filters:s,groupBys:r.groupBys};if(!r.timeQuery.enabled)return i;const{range_variable:o,unit_variable:l}=r.timeQuery,c="YYYY-MM-DD",u="PRC",d={start:"",end:"",unitOfTime:v.get(t,l,""),unitNumber:1,timezone:"PRC",stepKeyFormat:c};if(o){const p=v.get(t,o);Array.isArray(p)&&p.length===2&&(d.start=A(p[0]).tz(u).format(c),d.end=A(p[1]).tz(u).format(c))}return i.timeQuery=d,i},get metricQueryPayloadString(){return this.metricQueryPayload?JSON.stringify(this.metricQueryPayload,null,2):""},get metricQueryPayloadError(){const t=[];if(!this.metricQueryPayload)return t;const r=e.config,{groupBys:s,timeQuery:i}=this.metricQueryPayload;if(s.length===0&&t.push("分组聚合维度:不可为空"),!i)return t;r.groupByValues.length>1&&t.push("分组聚合维度:按时间序列展示时,仅可选择一个聚合维度");const{start:o,end:l,unitOfTime:c}=i;return(!o||!l)&&t.push("时间维度:时间范围不完整"),c||t.push("步长:必选"),t},get metricQueryPayloadErrorString(){return this.metricQueryPayloadError.join(`
481
- `)},get metricQueryPayloadValid(){return this.metricQueryPayload?this.metricQueryPayloadError.length===0:!1}})),Eo=g.types.compose("QueryRenderModel",_h,g.types.model({state:g.types.optional(g.types.enumeration(["idle","loading","error"]),"idle"),data:g.types.optional(g.types.frozen([]),[]),error:g.types.frozen()})).views(e=>({get datasource(){const{key:t,type:r}=e;return e.rootModel.datasources.find({type:r,key:t})},get additionalQueryInfo(){return e.contentModel.getAdditionalQueryInfo(e.id)},get depQueryModels(){const t=v.get(e,"config.dep_query_ids",[]);return e.contentModel.queries.findByIDSet(new Set(t))},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:r}=e.conditionNames;if(t.length===0&&r.length===0)return"Waiting";const s=[];return t.length>0&&s.push(`context: ${t.join(", ")}`),r.length>0&&s.push(`filter${r.length>1?"s":""}: ${r.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:g.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const r=e.payload,s=e.config;e.data=yield*g.toGenerator(fy({payload:r,name:e.name,query:{type:e.type,key:e.key,sql:s.sql,pre_process:e.pre_process,post_process:e.post_process},additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(r){if(pt.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const s=v.get(r,"message","unkown error");e.error=v.get(r,"response.data.detail.message",s),e.state="error"}}}}),runHTTP:g.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:r,key:s,post_process:i}=e.json;let o=JSON.parse(e.httpConfigString);o=ps(e.datasource,o);const l=yield*g.toGenerator(xy({type:r,key:s,configString:JSON.stringify(o),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=hs(e.datasource,l),u=md(i,c,e.contentModel.dashboardState);e.data=u,e.state="idle",e.error=null}catch(r){if(console.error(r),pt.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const s=v.get(r,"message","unkown error");e.error=v.get(r,"response.data.detail.message",s),e.state="error"}}}}),runMericoMetricQuery:g.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet&&e.metricQueryPayloadValid)){e.controller=new AbortController,e.state="loading";try{const{type:r,key:s,post_process:i}=e.json;let o={url:"/buffet/api/metric_management/query",method:"POST",data:e.metricQueryPayload};o=ps(e.datasource,o);const l=yield*g.toGenerator(my({key:s,configString:JSON.stringify(o),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=hs(e.datasource,l),u=md(i,c,e.contentModel.dashboardState);e.data=u.data,e.state="idle",e.error=null}catch(r){if(console.error(r),pt.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const s=v.get(r,"message","unkown error");e.error=v.get(r,"response.data.detail.message",s),e.state="error"}}}}),runTransformation(){e.state="loading";try{const t=e.depQueryModels.map(o=>({id:o.id,name:o.name,data:v.cloneDeep(o.data)})),r=e.contentModel.dashboardState,s=e.pre_process,i=new Function(`return ${s}`)()(t,r,zt);e.data=i,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.isMericoMetricQuery?e.runMericoMetricQuery():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){g.addDisposer(e,te.reaction(()=>{var r,s;if(e.isTransform){const i=e.config;return[e.inUse,e.id,e.key,i.dep_query_ids.toString(),e.pre_process,e.depQueryModelStatesString].join("--")}return e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(r=e.datasource)==null?void 0:r.id}`:e.isMericoMetricQuery?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(s=e.datasource)==null?void 0:s.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},()=>e.fetchData(!1),{fireImmediately:!0,delay:0}))}})),Po=g.types.model("QueriesRenderModel",{current:g.types.optional(g.types.array(Eo),[])}).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(r=>r.id===t)},findByIDSet(t){return e.current.filter(r=>t.has(r.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get contentModel(){return g.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:r,queries:s}=this.contentModel,i=[];t.visibleViews.forEach(c=>{c.panels.forEach(u=>{i.push(...u.queryIDs)})});const o=v.uniq(t.visibleViews.map(c=>c.renderViewIDs).flat());r.current.forEach(c=>{const u=v.get(c,"config.options_query_id");if(!u)return;o.some(p=>c.visibleInViewsIDSet.has(p))&&i.push(u)}),s.findByIDSet(new Set(i)).forEach(c=>{const u=c.config;!c.isTransform||u.dep_query_ids.length===0||i.push(...u.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:r,data:s})=>({id:r,data:s}));fh(t)},downloadDataByQueryIDs(t){const r=new Set(t),s=e.current.filter(i=>r.has(i.id)).map(({name:i,data:o})=>({id:i,data:o}));fh(s)},downloadDataByQueryID(t){const r=e.findByID(t);if(!r){console.log("[downloadDataByQueryID] query not found");return}const{name:s,data:i}=r;gh(s,i)},refetchDataByQueryID(t){const r=e.findByID(t);if(!r){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return r.fetchData(!0)},getSchema(t){return{definition:{queries:e.findByIDSet(new Set(t)).map(i=>i.json)},version:nn}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t),null,2);Jn("Queries",r)}}));function jh(e){return{current:e}}function wh({min:e,max:t}){const r=`${e}px`,s=Number.isFinite(t)?`${t}px`:"∞";return`[${r}, ${s})`}const Ao=g.types.model("LayoutsRenderModel",{list:g.types.array(Fp),currentBreakpoint:g.types.string}).views(e=>({get json(){return e.list.map(t=>t.json)},jsonByPanelIDSet(t){return e.list.map(r=>r.jsonByPanelIDSet(t))},get root(){return g.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 wh(t)},get cols(){const t={};return e.list.forEach(r=>{t[r.id]=36}),t},get breakpoints(){const t={};return e.list.forEach(r=>{t[r.id]=r.breakpoint}),t},get breakpointNameRecord(){const t={};return e.list.forEach(r=>{t[r.name]=r.breakpoint}),t},get breakpointRanges(){const t=e.list.map(r=>({id:r.id,name:r.name,min:r.breakpoint,max:1/0,text:""}));return t.sort((r,s)=>r.min-s.min).forEach((r,s)=>{s!==t.length-1&&(r.max=t[s+1].min)}),t.forEach(r=>{r.text=wh(r)}),t},get breakpointsInfo(){return e.list.map(t=>({id:t.id,name:t.name,breakpoint:t.breakpoint})).sort((t,r)=>t.breakpoint-r.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 r=new Set(t);return this.currentLayoutSet.list.filter(i=>r.has(i.panelID))},gridLayouts(t){const r=new Set(t),s={};return e.list.forEach(i=>{s[i.id]=i.list.filter(o=>r.has(o.panelID)).map(o=>o.layoutProperies)}),s},findItemByPanelID(t){return this.currentLayoutSet.findByPanelID(t)}})).actions(e=>({setCurrentBreakpoint(t){console.log("🔴 onBreakpointChange:",t),e.currentBreakpoint=t},afterCreate(){g.addDisposer(e,te.reaction(()=>e.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),Ch=Qp.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!g.getParent(e,2).findByKey(t)}})),Lo=g.types.model("SQLSnippetsRenderModel",{current:g.types.optional(g.types.array(Ch),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,r)=>(t[r.key]=r.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(r=>r.key===t)},findByKeySet(t){return e.current.filter(r=>t.has(r.key))}})).actions(e=>({getSchema(t){return{definition:{sqlSnippets:e.findByKeySet(new Set(t)).map(i=>i.json)},version:nn}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t),null,2);Jn("SQL Snippets",r)}}));function Sh(e){return{current:e}}function Ir(e,t,r,s){return e.reduce((i,o)=>{try{i[o[t]]=Xs(o[r],s)}catch(l){i[o[t]]=l.message}return i},{})}class Th{constructor(t){N(this,"origin");N(this,"copy");this.origin=t,this.copy=g.clone(t),te.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!v.isEqual(g.getSnapshot(this.origin),g.getSnapshot(this.copy))}commit(){g.applySnapshot(this.origin,g.getSnapshot(this.copy))}reset(){g.applySnapshot(this.copy,g.getSnapshot(this.origin))}update(t){g.applySnapshot(this.copy,t)}}const kh=e=>new Th(e),k3=({description:e,isDescriptionEmpty:t})=>t?null:n.jsx(a.Tooltip,{color:"white",label:n.jsx(Un,{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:n.jsx(a.Box,{sx:{height:"16px",alignSelf:"center"},children:n.jsx(C.IconInfoCircle,{size:16,color:"gray"})})}),D3=k.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:s,...i},value:o,onChange:l})=>n.jsxs(a.Box,{children:[n.jsx(a.Text,{size:"sm",children:" "}),n.jsx(a.Checkbox,{label:n.jsxs(a.Group,{wrap:"nowrap",justify:"space-between",align:"middle",gap:6,children:[n.jsx(a.Box,{sx:{flexGrow:1},children:e}),n.jsx(k3,{description:r,isDescriptionEmpty:s})]}),checked:o||!1,onChange:c=>l(c.currentTarget.checked),...i,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),z3=({value:e,onChange:t,close:r,max_days:s,allowSingleDateInRange:i})=>{const{i18n:o}=_.useTranslation(),l=e.value,[c,u]=l,d=f.useMemo(()=>c||new Date,[c]),p=f.useMemo(()=>{if(c&&!u)return c},[c,u]),h=f.useMemo(()=>{if(c&&!u&&s>0)return A(c).add(s-1,"days").toDate()},[c,u,s]),x=b=>{const[m,j]=b;t({value:b,shortcut:null}),m&&j&&r()};return n.jsx(_l.DatePicker,{defaultDate:d,numberOfColumns:2,type:"range",value:l,onChange:x,onNextMonth:console.log,minDate:p,maxDate:h,allowSingleDateInRange:i,locale:o.language})},I3=({begin:e,end:t})=>{const{t:r}=_.useTranslation(),s=f.useMemo(()=>!t&&!e?Number.NaN:A(t).diff(A(e),"days")+1,[e,t]);if(Number.isNaN(s))return n.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const i=s===1?r("filter.widget.date_range.one_day"):r("filter.widget.date_range.x_days",{count:s});return n.jsx(a.Tooltip,{label:i,children:n.jsx(a.Badge,{size:"sm",variant:"light",children:s})})},M3=({max_days:e})=>{const{t}=_.useTranslation();return e?n.jsxs(n.Fragment,{children:[n.jsx(a.Group,{justify:"flex-end",children:n.jsx(a.Badge,{size:"xs",variant:"light",children:t("filter.widget.date_range.x_max_days",{max_days:e})})}),n.jsx(a.Divider,{variant:"dashed",my:10})]}):null},E3=({onChange:e})=>{const{t,i18n:r}=_.useTranslation(),s=l=>()=>{const c=l();e(c)},i=f.useMemo(()=>Up(),[]),o=r.language==="zh";return n.jsxs(n.Fragment,{children:[n.jsx(a.Divider,{variant:"dashed",my:10}),n.jsx(a.Table,{withTableBorder:!1,sx:{"tbody > tr":{border:"none"},"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:n.jsx(a.Table.Tbody,{children:Object.entries(i).map(([l,c])=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:n.jsx(a.Text,{size:"xs",c:"#555",fw:500,sx:{textAlignLast:"justify"},children:t(`filter.widget.date_range.shortcut.${l}.label`)})}),c.map(({key:u,value:d,getRange:p})=>n.jsx(a.Table.Td,{children:n.jsx(a.Button,{size:"compact-xs",variant:"subtle",onClick:s(p),children:t(`filter.widget.date_range.shortcut.${l}.${o?"full.":""}${u}`)})},u))]},l))})})]})},Dh=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),P3=({label:e,required:t,value:r,onChange:s,max_days:i,allowSingleDateInRange:o,inputFormat:l,disabled:c})=>{const{t:u}=_.useTranslation(),[d,{open:p,close:h}]=ze.useDisclosure(!1),[x,b]=r.value,m=x?A(x).format(l):"",j=b?A(b).format(l):"";return n.jsxs(a.Popover,{opened:d,onClose:h,position:"bottom-start",shadow:"md",children:[n.jsxs(a.Group,{justify:"flex-start",grow:!0,wrap:"nowrap",gap:0,w:"288px",sx:{marginTop:"3px"},children:[n.jsx(a.Popover.Target,{children:n.jsx(a.TextInput,{label:e,labelProps:{title:e},required:t,leftSection:n.jsx(C.IconCalendar,{size:16}),placeholder:u("filter.widget.date_range.start_date"),readOnly:!0,disabled:c,value:m,onFocus:p,styles:Dh(d),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},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to left, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})}),n.jsx(a.TextInput,{label:n.jsx(a.Group,{justify:"flex-end",children:n.jsx(I3,{begin:x,end:b})}),leftSection:n.jsx(C.IconMinus,{size:16}),placeholder:u("filter.widget.date_range.end_date"),readOnly:!0,disabled:!x||c,value:j,onFocus:p,styles:Dh(d),sx:{".mantine-Input-section":{transform:"translateX(-18px)"},".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}}})]}),n.jsxs(a.Popover.Dropdown,{p:"sm",children:[n.jsx(M3,{max_days:i}),n.jsx(z3,{value:r,onChange:s,close:h,allowSingleDateInRange:o,max_days:i}),n.jsx(E3,{onChange:s})]})]})},zh={value:[null,null],shortcut:null},Ih=k.observer(({label:e,config:t,value:r=zh,onChange:s,disabled:i})=>{const{inputFormat:o,required:l,max_days:c,allowSingleDateInRange:u}=t,d=f.useMemo(()=>{const p=lo(r.shortcut);return p||(Array.isArray(r.value)?r:zh)},[r]);return n.jsx(P3,{label:e,value:d,onChange:s,inputFormat:o,allowSingleDateInRange:u,max_days:c,required:l,disabled:i})}),A3=on.createStyles((e,{radius:t=4,name:r,...s})=>({root:{borderRadius:a.getRadius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef",...s,"&.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"}}})),L3=({disabled:e,radius:t,style:r,label:s,value:i,onChange:o,options:l,errorMessage:c,required:u})=>{const{t:d}=_.useTranslation(),{classes:p,cx:h}=A3({radius:t,name:"MultiSelectWidget"}),[x,b]=f.useState(!1),m=I=>{b(I)},j=x&&(i==null?void 0:i.length)>0,[D,T]=f.useState(""),z=f.useMemo(()=>{if(!D)return l;const I=D.toLowerCase(),M=P=>{var ae;return((ae=P.description)==null?void 0:ae.toLowerCase().includes(I))||P.label.toLowerCase().includes(I)};return l.filter(M)},[D,l]);return n.jsxs(a.Stack,{gap:3,children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsxs(a.Text,{className:p.label,size:"sm",children:[s,u&&n.jsx("span",{className:p.required,"aria-hidden":"true",children:"*"})]}),j&&n.jsx(a.Tooltip,{label:d("filter.widget.common.x_selected",{count:i.length}),children:n.jsx(a.Badge,{variant:"light",children:i.length})})]}),n.jsx(kl,{disabled:e,allowClear:!0,className:h(p.root,"check-select"),dropdownClassName:h(p.dropdown,""),onDropdownVisibleChange:m,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:r,clearIcon:()=>n.jsx(a.CloseButton,{size:"sm"}),value:i,onChange:o,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:n.jsx(xo,{errorMessage:c}),maxTagTextLength:10,maxTagPlaceholder:I=>d("filter.widget.common.x_selected",{count:I.length}),searchValue:D,onSearch:T,filterOption:!1,children:z.map(I=>n.jsxs(kl.Option,{title:I.label,children:[n.jsx(a.Text,{size:"sm","data-role":"label",children:I.label}),I.description&&n.jsx(a.Text,{size:"xs",c:"dimmed","data-role":"description",children:I.description})]},I.value))})]})},O3=k.observer(({label:e,config:t,value:r,onChange:s})=>{const i=Te(),o=!!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=o?u:!1,h=f.useMemo(()=>t.initialSelection(r),[r,t.initialSelection]),x=b=>s(b,!1);return n.jsx(L3,{label:e,options:t.options,style:{minWidth:"160px",width:d,maxWidth:p?d:"unset",borderColor:"#e9ecef"},disabled:p,value:[...h],onChange:x,errorMessage:c,required:t.required})}),V3=({option:e,...t})=>{const{label:r,description:s}=e;return n.jsx("div",{...t,children:n.jsx(a.Group,{wrap:"nowrap",children:n.jsxs("div",{children:[n.jsx(a.Text,{size:"sm","data-role":"label",children:r}),n.jsx(a.Text,{size:"xs",c:"dimmed","data-role":"description",children:s})]})})})},B3=k.observer(({label:e,config:t,value:r,onChange:s})=>{const{t:i}=_.useTranslation(),o=Te(),l=!!t.options_query_id,{state:c,error:u}=o.getDataStuffByID(t.options_query_id),d=c==="loading",p=f.useCallback((h,x)=>{h&&s(h,!1)},[s]);return n.jsx(a.Select,{label:e,data:t.options,disabled:l?d:!1,value:r,onChange:p,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"}},renderOption:V3,searchable:!u,nothingFoundMessage:u||i("filter.widget.common.selector_option_empty"),clearable:t.clearable})});function q3({label:e,config:t,value:r,onChange:s}){return n.jsx(a.TextInput,{label:e,value:r||"",onChange:i=>s(i.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const N3=k.observer(({filter:{type:e,config:t,key:r,...s},formFieldProps:i})=>{switch(e){case Q.Select:return n.jsx(B3,{...s,...i,config:t});case Q.MultiSelect:return n.jsx(O3,{...s,...i,config:t});case Q.TreeSelect:return n.jsx(f3,{...s,...i,config:t});case Q.TreeSingleSelect:return n.jsx(y3,{...s,...i,config:t});case Q.TextInput:return n.jsx(q3,{...s,...i,config:t});case Q.DateRange:return n.jsx(Ih,{...s,...i,config:t});case Q.Checkbox:return n.jsx(D3,{...s,...i,config:t});default:return null}}),$3=k.observer(f.forwardRef(({filter:e,...t},r)=>n.jsx("div",{className:"filter-root",ref:r,children:n.jsx(Ie,{children:n.jsx(N3,{filter:e,formFieldProps:t})})}))),G3=({disabled:e})=>{const{searchButtonProps:t}=ql(),{children:r="Search",...s}=t;return n.jsx(a.Button,{color:"blue",size:"sm",type:"submit",...s,disabled:e||s.disabled,children:r})};function F3(e){const t=re();f.useEffect(()=>{var r,s;(s=(r=t.filters).updatePreviewValues)==null||s.call(r,e)},[e])}const Q3=({opened:e,toggle:t})=>{const{t:r}=_.useTranslation();return n.jsx(a.Group,{justify:"flex-end",ml:-4,mt:-4,mb:e?4:0,children:n.jsx(a.Button,{size:"compact-xs",variant:"subtle",color:e?"gray":"blue",leftSection:e?n.jsx(C.IconChevronsUp,{size:14}):n.jsx(C.IconChevronsDown,{size:14}),onClick:t,children:r(e?"filter.hide_filters":"filter.show_filters")})})},Mh=k.observer(function({view:t}){const[r,{toggle:s}]=ze.useDisclosure(!0),i=Te(),{control:o,handleSubmit:l,reset:c}=y.useForm({defaultValues:i.filters.values,reValidateMode:"onBlur"}),u=y.useWatch({control:o});f.useEffect(()=>{c(i.filters.values)},[i.filters.values,c]),F3(u);const d=i.filters.visibleInView(t.id),p=f.useMemo(()=>d.every(m=>m.should_auto_submit),[d]),h=f.useMemo(()=>d.filter(m=>v.get(m,"config.required",!1)),[d]),x=f.useMemo(()=>h.length===0?!1:h.some(m=>!m.requiredAndPass(u[m.key])),[u,h]);if(d.length===0)return null;const b=(m,j)=>(D,T)=>{j(D),(m.should_auto_submit||T)&&i.filters.setValueByKey(m.key,D)};return n.jsxs("form",{onSubmit:l(i.filters.setValues),children:[n.jsx(Q3,{opened:r,toggle:s}),n.jsx(a.Collapse,{in:r,children:n.jsxs(a.Group,{className:"dashboard-filters",justify:"space-between",wrap:"nowrap",sx:p?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n.jsx(a.Group,{align:"flex-start",children:d.map(m=>n.jsx(y.Controller,{name:m.key,control:o,render:({field:j})=>n.jsx($3,{filter:m,value:j.value,onChange:b(m,j.onChange)})},m.id))}),!p&&n.jsx(a.Group,{sx:{alignSelf:"flex-end"},children:n.jsx(G3,{disabled:x})})]})})]})}),R3={viewPanelInFullScreen:v.noop,inFullScreen:!1},Ls=f.createContext(R3),W3=k.observer(({view:e})=>{const{t}=_.useTranslation(),r=se(),{panel:s}=Le(),i=s.realQueryOptions,o=c=>{r.editor.open(["_QUERIES_",c])},l=()=>{r.editor.open(["_VIEWS_",e.id,"_PANELS_",s.id,"_TABS_","Data"])};return i.length===0?null:n.jsxs(n.Fragment,{children:[n.jsx(a.Divider,{label:t(i.length>1?"query.labels":"query.label"),labelPosition:"center"}),n.jsx(a.Menu.Item,{onClick:l,leftSection:n.jsx(C.IconDatabase,{size:14}),children:t("data.label")}),i.map(c=>n.jsx(a.Menu.Item,{onClick:()=>o(c.value),leftSection:n.jsx(C.IconDatabase,{size:14}),children:c.label},c.value))]})}),U3=k.observer(({view:e,title:t})=>{const{t:r}=_.useTranslation(),s=se(),i=re(),o=dt.useModals(),{panel:l,downloadPanelScreenshot:c}=Le(),{id:u}=l,{viewPanelInFullScreen:d,inFullScreen:p}=f.useContext(Ls),h=()=>{i.duplicatePanelByID(u,e.id)},x=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u,"_TABS_","Panel"])},b=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u,"_TABS_","Variables"])},m=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u,"_TABS_","Visualization"])},j=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u,"_TABS_","Interactions"])},D=()=>o.openConfirmModal({title:`${r("panel.delete")}?`,labels:{confirm:r("common.actions.confirm"),cancel:r("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.removePanelByID(u,e.id),confirmProps:{color:"red"},zIndex:320}),T=f.useCallback(()=>{d(u)},[u,d]),z=!p&&e.type!==F.Modal;return n.jsx(n.Fragment,{children:n.jsx(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:n.jsxs(a.Menu,{withinPortal:!0,children:[n.jsx(a.Menu.Target,{children:n.jsx(a.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),n.jsxs(a.Menu.Dropdown,{children:[n.jsx(a.Menu.Item,{onClick:l.refreshData,leftSection:n.jsx(C.IconRefresh,{size:14}),children:r("common.actions.refresh")}),n.jsx(a.Menu.Item,{onClick:l.downloadData,leftSection:n.jsx(C.IconDownload,{size:14}),children:r("common.actions.download_data")}),n.jsx(a.Menu.Item,{onClick:l.downloadSchema,leftSection:n.jsx(C.IconCode,{size:14}),children:r("common.actions.download_schema")}),n.jsx(a.Menu.Item,{onClick:c,leftSection:n.jsx(C.IconCamera,{size:14}),children:r("common.actions.download_screenshot")}),z&&n.jsx(a.Menu.Item,{onClick:T,leftSection:n.jsx(C.IconArrowsMaximize,{size:14}),disabled:!0,children:r("common.actions.enter_fullscreen")}),n.jsx(W3,{view:e}),n.jsx(a.Divider,{label:r("common.actions.edit"),labelPosition:"center"}),n.jsx(a.Menu.Item,{onClick:x,leftSection:n.jsx(C.IconAppWindow,{size:14}),children:r("panel.label")}),n.jsx(a.Menu.Item,{onClick:b,leftSection:n.jsx(C.IconVariable,{size:14}),children:r("panel.variable.labels")}),n.jsx(a.Menu.Item,{onClick:m,leftSection:n.jsx(C.IconChartHistogram,{size:14}),children:r("visualization.label")}),n.jsx(a.Menu.Item,{onClick:j,leftSection:n.jsx(C.IconRoute,{size:14}),children:r("interactions.label")}),n.jsx(a.Divider,{label:r("common.actions.actions"),labelPosition:"center"}),n.jsx(a.Menu.Item,{onClick:h,leftSection:n.jsx(C.IconCopy,{size:14}),children:r("common.actions.duplicate")}),n.jsx(a.Menu.Item,{color:"red",onClick:D,leftSection:n.jsx(C.IconTrash,{size:14}),children:r("common.actions.delete")})]})]})})})});function Y3(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const K3=k.observer(()=>{const e=Te(),{panel:t}=He(),r=f.useMemo(()=>fs(t.description,t.json.variables,e.payloadForViz,t.data),[t.data,t.description,t.json.variables,e.payloadForViz]);return n.jsx(Un,{value:r,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}},dashboardState:e.dashboardState,variableAggValueMap:t.variableAggValueMap})}),Oo=k.observer(()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState(!1),{panel:s}=He();return Y3(s.description)?null:n.jsxs(n.Fragment,{children:[n.jsx(a.Modal,{opened:t,onClose:()=>r(!1),title:s.title.show?s.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:n.jsx(K3,{})}),n.jsx(a.Tooltip,{label:e("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:n.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n.jsx(C.IconInfoCircle,{size:20})})})]})}),xE="",X3=k.observer(function(){const{panel:t}=He(),{name:r,title:s}=t;return s.show?n.jsx(a.Group,{grow:!0,justify:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:n.jsx(a.Text,{size:"sm",ta:"center",lineClamp:1,className:"panel-title-text",children:r})}):null});function H3(e){const t=f.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const s=t.current;if(!s)return;const i=s.offsetWidth*2,o=s.offsetHeight*2;Sl.toBlob(t.current,{bgcolor:"white",width:i,height:o,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 Eh=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(Eh||{}),Os=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(Os||{});class Z3{constructor(t){N(this,"vizInstance");N(this,"operationManager");N(this,"triggerManager");N(this,"vizManager");N(this,"runningMigration");N(this,"panelModel");N(this,"status","notStarted");this.panelModel=t.getRequired(Pe.instanceScope.panelModel),this.vizInstance=t.getRequired(Pe.instanceScope.vizInstance),this.operationManager=t.getRequired(Pe.instanceScope.operationManager),this.triggerManager=t.getRequired(Pe.instanceScope.triggerManager),this.vizManager=t.getRequired(Pe.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(r){return console.warn("check migration failed",r),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(r=>r())),"migrated"}catch(r){return console.warn("migration failed",r),"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),r={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(r)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),r={configData:this.vizInstance.instanceData};return t.migrator.needMigration(r)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function Ph(e){const{panel:t}=He();return f.useCallback(r=>{const s=r.getRequired(Pe.vizManager),i=s.resolveComponent(e.viz.type);return r.createScoped().provideFactory(Pe.instanceScope.vizInstance,()=>s.getOrCreateInstance(e)).provideFactory(Pe.instanceScope.interactionManager,o=>{const l=o.getRequired(Pe.instanceScope.vizInstance);return new wa(l,i,bs)}).provideFactory(Pe.instanceScope.operationManager,o=>o.getRequired(Pe.instanceScope.interactionManager).operationManager).provideFactory(Pe.instanceScope.triggerManager,o=>o.getRequired(Pe.instanceScope.interactionManager).triggerManager).provideValue(Pe.instanceScope.panelModel,t).provideFactory(Pe.instanceScope.migrator,o=>new Z3(o))},[e.viz.type,e.viz.conf])}function Ah(e){const[t,r]=f.useState(!1),s=Ip().getRequired(Pe.instanceScope.migrator);return Y.useAsyncEffect(async()=>{const i=s.status===Os.notStarted;r(s.status===Os.done),s.status===Os.notStarted&&s.runMigration().then(o=>{o===Eh.migrated&&i&&(e==null||e())}).finally(()=>{r(!0)})},[s]),t}function Lh(e,t){const r=Ip().getRequired(Pe.instanceScope.vizInstance);return f.useEffect(()=>(r.instanceData.setItem(null,t.viz.conf),r.instanceData.watchItem(null,s=>{e(s)})),[e,t.viz.type]),r}function J3({setVizConf:e,...t}){const{panel:r}=t,s=Lh(e,r),i=Ah(()=>{Nt.showNotification({title:`${r.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return Y.useAsyncEffect(async()=>{await s.instanceData.setItem(null,r.viz.conf)},[s,r.viz.type]),i?n.jsx(_y,{...t}):n.jsx(a.Text,{size:"sm",children:"Checking update..."})}function e5(e){const{panel:t,setVizConf:r}=e;Lh(r,t);const{inEditMode:s}=f.useContext($r);return Ah(()=>{s&&Nt.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?n.jsx(vy,{...e}):n.jsx(a.Text,{size:"sm",children:"Checking update"})}const mE="";function t5(e,t){const{vizManager:r}=f.useContext(tn),{panel:{viz:s,title:i,id:o,name:l,description:c,queryIDs:u,variables:d}}=He(),p={id:o,name:l,title:i,description:c,queryIDs:u,viz:s},h=Ph(p);try{return r.resolveComponent(s.type),n.jsx(Ms,{configure:h,children:n.jsx(e5,{setVizConf:s.setConf,panel:p,measure:t,data:e,variables:d,vizManager:r})})}catch(x){return console.info(v.get(x,"message")),null}}const Oh=k.observer(function({data:t}){const{ref:r,width:s,height:i}=ze.useElementSize(),o=t5(t,{w:s,h:i}),l=s>0&&i>0;return n.jsx("div",{className:"viz-root",ref:r,children:n.jsx(a.Box,{sx:{width:s,height:i,overflow:"hidden"},children:l&&n.jsx(Ie,{children:o})})})}),Vh=k.observer(({panel:e})=>n.jsxs(a.Stack,{children:[e.queryErrors.map((t,r)=>n.jsx(a.Text,{c:"red",size:"sm",ta:"center",ff:"monospace",children:t},`${r}-${t}`)),n.jsx(a.Text,{c:"gray",ta:"center",size:"sm",children:e.queryStateMessages})]})),Vo=k.observer(({panel:e})=>n.jsxs(a.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[n.jsx(a.LoadingOverlay,{visible:e.dataLoading,transitionProps:{exitDuration:0}}),!e.canRenderViz&&n.jsx(Vh,{panel:e}),e.canRenderViz&&n.jsx(Oh,{data:e.data})]})),n5={border:"1px solid #e9ecef"},Bh=k.observer(({panel:e,panelStyle:t,dropdownContent:r})=>{const{ref:s,downloadPanelScreenshot:i}=H3(e);return e.title.show,n.jsx(ii,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:i},children:n.jsxs(a.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,ref:s,p:0,sx:{...n5,...t},children:[n.jsx(a.Box,{className:"panel-description-popover-wrapper",children:n.jsx(Oo,{})}),r,n.jsx(X3,{}),n.jsx(Vo,{panel:e})]})})}),r5={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function s5(e){return e.style.border.enabled?{}:r5}const qh=k.observer(function({panel:t,view:r}){const s=s5(t);return n.jsx(Bh,{panel:t,panelStyle:s,dropdownContent:n.jsx(U3,{view:r,title:t.name})})});function i5(e){return!["richText","button"].includes(e)}const a5=k.observer(({view:e,title:t})=>{const{t:r}=_.useTranslation(),{panel:s,downloadPanelScreenshot:i}=He(),{id:o}=s,{viewPanelInFullScreen:l,inFullScreen:c}=f.useContext(Ls),u=f.useCallback(()=>{l(o)},[o,l]),d=!c&&e.type!==F.Modal;return i5(s.viz.type)?n.jsx(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:n.jsxs(a.Menu,{withinPortal:!0,children:[n.jsx(a.Menu.Target,{children:n.jsx(a.Box,{className:"panel-dropdown-target"})}),n.jsxs(a.Menu.Dropdown,{children:[n.jsx(a.Menu.Item,{onClick:s.refreshData,leftSection:n.jsx(C.IconRefresh,{size:14}),children:r("common.actions.refresh")}),n.jsx(a.Menu.Item,{onClick:s.downloadData,leftSection:n.jsx(C.IconDownload,{size:14}),children:r("common.actions.download_data")}),n.jsx(a.Menu.Item,{onClick:i,leftSection:n.jsx(C.IconCamera,{size:14}),children:r("common.actions.download_screenshot")}),d&&n.jsx(a.Menu.Item,{onClick:u,leftSection:n.jsx(C.IconArrowsMaximize,{size:14}),children:r("common.actions.enter_fullscreen")})]})]})}):null});function o5(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const Bo=k.observer(({panel:e,view:t})=>{const r=o5(e);return n.jsx(Bh,{panel:e,panelStyle:r,dropdownContent:n.jsx(a5,{title:e.name,view:t})})}),l5={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},Nh=k.observer(function({view:t,panel:r,exitFullScreen:s}){return n.jsx(a.Modal,{opened:!0,fullScreen:!0,onClose:s,title:n.jsx(a.Button,{color:"blue",size:"xs",onClick:s,leftSection:n.jsx(C.IconArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:l5,children:n.jsx(a.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:n.jsx(Bo,{view:t,panel:r})})})});function $h(e,t,r){const{panels:s}=Te(),i=e.id==="Main",[o,l]=f.useState(()=>i&&s.findByID(t)?t:null),c=f.useCallback(h=>{l(h),i&&r(h)},[i,r]),u=f.useCallback(()=>{l(null),i&&r("")},[i,r]),d=o?s.findByID(o):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const bE="",c5=f.forwardRef(({h:e},t)=>n.jsx(a.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:n.jsx(C.IconArrowsMove,{size:16})})),u5=f.forwardRef(({handleAxis:e,...t},r)=>n.jsx(a.ActionIcon,{ref:r,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:n.jsx(C.IconChevronDownRight,{size:16})})),d5=Br.WidthProvider(Br.Responsive),p5=k.observer(({view:e,className:t="layout"})=>{const s=re().layouts,i=s.items(e.panelIDs),o=s.gridLayouts(e.panelIDs),l=(d,p,h,x)=>{h.h<30&&(h.h=30,x.h=30),h.w<4&&(h.w=4,x.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 n.jsx(d5,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:s.cols,layouts:o,draggableHandle:".react-grid-customDragHandle",resizeHandle:n.jsx(u5,{}),onResize:l,breakpoints:s.breakpoints,onBreakpointChange:s.setCurrentBreakpoint,onResizeStop:c,onDragStop:u,width:s.currentLayoutPreviewWidth,children:i.map(d=>n.jsxs("div",{"data-grid":d.layoutProperies,className:"panel-grid-item",children:[n.jsx(c5,{h:d.h}),n.jsx(qh,{view:e,panel:d.panel})]},d.id))})}),h5=Br.WidthProvider(Br.Responsive),g5=k.observer(({view:e,className:t="layout"})=>{const r=Te(),s=r.layouts.items(e.panelIDs),i=r.layouts.gridLayouts(e.panelIDs);return n.jsx(h5,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:r.layouts.cols,layouts:i,breakpoints:r.layouts.breakpoints,onBreakpointChange:r.layouts.setCurrentBreakpoint,children:s.map(o=>n.jsx("div",{"data-grid":o.layoutProperies,className:"panel-grid-item",children:n.jsx(Bo,{view:e,panel:o.panel})},o.id))})});function qo(e){const t=f.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 f5=k.observer(({downloadScreenshot:e})=>{const{t}=_.useTranslation(),[r,{setTrue:s,setFalse:i}]=Y.useBoolean(!1),o=Vl(),l=Te(),c=()=>{const u=JSON.stringify(l.contentJSON,null,2),d=`${o.name}__${l.name}`;Jn(d,u)};return n.jsxs(a.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[n.jsx(a.Menu.Target,{children:n.jsx(a.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:n.jsx(a.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:s,onMouseLeave:i,sx:{opacity:r?1:.6,transform:`translateX(${r?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:n.jsx(C.IconShare3,{size:"1rem"})})})}),n.jsxs(a.Menu.Dropdown,{children:[n.jsx(a.Menu.Item,{leftSection:n.jsx(C.IconCamera,{size:14}),onClick:e,children:t("common.actions.download_screenshot")}),n.jsx(a.Menu.Divider,{}),n.jsx(a.Menu.Item,{leftSection:n.jsx(C.IconDownload,{size:14}),onClick:l.queries.downloadAllData,children:t("common.actions.download_data")}),n.jsx(a.Menu.Item,{leftSection:n.jsx(C.IconCode,{size:14}),onClick:c,children:t("common.actions.download_schema")})]})]})}),Gh=k.observer(({children:e,view:t,sx:r={}})=>{const{ref:s,downloadScreenshot:i}=qo(t);return n.jsxs(n.Fragment,{children:[n.jsx(a.Box,{ref:s,pt:10,pb:10,sx:r,children:e}),n.jsx(f5,{downloadScreenshot:i})]})}),Fh=k.observer(({downloadScreenshot:e})=>n.jsx(a.ActionIcon,{className:"download-screenshot-button",color:"blue",variant:"subtle",onClick:e,children:n.jsx(C.IconCamera,{size:14})})),x5=k.observer(({children:e,view:t})=>{const r=Te(),s=t.config,i=r.views.visibleViewIDs.includes(t.id),o=()=>r.views.rmVisibleViewID(t.id),{ref:l,downloadScreenshot:c}=qo(t);return n.jsx(a.Modal,{size:s.width,centered:!0,opened:i,onClose:o,withCloseButton:!1,title:n.jsxs(a.Group,{justify:"space-between",px:"1rem",h:"48px",children:[n.jsx(a.Box,{children:s.custom_modal_title.value}),n.jsx(Fh,{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:n.jsx(a.Box,{ref:l,children:e})})}),m5=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},b5=k.observer(({view:e})=>{const t=Te(),r=e.config;return n.jsxs(a.Tabs,{className:"render-view-tabs",variant:r.variant,orientation:r.orientation,value:e.tab,onChange:e.setTab,styles:{root:{height:"100%",overflow:r.orientation==="horizontal"?"hidden":"auto"},panel:{padding:r.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[n.jsx(a.Tabs.List,{grow:r.grow,children:r.tabsInOrder.map(s=>n.jsx(a.Tabs.Tab,{value:s.id,sx:m5(s),disabled:!s.view_id,children:s.name??s.id},s.id))}),r.tabsInOrder.map(s=>{const i=t.views.findByID(s.view_id);return i?n.jsx(a.Tabs.Panel,{value:s.id,children:n.jsx(Vs,{view:i})},s.id):null})]})}),y5=k.observer(({view:e,children:t})=>{switch(e.type){case F.Modal:return n.jsx(x5,{view:e,children:t});case F.Tabs:return n.jsx(b5,{view:e});case F.Division:default:return n.jsx(Gh,{view:e,children:t})}}),v5=k.observer(({children:e,view:t})=>{const s=re().layouts,[i,o]=ze.useResizeObserver();return f.useEffect(()=>{s.setCurrentLayoutWrapperWidth(o.width)},[o.width]),n.jsx(a.Box,{sx:{height:"100%"},ref:i,children:n.jsx(a.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:s.currentLayoutPreviewWidth??"100%",transform:`scale(${s.divisionPreviewScale})`,transformOrigin:"0 0"},children:n.jsx(Gh,{view:t,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:e})})})});function Qh(e){return e.replace(/(vw|vh)/,"%")}const _5=k.observer(({children:e,view:t})=>{const r=t.config,{width:s,height:i}=f.useMemo(()=>({width:Qh(r.width),height:Qh(r.height)}),[r.width,r.height]),{ref:o,downloadScreenshot:l}=qo(t);return n.jsx(a.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:n.jsx(a.Modal,{size:r.width,opened:!0,onClose:v.noop,withCloseButton:!1,title:n.jsxs(a.Group,{justify:"space-between",px:"1rem",h:"48px",children:[n.jsx(a.Box,{children:r.custom_modal_title.value}),n.jsx(Fh,{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:n.jsx(a.Box,{ref:o,children:e})})})}),j5=({variant:e,orientation:t})=>{const r={root:{height:"100%",overflow:"hidden"},list:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(r.tab.paddingTop="6px",r.tab.paddingBottom="6px"),t==="vertical"&&(r.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},r.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),r},w5=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},C5=k.observer(({view:e})=>{const{t}=_.useTranslation(),r=dt.useModals(),s=re(),i=f.useMemo(()=>s.views.options.filter(d=>d.type===F.Division),[e.id,s.views.options]),o=e.config,l=d=>r.openConfirmModal({title:`${t("view.component.tabs.tab.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.removeTab(d)},confirmProps:{color:"red"},zIndex:320}),c=o.tabs.length===0,u=o.tabsInOrder.length===0?void 0:o.tabsInOrder[0].id;return n.jsxs(a.Tabs,{className:"preview-view-tabs",variant:o.variant,orientation:o.orientation,value:e.tab||u,onChange:e.setTab,styles:j5(o),children:[n.jsxs(a.Tabs.List,{grow:o.grow,children:[o.tabsInOrder.map(d=>n.jsx(a.Tabs.Tab,{value:d.id,sx:w5(d),children:d.name??d.id},d.id)),n.jsx(a.Tabs.Tab,{onClick:o.addTab,value:"add",className:"add-a-tab",children:n.jsx(C.IconPlus,{size:18,color:"#228be6"})})]}),o.tabsInOrder.map((d,p)=>{const h=s.views.findByID(d.view_id);return n.jsxs(a.Tabs.Panel,{value:d.id,sx:{position:"relative"},children:[n.jsxs(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[n.jsx(a.Overlay,{backgroundOpacity:.8,color:"#FFF",blur:10,zIndex:100}),n.jsxs(a.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[n.jsx(a.TextInput,{label:t("view.component.tabs.tab.name"),required:!0,value:d.name,onChange:x=>d.setName(x.currentTarget.value)}),n.jsx(a.Select,{label:t("view.label"),value:d.view_id,onChange:d.setViewID,data:i}),n.jsx(a.NumberInput,{label:t("view.component.tabs.tab.order"),required:!0,value:d.order,onChange:x=>d.setOrder(x||0),min:0,max:1e3,step:1}),n.jsx(a.ColorInput,{label:t("view.component.tabs.tab.color"),value:d.color,onChange:d.setColor,disabled:o.variant!=="default"}),h&&n.jsx(a.Button,{mt:20,variant:"gradient",leftSection:n.jsx(C.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>s.views.setIDOfVIE(h.id),children:t("view.component.tabs.tab.switch_to_view",{name:h.name})}),n.jsx(a.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>l(p),disabled:c,leftSection:n.jsx(C.IconTrash,{size:14}),children:t("view.component.tabs.tab.delete")})]})]}),h&&n.jsx(Vs,{view:h})]},d.id)})]})}),S5=k.observer(({view:e,children:t})=>{switch(e.type){case F.Modal:return n.jsx(_5,{view:e,children:t});case F.Tabs:return n.jsx(C5,{view:e});case F.Division:default:return n.jsx(v5,{view:e,children:t})}}),Rh=k.observer(function({view:t}){const s=re().layouts.divisionPreviewScale!==1;return n.jsx(Ls.Provider,{value:{viewPanelInFullScreen:v.noop,inFullScreen:!1},children:n.jsx(a.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:s?"transparent":"#efefef"},children:n.jsx(S5,{view:t,children:n.jsxs(a.Box,{sx:{position:"relative"},children:[n.jsx(a.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n.jsx(Mh,{view:t})}),n.jsx(p5,{view:t})]})})})})}),Vs=k.observer(function({view:t}){const{fullScreenPanelID:r,setFullScreenPanelID:s}=Wl(),{viewPanelInFullScreen:i,exitFullScreen:o,inFullScreen:l,fullScreenPanel:c}=$h(t,r,s);return n.jsx(Ls.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:l},children:n.jsxs(a.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===F.Modal?"0 !important":"100%"},children:[l&&n.jsx(Nh,{view:t,panel:c,exitFullScreen:o}),n.jsx(y5,{view:t,children:n.jsxs(a.Box,{sx:{position:"relative"},children:[!l&&n.jsx(a.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n.jsx(Mh,{view:t})}),!l&&n.jsx(g5,{view:t})]})})]})})});var Wh=(e=>(e.Use="use",e.Edit="edit",e))(Wh||{});const T5={[F.Division]:"Division",[F.Tabs]:"Tabs",[F.Modal]:"Modal"},Uh={[F.Division]:"rgba(255, 0, 0, 0.2)",[F.Modal]:"rgba(0, 0, 0, 0.2)",[F.Tabs]:"rgba(255, 200, 100, 0.4)"},k5={[F.Division]:"#ff4000",[F.Modal]:"#000",[F.Tabs]:"#ffad18"};function D5(e,t,r){g.addDisposer(e,g.addMiddleware(e,(s,i)=>{i(s,()=>{g.getType(s.context)===t&&s.type==="action"&&r(s.name,s.context)})}))}const Yh=g.types.compose("FiltersModel",Io,g.types.model("FiltersModel",{previewValues:g.types.optional(g.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===Q.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,widget:t.type}))},get sortedList(){return v.sortBy(e.current,t=>t.label.toLowerCase())}})).actions(e=>({replace(t){e.current=g.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(s=>!e.idSet.has(s.id));e.current.push(...r)},remove(t){e.current.splice(t,1)},removeByID(t){const r=e.current.findIndex(s=>s.id===t);r>=0&&e.current.splice(r,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){D5(e.current,yo,(r,s)=>{if(r==="setType"){const i=bh(s.config.default_value,s.config);e.setValueByKey(s.key,i),e.updatePreviewValues({...e.previewValues,[s.key]:i})}})}return{afterCreate(){t()}}}),Kh=Eo.views(e=>({get canPreviewData(){return e.isTransform?e.config.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"},get usage(){return e.contentModel.findQueryUsage(e.id)},get runBySet(){return new Set(e.run_by)},keyInRunBy(t){return this.runBySet.has(t)}})).actions(e=>({changeRunByRecord(t,r){const s=new Set(e.run_by);r?s.add(t):s.delete(t),e.run_by.length=0,e.run_by.push(...s)}})),Xh=g.types.compose("QueriesModel",Po,g.types.model({current:g.types.optional(g.types.array(Kh),[])})).views(e=>({get options(){const t=e.current.map(r=>({value:r.id,label:r.name,_type:"query"}));return v.sortBy(t,r=>r.label.toLowerCase())},get optionsWithoutTransform(){const t=e.current.filter(r=>r.type!==J.Transform).map(r=>({value:r.id,label:r.name,_type:"query"}));return v.sortBy(t,r=>r.label.toLowerCase())},get sortedList(){return v.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=g.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(s=>!e.idSet.has(s.id));e.current.push(...r)},remove(t){e.current.splice(t,1)},replaceByIndex(t,r){e.current.splice(t,1,r)},removeQuery(t){const r=e.current.find(s=>s.id===t);r&&(g.detach(r),e.current.remove(r))},removeQueries(t){const r=new Set(t);e.current.forEach(i=>{r.has(i.id)&&g.detach(i)});const s=[...e.current];v.remove(s,i=>r.has(i.id)),e.current=g.cast(s)}})),Hh=Lo.views(e=>({get sortedList(){return v.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(r=>({label:r.key,value:r.key,_type:"sql_snippet"}));return v.sortBy(t,r=>r.label.toLowerCase())}})).actions(e=>({replace(t){e.current=g.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(s=>!e.keySet.has(s.key));e.current.push(...r)},remove(t){e.current.splice(t,1)},removeByKey(t){const r=e.current.findIndex(s=>s.key===t);r>=0&&e.current.splice(r,1)},removeByKeys(t){const r=new Set(t);e.current.forEach(i=>{r.has(i.key)&&g.detach(i)});const s=[...e.current];v.remove(s,i=>r.has(i.key)),e.current=g.cast(s)},replaceByIndex(t,r){e.current.splice(t,1,r)}})),z5=g.types.model({data:g.types.optional(g.types.frozen(),[]),state:g.types.optional(g.types.enumeration(["idle","loading","error"]),"idle"),error:g.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),I5=g.types.model({data:g.types.optional(g.types.frozen(),[]),state:g.types.optional(g.types.enumeration(["idle","loading","error"]),"idle"),error:g.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),M5=g.types.model({page:g.types.optional(g.types.number,1),limit:g.types.optional(g.types.number,20),data:g.types.optional(g.types.frozen(),[]),total:g.types.optional(g.types.number,0),state:g.types.optional(g.types.enumeration(["idle","loading","error"]),"idle"),error:g.types.frozen()}).views(e=>({get keywords(){return g.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:r}=g.getParent(e,1);return`${r}||${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:r}=e.keywords;return`
480
+ `)},_o=g.types.model("ViewModalConfig",{_name:g.types.literal(F.Modal),width:g.types.string,height:g.types.string,custom_modal_title:g.types.optional(j3,Ps)}).views(e=>({get json(){const{_name:t,width:r,height:s,custom_modal_title:i}=e;return{_name:t,width:r,height:s,custom_modal_title:i.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),oh=()=>_o.create({_name:F.Modal,width:"90vw",height:"90vh"}),w3=g.types.model("ViewTabsTabModel",{id:g.types.identifier,name:g.types.string,view_id:g.types.string,color:g.types.optional(g.types.string,""),order:g.types.optional(g.types.number,0)}).views(e=>({get json(){const{id:t,name:r,view_id:s,color:i,order:o}=e;return{id:t,name:r,color:i,order:o,view_id:s}}})).actions(e=>({setName(t){e.name=t},setViewID(t){t&&(e.view_id=t)},setColor(t){e.color=t},setOrder(t){typeof t!="string"&&(e.order=t)}})),jo=g.types.model("ViewTabsConfig",{_name:g.types.literal(F.Modal),tabs:g.types.optional(g.types.array(w3),[]),variant:g.types.optional(g.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:g.types.optional(g.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:g.types.optional(g.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:r,orientation:s,tabs:i,grow:o}=e;return{grow:o,tabs:i.map(l=>l.json),_name:t,variant:r,orientation:s}},get tabsInOrder(){return v.sortBy(e.tabs,"order")}})).actions(e=>({setVariant(t){t&&(e.variant=t)},setOrientation(t){t&&(e.orientation=t)},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=g.cast(t)},addTab(){const t=ze.randomId(),r={id:t,name:t,view_id:""};e.tabs.push(r)},removeTab(t){e.tabs.splice(t,1)}})),lh=()=>jo.create({_name:F.Modal,tabs:[]}),ch=g.types.model({id:g.types.identifier,name:g.types.string,type:g.types.enumeration("EViewComponentType",[F.Division,F.Modal,F.Tabs]),config:g.types.union(vo,_o,jo),panelIDs:g.types.optional(g.types.array(g.types.string),[])}).views(e=>({get json(){const{id:t,name:r,type:s,config:i}=e;return{id:t,name:r,type:s,config:i.json,panelIDs:e.panelIDs.map(o=>o)}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case F.Division:e.config=ah();break;case F.Modal:e.config=oh();break;case F.Tabs:e.config=lh();break;default:return}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},appendPanelIDs(t){e.panelIDs.push(...t)},removePanelID(t){const r=e.panelIDs.filter(s=>s!==t);e.panelIDs.length=0,e.panelIDs.push(...r)}})),nn="13.45.0",C3={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:F.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:nn,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},wo=g.types.model("DataSourceMetaModel",{id:g.types.string,type:g.types.enumeration("DataSourceType",[J.HTTP,J.MySQL,J.Postgresql,J.MericoMetricSystem]),key:g.types.string,config:g.types.frozen()}),uh=g.types.model("DataSourcesMetaModel",{list:g.types.optional(g.types.array(wo),[])}).views(e=>({find({type:t,key:r}){return e.list.find(s=>s.key===r&&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)}})),dh=g.types.model({id:g.types.string,content:g.types.string,create_time:g.types.string,update_time:g.types.string,is_preset:g.types.boolean}),Co=g.types.model("GlobalSQLSnippetsMeta",{list:g.types.optional(g.types.array(dh),[])}).views(e=>({find(t){return e.list.find(r=>r.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)}})),As=g.types.model("ContextMeta",{current:g.types.optional(g.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,r){e.current[t]=r}}));function So(e){return As.create({current:e})}const To=g.types.compose("ViewRenderModel",ch,g.types.model({tab:g.types.optional(g.types.string,"")})).views(e=>({get tabs(){return e.config.tabs},get tabInfo(){const t=this.tabs.find(r=>r.id===e.tab);return t?{id:t.id,name:t.name}:null},get tabView(){return e.type!==F.Tabs?null:this.tabs.find(t=>t.id===e.tab)},get tabViewID(){return this.tabView?this.tabView.view_id??"":""},get contentModel(){return g.getParent(e,3)},get panels(){if(e.type!==F.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs);const t=this.tabViewID,r=this.contentModel.views.findByID(t);return(r==null?void 0:r.panels)??[]},get renderViewIDs(){const t=[e.id];return e.type===F.Tabs&&t.push(this.tabViewID),t},async downloadScreenshot(t){const r=t.offsetWidth*2+10,s=t.offsetHeight*2+10,i=new Tl,o=new Date().getTime(),l=await Sl.toBlob(t,{bgcolor:"white",width:r,height:s,style:{transformOrigin:"0 0",transform:"scale(2)"}});i.file(`${e.name}_${o}.png`,l),i.file(`dashboard_state_${o}.json`,JSON.stringify(this.contentModel.dashboardState,null,4)),i.generateAsync({type:"blob"}).then(c=>{Vr.saveAs(c,`${e.name}_${o}.zip`)}).catch(c=>{console.error(c),Nt.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??""}})),ko=g.types.model("ViewsRenderModel",{current:g.types.optional(g.types.array(To),[]),visibleViewIDs:g.types.array(g.types.string)}).views(e=>({get json(){return e.current.map(t=>Zt(t.json))},get idMap(){const t=new Map;return e.current.forEach(r=>{t.set(r.id,r)}),t},findByID(t){return e.current.find(r=>r.id===t)},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:r})=>r===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:r})=>t.has(r))},get firstVisibleTabsView(){return this.visibleViews.find(t=>t.type===F.Tabs)},get firstVisibleTabsViewActiveTab(){const t=this.firstVisibleTabsView;return t?t.tabInfo:null},get firstVisibleTabsViewActiveTabStr(){return JSON.stringify(this.firstVisibleTabsViewActiveTab)}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(s=>s)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const r=e.visibleViewIDs.findIndex(s=>s===t);r!==-1&&e.visibleViewIDs.splice(r,1)},setFirstVisibleTabsViewActiveTab(t){if(!t)return;const r=e.firstVisibleTabsView;r==null||r.setTabByTabInfo(t)}}));function ph(e,t){const r=e.length>0?[e[0].id]:[],s=e.map(i=>{const{_name:o=i.type}=i.config,l={...i,tab:"",config:{...i.config,_name:o},panelIDs:i.panelIDs};if(i.type===F.Tabs){let c=v.minBy(i.config.tabs,u=>u.order);!c&&i.config.tabs.length>0&&(c=i.config.tabs[0]),l.tab=(c==null?void 0:c.id)??""}return l});return t&&(s[0].tab=t.id),{current:s,visibleViewIDs:r}}const S3=new uf.AsyncParser({withBOM:!0});async function hh(e){return!Array.isArray(e)||e.length===0?"":await S3.parse(e).promise()}async function gh(e,t){const r=await hh(t),s=new Blob([r],{type:"text/csv"});Vr.saveAs(s,`${e}.csv`)}function fh(e){const t=new Tl,r=e.map(async({id:s,data:i})=>{const o=await hh(i);t.file(`${s}.csv`,o)});Promise.all(r).then(()=>{t.generateAsync({type:"blob"}).then(s=>{Vr.saveAs(s,"dashboard_data.zip")})}).catch(s=>{console.error(s),Nt.notifications.show({color:"red",title:"Failed to download data",message:s.message})})}function Jn(e,t){const r=new Blob([t],{type:"application/json"});Vr.saveAs(r,`${e}.json`)}const Do=Lp.views(e=>({get contentModel(){return g.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(r=>r.id===t)},get data(){return this.queries.reduce((t,r)=>(t[r.id]=r.data,t),{})},get variableStrings(){return fd(e.variables,this.data)},get variableAggValueMap(){const t={},r=this.data;return e.variables.reduce((s,i)=>(s[i.name]=Qt(i,r),s),t),t},get variableValueMap(){const t={},r=this.variableAggValueMap;return e.variables.reduce((s,i)=>(s[i.name]=jt(i,r[i.name]),s),t),t},get variableStyleMap(){const t=this.variableValueMap,r={};return e.variables.reduce((s,i)=>{const o=lx(i.color,t[i.name]);return s[i.name]={color:o,"font-size":i.size,"font-weight":i.weight,variable:i},s},r),r},get dataLoading(){return this.queries.some(t=>t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(o=>!o.runByConditionsMet);if(t.length===0)return"";const r=new Set,s=new Set;t.forEach(o=>{const l=o.conditionNames;l.context.forEach(c=>r.add(c)),l.filters.forEach(c=>s.add(c))});const i=[];return r.size>0&&i.push(`context: ${Array.from(r).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??t.metricQueryPayloadErrorString).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(r=>r.json),layouts:e.contentModel.layouts.jsonByPanelIDSet(new Set([e.id]))}},downloadSchema(){const{panel:t,queries:r,layouts:s}=this.getSchema(),o=JSON.stringify({panels:[t],definition:{queries:r},layouts:s,version:nn},null,2),l=e.name;Jn(l,o)}}));function xh(e){return{id:e,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:Ra.name,conf:Ra.createConfig()},style:{border:{enabled:!0}}}}const zo=g.types.model("PanelsRenderModel",{list:g.types.optional(g.types.array(Do),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(r=>r.id===t)},get idMap(){const t=new Map;return e.list.forEach(r=>{t.set(r.id,r)}),t}})).views(e=>({panelsByIDs(t){const r=[];return t.forEach(s=>{const i=e.idMap.get(s);i?r.push(i):console.warn(`Panel is not found, id:${s}`)}),r}}));function mh(e){const t=e.config,r=t.default_value;return r===void 0?r:t._name==="date-range"?Yp(t):r}function T3(e,t){const r=e.default_value_func;try{const s=new Function(`return ${r}`)()(e,zt,t);return e.config._name==="date-range"&&Array.isArray(s)?{value:s,shortcut:null}:s}catch(s){return console.error(s),mh(e)}}function bh(e,t){var r;return(r=e.default_value_func)!=null&&r.trim()?T3(e,t):mh(e)}function yh(e,t){return e.reduce((r,s)=>(r[s.key]=bh(s,t),r),{})}function vh(e,t){const r={};return Object.entries(t).forEach(([s,i])=>{const o=e[s];return typeof i=="object"&&"shortcut"in i&&Array.isArray(o)?r[s]={value:o,shortcut:null}:r[s]=o??i,r}),r}const Io=g.types.model("FiltersRenderModel",{current:g.types.optional(g.types.array(yo),[]),values:g.types.optional(g.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get valuesString(){return JSON.stringify(e.values)},get filter(){return g.getParent(e)},get valuesForPayload(){const t={};return Object.entries(e.values).forEach(([r,s])=>{t[r]=s;const i=this.findByKey(r);i&&i.config._name==="date-range"&&(t[r]=i.config.dateStringsValue)}),t},get contentModel(){return g.getRoot(e).content},get context(){return this.contentModel.payloadForSQL.context},get initialValuesDep(){return JSON.stringify({filters:e.current.map(({default_value_func:t,config:r})=>({default_value_func:t,config:r})),context:this.contentModel.payloadForSQL.context})},get formattedDefaultValues(){return yh(this.json,this.contentModel.context)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(r=>r.id===t)},findByKey(t){return e.current.find(r=>r.key===t)},findByIDSet(t){return e.current.filter(r=>t.has(r.id))},get inOrder(){return v.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return v.sortBy(e.current.filter(r=>r.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,r)=>(t[r.key]=r.label,t),{})},getSelectOption(t){const r=this.findByID(t);if(!r||!("getSelectOption"in r.config))return null;const s=e.values[r.key];return r.config.getSelectOption(s)}})).actions(e=>({setValues(t){console.debug("⚪️ setting filter values: ",JSON.stringify(t)),e.values=t},patchValues(t){console.debug("⚪️ patching filter values: ",JSON.stringify(t)),e.values=vh(t,e.values)},setValueByKey(t,r){console.debug(`⚪️ setting filter[${t}] to value: `,JSON.stringify(r)),e.values={...e.values,[t]:r}},applyValuesPatch(t){e.values={...e.values,...t}},getValueByKey(t){return e.values[t]},getSchema(t,r){return{filters:e.findByIDSet(new Set(t)).map(o=>({...o.json,visibleInViewsIDs:r?o.json.visibleInViewsIDs:[]})),version:nn}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t,!1),null,2);Jn("Filters",r)}}));function Mo(e,t,r,s){const i={...r,...t},o=yh(e,i),l=vh(s,o);return{current:e,values:l}}const _h=$p.views(e=>({get rootModel(){return g.getRoot(e)},get contentModel(){return this.rootModel.content},get conditionOptions(){if(!g.isAlive(e))return{optionGroups:[],validValues:new Set};const t=new Set,{context:r}=this.contentModel.payloadForSQL,s={group:"context.label",items:Object.keys(r).map(l=>{const c=`context.${l}`;return t.add(c),{label:l,value:c,description:void 0,type:"context"}})},i={group:"filter.labels",items:this.contentModel.filters.keyLabelOptions.map(l=>{const c=`filters.${l.value}`;return t.add(c),{label:l.label,value:c,description:l.value,type:"filter",widget:l.widget}})};return{optionGroups:[s,i],validValues:t}},getConditionOptionsWithInvalidValue(t){const{optionGroups:r,validValues:s}=this.conditionOptions;if(!t||s.has(t))return this.conditionOptions;const i={group:"common.invalid",items:[{label:t,value:t}]};return{optionGroups:[...r,i],validValues:s}},get conditionOptionsWithInvalidRunbys(){const{optionGroups:t,validValues:r}=this.conditionOptions,s={group:"common.invalid",items:[]};return e.run_by.forEach(i=>{r.has(i)||s.items.push({label:i,value:i})}),{optionGroups:[...t,s],validValues:r}},get unmetRunByConditions(){if(!g.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const r=this.contentModel.payloadForSQL;return t.filter(s=>{const i=v.get(r,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(){const t=v.get(e,"config.sql","");return Hs(t,this.payload)},get httpConfigString(){const{context:t,filters:r}=this.payload,{name:s,pre_process:i}=e.json,o=uy(i,t,r);return console.groupCollapsed(`Request config for: ${s}`),console.log(o),console.groupEnd(),JSON.stringify(o)},get typedAsSQL(){return[J.Postgresql,J.MySQL].includes(e.type)},get typedAsHTTP(){return[J.HTTP].includes(e.type)},get isMericoMetricQuery(){return e.type===J.MericoMetricSystem},get isTransform(){return e.type===J.Transform},get reQueryKey(){const t=v.get(e,"config.react_to",[]);if(t.length===0)return"";const r=e.contentModel.payloadForSQL,s=[...t].reduce((i,o)=>(i[o]=v.get(r,o),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,r=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:r,filters:s}},get queries(){return g.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)},get dependencies(){if(!this.typedAsSQL)return[];const t=v.get(e,"config.sql","");if(!t)return[];const r=v.uniq(t.match(gs.sqlSnippet)),s=v.uniq(t.match(gs.filter)),i=v.uniq(t.match(gs.context)),o=[];return r.forEach(l=>{o.push({type:"sql_snippet",key:l,valid:e.contentModel.sqlSnippets.keySet.has(l)})}),s.forEach(l=>{o.push({type:"filter",key:l,valid:e.contentModel.filters.keySet.has(l)})}),i.forEach(l=>{o.push({type:"context",key:l,valid:e.contentModel.mock_context.keySet.has(l)})}),o},get metricQueryPayload(){if(e.type!==J.MericoMetricSystem)return null;const t=this.payload,r=e.config,s=r.filters.reduce((p,h)=>(p[h.dimension]={eq:v.get(t,h.variable)},p),{}),i={id:r.id,type:r.type,filters:s,groupBys:r.groupBys};if(!r.timeQuery.enabled)return i;const{range_variable:o,unit_variable:l}=r.timeQuery,c="YYYY-MM-DD",u="PRC",d={start:"",end:"",unitOfTime:v.get(t,l,""),unitNumber:1,timezone:"PRC",stepKeyFormat:c};if(o){const p=v.get(t,o);Array.isArray(p)&&p.length===2&&(d.start=A(p[0]).tz(u).format(c),d.end=A(p[1]).tz(u).format(c))}return i.timeQuery=d,i},get metricQueryPayloadString(){return this.metricQueryPayload?JSON.stringify(this.metricQueryPayload,null,2):""},get metricQueryPayloadError(){const t=[];if(!this.metricQueryPayload)return t;const r=e.config,{timeQuery:s}=this.metricQueryPayload;if(!s)return r.groupByValues.length>2&&t.push("分组聚合维度:最多支持两个维度的聚合计算"),t;r.groupByValues.length>1&&t.push("分组聚合维度:按时间序列展示时,仅可选择一个聚合维度");const{start:i,end:o,unitOfTime:l}=s;return(!i||!o)&&t.push("时间维度:时间范围不完整"),l||t.push("步长:必选"),t},get metricQueryPayloadErrorString(){return this.metricQueryPayloadError.join(`
481
+ `)},get metricQueryPayloadValid(){return this.metricQueryPayload?this.metricQueryPayloadError.length===0:!1}})),Eo=g.types.compose("QueryRenderModel",_h,g.types.model({state:g.types.optional(g.types.enumeration(["idle","loading","error"]),"idle"),data:g.types.optional(g.types.frozen([]),[]),error:g.types.frozen()})).views(e=>({get datasource(){const{key:t,type:r}=e;return e.rootModel.datasources.find({type:r,key:t})},get additionalQueryInfo(){return e.contentModel.getAdditionalQueryInfo(e.id)},get depQueryModels(){const t=v.get(e,"config.dep_query_ids",[]);return e.contentModel.queries.findByIDSet(new Set(t))},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:r}=e.conditionNames;if(t.length===0&&r.length===0)return"Waiting";const s=[];return t.length>0&&s.push(`context: ${t.join(", ")}`),r.length>0&&s.push(`filter${r.length>1?"s":""}: ${r.join(", ")}`),s.length===2&&s.splice(1,0,"and"),s.unshift("Waiting for"),s.join(" ")}return e.data.length>0?"":"data.empty_data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:g.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const r=e.payload,s=e.config;e.data=yield*g.toGenerator(fy({payload:r,name:e.name,query:{type:e.type,key:e.key,sql:s.sql,pre_process:e.pre_process,post_process:e.post_process},additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(r){if(pt.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const s=v.get(r,"message","unkown error");e.error=v.get(r,"response.data.detail.message",s),e.state="error"}}}}),runHTTP:g.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:r,key:s,post_process:i}=e.json;let o=JSON.parse(e.httpConfigString);o=ps(e.datasource,o);const l=yield*g.toGenerator(xy({type:r,key:s,configString:JSON.stringify(o),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=hs(e.datasource,l),u=md(i,c,e.contentModel.dashboardState);e.data=u,e.state="idle",e.error=null}catch(r){if(console.error(r),pt.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const s=v.get(r,"message","unkown error");e.error=v.get(r,"response.data.detail.message",s),e.state="error"}}}}),runMericoMetricQuery:g.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet&&e.metricQueryPayloadValid)){e.controller=new AbortController,e.state="loading";try{const{type:r,key:s,post_process:i}=e.json;let o={url:"/buffet/api/metric_management/query",method:"POST",data:e.metricQueryPayload};o=ps(e.datasource,o);const l=yield*g.toGenerator(my({key:s,configString:JSON.stringify(o),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=hs(e.datasource,l),u=md(i,c,e.contentModel.dashboardState);e.data=u.data,e.state="idle",e.error=null}catch(r){if(console.error(r),pt.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const s=v.get(r,"message","unkown error");e.error=v.get(r,"response.data.detail.message",s),e.state="error"}}}}),runTransformation(){e.state="loading";try{const t=e.depQueryModels.map(o=>({id:o.id,name:o.name,data:v.cloneDeep(o.data)})),r=e.contentModel.dashboardState,s=e.pre_process,i=new Function(`return ${s}`)()(t,r,zt);e.data=i,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.isMericoMetricQuery?e.runMericoMetricQuery():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){g.addDisposer(e,te.reaction(()=>{var r,s;if(e.isTransform){const i=e.config;return[e.inUse,e.id,e.key,i.dep_query_ids.toString(),e.pre_process,e.depQueryModelStatesString].join("--")}return e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(r=e.datasource)==null?void 0:r.id}`:e.isMericoMetricQuery?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(s=e.datasource)==null?void 0:s.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},()=>e.fetchData(!1),{fireImmediately:!0,delay:0}))}})),Po=g.types.model("QueriesRenderModel",{current:g.types.optional(g.types.array(Eo),[])}).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(r=>r.id===t)},findByIDSet(t){return e.current.filter(r=>t.has(r.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get contentModel(){return g.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:r,queries:s}=this.contentModel,i=[];t.visibleViews.forEach(c=>{c.panels.forEach(u=>{i.push(...u.queryIDs)})});const o=v.uniq(t.visibleViews.map(c=>c.renderViewIDs).flat());r.current.forEach(c=>{const u=v.get(c,"config.options_query_id");if(!u)return;o.some(p=>c.visibleInViewsIDSet.has(p))&&i.push(u)}),s.findByIDSet(new Set(i)).forEach(c=>{const u=c.config;!c.isTransform||u.dep_query_ids.length===0||i.push(...u.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:r,data:s})=>({id:r,data:s}));fh(t)},downloadDataByQueryIDs(t){const r=new Set(t),s=e.current.filter(i=>r.has(i.id)).map(({name:i,data:o})=>({id:i,data:o}));fh(s)},downloadDataByQueryID(t){const r=e.findByID(t);if(!r){console.log("[downloadDataByQueryID] query not found");return}const{name:s,data:i}=r;gh(s,i)},refetchDataByQueryID(t){const r=e.findByID(t);if(!r){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return r.fetchData(!0)},getSchema(t){return{definition:{queries:e.findByIDSet(new Set(t)).map(i=>i.json)},version:nn}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t),null,2);Jn("Queries",r)}}));function jh(e){return{current:e}}function wh({min:e,max:t}){const r=`${e}px`,s=Number.isFinite(t)?`${t}px`:"∞";return`[${r}, ${s})`}const Ao=g.types.model("LayoutsRenderModel",{list:g.types.array(Fp),currentBreakpoint:g.types.string}).views(e=>({get json(){return e.list.map(t=>t.json)},jsonByPanelIDSet(t){return e.list.map(r=>r.jsonByPanelIDSet(t))},get root(){return g.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 wh(t)},get cols(){const t={};return e.list.forEach(r=>{t[r.id]=36}),t},get breakpoints(){const t={};return e.list.forEach(r=>{t[r.id]=r.breakpoint}),t},get breakpointNameRecord(){const t={};return e.list.forEach(r=>{t[r.name]=r.breakpoint}),t},get breakpointRanges(){const t=e.list.map(r=>({id:r.id,name:r.name,min:r.breakpoint,max:1/0,text:""}));return t.sort((r,s)=>r.min-s.min).forEach((r,s)=>{s!==t.length-1&&(r.max=t[s+1].min)}),t.forEach(r=>{r.text=wh(r)}),t},get breakpointsInfo(){return e.list.map(t=>({id:t.id,name:t.name,breakpoint:t.breakpoint})).sort((t,r)=>t.breakpoint-r.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 r=new Set(t);return this.currentLayoutSet.list.filter(i=>r.has(i.panelID))},gridLayouts(t){const r=new Set(t),s={};return e.list.forEach(i=>{s[i.id]=i.list.filter(o=>r.has(o.panelID)).map(o=>o.layoutProperies)}),s},findItemByPanelID(t){return this.currentLayoutSet.findByPanelID(t)}})).actions(e=>({setCurrentBreakpoint(t){console.log("🔴 onBreakpointChange:",t),e.currentBreakpoint=t},afterCreate(){g.addDisposer(e,te.reaction(()=>e.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),Ch=Qp.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!g.getParent(e,2).findByKey(t)}})),Lo=g.types.model("SQLSnippetsRenderModel",{current:g.types.optional(g.types.array(Ch),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,r)=>(t[r.key]=r.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(r=>r.key===t)},findByKeySet(t){return e.current.filter(r=>t.has(r.key))}})).actions(e=>({getSchema(t){return{definition:{sqlSnippets:e.findByKeySet(new Set(t)).map(i=>i.json)},version:nn}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t),null,2);Jn("SQL Snippets",r)}}));function Sh(e){return{current:e}}function Ir(e,t,r,s){return e.reduce((i,o)=>{try{i[o[t]]=Xs(o[r],s)}catch(l){i[o[t]]=l.message}return i},{})}class Th{constructor(t){N(this,"origin");N(this,"copy");this.origin=t,this.copy=g.clone(t),te.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!v.isEqual(g.getSnapshot(this.origin),g.getSnapshot(this.copy))}commit(){g.applySnapshot(this.origin,g.getSnapshot(this.copy))}reset(){g.applySnapshot(this.copy,g.getSnapshot(this.origin))}update(t){g.applySnapshot(this.copy,t)}}const kh=e=>new Th(e),k3=({description:e,isDescriptionEmpty:t})=>t?null:n.jsx(a.Tooltip,{color:"white",label:n.jsx(Un,{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:n.jsx(a.Box,{sx:{height:"16px",alignSelf:"center"},children:n.jsx(C.IconInfoCircle,{size:16,color:"gray"})})}),D3=k.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:s,...i},value:o,onChange:l})=>n.jsxs(a.Box,{children:[n.jsx(a.Text,{size:"sm",children:" "}),n.jsx(a.Checkbox,{label:n.jsxs(a.Group,{wrap:"nowrap",justify:"space-between",align:"middle",gap:6,children:[n.jsx(a.Box,{sx:{flexGrow:1},children:e}),n.jsx(k3,{description:r,isDescriptionEmpty:s})]}),checked:o||!1,onChange:c=>l(c.currentTarget.checked),...i,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),z3=({value:e,onChange:t,close:r,max_days:s,allowSingleDateInRange:i})=>{const{i18n:o}=_.useTranslation(),l=e.value,[c,u]=l,d=f.useMemo(()=>c||new Date,[c]),p=f.useMemo(()=>{if(c&&!u)return c},[c,u]),h=f.useMemo(()=>{if(c&&!u&&s>0)return A(c).add(s-1,"days").toDate()},[c,u,s]),x=b=>{const[m,j]=b;t({value:b,shortcut:null}),m&&j&&r()};return n.jsx(_l.DatePicker,{defaultDate:d,numberOfColumns:2,type:"range",value:l,onChange:x,onNextMonth:console.log,minDate:p,maxDate:h,allowSingleDateInRange:i,locale:o.language})},I3=({begin:e,end:t})=>{const{t:r}=_.useTranslation(),s=f.useMemo(()=>!t&&!e?Number.NaN:A(t).diff(A(e),"days")+1,[e,t]);if(Number.isNaN(s))return n.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const i=s===1?r("filter.widget.date_range.one_day"):r("filter.widget.date_range.x_days",{count:s});return n.jsx(a.Tooltip,{label:i,children:n.jsx(a.Badge,{size:"sm",variant:"light",children:s})})},M3=({max_days:e})=>{const{t}=_.useTranslation();return e?n.jsxs(n.Fragment,{children:[n.jsx(a.Group,{justify:"flex-end",children:n.jsx(a.Badge,{size:"xs",variant:"light",children:t("filter.widget.date_range.x_max_days",{max_days:e})})}),n.jsx(a.Divider,{variant:"dashed",my:10})]}):null},E3=({onChange:e})=>{const{t,i18n:r}=_.useTranslation(),s=l=>()=>{const c=l();e(c)},i=f.useMemo(()=>Up(),[]),o=r.language==="zh";return n.jsxs(n.Fragment,{children:[n.jsx(a.Divider,{variant:"dashed",my:10}),n.jsx(a.Table,{withTableBorder:!1,sx:{"tbody > tr":{border:"none"},"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:n.jsx(a.Table.Tbody,{children:Object.entries(i).map(([l,c])=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:n.jsx(a.Text,{size:"xs",c:"#555",fw:500,sx:{textAlignLast:"justify"},children:t(`filter.widget.date_range.shortcut.${l}.label`)})}),c.map(({key:u,value:d,getRange:p})=>n.jsx(a.Table.Td,{children:n.jsx(a.Button,{size:"compact-xs",variant:"subtle",onClick:s(p),children:t(`filter.widget.date_range.shortcut.${l}.${o?"full.":""}${u}`)})},u))]},l))})})]})},Dh=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),P3=({label:e,required:t,value:r,onChange:s,max_days:i,allowSingleDateInRange:o,inputFormat:l,disabled:c})=>{const{t:u}=_.useTranslation(),[d,{open:p,close:h}]=ze.useDisclosure(!1),[x,b]=r.value,m=x?A(x).format(l):"",j=b?A(b).format(l):"";return n.jsxs(a.Popover,{opened:d,onClose:h,position:"bottom-start",shadow:"md",children:[n.jsxs(a.Group,{justify:"flex-start",grow:!0,wrap:"nowrap",gap:0,w:"288px",sx:{marginTop:"3px"},children:[n.jsx(a.Popover.Target,{children:n.jsx(a.TextInput,{label:e,labelProps:{title:e},required:t,leftSection:n.jsx(C.IconCalendar,{size:16}),placeholder:u("filter.widget.date_range.start_date"),readOnly:!0,disabled:c,value:m,onFocus:p,styles:Dh(d),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},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to left, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})}),n.jsx(a.TextInput,{label:n.jsx(a.Group,{justify:"flex-end",children:n.jsx(I3,{begin:x,end:b})}),leftSection:n.jsx(C.IconMinus,{size:16}),placeholder:u("filter.widget.date_range.end_date"),readOnly:!0,disabled:!x||c,value:j,onFocus:p,styles:Dh(d),sx:{".mantine-Input-section":{transform:"translateX(-18px)"},".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}}})]}),n.jsxs(a.Popover.Dropdown,{p:"sm",children:[n.jsx(M3,{max_days:i}),n.jsx(z3,{value:r,onChange:s,close:h,allowSingleDateInRange:o,max_days:i}),n.jsx(E3,{onChange:s})]})]})},zh={value:[null,null],shortcut:null},Ih=k.observer(({label:e,config:t,value:r=zh,onChange:s,disabled:i})=>{const{inputFormat:o,required:l,max_days:c,allowSingleDateInRange:u}=t,d=f.useMemo(()=>{const p=lo(r.shortcut);return p||(Array.isArray(r.value)?r:zh)},[r]);return n.jsx(P3,{label:e,value:d,onChange:s,inputFormat:o,allowSingleDateInRange:u,max_days:c,required:l,disabled:i})}),A3=on.createStyles((e,{radius:t=4,name:r,...s})=>({root:{borderRadius:a.getRadius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef",...s,"&.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"}}})),L3=({disabled:e,radius:t,style:r,label:s,value:i,onChange:o,options:l,errorMessage:c,required:u})=>{const{t:d}=_.useTranslation(),{classes:p,cx:h}=A3({radius:t,name:"MultiSelectWidget"}),[x,b]=f.useState(!1),m=I=>{b(I)},j=x&&(i==null?void 0:i.length)>0,[D,T]=f.useState(""),z=f.useMemo(()=>{if(!D)return l;const I=D.toLowerCase(),M=P=>{var ae;return((ae=P.description)==null?void 0:ae.toLowerCase().includes(I))||P.label.toLowerCase().includes(I)};return l.filter(M)},[D,l]);return n.jsxs(a.Stack,{gap:3,children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsxs(a.Text,{className:p.label,size:"sm",children:[s,u&&n.jsx("span",{className:p.required,"aria-hidden":"true",children:"*"})]}),j&&n.jsx(a.Tooltip,{label:d("filter.widget.common.x_selected",{count:i.length}),children:n.jsx(a.Badge,{variant:"light",children:i.length})})]}),n.jsx(kl,{disabled:e,allowClear:!0,className:h(p.root,"check-select"),dropdownClassName:h(p.dropdown,""),onDropdownVisibleChange:m,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:r,clearIcon:()=>n.jsx(a.CloseButton,{size:"sm"}),value:i,onChange:o,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:n.jsx(xo,{errorMessage:c}),maxTagTextLength:10,maxTagPlaceholder:I=>d("filter.widget.common.x_selected",{count:I.length}),searchValue:D,onSearch:T,filterOption:!1,children:z.map(I=>n.jsxs(kl.Option,{title:I.label,children:[n.jsx(a.Text,{size:"sm","data-role":"label",children:I.label}),I.description&&n.jsx(a.Text,{size:"xs",c:"dimmed","data-role":"description",children:I.description})]},I.value))})]})},O3=k.observer(({label:e,config:t,value:r,onChange:s})=>{const i=Te(),o=!!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=o?u:!1,h=f.useMemo(()=>t.initialSelection(r),[r,t.initialSelection]),x=b=>s(b,!1);return n.jsx(L3,{label:e,options:t.options,style:{minWidth:"160px",width:d,maxWidth:p?d:"unset",borderColor:"#e9ecef"},disabled:p,value:[...h],onChange:x,errorMessage:c,required:t.required})}),V3=({option:e,...t})=>{const{label:r,description:s}=e;return n.jsx("div",{...t,children:n.jsx(a.Group,{wrap:"nowrap",children:n.jsxs("div",{children:[n.jsx(a.Text,{size:"sm","data-role":"label",children:r}),n.jsx(a.Text,{size:"xs",c:"dimmed","data-role":"description",children:s})]})})})},B3=k.observer(({label:e,config:t,value:r,onChange:s})=>{const{t:i}=_.useTranslation(),o=Te(),l=!!t.options_query_id,{state:c,error:u}=o.getDataStuffByID(t.options_query_id),d=c==="loading",p=f.useCallback((h,x)=>{h&&s(h,!1)},[s]);return n.jsx(a.Select,{label:e,data:t.options,disabled:l?d:!1,value:r,onChange:p,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"}},renderOption:V3,searchable:!u,nothingFoundMessage:u||i("filter.widget.common.selector_option_empty"),clearable:t.clearable})});function q3({label:e,config:t,value:r,onChange:s}){return n.jsx(a.TextInput,{label:e,value:r||"",onChange:i=>s(i.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const N3=k.observer(({filter:{type:e,config:t,key:r,...s},formFieldProps:i})=>{switch(e){case Q.Select:return n.jsx(B3,{...s,...i,config:t});case Q.MultiSelect:return n.jsx(O3,{...s,...i,config:t});case Q.TreeSelect:return n.jsx(f3,{...s,...i,config:t});case Q.TreeSingleSelect:return n.jsx(y3,{...s,...i,config:t});case Q.TextInput:return n.jsx(q3,{...s,...i,config:t});case Q.DateRange:return n.jsx(Ih,{...s,...i,config:t});case Q.Checkbox:return n.jsx(D3,{...s,...i,config:t});default:return null}}),$3=k.observer(f.forwardRef(({filter:e,...t},r)=>n.jsx("div",{className:"filter-root",ref:r,children:n.jsx(Ie,{children:n.jsx(N3,{filter:e,formFieldProps:t})})}))),G3=({disabled:e})=>{const{searchButtonProps:t}=ql(),{children:r="Search",...s}=t;return n.jsx(a.Button,{color:"blue",size:"sm",type:"submit",...s,disabled:e||s.disabled,children:r})};function F3(e){const t=re();f.useEffect(()=>{var r,s;(s=(r=t.filters).updatePreviewValues)==null||s.call(r,e)},[e])}const Q3=({opened:e,toggle:t})=>{const{t:r}=_.useTranslation();return n.jsx(a.Group,{justify:"flex-end",ml:-4,mt:-4,mb:e?4:0,children:n.jsx(a.Button,{size:"compact-xs",variant:"subtle",color:e?"gray":"blue",leftSection:e?n.jsx(C.IconChevronsUp,{size:14}):n.jsx(C.IconChevronsDown,{size:14}),onClick:t,children:r(e?"filter.hide_filters":"filter.show_filters")})})},Mh=k.observer(function({view:t}){const[r,{toggle:s}]=ze.useDisclosure(!0),i=Te(),{control:o,handleSubmit:l,reset:c}=y.useForm({defaultValues:i.filters.values,reValidateMode:"onBlur"}),u=y.useWatch({control:o});f.useEffect(()=>{c(i.filters.values)},[i.filters.values,c]),F3(u);const d=i.filters.visibleInView(t.id),p=f.useMemo(()=>d.every(m=>m.should_auto_submit),[d]),h=f.useMemo(()=>d.filter(m=>v.get(m,"config.required",!1)),[d]),x=f.useMemo(()=>h.length===0?!1:h.some(m=>!m.requiredAndPass(u[m.key])),[u,h]);if(d.length===0)return null;const b=(m,j)=>(D,T)=>{j(D),(m.should_auto_submit||T)&&i.filters.setValueByKey(m.key,D)};return n.jsxs("form",{onSubmit:l(i.filters.setValues),children:[n.jsx(Q3,{opened:r,toggle:s}),n.jsx(a.Collapse,{in:r,children:n.jsxs(a.Group,{className:"dashboard-filters",justify:"space-between",wrap:"nowrap",sx:p?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n.jsx(a.Group,{align:"flex-start",children:d.map(m=>n.jsx(y.Controller,{name:m.key,control:o,render:({field:j})=>n.jsx($3,{filter:m,value:j.value,onChange:b(m,j.onChange)})},m.id))}),!p&&n.jsx(a.Group,{sx:{alignSelf:"flex-end"},children:n.jsx(G3,{disabled:x})})]})})]})}),R3={viewPanelInFullScreen:v.noop,inFullScreen:!1},Ls=f.createContext(R3),W3=k.observer(({view:e})=>{const{t}=_.useTranslation(),r=se(),{panel:s}=Le(),i=s.realQueryOptions,o=c=>{r.editor.open(["_QUERIES_",c])},l=()=>{r.editor.open(["_VIEWS_",e.id,"_PANELS_",s.id,"_TABS_","Data"])};return i.length===0?null:n.jsxs(n.Fragment,{children:[n.jsx(a.Divider,{label:t(i.length>1?"query.labels":"query.label"),labelPosition:"center"}),n.jsx(a.Menu.Item,{onClick:l,leftSection:n.jsx(C.IconDatabase,{size:14}),children:t("data.label")}),i.map(c=>n.jsx(a.Menu.Item,{onClick:()=>o(c.value),leftSection:n.jsx(C.IconDatabase,{size:14}),children:c.label},c.value))]})}),U3=k.observer(({view:e,title:t})=>{const{t:r}=_.useTranslation(),s=se(),i=re(),o=dt.useModals(),{panel:l,downloadPanelScreenshot:c}=Le(),{id:u}=l,{viewPanelInFullScreen:d,inFullScreen:p}=f.useContext(Ls),h=()=>{i.duplicatePanelByID(u,e.id)},x=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u,"_TABS_","Panel"])},b=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u,"_TABS_","Variables"])},m=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u,"_TABS_","Visualization"])},j=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u,"_TABS_","Interactions"])},D=()=>o.openConfirmModal({title:`${r("panel.delete")}?`,labels:{confirm:r("common.actions.confirm"),cancel:r("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.removePanelByID(u,e.id),confirmProps:{color:"red"},zIndex:320}),T=f.useCallback(()=>{d(u)},[u,d]),z=!p&&e.type!==F.Modal;return n.jsx(n.Fragment,{children:n.jsx(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:n.jsxs(a.Menu,{withinPortal:!0,children:[n.jsx(a.Menu.Target,{children:n.jsx(a.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),n.jsxs(a.Menu.Dropdown,{children:[n.jsx(a.Menu.Item,{onClick:l.refreshData,leftSection:n.jsx(C.IconRefresh,{size:14}),children:r("common.actions.refresh")}),n.jsx(a.Menu.Item,{onClick:l.downloadData,leftSection:n.jsx(C.IconDownload,{size:14}),children:r("common.actions.download_data")}),n.jsx(a.Menu.Item,{onClick:l.downloadSchema,leftSection:n.jsx(C.IconCode,{size:14}),children:r("common.actions.download_schema")}),n.jsx(a.Menu.Item,{onClick:c,leftSection:n.jsx(C.IconCamera,{size:14}),children:r("common.actions.download_screenshot")}),z&&n.jsx(a.Menu.Item,{onClick:T,leftSection:n.jsx(C.IconArrowsMaximize,{size:14}),disabled:!0,children:r("common.actions.enter_fullscreen")}),n.jsx(W3,{view:e}),n.jsx(a.Divider,{label:r("common.actions.edit"),labelPosition:"center"}),n.jsx(a.Menu.Item,{onClick:x,leftSection:n.jsx(C.IconAppWindow,{size:14}),children:r("panel.label")}),n.jsx(a.Menu.Item,{onClick:b,leftSection:n.jsx(C.IconVariable,{size:14}),children:r("panel.variable.labels")}),n.jsx(a.Menu.Item,{onClick:m,leftSection:n.jsx(C.IconChartHistogram,{size:14}),children:r("visualization.label")}),n.jsx(a.Menu.Item,{onClick:j,leftSection:n.jsx(C.IconRoute,{size:14}),children:r("interactions.label")}),n.jsx(a.Divider,{label:r("common.actions.actions"),labelPosition:"center"}),n.jsx(a.Menu.Item,{onClick:h,leftSection:n.jsx(C.IconCopy,{size:14}),children:r("common.actions.duplicate")}),n.jsx(a.Menu.Item,{color:"red",onClick:D,leftSection:n.jsx(C.IconTrash,{size:14}),children:r("common.actions.delete")})]})]})})})});function Y3(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const K3=k.observer(()=>{const e=Te(),{panel:t}=He(),r=f.useMemo(()=>fs(t.description,t.json.variables,e.payloadForViz,t.data),[t.data,t.description,t.json.variables,e.payloadForViz]);return n.jsx(Un,{value:r,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}},dashboardState:e.dashboardState,variableAggValueMap:t.variableAggValueMap})}),Oo=k.observer(()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState(!1),{panel:s}=He();return Y3(s.description)?null:n.jsxs(n.Fragment,{children:[n.jsx(a.Modal,{opened:t,onClose:()=>r(!1),title:s.title.show?s.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:n.jsx(K3,{})}),n.jsx(a.Tooltip,{label:e("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:n.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n.jsx(C.IconInfoCircle,{size:20})})})]})}),fE="",X3=k.observer(function(){const{panel:t}=He(),{name:r,title:s}=t;return s.show?n.jsx(a.Group,{grow:!0,justify:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:n.jsx(a.Text,{size:"sm",ta:"center",lineClamp:1,className:"panel-title-text",children:r})}):null});function H3(e){const t=f.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const s=t.current;if(!s)return;const i=s.offsetWidth*2,o=s.offsetHeight*2;Sl.toBlob(t.current,{bgcolor:"white",width:i,height:o,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 Eh=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(Eh||{}),Os=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(Os||{});class Z3{constructor(t){N(this,"vizInstance");N(this,"operationManager");N(this,"triggerManager");N(this,"vizManager");N(this,"runningMigration");N(this,"panelModel");N(this,"status","notStarted");this.panelModel=t.getRequired(Pe.instanceScope.panelModel),this.vizInstance=t.getRequired(Pe.instanceScope.vizInstance),this.operationManager=t.getRequired(Pe.instanceScope.operationManager),this.triggerManager=t.getRequired(Pe.instanceScope.triggerManager),this.vizManager=t.getRequired(Pe.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(r){return console.warn("check migration failed",r),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(r=>r())),"migrated"}catch(r){return console.warn("migration failed",r),"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),r={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(r)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),r={configData:this.vizInstance.instanceData};return t.migrator.needMigration(r)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function Ph(e){const{panel:t}=He();return f.useCallback(r=>{const s=r.getRequired(Pe.vizManager),i=s.resolveComponent(e.viz.type);return r.createScoped().provideFactory(Pe.instanceScope.vizInstance,()=>s.getOrCreateInstance(e)).provideFactory(Pe.instanceScope.interactionManager,o=>{const l=o.getRequired(Pe.instanceScope.vizInstance);return new wa(l,i,bs)}).provideFactory(Pe.instanceScope.operationManager,o=>o.getRequired(Pe.instanceScope.interactionManager).operationManager).provideFactory(Pe.instanceScope.triggerManager,o=>o.getRequired(Pe.instanceScope.interactionManager).triggerManager).provideValue(Pe.instanceScope.panelModel,t).provideFactory(Pe.instanceScope.migrator,o=>new Z3(o))},[e.viz.type,e.viz.conf])}function Ah(e){const[t,r]=f.useState(!1),s=Ip().getRequired(Pe.instanceScope.migrator);return Y.useAsyncEffect(async()=>{const i=s.status===Os.notStarted;r(s.status===Os.done),s.status===Os.notStarted&&s.runMigration().then(o=>{o===Eh.migrated&&i&&(e==null||e())}).finally(()=>{r(!0)})},[s]),t}function Lh(e,t){const r=Ip().getRequired(Pe.instanceScope.vizInstance);return f.useEffect(()=>(r.instanceData.setItem(null,t.viz.conf),r.instanceData.watchItem(null,s=>{e(s)})),[e,t.viz.type]),r}function J3({setVizConf:e,...t}){const{panel:r}=t,s=Lh(e,r),i=Ah(()=>{Nt.showNotification({title:`${r.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return Y.useAsyncEffect(async()=>{await s.instanceData.setItem(null,r.viz.conf)},[s,r.viz.type]),i?n.jsx(_y,{...t}):n.jsx(a.Text,{size:"sm",children:"Checking update..."})}function e5(e){const{panel:t,setVizConf:r}=e;Lh(r,t);const{inEditMode:s}=f.useContext($r);return Ah(()=>{s&&Nt.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?n.jsx(vy,{...e}):n.jsx(a.Text,{size:"sm",children:"Checking update"})}const xE="";function t5(e,t){const{vizManager:r}=f.useContext(tn),{panel:{viz:s,title:i,id:o,name:l,description:c,queryIDs:u,variables:d}}=He(),p={id:o,name:l,title:i,description:c,queryIDs:u,viz:s},h=Ph(p);try{return r.resolveComponent(s.type),n.jsx(Ms,{configure:h,children:n.jsx(e5,{setVizConf:s.setConf,panel:p,measure:t,data:e,variables:d,vizManager:r})})}catch(x){return console.info(v.get(x,"message")),null}}const Oh=k.observer(function({data:t}){const{ref:r,width:s,height:i}=ze.useElementSize(),o=t5(t,{w:s,h:i}),l=s>0&&i>0;return n.jsx("div",{className:"viz-root",ref:r,children:n.jsx(a.Box,{sx:{width:s,height:i,overflow:"hidden"},children:l&&n.jsx(Ie,{children:o})})})}),Vh=k.observer(({panel:e})=>n.jsxs(a.Stack,{children:[e.queryErrors.map((t,r)=>n.jsx(a.Text,{c:"red",size:"sm",ta:"center",ff:"monospace",children:t},`${r}-${t}`)),n.jsx(a.Text,{c:"gray",ta:"center",size:"sm",children:e.queryStateMessages})]})),Vo=k.observer(({panel:e})=>n.jsxs(a.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[n.jsx(a.LoadingOverlay,{visible:e.dataLoading,transitionProps:{exitDuration:0}}),!e.canRenderViz&&n.jsx(Vh,{panel:e}),e.canRenderViz&&n.jsx(Oh,{data:e.data})]})),n5={border:"1px solid #e9ecef"},Bh=k.observer(({panel:e,panelStyle:t,dropdownContent:r})=>{const{ref:s,downloadPanelScreenshot:i}=H3(e);return e.title.show,n.jsx(ii,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:i},children:n.jsxs(a.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,ref:s,p:0,sx:{...n5,...t},children:[n.jsx(a.Box,{className:"panel-description-popover-wrapper",children:n.jsx(Oo,{})}),r,n.jsx(X3,{}),n.jsx(Vo,{panel:e})]})})}),r5={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function s5(e){return e.style.border.enabled?{}:r5}const qh=k.observer(function({panel:t,view:r}){const s=s5(t);return n.jsx(Bh,{panel:t,panelStyle:s,dropdownContent:n.jsx(U3,{view:r,title:t.name})})});function i5(e){return!["richText","button"].includes(e)}const a5=k.observer(({view:e,title:t})=>{const{t:r}=_.useTranslation(),{panel:s,downloadPanelScreenshot:i}=He(),{id:o}=s,{viewPanelInFullScreen:l,inFullScreen:c}=f.useContext(Ls),u=f.useCallback(()=>{l(o)},[o,l]),d=!c&&e.type!==F.Modal;return i5(s.viz.type)?n.jsx(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:n.jsxs(a.Menu,{withinPortal:!0,children:[n.jsx(a.Menu.Target,{children:n.jsx(a.Box,{className:"panel-dropdown-target"})}),n.jsxs(a.Menu.Dropdown,{children:[n.jsx(a.Menu.Item,{onClick:s.refreshData,leftSection:n.jsx(C.IconRefresh,{size:14}),children:r("common.actions.refresh")}),n.jsx(a.Menu.Item,{onClick:s.downloadData,leftSection:n.jsx(C.IconDownload,{size:14}),children:r("common.actions.download_data")}),n.jsx(a.Menu.Item,{onClick:i,leftSection:n.jsx(C.IconCamera,{size:14}),children:r("common.actions.download_screenshot")}),d&&n.jsx(a.Menu.Item,{onClick:u,leftSection:n.jsx(C.IconArrowsMaximize,{size:14}),children:r("common.actions.enter_fullscreen")})]})]})}):null});function o5(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const Bo=k.observer(({panel:e,view:t})=>{const r=o5(e);return n.jsx(Bh,{panel:e,panelStyle:r,dropdownContent:n.jsx(a5,{title:e.name,view:t})})}),l5={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},Nh=k.observer(function({view:t,panel:r,exitFullScreen:s}){return n.jsx(a.Modal,{opened:!0,fullScreen:!0,onClose:s,title:n.jsx(a.Button,{color:"blue",size:"xs",onClick:s,leftSection:n.jsx(C.IconArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:l5,children:n.jsx(a.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:n.jsx(Bo,{view:t,panel:r})})})});function $h(e,t,r){const{panels:s}=Te(),i=e.id==="Main",[o,l]=f.useState(()=>i&&s.findByID(t)?t:null),c=f.useCallback(h=>{l(h),i&&r(h)},[i,r]),u=f.useCallback(()=>{l(null),i&&r("")},[i,r]),d=o?s.findByID(o):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const mE="",c5=f.forwardRef(({h:e},t)=>n.jsx(a.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:n.jsx(C.IconArrowsMove,{size:16})})),u5=f.forwardRef(({handleAxis:e,...t},r)=>n.jsx(a.ActionIcon,{ref:r,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:n.jsx(C.IconChevronDownRight,{size:16})})),d5=Br.WidthProvider(Br.Responsive),p5=k.observer(({view:e,className:t="layout"})=>{const s=re().layouts,i=s.items(e.panelIDs),o=s.gridLayouts(e.panelIDs),l=(d,p,h,x)=>{h.h<30&&(h.h=30,x.h=30),h.w<4&&(h.w=4,x.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 n.jsx(d5,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:s.cols,layouts:o,draggableHandle:".react-grid-customDragHandle",resizeHandle:n.jsx(u5,{}),onResize:l,breakpoints:s.breakpoints,onBreakpointChange:s.setCurrentBreakpoint,onResizeStop:c,onDragStop:u,width:s.currentLayoutPreviewWidth,children:i.map(d=>n.jsxs("div",{"data-grid":d.layoutProperies,className:"panel-grid-item",children:[n.jsx(c5,{h:d.h}),n.jsx(qh,{view:e,panel:d.panel})]},d.id))})}),h5=Br.WidthProvider(Br.Responsive),g5=k.observer(({view:e,className:t="layout"})=>{const r=Te(),s=r.layouts.items(e.panelIDs),i=r.layouts.gridLayouts(e.panelIDs);return n.jsx(h5,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:r.layouts.cols,layouts:i,breakpoints:r.layouts.breakpoints,onBreakpointChange:r.layouts.setCurrentBreakpoint,children:s.map(o=>n.jsx("div",{"data-grid":o.layoutProperies,className:"panel-grid-item",children:n.jsx(Bo,{view:e,panel:o.panel})},o.id))})});function qo(e){const t=f.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 f5=k.observer(({downloadScreenshot:e})=>{const{t}=_.useTranslation(),[r,{setTrue:s,setFalse:i}]=Y.useBoolean(!1),o=Vl(),l=Te(),c=()=>{const u=JSON.stringify(l.contentJSON,null,2),d=`${o.name}__${l.name}`;Jn(d,u)};return n.jsxs(a.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[n.jsx(a.Menu.Target,{children:n.jsx(a.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:n.jsx(a.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:s,onMouseLeave:i,sx:{opacity:r?1:.6,transform:`translateX(${r?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:n.jsx(C.IconShare3,{size:"1rem"})})})}),n.jsxs(a.Menu.Dropdown,{children:[n.jsx(a.Menu.Item,{leftSection:n.jsx(C.IconCamera,{size:14}),onClick:e,children:t("common.actions.download_screenshot")}),n.jsx(a.Menu.Divider,{}),n.jsx(a.Menu.Item,{leftSection:n.jsx(C.IconDownload,{size:14}),onClick:l.queries.downloadAllData,children:t("common.actions.download_data")}),n.jsx(a.Menu.Item,{leftSection:n.jsx(C.IconCode,{size:14}),onClick:c,children:t("common.actions.download_schema")})]})]})}),Gh=k.observer(({children:e,view:t,sx:r={}})=>{const{ref:s,downloadScreenshot:i}=qo(t);return n.jsxs(n.Fragment,{children:[n.jsx(a.Box,{ref:s,pt:10,pb:10,sx:r,children:e}),n.jsx(f5,{downloadScreenshot:i})]})}),Fh=k.observer(({downloadScreenshot:e})=>n.jsx(a.ActionIcon,{className:"download-screenshot-button",color:"blue",variant:"subtle",onClick:e,children:n.jsx(C.IconCamera,{size:14})})),x5=k.observer(({children:e,view:t})=>{const r=Te(),s=t.config,i=r.views.visibleViewIDs.includes(t.id),o=()=>r.views.rmVisibleViewID(t.id),{ref:l,downloadScreenshot:c}=qo(t);return n.jsx(a.Modal,{size:s.width,centered:!0,opened:i,onClose:o,withCloseButton:!1,title:n.jsxs(a.Group,{justify:"space-between",px:"1rem",h:"48px",children:[n.jsx(a.Box,{children:s.custom_modal_title.value}),n.jsx(Fh,{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:n.jsx(a.Box,{ref:l,children:e})})}),m5=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},b5=k.observer(({view:e})=>{const t=Te(),r=e.config;return n.jsxs(a.Tabs,{className:"render-view-tabs",variant:r.variant,orientation:r.orientation,value:e.tab,onChange:e.setTab,styles:{root:{height:"100%",overflow:r.orientation==="horizontal"?"hidden":"auto"},panel:{padding:r.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[n.jsx(a.Tabs.List,{grow:r.grow,children:r.tabsInOrder.map(s=>n.jsx(a.Tabs.Tab,{value:s.id,sx:m5(s),disabled:!s.view_id,children:s.name??s.id},s.id))}),r.tabsInOrder.map(s=>{const i=t.views.findByID(s.view_id);return i?n.jsx(a.Tabs.Panel,{value:s.id,children:n.jsx(Vs,{view:i})},s.id):null})]})}),y5=k.observer(({view:e,children:t})=>{switch(e.type){case F.Modal:return n.jsx(x5,{view:e,children:t});case F.Tabs:return n.jsx(b5,{view:e});case F.Division:default:return n.jsx(Gh,{view:e,children:t})}}),v5=k.observer(({children:e,view:t})=>{const s=re().layouts,[i,o]=ze.useResizeObserver();return f.useEffect(()=>{s.setCurrentLayoutWrapperWidth(o.width)},[o.width]),n.jsx(a.Box,{sx:{height:"100%"},ref:i,children:n.jsx(a.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:s.currentLayoutPreviewWidth??"100%",transform:`scale(${s.divisionPreviewScale})`,transformOrigin:"0 0"},children:n.jsx(Gh,{view:t,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:e})})})});function Qh(e){return e.replace(/(vw|vh)/,"%")}const _5=k.observer(({children:e,view:t})=>{const r=t.config,{width:s,height:i}=f.useMemo(()=>({width:Qh(r.width),height:Qh(r.height)}),[r.width,r.height]),{ref:o,downloadScreenshot:l}=qo(t);return n.jsx(a.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:n.jsx(a.Modal,{size:r.width,opened:!0,onClose:v.noop,withCloseButton:!1,title:n.jsxs(a.Group,{justify:"space-between",px:"1rem",h:"48px",children:[n.jsx(a.Box,{children:r.custom_modal_title.value}),n.jsx(Fh,{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:n.jsx(a.Box,{ref:o,children:e})})})}),j5=({variant:e,orientation:t})=>{const r={root:{height:"100%",overflow:"hidden"},list:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(r.tab.paddingTop="6px",r.tab.paddingBottom="6px"),t==="vertical"&&(r.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},r.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),r},w5=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},C5=k.observer(({view:e})=>{const{t}=_.useTranslation(),r=dt.useModals(),s=re(),i=f.useMemo(()=>s.views.options.filter(d=>d.type===F.Division),[e.id,s.views.options]),o=e.config,l=d=>r.openConfirmModal({title:`${t("view.component.tabs.tab.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.removeTab(d)},confirmProps:{color:"red"},zIndex:320}),c=o.tabs.length===0,u=o.tabsInOrder.length===0?void 0:o.tabsInOrder[0].id;return n.jsxs(a.Tabs,{className:"preview-view-tabs",variant:o.variant,orientation:o.orientation,value:e.tab||u,onChange:e.setTab,styles:j5(o),children:[n.jsxs(a.Tabs.List,{grow:o.grow,children:[o.tabsInOrder.map(d=>n.jsx(a.Tabs.Tab,{value:d.id,sx:w5(d),children:d.name??d.id},d.id)),n.jsx(a.Tabs.Tab,{onClick:o.addTab,value:"add",className:"add-a-tab",children:n.jsx(C.IconPlus,{size:18,color:"#228be6"})})]}),o.tabsInOrder.map((d,p)=>{const h=s.views.findByID(d.view_id);return n.jsxs(a.Tabs.Panel,{value:d.id,sx:{position:"relative"},children:[n.jsxs(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[n.jsx(a.Overlay,{backgroundOpacity:.8,color:"#FFF",blur:10,zIndex:100}),n.jsxs(a.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[n.jsx(a.TextInput,{label:t("view.component.tabs.tab.name"),required:!0,value:d.name,onChange:x=>d.setName(x.currentTarget.value)}),n.jsx(a.Select,{label:t("view.label"),value:d.view_id,onChange:d.setViewID,data:i}),n.jsx(a.NumberInput,{label:t("view.component.tabs.tab.order"),required:!0,value:d.order,onChange:x=>d.setOrder(x||0),min:0,max:1e3,step:1}),n.jsx(a.ColorInput,{label:t("view.component.tabs.tab.color"),value:d.color,onChange:d.setColor,disabled:o.variant!=="default"}),h&&n.jsx(a.Button,{mt:20,variant:"gradient",leftSection:n.jsx(C.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>s.views.setIDOfVIE(h.id),children:t("view.component.tabs.tab.switch_to_view",{name:h.name})}),n.jsx(a.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>l(p),disabled:c,leftSection:n.jsx(C.IconTrash,{size:14}),children:t("view.component.tabs.tab.delete")})]})]}),h&&n.jsx(Vs,{view:h})]},d.id)})]})}),S5=k.observer(({view:e,children:t})=>{switch(e.type){case F.Modal:return n.jsx(_5,{view:e,children:t});case F.Tabs:return n.jsx(C5,{view:e});case F.Division:default:return n.jsx(v5,{view:e,children:t})}}),Rh=k.observer(function({view:t}){const s=re().layouts.divisionPreviewScale!==1;return n.jsx(Ls.Provider,{value:{viewPanelInFullScreen:v.noop,inFullScreen:!1},children:n.jsx(a.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:s?"transparent":"#efefef"},children:n.jsx(S5,{view:t,children:n.jsxs(a.Box,{sx:{position:"relative"},children:[n.jsx(a.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n.jsx(Mh,{view:t})}),n.jsx(p5,{view:t})]})})})})}),Vs=k.observer(function({view:t}){const{fullScreenPanelID:r,setFullScreenPanelID:s}=Wl(),{viewPanelInFullScreen:i,exitFullScreen:o,inFullScreen:l,fullScreenPanel:c}=$h(t,r,s);return n.jsx(Ls.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:l},children:n.jsxs(a.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===F.Modal?"0 !important":"100%"},children:[l&&n.jsx(Nh,{view:t,panel:c,exitFullScreen:o}),n.jsx(y5,{view:t,children:n.jsxs(a.Box,{sx:{position:"relative"},children:[!l&&n.jsx(a.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n.jsx(Mh,{view:t})}),!l&&n.jsx(g5,{view:t})]})})]})})});var Wh=(e=>(e.Use="use",e.Edit="edit",e))(Wh||{});const T5={[F.Division]:"Division",[F.Tabs]:"Tabs",[F.Modal]:"Modal"},Uh={[F.Division]:"rgba(255, 0, 0, 0.2)",[F.Modal]:"rgba(0, 0, 0, 0.2)",[F.Tabs]:"rgba(255, 200, 100, 0.4)"},k5={[F.Division]:"#ff4000",[F.Modal]:"#000",[F.Tabs]:"#ffad18"};function D5(e,t,r){g.addDisposer(e,g.addMiddleware(e,(s,i)=>{i(s,()=>{g.getType(s.context)===t&&s.type==="action"&&r(s.name,s.context)})}))}const Yh=g.types.compose("FiltersModel",Io,g.types.model("FiltersModel",{previewValues:g.types.optional(g.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===Q.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,widget:t.type}))},get sortedList(){return v.sortBy(e.current,t=>t.label.toLowerCase())}})).actions(e=>({replace(t){e.current=g.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(s=>!e.idSet.has(s.id));e.current.push(...r)},remove(t){e.current.splice(t,1)},removeByID(t){const r=e.current.findIndex(s=>s.id===t);r>=0&&e.current.splice(r,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){D5(e.current,yo,(r,s)=>{if(r==="setType"){const i=bh(s.config.default_value,s.config);e.setValueByKey(s.key,i),e.updatePreviewValues({...e.previewValues,[s.key]:i})}})}return{afterCreate(){t()}}}),Kh=Eo.views(e=>({get canPreviewData(){return e.isTransform?e.config.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"},get usage(){return e.contentModel.findQueryUsage(e.id)},get runBySet(){return new Set(e.run_by)},keyInRunBy(t){return this.runBySet.has(t)}})).actions(e=>({changeRunByRecord(t,r){const s=new Set(e.run_by);r?s.add(t):s.delete(t),e.run_by.length=0,e.run_by.push(...s)}})),Xh=g.types.compose("QueriesModel",Po,g.types.model({current:g.types.optional(g.types.array(Kh),[])})).views(e=>({get options(){const t=e.current.map(r=>({value:r.id,label:r.name,_type:"query"}));return v.sortBy(t,r=>r.label.toLowerCase())},get optionsWithoutTransform(){const t=e.current.filter(r=>r.type!==J.Transform).map(r=>({value:r.id,label:r.name,_type:"query"}));return v.sortBy(t,r=>r.label.toLowerCase())},get sortedList(){return v.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=g.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(s=>!e.idSet.has(s.id));e.current.push(...r)},remove(t){e.current.splice(t,1)},replaceByIndex(t,r){e.current.splice(t,1,r)},removeQuery(t){const r=e.current.find(s=>s.id===t);r&&(g.detach(r),e.current.remove(r))},removeQueries(t){const r=new Set(t);e.current.forEach(i=>{r.has(i.id)&&g.detach(i)});const s=[...e.current];v.remove(s,i=>r.has(i.id)),e.current=g.cast(s)}})),Hh=Lo.views(e=>({get sortedList(){return v.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(r=>({label:r.key,value:r.key,_type:"sql_snippet"}));return v.sortBy(t,r=>r.label.toLowerCase())}})).actions(e=>({replace(t){e.current=g.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(s=>!e.keySet.has(s.key));e.current.push(...r)},remove(t){e.current.splice(t,1)},removeByKey(t){const r=e.current.findIndex(s=>s.key===t);r>=0&&e.current.splice(r,1)},removeByKeys(t){const r=new Set(t);e.current.forEach(i=>{r.has(i.key)&&g.detach(i)});const s=[...e.current];v.remove(s,i=>r.has(i.key)),e.current=g.cast(s)},replaceByIndex(t,r){e.current.splice(t,1,r)}})),z5=g.types.model({data:g.types.optional(g.types.frozen(),[]),state:g.types.optional(g.types.enumeration(["idle","loading","error"]),"idle"),error:g.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),I5=g.types.model({data:g.types.optional(g.types.frozen(),[]),state:g.types.optional(g.types.enumeration(["idle","loading","error"]),"idle"),error:g.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),M5=g.types.model({page:g.types.optional(g.types.number,1),limit:g.types.optional(g.types.number,20),data:g.types.optional(g.types.frozen(),[]),total:g.types.optional(g.types.number,0),state:g.types.optional(g.types.enumeration(["idle","loading","error"]),"idle"),error:g.types.frozen()}).views(e=>({get keywords(){return g.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:r}=g.getParent(e,1);return`${r}||${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:r}=e.keywords;return`
482
482
  SELECT count(*) AS total
483
483
  FROM ${r}.${t}
484
484
  `}})).actions(e=>({setPage(t){e.page=t},resetPage(){e.page=1},setLimit(t){e.limit=t}})).actions(e=>({afterCreate(){g.addDisposer(e,te.reaction(()=>e.keywordString,e.resetPage,{fireImmediately:!1,delay:0})),g.addDisposer(e,te.reaction(()=>e.limit,e.resetPage,{fireImmediately:!1,delay:0}))}})),E5=g.types.model({data:g.types.optional(g.types.frozen(),{}),state:g.types.optional(g.types.enumeration(["idle","loading","error"]),"idle"),error:g.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return Object.keys(e.data).length===0}})),P5=g.types.model({tables:g.types.optional(E5,{}),columns:g.types.optional(z5,{}),tableData:g.types.optional(M5,{}),indexes:g.types.optional(I5,{}),table_schema:g.types.optional(g.types.string,""),table_name:g.types.optional(g.types.string,"")}).views(e=>({get dataSource(){return g.getParent(e)},get key(){return this.dataSource.key},get type(){return this.dataSource.type},get sqlDataSourceType(){return this.type},get reloadConditionString(){const t=this.type,{table_name:r,table_schema:s}=e;return`${t};${r};${s}`}})).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(e=>({setKeywords(t,r){e.table_schema=t,e.table_name=r}})).actions(e=>({initKeywords(){if(e.tables.empty)return;const t=Object.keys(e.tables.data)[0],r=e.tables.data[t][0].table_name;e.setKeywords(t,r)}})).actions(e=>{const t=g.flow(function*(){var r;(r=e.controllers.tables)==null||r.abort(),e.controllers.tables=new AbortController,e.tables.state="loading";try{const s=yield*g.toGenerator(gt.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(!pt.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:g.flow(function*(){var r;(r=e.controllers.columns)==null||r.abort(),e.controllers.columns=new AbortController,e.columns.state="loading";try{e.columns.data=yield*g.toGenerator(gt.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(pt.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:g.flow(function*(){var r;(r=e.controllers.indexes)==null||r.abort(),e.controllers.indexes=new AbortController,e.indexes.state="loading";try{e.indexes.data=yield*g.toGenerator(gt.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(pt.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:g.flow(function*(){var s;(s=e.controllers.tableData)==null||s.abort(),e.controllers.tableData=new AbortController;const r=e.tableData;r.state="loading";try{r.data=yield*g.toGenerator(gt.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:r.limit,offset:r.offset},{params:{query_type:"DATA"}}));const[{total:i}]=yield*g.toGenerator(gt.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"}}));r.total=Number(i),r.state="idle",r.error=null}catch(i){if(pt.isCancel(i))r.state="idle",r.error=null;else{r.data=[];const o=v.get(i,"message","unkown error");r.error=v.get(i,"response.data.detail.message",o),r.state="error"}}})}}).actions(e=>({afterCreate(){g.addDisposer(e,te.reaction(()=>e.reloadConditionString,e.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(e=>({afterCreate(){g.addDisposer(e,te.reaction(()=>e.reloadConditionString,e.loadIndexes,{fireImmediately:!1,delay:500})),g.addDisposer(e,te.reaction(()=>`${e.reloadConditionString};limit:${e.tableData.limit};offset:${e.tableData.offset}`,e.loadTableData,{fireImmediately:!1,delay:0}))}}));function A5(e){var t;if("cols"in e){const{cols:r}=e;return{filters:r.filter(s=>s.type==="filter").map(s=>s.metricSourceCol),groupBys:r.filter(s=>s.type==="group_by").map(s=>s.metricSourceCol),trendingDateCol:((t=r.find(s=>s.type==="trending_date_col"))==null?void 0:t.metricSourceCol)??null}}return{filters:e.filters,groupBys:e.groupBys,trendingDateCol:null}}const Zh={string:"维度列",number:"数值列",date:"数值列",boolean:"维度列",dimension:"扩展维度"};function Jh(e){return v.groupBy(e,r=>{const{dataType:s}=r;return s?Zh[s]:r.dimension!==null?Zh.dimension:"ERROR"})}function L5(e){if(e.length===0)return[];const t=Jh(e);return Object.entries(t).map(([s,i])=>({group:`${s}(${i.length})`,items:i.map(o=>{const{dataType:l,dimension:c}=o;return c?{group:o.name,description:o.description,items:c.fields.map(u=>({label:u.field,value:`${o.name} -> ${u.field}`,...u}))}:{label:o.name,value:o.name,...o}})}))}function O5(e){if(e.length===0)return[];const t=Jh(e);return Object.entries(t).map(([s,i])=>({group:`${s}(${i.length})`,items:i.map(o=>({label:o.name,value:o.name,description:o.description,dataType:o.dataType??"dimension",dimension:o.dimension}))}))}function V5(e,t){if(!t)throw new Error("Shouldnt run query without ID");if(e==="derived")return`/buffet/api/metric_management/derived_metric/${t}`;if(e==="combined")return`/buffet/api/metric_management/combined_metric/${t}`;throw new Error(`Unexpected metric type[${e}]`)}const B5=g.types.model({data:g.types.optional(g.types.frozen(),null),filters:g.types.optional(g.types.frozen(),[]),groupBys:g.types.optional(g.types.frozen(),[]),trendingDateCol:g.types.optional(g.types.frozen(),null),state:g.types.optional(g.types.enumeration(["idle","loading","error"]),"idle"),error:g.types.frozen()}).volatile(()=>({controller:new AbortController})).views(e=>({get loading(){return e.state==="loading"},get hasData(){return e.data!==null},get mmInfo(){return g.getParent(e)},get metricID(){return this.mmInfo.metricID},get metric(){return this.mmInfo.metric},get metricType(){var t;return(t=this.metric)==null?void 0:t.type},get filterColOptions(){return L5(e.filters)},get groupByColOptions(){return O5(e.groupBys)},get flatGroupByColOptions(){const t=this.groupByColOptions,r=[];return t.forEach(({group:s,items:i})=>{r.push(...i)}),r},getGroupByOptions(t){const r=new Set(t);return this.flatGroupByColOptions.filter(s=>r.has(s.value))}})).actions(e=>({load:g.flow(function*(){var t;if(e.mmInfo.type===J.MericoMetricSystem&&!(!e.metricID||!e.metricType)){(t=e.controller)==null||t.abort(),e.controller=new AbortController,e.state="loading";try{const r=V5(e.metricType,e.metricID),s=ps(e.mmInfo.dataSource,{url:r,method:"GET",data:{key:e.mmInfo.key}}),i=yield*g.toGenerator(gt.mericoMetricInfo(e.controller.signal)({key:e.mmInfo.key,query:JSON.stringify(s),...e.mmInfo.additionalQueryInfo},e.controller.signal)),o=hs(e.mmInfo.dataSource,i),l=v.cloneDeep(o.data),{filters:c,groupBys:u,trendingDateCol:d}=A5(o.data);e.data=l,e.filters=c,e.groupBys=u,e.trendingDateCol=d,e.state="idle",e.error=null}catch(r){if(!pt.isCancel(r)){e.data=null;const s=v.get(r,"message","unkown error");e.error=v.get(r,"response.data.detail.message",s),e.state="error"}}}})})).actions(e=>({afterCreate(){g.addDisposer(e,te.reaction(()=>e.metricID+e.metricType,e.load,{fireImmediately:!0,delay:0}))}})),q5=g.types.model({keyword:g.types.optional(g.types.string,""),data:g.types.optional(g.types.frozen(),[]),state:g.types.optional(g.types.enumeration(["idle","loading","error"]),"idle"),error:g.types.frozen()}).volatile(()=>({controller:new AbortController})).views(e=>({get loading(){return e.state==="loading"},get empty(){return Object.keys(e.data).length===0},get mmInfo(){return g.getParent(e)}})).actions(e=>({setKeyword(t){e.keyword=t}})).actions(e=>({load:g.flow(function*(){var t;if(e.mmInfo.type===J.MericoMetricSystem){(t=e.controller)==null||t.abort(),e.controller=new AbortController,e.state="loading";try{const r=ps(e.mmInfo.dataSource,{url:"/buffet/api/metric_management/search",method:"POST",data:{key:e.mmInfo.key},params:{search:e.keyword}}),s=yield*g.toGenerator(gt.mericoMetricInfo(e.controller.signal)({key:e.mmInfo.key,query:JSON.stringify(r),...e.mmInfo.additionalQueryInfo},e.controller.signal)),o=hs(e.mmInfo.dataSource,s).data;e.data=o,e.state="idle",e.error=null}catch(r){if(!pt.isCancel(r)){e.data=[];const s=v.get(r,"message","unkown error");e.error=v.get(r,"response.data.detail.message",s),e.state="error"}}}})})).actions(e=>({afterCreate(){g.addDisposer(e,te.reaction(()=>`${e.mmInfo.type}:${e.keyword}`,e.load,{fireImmediately:!0,delay:0}))}})),N5=g.types.model({metrics:g.types.optional(q5,{}),metricDetail:g.types.optional(B5,{}),keyword:g.types.optional(g.types.string,""),metricID:g.types.optional(g.types.string,"")}).views(e=>({get rootModel(){return g.getRoot(e)},get contentModel(){return this.rootModel.content},get additionalQueryInfo(){return this.contentModel.getAdditionalQueryInfo("")},get dataSource(){return g.getParent(e)},get key(){return this.dataSource.key},get type(){return this.dataSource.type},get metric(){return e.metricID?e.metrics.data.find(t=>t.id===e.metricID)??null:null}})).actions(e=>({selectMetric(t){e.metricID=t}})),$5=g.types.compose("DataSourceModel",wo,g.types.model({dbInfo:g.types.optional(P5,{}),mericoMetricInfo:g.types.optional(N5,{})})),G5=g.types.model("DataSourcesModel",{list:g.types.optional(g.types.array($5),[])}).views(e=>({find({type:t,key:r}){return e.list.find(s=>s.key===r&&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 F5(e){return e.length===1&&e[0]==="_QUERY_VARS_"}function Q5(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function R5(e){return e.length===1&&e[0]==="_FILTERS_"}function W5(e){return e.length===2&&e[0]==="_FILTERS_"}function U5(e){return e.length===1&&e[0]==="_SQL_SNIPPETS_"}function Y5(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function K5(e){return e.length===2&&e[0]==="_QUERIES_"}function X5(e){return e.length===1&&e[0]==="_QUERIES_"}function H5(e){return e.length===2&&e[0]==="_VIEWS_"}function No(e){return e.length===6&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}function zn(e){return{label:e,value:e,_type:"ACTION",_action_type:e,Icon:null,children:null}}function Z5(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,"_TABS_","Data"]:(console.error("[getPathFromOption] parentID is required"),null)}}const J5=g.types.model("EditorModel",{path:g.types.optional(g.types.frozen(),[]),settings_open:g.types.optional(g.types.boolean,!1)}).views(e=>({get isPanelPath(){return No(e.path)},get panelTab(){return this.isPanelPath?v.get(e.path,5,"Data"):null},get navOptions(){const{content:t}=g.getRoot(e),{filters:r,views:s,sqlSnippets:i,queries:o}=t;return[{label:"query_variable.labels",value:"_QUERY_VARS_",_type:"query_variables",Icon:C.IconVariable},{label:"mock_context.label",value:"_MOCK_CONTEXT_",Icon:C.IconCodeDots,_type:"mock_context"},{label:"filter.labels",value:"_FILTERS_",Icon:C.IconFilter,children:[zn("_FILTERS_SETTINGS_"),...r.options,zn("_Add_A_Filter_")],_type:"GROUP"},{label:"sql_snippet.labels",value:"_SQL_SNIPPETS_",Icon:C.IconCopy,children:[zn("_SQL_SNIPPETS_SETTINGS_"),...i.options,zn("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"query.labels",value:"_QUERIES_",Icon:C.IconDatabase,children:[zn("_QUERIES_SETTINGS_"),...o.options,zn("_Add_A_QUERY_")],_type:"GROUP"},{label:"view.labels",value:"_VIEWS_",Icon:C.IconBoxMultiple,children:[...s.editorOptions,zn("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(t,r){return t.length===0?!1:No(t)?t[3]===r.value:t[t.length-1]===r.value},isOptionOpened(t){const{path:r}=e;return r.length===0||!t.children||t.children.length===0?!1:r.includes(t.value)}})).actions(e=>({setPath(t){e.path=t},setSettingsOpen(t){e.settings_open=t},openAndSetPath(t){this.setPath(t),e.settings_open||(e.settings_open=!0)}})).actions(e=>({setPanelTab(t){if(!e.isPanelPath||e.panelTab===t||!t)return;const r=v.clone(e.path);r[5]=t,e.setPath(r)},open(t){e.setPath(t),e.setSettingsOpen(!0)},close(){e.setSettingsOpen(!1)},navigate(t){const r=Z5(t);r&&e.setPath(r)}})).views(e=>({get spotlightActionGroups(){const{content:t}=g.getRoot(e),{filters:r,views:s,sqlSnippets:i,queries:o}=t,l={group:"spotlight.main_group",actions:[{id:"query_variable.labels",title:"query_variable.labels",onClick:()=>e.openAndSetPath(["_QUERY_VARS_"]),iconKey:"query_variables"},{id:"mock_context.label",title:"mock_context.label",onClick:()=>e.openAndSetPath(["_MOCK_CONTEXT_"]),iconKey:"mock_context"},{id:"filter.labels",title:"filter.labels",onClick:()=>e.openAndSetPath(["_FILTERS_"]),iconKey:"filter"},{id:"sql_snippet.labels",title:"sql_snippet.labels",onClick:()=>e.openAndSetPath(["_SQL_SNIPPETS_"]),iconKey:"sql_snippet"},{id:"query.labels",title:"query.labels",onClick:()=>e.openAndSetPath(["_QUERIES_"]),iconKey:"query"}]},c={group:"filter.labels",actions:[]};r.options.forEach(h=>{c.actions.push({id:`_FILTERS_.${h.value}`,title:h.label,onClick:()=>e.openAndSetPath(["_FILTERS_",h.value]),iconKey:"filter"})});const u={group:"sql_snippet.labels",actions:[]};i.options.forEach(h=>{u.actions.push({id:`_SQL_SNIPPETS_.${h.value}`,title:h.label,onClick:()=>e.openAndSetPath(["_SQL_SNIPPETS_",h.value]),iconKey:"sql_snippet"})});const d={group:"query.labels",actions:[]};o.options.forEach(h=>{d.actions.push({id:`_QUERIES_.${h.value}`,title:h.label,onClick:()=>e.openAndSetPath(["_QUERIES_",h.value]),iconKey:"query"})});const p=[l,c,u,d];return s.editorOptions.forEach(h=>{const x={group:h.label,actions:[]};x.actions.push({id:`_VIEWS_.${h.value}`,title:h.label,onClick:()=>e.openAndSetPath(["_VIEWS_",h.value]),iconKey:"view",group:h.label}),h.children.forEach(b=>{b._type!=="ACTION"&&x.actions.push({id:`_VIEWS_._PANELS_.${b.value}`,title:b.label,viz:b.viz,onClick:()=>e.openAndSetPath(["_VIEWS_",h.value,"_PANELS_",b.value,"_TABS_","Panel"]),iconKey:"panel",group:h.label})}),p.push(x)}),p}})),ez=g.types.compose("LayoutsModel",Ao,g.types.model({currentLayoutWrapperWidth:g.types.optional(g.types.number,0)})).views(e=>({get divisionPreviewScale(){const t=e.currentLayoutPreviewWidth,r=e.currentLayoutWrapperWidth;return!t||!r||t<=r?1:r/t}})).actions(e=>({addALayoutItem(t){e.list.forEach(r=>{r.addNewLayout(t)})},duplicateLayoutItemsByPanelID(t,r){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:r,y:1/0})})},removeByPanelID(t){e.list.forEach(r=>{r.removeByPanelID(t)})},removeByPanelIDs(t){e.list.forEach(r=>{r.removeByPanelIDs(t)})},setCurrentLayoutWrapperWidth(t){e.currentLayoutWrapperWidth=t},addALayoutSet(t,r,s){const i=e.basisLayoutSet,o={id:t,name:r,breakpoint:s,list:i.json.list.map(l=>({...l,id:Ut.v4()}))};e.list.push(o)},updateLayoutSetsInfo(t){const r=v.keyBy(e.list,"id");t.forEach(o=>{const l=r[o.id];if(l){l.setName(o.name),l.setBreakpoint(o.breakpoint),delete r[o.id];return}this.addALayoutSet(o.id,o.name,o.breakpoint)});const s=new Set(Object.keys(r)),i=s.size>0;s.forEach(o=>{const l=e.list.findIndex(c=>c.id===o);e.list.splice(l,1)}),i&&e.setCurrentBreakpoint("basis")},updateCurrentLayoutItem(t){e.currentLayoutSet.updateLayoutItem(t)},updateCurrentLayoutItems(t){t.forEach(r=>{e.currentLayoutSet.updateLayoutItem(r)})},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 r=e.list.findIndex(s=>s.id===t);r!==-1&&e.list.splice(r,1)},removeByIDs(t){t.forEach(r=>{this.removeByID(r)})}})),eg=Do.views(e=>({get realDataFieldOptions(){return e.queryIDs.length===0?[]:e.queries.map(t=>{const r=t.data;return r.length===0?[]:Object.keys(r[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,r){const s=[...this.realQueryOptions];return t&&!s.find(i=>i.value===t)&&s.unshift({label:t,value:t,disabled:!0}),r&&s.unshift({label:"unset",value:"",disabled:!1}),s},get realVariableOptions(){const t=e.variableValueMap;return Object.entries(e.variableAggValueMap).map(([r,s])=>({label:r,value:r,formattedValue:t[r],aggValue:s,disabled:!1}))},variableOptions(t,r){const s=[...this.realVariableOptions];return t&&!s.find(i=>i.value===t)&&s.unshift({label:t,value:t,formattedValue:"",aggValue:"",disabled:!0}),r&&s.unshift({label:"unset",value:"",formattedValue:"",aggValue:"",disabled:!1}),s},dataFieldOptions(t,r,s){let i=[...this.realDataFieldOptions];if(s&&(i=i.filter(o=>o.group_id===s)),t&&!i.find(o=>o.value===t)){const o=O(t),l=e.queryByID(o.queryID);i.unshift({label:o.columnKey,value:t,group:l?l.name:o.queryID,group_id:l?l.id:"",disabled:!0})}return r&&i.unshift({label:"unset",value:"",group:"",group_id:"",disabled:!1}),i},dataFieldOptionGroups(t,r,s){const i=this.dataFieldOptions(t,r,s);return Object.entries(v.groupBy(i,"group")).map(([l,c])=>({group:l,items:c.map(u=>({label:u.label,value:u.value,group_id:u.group_id,disabled:u.disabled}))}))},explainDataKey(t){const{queryID:r,columnKey:s}=O(t),i=e.queries.find(o=>o.id===r);return i?{queryID:r,queryName:i.name,columnKey:s}:{queryID:r,queryName:null,columnKey:s}}})).actions(e=>({removeSelf(){g.getParent(e,2).removeByID(e.id)}})).actions(e=>({moveToView(t,r){g.getRoot(e).content.views.findByID(t).removePanelID(e.id),g.getRoot(e).content.views.findByID(r).appendPanelID(e.id),g.getRoot(e).editor.setPath(["_VIEWS_",r,"_PANELS_",e.id])}})),tg=g.types.compose("PanelsModel",zo,g.types.model({list:g.types.optional(g.types.array(eg),[])})).views(e=>({get contentModel(){return g.getRoot(e).content},editorOptions(t,r){const s=e.panelsByIDs(r);s.length!==r.length&&console.warn(`Unfulfilled panels for View[${t}]`);const i=s.map(l=>({label:l.name,value:l.id,_type:"panel",parentID:t,viz:t3[l.viz.type]})),o="_Add_A_PANEL_";return i.push({label:o,value:o,_type:"ACTION",_action_type:o,parentID:t,Icon:null,children:null}),i}})).actions(e=>({replace(t){e.list=g.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 r=e.list.findIndex(s=>s.id===t);r!==-1&&e.list.splice(r,1)},removeByIDs(t){t.forEach(r=>{this.removeByID(r)})},duplicateByID(t){const r=e.list.find(i=>i.id===t);if(!r){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({...r.json,id:s,title:{...r.json.title}}),e.contentModel.layouts.duplicateLayoutItemsByPanelID(r.id,s),s},replaceByIndex(t,r){e.list.splice(t,1,r)}})),tz=To.actions(e=>({getSchema(){const t=e.json,r=[],s=[];e.panels.forEach(l=>{const c=l.getSchema();r.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:r,definition:{queries:v.uniqBy(s,l=>l.id)},layouts:i,version:nn}},downloadSchema(){if(e.type===F.Tabs){console.error(new Error("Please choose a tab first"));return}const t=JSON.stringify(this.getSchema(),null,2),r=e.name;Jn(r,t)}})),ng=g.types.compose("ViewsModel",ko,g.types.model({current:g.types.optional(g.types.array(tz),[]),idOfVIE:g.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=g.getRoot(e).content.panels;return e.current.map(r=>({label:r.name,value:r.id,_type:"view",children:t.editorOptions(r.id,r.panelIDs)}))},get contentModel(){return g.getRoot(e).content}})).actions(e=>({setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},resetIDOfVIE(){this.setIDOfVIE(e.current[0].id)},replace(t){e.current.replace(t)},addANewView(t,r,s,i){e.current.push({id:t,name:r,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 r=e.current.findIndex(l=>l.id===t);if(r===-1)return;const s=e.current[r],i=e.contentModel.panels,o=e.contentModel.layouts;i.removeByIDs(s.panelIDs),o.removeByPanelIDs(s.panelIDs),e.current.splice(r,1),this.resetIDOfVIE()},replaceByIndex(t,r){e.current.splice(t,1,r)},addARandomNewView(){const t=new Date().getTime().toString();this.addANewView(t,F.Division,F.Division,{_name:F.Division}),this.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(this.removeByID(e.idOfVIE),this.resetIDOfVIE())}}));function $o(e){const t=e.length>0?[e[0].id]:[],r=e.length>0?e[0].id:"";return{current:e.map(i=>{const{_name:o=i.type}=i.config;return{...i,config:{...i.config,_name:o},panelIDs:i.panelIDs}}),visibleViewIDs:t,idOfVIE:r}}const nz=g.types.model({id:g.types.string,name:g.types.string,dashboard_id:g.types.string,create_time:g.types.string,update_time:g.types.string,version:g.types.string,filters:Yh,queries:Xh,sqlSnippets:Hh,views:ng,panels:tg,layouts:ez,mock_context:so,origin:g.types.maybe(g.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(g.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get queriesChanged(){const t="queries.current",r=g.getSnapshot(v.get(e,t)).map(i=>v.pick(i,["id","name","key","type","run_by","pre_process","post_process","config"])),s=v.get(e.origin,t);return!v.isEqual(r,s)},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!v.isEqual(g.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(g.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get layoutsChanged(){const t="layouts.list";return!v.isEqual(g.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=g.getParent(e).context.current;return{...e.mock_context.current,...t}},get payloadForSQL(){const t=g.getParent(e).globalSQLSnippets,r={context:this.context,filters:e.filters.valuesForPayload};return{...r,sql_snippets:Ir(e.sqlSnippets.current,"key","value",r),global_sql_snippets:Ir(t.list,"id","content",r)}},get payloadForViz(){const t=g.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload}},get dashboardState(){return ma(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:r,data:s})=>({id:r,data:s})).reduce((r,s)=>(r[s.id]=s.data,r),{})},getDataStuffByID(t){const r=e.queries.findByID(t);return r?{data:r.data,len:r.data.length,state:r.state,error:r.error}:{data:[],len:0,state:"idle",error:void 0}}})).views(e=>({get queriesUsage(){const t=e.panels.idMap,r=[];e.views.current.forEach(i=>{i.panelIDs.forEach(o=>{const l=t.get(o);if(!l)return;const c="panel",u=l.name,d=[{id:i.id,label:i.name}];l.queryIDs.forEach(p=>{r.push({id:o,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=>{r.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(o=>{var l;return{id:o,label:((l=s.get(o))==null?void 0:l.name)??o}})})}),e.queries.current.forEach(i=>{if(!i.isTransform)return;i.config.dep_query_ids.forEach(l=>{r.push({type:"transform-query",type_label:"query.transform.full_label",id:i.id,queryID:l,label:i.name,views:[]})})}),v.groupBy(r,"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(r=>{if(!r.typedAsSQL)return;const s=r.config;v.uniq(s.sql.match(gs.sqlSnippet)).forEach(o=>{t.push({queryID:r.id,sqlSnippetKey:o,queryName:r.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)),r=e.queries.current.filter(s=>!t.has(s.id)).map(s=>s.id);e.queries.removeQueries(r)},removeUnusedSQLSnippets(){const t=new Set(Object.keys(e.sqlSnippetsUsage)),r=e.sqlSnippets.current.filter(s=>!t.has(s.key)).map(s=>s.key);e.sqlSnippets.removeByKeys(r)},duplicatePanelByID(t,r){var i;const s=e.panels.duplicateByID(t);s&&((i=e.views.findByID(r))==null||i.appendPanelID(s))},removePanelByID(t,r){var s;e.panels.removeByID(t),e.layouts.removeByPanelID(t),(s=e.views.findByID(r))==null||s.removePanelID(t)},addANewPanel(t){var s;const r=Ut.v4();e.panels.append(xh(r)),(s=e.views.findByID(t))==null||s.appendPanelID(r),e.layouts.addALayoutItem(r)},applyJSONSchema(t){var h;const{views:r,panels:s,filters:i,definition:o={},layouts:l}=t,{queries:c,sqlSnippets:u,mock_context:d}=o,p=new Map;if(Array.isArray(s)){const x=s.map(b=>{const m=Ut.v4();return p.set(b.id,m),{...b,id:m}});if(e.panels.appendMultiple(x),!Array.isArray(r)||r.length===0){const b=x.map(m=>m.id);(h=e.views.VIE)==null||h.appendPanelIDs(b)}}if(Array.isArray(r)){const x=r.map(b=>{const m=b.panelIDs.map(j=>p.get(j)??j);return{...b,id:Ut.v4(),panelIDs:m}});e.views.appendMultiple(x)}if(Array.isArray(l)){const x=(j,D)=>e.layouts.breakpointNameRecord[j]===D;let b=[];const m=l.filter(j=>x(j.name,j.breakpoint));m.forEach(j=>{j.id==="basis"&&(b=j.list),j.list.forEach(D=>{const T=p.get(D.panelID);D.id=Ut.v4(),D.panelID=T})}),e.layouts.list.forEach(j=>{const D=m.find(T=>T.name===j.name&&T.breakpoint===j.breakpoint);if(!D){b.forEach(T=>{j.addLayout(T)});return}D.list.forEach(T=>{j.addLayout(T)})})}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(){g.applySnapshot(e.filters.current,e.origin.filters.current),g.applySnapshot(e.queries.current,e.origin.queries.current),g.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),g.applySnapshot(e.views.current,e.origin.views.current),g.applySnapshot(e.panels.list,e.origin.panels.list),g.applySnapshot(e.layouts.list,e.origin.layouts.list),e.mock_context.current=e.origin.mock_context.current},resetFilters(){g.applySnapshot(e.filters.current,e.origin.filters.current)},updateCurrent(t){const{id:r,name:s,content:i}=t;if(!i)throw new Error("unexpected null content when updating a content model");const{version:o,filters:l,views:c,panels:u,definition:{queries:d,sqlSnippets:p,mock_context:h={}}}=i;e.id=r,e.name=s,e.version=o,g.applySnapshot(e.filters.current,l),g.applySnapshot(e.views.current,$o(c).current),g.applySnapshot(e.panels.list,u),g.applySnapshot(e.queries.current,d),g.applySnapshot(e.sqlSnippets.current,p),e.mock_context.current=h}})),Go=g.types.snapshotProcessor(nz,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=g.castToSnapshot(e.queries.current.map(r=>v.pick(r,["id","key","type","sql"])));return v.defaults({},{queries:{current:t}},e)}});function rz(e,t){t.filters&&g.applySnapshot(e.filters.current,t.filters)}function rg({id:e,name:t,dashboard_id:r,create_time:s,update_time:i,content:o},l,c){if(!o)throw new Error("unexpected null content when creating a content model");const{version:u,filters:d,views:p,panels:h,layouts:x,definition:{queries:b,sqlSnippets:m,mock_context:j={}}}=o;return Go.create({id:e,name:t,dashboard_id:r,create_time:s,update_time:i,version:u,filters:Mo(d,l,j,c),queries:{current:b},sqlSnippets:{current:m},mock_context:io(j),views:$o(p),panels:{list:h},layouts:{list:x,currentBreakpoint:x[0].id}})}const sg=g.types.model({id:g.types.identifier,name:g.types.string,group:g.types.string,content:Go,content_id:g.types.string,datasources:G5,globalSQLSnippets:Co,context:As,editor:J5}).views(e=>({get json(){return{id:e.id,name:e.name,group:e.group,content_id:e.content_id}},get queryVariables(){return{context:{...e.content.mock_context.current,...e.context.current},filters:e.content.filters.previewValues}},get queryVariablesString(){return JSON.stringify(this.queryVariables,null,2)}})).actions(e=>({updateCurrentContent(t){e.content.updateCurrent(t)},updateCurrent(t,r){const{id:s,name:i,group:o,content_id:l}=t;e.id=s,e.name=i,e.group=o,e.content_id=l,this.updateCurrentContent(r)}}));function ig({id:e,name:t,group:r,content_id:s},i,o,l,c,u){return sg.create({id:e,name:t,group:r,content_id:s,content:rg(i,c,u),datasources:{list:o},globalSQLSnippets:{list:l},context:So(c),editor:{}})}const sz={translation:{filter:{label:"Filter",labels:"Filters",add:"Add a Filter",manage:"Manage Filters",delete:"Delete this filter",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 default value",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",tree_single_select:"Tree Single 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",preset_options:{apply:"Apply preset options",date_unit:"Date units"}},multi_select:{width_description:"At least 160px"},tree_select:{strictly:"Parent and children nodes are not associated"},tree_single_select:{select_first_option_by_default:"Select the first option by default"},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:{label:"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",invalid:"Invalid",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:{actions:"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:"Clear",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 <0>{{name}}</0>"},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"},guide:{text:`-- You may reference dashboard state & panel variables in rich-text content or custom functions.
@@ -489,14 +489,14 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
489
489
  -- 在富文本中,要使用双重花括号来包裹代码。
490
490
  项目ID:{{ context.project_id }}
491
491
  搜索关键字:{{ filters.keyword }}
492
- 我的卡片变量: {{ your_var }}`,tabs:{guide:"使用指南",vars:"看板信息与卡片的变量"}}}},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:"以下条件为真时,才运行本查询",description:"为假的情况: 空数组 / NaN / false / 空字符串 / undefined / null",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:"编辑动态颜色",clear:"清除动态颜色"},color_mapping:{label:"颜色映射",edit:"编辑颜色映射",clear:"清除颜色映射",choose_value_var:"选择用于映射颜色的变量",min:{val:"固定最小值",var:"动态最小值(优先)"},max:{val:"固定最大值",var:"动态最大值(优先)"}}},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:"显示标记点",area_style:{label:"区域填充样式",enabled:"启用区域填充",color:"填充颜色",use_series_color:"沿用系列本色",origin:{label:"图形区域的起始位置",auto:{label:"自动",description:"填充坐标轴线到数据间的区域(默认)"},start:{label:"自下而上",description:"填充坐标轴底部到数据间的区域"},end:{label:"自上而下",description:"填充坐标轴顶部到数据间的区域"}},shadow_blur:"图形阴影的模糊大小",shadow_color:"图形阴影的颜色",shadow_offset_x:"阴影水平方向上的偏移距离",shadow_offset_y:"阴影垂直方向上的偏移距离",opacity:"图形透明度"}},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:"颜色",background_color:"背景色",text_color:"文字颜色",click_to_add_a_color:"点击增加一个颜色",color_gradient:"颜色渐变",not_set:"未设置"},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:"请填写一个数字"}},spotlight:{trigger_text:"搜索",main_group:"主要项",placeholder:"打开…",not_found:"无匹配项"}}},Bs=Rf.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:sz,zh:iz}}).use(Wf).use(_.initReactI18next);Bs.init(),to.forEach(e=>{var t;(t=e.translation)==null||t.forEach(r=>{Bs.addResourceBundle(r.lang,"translation",{viz:r.resources},!0,!0)})});function ag({lang:e,children:t}){return f.useEffect(()=>{Bs.changeLanguage(e)},[e]),n.jsx(_.I18nextProvider,{i18n:Bs,children:t})}function qs(e){console.groupCollapsed("Running operation ",e.type),console.log(e),console.groupEnd()}function og(e,t){f.useEffect(()=>{const r=s=>{qs(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",r),()=>{window.removeEventListener("open-view",r)}},[e,t]),f.useEffect(()=>{const r=s=>{qs(s);const{dictionary:i,payload:o}=s.detail;if(!o||Object.keys(o).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(o,u);l[c]=d}),e.filters.applyValuesPatch(l)};return window.addEventListener("set-filter-values",r),()=>{window.removeEventListener("set-filter-values",r)}},[e]),f.useEffect(()=>{function r(i){return Array.isArray(i)?[]:typeof i=="object"?{}:typeof i=="boolean"?!1:typeof i=="string"?"":typeof i=="number"?0:i}const s=i=>{qs(i);const o={},{filter_keys:l}=i.detail;l.forEach(c=>{const u=v.get(e.filters.values,c),d=r(u);o[c]=d}),e.filters.applyValuesPatch(o)};return window.addEventListener("clear-filter-values",s),()=>{window.removeEventListener("clear-filter-values",s)}},[e]),f.useEffect(()=>{const r=s=>{qs(s);const{urlTemplate:i,openInNewTab:o,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,b=>{if(l&&typeof b=="string")return encodeURIComponent(b)})}const p=v.template(i||"")(u({...c,filters:e.payloadForSQL.filters,context:e.payloadForSQL.context}));window.open(p,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",r),()=>{window.removeEventListener("open-link",r)}},[e])}function lg(e){return f.useCallback(t=>t.provideValue(Pe.pluginManager,e.pluginManager).provideValue(Pe.vizManager,e.vizManager).provideValue(Pe.colorManager,e.colorManager),[])}const yE="",az=k.observer(({saveDashboardChanges:e})=>{const{t}=_.useTranslation(),r=dt.useModals(),s=re(),i=()=>{r.openConfirmModal({title:n.jsxs(a.Group,{justify:"flex-start",children:[n.jsx(C.IconAlertTriangle,{size:18,color:"red"}),n.jsx(a.Text,{size:"sm",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})},o=s.changed;return n.jsxs(a.Group,{gap:0,children:[n.jsx(a.Button,{color:"green",variant:"filled",size:"xs",leftSection:n.jsx(C.IconDeviceFloppy,{size:18}),onClick:e,disabled:!o,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:t("common.actions.save_changes")}),n.jsxs(a.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!o,children:[n.jsx(a.Menu.Target,{children:n.jsx(a.ActionIcon,{variant:"default",disabled:!o,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:n.jsx(C.IconCaretDown,{size:18})})}),n.jsx(a.Menu.Dropdown,{children:n.jsx(a.Menu.Item,{leftSection:n.jsx(C.IconRecycle,{size:14,color:"red"}),disabled:!o,onClick:i,children:t("common.actions.revert_changes")})})]})]})}),oz=k.observer(({saveDashboardChanges:e,onExit:t,headerSlot:r=null})=>{_.useTranslation();const s=se(),i=s.content.changed,o=()=>{t({hasChanges:i,dashboardId:s.id})};return n.jsx(a.AppShell.Header,{h:60,py:0,px:"md",sx:{zIndex:299},children:n.jsxs(a.Group,{justify:"space-between",sx:{height:60,minWidth:"1000px",position:"relative"},children:[n.jsxs(a.Group,{children:[n.jsx(a.Button,{size:"xs",color:i?"red":"green",leftSection:n.jsx(C.IconArrowLeft,{size:20}),onClick:o,children:n.jsx(a.Group,{gap:4,children:n.jsx(_.Trans,{i18nKey:"common.actions.end_editing",values:{name:s.name},children:n.jsx(a.Text,{td:"underline",size:"xs",children:s.name})})})}),n.jsx(az,{saveDashboardChanges:e})]}),n.jsx(a.Group,{justify:"flex-end",sx:{flexGrow:1},children:r})]})})}),cg={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},lz=k.observer(()=>{var i;const{t:e}=_.useTranslation(),t=re(),r=((i=t.views.VIE)==null?void 0:i.type)===F.Tabs,s=()=>t.addANewPanel(t.views.idOfVIE);return r?n.jsx(a.Tooltip,{label:e("common.choose_a_tab_first"),children:n.jsx(a.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftSection:n.jsx(C.IconPlaylistAdd,{size:20}),sx:{...cg,transform:"none !important"},children:e("panel.add")})}):n.jsx(a.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:s,leftSection:n.jsx(C.IconPlaylistAdd,{size:20}),sx:{...cg,background:"rgb(231, 245, 255)"},children:e("panel.add")})}),cz=k.observer(({done:e})=>{var P,ae;const{t}=_.useTranslation(),s=re().layouts,i=f.useMemo(()=>({list:s.breakpointsInfo}),[s.breakpointsInfo]),{control:o,handleSubmit:l,watch:c,getValues:u,reset:d,formState:p}=y.useForm({defaultValues:i}),{fields:h,append:x,remove:b}=y.useFieldArray({control:o,name:"list",rules:{validate:pe=>{if(v.uniqBy(pe,"breakpoint").length!==pe.length)return"Screen sizes should be unique by min width"}}}),m=c("list"),j=h.map((pe,be)=>({...pe,...m[be]})),D=()=>{x({id:Ut.v4(),name:"",breakpoint:""})},T=({list:pe})=>{const be=pe.filter(Ce=>Number.isFinite(Ce.breakpoint));s.updateLayoutSetsInfo(be),e()},z=u(),I=f.useMemo(()=>{const pe={list:z.list.filter(be=>!!be.name&&Number.isFinite(be.breakpoint))};return!v.isEqual(pe,i)},[z,i]),M=(ae=(P=p.errors.list)==null?void 0:P.root)==null?void 0:ae.message;return n.jsx(n.Fragment,{children:n.jsxs("form",{onSubmit:l(T),children:[n.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,withTableBorder:!0,sx:{tableLayout:"fixed"},children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"340px"},children:t("common.name")}),n.jsx(a.Table.Th,{style:{width:"160px"},children:t("breakpoint.breakpoint")}),n.jsx(a.Table.Th,{})]})}),n.jsxs(a.Table.Tbody,{children:[j.map((pe,be)=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:pe.id==="basis"?pe.name:n.jsx(y.Controller,{name:`list.${be}.name`,control:o,render:({field:Ce})=>n.jsx(a.TextInput,{size:"xs",label:"",required:!0,sx:{flex:1},...Ce})})}),n.jsx(a.Table.Td,{children:pe.id==="basis"?n.jsxs(a.Text,{size:"sm",ff:"monospace",children:[pe.breakpoint,"px"]}):n.jsx(y.Controller,{name:`list.${be}.breakpoint`,control:o,render:({field:Ce})=>n.jsx(a.NumberInput,{size:"xs",label:"",required:!0,max:1e4,hideControls:!0,rightSection:n.jsx(a.Text,{size:"sm",c:"dimmed",children:"px"}),rightSectionProps:{style:{width:"30px"}},sx:{flex:1},ff:"monospace",styles:{input:{paddingRight:"30px"}},...Ce})})}),n.jsx(a.Table.Td,{children:pe.id!=="basis"&&n.jsx(a.ActionIcon,{mx:"auto",size:"xs",variant:"subtle",color:"red",onClick:()=>b(be),children:n.jsx(C.IconTrash,{})})})]},pe.id)),n.jsx(a.Table.Tr,{style:{backgroundColor:"transparent"},children:n.jsx(a.Table.Td,{colSpan:3,style:{padding:"0"},children:n.jsx(a.Tooltip,{label:t("breakpoint.add"),children:n.jsx(a.ActionIcon,{variant:"subtle",size:"md",color:"blue",onClick:D,sx:{width:"100%"},children:n.jsx(C.IconPlus,{size:18})})})})})]})]}),n.jsx(a.Text,{mt:6,ta:"right",size:"xs",c:"red",children:M??" "}),n.jsxs(a.Group,{mt:6,justify:"space-between",children:[n.jsx(a.Button,{color:"orange",size:"xs",onClick:()=>d(),leftSection:n.jsx(C.IconRecycle,{size:18}),disabled:!I,children:t("common.actions.revert")}),n.jsx(a.Button,{color:"green",size:"xs",type:"submit",leftSection:n.jsx(C.IconDeviceFloppy,{size:18}),disabled:!I,children:t("common.actions.save_changes")})]})]})})}),uz=k.observer(()=>{const{t:e}=_.useTranslation(),[t,{open:r,close:s}]=ze.useDisclosure(!1),i=re(),o=i.layouts.currentBreakpoint,l=i.layouts.currentLayoutRange,c=()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},u=()=>{s(),c()};return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{children:[n.jsxs(a.Menu,{withArrow:!0,withinPortal:!0,zIndex:320,trigger:"hover",children:[n.jsx(a.Menu.Target,{children:n.jsx(a.Button,{size:"xs",variant:"subtle",leftSection:n.jsx(C.IconDevices,{size:16}),sx:{borderRadius:0},children:n.jsxs(a.Group,{gap:6,children:[n.jsx(a.Text,{size:"xs",fw:"normal",children:l.name}),n.jsx(a.Text,{size:"xs",c:"#777",children:i.layouts.currentRangeText})]})})}),n.jsxs(a.Menu.Dropdown,{children:[i.layouts.breakpointRanges.map(d=>n.jsx(a.Menu.Item,{onClick:()=>i.layouts.setCurrentBreakpoint(d.id),disabled:o===d.id,children:n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Text,{size:"sm",children:d.name}),n.jsx(a.Text,{size:"xs",c:"dimmed",children:d.text})]})},d.id)),n.jsx(a.Menu.Divider,{}),n.jsx(a.Menu.Item,{color:"blue",leftSection:n.jsx(C.IconSettings,{size:14}),onClick:r,children:n.jsx(a.Text,{size:"sm",children:e("breakpoint.manage")})})]})]}),i.layouts.divisionPreviewScale<1&&n.jsx(a.Text,{size:"xs",c:"dimmed",children:Lr(i.layouts.divisionPreviewScale).format({output:"percent",mantissa:0})})]}),n.jsx(a.Modal,{opened:t,onClose:u,title:e("breakpoint.label",{count:2}),withinPortal:!0,zIndex:320,size:600,closeOnClickOutside:!1,children:n.jsx(cz,{done:u})})]})}),ug={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},dz=k.observer(()=>{var i;const{t:e}=_.useTranslation(),t=re(),r=((i=t.views.VIE)==null?void 0:i.type)===F.Tabs,s=()=>{var o;return(o=t.views.VIE)==null?void 0:o.downloadSchema()};return r?n.jsx(a.Tooltip,{label:e("common.choose_a_tab_first"),children:n.jsx(a.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftSection:n.jsx(C.IconCode,{size:16}),sx:{...ug,transform:"none !important"},children:e("view.download_schema")})}):n.jsx(a.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:s,leftSection:n.jsx(C.IconCode,{size:16}),sx:{...ug},children:e("view.download_schema")})}),Ns=({headers:e,rows:t})=>n.jsxs(a.Table,{fz:"xs",highlightOnHover:!0,sx:{tableLayout:"fixed",fontFamily:"monospace"},children:[n.jsx(a.Table.Thead,{children:e}),n.jsx(a.Table.Tbody,{children:t})]}),pz=({content:e})=>{const{t}=_.useTranslation(),r=e.views;return!Array.isArray(r)||r.length===0?null:n.jsxs(a.Box,{children:[n.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("view.labels")}),n.jsx(Ns,{headers:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(a.Table.Th,{children:t("common.name")}),n.jsx(a.Table.Th,{children:t("common.type")})]}),rows:r.map(s=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:s.id}),n.jsx(a.Table.Td,{children:s.name}),n.jsx(a.Table.Td,{children:t(`view.component.${s.type}.label`)})]},s.id))})]})},hz=({content:e})=>{const{t}=_.useTranslation(),r=e.filters;return!Array.isArray(r)||r.length===0?null:n.jsxs(a.Box,{children:[n.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("filter.labels")}),n.jsx(Ns,{headers:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(a.Table.Th,{children:t("common.key")}),n.jsx(a.Table.Th,{children:t("common.label")})]}),rows:r.map(s=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:s.id}),n.jsx(a.Table.Td,{children:s.key}),n.jsx(a.Table.Td,{children:s.label})]},s.id))})]})},gz=({content:e})=>{const{t}=_.useTranslation(),r=e.panels;return!Array.isArray(r)||r.length===0?null:n.jsxs(a.Box,{children:[n.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("panel.labels")}),n.jsx(Ns,{headers:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(a.Table.Th,{children:t("common.name")}),n.jsx(a.Table.Th,{children:t("visualization.component")})]}),rows:r.map(s=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:s.id}),n.jsx(a.Table.Td,{children:s.name}),n.jsx(a.Table.Td,{children:s.viz.type})]},s.id))})]})},fz=({content:e})=>{var s;const{t}=_.useTranslation(),r=(s=e.definition)==null?void 0:s.queries;return!Array.isArray(r)||r.length===0?null:n.jsxs(a.Box,{children:[n.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("query.labels")}),n.jsx(Ns,{headers:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(a.Table.Th,{children:t("common.name")}),n.jsx(a.Table.Th,{style:{width:"140px"},children:t("common.type")}),n.jsx(a.Table.Th,{style:{width:"260px"},children:t("data_source.label")})]}),rows:r.map(i=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:i.id}),n.jsx(a.Table.Td,{children:i.name}),n.jsx(a.Table.Td,{children:i.type}),n.jsx(a.Table.Td,{children:i.key})]},i.id))})]})},xz=({content:e})=>{var s;const{t}=_.useTranslation(),r=(s=e.definition)==null?void 0:s.sqlSnippets;return!Array.isArray(r)||r.length===0?null:n.jsxs(a.Box,{children:[n.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("sql_snippet.labels")}),n.jsx(a.List,{size:"sm",pl:10,ff:"monospace",icon:n.jsx(C.IconPointFilled,{size:10}),children:r.map(i=>n.jsx(a.List.Item,{children:i.key},i.key))})]})},mz=({content:e})=>{var s;const{t}=_.useTranslation(),r=Object.keys(((s=e.definition)==null?void 0:s.mock_context)??{});return r.length===0?null:n.jsxs(a.Box,{children:[n.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("mock_context.label")}),n.jsx(a.List,{size:"sm",pl:10,ff:"monospace",icon:n.jsx(C.IconPointFilled,{size:10}),children:r.map(i=>n.jsx(a.List.Item,{children:i},i))})]})},bz=({content:e})=>e?n.jsxs(a.Box,{children:[n.jsx(a.Divider,{mt:20,mb:10,variant:"dashed"}),n.jsx(a.Text,{ta:"left",c:"dimmed",size:"sm",children:"Preview"}),n.jsxs(a.Stack,{children:[n.jsx(pz,{content:e}),n.jsx(hz,{content:e}),n.jsx(gz,{content:e}),n.jsx(fz,{content:e}),n.jsx(xz,{content:e}),n.jsx(mz,{content:e})]})]}):null;function yz(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!==nn)throw new Error("Schema version mismatch");return t}const vz=k.observer(({onSuccess:e,stretchModal:t,shrinkModal:r})=>{var T,z;const{t:s}=_.useTranslation(),i=re(),{handleSubmit:o,formState:{errors:l},setValue:c,watch:u,setError:d,clearErrors:p}=y.useForm({defaultValues:{content:null}}),h=({content:I})=>{try{if(!I)throw new Error("please use a valid json file");i.applyJSONSchema(I),Nt.showNotification({title:"Successful",message:"",color:"green"}),e()}catch(M){console.error(M),Nt.showNotification({title:"Failed",message:M.message,color:"red"})}},[x,b]=f.useState(null);f.useEffect(()=>{if(!x)return;const I=new FileReader;I.readAsText(x,"UTF-8"),I.onload=M=>{try{const P=yz(M);c("content",P),p("content")}catch(P){console.error(P),d("content",{type:"custom",message:P.message})}},I.onabort=()=>console.log("🟨 abort"),I.onerror=()=>{I.error&&(console.error(I.error),d("content",{type:"custom",message:I.error.message}))}},[x]);const[m]=u(["content"]),j=!m,D=(T=l==null?void 0:l.content)==null?void 0:T.message;return f.useEffect(()=>{!m||D?r():t()},[m,D]),n.jsx(a.Box,{mx:"auto",sx:{position:"relative"},children:n.jsxs("form",{onSubmit:o(h),children:[n.jsx(a.FileInput,{label:s("import.json_file"),required:!0,value:x,onChange:b,error:(z=l==null?void 0:l.content)==null?void 0:z.message,sx:{maxWidth:500}}),D?n.jsx(a.Table,{fz:12,mt:10,children:n.jsxs(a.Table.Tbody,{children:[n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:s("import.this_dashboard")}),n.jsx(a.Table.Td,{children:nn})]}),n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:s("import.this_file")}),n.jsx(a.Table.Td,{style:{color:"red"},children:m==null?void 0:m.version})]})]})}):n.jsxs(n.Fragment,{children:[n.jsx(bz,{content:m}),n.jsx(a.Group,{justify:"flex-end",my:"md",children:n.jsx(a.Button,{type:"submit",color:"green",disabled:j,children:s("common.actions.confirm")})})]})]})})}),dg={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},_z=k.observer(()=>{var d;const{t:e}=_.useTranslation(),[t,{open:r,close:s}]=ze.useDisclosure(!1),[i,{setTrue:o,setFalse:l}]=Y.useBoolean(!1),u=((d=se().content.views.VIE)==null?void 0:d.type)===F.Tabs;return u?n.jsx(a.Tooltip,{label:e("common.choose_a_tab_first"),children:n.jsx(a.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftSection:n.jsx(C.IconFileImport,{size:16}),sx:{...dg,transform:"none !important"},children:e("import.label")})}):n.jsxs(n.Fragment,{children:[n.jsx(a.Button,{variant:"subtle",color:"blue",radius:0,size:"xs",disabled:u||t,onClick:r,leftSection:n.jsx(C.IconFileImport,{size:16}),sx:{...dg},children:e("import.label")}),n.jsx(a.Modal,{opened:t,onClose:s,title:e("import.title"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},withinPortal:!0,zIndex:320,size:i?"90vw":500,children:n.jsx(vz,{onSuccess:s,stretchModal:o,shrinkModal:l})})]})}),vE="",jz=({iconKey:e,...t})=>{switch(e){case"query_variables":return n.jsx(C.IconVariable,{...t});case"mock_context":return n.jsx(C.IconCodeDots,{...t});case"filter":return n.jsx(C.IconFilter,{...t});case"sql_snippet":return n.jsx(C.IconCopy,{...t});case"query":return n.jsx(C.IconDatabase,{...t});case"view":return n.jsx(C.IconBoxMultiple,{...t});case"panel":return n.jsx(C.IconAppWindow,{...t});default:return null}},wz=({action:e})=>{const{t}=_.useTranslation();return e.description?n.jsx(a.Text,{c:"dimmed",size:"xs",children:t(e.description)}):e.viz?n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Text,{c:"dimmed",size:"xs",children:t(e.viz.displayName)}),n.jsx(a.Text,{c:"dimmed",size:"xs",className:"spotlight-action-viz-group",children:t(e.viz.displayGroup)})]}):null},Cz=k.observer(({action:e,query:t})=>{const{t:r}=_.useTranslation();return n.jsx(a.Box,{className:"spotlight-custom-action-component",children:n.jsxs(a.Group,{wrap:"nowrap",children:[n.jsx(jz,{iconKey:e.iconKey,size:14}),n.jsxs("div",{style:{flex:1},children:[n.jsx(a.Highlight,{highlight:t,size:"sm",children:e.title?r(e.title):""}),n.jsx(wz,{action:e})]})]})})}),Sz=({groups:e,query:t})=>{const{t:r}=_.useTranslation();return e.length===0?n.jsx(_n.Spotlight.Empty,{children:r("spotlight.not_found")}):n.jsx(n.Fragment,{children:e.map(s=>n.jsx(_n.Spotlight.ActionsGroup,{label:s.group,children:s.actions.map(i=>n.jsx(_n.Spotlight.Action,{onClick:i.onClick,children:n.jsx(Cz,{action:i,query:t})},i.id))},s.group))})},Tz=k.observer(()=>{const{t:e,i18n:t}=_.useTranslation(),r=a.useMantineTheme(),s=se(),[i,o]=f.useState(""),l=f.useMemo(()=>s.editor.spotlightActionGroups.map(u=>({group:e(u.group),keywords:[u.group,e(u.group)],actions:u.actions.map(d=>{const p=[];return d.title&&(p.push(d.title.toLowerCase()),p.push(e(d.title).toLowerCase())),d.group&&p.push(d.group.toLowerCase()),d.viz&&(p.push(d.viz.displayGroup.toLowerCase()),p.push(d.viz.displayName.toLowerCase())),d.iconKey&&p.push(d.iconKey),{...d,keywords:p}})})),[s.editor.spotlightActionGroups,t.language]),c=f.useMemo(()=>{const u=i.toLowerCase().trim();return u?l.map(p=>{if(p.keywords.some(b=>b.includes(u)))return p;const x=p.actions.filter(b=>b.keywords.some(m=>m.includes(u)));return x.length===0?null:{...p,actions:x}}).filter(p=>p!==null):[l[0]]},[l,i]);return n.jsxs(_n.Spotlight.Root,{onQueryChange:o,shortcut:["mod + P","mod + K"],radius:"md",styles:{search:{border:"none"},action:{position:"relative",display:"block",width:"100%",padding:`${a.rem(10)} ${a.rem(12)}`,borderRadius:r.radius.sm,".spotlight-action-viz-group":{opacity:0},"&:hover, &[data-selected]":{backgroundColor:r.colors.gray[1],".spotlight-action-viz-group":{opacity:1}}}},children:[n.jsx(_n.Spotlight.Search,{placeholder:e("spotlight.placeholder"),leftSection:n.jsx(C.IconSearch,{size:"1.2rem"})}),n.jsx(_n.Spotlight.ActionsList,{children:n.jsx(Sz,{groups:c,query:i})})]})}),pg=({children:e})=>n.jsx(a.Text,{style:{fontSize:"0.6875rem",lineHeight:1,padding:"0.25rem 0.2375rem",borderRadius:"0.25rem"},children:e}),hg=function(){var t;return(((t=navigator.userAgentData)==null?void 0:t.platform)??navigator.platform).toLowerCase().includes("mac")}(),kz=()=>{const{t:e}=_.useTranslation();return n.jsx(a.Tooltip,{label:n.jsxs(n.Fragment,{children:[hg&&n.jsx(pg,{children:"⌘ + K"}),!hg&&n.jsx(pg,{children:"Ctrl + K"})]}),children:n.jsx(a.UnstyledButton,{onClick:()=>_n.spotlight.open(),style:{height:"1.875rem",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef",paddingLeft:"calc(0.875rem / 1.5)",paddingRight:"1rem"},sx:{color:"#228be6",background:"transparent","&:hover":{background:"rgb(231, 245, 255)"}},children:n.jsxs(a.Group,{gap:"0.625rem",children:[n.jsx(C.IconSearch,{size:"1rem",color:"#228be6"}),n.jsx(a.Text,{fw:500,style:{flexGrow:1,fontWeight:500,fontSize:"0.75rem",lineHeight:1},children:e("spotlight.trigger_text")})]})})})},Dz={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},zz=k.observer(()=>n.jsx(a.Box,{sx:Dz,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:n.jsxs(a.Group,{justify:"space-between",align:"center",sx:{height:"30px"},children:[n.jsxs(a.Group,{justify:"flex-start",gap:0,children:[n.jsx(lz,{}),n.jsx(_z,{}),n.jsx(kz,{})]}),n.jsx(uz,{}),n.jsx(a.Group,{justify:"flex-end",gap:0,children:n.jsx(dz,{})})]})})),Iz=k.observer(e=>n.jsxs(n.Fragment,{children:[n.jsx(oz,{...e}),n.jsx(zz,{})]})),_E="";function Mz(e,t,r){const s=[];return e.filter(i=>"__INTERACTIONS"in i.viz.conf).forEach((i,o)=>{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:x,data:b}=h,{config:m}=b;switch(x){case"builtin:op:open-link":let j=m.urlTemplate.substring(0,100);m.urlTemplate.length>=20&&(j+="..."),l.type="interaction",l.data.interactions.push({schemaRef:x,urlTemplate:m.urlTemplate,shortURLTemplate:j});return;case"builtin:op:open_view":s.push({id:`OPERATION--${p}`,source:i.id,target:m.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:x,filters:Object.keys(m.dictionary).map(D=>({key:D,label:r[D]}))});return;case"builtin:op:clear_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:x,filters:m.filter_keys.map(D=>({key:D,label:r[D]}))});return;default:return}})}),s}function Ez(e,t){const r=e.filters.keyLabelMap;return{edges:Mz(e.panels.list,t,r),edgeNodes:[]}}function gg(e,t,r){return e*t+e*r}function Pz(e,t,r){return e*t+(e-1)*r}const $s=25,Fo=40,fg=25,Qo=350,Az=150,Lz=150,xg=150,mg=300,Gs=40,bg=25,Oz=300;function Vz(e,t){const r=v.keyBy(t,i=>i.id),s=[];return e.current.forEach((i,o)=>{i.panelIDs.forEach((l,c)=>{const u=gg(c,Gs,bg)+Fo,d=r[l];if(!d){s.push({id:l,_node_type:"panel",parentNode:i.id,data:{label:`!: ${l}`},position:{x:$s,y:u},sourcePosition:Ge.Position.Right,targetPosition:Ge.Position.Left,style:{width:mg,height:Gs}});return}const p=d.name;s.push({id:d.id,_node_type:"panel",parentNode:i.id,data:{label:p},position:{x:$s,y:u},sourcePosition:Ge.Position.Right,targetPosition:Ge.Position.Left,style:{width:mg,height:Gs}})})}),s}const Bz={[F.Division]:"Div",[F.Modal]:"Modal",[F.Tabs]:"Tabs"},qz=Uh;function Nz(e){return e.current.map((r,s)=>{const i=Pz(r.panelIDs.length,Gs,bg)+Fo+fg;let o=[];return r.type===F.Tabs&&(o=r.config.tabsInOrder.map(c=>c.view_id)),{id:r.id,_node_type:"view-root",_view_type:r.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:o,data:{label:`${Bz[r.type]}:${r.name}`},position:{x:0,y:0},sourcePosition:Ge.Position.Right,targetPosition:Ge.Position.Left,className:"light",style:{backgroundColor:qz[r.type],width:Qo,height:i}}})}function $z(e){const t=v.keyBy(e,r=>r.id);e.forEach(r=>{r._node_type!=="view-root"||r._view_type!==F.Tabs||r._tab_view_ids.forEach(s=>{t[s].parentNode=r.id})})}function Gz(e){const t=Nz(e.views);$z(t);const r=Vz(e.views,e.panels.list);return[...t,...r]}function Fz({nodeMap:e,nodes:t,edges:r}){t.forEach(s=>{s._node_type!=="view-root"||s._view_type!==F.Tabs||(s.sourcePosition=Ge.Position.Bottom,s.style.width=Qo+$s*2,s.style.height=fg+s._tab_view_ids.reduce((i,o)=>{const l=e[o];l.position.y=i,l.position.x=$s;const c=l.style.height;return i+c+20},Fo))})}function Qz({nodeMap:e,nodes:t,edges:r}){r.filter(s=>s.label==="Open View").forEach(s=>{const i=e[s.source],o=e[s.target];if(!i||!o||!i.parentNode)return;const l=e[i.parentNode];l._node_type!=="view-root"||o._node_type!=="view-root"||(o._view_level+=1+l._view_level,l._sub_view_ids.push(o.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 Rz({nodeMap:e,nodes:t,edges:r}){const s={};r.forEach(i=>{if(i.label!=="Open View")return;const o=e[i.source],l=e[i.target];if(o&&l&&o.parentNode){const c=e[o.parentNode],u=c.position.x,d=Number(v.get(l,"style.height",0)),p=Number(c.style.width);l.position.x=u+p+Oz,c._view_level===0&&l._sub_view_ids.length===0&&(o.sourcePosition=Ge.Position.Left,l.targetPosition=Ge.Position.Right,l.position.x*=-1);const x=l.position.x,b=v.get(s,x,0);l.position.y=b,s[x]=b+d+xg}})}function Wz({nodeMap:e,nodes:t,edges:r}){const s=new Set,i=new Set;r.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=gg(c,Qo,Lz),l.position.y=0-Az-xg})}function Uz({nodeMap:e,nodes:t,edges:r}){const s={nodeMap:e,nodes:t,edges:r};return Wz(s),Qz(s),Fz(s),Rz(s),{nodes:t,edges:r}}function Yz(e){const t=Gz(e),r=v.keyBy(t,u=>u.id),{edges:s,edgeNodes:i}=Ez(e,r),o=[...t,...i],l=v.keyBy(o,u=>u.id),c={edges:v.uniqBy(s,u=>u.id),nodes:o,nodeMap:l};return Uz(c)}const jE="",Ro={"builtin:op:open-link":n.jsx(a.ThemeIcon,{color:"blue",size:20,radius:"xl",children:n.jsx(C.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":n.jsx(a.ThemeIcon,{color:"orange",size:20,radius:"xl",children:n.jsx(C.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":n.jsx(a.ThemeIcon,{color:"orange",size:20,radius:"xl",children:n.jsx(C.IconCircleOff,{size:14})})};function Kz(e){const t=[];return e.forEach(r=>{switch(r.schemaRef){case"builtin:op:open-link":t.push({key:r.urlTemplate,icon:Ro[r.schemaRef],text:n.jsxs(a.Group,{gap:4,children:[n.jsx(a.Text,{size:"sm",children:"Open: "}),n.jsx(a.Text,{size:"sm",c:"dimmed",children:r.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":r.filters.forEach(({key:s,label:i})=>{t.push({key:r.schemaRef+s,icon:Ro[r.schemaRef],text:n.jsx(a.Group,{gap:4,children:n.jsxs(a.Text,{size:"sm",children:["Set Filter: ",i]})})})});return;case"builtin:op:clear_filter_values":r.filters.forEach(({key:s,label:i})=>{t.push({key:r.schemaRef+s,icon:Ro[r.schemaRef],text:n.jsx(a.Group,{gap:4,children:n.jsxs(a.Text,{size:"sm",children:["Clear Filter: ",i]})})})});return}}),t}const Xz=f.memo(({data:e,isConnectable:t,sourcePosition:r=Ge.Position.Right,targetPosition:s=Ge.Position.Left,...i})=>{const o=f.useMemo(()=>Kz(e.interactions),[e.interactions]);return n.jsxs(n.Fragment,{children:[n.jsx(Ge.Handle,{type:"target",position:s,isConnectable:t}),n.jsx(a.Box,{sx:{position:"absolute",top:0,right:0},children:n.jsx(C.IconChevronsUpRight,{size:12})}),n.jsxs(a.HoverCard,{shadow:"xl",withinPortal:!0,children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.Text,{size:"sm",children:e.label})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsx(a.List,{spacing:"xs",size:"sm",center:!0,children:o.map(l=>n.jsx(a.List.Item,{icon:l.icon,children:l.text},l.key))})})]}),n.jsx(Ge.Handle,{type:"source",position:r,isConnectable:t})]})}),wE="",Hz={interaction:Xz},Zz=k.observer(()=>{const e=Te(),{edges:t,nodes:r}=Yz(e);return n.jsxs(Ge,{nodes:r,edges:t,onNodesChange:v.noop,onEdgesChange:v.noop,onConnect:v.noop,className:"interactions-viewer",fitView:!0,nodeTypes:Hz,children:[n.jsx(Ge.MiniMap,{}),n.jsx(Ge.Controls,{}),n.jsx(Ge.Background,{})]})}),Jz=k.observer(({opened:e,close:t})=>{const{t:r}=_.useTranslation();return n.jsx(a.Modal,{size:"96vw",opened:e,onClose:t,title:r("interactions.interactions_viewer"),trapFocus:!0,onDragStart:s=>{s.stopPropagation()},styles:{body:{height:"calc(90vh - 54px)"},content:{transform:"none !important"}},zIndex:300,children:n.jsx(Zz,{})})}),eI={"> 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 tI({onClick:e,name:t,active:r,openSettings:s}){return n.jsxs(a.Box,{sx:{position:"relative"},children:[n.jsx(a.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:r?i.colors.gray[2]:"transparent"}),children:n.jsx(a.Group,{sx:{width:"calc(100% - 28px)"},onClick:e,children:n.jsx(a.Text,{size:"sm",children:t})})}),r&&n.jsx(a.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:n.jsx(a.ActionIcon,{onClick:s,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:n.jsx(C.IconAdjustments,{size:16})})})]})}const nI=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=re(),s=f.useCallback(o=>()=>r.views.setIDOfVIE(o),[r]),i=o=>{t.editor.open(["_VIEWS_",o])};return n.jsxs(a.Box,{sx:{position:"relative"},children:[r.views.options.map(o=>n.jsx(tI,{active:r.views.idOfVIE===o.value,name:o.label,onClick:s(o.value),openSettings:()=>i(o.value)},o.value)),n.jsx(a.Divider,{variant:"dashed"}),n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:r.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:e("view.add")})]})}),rI=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=re(),s=()=>{if(!r.queries.firstID){t.editor.open(["_QUERIES_",""]);return}t.editor.open(["_QUERIES_",r.queries.firstID])},i=()=>{if(!r.filters.firstID){t.editor.open(["_FILTERS_",""]);return}t.editor.open(["_FILTERS_",r.filters.firstID])},[o,l]=f.useState(!1),c=()=>l(!0),u=()=>l(!1);return n.jsxs(a.AppShell.Navbar,{p:0,zIndex:299,children:[n.jsxs(a.AppShell.Section,{children:[n.jsxs(a.Group,{grow:!0,gap:0,sx:{...eI,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[n.jsx(a.Tooltip,{label:e("filter.labels"),withinPortal:!0,children:n.jsx(a.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:i,children:n.jsx(C.IconFilter,{size:18})})}),n.jsx(a.Tooltip,{label:e("query.labels"),withinPortal:!0,children:n.jsx(a.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:s,children:n.jsx(C.IconDatabase,{size:18})})}),n.jsx(a.Tooltip,{label:e("interactions.interactions_viewer"),withinPortal:!0,children:n.jsx(a.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:c,children:n.jsx(C.IconRoute,{size:18})})})]}),n.jsx(Jz,{opened:o,close:u})]}),n.jsx(a.AppShell.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:n.jsx(a.Text,{size:"sm",ta:"center",sx:{userSelect:"none",cursor:"default"},children:e("view.labels")})}),n.jsx(a.AppShell.Section,{grow:!0,sx:{overflow:"auto"},children:n.jsx(nI,{})}),n.jsx(a.AppShell.Section,{children:n.jsx(a.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n.jsx(a.Button,{size:"xs",leftSection:n.jsx(C.IconSettings,{size:20}),onClick:()=>t.editor.open([]),children:e("common.titles.settings")})})})]})}),sI=k.observer(({filter:e})=>{const{t}=_.useTranslation(),r=e.config;return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Checkbox,{checked:r.default_value,onChange:s=>r.setDefaultValue(s.currentTarget.checked),label:t("filter.widget.checkbox.default_checked")}),n.jsx(Dn,{filter:e})]}),n.jsx(bn,{label:t("filter.widget.checkbox.description"),value:r.description,onChange:r.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}},e.id)]})}),iI=[{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"}],aI=k.observer(function({filter:t}){const{t:r}=_.useTranslation(),s=t.config,i=f.useMemo(()=>{const l=Up();return Object.entries(l).map(([c,u])=>({group:r(`filter.widget.date_range.shortcut.${c}.label`),items:u.map(({key:d,value:p})=>({label:r(`filter.widget.date_range.shortcut.${c}.full.${d}`),value:p}))}))},[]),o=[...s.default_value];return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{children:[n.jsx(a.Checkbox,{checked:s.required,onChange:l=>s.setRequired(l.currentTarget.checked),label:r("filter.widget.date_range.required")}),n.jsx(a.Checkbox,{checked:s.allowSingleDateInRange,onChange:l=>s.setAllowSingleDateInRange(l.currentTarget.checked),label:r("filter.widget.date_range.allow_single_date")})]}),n.jsxs(a.Group,{grow:!0,children:[n.jsx(a.Select,{data:iI,label:r("filter.widget.date_range.display_format"),value:s.inputFormat,onChange:s.setInputFormat}),n.jsx(a.NumberInput,{label:r("filter.widget.date_range.max_days"),min:0,value:s.max_days,onChange:s.setMaxDays,hideControls:!0})]}),n.jsxs(a.Group,{children:[n.jsx(Ih,{label:r("filter.widget.date_range.default_value"),config:s,value:{value:o,shortcut:null},onChange:s.setDefaultValue,disabled:!!s.default_shortcut}),n.jsx(a.Select,{data:i,label:r("filter.widget.date_range.default_by_shortcut"),value:s.default_shortcut,onChange:s.setDefaultShortcut,placeholder:r("filter.widget.date_range.default_by_shortcut_placeholder"),clearable:!0,sx:{flexGrow:1},maxDropdownHeight:500})]}),n.jsx(Dn,{filter:t})]})}),oI=`
492
+ 我的卡片变量: {{ your_var }}`,tabs:{guide:"使用指南",vars:"看板信息与卡片的变量"}}}},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:"以下条件为真时,才运行本查询",description:"为假的情况: 空数组 / NaN / false / 空字符串 / undefined / null",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:"编辑动态颜色",clear:"清除动态颜色"},color_mapping:{label:"颜色映射",edit:"编辑颜色映射",clear:"清除颜色映射",choose_value_var:"选择用于映射颜色的变量",min:{val:"固定最小值",var:"动态最小值(优先)"},max:{val:"固定最大值",var:"动态最大值(优先)"}}},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:"显示标记点",area_style:{label:"区域填充样式",enabled:"启用区域填充",color:"填充颜色",use_series_color:"沿用系列本色",origin:{label:"图形区域的起始位置",auto:{label:"自动",description:"填充坐标轴线到数据间的区域(默认)"},start:{label:"自下而上",description:"填充坐标轴底部到数据间的区域"},end:{label:"自上而下",description:"填充坐标轴顶部到数据间的区域"}},shadow_blur:"图形阴影的模糊大小",shadow_color:"图形阴影的颜色",shadow_offset_x:"阴影水平方向上的偏移距离",shadow_offset_y:"阴影垂直方向上的偏移距离",opacity:"图形透明度"}},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:"颜色",background_color:"背景色",text_color:"文字颜色",click_to_add_a_color:"点击增加一个颜色",color_gradient:"颜色渐变",not_set:"未设置"},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:"请填写一个数字"}},spotlight:{trigger_text:"搜索",main_group:"主要项",placeholder:"打开…",not_found:"无匹配项"}}},Bs=Rf.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:sz,zh:iz}}).use(Wf).use(_.initReactI18next);Bs.init(),to.forEach(e=>{var t;(t=e.translation)==null||t.forEach(r=>{Bs.addResourceBundle(r.lang,"translation",{viz:r.resources},!0,!0)})});function ag({lang:e,children:t}){return f.useEffect(()=>{Bs.changeLanguage(e)},[e]),n.jsx(_.I18nextProvider,{i18n:Bs,children:t})}function qs(e){console.groupCollapsed("Running operation ",e.type),console.log(e),console.groupEnd()}function og(e,t){f.useEffect(()=>{const r=s=>{qs(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",r),()=>{window.removeEventListener("open-view",r)}},[e,t]),f.useEffect(()=>{const r=s=>{qs(s);const{dictionary:i,payload:o}=s.detail;if(!o||Object.keys(o).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(o,u);l[c]=d}),e.filters.applyValuesPatch(l)};return window.addEventListener("set-filter-values",r),()=>{window.removeEventListener("set-filter-values",r)}},[e]),f.useEffect(()=>{function r(i){return Array.isArray(i)?[]:typeof i=="object"?{}:typeof i=="boolean"?!1:typeof i=="string"?"":typeof i=="number"?0:i}const s=i=>{qs(i);const o={},{filter_keys:l}=i.detail;l.forEach(c=>{const u=v.get(e.filters.values,c),d=r(u);o[c]=d}),e.filters.applyValuesPatch(o)};return window.addEventListener("clear-filter-values",s),()=>{window.removeEventListener("clear-filter-values",s)}},[e]),f.useEffect(()=>{const r=s=>{qs(s);const{urlTemplate:i,openInNewTab:o,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,b=>{if(l&&typeof b=="string")return encodeURIComponent(b)})}const p=v.template(i||"")(u({...c,filters:e.payloadForSQL.filters,context:e.payloadForSQL.context}));window.open(p,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",r),()=>{window.removeEventListener("open-link",r)}},[e])}function lg(e){return f.useCallback(t=>t.provideValue(Pe.pluginManager,e.pluginManager).provideValue(Pe.vizManager,e.vizManager).provideValue(Pe.colorManager,e.colorManager),[])}const bE="",az=k.observer(({saveDashboardChanges:e})=>{const{t}=_.useTranslation(),r=dt.useModals(),s=re(),i=()=>{r.openConfirmModal({title:n.jsxs(a.Group,{justify:"flex-start",children:[n.jsx(C.IconAlertTriangle,{size:18,color:"red"}),n.jsx(a.Text,{size:"sm",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})},o=s.changed;return n.jsxs(a.Group,{gap:0,children:[n.jsx(a.Button,{color:"green",variant:"filled",size:"xs",leftSection:n.jsx(C.IconDeviceFloppy,{size:18}),onClick:e,disabled:!o,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:t("common.actions.save_changes")}),n.jsxs(a.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!o,children:[n.jsx(a.Menu.Target,{children:n.jsx(a.ActionIcon,{variant:"default",disabled:!o,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:n.jsx(C.IconCaretDown,{size:18})})}),n.jsx(a.Menu.Dropdown,{children:n.jsx(a.Menu.Item,{leftSection:n.jsx(C.IconRecycle,{size:14,color:"red"}),disabled:!o,onClick:i,children:t("common.actions.revert_changes")})})]})]})}),oz=k.observer(({saveDashboardChanges:e,onExit:t,headerSlot:r=null})=>{_.useTranslation();const s=se(),i=s.content.changed,o=()=>{t({hasChanges:i,dashboardId:s.id})};return n.jsx(a.AppShell.Header,{h:60,py:0,px:"md",sx:{zIndex:299},children:n.jsxs(a.Group,{justify:"space-between",sx:{height:60,minWidth:"1000px",position:"relative"},children:[n.jsxs(a.Group,{children:[n.jsx(a.Button,{size:"xs",color:i?"red":"green",leftSection:n.jsx(C.IconArrowLeft,{size:20}),onClick:o,children:n.jsx(a.Group,{gap:4,children:n.jsx(_.Trans,{i18nKey:"common.actions.end_editing",values:{name:s.name},children:n.jsx(a.Text,{td:"underline",size:"xs",children:s.name})})})}),n.jsx(az,{saveDashboardChanges:e})]}),n.jsx(a.Group,{justify:"flex-end",sx:{flexGrow:1},children:r})]})})}),cg={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},lz=k.observer(()=>{var i;const{t:e}=_.useTranslation(),t=re(),r=((i=t.views.VIE)==null?void 0:i.type)===F.Tabs,s=()=>t.addANewPanel(t.views.idOfVIE);return r?n.jsx(a.Tooltip,{label:e("common.choose_a_tab_first"),children:n.jsx(a.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftSection:n.jsx(C.IconPlaylistAdd,{size:20}),sx:{...cg,transform:"none !important"},children:e("panel.add")})}):n.jsx(a.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:s,leftSection:n.jsx(C.IconPlaylistAdd,{size:20}),sx:{...cg,background:"rgb(231, 245, 255)"},children:e("panel.add")})}),cz=k.observer(({done:e})=>{var P,ae;const{t}=_.useTranslation(),s=re().layouts,i=f.useMemo(()=>({list:s.breakpointsInfo}),[s.breakpointsInfo]),{control:o,handleSubmit:l,watch:c,getValues:u,reset:d,formState:p}=y.useForm({defaultValues:i}),{fields:h,append:x,remove:b}=y.useFieldArray({control:o,name:"list",rules:{validate:pe=>{if(v.uniqBy(pe,"breakpoint").length!==pe.length)return"Screen sizes should be unique by min width"}}}),m=c("list"),j=h.map((pe,be)=>({...pe,...m[be]})),D=()=>{x({id:Ut.v4(),name:"",breakpoint:""})},T=({list:pe})=>{const be=pe.filter(Ce=>Number.isFinite(Ce.breakpoint));s.updateLayoutSetsInfo(be),e()},z=u(),I=f.useMemo(()=>{const pe={list:z.list.filter(be=>!!be.name&&Number.isFinite(be.breakpoint))};return!v.isEqual(pe,i)},[z,i]),M=(ae=(P=p.errors.list)==null?void 0:P.root)==null?void 0:ae.message;return n.jsx(n.Fragment,{children:n.jsxs("form",{onSubmit:l(T),children:[n.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,withTableBorder:!0,sx:{tableLayout:"fixed"},children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"340px"},children:t("common.name")}),n.jsx(a.Table.Th,{style:{width:"160px"},children:t("breakpoint.breakpoint")}),n.jsx(a.Table.Th,{})]})}),n.jsxs(a.Table.Tbody,{children:[j.map((pe,be)=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:pe.id==="basis"?pe.name:n.jsx(y.Controller,{name:`list.${be}.name`,control:o,render:({field:Ce})=>n.jsx(a.TextInput,{size:"xs",label:"",required:!0,sx:{flex:1},...Ce})})}),n.jsx(a.Table.Td,{children:pe.id==="basis"?n.jsxs(a.Text,{size:"sm",ff:"monospace",children:[pe.breakpoint,"px"]}):n.jsx(y.Controller,{name:`list.${be}.breakpoint`,control:o,render:({field:Ce})=>n.jsx(a.NumberInput,{size:"xs",label:"",required:!0,max:1e4,hideControls:!0,rightSection:n.jsx(a.Text,{size:"sm",c:"dimmed",children:"px"}),rightSectionProps:{style:{width:"30px"}},sx:{flex:1},ff:"monospace",styles:{input:{paddingRight:"30px"}},...Ce})})}),n.jsx(a.Table.Td,{children:pe.id!=="basis"&&n.jsx(a.ActionIcon,{mx:"auto",size:"xs",variant:"subtle",color:"red",onClick:()=>b(be),children:n.jsx(C.IconTrash,{})})})]},pe.id)),n.jsx(a.Table.Tr,{style:{backgroundColor:"transparent"},children:n.jsx(a.Table.Td,{colSpan:3,style:{padding:"0"},children:n.jsx(a.Tooltip,{label:t("breakpoint.add"),children:n.jsx(a.ActionIcon,{variant:"subtle",size:"md",color:"blue",onClick:D,sx:{width:"100%"},children:n.jsx(C.IconPlus,{size:18})})})})})]})]}),n.jsx(a.Text,{mt:6,ta:"right",size:"xs",c:"red",children:M??" "}),n.jsxs(a.Group,{mt:6,justify:"space-between",children:[n.jsx(a.Button,{color:"orange",size:"xs",onClick:()=>d(),leftSection:n.jsx(C.IconRecycle,{size:18}),disabled:!I,children:t("common.actions.revert")}),n.jsx(a.Button,{color:"green",size:"xs",type:"submit",leftSection:n.jsx(C.IconDeviceFloppy,{size:18}),disabled:!I,children:t("common.actions.save_changes")})]})]})})}),uz=k.observer(()=>{const{t:e}=_.useTranslation(),[t,{open:r,close:s}]=ze.useDisclosure(!1),i=re(),o=i.layouts.currentBreakpoint,l=i.layouts.currentLayoutRange,c=()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},u=()=>{s(),c()};return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{children:[n.jsxs(a.Menu,{withArrow:!0,withinPortal:!0,zIndex:320,trigger:"hover",children:[n.jsx(a.Menu.Target,{children:n.jsx(a.Button,{size:"xs",variant:"subtle",leftSection:n.jsx(C.IconDevices,{size:16}),sx:{borderRadius:0},children:n.jsxs(a.Group,{gap:6,children:[n.jsx(a.Text,{size:"xs",fw:"normal",children:l.name}),n.jsx(a.Text,{size:"xs",c:"#777",children:i.layouts.currentRangeText})]})})}),n.jsxs(a.Menu.Dropdown,{children:[i.layouts.breakpointRanges.map(d=>n.jsx(a.Menu.Item,{onClick:()=>i.layouts.setCurrentBreakpoint(d.id),disabled:o===d.id,children:n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Text,{size:"sm",children:d.name}),n.jsx(a.Text,{size:"xs",c:"dimmed",children:d.text})]})},d.id)),n.jsx(a.Menu.Divider,{}),n.jsx(a.Menu.Item,{color:"blue",leftSection:n.jsx(C.IconSettings,{size:14}),onClick:r,children:n.jsx(a.Text,{size:"sm",children:e("breakpoint.manage")})})]})]}),i.layouts.divisionPreviewScale<1&&n.jsx(a.Text,{size:"xs",c:"dimmed",children:Lr(i.layouts.divisionPreviewScale).format({output:"percent",mantissa:0})})]}),n.jsx(a.Modal,{opened:t,onClose:u,title:e("breakpoint.label",{count:2}),withinPortal:!0,zIndex:320,size:600,closeOnClickOutside:!1,children:n.jsx(cz,{done:u})})]})}),ug={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},dz=k.observer(()=>{var i;const{t:e}=_.useTranslation(),t=re(),r=((i=t.views.VIE)==null?void 0:i.type)===F.Tabs,s=()=>{var o;return(o=t.views.VIE)==null?void 0:o.downloadSchema()};return r?n.jsx(a.Tooltip,{label:e("common.choose_a_tab_first"),children:n.jsx(a.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftSection:n.jsx(C.IconCode,{size:16}),sx:{...ug,transform:"none !important"},children:e("view.download_schema")})}):n.jsx(a.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:s,leftSection:n.jsx(C.IconCode,{size:16}),sx:{...ug},children:e("view.download_schema")})}),Ns=({headers:e,rows:t})=>n.jsxs(a.Table,{fz:"xs",highlightOnHover:!0,sx:{tableLayout:"fixed",fontFamily:"monospace"},children:[n.jsx(a.Table.Thead,{children:e}),n.jsx(a.Table.Tbody,{children:t})]}),pz=({content:e})=>{const{t}=_.useTranslation(),r=e.views;return!Array.isArray(r)||r.length===0?null:n.jsxs(a.Box,{children:[n.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("view.labels")}),n.jsx(Ns,{headers:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(a.Table.Th,{children:t("common.name")}),n.jsx(a.Table.Th,{children:t("common.type")})]}),rows:r.map(s=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:s.id}),n.jsx(a.Table.Td,{children:s.name}),n.jsx(a.Table.Td,{children:t(`view.component.${s.type}.label`)})]},s.id))})]})},hz=({content:e})=>{const{t}=_.useTranslation(),r=e.filters;return!Array.isArray(r)||r.length===0?null:n.jsxs(a.Box,{children:[n.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("filter.labels")}),n.jsx(Ns,{headers:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(a.Table.Th,{children:t("common.key")}),n.jsx(a.Table.Th,{children:t("common.label")})]}),rows:r.map(s=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:s.id}),n.jsx(a.Table.Td,{children:s.key}),n.jsx(a.Table.Td,{children:s.label})]},s.id))})]})},gz=({content:e})=>{const{t}=_.useTranslation(),r=e.panels;return!Array.isArray(r)||r.length===0?null:n.jsxs(a.Box,{children:[n.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("panel.labels")}),n.jsx(Ns,{headers:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(a.Table.Th,{children:t("common.name")}),n.jsx(a.Table.Th,{children:t("visualization.component")})]}),rows:r.map(s=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:s.id}),n.jsx(a.Table.Td,{children:s.name}),n.jsx(a.Table.Td,{children:s.viz.type})]},s.id))})]})},fz=({content:e})=>{var s;const{t}=_.useTranslation(),r=(s=e.definition)==null?void 0:s.queries;return!Array.isArray(r)||r.length===0?null:n.jsxs(a.Box,{children:[n.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("query.labels")}),n.jsx(Ns,{headers:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"160px"},children:t("common.id")}),n.jsx(a.Table.Th,{children:t("common.name")}),n.jsx(a.Table.Th,{style:{width:"140px"},children:t("common.type")}),n.jsx(a.Table.Th,{style:{width:"260px"},children:t("data_source.label")})]}),rows:r.map(i=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:i.id}),n.jsx(a.Table.Td,{children:i.name}),n.jsx(a.Table.Td,{children:i.type}),n.jsx(a.Table.Td,{children:i.key})]},i.id))})]})},xz=({content:e})=>{var s;const{t}=_.useTranslation(),r=(s=e.definition)==null?void 0:s.sqlSnippets;return!Array.isArray(r)||r.length===0?null:n.jsxs(a.Box,{children:[n.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("sql_snippet.labels")}),n.jsx(a.List,{size:"sm",pl:10,ff:"monospace",icon:n.jsx(C.IconPointFilled,{size:10}),children:r.map(i=>n.jsx(a.List.Item,{children:i.key},i.key))})]})},mz=({content:e})=>{var s;const{t}=_.useTranslation(),r=Object.keys(((s=e.definition)==null?void 0:s.mock_context)??{});return r.length===0?null:n.jsxs(a.Box,{children:[n.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("mock_context.label")}),n.jsx(a.List,{size:"sm",pl:10,ff:"monospace",icon:n.jsx(C.IconPointFilled,{size:10}),children:r.map(i=>n.jsx(a.List.Item,{children:i},i))})]})},bz=({content:e})=>e?n.jsxs(a.Box,{children:[n.jsx(a.Divider,{mt:20,mb:10,variant:"dashed"}),n.jsx(a.Text,{ta:"left",c:"dimmed",size:"sm",children:"Preview"}),n.jsxs(a.Stack,{children:[n.jsx(pz,{content:e}),n.jsx(hz,{content:e}),n.jsx(gz,{content:e}),n.jsx(fz,{content:e}),n.jsx(xz,{content:e}),n.jsx(mz,{content:e})]})]}):null;function yz(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!==nn)throw new Error("Schema version mismatch");return t}const vz=k.observer(({onSuccess:e,stretchModal:t,shrinkModal:r})=>{var T,z;const{t:s}=_.useTranslation(),i=re(),{handleSubmit:o,formState:{errors:l},setValue:c,watch:u,setError:d,clearErrors:p}=y.useForm({defaultValues:{content:null}}),h=({content:I})=>{try{if(!I)throw new Error("please use a valid json file");i.applyJSONSchema(I),Nt.showNotification({title:"Successful",message:"",color:"green"}),e()}catch(M){console.error(M),Nt.showNotification({title:"Failed",message:M.message,color:"red"})}},[x,b]=f.useState(null);f.useEffect(()=>{if(!x)return;const I=new FileReader;I.readAsText(x,"UTF-8"),I.onload=M=>{try{const P=yz(M);c("content",P),p("content")}catch(P){console.error(P),d("content",{type:"custom",message:P.message})}},I.onabort=()=>console.log("🟨 abort"),I.onerror=()=>{I.error&&(console.error(I.error),d("content",{type:"custom",message:I.error.message}))}},[x]);const[m]=u(["content"]),j=!m,D=(T=l==null?void 0:l.content)==null?void 0:T.message;return f.useEffect(()=>{!m||D?r():t()},[m,D]),n.jsx(a.Box,{mx:"auto",sx:{position:"relative"},children:n.jsxs("form",{onSubmit:o(h),children:[n.jsx(a.FileInput,{label:s("import.json_file"),required:!0,value:x,onChange:b,error:(z=l==null?void 0:l.content)==null?void 0:z.message,sx:{maxWidth:500}}),D?n.jsx(a.Table,{fz:12,mt:10,children:n.jsxs(a.Table.Tbody,{children:[n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:s("import.this_dashboard")}),n.jsx(a.Table.Td,{children:nn})]}),n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:s("import.this_file")}),n.jsx(a.Table.Td,{style:{color:"red"},children:m==null?void 0:m.version})]})]})}):n.jsxs(n.Fragment,{children:[n.jsx(bz,{content:m}),n.jsx(a.Group,{justify:"flex-end",my:"md",children:n.jsx(a.Button,{type:"submit",color:"green",disabled:j,children:s("common.actions.confirm")})})]})]})})}),dg={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},_z=k.observer(()=>{var d;const{t:e}=_.useTranslation(),[t,{open:r,close:s}]=ze.useDisclosure(!1),[i,{setTrue:o,setFalse:l}]=Y.useBoolean(!1),u=((d=se().content.views.VIE)==null?void 0:d.type)===F.Tabs;return u?n.jsx(a.Tooltip,{label:e("common.choose_a_tab_first"),children:n.jsx(a.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftSection:n.jsx(C.IconFileImport,{size:16}),sx:{...dg,transform:"none !important"},children:e("import.label")})}):n.jsxs(n.Fragment,{children:[n.jsx(a.Button,{variant:"subtle",color:"blue",radius:0,size:"xs",disabled:u||t,onClick:r,leftSection:n.jsx(C.IconFileImport,{size:16}),sx:{...dg},children:e("import.label")}),n.jsx(a.Modal,{opened:t,onClose:s,title:e("import.title"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},withinPortal:!0,zIndex:320,size:i?"90vw":500,children:n.jsx(vz,{onSuccess:s,stretchModal:o,shrinkModal:l})})]})}),yE="",jz=({iconKey:e,...t})=>{switch(e){case"query_variables":return n.jsx(C.IconVariable,{...t});case"mock_context":return n.jsx(C.IconCodeDots,{...t});case"filter":return n.jsx(C.IconFilter,{...t});case"sql_snippet":return n.jsx(C.IconCopy,{...t});case"query":return n.jsx(C.IconDatabase,{...t});case"view":return n.jsx(C.IconBoxMultiple,{...t});case"panel":return n.jsx(C.IconAppWindow,{...t});default:return null}},wz=({action:e})=>{const{t}=_.useTranslation();return e.description?n.jsx(a.Text,{c:"dimmed",size:"xs",children:t(e.description)}):e.viz?n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Text,{c:"dimmed",size:"xs",children:t(e.viz.displayName)}),n.jsx(a.Text,{c:"dimmed",size:"xs",className:"spotlight-action-viz-group",children:t(e.viz.displayGroup)})]}):null},Cz=k.observer(({action:e,query:t})=>{const{t:r}=_.useTranslation();return n.jsx(a.Box,{className:"spotlight-custom-action-component",children:n.jsxs(a.Group,{wrap:"nowrap",children:[n.jsx(jz,{iconKey:e.iconKey,size:14}),n.jsxs("div",{style:{flex:1},children:[n.jsx(a.Highlight,{highlight:t,size:"sm",children:e.title?r(e.title):""}),n.jsx(wz,{action:e})]})]})})}),Sz=({groups:e,query:t})=>{const{t:r}=_.useTranslation();return e.length===0?n.jsx(_n.Spotlight.Empty,{children:r("spotlight.not_found")}):n.jsx(n.Fragment,{children:e.map(s=>n.jsx(_n.Spotlight.ActionsGroup,{label:s.group,children:s.actions.map(i=>n.jsx(_n.Spotlight.Action,{onClick:i.onClick,children:n.jsx(Cz,{action:i,query:t})},i.id))},s.group))})},Tz=k.observer(()=>{const{t:e,i18n:t}=_.useTranslation(),r=a.useMantineTheme(),s=se(),[i,o]=f.useState(""),l=f.useMemo(()=>s.editor.spotlightActionGroups.map(u=>({group:e(u.group),keywords:[u.group,e(u.group)],actions:u.actions.map(d=>{const p=[];return d.title&&(p.push(d.title.toLowerCase()),p.push(e(d.title).toLowerCase())),d.group&&p.push(d.group.toLowerCase()),d.viz&&(p.push(d.viz.displayGroup.toLowerCase()),p.push(d.viz.displayName.toLowerCase())),d.iconKey&&p.push(d.iconKey),{...d,keywords:p}})})),[s.editor.spotlightActionGroups,t.language]),c=f.useMemo(()=>{const u=i.toLowerCase().trim();return u?l.map(p=>{if(p.keywords.some(b=>b.includes(u)))return p;const x=p.actions.filter(b=>b.keywords.some(m=>m.includes(u)));return x.length===0?null:{...p,actions:x}}).filter(p=>p!==null):[l[0]]},[l,i]);return n.jsxs(_n.Spotlight.Root,{onQueryChange:o,shortcut:["mod + P","mod + K"],radius:"md",styles:{search:{border:"none"},action:{position:"relative",display:"block",width:"100%",padding:`${a.rem(10)} ${a.rem(12)}`,borderRadius:r.radius.sm,".spotlight-action-viz-group":{opacity:0},"&:hover, &[data-selected]":{backgroundColor:r.colors.gray[1],".spotlight-action-viz-group":{opacity:1}}}},children:[n.jsx(_n.Spotlight.Search,{placeholder:e("spotlight.placeholder"),leftSection:n.jsx(C.IconSearch,{size:"1.2rem"})}),n.jsx(_n.Spotlight.ActionsList,{children:n.jsx(Sz,{groups:c,query:i})})]})}),pg=({children:e})=>n.jsx(a.Text,{style:{fontSize:"0.6875rem",lineHeight:1,padding:"0.25rem 0.2375rem",borderRadius:"0.25rem"},children:e}),hg=function(){var t;return(((t=navigator.userAgentData)==null?void 0:t.platform)??navigator.platform).toLowerCase().includes("mac")}(),kz=()=>{const{t:e}=_.useTranslation();return n.jsx(a.Tooltip,{label:n.jsxs(n.Fragment,{children:[hg&&n.jsx(pg,{children:"⌘ + K"}),!hg&&n.jsx(pg,{children:"Ctrl + K"})]}),children:n.jsx(a.UnstyledButton,{onClick:()=>_n.spotlight.open(),style:{height:"1.875rem",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef",paddingLeft:"calc(0.875rem / 1.5)",paddingRight:"1rem"},sx:{color:"#228be6",background:"transparent","&:hover":{background:"rgb(231, 245, 255)"}},children:n.jsxs(a.Group,{gap:"0.625rem",children:[n.jsx(C.IconSearch,{size:"1rem",color:"#228be6"}),n.jsx(a.Text,{fw:500,style:{flexGrow:1,fontWeight:500,fontSize:"0.75rem",lineHeight:1},children:e("spotlight.trigger_text")})]})})})},Dz={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},zz=k.observer(()=>n.jsx(a.Box,{sx:Dz,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:n.jsxs(a.Group,{justify:"space-between",align:"center",sx:{height:"30px"},children:[n.jsxs(a.Group,{justify:"flex-start",gap:0,children:[n.jsx(lz,{}),n.jsx(_z,{}),n.jsx(kz,{})]}),n.jsx(uz,{}),n.jsx(a.Group,{justify:"flex-end",gap:0,children:n.jsx(dz,{})})]})})),Iz=k.observer(e=>n.jsxs(n.Fragment,{children:[n.jsx(oz,{...e}),n.jsx(zz,{})]})),vE="";function Mz(e,t,r){const s=[];return e.filter(i=>"__INTERACTIONS"in i.viz.conf).forEach((i,o)=>{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:x,data:b}=h,{config:m}=b;switch(x){case"builtin:op:open-link":let j=m.urlTemplate.substring(0,100);m.urlTemplate.length>=20&&(j+="..."),l.type="interaction",l.data.interactions.push({schemaRef:x,urlTemplate:m.urlTemplate,shortURLTemplate:j});return;case"builtin:op:open_view":s.push({id:`OPERATION--${p}`,source:i.id,target:m.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:x,filters:Object.keys(m.dictionary).map(D=>({key:D,label:r[D]}))});return;case"builtin:op:clear_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:x,filters:m.filter_keys.map(D=>({key:D,label:r[D]}))});return;default:return}})}),s}function Ez(e,t){const r=e.filters.keyLabelMap;return{edges:Mz(e.panels.list,t,r),edgeNodes:[]}}function gg(e,t,r){return e*t+e*r}function Pz(e,t,r){return e*t+(e-1)*r}const $s=25,Fo=40,fg=25,Qo=350,Az=150,Lz=150,xg=150,mg=300,Gs=40,bg=25,Oz=300;function Vz(e,t){const r=v.keyBy(t,i=>i.id),s=[];return e.current.forEach((i,o)=>{i.panelIDs.forEach((l,c)=>{const u=gg(c,Gs,bg)+Fo,d=r[l];if(!d){s.push({id:l,_node_type:"panel",parentNode:i.id,data:{label:`!: ${l}`},position:{x:$s,y:u},sourcePosition:Ge.Position.Right,targetPosition:Ge.Position.Left,style:{width:mg,height:Gs}});return}const p=d.name;s.push({id:d.id,_node_type:"panel",parentNode:i.id,data:{label:p},position:{x:$s,y:u},sourcePosition:Ge.Position.Right,targetPosition:Ge.Position.Left,style:{width:mg,height:Gs}})})}),s}const Bz={[F.Division]:"Div",[F.Modal]:"Modal",[F.Tabs]:"Tabs"},qz=Uh;function Nz(e){return e.current.map((r,s)=>{const i=Pz(r.panelIDs.length,Gs,bg)+Fo+fg;let o=[];return r.type===F.Tabs&&(o=r.config.tabsInOrder.map(c=>c.view_id)),{id:r.id,_node_type:"view-root",_view_type:r.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:o,data:{label:`${Bz[r.type]}:${r.name}`},position:{x:0,y:0},sourcePosition:Ge.Position.Right,targetPosition:Ge.Position.Left,className:"light",style:{backgroundColor:qz[r.type],width:Qo,height:i}}})}function $z(e){const t=v.keyBy(e,r=>r.id);e.forEach(r=>{r._node_type!=="view-root"||r._view_type!==F.Tabs||r._tab_view_ids.forEach(s=>{t[s].parentNode=r.id})})}function Gz(e){const t=Nz(e.views);$z(t);const r=Vz(e.views,e.panels.list);return[...t,...r]}function Fz({nodeMap:e,nodes:t,edges:r}){t.forEach(s=>{s._node_type!=="view-root"||s._view_type!==F.Tabs||(s.sourcePosition=Ge.Position.Bottom,s.style.width=Qo+$s*2,s.style.height=fg+s._tab_view_ids.reduce((i,o)=>{const l=e[o];l.position.y=i,l.position.x=$s;const c=l.style.height;return i+c+20},Fo))})}function Qz({nodeMap:e,nodes:t,edges:r}){r.filter(s=>s.label==="Open View").forEach(s=>{const i=e[s.source],o=e[s.target];if(!i||!o||!i.parentNode)return;const l=e[i.parentNode];l._node_type!=="view-root"||o._node_type!=="view-root"||(o._view_level+=1+l._view_level,l._sub_view_ids.push(o.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 Rz({nodeMap:e,nodes:t,edges:r}){const s={};r.forEach(i=>{if(i.label!=="Open View")return;const o=e[i.source],l=e[i.target];if(o&&l&&o.parentNode){const c=e[o.parentNode],u=c.position.x,d=Number(v.get(l,"style.height",0)),p=Number(c.style.width);l.position.x=u+p+Oz,c._view_level===0&&l._sub_view_ids.length===0&&(o.sourcePosition=Ge.Position.Left,l.targetPosition=Ge.Position.Right,l.position.x*=-1);const x=l.position.x,b=v.get(s,x,0);l.position.y=b,s[x]=b+d+xg}})}function Wz({nodeMap:e,nodes:t,edges:r}){const s=new Set,i=new Set;r.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=gg(c,Qo,Lz),l.position.y=0-Az-xg})}function Uz({nodeMap:e,nodes:t,edges:r}){const s={nodeMap:e,nodes:t,edges:r};return Wz(s),Qz(s),Fz(s),Rz(s),{nodes:t,edges:r}}function Yz(e){const t=Gz(e),r=v.keyBy(t,u=>u.id),{edges:s,edgeNodes:i}=Ez(e,r),o=[...t,...i],l=v.keyBy(o,u=>u.id),c={edges:v.uniqBy(s,u=>u.id),nodes:o,nodeMap:l};return Uz(c)}const _E="",Ro={"builtin:op:open-link":n.jsx(a.ThemeIcon,{color:"blue",size:20,radius:"xl",children:n.jsx(C.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":n.jsx(a.ThemeIcon,{color:"orange",size:20,radius:"xl",children:n.jsx(C.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":n.jsx(a.ThemeIcon,{color:"orange",size:20,radius:"xl",children:n.jsx(C.IconCircleOff,{size:14})})};function Kz(e){const t=[];return e.forEach(r=>{switch(r.schemaRef){case"builtin:op:open-link":t.push({key:r.urlTemplate,icon:Ro[r.schemaRef],text:n.jsxs(a.Group,{gap:4,children:[n.jsx(a.Text,{size:"sm",children:"Open: "}),n.jsx(a.Text,{size:"sm",c:"dimmed",children:r.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":r.filters.forEach(({key:s,label:i})=>{t.push({key:r.schemaRef+s,icon:Ro[r.schemaRef],text:n.jsx(a.Group,{gap:4,children:n.jsxs(a.Text,{size:"sm",children:["Set Filter: ",i]})})})});return;case"builtin:op:clear_filter_values":r.filters.forEach(({key:s,label:i})=>{t.push({key:r.schemaRef+s,icon:Ro[r.schemaRef],text:n.jsx(a.Group,{gap:4,children:n.jsxs(a.Text,{size:"sm",children:["Clear Filter: ",i]})})})});return}}),t}const Xz=f.memo(({data:e,isConnectable:t,sourcePosition:r=Ge.Position.Right,targetPosition:s=Ge.Position.Left,...i})=>{const o=f.useMemo(()=>Kz(e.interactions),[e.interactions]);return n.jsxs(n.Fragment,{children:[n.jsx(Ge.Handle,{type:"target",position:s,isConnectable:t}),n.jsx(a.Box,{sx:{position:"absolute",top:0,right:0},children:n.jsx(C.IconChevronsUpRight,{size:12})}),n.jsxs(a.HoverCard,{shadow:"xl",withinPortal:!0,children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.Text,{size:"sm",children:e.label})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsx(a.List,{spacing:"xs",size:"sm",center:!0,children:o.map(l=>n.jsx(a.List.Item,{icon:l.icon,children:l.text},l.key))})})]}),n.jsx(Ge.Handle,{type:"source",position:r,isConnectable:t})]})}),jE="",Hz={interaction:Xz},Zz=k.observer(()=>{const e=Te(),{edges:t,nodes:r}=Yz(e);return n.jsxs(Ge,{nodes:r,edges:t,onNodesChange:v.noop,onEdgesChange:v.noop,onConnect:v.noop,className:"interactions-viewer",fitView:!0,nodeTypes:Hz,children:[n.jsx(Ge.MiniMap,{}),n.jsx(Ge.Controls,{}),n.jsx(Ge.Background,{})]})}),Jz=k.observer(({opened:e,close:t})=>{const{t:r}=_.useTranslation();return n.jsx(a.Modal,{size:"96vw",opened:e,onClose:t,title:r("interactions.interactions_viewer"),trapFocus:!0,onDragStart:s=>{s.stopPropagation()},styles:{body:{height:"calc(90vh - 54px)"},content:{transform:"none !important"}},zIndex:300,children:n.jsx(Zz,{})})}),eI={"> 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 tI({onClick:e,name:t,active:r,openSettings:s}){return n.jsxs(a.Box,{sx:{position:"relative"},children:[n.jsx(a.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:r?i.colors.gray[2]:"transparent"}),children:n.jsx(a.Group,{sx:{width:"calc(100% - 28px)"},onClick:e,children:n.jsx(a.Text,{size:"sm",children:t})})}),r&&n.jsx(a.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:n.jsx(a.ActionIcon,{onClick:s,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:n.jsx(C.IconAdjustments,{size:16})})})]})}const nI=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=re(),s=f.useCallback(o=>()=>r.views.setIDOfVIE(o),[r]),i=o=>{t.editor.open(["_VIEWS_",o])};return n.jsxs(a.Box,{sx:{position:"relative"},children:[r.views.options.map(o=>n.jsx(tI,{active:r.views.idOfVIE===o.value,name:o.label,onClick:s(o.value),openSettings:()=>i(o.value)},o.value)),n.jsx(a.Divider,{variant:"dashed"}),n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:r.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:e("view.add")})]})}),rI=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=re(),s=()=>{if(!r.queries.firstID){t.editor.open(["_QUERIES_",""]);return}t.editor.open(["_QUERIES_",r.queries.firstID])},i=()=>{if(!r.filters.firstID){t.editor.open(["_FILTERS_",""]);return}t.editor.open(["_FILTERS_",r.filters.firstID])},[o,l]=f.useState(!1),c=()=>l(!0),u=()=>l(!1);return n.jsxs(a.AppShell.Navbar,{p:0,zIndex:299,children:[n.jsxs(a.AppShell.Section,{children:[n.jsxs(a.Group,{grow:!0,gap:0,sx:{...eI,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[n.jsx(a.Tooltip,{label:e("filter.labels"),withinPortal:!0,children:n.jsx(a.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:i,children:n.jsx(C.IconFilter,{size:18})})}),n.jsx(a.Tooltip,{label:e("query.labels"),withinPortal:!0,children:n.jsx(a.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:s,children:n.jsx(C.IconDatabase,{size:18})})}),n.jsx(a.Tooltip,{label:e("interactions.interactions_viewer"),withinPortal:!0,children:n.jsx(a.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:c,children:n.jsx(C.IconRoute,{size:18})})})]}),n.jsx(Jz,{opened:o,close:u})]}),n.jsx(a.AppShell.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:n.jsx(a.Text,{size:"sm",ta:"center",sx:{userSelect:"none",cursor:"default"},children:e("view.labels")})}),n.jsx(a.AppShell.Section,{grow:!0,sx:{overflow:"auto"},children:n.jsx(nI,{})}),n.jsx(a.AppShell.Section,{children:n.jsx(a.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n.jsx(a.Button,{size:"xs",leftSection:n.jsx(C.IconSettings,{size:20}),onClick:()=>t.editor.open([]),children:e("common.titles.settings")})})})]})}),sI=k.observer(({filter:e})=>{const{t}=_.useTranslation(),r=e.config;return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Checkbox,{checked:r.default_value,onChange:s=>r.setDefaultValue(s.currentTarget.checked),label:t("filter.widget.checkbox.default_checked")}),n.jsx(Dn,{filter:e})]}),n.jsx(bn,{label:t("filter.widget.checkbox.description"),value:r.description,onChange:r.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}},e.id)]})}),iI=[{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"}],aI=k.observer(function({filter:t}){const{t:r}=_.useTranslation(),s=t.config,i=f.useMemo(()=>{const l=Up();return Object.entries(l).map(([c,u])=>({group:r(`filter.widget.date_range.shortcut.${c}.label`),items:u.map(({key:d,value:p})=>({label:r(`filter.widget.date_range.shortcut.${c}.full.${d}`),value:p}))}))},[]),o=[...s.default_value];return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{children:[n.jsx(a.Checkbox,{checked:s.required,onChange:l=>s.setRequired(l.currentTarget.checked),label:r("filter.widget.date_range.required")}),n.jsx(a.Checkbox,{checked:s.allowSingleDateInRange,onChange:l=>s.setAllowSingleDateInRange(l.currentTarget.checked),label:r("filter.widget.date_range.allow_single_date")})]}),n.jsxs(a.Group,{grow:!0,children:[n.jsx(a.Select,{data:iI,label:r("filter.widget.date_range.display_format"),value:s.inputFormat,onChange:s.setInputFormat}),n.jsx(a.NumberInput,{label:r("filter.widget.date_range.max_days"),min:0,value:s.max_days,onChange:s.setMaxDays,hideControls:!0})]}),n.jsxs(a.Group,{children:[n.jsx(Ih,{label:r("filter.widget.date_range.default_value"),config:s,value:{value:o,shortcut:null},onChange:s.setDefaultValue,disabled:!!s.default_shortcut}),n.jsx(a.Select,{data:i,label:r("filter.widget.date_range.default_by_shortcut"),value:s.default_shortcut,onChange:s.setDefaultShortcut,placeholder:r("filter.widget.date_range.default_by_shortcut_placeholder"),clearable:!0,sx:{flexGrow:1},maxDropdownHeight:500})]}),n.jsx(Dn,{filter:t})]})}),oI=`
493
493
  // row
494
494
  {
495
495
  label: string;
496
496
  value: string;
497
497
  description?: string; // optional
498
498
  }
499
- `,yg=()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(a.Button,{variant:"subtle",size:"compact-sm",onClick:()=>r(s=>!s),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),n.jsx(a.Collapse,{in:t,children:n.jsx(Dt.CodeHighlight,{language:"typescript",withCopyButton:!1,code:oI})})]})},lI=k.observer(function({filter:t}){const{t:r}=_.useTranslation(),s=t.config,i=()=>{s.addStaticOption({label:"",value:""})},o=s.static_options,l=[...o];return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Checkbox,{checked:s.required,onChange:c=>s.setRequired(c.currentTarget.checked),label:r("filter.widget.select.required")}),n.jsx(Dn,{filter:t})]}),n.jsx(a.TextInput,{label:r("filter.widget.select.width"),description:r("filter.widget.multi_select.width_description"),value:s.min_width,onChange:c=>s.setMinWidth(c.currentTarget.value),placeholder:"200px"}),n.jsx(a.Divider,{label:r("filter.widget.select.configure_options"),labelPosition:"center"}),n.jsxs(a.Stack,{gap:10,sx:{position:"relative",minHeight:"50px"},children:[s.usingQuery&&n.jsxs(n.Fragment,{children:[n.jsx(a.Overlay,{backgroundOpacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),n.jsx(a.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:n.jsx(a.Text,{c:"white",size:"16px",children:r("filter.widget.common.using_query")})})]}),o.length>0&&n.jsx(a.MultiSelect,{label:r("filter.widget.select.default_selection"),data:l,value:[...s.default_value],onChange:s.setDefaultValue}),o.map((c,u)=>n.jsxs(a.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[n.jsx(a.TextInput,{label:r("common.label"),required:!0,value:s.static_options[u].label,onChange:d=>{s.static_options[u].setLabel(d.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(a.TextInput,{label:r("common.value"),required:!0,value:s.static_options[u].value,onChange:d=>{s.static_options[u].setValue(d.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>s.removeStaticOption(u),sx:{position:"absolute",top:28,right:5},children:n.jsx(C.IconTrash,{size:16})})]},u)),n.jsx(a.Button,{mt:10,size:"xs",color:"blue",leftSection:n.jsx(C.IconPlaylistAdd,{size:20}),onClick:i,sx:{width:"50%"},mx:"auto",children:r("common.actions.add_an_option")})]}),n.jsx(a.Divider,{label:r("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),n.jsx(a.NumberInput,{value:s.default_selection_count,onChange:s.setDefaultSelectionCount,label:r("filter.widget.common.default_selection_count")}),n.jsx(Es,{value:s.options_query_id,onChange:s.setOptionsQueryID}),n.jsx(yg,{})]})}),vg={date_unit:{zh:[{label:"天",value:"day"},{label:"周",value:"week"},{label:"双周",value:"bi-week"},{label:"月",value:"month"},{label:"季度",value:"quarter"},{label:"年",value:"year"}],en:[{label:"Day",value:"day"},{label:"Week",value:"week"},{label:"Bi-Week",value:"bi-week"},{label:"Month",value:"month"},{label:"Quarter",value:"quarter"},{label:"Year",value:"year"}]}},_g=k.observer(({config:e})=>{const{t,i18n:r}=_.useTranslation(),s=()=>{e.addStaticOption({label:"",value:""})},i=f.useMemo(()=>[{label:t("filter.widget.select.preset_options.date_unit"),value:"date_unit"}],[r.language]),o=l=>{if(!l||!(l in vg))return;const c=vg[l][r.language];e.replaceStaticOptions(c),c.length>0&&e.setDefaultValue(c[0].value)};return n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Button,{size:"xs",color:"blue",leftSection:n.jsx(C.IconPlaylistAdd,{size:20}),onClick:s,children:t("common.actions.add_an_option")}),n.jsx(a.Select,{placeholder:t("filter.widget.select.preset_options.apply"),value:null,onChange:o,data:i,size:"xs"})]})}),cI=k.observer(({config:e})=>{const{t,i18n:r}=_.useTranslation(),s=[...e.static_options],i=f.useMemo(()=>[{label:t("filter.widget.select.no_default_selection"),value:""},...s],[r.language,s]);return s.length===0?n.jsx(_g,{config:e}):n.jsxs(n.Fragment,{children:[n.jsx(a.Select,{label:t("filter.widget.select.default_selection"),data:i,value:e.default_value,onChange:e.setDefaultValue}),s.map((o,l)=>n.jsxs(a.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[n.jsx(a.TextInput,{label:t("common.label"),required:!0,value:e.static_options[l].label,onChange:c=>{e.static_options[l].setLabel(c.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(a.TextInput,{label:t("common.value"),required:!0,value:e.static_options[l].value,onChange:c=>{e.static_options[l].setValue(c.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.removeStaticOption(l),sx:{position:"absolute",top:28,right:5},children:n.jsx(C.IconTrash,{size:16})})]},l)),n.jsx(_g,{config:e})]})}),uI=k.observer(({filter:e})=>{const{t}=_.useTranslation(),r=e.config;return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Checkbox,{checked:r.required,onChange:s=>r.setRequired(s.currentTarget.checked),label:t("filter.widget.select.required")}),n.jsx(a.Checkbox,{checked:r.clearable,onChange:s=>r.setClearable(s.currentTarget.checked),label:t("filter.widget.select.clearable")}),n.jsx(Dn,{filter:e})]}),n.jsx(a.TextInput,{label:t("filter.widget.select.width"),value:r.width,onChange:s=>r.setWidth(s.currentTarget.value),placeholder:"200px"}),n.jsx(a.Divider,{label:t("filter.widget.select.configure_options"),labelPosition:"center"}),n.jsxs(a.Stack,{gap:10,sx:{position:"relative",minHeight:"50px"},children:[r.usingQuery&&n.jsxs(n.Fragment,{children:[n.jsx(a.Overlay,{backgroundOpacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),n.jsx(a.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:n.jsx(a.Text,{c:"white",size:"16px",children:t("filter.widget.common.using_query")})})]}),n.jsx(cI,{config:r})]}),n.jsx(a.Divider,{label:t("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),n.jsx(a.Checkbox,{checked:r.default_selection_count===1,onChange:s=>r.setDefaultSelectionCount(s.currentTarget.checked?1:0),label:t("filter.widget.select.select_first_option_by_default")}),n.jsx(Es,{value:r.options_query_id,onChange:r.setOptionsQueryID}),n.jsx(yg,{})]})}),dI=k.observer(function({filter:t}){const{t:r}=_.useTranslation(),s=t.config;return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{children:[n.jsx(a.TextInput,{label:r("filter.widget.text_input.default_value"),value:s.default_value,onChange:i=>{s.setDefaultValue(i.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(a.Box,{mt:22,children:n.jsx(Dn,{filter:t})})]}),n.jsx(a.Checkbox,{checked:s.required,onChange:i=>s.setRequired(i.currentTarget.checked),label:r("filter.widget.text_input.required")})]})}),pI=k.observer(function({filter:t}){const{t:r}=_.useTranslation();return n.jsxs(a.Box,{sx:{maxWidth:"480px"},children:[n.jsx(a.Text,{pt:"0",pb:"md",c:"gray",size:"sm",children:r("common.titles.config")}),n.jsx(Dt.CodeHighlight,{mt:22,language:"json",withCopyButton:!1,code:JSON.stringify(t,null,4)})]})}),hI={[Q.Select]:uI,[Q.MultiSelect]:lI,[Q.TreeSelect]:u3,[Q.TreeSingleSelect]:x3,[Q.TextInput]:dI,[Q.Checkbox]:sI,[Q.DateRange]:aI},rn={[Q.Select]:"filter.widget.names.select",[Q.MultiSelect]:"filter.widget.names.multi_select",[Q.TreeSelect]:"filter.widget.names.tree_select",[Q.TreeSingleSelect]:"filter.widget.names.tree_single_select",[Q.TextInput]:"filter.widget.names.text_input",[Q.Checkbox]:"filter.widget.names.checkbox",[Q.DateRange]:"filter.widget.names.date_range"},gI=k.observer(function({filter:t}){const{t:r,i18n:s}=_.useTranslation(),i=re(),o=f.useMemo(()=>hI[t.type],[t.type]),l=f.useMemo(()=>[{label:r(rn[Q.Select]),value:"select"},{label:r(rn[Q.MultiSelect]),value:"multi-select"},{label:r(rn[Q.TreeSelect]),value:"tree-select"},{label:r(rn[Q.TreeSingleSelect]),value:"tree-single-select"},{label:r(rn[Q.TextInput]),value:"text-input"},{label:r(rn[Q.Checkbox]),value:"checkbox"},{label:r(rn[Q.DateRange]),value:"date-range"}],[s.language]);return n.jsxs(a.Group,{grow:!0,gap:20,align:"top",children:[n.jsxs(a.Box,{sx:{maxWidth:"600px"},children:[n.jsx(a.Text,{pb:"md",c:"gray",size:"sm",children:r("common.titles.edit")}),n.jsxs(a.Stack,{children:[n.jsxs(a.Group,{wrap:"nowrap",children:[n.jsx(a.NumberInput,{label:r("filter.field.order"),required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&n.jsx(a.Checkbox,{label:r("filter.field.auto_submit"),checked:t.auto_submit,onChange:c=>t.setAutoSubmit(c.currentTarget.checked),mt:22})]}),n.jsx(a.MultiSelect,{label:r("filter.field.visible_in"),data:i.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),n.jsx(a.TextInput,{label:r("common.key"),placeholder:r("filter.field.key_placeholder"),required:!0,value:t.key,onChange:c=>{t.setKey(c.currentTarget.value)}}),n.jsx(a.TextInput,{label:r("common.label"),placeholder:r("filter.field.label_placeholder"),required:!0,value:t.label,onChange:c=>{t.setLabel(c.currentTarget.value)}}),n.jsx(a.Select,{label:r("filter.field.widget"),data:l,required:!0,value:t.type,onChange:t.setType,maxDropdownHeight:500}),n.jsx(a.Divider,{mb:0,mt:10,variant:"dashed",labelPosition:"center"}),n.jsx(o,{filter:t})]})]}),n.jsx(pI,{filter:t})]})}),fI=k.observer(({id:e})=>{const{t}=_.useTranslation(),r=dt.useModals(),s=se(),i=re();if(e==="")return null;const o=i.filters.findByID(e);if(!o)return n.jsxs(a.Text,{size:"14px",children:["Filter by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_FILTERS_",""])},c=()=>{r.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 n.jsxs(a.Stack,{sx:{maxWidth:"1100px",height:"100vh"},gap:"sm",pb:30,children:[n.jsx(a.Group,{justify:"flex-end",pt:10,children:n.jsx(a.Button,{size:"xs",color:"red",leftSection:n.jsx(C.IconTrash,{size:16}),onClick:c,children:t("filter.delete")})}),n.jsx(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n.jsx(gI,{filter:o})})]})}),xI=k.observer(()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState([]),s=se(),i=d=>{s.editor.setPath(["_FILTERS_",d])},o=()=>{s.content.filters.downloadSchema(t)},l=f.useMemo(()=>s.content.filters.sortedList.map(d=>d.id),[s.content.filters.sortedList]),c=()=>{r(l)},u=()=>{r([])};return n.jsxs(a.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(a.Text,{size:"sm",px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("filter.manage")})}),n.jsx(a.Flex,{justify:"space-between",align:"center",px:12,children:n.jsxs(a.Group,{justify:"flex-start",children:[n.jsxs(a.Button.Group,{children:[n.jsx(a.Button,{variant:"default",size:"xs",onClick:c,children:e("common.actions.select_all")}),n.jsx(a.Button,{variant:"default",size:"xs",onClick:u,children:e("common.actions.clear_selection")})]}),n.jsx(a.Button,{size:"xs",color:"blue",leftSection:n.jsx(C.IconCode,{size:14}),disabled:t.length===0,onClick:o,children:e("common.actions.download_schema")})]})}),n.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(a.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"40px"}}),n.jsx(a.Table.Th,{style:{width:"300px"},children:e("common.label")}),n.jsx(a.Table.Th,{children:e("common.key")}),n.jsx(a.Table.Th,{style:{width:"100px"},children:e("filter.field.widget")}),n.jsx(a.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(a.Table.Tbody,{children:s.content.filters.sortedList.map(d=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:n.jsx(a.Checkbox,{value:d.id,styles:{input:{cursor:"pointer"}}})}),n.jsx(a.Table.Td,{children:d.label}),n.jsx(a.Table.Td,{children:d.key}),n.jsx(a.Table.Td,{children:e(rn[d.type])}),n.jsx(a.Table.Td,{children:n.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>i(d.id),children:e("common.actions.open")})})]},d.id))})]})})})]})}),mI=k.observer(()=>{const{t:e}=_.useTranslation(),t=re(),[r,s]=f.useState(()=>JSON.stringify(t.mock_context.current,null,4)),i=()=>{try{t.mock_context.replace(JSON.parse(r))}catch(l){Nt.showNotification({title:"Failed",message:l.message,color:"red"})}},o=f.useMemo(()=>{try{return JSON.stringify(JSON.parse(r))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[r,t.mock_context.current]);return n.jsxs(a.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[n.jsx(a.Group,{justify:"flex-start",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:n.jsx(a.Text,{size:"sm",fw:500,children:e("mock_context.label")})}),n.jsx(a.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:n.jsxs(a.Stack,{gap:10,sx:{maxWidth:"unset !important"},children:[n.jsxs(a.Group,{justify:"flex-start",children:[n.jsx(a.Text,{size:"sm",children:e("mock_context.hint")}),n.jsx(a.Button,{color:"green",size:"compact-sm",leftSection:n.jsx(C.IconDeviceFloppy,{size:16}),onClick:i,disabled:!o,children:e("common.actions.save")})]}),n.jsx(a.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:r,onChange:s,sx:{flexGrow:1}})]})})]})}),bI=k.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Le();return n.jsx(bn,{label:e("panel.panel_description"),value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}},t.id)}),yI=k.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Le(),r=Te().layouts.findItemByPanelID(t.id),{style:s}=t;return n.jsx(n.Fragment,{children:n.jsxs(a.Stack,{gap:20,children:[n.jsxs(a.Group,{grow:!0,align:"top",children:[n.jsx(a.NumberInput,{label:e("panel.style.width"),min:1,max:36,step:1,decimalScale:0,rightSection:n.jsx(a.Text,{size:"12px",children:e("panel.style.width_postfix")}),styles:{section:{width:"auto",maxWidth:"100px",paddingRight:"14px",justifyContent:"flex-end"}},value:r.w,onChange:i=>{typeof i!="string"&&r.setWidth(i)}}),n.jsx(a.NumberInput,{label:e("panel.style.height"),rightSection:n.jsx(a.Text,{size:"12px",children:e("panel.style.height_postfix")}),styles:{section:{width:"40px"}},value:r.h,onChange:i=>{typeof i!="string"&&r.setHeight(i)}})]}),n.jsx(a.Checkbox,{ml:6,label:e("panel.style.border"),checked:s.border.enabled,onChange:i=>s.border.setEnabled(i.currentTarget.checked)})]})})}),vI=()=>n.jsxs("span",{className:"mantine-103svbs mantine-InputWrapper-required mantine-Select-required","aria-hidden":"true",children:[" ","*"]}),_I=k.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Le(),{name:r}=t,[s,i]=ze.useInputState(r),o=r!==s,l=f.useCallback(()=>{o&&t.setName(s)},[o,s]);f.useEffect(()=>{i(r)},[r]);const c=!s.trim();return n.jsxs(a.Stack,{gap:4,children:[n.jsxs(a.Group,{align:"center",children:[n.jsxs(a.Text,{size:"14px",fw:500,children:[e("panel.panel_name"),n.jsx(vI,{})]}),n.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:!o||c,onClick:l,children:n.jsx(C.IconDeviceFloppy,{size:18})})]}),n.jsx(a.TextInput,{value:s,onChange:i,required:!0})]})}),jI=k.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Le();return n.jsx(a.Stack,{gap:6,mb:10,children:n.jsxs(a.Group,{pl:6,justify:"flex-start",gap:20,children:[n.jsx(a.Checkbox,{size:"sm",checked:t.title.show,onChange:r=>t.title.setShow(r.currentTarget.checked),label:e("panel.show_title"),sx:{userSelect:"none"}}),n.jsx(a.Checkbox,{size:"sm",checked:!0,disabled:!0,label:e("panel.use_name_as_title")})]})})});function wI(){const{t:e}=_.useTranslation();return n.jsxs(a.Stack,{sx:{height:"100%"},children:[n.jsx(yI,{}),n.jsx(a.Divider,{label:e("common.info"),labelPosition:"center",variant:"dashed"}),n.jsx(_I,{}),n.jsx(jI,{}),n.jsx(bI,{})]})}const CI={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 jg({data:e}){const t=f.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const s=Re.createColumnHelper();return Object.keys(e[0]).map(i=>s.accessor(i,{cell:o=>o.getValue()}))},[e]),r=Re.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Re.getCoreRowModel()});return e.length===0?n.jsx(a.Box,{sx:{height:"5em"}}):n.jsx(Ie,{children:n.jsxs(a.Table,{sx:CI,children:[n.jsx(a.Table.Thead,{children:r.getHeaderGroups().map(s=>n.jsx(a.Table.Tr,{children:s.headers.map(i=>n.jsxs(a.Table.Th,{style:{width:i.getSize()},children:[i.isPlaceholder?null:Re.flexRender(i.column.columnDef.header,i.getContext()),n.jsx(a.ActionIcon,{variant:"subtle",onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:n.jsx(C.IconArrowBarToRight,{})})]},i.id))},s.id))}),n.jsx(a.Table.Tbody,{children:r.getRowModel().rows.map(s=>n.jsx(a.Table.Tr,{children:s.getVisibleCells().map(i=>n.jsx(a.Table.Td,{children:n.jsx(Ie,{children:typeof i.getValue()=="object"?n.jsx("pre",{children:JSON.stringify(i.getValue(),null,2)}):Re.flexRender(i.column.columnDef.cell,i.getContext())})},i.id))},s.id))})]})})}const SI=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],TI={icon:{width:"80px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"80px"}}},kI=({data:e,page:t,setPage:r,limit:s,setLimit:i})=>{const{t:o}=_.useTranslation(),l=e.length,c=Math.ceil(l/s),u=p=>{p&&(r(1),i(Number(p)))};if(l===0)return null;const d=c===1&&l<=10;return n.jsxs(a.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(a.Group,{justify:"flex-start",children:[c>1&&n.jsx(a.Pagination,{size:"sm",value:t,onChange:r,total:c,withEdges:c>7,styles:{control:{height:"30px"}}}),!d&&n.jsx(a.Select,{leftSection:n.jsx(a.Text,{ta:"center",c:"dimmed",size:"14px",children:o("common.pagination.page_size")}),size:"xs",styles:TI,data:SI,value:String(s),onChange:u})]}),n.jsx(a.Group,{justify:"flex-end",children:n.jsx(a.Text,{c:"dimmed",my:0,size:"14px",children:o("common.pagination.total_rows",{total:l})})})]})},DI=xd(({data:e,loading:t})=>{const[r,s]=f.useState(1),[i,o]=f.useState(20),l=f.useMemo(()=>{const c=(r-1)*i,u=c+i;return e.slice(c,u)},[e,r,i]);return n.jsxs(Ie,{children:[n.jsx(kI,{data:e,page:r,setPage:s,limit:i,setLimit:o}),n.jsxs(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(a.LoadingOverlay,{visible:t,overlayProps:{blur:2}}),n.jsx(jg,{data:l})]})]})}),zI=k.observer(({queryID:e})=>{const t=Te(),r=f.useMemo(()=>t.queries.findByID(e),[t,e]);if(!r||r.state==="loading")return null;const{error:s,metricQueryPayloadErrorString:i,stateMessage:o}=r;return s||i?n.jsx(a.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:s??i}):o?n.jsx(a.Text,{size:"sm",mt:10,c:"gray",ta:"center",children:o}):null}),Wo=k.observer(({id:e,moreActions:t,refreshOnMount:r})=>{const{t:s}=_.useTranslation(),i=Te(),{data:o,state:l}=i.getDataStuffByID(e),c=l==="loading",u=f.useCallback(()=>{i.queries.refetchDataByQueryID(e)},[e,i]),d=()=>{i.queries.downloadDataByQueryID(e)};f.useEffect(()=>{r&&u()},[u,r]);const p=!Array.isArray(o)||o.length===0;return n.jsxs(a.Stack,{gap:0,sx:{height:"100%",border:"1px solid #eee"},children:[n.jsxs(a.Group,{justify:"space-between",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n.jsx(a.Group,{justify:"flex-start",children:n.jsx(a.Text,{size:"sm",fw:500,children:s("data.preview_data")})}),n.jsxs(a.Group,{pr:15,children:[t,n.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:c,onClick:u,children:n.jsx(C.IconRefresh,{size:16})}),n.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:c||p,onClick:d,children:n.jsx(C.IconDownload,{size:16})})]})]}),n.jsxs(a.Box,{pb:20,sx:{position:"relative",flexGrow:1,overflow:"auto"},children:[n.jsx(zI,{queryID:e}),n.jsx(DI,{data:o,loading:c})]})]})}),II=k.observer(function(){const{t}=_.useTranslation(),r=se(),s=re(),{panel:i}=Le(),[o,l]=f.useState(!1),c=d=>{r.editor.setPath(["_QUERIES_",d])},u=i.queryIDs.length;return n.jsxs(n.Fragment,{children:[n.jsx(a.Drawer,{opened:o,onClose:()=>l(!1),title:t("panel.settings.choose_queries"),padding:"xl",size:500,zIndex:320,children:n.jsx(a.Checkbox.Group,{value:[...i.queryIDs],onChange:i.setQueryIDs,children:n.jsx(a.Stack,{gap:"lg",children:s.queries.options.map(d=>n.jsx(a.Checkbox,{label:d.label,value:d.value},d.value))})})}),n.jsxs(a.Stack,{gap:6,children:[n.jsx(a.Group,{justify:"flex-start",children:n.jsx(a.Button,{variant:"light",size:"sm",leftSection:n.jsx(C.IconLine,{size:16}),onClick:()=>l(!0),children:t(u===0?"panel.settings.need_to_choose_queries":"panel.settings.choose_queries")})}),u===1&&n.jsx(Wo,{id:i.queryIDs[0],moreActions:n.jsx(a.Tooltip,{label:t("query.open"),children:n.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(i.queryIDs[0]),children:n.jsx(C.IconArrowCurveRight,{size:16})})})}),u>1&&n.jsxs(a.Tabs,{defaultValue:i.queryIDs[0],children:[n.jsx(a.Tabs.List,{children:i.queries.map(d=>n.jsx(a.Tabs.Tab,{value:d.id,children:d.name},d.id))}),i.queries.map(d=>n.jsx(a.Tabs.Panel,{value:d.id,children:n.jsx(Wo,{id:d.id,moreActions:n.jsx(a.Tooltip,{label:t("query.open"),children:n.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(d.id),children:n.jsx(C.IconArrowCurveRight,{size:16})})})})},d.id))]})]})]})}),MI=k.observer(()=>{const{panel:e}=He();return e.title.show?n.jsx(a.Group,{grow:!0,justify:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:n.jsx(a.Text,{size:"sm",ta:"center",lineClamp:1,className:"panel-title-text",children:e.title.show?e.name:""})}):null}),EI=k.observer(()=>{const{panel:e}=He();return n.jsx(Ie,{children:n.jsxs(a.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,p:0,sx:{border:"1px solid",borderColor:e.style.border.enabled?"#e9ecef":"transparent",flexGrow:0,flexShrink:0,width:"600px !important",height:"450px !important"},children:[n.jsx(a.Box,{className:"panel-description-popover-wrapper",children:n.jsx(Oo,{})}),n.jsx(MI,{}),n.jsx(Vo,{panel:e})]})})});function PI(){const{t:e}=_.useTranslation(),{vizManager:t}=f.useContext(tn);return f.useMemo(()=>v.orderBy(Object.entries(v.groupBy(t.availableVizList,"displayGroup")),[i=>i[0]],["asc"]).map(([i,o])=>{const l=o.map(c=>({value:c.name,label:e(c.displayName??it.name)}));return{group:e(i??"ungrouped"),items:v.orderBy(l,[c=>c.label],["asc"])}}),[t])}const AI=k.observer(({value:e,submit:t})=>{const{t:r}=_.useTranslation(),[s,i]=ze.useInputState(e);f.useEffect(()=>{i(e)},[e]);const o=PI(),l=e!==s;return n.jsx(a.Select,{label:r("visualization.component"),value:s,searchable:!0,onChange:i,data:o,rightSection:n.jsx(a.ActionIcon,{variant:"filled",color:"green",disabled:!l,onClick:()=>t(s),styles:{root:{pointerEvents:"all"}},children:n.jsx(C.IconDeviceFloppy,{size:20})}),maxDropdownHeight:600})}),wg=[];function LI(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function OI(){const{data:e,panel:{variables:t,viz:r,title:s,name:i,queryIDs:o,description:l,id:c}}=Le(),{vizManager:u}=f.useContext(tn),d={name:i,title:s,description:l,viz:r,queryIDs:o,id:c},p=Ph(d);try{return u.resolveComponent(d.viz.type),n.jsx(Ms,{configure:p,children:n.jsx(J3,{variables:t,setVizConf:r.setConf,panel:d,vizManager:u,data:e})})}catch(h){return console.info(v.get(h,"message")),null}}const VI=k.observer(()=>{const{data:e,panel:{viz:t}}=Le(),{vizManager:r}=f.useContext(tn),s=f.useCallback(d=>{if(d===t.type)return;const p=LI(r,d);t.setType(d),t.setConf(p||{})},[t.type]),i=d=>{try{t.setConf(JSON.parse(d))}catch(p){console.error(p)}},o=f.useMemo(()=>{var d;return(d=wg.find(p=>p.value===t.type))==null?void 0:d.Panel},[t.type,wg]),l=OI(),c=o?f.createElement(o,{data:e,conf:t.conf,setConf:t.setConf}):null,u=l||c;return n.jsxs(a.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[n.jsx(AI,{submit:s,value:t.type}),n.jsxs(Ie,{children:[n.jsx(a.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:u}),!u&&n.jsx(a.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:i})]})]})}),BI=k.observer(({panel:e,sourceViewID:t})=>{const{t:r}=_.useTranslation(),s=re(),[i,o]=f.useState(t);f.useEffect(()=>{o(t)},[t]);const[l,{open:c,close:u}]=ze.useDisclosure(!1),d=()=>{e.moveToView(t,i),u()};return n.jsxs(n.Fragment,{children:[n.jsx(a.Button,{size:"xs",variant:"subtle",color:"blue",onClick:c,leftSection:n.jsx(C.IconBoxMultiple,{size:14}),children:r("panel.settings.change_view")}),n.jsx(a.Modal,{opened:l,onClose:u,title:r("panel.settings.change_view_title"),zIndex:320,children:n.jsxs(a.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[n.jsx(a.Radio.Group,{value:i,onChange:o,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:n.jsx(a.Stack,{gap:"xs",children:s.views.options.map(p=>n.jsx(a.Radio,{value:p.value,label:p.label},p.value))})}),n.jsxs(a.Group,{wrap:"nowrap",justify:"space-between",sx:{flexGrow:0,flexShrink:0},children:[n.jsx(a.Button,{size:"xs",color:"red",leftSection:n.jsx(C.IconX,{size:14}),onClick:u,children:r("common.actions.cancel")}),n.jsx(a.Button,{size:"xs",color:"blue",leftSection:n.jsx(C.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:r("common.actions.confirm")})]})]})})]})}),qI=k.observer(({sx:e={}})=>{const{t}=_.useTranslation(),r=Te(),{panel:s}=He(),i=r.dashboardState,o=(()=>{const l={...i,...s.variableStrings};return JSON.stringify(l,null,2)})();return n.jsx(a.Stack,{sx:{overflow:"hidden",...e},children:n.jsxs(a.Tabs,{defaultValue:"vars",keepMounted:!1,children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"guide",leftSection:n.jsx(C.IconAlertCircle,{size:14}),children:t("panel.variable.guide.tabs.guide")}),n.jsx(a.Tabs.Tab,{value:"vars",leftSection:n.jsx(C.IconVariable,{size:14}),children:t("panel.variable.guide.tabs.vars")})]}),n.jsx(a.Tabs.Panel,{value:"guide",pt:"xs",children:n.jsx(Dt.CodeHighlight,{language:"sql",sx:{width:"100%"},withCopyButton:!1,code:t("panel.variable.guide.text")})}),n.jsx(a.Tabs.Panel,{value:"vars",pt:"xs",children:n.jsx(Dt.CodeHighlight,{language:"json",sx:{width:"100%"},withCopyButton:!1,code:o})})]})})}),Uo={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 NI{constructor(t){N(this,"panel");N(this,"selected");this.panel=t,t.variables.length>0&&(this.selected=t.variables[0]),te.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(r=>r.name.startsWith(Uo.name)).length;this.panel.addVariable(v.cloneDeep({...Uo,name:`${Uo.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 r=this.variables.find(s=>s.name===t);if(!r){console.error(`Variable by name[${t}] not found`);return}this.selected=r}remove(t){this.selected===t&&(this.selected=void 0);const r=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,r);this.selected=this.panel.variables[s]}}}function $I(){const{panel:e}=Le();return Y.useCreation(()=>new NI(e),[e])}const GI=f.forwardRef(function({value:t,onChange:r,remove:s},i){const{t:o}=_.useTranslation(),l=(c,u)=>{const d=v.cloneDeep(t);v.set(d,c,u),r(d)};return n.jsxs(a.Stack,{ref:i,children:[n.jsxs(a.Stack,{gap:"xs",px:"sm",py:"md",sx:{border:"1px solid #e9ecef"},children:[n.jsxs(a.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(a.TextInput,{label:o("common.name"),required:!0,value:t.name,onChange:c=>l("name",c.currentTarget.value)}),n.jsx(W,{label:o("common.data_field"),required:!0,value:t.data_field,onChange:c=>l("data_field",c)})]}),n.jsx(Oa,{label:o("panel.variable.aggregation.label"),pt:0,value:t.aggregation,onChange:c=>l("aggregation",c),withFallback:!0}),t.aggregation.type!=="custom"&&n.jsxs(n.Fragment,{children:[n.jsx(a.Divider,{mt:"xl",mb:0,label:o("numbro.format.label"),labelPosition:"center",variant:"dashed"}),n.jsx(St,{value:t.formatter,onChange:c=>l("formatter",c)})]})]}),n.jsx(a.Button,{mt:20,leftSection:n.jsx(C.IconTrash,{size:16}),color:"red",variant:"light",onClick:s,children:o("panel.variable.delete")})]})}),FI=k.observer(e=>{const{t}=_.useTranslation(),r=Y.useCreation(()=>kh(e.variable),[e.variable]),s=()=>e.uiModel.remove(e.variable);return n.jsxs(a.Stack,{"data-testid":"variable-editor",align:"stretch",children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Button,{variant:"subtle",size:"xs",disabled:!r.changed,color:"red",onClick:r.reset,leftSection:n.jsx(C.IconRecycle,{size:18}),children:t("common.actions.revert_changes")}),n.jsx(a.Button,{variant:"filled",size:"xs",disabled:!r.changed,color:"green",onClick:r.commit,leftSection:n.jsx(C.IconDeviceFloppy,{size:18}),children:t("common.actions.save_changes")})]}),n.jsx(GI,{value:g.getSnapshot(r.copy),onChange:r.update,remove:s})]})});k.observer(e=>{const{uiModel:t}=e;return n.jsx(a.Stack,{className:"var-list",children:t.variables.map(r=>n.jsx(a.Button,{variant:t.selected===r?"filled":"subtle",color:"gray",onClick:()=>t.select(r),children:r.name},r.name))})});const QI=k.observer(({model:e})=>{const{t}=_.useTranslation();return n.jsx(a.Overlay,{color:"#fff",backgroundOpacity:1,sx:{position:"absolute"},children:n.jsx(a.Button,{variant:"light",size:"xs",leftSection:n.jsx(C.IconPlus,{size:16}),onClick:e.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:t("panel.variable.add")})})}),RI=k.observer(()=>{var r;const{t:e}=_.useTranslation(),t=$I();return t.variableOptions.length===0?n.jsx(QI,{model:t}):n.jsxs(a.Stack,{pb:20,children:[n.jsxs(a.Group,{justify:"flex-start",children:[n.jsx(a.Select,{label:e("panel.variable.labels"),data:t.variableOptions,value:(r=t.selected)==null?void 0:r.name,onChange:t.selectByName,maxDropdownHeight:600,sx:{flexGrow:1}}),n.jsx(a.Button,{variant:"light",size:"xs",leftSection:n.jsx(C.IconPlus,{size:16}),onClick:t.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:e("panel.variable.add")})]}),n.jsx(a.Divider,{variant:"dashed"}),t.selected?n.jsx(FI,{uiModel:t,variable:t.selected}):n.jsx("span",{children:"Select or create a new variable on right side"})]})}),WI={root:{flexGrow:1,width:"100%",minWidth:"1200px",overflow:"hidden"},panel:{width:"100%",minWidth:"1200px",height:"calc(100% - 44px)",padding:10,overflow:"auto"}},Yo=({children:e})=>n.jsxs(a.Group,{wrap:"nowrap",grow:!0,justify:"flex-start",gap:20,sx:{width:"100%",height:"100%",position:"relative"},children:[n.jsx(a.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),n.jsxs(a.Stack,{justify:"flex-start",sx:{alignSelf:"flex-start",width:"600px",flexGrow:0,flexShrink:0},children:[n.jsx(EI,{}),n.jsx(a.Box,{sx:{flexGrow:1},children:n.jsx(qI,{})})]})]});function UI(e){return!["richText","button"].includes(e)}const YI=k.observer(({panel:e})=>{const{t}=_.useTranslation(),r=dt.useModals(),s=se(),i=re(),[o,l]=f.useState(s.editor.panelTab),c=e.queries,d=UI(e.viz.type)&&e.dataLoading,p=d||e.queryErrors.length>0||e.queryStateMessages!==""||c.length===0,h=s.editor.path[1];f.useEffect(()=>{l(j=>p&&j==="Visualization"?"Data":j)},[e.id,p]);const x=f.useCallback(j=>{l(j),s.editor.setPanelTab(o)},[]),b=()=>{s.editor.setPath(["_VIEWS_",h])},m=()=>r.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),b()},confirmProps:{color:"red"},zIndex:320});return n.jsxs(ii,{value:{panel:e,data:e.data,loading:d,errors:e.queryErrors,downloadPanelScreenshot:()=>{}},children:[n.jsxs(a.Group,{px:16,justify:"space-between",sx:{borderBottom:"1px solid #eee"},children:[n.jsx(a.Text,{size:"sm",pt:9,pb:8,children:e.name}),n.jsxs(a.Group,{justify:"flex-end",wrap:"nowrap",children:[n.jsx(BI,{panel:e,sourceViewID:h}),n.jsx(a.Button,{size:"xs",variant:"subtle",color:"red",onClick:m,leftSection:n.jsx(C.IconTrash,{size:14}),children:t("panel.delete")})]})]}),n.jsxs(a.Tabs,{value:o,onChange:x,keepMounted:!1,styles:WI,children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"Data",leftSection:n.jsx(C.IconDatabase,{size:14}),disabled:d,children:t("data.label")}),n.jsx(a.Tabs.Tab,{value:"Panel",leftSection:n.jsx(C.IconAppWindow,{size:14}),children:t("panel.label")}),n.jsx(a.Tabs.Tab,{value:"Variables",leftSection:n.jsx(C.IconVariable,{size:14}),disabled:p,children:n.jsx(a.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:n.jsx(a.Text,{size:"sm",children:t("panel.variable.labels")})})}),n.jsx(a.Tabs.Tab,{value:"Visualization",leftSection:n.jsx(C.IconChartHistogram,{size:14}),disabled:p,children:n.jsx(a.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:n.jsx(a.Text,{size:"sm",children:t("visualization.label")})})}),n.jsx(a.Tabs.Tab,{value:"Interactions",leftSection:n.jsx(C.IconRoute,{size:14}),children:t("interactions.label")})]}),n.jsxs(a.Tabs.Panel,{value:"Data",children:[n.jsx(a.LoadingOverlay,{visible:d,transitionProps:{exitDuration:0}}),n.jsx(II,{})]}),n.jsx(a.Tabs.Panel,{value:"Panel",children:n.jsx(Yo,{children:n.jsx(wI,{})})}),n.jsx(a.Tabs.Panel,{value:"Variables",children:n.jsx(Yo,{children:n.jsx(RI,{})})}),n.jsx(a.Tabs.Panel,{value:"Visualization",children:n.jsx(Ie,{children:n.jsx(Yo,{children:n.jsx(VI,{})})})}),n.jsx(a.Tabs.Panel,{value:"Interactions",children:n.jsx(Ie,{children:n.jsx(Iv,{})})})]})]})}),KI=k.observer(({viewID:e,panelID:t})=>{const r=re();if(!r.views.findByID(e))return n.jsxs(a.Text,{size:"14px",children:["View by ID[",e,"] is not found"]});const i=r.panels.findByID(t);return i?n.jsx(YI,{panel:i}):n.jsxs(a.Text,{size:"14px",children:["Panel by ID[",t,"] is not found"]})}),XI=k.observer(()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState([]),s=dt.useModals(),i=se(),o=x=>{i.editor.setPath(["_QUERIES_",x])},l=()=>{s.openConfirmModal({title:"Delete ununsed queries?",children:n.jsx(a.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=f.useMemo(()=>i.content.queries.sortedList.map(x=>x.id),[i.content.queries.sortedList]),d=()=>{r(u)},p=()=>{r([])},h=i.content.queriesUsage;return n.jsxs(a.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(a.Text,{px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("query.manage")})}),n.jsxs(a.Flex,{justify:"space-between",align:"center",px:12,children:[n.jsxs(a.Group,{justify:"flex-start",children:[n.jsxs(a.Button.Group,{children:[n.jsx(a.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),n.jsx(a.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),n.jsx(a.Button,{size:"xs",color:"blue",leftSection:n.jsx(C.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),n.jsx(a.Button,{variant:"subtle",size:"xs",color:"red",leftSection:n.jsx(C.IconTrash,{size:14}),disabled:!i.content.hasUnusedQueries,onClick:l,children:e("query.delete_unused")})]}),n.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(a.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"40px"}}),n.jsx(a.Table.Th,{children:e("common.name")}),n.jsx(a.Table.Th,{style:{width:"200px"},children:e("data_source.label")}),n.jsx(a.Table.Th,{style:{width:"100px",textAlign:"right"},children:e("common.type")}),n.jsx(a.Table.Th,{style:{width:"100px",textAlign:"center"},children:e("query.usage.label")}),n.jsx(a.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(a.Table.Tbody,{children:i.content.queries.sortedList.map(x=>{var m;const b=((m=h[x.id])==null?void 0:m.length)??0;return n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:n.jsx(a.Checkbox,{value:x.id,styles:{input:{cursor:"pointer"}}})}),n.jsx(a.Table.Td,{children:x.name}),n.jsx(a.Table.Td,{children:x.key}),n.jsx(a.Table.Td,{style:{textAlign:"right"},children:x.type}),n.jsx(a.Table.Td,{style:{color:b===0?"#ff0000":"#000",fontWeight:b===0?"bold":"normal",textAlign:"center"},children:b}),n.jsx(a.Table.Td,{children:n.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>o(x.id),children:e("common.actions.open")})})]},x.id)})})]})})})]})}),HI=e=>{const{t}=_.useTranslation(),{queryModel:r}=e,s=se(),i=re(),l=i.findQueryUsage(r.id).length>0,c=dt.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(r.id),s.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return l?n.jsx(a.Tooltip,{label:t("query.cant_delete"),withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"top-end",children:n.jsx(a.Box,{sx:{alignSelf:"flex-end"},children:n.jsx(a.Button,{disabled:!0,size:"xs",leftSection:n.jsx(C.IconTrash,{size:16}),children:t("query.delete")})})}):n.jsx(a.Button,{color:"red",size:"xs",onClick:u,leftSection:n.jsx(C.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:t("query.delete")})},ZI=k.observer(HI),Cg=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:r,count:s,spacing:i=16,pl:o=0})=>n.jsxs(a.Stack,{gap:i,mt:6,pl:o,children:[Array.from(new Array(s-1),(l,c)=>n.jsx(a.Skeleton,{width:e,height:r,radius:"xs"},c)),n.jsx(a.Skeleton,{width:t,height:r,radius:"xs"})]}),Mr=({value:e})=>e===null||e===""?null:n.jsx(a.Tooltip,{label:e,disabled:!e,multiline:!0,zIndex:340,children:n.jsx(a.ActionIcon,{variant:"subtle",children:n.jsx(C.IconInfoCircle,{size:14})})}),JI=({column:e})=>{const{column_key:t,column_key_text:r}=e;return t?n.jsx(a.Tooltip,{label:r,disabled:!r,children:n.jsx(a.Badge,{variant:"light",children:t})}):null},eM=k.observer(({dataSource:e})=>{const{columns:t}=e.dbInfo;return t.loading?n.jsx(Cg,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:n.jsxs(a.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:50}}),n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{width:30}}),n.jsx("col",{style:{width:70}}),n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{minWidth:80,width:80}}),n.jsx("col",{style:{minWidth:120,width:120}})]}),n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:"#"}),n.jsx(a.Table.Th,{children:"Column Name"}),n.jsx(a.Table.Th,{}),n.jsx(a.Table.Th,{}),n.jsx(a.Table.Th,{children:"Type"}),n.jsx(a.Table.Th,{children:"Nullable"}),n.jsx(a.Table.Th,{children:"Default Value"})]})}),n.jsx(a.Table.Tbody,{children:t.data.map(r=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:r.ordinal_position}),n.jsx(a.Table.Td,{children:r.column_name}),n.jsx(a.Table.Td,{children:n.jsx(Mr,{value:r.column_comment})}),n.jsx(a.Table.Td,{children:n.jsx(JI,{column:r})}),n.jsx(a.Table.Td,{children:r.column_type}),n.jsx(a.Table.Td,{children:r.is_nullable}),n.jsx(a.Table.Td,{children:n.jsx(Mr,{value:r.column_default})})]},r.column_name))})]})}),tM=k.observer(({dataSource:e})=>{const{indexes:t}=e.dbInfo,r=t.data;return n.jsxs(a.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{width:150}}),n.jsx("col",{style:{width:150}}),n.jsx("col",{style:{width:250}})]}),n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:"Index Length"}),n.jsx(a.Table.Th,{children:"Index Name"}),n.jsx(a.Table.Th,{children:"Index Algorithm"}),n.jsx(a.Table.Th,{children:"Unique"}),n.jsx(a.Table.Th,{children:"Column Name"})]})}),n.jsx(a.Table.Tbody,{children:r.map(s=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:s.index_length}),n.jsx(a.Table.Td,{children:s.index_name}),n.jsx(a.Table.Td,{children:s.index_algorithm}),n.jsx(a.Table.Td,{children:s.is_unique?"YES":"NO"}),n.jsx(a.Table.Td,{children:s.column_name})]},s.index_name))})]})}),nM=k.observer(({dataSource:e})=>{const{indexes:t}=e.dbInfo,r=t.data;return n.jsxs(a.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{width:150}}),n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{width:100}})]}),n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:"Index Name"}),n.jsx(a.Table.Th,{children:"Index Algorithm"}),n.jsx(a.Table.Th,{children:"Unique"}),n.jsx(a.Table.Th,{children:"Definition"}),n.jsx(a.Table.Th,{children:"Condition"}),n.jsx(a.Table.Th,{children:"Comment"})]})}),n.jsx(a.Table.Tbody,{children:r.map(s=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:s.index_name}),n.jsx(a.Table.Td,{children:s.index_algorithm}),n.jsx(a.Table.Td,{children:s.is_unique?"YES":"NO"}),n.jsx(a.Table.Td,{children:n.jsx(Mr,{value:s.index_definition})}),n.jsx(a.Table.Td,{children:n.jsx(Mr,{value:s.condition})}),n.jsx(a.Table.Td,{children:n.jsx(Mr,{value:s.comment})})]},s.index_name))})]})}),rM=k.observer(({dataSource:e})=>{const{indexes:t}=e.dbInfo;return t.loading||t.empty?null:e.type===J.MySQL?n.jsx(tM,{dataSource:e}):e.type===J.Postgresql?n.jsx(nM,{dataSource:e}):null}),sM=k.observer(({dataSource:e})=>n.jsxs(a.Stack,{gap:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[n.jsx(Ie,{children:n.jsx(eM,{dataSource:e})}),n.jsx(Ie,{children:n.jsx(rM,{dataSource:e})})]}));function iM({table_type:e}){return e==="VIEW"?n.jsx(C.IconEye,{size:14}):e==="BASE TABLE"?n.jsx(C.IconTable,{size:14}):null}const aM=k.observer(({dataSource:e})=>{const t=e.dbInfo,{tables:r}=t;return r.loading?n.jsx(Cg,{height:"24px",lastWidth:"50%",count:15}):n.jsx(a.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(r.data).map(([s,i])=>n.jsx(a.NavLink,{label:s,title:s,leftSection:n.jsx(C.IconDatabase,{size:14}),defaultOpened:t.table_schema===s,pl:0,childrenOffset:14,children:i.map(o=>n.jsx(a.NavLink,{label:o.table_name,title:o.table_name,leftSection:n.jsx(iM,{table_type:o.table_type}),onClick:()=>{t.setKeywords(s,o.table_name)},active:t.table_name===o.table_name},o.table_name))},s))})}),oM=({visible:e})=>n.jsx(a.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:n.jsx(a.LoadingOverlay,{visible:e})}),lM=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],cM={section:{width:"50px",textAlign:"center"},input:{paddingLeft:"50px"}},uM=k.observer(({dataSource:e})=>{const{t}=_.useTranslation(),{tableData:r}=e.dbInfo;return n.jsxs(a.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(a.Group,{justify:"flex-start",children:[r.maxPage>1&&n.jsx(a.Pagination,{size:"sm",value:r.page,onChange:r.setPage,total:r.maxPage,withEdges:r.maxPage>7,styles:{control:{height:"30px"}}}),n.jsx(a.Select,{leftSection:n.jsx(a.Text,{ta:"center",c:"dimmed",size:"14px",children:t("common.pagination.page_size")}),size:"xs",styles:cM,data:lM,value:String(r.limit),onChange:s=>r.setLimit(Number(s)),comboboxProps:{zIndex:340}})]}),n.jsx(a.Group,{justify:"flex-end",children:n.jsx(a.Text,{c:"dimmed",my:0,size:"14px",children:t("common.pagination.total_rows",{total:r.total})})})]})}),dM=k.observer(({dataSource:e})=>{const t=e.dbInfo.tableData;return t.maxPage===0?n.jsx(a.Text,{mt:20,c:"red",size:"md",ta:"center",ff:"monospace",children:"This table is empty"}):t.error?n.jsx(a.Text,{mt:20,c:"red",size:"md",ta:"center",ff:"monospace",children:t.error}):t.page===1&&t.loading?n.jsx(oM,{visible:!0}):n.jsxs(Ie,{children:[n.jsx(uM,{dataSource:e}),n.jsxs(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(a.LoadingOverlay,{visible:t.loading,overlayProps:{blur:2}}),n.jsx(jg,{data:t.data})]})]})}),pM={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},hM=k.observer(({dataSource:e})=>{const{t}=_.useTranslation(),r=e.dbInfo;return f.useEffect(()=>{r.loadTablesIfEmpty()},[r]),r.tables.error?n.jsx(a.Text,{c:"red",size:"md",ta:"center",ff:"monospace",children:r.tables.error}):n.jsxs(a.Flex,{sx:{height:"100%"},children:[n.jsx(a.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:n.jsx(Ie,{children:n.jsx(aM,{dataSource:e})})}),n.jsxs(a.Tabs,{defaultValue:"structure",styles:pM,children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"structure",leftSection:n.jsx(C.IconColumns,{size:14}),children:t("data_source.table_structure_short")}),n.jsx(a.Tabs.Tab,{value:"data",leftSection:n.jsx(C.IconDatabase,{size:14}),children:t("data.label")})]}),n.jsx(a.Tabs.Panel,{value:"structure",children:n.jsx(sM,{dataSource:e})}),n.jsx(a.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:n.jsx(dM,{dataSource:e})})]})]})}),gM={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"}},Sg=k.observer(({dataSource:e,triggerButtonProps:t={}})=>{const{t:r}=_.useTranslation(),[s,i]=f.useState(!1),{type:o}=e;return o==="http"||o==="merico_metric_system"?null:n.jsxs(n.Fragment,{children:[n.jsx(a.Modal,{opened:s,onClose:()=>i(!1),title:n.jsxs(a.Group,{justify:"space-between",sx:{flexGrow:1},children:[n.jsx(a.Text,{size:"sm",fw:500,children:r("data_source.explorer")}),n.jsxs(a.Group,{gap:7,children:[n.jsx(a.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),n.jsx(a.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",styles:gM,children:n.jsx(a.Box,{sx:{height:"calc(100vh - 220px)"},children:n.jsx(hM,{dataSource:e})})}),n.jsx(a.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:r("data_source.see_table_structure")})]})}),Tg={http:"HTTP",mysql:"MySQL",postgresql:"PostgreSQL",merico_metric_system:"指标系统"},fM=({option:e,...t})=>{const{label:r,type:s}=e;return s===J.Transform?n.jsxs(a.Group,{className:"transform-query-option",justify:"flex-start",...t,sx:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}},children:[n.jsx(C.IconVectorTriangle,{size:14,color:"#228be6"}),n.jsx(a.Text,{size:"sm",c:"blue",children:r})]}):n.jsxs(a.Group,{justify:"space-between",...t,sx:{flexGrow:1},children:[n.jsx(a.Text,{size:"sm",children:r}),n.jsx(a.Text,{size:"sm",children:Tg[s]})]})},kg=k.observer(({queryModel:e,size:t="sm"})=>{const{t:r}=_.useTranslation(),s=se(),{data:i=[],loading:o}=Y.useRequest(ba,{refreshDeps:[]},[]),l=f.useMemo(()=>{const p=i.map(h=>({label:h.key,value:h.key,type:h.type}));return p.push({label:r("query.transform.data_source"),value:J.Transform,type:J.Transform}),p},[i]),c=f.useMemo(()=>l.reduce((p,h)=>(p[h.value]=h.type,p),{}),[l]),u=p=>{p!==null&&(e.setKey(p),e.setType(c[p]))},d=f.useMemo(()=>s.datasources.find({type:e.type,key:e.key}),[s,e.type,e.key]);return n.jsx(a.Select,{size:t,data:l,label:n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Box,{children:r("data_source.label")}),d&&n.jsx(Sg,{dataSource:d,triggerButtonProps:{size:"compact-xs",px:10}})]}),renderOption:fM,rightSection:d?n.jsx(a.Text,{size:"xs",c:"dimmed",children:Tg[d.type]??d.type}):void 0,rightSectionWidth:85,maxDropdownHeight:500,styles:{root:{flex:1,minWidth:"300px"},label:{display:"block"},section:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:o,value:e.key,onChange:u})}),xM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),[r,s]=f.useState(e.name);f.useEffect(()=>{s(e.name)},[e.name]);const i=f.useMemo(()=>e.conditionOptionsWithInvalidRunbys.optionGroups.map(l=>({group:t(l.group),items:l.items})),[e.conditionOptionsWithInvalidRunbys.optionGroups]);return n.jsx(a.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:n.jsxs(a.Stack,{gap:10,sx:{width:"100%"},children:[n.jsx(a.Divider,{mb:-10,variant:"dashed",label:t("query.basics"),labelPosition:"center"}),n.jsx(a.TextInput,{placeholder:t("query.name_description"),label:t("query.name"),required:!0,sx:{flex:1},value:r,onChange:o=>{s(o.currentTarget.value)},rightSection:n.jsx(a.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>e.setName(r),disabled:r===e.name,children:n.jsx(C.IconDeviceFloppy,{size:16})}),onBlur:()=>{e.setName(r)}}),n.jsx(kg,{queryModel:e}),n.jsx(a.Divider,{mt:10,mb:-10,variant:"dashed",label:t("query.conditions"),labelPosition:"center"}),n.jsx(a.MultiSelect,{label:t("query.run_by_condition.label"),description:t("query.run_by_condition.description"),placeholder:t("query.run_by_condition.unset"),data:i,value:[...e.run_by],onChange:e.setRunBy,renderOption:cd,maxDropdownHeight:500}),e.typedAsHTTP&&n.jsx(a.MultiSelect,{label:t("query.re_run_condition.label"),placeholder:t("query.re_run_condition.label"),data:i,value:[...e.config.react_to],onChange:e.config.setReactTo,renderOption:cd,maxDropdownHeight:500}),n.jsx(a.Divider,{mt:20,mb:10,variant:"dashed"}),n.jsx(ZI,{queryModel:e})]})})});function mM({content:e}){return n.jsxs(a.HoverCard,{width:"60vw",shadow:"md",zIndex:340,children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.ActionIcon,{size:16,color:"blue",variant:"subtle",children:n.jsx(C.IconEye,{})})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsx(Dt.CodeHighlight,{language:"sql",withCopyButton:!1,code:e})})]})}const bM=k.observer(()=>{const t=[...se().globalSQLSnippets.list];return t.length===0?null:n.jsxs(a.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fz:"sm",highlightOnHover:!0,children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:"Key"}),n.jsx(a.Table.Th,{children:"Value"})]})}),n.jsx(a.Table.Tbody,{children:t.map(r=>{const{id:s,content:i}=r;return n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:s}),n.jsx(a.Table.Td,{width:200,children:n.jsx(mM,{content:i})})]},s)})})]})}),yM=`
499
+ `,yg=()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(a.Button,{variant:"subtle",size:"compact-sm",onClick:()=>r(s=>!s),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),n.jsx(a.Collapse,{in:t,children:n.jsx(Dt.CodeHighlight,{language:"typescript",withCopyButton:!1,code:oI})})]})},lI=k.observer(function({filter:t}){const{t:r}=_.useTranslation(),s=t.config,i=()=>{s.addStaticOption({label:"",value:""})},o=s.static_options,l=[...o];return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Checkbox,{checked:s.required,onChange:c=>s.setRequired(c.currentTarget.checked),label:r("filter.widget.select.required")}),n.jsx(Dn,{filter:t})]}),n.jsx(a.TextInput,{label:r("filter.widget.select.width"),description:r("filter.widget.multi_select.width_description"),value:s.min_width,onChange:c=>s.setMinWidth(c.currentTarget.value),placeholder:"200px"}),n.jsx(a.Divider,{label:r("filter.widget.select.configure_options"),labelPosition:"center"}),n.jsxs(a.Stack,{gap:10,sx:{position:"relative",minHeight:"50px"},children:[s.usingQuery&&n.jsxs(n.Fragment,{children:[n.jsx(a.Overlay,{backgroundOpacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),n.jsx(a.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:n.jsx(a.Text,{c:"white",size:"16px",children:r("filter.widget.common.using_query")})})]}),o.length>0&&n.jsx(a.MultiSelect,{label:r("filter.widget.select.default_selection"),data:l,value:[...s.default_value],onChange:s.setDefaultValue}),o.map((c,u)=>n.jsxs(a.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[n.jsx(a.TextInput,{label:r("common.label"),required:!0,value:s.static_options[u].label,onChange:d=>{s.static_options[u].setLabel(d.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(a.TextInput,{label:r("common.value"),required:!0,value:s.static_options[u].value,onChange:d=>{s.static_options[u].setValue(d.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>s.removeStaticOption(u),sx:{position:"absolute",top:28,right:5},children:n.jsx(C.IconTrash,{size:16})})]},u)),n.jsx(a.Button,{mt:10,size:"xs",color:"blue",leftSection:n.jsx(C.IconPlaylistAdd,{size:20}),onClick:i,sx:{width:"50%"},mx:"auto",children:r("common.actions.add_an_option")})]}),n.jsx(a.Divider,{label:r("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),n.jsx(a.NumberInput,{value:s.default_selection_count,onChange:s.setDefaultSelectionCount,label:r("filter.widget.common.default_selection_count")}),n.jsx(Es,{value:s.options_query_id,onChange:s.setOptionsQueryID}),n.jsx(yg,{})]})}),vg={date_unit:{zh:[{label:"天",value:"day"},{label:"周",value:"week"},{label:"双周",value:"bi-week"},{label:"月",value:"month"},{label:"季度",value:"quarter"},{label:"年",value:"year"}],en:[{label:"Day",value:"day"},{label:"Week",value:"week"},{label:"Bi-Week",value:"bi-week"},{label:"Month",value:"month"},{label:"Quarter",value:"quarter"},{label:"Year",value:"year"}]}},_g=k.observer(({config:e})=>{const{t,i18n:r}=_.useTranslation(),s=()=>{e.addStaticOption({label:"",value:""})},i=f.useMemo(()=>[{label:t("filter.widget.select.preset_options.date_unit"),value:"date_unit"}],[r.language]),o=l=>{if(!l||!(l in vg))return;const c=vg[l][r.language];e.replaceStaticOptions(c),c.length>0&&e.setDefaultValue(c[0].value)};return n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Button,{size:"xs",color:"blue",leftSection:n.jsx(C.IconPlaylistAdd,{size:20}),onClick:s,children:t("common.actions.add_an_option")}),n.jsx(a.Select,{placeholder:t("filter.widget.select.preset_options.apply"),value:null,onChange:o,data:i,size:"xs"})]})}),cI=k.observer(({config:e})=>{const{t,i18n:r}=_.useTranslation(),s=[...e.static_options],i=f.useMemo(()=>[{label:t("filter.widget.select.no_default_selection"),value:""},...s],[r.language,s]);return s.length===0?n.jsx(_g,{config:e}):n.jsxs(n.Fragment,{children:[n.jsx(a.Select,{label:t("filter.widget.select.default_selection"),data:i,value:e.default_value,onChange:e.setDefaultValue}),s.map((o,l)=>n.jsxs(a.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[n.jsx(a.TextInput,{label:t("common.label"),required:!0,value:e.static_options[l].label,onChange:c=>{e.static_options[l].setLabel(c.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(a.TextInput,{label:t("common.value"),required:!0,value:e.static_options[l].value,onChange:c=>{e.static_options[l].setValue(c.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.removeStaticOption(l),sx:{position:"absolute",top:28,right:5},children:n.jsx(C.IconTrash,{size:16})})]},l)),n.jsx(_g,{config:e})]})}),uI=k.observer(({filter:e})=>{const{t}=_.useTranslation(),r=e.config;return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Checkbox,{checked:r.required,onChange:s=>r.setRequired(s.currentTarget.checked),label:t("filter.widget.select.required")}),n.jsx(a.Checkbox,{checked:r.clearable,onChange:s=>r.setClearable(s.currentTarget.checked),label:t("filter.widget.select.clearable")}),n.jsx(Dn,{filter:e})]}),n.jsx(a.TextInput,{label:t("filter.widget.select.width"),value:r.width,onChange:s=>r.setWidth(s.currentTarget.value),placeholder:"200px"}),n.jsx(a.Divider,{label:t("filter.widget.select.configure_options"),labelPosition:"center"}),n.jsxs(a.Stack,{gap:10,sx:{position:"relative",minHeight:"50px"},children:[r.usingQuery&&n.jsxs(n.Fragment,{children:[n.jsx(a.Overlay,{backgroundOpacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),n.jsx(a.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:n.jsx(a.Text,{c:"white",size:"16px",children:t("filter.widget.common.using_query")})})]}),n.jsx(cI,{config:r})]}),n.jsx(a.Divider,{label:t("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),n.jsx(a.Checkbox,{checked:r.default_selection_count===1,onChange:s=>r.setDefaultSelectionCount(s.currentTarget.checked?1:0),label:t("filter.widget.select.select_first_option_by_default")}),n.jsx(Es,{value:r.options_query_id,onChange:r.setOptionsQueryID}),n.jsx(yg,{})]})}),dI=k.observer(function({filter:t}){const{t:r}=_.useTranslation(),s=t.config;return n.jsxs(n.Fragment,{children:[n.jsxs(a.Group,{children:[n.jsx(a.TextInput,{label:r("filter.widget.text_input.default_value"),value:s.default_value,onChange:i=>{s.setDefaultValue(i.currentTarget.value)},sx:{flexGrow:1}}),n.jsx(a.Box,{mt:22,children:n.jsx(Dn,{filter:t})})]}),n.jsx(a.Checkbox,{checked:s.required,onChange:i=>s.setRequired(i.currentTarget.checked),label:r("filter.widget.text_input.required")})]})}),pI=k.observer(function({filter:t}){const{t:r}=_.useTranslation();return n.jsxs(a.Box,{sx:{maxWidth:"480px"},children:[n.jsx(a.Text,{pt:"0",pb:"md",c:"gray",size:"sm",children:r("common.titles.config")}),n.jsx(Dt.CodeHighlight,{mt:22,language:"json",withCopyButton:!1,code:JSON.stringify(t,null,4)})]})}),hI={[Q.Select]:uI,[Q.MultiSelect]:lI,[Q.TreeSelect]:u3,[Q.TreeSingleSelect]:x3,[Q.TextInput]:dI,[Q.Checkbox]:sI,[Q.DateRange]:aI},rn={[Q.Select]:"filter.widget.names.select",[Q.MultiSelect]:"filter.widget.names.multi_select",[Q.TreeSelect]:"filter.widget.names.tree_select",[Q.TreeSingleSelect]:"filter.widget.names.tree_single_select",[Q.TextInput]:"filter.widget.names.text_input",[Q.Checkbox]:"filter.widget.names.checkbox",[Q.DateRange]:"filter.widget.names.date_range"},gI=k.observer(function({filter:t}){const{t:r,i18n:s}=_.useTranslation(),i=re(),o=f.useMemo(()=>hI[t.type],[t.type]),l=f.useMemo(()=>[{label:r(rn[Q.Select]),value:"select"},{label:r(rn[Q.MultiSelect]),value:"multi-select"},{label:r(rn[Q.TreeSelect]),value:"tree-select"},{label:r(rn[Q.TreeSingleSelect]),value:"tree-single-select"},{label:r(rn[Q.TextInput]),value:"text-input"},{label:r(rn[Q.Checkbox]),value:"checkbox"},{label:r(rn[Q.DateRange]),value:"date-range"}],[s.language]);return n.jsxs(a.Group,{grow:!0,gap:20,align:"top",children:[n.jsxs(a.Box,{sx:{maxWidth:"600px"},children:[n.jsx(a.Text,{pb:"md",c:"gray",size:"sm",children:r("common.titles.edit")}),n.jsxs(a.Stack,{children:[n.jsxs(a.Group,{wrap:"nowrap",children:[n.jsx(a.NumberInput,{label:r("filter.field.order"),required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&n.jsx(a.Checkbox,{label:r("filter.field.auto_submit"),checked:t.auto_submit,onChange:c=>t.setAutoSubmit(c.currentTarget.checked),mt:22})]}),n.jsx(a.MultiSelect,{label:r("filter.field.visible_in"),data:i.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),n.jsx(a.TextInput,{label:r("common.key"),placeholder:r("filter.field.key_placeholder"),required:!0,value:t.key,onChange:c=>{t.setKey(c.currentTarget.value)}}),n.jsx(a.TextInput,{label:r("common.label"),placeholder:r("filter.field.label_placeholder"),required:!0,value:t.label,onChange:c=>{t.setLabel(c.currentTarget.value)}}),n.jsx(a.Select,{label:r("filter.field.widget"),data:l,required:!0,value:t.type,onChange:t.setType,maxDropdownHeight:500}),n.jsx(a.Divider,{mb:0,mt:10,variant:"dashed",labelPosition:"center"}),n.jsx(o,{filter:t})]})]}),n.jsx(pI,{filter:t})]})}),fI=k.observer(({id:e})=>{const{t}=_.useTranslation(),r=dt.useModals(),s=se(),i=re();if(e==="")return null;const o=i.filters.findByID(e);if(!o)return n.jsxs(a.Text,{size:"14px",children:["Filter by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_FILTERS_",""])},c=()=>{r.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 n.jsxs(a.Stack,{sx:{maxWidth:"1100px",height:"100vh"},gap:"sm",pb:30,children:[n.jsx(a.Group,{justify:"flex-end",pt:10,children:n.jsx(a.Button,{size:"xs",color:"red",leftSection:n.jsx(C.IconTrash,{size:16}),onClick:c,children:t("filter.delete")})}),n.jsx(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n.jsx(gI,{filter:o})})]})}),xI=k.observer(()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState([]),s=se(),i=d=>{s.editor.setPath(["_FILTERS_",d])},o=()=>{s.content.filters.downloadSchema(t)},l=f.useMemo(()=>s.content.filters.sortedList.map(d=>d.id),[s.content.filters.sortedList]),c=()=>{r(l)},u=()=>{r([])};return n.jsxs(a.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(a.Text,{size:"sm",px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("filter.manage")})}),n.jsx(a.Flex,{justify:"space-between",align:"center",px:12,children:n.jsxs(a.Group,{justify:"flex-start",children:[n.jsxs(a.Button.Group,{children:[n.jsx(a.Button,{variant:"default",size:"xs",onClick:c,children:e("common.actions.select_all")}),n.jsx(a.Button,{variant:"default",size:"xs",onClick:u,children:e("common.actions.clear_selection")})]}),n.jsx(a.Button,{size:"xs",color:"blue",leftSection:n.jsx(C.IconCode,{size:14}),disabled:t.length===0,onClick:o,children:e("common.actions.download_schema")})]})}),n.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(a.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"40px"}}),n.jsx(a.Table.Th,{style:{width:"300px"},children:e("common.label")}),n.jsx(a.Table.Th,{children:e("common.key")}),n.jsx(a.Table.Th,{style:{width:"100px"},children:e("filter.field.widget")}),n.jsx(a.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(a.Table.Tbody,{children:s.content.filters.sortedList.map(d=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:n.jsx(a.Checkbox,{value:d.id,styles:{input:{cursor:"pointer"}}})}),n.jsx(a.Table.Td,{children:d.label}),n.jsx(a.Table.Td,{children:d.key}),n.jsx(a.Table.Td,{children:e(rn[d.type])}),n.jsx(a.Table.Td,{children:n.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>i(d.id),children:e("common.actions.open")})})]},d.id))})]})})})]})}),mI=k.observer(()=>{const{t:e}=_.useTranslation(),t=re(),[r,s]=f.useState(()=>JSON.stringify(t.mock_context.current,null,4)),i=()=>{try{t.mock_context.replace(JSON.parse(r))}catch(l){Nt.showNotification({title:"Failed",message:l.message,color:"red"})}},o=f.useMemo(()=>{try{return JSON.stringify(JSON.parse(r))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[r,t.mock_context.current]);return n.jsxs(a.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[n.jsx(a.Group,{justify:"flex-start",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:n.jsx(a.Text,{size:"sm",fw:500,children:e("mock_context.label")})}),n.jsx(a.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:n.jsxs(a.Stack,{gap:10,sx:{maxWidth:"unset !important"},children:[n.jsxs(a.Group,{justify:"flex-start",children:[n.jsx(a.Text,{size:"sm",children:e("mock_context.hint")}),n.jsx(a.Button,{color:"green",size:"compact-sm",leftSection:n.jsx(C.IconDeviceFloppy,{size:16}),onClick:i,disabled:!o,children:e("common.actions.save")})]}),n.jsx(a.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:r,onChange:s,sx:{flexGrow:1}})]})})]})}),bI=k.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Le();return n.jsx(bn,{label:e("panel.panel_description"),value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}},t.id)}),yI=k.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Le(),r=Te().layouts.findItemByPanelID(t.id),{style:s}=t;return n.jsx(n.Fragment,{children:n.jsxs(a.Stack,{gap:20,children:[n.jsxs(a.Group,{grow:!0,align:"top",children:[n.jsx(a.NumberInput,{label:e("panel.style.width"),min:1,max:36,step:1,decimalScale:0,rightSection:n.jsx(a.Text,{size:"12px",children:e("panel.style.width_postfix")}),styles:{section:{width:"auto",maxWidth:"100px",paddingRight:"14px",justifyContent:"flex-end"}},value:r.w,onChange:i=>{typeof i!="string"&&r.setWidth(i)}}),n.jsx(a.NumberInput,{label:e("panel.style.height"),rightSection:n.jsx(a.Text,{size:"12px",children:e("panel.style.height_postfix")}),styles:{section:{width:"40px"}},value:r.h,onChange:i=>{typeof i!="string"&&r.setHeight(i)}})]}),n.jsx(a.Checkbox,{ml:6,label:e("panel.style.border"),checked:s.border.enabled,onChange:i=>s.border.setEnabled(i.currentTarget.checked)})]})})}),vI=()=>n.jsxs("span",{className:"mantine-103svbs mantine-InputWrapper-required mantine-Select-required","aria-hidden":"true",children:[" ","*"]}),_I=k.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Le(),{name:r}=t,[s,i]=ze.useInputState(r),o=r!==s,l=f.useCallback(()=>{o&&t.setName(s)},[o,s]);f.useEffect(()=>{i(r)},[r]);const c=!s.trim();return n.jsxs(a.Stack,{gap:4,children:[n.jsxs(a.Group,{align:"center",children:[n.jsxs(a.Text,{size:"14px",fw:500,children:[e("panel.panel_name"),n.jsx(vI,{})]}),n.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:!o||c,onClick:l,children:n.jsx(C.IconDeviceFloppy,{size:18})})]}),n.jsx(a.TextInput,{value:s,onChange:i,required:!0})]})}),jI=k.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Le();return n.jsx(a.Stack,{gap:6,mb:10,children:n.jsxs(a.Group,{pl:6,justify:"flex-start",gap:20,children:[n.jsx(a.Checkbox,{size:"sm",checked:t.title.show,onChange:r=>t.title.setShow(r.currentTarget.checked),label:e("panel.show_title"),sx:{userSelect:"none"}}),n.jsx(a.Checkbox,{size:"sm",checked:!0,disabled:!0,label:e("panel.use_name_as_title")})]})})});function wI(){const{t:e}=_.useTranslation();return n.jsxs(a.Stack,{sx:{height:"100%"},children:[n.jsx(yI,{}),n.jsx(a.Divider,{label:e("common.info"),labelPosition:"center",variant:"dashed"}),n.jsx(_I,{}),n.jsx(jI,{}),n.jsx(bI,{})]})}const CI={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 jg({data:e}){const t=f.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const s=Re.createColumnHelper();return Object.keys(e[0]).map(i=>s.accessor(i,{cell:o=>o.getValue()}))},[e]),r=Re.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Re.getCoreRowModel()});return e.length===0?n.jsx(a.Box,{sx:{height:"5em"}}):n.jsx(Ie,{children:n.jsxs(a.Table,{sx:CI,children:[n.jsx(a.Table.Thead,{children:r.getHeaderGroups().map(s=>n.jsx(a.Table.Tr,{children:s.headers.map(i=>n.jsxs(a.Table.Th,{style:{width:i.getSize()},children:[i.isPlaceholder?null:Re.flexRender(i.column.columnDef.header,i.getContext()),n.jsx(a.ActionIcon,{variant:"subtle",onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:n.jsx(C.IconArrowBarToRight,{})})]},i.id))},s.id))}),n.jsx(a.Table.Tbody,{children:r.getRowModel().rows.map(s=>n.jsx(a.Table.Tr,{children:s.getVisibleCells().map(i=>n.jsx(a.Table.Td,{children:n.jsx(Ie,{children:typeof i.getValue()=="object"?n.jsx("pre",{children:JSON.stringify(i.getValue(),null,2)}):Re.flexRender(i.column.columnDef.cell,i.getContext())})},i.id))},s.id))})]})})}const SI=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],TI={section:{"&[data-position=left]":{width:"70px",textAlign:"center"}},input:{paddingLeft:"70px"}},kI=({data:e,page:t,setPage:r,limit:s,setLimit:i})=>{const{t:o}=_.useTranslation(),l=e.length,c=Math.ceil(l/s),u=p=>{p&&(r(1),i(Number(p)))};if(l===0)return null;const d=c===1&&l<=10;return n.jsxs(a.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(a.Group,{justify:"flex-start",children:[c>1&&n.jsx(a.Pagination,{size:"sm",value:t,onChange:r,total:c,withEdges:c>7,styles:{control:{height:"30px"}}}),!d&&n.jsx(a.Select,{leftSection:n.jsx(a.Text,{ta:"center",c:"dimmed",size:"14px",children:o("common.pagination.page_size")}),size:"xs",styles:TI,data:SI,value:String(s),onChange:u})]}),n.jsx(a.Group,{justify:"flex-end",children:n.jsx(a.Text,{c:"dimmed",my:0,size:"14px",children:o("common.pagination.total_rows",{total:l})})})]})},DI=xd(({data:e,loading:t})=>{const[r,s]=f.useState(1),[i,o]=f.useState(20),l=f.useMemo(()=>{const c=(r-1)*i,u=c+i;return e.slice(c,u)},[e,r,i]);return n.jsxs(Ie,{children:[n.jsx(kI,{data:e,page:r,setPage:s,limit:i,setLimit:o}),n.jsxs(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(a.LoadingOverlay,{visible:t,overlayProps:{blur:2}}),n.jsx(jg,{data:l})]})]})}),zI=k.observer(({queryID:e})=>{const{t}=_.useTranslation(),r=Te(),s=f.useMemo(()=>r.queries.findByID(e),[r,e]);if(!s||s.state==="loading")return null;const{error:i,metricQueryPayloadErrorString:o,stateMessage:l}=s;return i||o?n.jsx(a.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:i??o}):l?n.jsx(a.Text,{size:"sm",mt:10,c:"gray",ta:"center",children:t(l)}):null}),Wo=k.observer(({id:e,moreActions:t,refreshOnMount:r})=>{const{t:s}=_.useTranslation(),i=Te(),{data:o,state:l}=i.getDataStuffByID(e),c=l==="loading",u=f.useCallback(()=>{i.queries.refetchDataByQueryID(e)},[e,i]),d=()=>{i.queries.downloadDataByQueryID(e)};f.useEffect(()=>{r&&u()},[u,r]);const p=!Array.isArray(o)||o.length===0;return n.jsxs(a.Stack,{gap:0,sx:{height:"100%",border:"1px solid #eee"},children:[n.jsxs(a.Group,{justify:"space-between",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n.jsx(a.Group,{justify:"flex-start",children:n.jsx(a.Text,{size:"sm",fw:500,children:s("data.preview_data")})}),n.jsxs(a.Group,{pr:15,children:[t,n.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:c,onClick:u,children:n.jsx(C.IconRefresh,{size:16})}),n.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:c||p,onClick:d,children:n.jsx(C.IconDownload,{size:16})})]})]}),n.jsxs(a.Box,{pb:20,sx:{position:"relative",flexGrow:1,overflow:"auto"},children:[n.jsx(zI,{queryID:e}),n.jsx(DI,{data:o,loading:c})]})]})}),II=k.observer(function(){const{t}=_.useTranslation(),r=se(),s=re(),{panel:i}=Le(),[o,l]=f.useState(!1),c=d=>{r.editor.setPath(["_QUERIES_",d])},u=i.queryIDs.length;return n.jsxs(n.Fragment,{children:[n.jsx(a.Drawer,{opened:o,onClose:()=>l(!1),title:t("panel.settings.choose_queries"),padding:"xl",size:500,zIndex:320,children:n.jsx(a.Checkbox.Group,{value:[...i.queryIDs],onChange:i.setQueryIDs,children:n.jsx(a.Stack,{gap:"lg",children:s.queries.options.map(d=>n.jsx(a.Checkbox,{label:d.label,value:d.value},d.value))})})}),n.jsxs(a.Stack,{gap:6,children:[n.jsx(a.Group,{justify:"flex-start",children:n.jsx(a.Button,{variant:"light",size:"sm",leftSection:n.jsx(C.IconLine,{size:16}),onClick:()=>l(!0),children:t(u===0?"panel.settings.need_to_choose_queries":"panel.settings.choose_queries")})}),u===1&&n.jsx(Wo,{id:i.queryIDs[0],moreActions:n.jsx(a.Tooltip,{label:t("query.open"),children:n.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(i.queryIDs[0]),children:n.jsx(C.IconArrowCurveRight,{size:16})})})}),u>1&&n.jsxs(a.Tabs,{defaultValue:i.queryIDs[0],children:[n.jsx(a.Tabs.List,{children:i.queries.map(d=>n.jsx(a.Tabs.Tab,{value:d.id,children:d.name},d.id))}),i.queries.map(d=>n.jsx(a.Tabs.Panel,{value:d.id,children:n.jsx(Wo,{id:d.id,moreActions:n.jsx(a.Tooltip,{label:t("query.open"),children:n.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(d.id),children:n.jsx(C.IconArrowCurveRight,{size:16})})})})},d.id))]})]})]})}),MI=k.observer(()=>{const{panel:e}=He();return e.title.show?n.jsx(a.Group,{grow:!0,justify:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:n.jsx(a.Text,{size:"sm",ta:"center",lineClamp:1,className:"panel-title-text",children:e.title.show?e.name:""})}):null}),EI=k.observer(()=>{const{panel:e}=He();return n.jsx(Ie,{children:n.jsxs(a.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,p:0,sx:{border:"1px solid",borderColor:e.style.border.enabled?"#e9ecef":"transparent",flexGrow:0,flexShrink:0,width:"600px !important",height:"450px !important"},children:[n.jsx(a.Box,{className:"panel-description-popover-wrapper",children:n.jsx(Oo,{})}),n.jsx(MI,{}),n.jsx(Vo,{panel:e})]})})});function PI(){const{t:e}=_.useTranslation(),{vizManager:t}=f.useContext(tn);return f.useMemo(()=>v.orderBy(Object.entries(v.groupBy(t.availableVizList,"displayGroup")),[i=>i[0]],["asc"]).map(([i,o])=>{const l=o.map(c=>({value:c.name,label:e(c.displayName??it.name)}));return{group:e(i??"ungrouped"),items:v.orderBy(l,[c=>c.label],["asc"])}}),[t])}const AI=k.observer(({value:e,submit:t})=>{const{t:r}=_.useTranslation(),[s,i]=ze.useInputState(e);f.useEffect(()=>{i(e)},[e]);const o=PI(),l=e!==s;return n.jsx(a.Select,{label:r("visualization.component"),value:s,searchable:!0,onChange:i,data:o,rightSection:n.jsx(a.ActionIcon,{variant:"filled",color:"green",disabled:!l,onClick:()=>t(s),styles:{root:{pointerEvents:"all"}},children:n.jsx(C.IconDeviceFloppy,{size:20})}),maxDropdownHeight:600})}),wg=[];function LI(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function OI(){const{data:e,panel:{variables:t,viz:r,title:s,name:i,queryIDs:o,description:l,id:c}}=Le(),{vizManager:u}=f.useContext(tn),d={name:i,title:s,description:l,viz:r,queryIDs:o,id:c},p=Ph(d);try{return u.resolveComponent(d.viz.type),n.jsx(Ms,{configure:p,children:n.jsx(J3,{variables:t,setVizConf:r.setConf,panel:d,vizManager:u,data:e})})}catch(h){return console.info(v.get(h,"message")),null}}const VI=k.observer(()=>{const{data:e,panel:{viz:t}}=Le(),{vizManager:r}=f.useContext(tn),s=f.useCallback(d=>{if(d===t.type)return;const p=LI(r,d);t.setType(d),t.setConf(p||{})},[t.type]),i=d=>{try{t.setConf(JSON.parse(d))}catch(p){console.error(p)}},o=f.useMemo(()=>{var d;return(d=wg.find(p=>p.value===t.type))==null?void 0:d.Panel},[t.type,wg]),l=OI(),c=o?f.createElement(o,{data:e,conf:t.conf,setConf:t.setConf}):null,u=l||c;return n.jsxs(a.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[n.jsx(AI,{submit:s,value:t.type}),n.jsxs(Ie,{children:[n.jsx(a.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:u}),!u&&n.jsx(a.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:i})]})]})}),BI=k.observer(({panel:e,sourceViewID:t})=>{const{t:r}=_.useTranslation(),s=re(),[i,o]=f.useState(t);f.useEffect(()=>{o(t)},[t]);const[l,{open:c,close:u}]=ze.useDisclosure(!1),d=()=>{e.moveToView(t,i),u()};return n.jsxs(n.Fragment,{children:[n.jsx(a.Button,{size:"xs",variant:"subtle",color:"blue",onClick:c,leftSection:n.jsx(C.IconBoxMultiple,{size:14}),children:r("panel.settings.change_view")}),n.jsx(a.Modal,{opened:l,onClose:u,title:r("panel.settings.change_view_title"),zIndex:320,children:n.jsxs(a.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[n.jsx(a.Radio.Group,{value:i,onChange:o,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:n.jsx(a.Stack,{gap:"xs",children:s.views.options.map(p=>n.jsx(a.Radio,{value:p.value,label:p.label},p.value))})}),n.jsxs(a.Group,{wrap:"nowrap",justify:"space-between",sx:{flexGrow:0,flexShrink:0},children:[n.jsx(a.Button,{size:"xs",color:"red",leftSection:n.jsx(C.IconX,{size:14}),onClick:u,children:r("common.actions.cancel")}),n.jsx(a.Button,{size:"xs",color:"blue",leftSection:n.jsx(C.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:r("common.actions.confirm")})]})]})})]})}),qI=k.observer(({sx:e={}})=>{const{t}=_.useTranslation(),r=Te(),{panel:s}=He(),i=r.dashboardState,o=(()=>{const l={...i,...s.variableStrings};return JSON.stringify(l,null,2)})();return n.jsx(a.Stack,{sx:{overflow:"hidden",...e},children:n.jsxs(a.Tabs,{defaultValue:"vars",keepMounted:!1,children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"guide",leftSection:n.jsx(C.IconAlertCircle,{size:14}),children:t("panel.variable.guide.tabs.guide")}),n.jsx(a.Tabs.Tab,{value:"vars",leftSection:n.jsx(C.IconVariable,{size:14}),children:t("panel.variable.guide.tabs.vars")})]}),n.jsx(a.Tabs.Panel,{value:"guide",pt:"xs",children:n.jsx(Dt.CodeHighlight,{language:"sql",sx:{width:"100%"},withCopyButton:!1,code:t("panel.variable.guide.text")})}),n.jsx(a.Tabs.Panel,{value:"vars",pt:"xs",children:n.jsx(Dt.CodeHighlight,{language:"json",sx:{width:"100%"},withCopyButton:!1,code:o})})]})})}),Uo={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 NI{constructor(t){N(this,"panel");N(this,"selected");this.panel=t,t.variables.length>0&&(this.selected=t.variables[0]),te.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(r=>r.name.startsWith(Uo.name)).length;this.panel.addVariable(v.cloneDeep({...Uo,name:`${Uo.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 r=this.variables.find(s=>s.name===t);if(!r){console.error(`Variable by name[${t}] not found`);return}this.selected=r}remove(t){this.selected===t&&(this.selected=void 0);const r=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,r);this.selected=this.panel.variables[s]}}}function $I(){const{panel:e}=Le();return Y.useCreation(()=>new NI(e),[e])}const GI=f.forwardRef(function({value:t,onChange:r,remove:s},i){const{t:o}=_.useTranslation(),l=(c,u)=>{const d=v.cloneDeep(t);v.set(d,c,u),r(d)};return n.jsxs(a.Stack,{ref:i,children:[n.jsxs(a.Stack,{gap:"xs",px:"sm",py:"md",sx:{border:"1px solid #e9ecef"},children:[n.jsxs(a.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(a.TextInput,{label:o("common.name"),required:!0,value:t.name,onChange:c=>l("name",c.currentTarget.value)}),n.jsx(W,{label:o("common.data_field"),required:!0,value:t.data_field,onChange:c=>l("data_field",c)})]}),n.jsx(Oa,{label:o("panel.variable.aggregation.label"),pt:0,value:t.aggregation,onChange:c=>l("aggregation",c),withFallback:!0}),t.aggregation.type!=="custom"&&n.jsxs(n.Fragment,{children:[n.jsx(a.Divider,{mt:"xl",mb:0,label:o("numbro.format.label"),labelPosition:"center",variant:"dashed"}),n.jsx(St,{value:t.formatter,onChange:c=>l("formatter",c)})]})]}),n.jsx(a.Button,{mt:20,leftSection:n.jsx(C.IconTrash,{size:16}),color:"red",variant:"light",onClick:s,children:o("panel.variable.delete")})]})}),FI=k.observer(e=>{const{t}=_.useTranslation(),r=Y.useCreation(()=>kh(e.variable),[e.variable]),s=()=>e.uiModel.remove(e.variable);return n.jsxs(a.Stack,{"data-testid":"variable-editor",align:"stretch",children:[n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Button,{variant:"subtle",size:"xs",disabled:!r.changed,color:"red",onClick:r.reset,leftSection:n.jsx(C.IconRecycle,{size:18}),children:t("common.actions.revert_changes")}),n.jsx(a.Button,{variant:"filled",size:"xs",disabled:!r.changed,color:"green",onClick:r.commit,leftSection:n.jsx(C.IconDeviceFloppy,{size:18}),children:t("common.actions.save_changes")})]}),n.jsx(GI,{value:g.getSnapshot(r.copy),onChange:r.update,remove:s})]})});k.observer(e=>{const{uiModel:t}=e;return n.jsx(a.Stack,{className:"var-list",children:t.variables.map(r=>n.jsx(a.Button,{variant:t.selected===r?"filled":"subtle",color:"gray",onClick:()=>t.select(r),children:r.name},r.name))})});const QI=k.observer(({model:e})=>{const{t}=_.useTranslation();return n.jsx(a.Overlay,{color:"#fff",backgroundOpacity:1,sx:{position:"absolute"},children:n.jsx(a.Button,{variant:"light",size:"xs",leftSection:n.jsx(C.IconPlus,{size:16}),onClick:e.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:t("panel.variable.add")})})}),RI=k.observer(()=>{var r;const{t:e}=_.useTranslation(),t=$I();return t.variableOptions.length===0?n.jsx(QI,{model:t}):n.jsxs(a.Stack,{pb:20,children:[n.jsxs(a.Group,{justify:"flex-start",children:[n.jsx(a.Select,{label:e("panel.variable.labels"),data:t.variableOptions,value:(r=t.selected)==null?void 0:r.name,onChange:t.selectByName,maxDropdownHeight:600,sx:{flexGrow:1}}),n.jsx(a.Button,{variant:"light",size:"xs",leftSection:n.jsx(C.IconPlus,{size:16}),onClick:t.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:e("panel.variable.add")})]}),n.jsx(a.Divider,{variant:"dashed"}),t.selected?n.jsx(FI,{uiModel:t,variable:t.selected}):n.jsx("span",{children:"Select or create a new variable on right side"})]})}),WI={root:{flexGrow:1,width:"100%",minWidth:"1200px",overflow:"hidden"},panel:{width:"100%",minWidth:"1200px",height:"calc(100% - 44px)",padding:10,overflow:"auto"}},Yo=({children:e})=>n.jsxs(a.Group,{wrap:"nowrap",grow:!0,justify:"flex-start",gap:20,sx:{width:"100%",height:"100%",position:"relative"},children:[n.jsx(a.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),n.jsxs(a.Stack,{justify:"flex-start",sx:{alignSelf:"flex-start",width:"600px",flexGrow:0,flexShrink:0},children:[n.jsx(EI,{}),n.jsx(a.Box,{sx:{flexGrow:1},children:n.jsx(qI,{})})]})]});function UI(e){return!["richText","button"].includes(e)}const YI=k.observer(({panel:e})=>{const{t}=_.useTranslation(),r=dt.useModals(),s=se(),i=re(),[o,l]=f.useState(s.editor.panelTab),c=e.queries,d=UI(e.viz.type)&&e.dataLoading,p=d||e.queryErrors.length>0||e.queryStateMessages!==""||c.length===0,h=s.editor.path[1];f.useEffect(()=>{l(j=>p&&j==="Visualization"?"Data":j)},[e.id,p]);const x=f.useCallback(j=>{l(j),s.editor.setPanelTab(o)},[]),b=()=>{s.editor.setPath(["_VIEWS_",h])},m=()=>r.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),b()},confirmProps:{color:"red"},zIndex:320});return n.jsxs(ii,{value:{panel:e,data:e.data,loading:d,errors:e.queryErrors,downloadPanelScreenshot:()=>{}},children:[n.jsxs(a.Group,{px:16,justify:"space-between",sx:{borderBottom:"1px solid #eee"},children:[n.jsx(a.Text,{size:"sm",pt:9,pb:8,children:e.name}),n.jsxs(a.Group,{justify:"flex-end",wrap:"nowrap",children:[n.jsx(BI,{panel:e,sourceViewID:h}),n.jsx(a.Button,{size:"xs",variant:"subtle",color:"red",onClick:m,leftSection:n.jsx(C.IconTrash,{size:14}),children:t("panel.delete")})]})]}),n.jsxs(a.Tabs,{value:o,onChange:x,keepMounted:!1,styles:WI,children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"Data",leftSection:n.jsx(C.IconDatabase,{size:14}),disabled:d,children:t("data.label")}),n.jsx(a.Tabs.Tab,{value:"Panel",leftSection:n.jsx(C.IconAppWindow,{size:14}),children:t("panel.label")}),n.jsx(a.Tabs.Tab,{value:"Variables",leftSection:n.jsx(C.IconVariable,{size:14}),disabled:p,children:n.jsx(a.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:n.jsx(a.Text,{size:"sm",children:t("panel.variable.labels")})})}),n.jsx(a.Tabs.Tab,{value:"Visualization",leftSection:n.jsx(C.IconChartHistogram,{size:14}),disabled:p,children:n.jsx(a.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:n.jsx(a.Text,{size:"sm",children:t("visualization.label")})})}),n.jsx(a.Tabs.Tab,{value:"Interactions",leftSection:n.jsx(C.IconRoute,{size:14}),children:t("interactions.label")})]}),n.jsxs(a.Tabs.Panel,{value:"Data",children:[n.jsx(a.LoadingOverlay,{visible:d,transitionProps:{exitDuration:0}}),n.jsx(II,{})]}),n.jsx(a.Tabs.Panel,{value:"Panel",children:n.jsx(Yo,{children:n.jsx(wI,{})})}),n.jsx(a.Tabs.Panel,{value:"Variables",children:n.jsx(Yo,{children:n.jsx(RI,{})})}),n.jsx(a.Tabs.Panel,{value:"Visualization",children:n.jsx(Ie,{children:n.jsx(Yo,{children:n.jsx(VI,{})})})}),n.jsx(a.Tabs.Panel,{value:"Interactions",children:n.jsx(Ie,{children:n.jsx(Iv,{})})})]})]})}),KI=k.observer(({viewID:e,panelID:t})=>{const r=re();if(!r.views.findByID(e))return n.jsxs(a.Text,{size:"14px",children:["View by ID[",e,"] is not found"]});const i=r.panels.findByID(t);return i?n.jsx(YI,{panel:i}):n.jsxs(a.Text,{size:"14px",children:["Panel by ID[",t,"] is not found"]})}),XI=k.observer(()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState([]),s=dt.useModals(),i=se(),o=x=>{i.editor.setPath(["_QUERIES_",x])},l=()=>{s.openConfirmModal({title:"Delete ununsed queries?",children:n.jsx(a.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=f.useMemo(()=>i.content.queries.sortedList.map(x=>x.id),[i.content.queries.sortedList]),d=()=>{r(u)},p=()=>{r([])},h=i.content.queriesUsage;return n.jsxs(a.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(a.Text,{px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("query.manage")})}),n.jsxs(a.Flex,{justify:"space-between",align:"center",px:12,children:[n.jsxs(a.Group,{justify:"flex-start",children:[n.jsxs(a.Button.Group,{children:[n.jsx(a.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),n.jsx(a.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),n.jsx(a.Button,{size:"xs",color:"blue",leftSection:n.jsx(C.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),n.jsx(a.Button,{variant:"subtle",size:"xs",color:"red",leftSection:n.jsx(C.IconTrash,{size:14}),disabled:!i.content.hasUnusedQueries,onClick:l,children:e("query.delete_unused")})]}),n.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(a.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"40px"}}),n.jsx(a.Table.Th,{children:e("common.name")}),n.jsx(a.Table.Th,{style:{width:"200px"},children:e("data_source.label")}),n.jsx(a.Table.Th,{style:{width:"100px",textAlign:"right"},children:e("common.type")}),n.jsx(a.Table.Th,{style:{width:"100px",textAlign:"center"},children:e("query.usage.label")}),n.jsx(a.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(a.Table.Tbody,{children:i.content.queries.sortedList.map(x=>{var m;const b=((m=h[x.id])==null?void 0:m.length)??0;return n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:n.jsx(a.Checkbox,{value:x.id,styles:{input:{cursor:"pointer"}}})}),n.jsx(a.Table.Td,{children:x.name}),n.jsx(a.Table.Td,{children:x.key}),n.jsx(a.Table.Td,{style:{textAlign:"right"},children:x.type}),n.jsx(a.Table.Td,{style:{color:b===0?"#ff0000":"#000",fontWeight:b===0?"bold":"normal",textAlign:"center"},children:b}),n.jsx(a.Table.Td,{children:n.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>o(x.id),children:e("common.actions.open")})})]},x.id)})})]})})})]})}),HI=e=>{const{t}=_.useTranslation(),{queryModel:r}=e,s=se(),i=re(),l=i.findQueryUsage(r.id).length>0,c=dt.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(r.id),s.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return l?n.jsx(a.Tooltip,{label:t("query.cant_delete"),withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"top-end",children:n.jsx(a.Box,{sx:{alignSelf:"flex-end"},children:n.jsx(a.Button,{disabled:!0,size:"xs",leftSection:n.jsx(C.IconTrash,{size:16}),children:t("query.delete")})})}):n.jsx(a.Button,{color:"red",size:"xs",onClick:u,leftSection:n.jsx(C.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:t("query.delete")})},ZI=k.observer(HI),Cg=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:r,count:s,spacing:i=16,pl:o=0})=>n.jsxs(a.Stack,{gap:i,mt:6,pl:o,children:[Array.from(new Array(s-1),(l,c)=>n.jsx(a.Skeleton,{width:e,height:r,radius:"xs"},c)),n.jsx(a.Skeleton,{width:t,height:r,radius:"xs"})]}),Mr=({value:e})=>e===null||e===""?null:n.jsx(a.Tooltip,{label:e,disabled:!e,multiline:!0,zIndex:340,children:n.jsx(a.ActionIcon,{variant:"subtle",children:n.jsx(C.IconInfoCircle,{size:14})})}),JI=({column:e})=>{const{column_key:t,column_key_text:r}=e;return t?n.jsx(a.Tooltip,{label:r,disabled:!r,children:n.jsx(a.Badge,{variant:"light",children:t})}):null},eM=k.observer(({dataSource:e})=>{const{columns:t}=e.dbInfo;return t.loading?n.jsx(Cg,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:n.jsxs(a.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:50}}),n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{width:30}}),n.jsx("col",{style:{width:70}}),n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{minWidth:80,width:80}}),n.jsx("col",{style:{minWidth:120,width:120}})]}),n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:"#"}),n.jsx(a.Table.Th,{children:"Column Name"}),n.jsx(a.Table.Th,{}),n.jsx(a.Table.Th,{}),n.jsx(a.Table.Th,{children:"Type"}),n.jsx(a.Table.Th,{children:"Nullable"}),n.jsx(a.Table.Th,{children:"Default Value"})]})}),n.jsx(a.Table.Tbody,{children:t.data.map(r=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:r.ordinal_position}),n.jsx(a.Table.Td,{children:r.column_name}),n.jsx(a.Table.Td,{children:n.jsx(Mr,{value:r.column_comment})}),n.jsx(a.Table.Td,{children:n.jsx(JI,{column:r})}),n.jsx(a.Table.Td,{children:r.column_type}),n.jsx(a.Table.Td,{children:r.is_nullable}),n.jsx(a.Table.Td,{children:n.jsx(Mr,{value:r.column_default})})]},r.column_name))})]})}),tM=k.observer(({dataSource:e})=>{const{indexes:t}=e.dbInfo,r=t.data;return n.jsxs(a.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{width:150}}),n.jsx("col",{style:{width:150}}),n.jsx("col",{style:{width:250}})]}),n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:"Index Length"}),n.jsx(a.Table.Th,{children:"Index Name"}),n.jsx(a.Table.Th,{children:"Index Algorithm"}),n.jsx(a.Table.Th,{children:"Unique"}),n.jsx(a.Table.Th,{children:"Column Name"})]})}),n.jsx(a.Table.Tbody,{children:r.map(s=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:s.index_length}),n.jsx(a.Table.Td,{children:s.index_name}),n.jsx(a.Table.Td,{children:s.index_algorithm}),n.jsx(a.Table.Td,{children:s.is_unique?"YES":"NO"}),n.jsx(a.Table.Td,{children:s.column_name})]},s.index_name))})]})}),nM=k.observer(({dataSource:e})=>{const{indexes:t}=e.dbInfo,r=t.data;return n.jsxs(a.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{minWidth:300}}),n.jsx("col",{style:{width:150}}),n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{width:100}}),n.jsx("col",{style:{width:100}})]}),n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:"Index Name"}),n.jsx(a.Table.Th,{children:"Index Algorithm"}),n.jsx(a.Table.Th,{children:"Unique"}),n.jsx(a.Table.Th,{children:"Definition"}),n.jsx(a.Table.Th,{children:"Condition"}),n.jsx(a.Table.Th,{children:"Comment"})]})}),n.jsx(a.Table.Tbody,{children:r.map(s=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:s.index_name}),n.jsx(a.Table.Td,{children:s.index_algorithm}),n.jsx(a.Table.Td,{children:s.is_unique?"YES":"NO"}),n.jsx(a.Table.Td,{children:n.jsx(Mr,{value:s.index_definition})}),n.jsx(a.Table.Td,{children:n.jsx(Mr,{value:s.condition})}),n.jsx(a.Table.Td,{children:n.jsx(Mr,{value:s.comment})})]},s.index_name))})]})}),rM=k.observer(({dataSource:e})=>{const{indexes:t}=e.dbInfo;return t.loading||t.empty?null:e.type===J.MySQL?n.jsx(tM,{dataSource:e}):e.type===J.Postgresql?n.jsx(nM,{dataSource:e}):null}),sM=k.observer(({dataSource:e})=>n.jsxs(a.Stack,{gap:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[n.jsx(Ie,{children:n.jsx(eM,{dataSource:e})}),n.jsx(Ie,{children:n.jsx(rM,{dataSource:e})})]}));function iM({table_type:e}){return e==="VIEW"?n.jsx(C.IconEye,{size:14}):e==="BASE TABLE"?n.jsx(C.IconTable,{size:14}):null}const aM=k.observer(({dataSource:e})=>{const t=e.dbInfo,{tables:r}=t;return r.loading?n.jsx(Cg,{height:"24px",lastWidth:"50%",count:15}):n.jsx(a.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(r.data).map(([s,i])=>n.jsx(a.NavLink,{label:s,title:s,leftSection:n.jsx(C.IconDatabase,{size:14}),defaultOpened:t.table_schema===s,pl:0,childrenOffset:14,children:i.map(o=>n.jsx(a.NavLink,{label:o.table_name,title:o.table_name,leftSection:n.jsx(iM,{table_type:o.table_type}),onClick:()=>{t.setKeywords(s,o.table_name)},active:t.table_name===o.table_name},o.table_name))},s))})}),oM=({visible:e})=>n.jsx(a.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:n.jsx(a.LoadingOverlay,{visible:e})}),lM=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],cM={section:{"&[data-position=left]":{width:"70px",textAlign:"center"}},input:{paddingLeft:"70px"}},uM=k.observer(({dataSource:e})=>{const{t}=_.useTranslation(),{tableData:r}=e.dbInfo;return n.jsxs(a.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(a.Group,{justify:"flex-start",children:[r.maxPage>1&&n.jsx(a.Pagination,{size:"sm",value:r.page,onChange:r.setPage,total:r.maxPage,withEdges:r.maxPage>7,styles:{control:{height:"30px"}}}),n.jsx(a.Select,{leftSection:n.jsx(a.Text,{ta:"center",c:"dimmed",size:"14px",children:t("common.pagination.page_size")}),size:"xs",styles:cM,data:lM,value:String(r.limit),onChange:s=>r.setLimit(Number(s)),comboboxProps:{zIndex:340}})]}),n.jsx(a.Group,{justify:"flex-end",children:n.jsx(a.Text,{c:"dimmed",my:0,size:"14px",children:t("common.pagination.total_rows",{total:r.total})})})]})}),dM=k.observer(({dataSource:e})=>{const t=e.dbInfo.tableData;return t.maxPage===0?n.jsx(a.Text,{mt:20,c:"red",size:"md",ta:"center",ff:"monospace",children:"This table is empty"}):t.error?n.jsx(a.Text,{mt:20,c:"red",size:"md",ta:"center",ff:"monospace",children:t.error}):t.page===1&&t.loading?n.jsx(oM,{visible:!0}):n.jsxs(Ie,{children:[n.jsx(uM,{dataSource:e}),n.jsxs(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(a.LoadingOverlay,{visible:t.loading,overlayProps:{blur:2}}),n.jsx(jg,{data:t.data})]})]})}),pM={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},hM=k.observer(({dataSource:e})=>{const{t}=_.useTranslation(),r=e.dbInfo;return f.useEffect(()=>{r.loadTablesIfEmpty()},[r]),r.tables.error?n.jsx(a.Text,{c:"red",size:"md",ta:"center",ff:"monospace",children:r.tables.error}):n.jsxs(a.Flex,{sx:{height:"100%"},children:[n.jsx(a.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:n.jsx(Ie,{children:n.jsx(aM,{dataSource:e})})}),n.jsxs(a.Tabs,{defaultValue:"structure",styles:pM,children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"structure",leftSection:n.jsx(C.IconColumns,{size:14}),children:t("data_source.table_structure_short")}),n.jsx(a.Tabs.Tab,{value:"data",leftSection:n.jsx(C.IconDatabase,{size:14}),children:t("data.label")})]}),n.jsx(a.Tabs.Panel,{value:"structure",children:n.jsx(sM,{dataSource:e})}),n.jsx(a.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:n.jsx(dM,{dataSource:e})})]})]})}),gM={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"}},Sg=k.observer(({dataSource:e,triggerButtonProps:t={}})=>{const{t:r}=_.useTranslation(),[s,i]=f.useState(!1),{type:o}=e;return o==="http"||o==="merico_metric_system"?null:n.jsxs(n.Fragment,{children:[n.jsx(a.Modal,{opened:s,onClose:()=>i(!1),title:n.jsxs(a.Group,{justify:"space-between",sx:{flexGrow:1},children:[n.jsx(a.Text,{size:"sm",fw:500,children:r("data_source.explorer")}),n.jsxs(a.Group,{gap:7,children:[n.jsx(a.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),n.jsx(a.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",styles:gM,children:n.jsx(a.Box,{sx:{height:"calc(100vh - 220px)"},children:n.jsx(hM,{dataSource:e})})}),n.jsx(a.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:r("data_source.see_table_structure")})]})}),Tg={http:"HTTP",mysql:"MySQL",postgresql:"PostgreSQL",merico_metric_system:"指标系统"},fM=({option:e,...t})=>{const{label:r,type:s}=e;return s===J.Transform?n.jsxs(a.Group,{className:"transform-query-option",justify:"flex-start",...t,sx:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}},children:[n.jsx(C.IconVectorTriangle,{size:14,color:"#228be6"}),n.jsx(a.Text,{size:"sm",c:"blue",children:r})]}):n.jsxs(a.Group,{justify:"space-between",...t,sx:{flexGrow:1},children:[n.jsx(a.Text,{size:"sm",children:r}),n.jsx(a.Text,{size:"sm",children:Tg[s]})]})},kg=k.observer(({queryModel:e,size:t="sm"})=>{const{t:r}=_.useTranslation(),s=se(),{data:i=[],loading:o}=Y.useRequest(ba,{refreshDeps:[]},[]),l=f.useMemo(()=>{const p=i.map(h=>({label:h.key,value:h.key,type:h.type}));return p.push({label:r("query.transform.data_source"),value:J.Transform,type:J.Transform}),p},[i]),c=f.useMemo(()=>l.reduce((p,h)=>(p[h.value]=h.type,p),{}),[l]),u=p=>{p!==null&&(e.setKey(p),e.setType(c[p]))},d=f.useMemo(()=>s.datasources.find({type:e.type,key:e.key}),[s,e.type,e.key]);return n.jsx(a.Select,{size:t,data:l,label:n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Box,{children:r("data_source.label")}),d&&n.jsx(Sg,{dataSource:d,triggerButtonProps:{size:"compact-xs",px:10}})]}),renderOption:fM,rightSection:d?n.jsx(a.Text,{size:"xs",c:"dimmed",children:Tg[d.type]??d.type}):void 0,rightSectionWidth:85,maxDropdownHeight:500,styles:{root:{flex:1,minWidth:"300px"},label:{display:"block"},section:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:o,value:e.key,onChange:u})}),xM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),[r,s]=f.useState(e.name);f.useEffect(()=>{s(e.name)},[e.name]);const i=f.useMemo(()=>e.conditionOptionsWithInvalidRunbys.optionGroups.map(l=>({group:t(l.group),items:l.items})),[e.conditionOptionsWithInvalidRunbys.optionGroups]);return n.jsx(a.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:n.jsxs(a.Stack,{gap:10,sx:{width:"100%"},children:[n.jsx(a.Divider,{mb:-10,variant:"dashed",label:t("query.basics"),labelPosition:"center"}),n.jsx(a.TextInput,{placeholder:t("query.name_description"),label:t("query.name"),required:!0,sx:{flex:1},value:r,onChange:o=>{s(o.currentTarget.value)},rightSection:n.jsx(a.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>e.setName(r),disabled:r===e.name,children:n.jsx(C.IconDeviceFloppy,{size:16})}),onBlur:()=>{e.setName(r)}}),n.jsx(kg,{queryModel:e}),n.jsx(a.Divider,{mt:10,mb:-10,variant:"dashed",label:t("query.conditions"),labelPosition:"center"}),n.jsx(a.MultiSelect,{label:t("query.run_by_condition.label"),description:t("query.run_by_condition.description"),placeholder:t("query.run_by_condition.unset"),data:i,value:[...e.run_by],onChange:e.setRunBy,renderOption:cd,maxDropdownHeight:500}),e.typedAsHTTP&&n.jsx(a.MultiSelect,{label:t("query.re_run_condition.label"),placeholder:t("query.re_run_condition.label"),data:i,value:[...e.config.react_to],onChange:e.config.setReactTo,renderOption:cd,maxDropdownHeight:500}),n.jsx(a.Divider,{mt:20,mb:10,variant:"dashed"}),n.jsx(ZI,{queryModel:e})]})})});function mM({content:e}){return n.jsxs(a.HoverCard,{width:"60vw",shadow:"md",zIndex:340,children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.ActionIcon,{size:16,color:"blue",variant:"subtle",children:n.jsx(C.IconEye,{})})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsx(Dt.CodeHighlight,{language:"sql",withCopyButton:!1,code:e})})]})}const bM=k.observer(()=>{const t=[...se().globalSQLSnippets.list];return t.length===0?null:n.jsxs(a.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fz:"sm",highlightOnHover:!0,children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{children:"Key"}),n.jsx(a.Table.Th,{children:"Value"})]})}),n.jsx(a.Table.Tbody,{children:t.map(r=>{const{id:s,content:i}=r;return n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:s}),n.jsx(a.Table.Td,{width:200,children:n.jsx(mM,{content:i})})]},s)})})]})}),yM=`
500
500
  -- You may reference query variables in SQL or VizConfig.
501
501
  SELECT *
502
502
  FROM commit
@@ -514,5 +514,5 @@ WHERE
514
514
  `)},vM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation();return e.typedAsHTTP?n.jsxs(a.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"pre_process",children:t("query.build_request")}),n.jsx(a.Tabs.Tab,{value:"post_process",children:t("query.process_result")}),n.jsx(Ko,{})]}),n.jsx(a.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:n.jsx(Sn,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:zg.pre})}),n.jsx(a.Tabs.Panel,{value:"post_process",p:"sm",children:n.jsx(Sn,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:zg.post})})]}):null}),Ig=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),r=se().editor,s=l=>{if(l.type==="filter"){r.setPath(["_FILTERS_",l.id]);return}if(l.type==="panel"){const c=l.views[0].id;r.setPath(["_VIEWS_",c,"_PANELS_",l.id,"_TABS_","Data"]);return}},i=l=>{r.setPath(["_VIEWS_",l])},o=e.usage;return n.jsxs(a.Table,{highlightOnHover:!0,layout:"fixed",styles:{table:{fontSize:"14px"}},children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:100},children:t("common.type")}),n.jsx(a.Table.Th,{style:{width:"calc(50% - 50px)"},children:t("common.name")}),n.jsx(a.Table.Th,{children:t("query.usage.in_views")})]})}),n.jsx(a.Table.Tbody,{children:o.map(l=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:t(l.type_label)}),n.jsx(a.Table.Td,{children:n.jsx(a.Anchor,{size:"sm",component:"button",type:"button",onClick:()=>s(l),children:l.label})}),n.jsx(a.Table.Td,{children:n.jsxs(a.Stack,{align:"flex-start",justify:"flex-start",gap:2,children:[l.views.map(c=>n.jsx(a.Anchor,{size:"sm",component:"button",type:"button",onClick:()=>i(c.id),children:n.jsx(a.Box,{children:c.label})},c.id)),l.views.length===0&&n.jsx(a.Box,{children:"--"})]})})]},l.id))})]})}),_M=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),r=f.useMemo(()=>v.groupBy(e.dependencies,"type"),[e.dependencies]),s=f.useMemo(()=>e.dependencies.some(o=>!o.valid),[e.dependencies]),i=e.dependencies.length>0;return i?n.jsxs(a.HoverCard,{withinPortal:!0,zIndex:340,shadow:"md",disabled:!i,children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.Button,{size:"xs",variant:"subtle",color:s?"red":"green",disabled:!i,leftSection:s?n.jsx(C.IconAlertTriangle,{size:16}):n.jsx(C.IconDiscountCheckFilled,{size:16}),children:t("query.dependency.label")})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsx(a.List,{spacing:"md",size:"sm",listStyleType:"none",children:Object.entries(r).map(([o,l])=>n.jsxs(a.List.Item,{children:[n.jsx(a.Text,{size:"sm",fw:"bold",ff:"monospace",children:t(`${o}.label`)}),n.jsx(a.List,{withPadding:!0,size:"sm",sx:{fontFamily:"monospace",svg:{verticalAlign:"middle"}},children:l.map(c=>n.jsx(a.List.Item,{icon:n.jsx(a.Box,{sx:{path:{fill:c.valid?"rgb(18, 184, 134)":"rgb(250, 82, 82)"}},children:n.jsx(C.IconPointFilled,{size:12})}),children:c.key},c.key))})]},o))})})]}):n.jsx(a.Tooltip,{label:t("query.dependency.has_none"),children:n.jsx(a.Button,{size:"xs",variant:"subtle",color:"gray",leftSection:n.jsx(C.IconHierarchy,{size:16,style:{transform:"rotate(180deg)"}}),sx:{transform:"none !important"},children:t("query.dependency.label")})})}),jM="SELECT 1",wM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),r=e.config,[s,i]=f.useState(r.sql),o=()=>{r.setSQL(s)},l=()=>{i(r.sql)},c=()=>{i(jM)};f.useEffect(()=>{i(r.sql)},[r.sql]);const u=s!==r.sql;return n.jsxs(a.Stack,{gap:4,sx:{height:"100%"},children:[n.jsxs(a.Group,{mb:6,justify:"space-between",sx:{flexShrink:0,flexGrow:0},children:[n.jsx(a.Group,{justify:"flex-start",children:n.jsx(_M,{queryModel:e})}),n.jsxs(a.Group,{justify:"flex-end",children:[n.jsx(a.Button,{onClick:c,size:"xs",variant:"default",leftSection:n.jsx(C.IconPlayerSkipBack,{size:16}),children:t("common.actions.reset_to_default")}),n.jsx(a.Button,{onClick:l,color:"red",size:"xs",disabled:!u,leftSection:n.jsx(C.IconRecycle,{size:16}),children:t("common.actions.revert_changes")}),n.jsx(a.Button,{color:"green",size:"xs",onClick:o,disabled:!u,leftSection:n.jsx(C.IconDeviceFloppy,{size:16}),children:t("common.actions.save_changes")})]})]}),n.jsx(fa,{height:"100%",value:s,onChange:i,theme:"sql-dark",defaultLanguage:"sql"})]})}),CM=({value:e,height:t="200px",defaultLanguage:r="sql"})=>n.jsx(ht,{className:"preview-sql-in-monaco-editor",height:t,defaultLanguage:r,value:e,onChange:void 0,theme:"vs-light",options:{lineNumbers:"on",folding:!0,lineDecorationsWidth:20,wordWrap:"on",minimap:{enabled:!1},readOnly:!0}}),SM=k.observer(({value:e})=>{const r=Te().payloadForSQL,s=f.useMemo(()=>Hs(e,r),[e,r]);return n.jsx(CM,{height:"100%",value:s})}),Mg={pre:["function process_request({ context, filters, sql }, utils) {"," // modify and return sql"," return sql","}"].join(`
515
515
  `),post:["function process_result(data, utils, state) {"," // process data and return the result"," return data","}"].join(`
516
516
  `)},TM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation();if(!e.typedAsSQL)return null;const r=e.config;return n.jsxs(a.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"Edit",children:n.jsx(a.Group,{gap:14,justify:"space-between",children:t("query.edit_sql")})}),n.jsx(a.Tabs.Tab,{value:"Preview",children:t("query.preview_sql")}),n.jsx(a.Tabs.Tab,{value:"pre_process",children:t("query.process_request")}),n.jsx(a.Tabs.Tab,{value:"post_process",children:t("query.process_result")}),n.jsx(Ko,{}),e.datasource&&n.jsx(Sg,{dataSource:e.datasource})]}),n.jsx(a.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:n.jsx(wM,{queryModel:e})}),n.jsx(a.Tabs.Panel,{value:"Preview",p:0,pl:4,children:n.jsx(SM,{value:r.sql})}),n.jsx(a.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:n.jsx(Sn,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:Mg.pre})}),n.jsx(a.Tabs.Panel,{value:"post_process",p:"sm",children:n.jsx(Sn,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:Mg.post})})]})}),kM={pre:["function transform(queries, state, utils) {"," // use queries & dashboar state to build new data"," const data = []"," return data","}"].join(`
517
- `),post:""},DM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),r=re();if(!e.isTransform)return null;const s=e.config;return n.jsxs(a.Stack,{py:20,px:20,sx:{height:"100%"},children:[n.jsx(a.Text,{size:"sm",children:t("query.transform.guide.pick_queries")}),n.jsx(a.MultiSelect,{data:r.queries.optionsWithoutTransform,value:[...s.dep_query_ids],onChange:s.setDependantQueryIDs,maxDropdownHeight:800}),n.jsx(a.Text,{size:"sm",children:t("query.transform.guide.write_function")}),n.jsx(a.Box,{sx:{flexGrow:1},children:n.jsx(Sn,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:kM.pre})})]})}),Er={height:"calc(100% - 44px)",padding:0},zM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),r=re(),s=f.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),[i,o]=f.useState(s);f.useEffect(()=>{o(u=>u!=="Configurations"&&s==="Configurations"?"Configurations":u)},[s]);const c=r.findQueryUsage(e.id).length===0;return n.jsxs(a.Tabs,{value:i,onChange:o,defaultValue:s,orientation:"horizontal",keepMounted:!1,sx:{height:"100vh"},children:[n.jsxs(a.Tabs.List,{grow:!0,children:[n.jsx(a.Tabs.Tab,{value:"Configurations",children:t("query.configurations")}),e.typedAsSQL&&n.jsx(a.Tabs.Tab,{value:"SQL",children:t("query.request")}),e.typedAsHTTP&&n.jsx(a.Tabs.Tab,{value:"HTTP",children:t("query.request")}),e.isTransform&&n.jsx(a.Tabs.Tab,{value:"Transform",children:t("query.transform.label")}),n.jsx(a.Tabs.Tab,{value:"Data",disabled:!e.canPreviewData,children:n.jsx(a.Tooltip,{label:e.guideToPreviewData,disabled:e.canPreviewData,withinPortal:!0,children:n.jsx(a.Text,{size:"sm",children:t("data.preview_data")})})}),n.jsx(a.Tabs.Tab,{value:"Usage",disabled:c,children:n.jsx(a.Tooltip,{label:t("query.usage.unused_description"),disabled:!c,withinPortal:!0,children:n.jsx(a.Text,{size:"sm",children:t("query.usage.label")})})})]}),n.jsx(a.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:n.jsx(xM,{queryModel:e})}),e.typedAsSQL&&n.jsx(a.Tabs.Panel,{value:"SQL",sx:Er,children:n.jsx(a.Stack,{sx:{height:"100%"},children:n.jsx(TM,{queryModel:e})})}),e.typedAsHTTP&&n.jsx(a.Tabs.Panel,{value:"HTTP",sx:Er,children:n.jsx(a.Stack,{sx:{height:"100%"},children:n.jsx(vM,{queryModel:e})})}),e.isTransform&&n.jsx(a.Tabs.Panel,{value:"Transform",sx:Er,children:n.jsx(a.Stack,{sx:{height:"100%"},children:n.jsx(DM,{queryModel:e})})}),n.jsx(a.Tabs.Panel,{value:"Data",sx:{...Er,overflow:"hidden"},children:n.jsx(Wo,{id:e.id,moreActions:null,refreshOnMount:!0})}),n.jsx(a.Tabs.Panel,{value:"Usage",py:"sm",px:"md",sx:{...Er,overflow:"hidden"},children:n.jsx(Ig,{queryModel:e})})]})}),IM=({width:e,height:t})=>n.jsxs("svg",{width:e,height:t,viewBox:"0 0 36 36",fill:"none",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.5 10.5C7.10217 10.5 6.72064 10.658 6.43934 10.9393C6.15804 11.2206 6 11.6022 6 12V28.5C6 28.8978 6.15804 29.2794 6.43934 29.5607C6.72064 29.842 7.10218 30 7.5 30H24C24.3978 30 24.7794 29.842 25.0607 29.5607C25.342 29.2794 25.5 28.8978 25.5 28.5V19.5C25.5 18.6716 26.1716 18 27 18C27.8284 18 28.5 18.6716 28.5 19.5V28.5C28.5 29.6935 28.0259 30.8381 27.182 31.682C26.3381 32.5259 25.1935 33 24 33H7.5C6.30653 33 5.16193 32.5259 4.31802 31.682C3.47411 30.8381 3 29.6935 3 28.5V12C3 10.8065 3.47411 9.66193 4.31802 8.81802C5.16193 7.97411 6.30653 7.5 7.5 7.5H16.5C17.3284 7.5 18 8.17157 18 9C18 9.82843 17.3284 10.5 16.5 10.5H7.5Z",fill:"#3D3E45"}),n.jsx("path",{d:"M32.8862 3.92582C32.8135 3.75021 32.7061 3.5856 32.5638 3.44253C32.5617 3.4404 32.5596 3.43828 32.5575 3.43616C32.2863 3.16658 31.9126 3 31.5 3H22.5C21.6716 3 21 3.67157 21 4.5C21 5.32843 21.6716 6 22.5 6H27.8787L13.9393 19.9393C13.3536 20.5251 13.3536 21.4749 13.9393 22.0607C14.5251 22.6464 15.4749 22.6464 16.0607 22.0607L30 8.12132V13.5C30 14.3284 30.6716 15 31.5 15C32.3284 15 33 14.3284 33 13.5V4.5C33 4.29662 32.9595 4.10268 32.8862 3.92582Z",fill:"#3D3E45"})]}),Eg=({width:e,height:t,color:r="#FFFFFF"})=>n.jsxs("svg",{viewBox:"0 0 36 36",fill:"none",width:e,height:t,children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24.6931 20.547C26.1129 19.5516 26.113 17.4483 24.6931 16.4529L16.9351 11.0141C15.2783 9.85255 13 11.0377 13 13.0611L13 23.9389C13 25.9623 15.2783 27.1474 16.9351 25.9859L24.6931 20.547ZM16 14.0223L22.387 18.5L16 22.9777L16 14.0223Z",fill:r}),n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18 1.5C8.8873 1.5 1.5 8.8873 1.5 18C1.5 27.1127 8.8873 34.5 18 34.5C27.1127 34.5 34.5 27.1127 34.5 18C34.5 8.8873 27.1127 1.5 18 1.5ZM4.5 18C4.5 10.5442 10.5442 4.5 18 4.5C25.4558 4.5 31.5 10.5442 31.5 18C31.5 25.4558 25.4558 31.5 18 31.5C10.5442 31.5 4.5 25.4558 4.5 18Z",fill:r})]}),Pg=({width:e,height:t,color:r="#EB1212"})=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",width:e,height:t,children:[n.jsx("path",{d:"M6.66665 6.66699C7.03484 6.66699 7.33331 6.96547 7.33331 7.33366V11.3337C7.33331 11.7018 7.03484 12.0003 6.66665 12.0003C6.29846 12.0003 5.99998 11.7018 5.99998 11.3337V7.33366C5.99998 6.96547 6.29846 6.66699 6.66665 6.66699Z",fill:r}),n.jsx("path",{d:"M9.99998 11.3337V7.33366C9.99998 6.96547 9.7015 6.66699 9.33331 6.66699C8.96512 6.66699 8.66665 6.96547 8.66665 7.33366V11.3337C8.66665 11.7018 8.96512 12.0003 9.33331 12.0003C9.7015 12.0003 9.99998 11.7018 9.99998 11.3337Z",fill:r}),n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66665 3.33366V2.66699C4.66665 2.13656 4.87736 1.62785 5.25243 1.25278C5.62751 0.877706 6.13621 0.666992 6.66665 0.666992H9.33331C9.86375 0.666992 10.3725 0.877706 10.7475 1.25278C11.1226 1.62785 11.3333 2.13656 11.3333 2.66699V3.33366H14C14.3682 3.33366 14.6666 3.63214 14.6666 4.00033C14.6666 4.36852 14.3682 4.66699 14 4.66699H13.3333V13.3337C13.3333 13.8641 13.1226 14.3728 12.7475 14.7479C12.3725 15.1229 11.8637 15.3337 11.3333 15.3337H4.66665C4.13621 15.3337 3.62751 15.1229 3.25243 14.7479C2.87736 14.3728 2.66665 13.8641 2.66665 13.3337V4.66699H1.99998C1.63179 4.66699 1.33331 4.36852 1.33331 4.00033C1.33331 3.63214 1.63179 3.33366 1.99998 3.33366H4.66665ZM6.19524 2.19559C6.32027 2.07056 6.48984 2.00033 6.66665 2.00033H9.33331C9.51012 2.00033 9.67969 2.07056 9.80472 2.19559C9.92974 2.32061 9.99998 2.49018 9.99998 2.66699V3.33366H5.99998V2.66699C5.99998 2.49018 6.07022 2.32061 6.19524 2.19559ZM3.99998 4.66699V13.3337C3.99998 13.5105 4.07022 13.68 4.19524 13.8051C4.32027 13.9301 4.48984 14.0003 4.66665 14.0003H11.3333C11.5101 14.0003 11.6797 13.9301 11.8047 13.8051C11.9297 13.68 12 13.5105 12 13.3337V4.66699H3.99998Z",fill:r})]}),MM=({width:e,height:t})=>n.jsxs("svg",{viewBox:"0 0 18 18",fill:"none",width:e,height:t,children:[n.jsx("path",{d:"M7.5 3.75C7.5 2.92157 8.17157 2.25 9 2.25C9.82843 2.25 10.5 2.92157 10.5 3.75C10.5 4.57843 9.82843 5.25 9 5.25C8.17157 5.25 7.5 4.57843 7.5 3.75Z",fill:"#3D3E45"}),n.jsx("path",{d:"M7.5 9C7.5 8.17157 8.17157 7.5 9 7.5C9.82843 7.5 10.5 8.17157 10.5 9C10.5 9.82843 9.82843 10.5 9 10.5C8.17157 10.5 7.5 9.82843 7.5 9Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9 12.75C8.17157 12.75 7.5 13.4216 7.5 14.25C7.5 15.0784 8.17157 15.75 9 15.75C9.82843 15.75 10.5 15.0784 10.5 14.25C10.5 13.4216 9.82843 12.75 9 12.75Z",fill:"#3D3E45"})]}),EM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),r=se(),s=re(),o=s.findQueryUsage(e.id).length>0,l=dt.useModals(),c=()=>{l.openConfirmModal({title:`${t("query.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{s.queries.removeQuery(e.id),r.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return o?n.jsx(a.Tooltip,{label:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"bottom-end",children:n.jsx(a.Button,{leftSection:n.jsx(Pg,{width:14,height:14,color:"gray"}),variant:"subtle",color:"gray",onClick:u=>{u.stopPropagation()},children:"删除查询"})}):n.jsx(a.Menu.Item,{leftSection:n.jsx(Pg,{width:14,height:14}),color:"red",onClick:c,children:"删除查询"})}),PM=k.observer(({queryModel:e})=>n.jsxs(a.Menu,{shadow:"md",width:120,trigger:"hover",children:[n.jsx(a.Menu.Target,{children:n.jsx(a.ActionIcon,{variant:"subtle","aria-label":"Settings",children:n.jsx(MM,{width:18,height:18})})}),n.jsx(a.Menu.Dropdown,{children:n.jsx(EM,{queryModel:e})})]})),AM={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 LM({data:e}){const t=f.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const s=Re.createColumnHelper();return Object.keys(e[0]).map(i=>s.accessor(i,{cell:o=>o.getValue()}))},[e]),r=Re.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Re.getCoreRowModel()});return e.length===0?n.jsx(a.Box,{sx:{height:"5em"}}):n.jsx(Ie,{children:n.jsxs(a.Table,{sx:AM,stickyHeader:!0,stickyHeaderOffset:0,children:[n.jsx(a.Table.Thead,{style:{backgroundColor:"#F9F9FA"},children:r.getHeaderGroups().map(s=>n.jsx(a.Table.Tr,{children:s.headers.map(i=>n.jsxs(a.Table.Th,{style:{width:i.getSize()},children:[i.isPlaceholder?null:Re.flexRender(i.column.columnDef.header,i.getContext()),n.jsx(a.ActionIcon,{variant:"subtle",onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:n.jsx(C.IconArrowBarToRight,{})})]},i.id))},s.id))}),n.jsx(a.Table.Tbody,{children:r.getRowModel().rows.map(s=>n.jsx(a.Table.Tr,{children:s.getVisibleCells().map(i=>n.jsx(a.Table.Td,{children:n.jsx(Ie,{children:typeof i.getValue()=="object"?n.jsx("pre",{children:JSON.stringify(i.getValue(),null,2)}):Re.flexRender(i.column.columnDef.cell,i.getContext())})},i.id))},s.id))})]})})}const OM=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],VM={root:{width:"150px"},section:{"&[data-position=left]":{width:"70px",textAlign:"center"}},input:{paddingLeft:"70px",paddingRight:0}},BM=({data:e,page:t,setPage:r,limit:s,setLimit:i})=>{const{t:o}=_.useTranslation(),l=e.length,c=Math.ceil(l/s),u=p=>{p&&(r(1),i(Number(p)))};if(l===0)return null;const d=c===1&&l<=10;return n.jsxs(a.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(a.Group,{justify:"flex-start",children:[!d&&n.jsx(a.Select,{leftSection:n.jsx(a.Text,{ta:"center",c:"dimmed",size:"xs",children:o("common.pagination.page_size")}),size:"xs",styles:VM,data:OM,value:String(s),onChange:u}),c>1&&n.jsx(a.Pagination,{size:"sm",value:t,onChange:r,total:c,withEdges:c>7,styles:{control:{height:"30px"}},color:"red"})]}),n.jsx(a.Group,{justify:"flex-end",children:n.jsx(a.Text,{c:"dimmed",my:0,size:"14px",children:o("common.pagination.total_rows",{total:l})})})]})},qM=xd(({data:e,loading:t})=>{const[r,s]=f.useState(1),[i,o]=f.useState(20),l=f.useMemo(()=>{const c=(r-1)*i,u=c+i;return e.slice(c,u)},[e,r,i]);return n.jsx(Ie,{children:n.jsxs(a.Stack,{gap:10,styles:{root:{height:"100%",overflow:"hidden"}},children:[n.jsx(BM,{data:e,page:r,setPage:s,limit:i,setLimit:o}),n.jsxs(a.Box,{sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(a.LoadingOverlay,{visible:t,overlayProps:{blur:2}}),n.jsx(LM,{data:l})]})]})})}),NM=k.observer(({queryModel:e})=>{const{state:t,error:r,metricQueryPayloadError:s,stateMessage:i}=e;return t==="loading"?null:r?n.jsx(a.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:r}):s?n.jsx(a.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:s}):i?n.jsx(a.Text,{size:"sm",mt:10,c:"gray",ta:"center",children:i}):null}),$M=k.observer(({queryModel:e})=>{_.useTranslation();const{data:t,state:r}=e,s=r==="loading",i=f.useCallback(()=>{e.fetchData(!0)},[e.fetchData]),o=()=>{gh(e.name,e.data)};f.useEffect(()=>{i()},[i]);const l=!Array.isArray(t)||t.length===0;return n.jsxs(a.Stack,{gap:0,sx:{minHeight:"250px",maxHeight:"calc(50vh - 48px)",flexGrow:1,flexShrink:0,background:"#F9F9FA"},children:[n.jsxs(a.Group,{justify:"space-between",py:7,px:8,children:[n.jsx(a.Text,{size:"sm",fw:500,children:"查询结果"}),n.jsx(a.Button,{size:"xs",variant:"transparent",color:"gray",leftSection:n.jsx(C.IconDownload,{size:16}),disabled:s||l,onClick:o,children:"下载查询结果"})]}),n.jsxs(a.Box,{sx:{position:"relative",flexGrow:1,overflow:"hidden"},children:[n.jsx(NM,{queryModel:e}),n.jsx(qM,{data:t,loading:s})]})]})}),GM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.24335 1.62305C7.50108 1.62305 7.71001 1.83198 7.71001 2.08971L7.71001 11.423C7.71001 11.6808 7.50108 11.8897 7.24335 11.8897C6.98561 11.8897 6.77668 11.6808 6.77668 11.423L6.77668 2.08971C6.77668 1.83198 6.98561 1.62305 7.24335 1.62305Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9.93845 9.4786C9.80779 9.4786 9.70045 9.43893 9.61645 9.3596C9.53712 9.2756 9.49745 9.17293 9.49745 9.0516L9.49745 5.0056C9.49745 4.88427 9.53712 4.78393 9.61645 4.7046C9.70045 4.6206 9.80312 4.5786 9.92445 4.5786L12.1995 4.5786C12.3208 4.5786 12.4211 4.61827 12.5005 4.6976C12.5845 4.77227 12.6265 4.87027 12.6265 4.9916C12.6265 5.09427 12.5845 5.18527 12.5005 5.2646C12.4211 5.34393 12.3208 5.3836 12.1995 5.3836L10.3725 5.3836V6.6156H11.8845C12.0058 6.6156 12.1061 6.65527 12.1855 6.7346C12.2695 6.80927 12.3115 6.90727 12.3115 7.0286C12.3115 7.13127 12.2695 7.22227 12.1855 7.3016C12.1061 7.38093 12.0058 7.4206 11.8845 7.4206H10.3725L10.3725 9.0516C10.3725 9.17293 10.3281 9.2756 10.2395 9.3596C10.1555 9.43893 10.0551 9.4786 9.93845 9.4786Z",fill:"#3D3E45"}),n.jsx("path",{d:"M3.34754 9.4786C3.21687 9.4786 3.10954 9.43893 3.02554 9.3596C2.94154 9.2756 2.89954 9.17293 2.89954 9.0516L2.89954 5.3836H1.80054C1.6792 5.3836 1.57654 5.34627 1.49254 5.2716C1.4132 5.19693 1.37354 5.09893 1.37354 4.9776C1.37354 4.85627 1.4132 4.7606 1.49254 4.6906C1.57654 4.61593 1.6792 4.5786 1.80054 4.5786H4.90854C5.02987 4.5786 5.1302 4.61593 5.20954 4.6906C5.29354 4.76527 5.33554 4.86327 5.33554 4.9846C5.33554 5.10593 5.29354 5.20393 5.20954 5.2786C5.1302 5.3486 5.02987 5.3836 4.90854 5.3836H3.80954L3.80954 9.0516C3.80954 9.17293 3.7652 9.2756 3.67654 9.3596C3.59254 9.43893 3.48287 9.4786 3.34754 9.4786Z",fill:"#3D3E45"})]}),FM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("g",{clipPath:"url(#clip0_245_10828)",children:n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.91663 1.16634C9.91663 0.844175 9.65546 0.583008 9.33329 0.583008C9.01113 0.583008 8.74996 0.844175 8.74996 1.16634V1.74967L5.24996 1.74967V1.16634C5.24996 0.844175 4.98879 0.583008 4.66663 0.583008C4.34446 0.583008 4.08329 0.844175 4.08329 1.16634V1.74967H2.91663C1.95013 1.74967 1.16663 2.53318 1.16663 3.49967L1.16663 11.6663C1.16663 12.6328 1.95013 13.4163 2.91663 13.4163L11.0833 13.4163C12.0498 13.4163 12.8333 12.6328 12.8333 11.6663L12.8333 3.49967C12.8333 2.53318 12.0498 1.74967 11.0833 1.74967H9.91663V1.16634ZM11.6666 5.24967V3.49967C11.6666 3.17751 11.4055 2.91634 11.0833 2.91634H9.91663V3.49967C9.91663 3.82184 9.65546 4.08301 9.33329 4.08301C9.01113 4.08301 8.74996 3.82184 8.74996 3.49967V2.91634L5.24996 2.91634V3.49967C5.24996 3.82184 4.98879 4.08301 4.66663 4.08301C4.34446 4.08301 4.08329 3.82184 4.08329 3.49967V2.91634L2.91663 2.91634C2.59446 2.91634 2.33329 3.17751 2.33329 3.49967L2.33329 5.24967L11.6666 5.24967ZM2.33329 6.41634L11.6666 6.41634L11.6666 11.6663C11.6666 11.9885 11.4055 12.2497 11.0833 12.2497L2.91663 12.2497C2.59446 12.2497 2.33329 11.9885 2.33329 11.6663V6.41634Z",fill:"#3D3E45"})}),n.jsx("defs",{children:n.jsx("clipPath",{id:"clip0_245_10828",children:n.jsx("rect",{width:"14",height:"14",fill:"white"})})})]}),QM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.11108 2.13932C2.78892 2.13932 2.52775 2.40049 2.52775 2.72266V10.8893C2.52775 11.2115 2.78892 11.4727 3.11108 11.4727H11.2778C11.5999 11.4727 11.8611 11.2115 11.8611 10.8893V2.72266C11.8611 2.40049 11.5999 2.13932 11.2778 2.13932H3.11108ZM1.36108 2.72266C1.36108 1.75616 2.14459 0.972656 3.11108 0.972656H11.2778C12.2442 0.972656 13.0278 1.75616 13.0278 2.72266V10.8893C13.0278 11.8558 12.2442 12.6393 11.2778 12.6393H3.11108C2.14459 12.6393 1.36108 11.8558 1.36108 10.8893V2.72266Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9.84418 8.37166C9.94816 8.37166 10.0348 8.40631 10.1041 8.47563C10.1734 8.54494 10.2081 8.63159 10.2081 8.73556C10.2081 8.8352 10.1734 8.91968 10.1041 8.989C10.0348 9.05398 9.94816 9.08647 9.84418 9.08647H7.63475C7.52211 9.08647 7.4333 9.05182 7.36832 8.9825C7.30334 8.91318 7.27084 8.82437 7.27084 8.71607C7.27084 8.60776 7.30983 8.51245 7.38781 8.43014L8.80445 6.91603C8.96474 6.74274 9.09038 6.56512 9.18135 6.38317C9.27666 6.20121 9.32432 6.04309 9.32432 5.90879C9.32432 5.69218 9.2615 5.51889 9.13587 5.38892C9.01023 5.25462 8.84344 5.18747 8.63549 5.18747C8.55318 5.18747 8.4687 5.20697 8.38206 5.24596C8.29541 5.28495 8.21094 5.3391 8.12862 5.40842C8.05064 5.47773 7.977 5.55788 7.90768 5.64885C7.85569 5.71817 7.80371 5.76149 7.75172 5.77882C7.69973 5.79615 7.65208 5.80481 7.60876 5.80481C7.51345 5.80481 7.42464 5.77016 7.34233 5.70084C7.26435 5.62719 7.22536 5.54271 7.22536 5.44741C7.22536 5.37376 7.24918 5.30228 7.29684 5.23296C7.34882 5.16365 7.41164 5.09216 7.48529 5.01852C7.59359 4.91021 7.7149 4.8149 7.8492 4.73259C7.98349 4.65028 8.12213 4.58746 8.26509 4.54414C8.40805 4.49648 8.54668 4.47266 8.68098 4.47266C8.97124 4.47266 9.22251 4.53114 9.43479 4.64811C9.6514 4.76075 9.81819 4.92321 9.93516 5.13549C10.0521 5.34343 10.1106 5.59037 10.1106 5.8763C10.1106 6.11457 10.0391 6.381 9.89617 6.67559C9.75754 6.96585 9.56909 7.23878 9.33081 7.49438L8.50837 8.37166H9.84418Z",fill:"#3D3E45"}),n.jsx("path",{d:"M5.49994 9.08647C5.37864 9.08647 5.279 9.04965 5.20102 8.976C5.12304 8.89802 5.08405 8.80271 5.08405 8.69007V5.62518L4.70065 5.90879C4.64 5.95644 4.56418 5.98027 4.47321 5.98027C4.36923 5.98027 4.27826 5.94128 4.20028 5.8633C4.1223 5.78532 4.08331 5.69218 4.08331 5.58387C4.08331 5.44524 4.15046 5.3326 4.28475 5.24596L5.22051 4.62212C5.26384 4.59179 5.31149 4.57013 5.36348 4.55713C5.4198 4.54414 5.47178 4.53764 5.51944 4.53764C5.64507 4.53764 5.74471 4.57663 5.81836 4.65461C5.89201 4.72826 5.92883 4.8214 5.92883 4.93404V8.69007C5.92883 8.80271 5.88768 8.89802 5.80536 8.976C5.72738 9.04965 5.62558 9.08647 5.49994 9.08647Z",fill:"#3D3E45"})]}),RM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M12.0334 5.64833C12.3099 5.64833 12.55 5.67744 12.7537 5.73565C12.9623 5.79386 13.1224 5.87632 13.2339 5.98303C13.3504 6.0849 13.4086 6.20859 13.4086 6.35412C13.4086 6.45113 13.3795 6.5433 13.3213 6.63061C13.263 6.71307 13.1782 6.7543 13.0666 6.7543C12.989 6.7543 12.9235 6.7446 12.8701 6.7252C12.8216 6.70094 12.778 6.67184 12.7392 6.63788C12.7004 6.60393 12.6543 6.5724 12.6009 6.54329C12.5524 6.51419 12.4772 6.49236 12.3754 6.47781C12.2783 6.45841 12.2056 6.44871 12.1571 6.44871C11.9097 6.44871 11.6987 6.50206 11.5241 6.60878C11.3543 6.7155 11.2233 6.86102 11.1311 7.04535C11.039 7.22482 10.9929 7.43341 10.9929 7.67109C10.9929 7.90393 11.039 8.11251 11.1311 8.29684C11.2282 8.47631 11.3591 8.61941 11.5241 8.72613C11.6938 8.83284 11.8879 8.8862 12.1061 8.8862C12.2274 8.8862 12.3317 8.87893 12.419 8.86437C12.5063 8.84982 12.5791 8.82799 12.6373 8.79889C12.7052 8.76008 12.7658 8.71885 12.8192 8.6752C12.8726 8.63154 12.9526 8.60971 13.0593 8.60971C13.1854 8.60971 13.2824 8.65094 13.3504 8.7334C13.4183 8.81102 13.4522 8.90803 13.4522 9.02445C13.4522 9.14572 13.3843 9.25728 13.2485 9.35915C13.1127 9.45616 12.9332 9.5362 12.7101 9.59926C12.4918 9.65747 12.2541 9.68657 11.997 9.68657C11.6138 9.68657 11.2815 9.59926 11.0002 9.42463C10.7188 9.24516 10.5005 9.00262 10.3453 8.69702C10.1949 8.39143 10.1198 8.04945 10.1198 7.67109C10.1198 7.27333 10.1998 6.92408 10.3599 6.62333C10.5248 6.31774 10.7504 6.08005 11.0366 5.91027C11.3276 5.73565 11.6599 5.64833 12.0334 5.64833Z",fill:"#3D3E45"}),n.jsx("path",{d:"M7.74826 5.64833C8.08781 5.64833 8.39099 5.73565 8.65778 5.91027C8.92942 6.08005 9.14285 6.31531 9.29807 6.61606C9.45815 6.9168 9.53819 7.26606 9.53819 7.66382C9.53819 8.06158 9.45815 8.41326 9.29807 8.71885C9.14285 9.0196 8.93184 9.25728 8.66505 9.43191C8.40311 9.60169 8.10722 9.68657 7.77737 9.68657C7.58334 9.68657 7.40143 9.65505 7.23166 9.59199C7.06188 9.52893 6.91151 9.44889 6.78054 9.35187C6.65442 9.25486 6.55498 9.15784 6.48222 9.06083C6.41431 8.95896 6.38035 8.87408 6.38035 8.80617L6.60591 8.71158V9.24273C6.60591 9.36885 6.56468 9.47557 6.48222 9.56288C6.39976 9.64534 6.29547 9.68657 6.16935 9.68657C6.04323 9.68657 5.93894 9.64534 5.85647 9.56288C5.77401 9.48042 5.73278 9.3737 5.73278 9.24273V4.67333C5.73278 4.54722 5.77401 4.44292 5.85647 4.36046C5.93894 4.27315 6.04323 4.22949 6.16935 4.22949C6.29547 4.22949 6.39976 4.27315 6.48222 4.36046C6.56468 4.44292 6.60591 4.54722 6.60591 4.67333V6.52147L6.48222 6.45598C6.48222 6.39292 6.51617 6.31774 6.58408 6.23042C6.652 6.13826 6.74416 6.04852 6.86058 5.96121C6.97699 5.86904 7.11039 5.79386 7.26076 5.73565C7.41599 5.67744 7.57849 5.64833 7.74826 5.64833ZM7.63912 6.44871C7.42569 6.44871 7.23893 6.50206 7.07886 6.60878C6.91879 6.7155 6.79267 6.86102 6.7005 7.04535C6.61319 7.22482 6.56953 7.43098 6.56953 7.66382C6.56953 7.8918 6.61319 8.10038 6.7005 8.28956C6.79267 8.47389 6.91879 8.61941 7.07886 8.72613C7.23893 8.83285 7.42569 8.8862 7.63912 8.8862C7.85255 8.8862 8.03688 8.83285 8.19211 8.72613C8.35218 8.61941 8.47587 8.47389 8.56319 8.28956C8.65535 8.10038 8.70143 7.8918 8.70143 7.66382C8.70143 7.43098 8.65535 7.22482 8.56319 7.04535C8.47587 6.86102 8.35218 6.7155 8.19211 6.60878C8.03688 6.50206 7.85255 6.44871 7.63912 6.44871Z",fill:"#3D3E45"}),n.jsx("path",{d:"M3.02845 5.66289L1.45681 9.35915C1.42286 9.45131 1.3695 9.52408 1.29674 9.57743C1.22883 9.62594 1.15364 9.65019 1.07118 9.65019C0.940211 9.65019 0.843196 9.61381 0.780136 9.54105C0.717077 9.46829 0.685547 9.37855 0.685547 9.27184C0.685547 9.22818 0.692823 9.1821 0.707375 9.13359L2.51913 4.78248C2.55793 4.68546 2.61614 4.61028 2.69375 4.55692C2.77622 4.50356 2.86353 4.48173 2.95569 4.49143C3.04301 4.49143 3.12304 4.51811 3.19581 4.57147C3.27342 4.61998 3.3292 4.69031 3.36316 4.78248L5.15308 9.04628C5.17733 9.10934 5.18946 9.16755 5.18946 9.2209C5.18946 9.35187 5.1458 9.45616 5.05849 9.53378C4.97603 9.61139 4.88386 9.65019 4.782 9.65019C4.69468 9.65019 4.61465 9.62352 4.54189 9.57016C4.47398 9.5168 4.42062 9.44404 4.38181 9.35187L2.81745 5.70654L3.02845 5.66289ZM1.68237 8.47146L2.08256 7.63471H4.04711L4.18536 8.47146H1.68237Z",fill:"#3D3E45"})]}),WM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("g",{clipPath:"url(#clip0_567_6919)",children:n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.00001 1.02051C7.29533 1.02051 7.53473 1.25991 7.53473 1.55523V2.99492L11.3486 5.17429C11.5152 5.2695 11.6181 5.44667 11.6181 5.63856V9.97475L13.0725 10.702C13.3366 10.834 13.4437 11.1552 13.3116 11.4194C13.1795 11.6835 12.8583 11.7906 12.5942 11.6585L11.1002 10.9115L7.26531 13.1028C7.10091 13.1968 6.8991 13.1968 6.73471 13.1028L2.89985 10.9115L1.40581 11.6585C1.14167 11.7906 0.820476 11.6835 0.688405 11.4194C0.556335 11.1552 0.663399 10.834 0.92754 10.702L2.38195 9.97475V5.63856C2.38195 5.44667 2.48477 5.2695 2.65138 5.17429L6.46529 2.99492V1.55523C6.46529 1.25991 6.70469 1.02051 7.00001 1.02051ZM7.00001 3.9211L3.99444 5.63856L7.00001 7.35603L10.0056 5.63856L7.00001 3.9211ZM10.5486 6.55999L7.53473 8.28221V11.7171L10.5486 9.99492V6.55999ZM6.46529 11.7171V8.28221L3.4514 6.55999V9.99492L6.46529 11.7171Z",fill:"#3D3E45"})}),n.jsx("defs",{children:n.jsx("clipPath",{id:"clip0_567_6919",children:n.jsx("rect",{width:"14",height:"14",fill:"white"})})})]}),Xo=({type:e})=>{switch(e){case"boolean":return n.jsx(GM,{});case"date":return n.jsx(FM,{});case"number":return n.jsx(QM,{});case"string":return n.jsx(RM,{});case"dimension":return n.jsx(WM,{});default:return null}},UM={option:{fontFamily:"monospace","&.sub-option":{position:"relative",marginLeft:"22px"},"&.sub-option::before":{content:'""',width:"1px",height:"100%",position:"absolute",left:"-6px",borderLeft:"1px solid #E7E7E9"}},groupLabel:{cursor:"default",fontWeight:"normal","&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",borderBottom:"1px dashed var(--mantine-color-gray-2)"},"&::after":{borderBottom:"1px dashed var(--mantine-color-gray-2)",background:"none"}},group:{"&.dimension-group":{paddingBottom:"4px",".mantine-Combobox-groupLabel":{color:"#000"},".mantine-Combobox-groupLabel::before":{display:"none"},".mantine-Combobox-groupLabel::after":{display:"none"}}}},YM={root:{maxWidth:"unset"},option:{fontFamily:"monospace"},input:{paddingInlineStart:"var(--input-padding-inline-start)",color:"black",fontFamily:"monospace"}},Ag=(e,t,r)=>{const s=[];return t&&s.push("sub-option"),r&&s.push("disabled"),n.jsx(a.Combobox.Option,{value:e.value,className:s.join(" "),disabled:r,children:n.jsxs(a.Stack,{gap:1,children:[n.jsxs(a.Group,{gap:4,children:[n.jsx(Xo,{type:e.dataType}),n.jsx(a.Text,{size:"xs",children:e.label})]}),n.jsx(a.Text,{size:"xs",c:"dimmed",pl:18,children:e.description})]})},e.value)},Lg=k.observer(({mmInfo:e,value:t,onChange:r,usedKeys:s})=>{const i=e.metricDetail,o=e.metrics.loading||i.loading,l=i.error,c=i.filterColOptions,u=a.useCombobox({onDropdownClose:()=>u.resetSelectedOption()}),d=f.useMemo(()=>o?n.jsx(a.Loader,{size:"xs"}):t?n.jsx(a.CloseButton,{size:"xs",onClick:()=>r(null)}):n.jsx(a.Combobox.Chevron,{size:"xs"}),[o,t]),p=n.jsx(a.InputBase,{component:"button",type:"button",variant:"unstyled",size:"xs",pointer:!0,rightSection:d,rightSectionPointerEvents:!o&&t?"all":"none",onClick:()=>u.toggleDropdown(),disabled:o||c.length===0,styles:YM,error:!!l,children:t||n.jsx(a.Input.Placeholder,{children:"选择维度"})});return n.jsxs(a.Combobox,{store:u,onOptionSubmit:h=>{r(h),u.closeDropdown()},styles:UM,children:[n.jsx(a.Combobox.Target,{children:l?n.jsx(a.Tooltip,{label:l,children:p}):p}),n.jsx(a.Combobox.Dropdown,{miw:300,children:n.jsx(a.Combobox.Options,{children:c.map(({group:h,items:x})=>n.jsx(a.Combobox.Group,{label:h,children:x.map(b=>{var m;return"group"in b?n.jsx(a.Combobox.Group,{className:"dimension-group",label:n.jsxs(a.Group,{gap:4,children:[n.jsx(Xo,{type:"dimension"}),n.jsx(a.Text,{size:"sm",children:b.group}),n.jsx(a.Text,{size:"xs",c:"dimmed",children:b.description})]}),children:(m=b.items)==null?void 0:m.map(j=>Ag(j,!0,s.has(j.value)))},b.group):Ag(b,!1,s.has(b.value))})},h))})})]})}),Og={tbody:{td:{fontFamily:"monospace"}}},KM={root:{maxWidth:"unset"},option:{fontFamily:"monospace","&[data-checked=true][data-combobox-disabled]":{opacity:1}},input:{fontFamily:"monospace"},groupLabel:{"&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",backgroundColor:"var(--mantine-color-gray-2)"}}},XM=({option:e,...t})=>{const{t:r}=_.useTranslation(),s=e,i=s.type==="filter";return n.jsxs(a.Stack,{gap:0,py:4,styles:{root:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}}},...t,children:[n.jsx(a.Group,{flex:"1",gap:4,children:n.jsx(a.Text,{size:"xs",children:e.value})}),i&&n.jsxs(a.Group,{justify:"space-between",wrap:"nowrap",children:[n.jsx(a.Text,{size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",style:{flexShrink:1,flexGrow:1},children:s.widget_label}),n.jsx(a.Text,{size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",style:{flexShrink:0,flexGrow:0},children:r(rn[s.widget])})]})]})},Fs=k.observer(({queryModel:e,value:t,onChange:r,usedKeys:s})=>{const{t:i}=_.useTranslation();e.config;const o=f.useMemo(()=>e.getConditionOptionsWithInvalidValue(t).optionGroups.map(u=>{const d=u.items.length;return{group:`${i(u.group)}(${d})`,items:u.items.map(h=>({...h,label:h.value,widget_label:h.label,disabled:s.has(h.value)}))}}),[e.getConditionOptionsWithInvalidValue,i,t,s]),l=f.useCallback((c,u)=>{r(c,u)},[r]);return n.jsx(a.Select,{size:"xs",variant:"unstyled",placeholder:"选择变量",styles:KM,data:o,renderOption:XM,maxDropdownHeight:600,value:t,onChange:l,clearable:!0})}),Ho=k.observer(({variable:e})=>{const t=se();if(!e)return null;const r=v.has(t.queryVariables,e);return n.jsx(a.ThemeIcon,{variant:"white",size:"xs",color:r?"#88CE98":"#F15050",styles:{root:{flexGrow:0,flexShrink:0}},children:n.jsx(C.IconPointFilled,{})})}),HM=k.observer(({queryModel:e})=>{const t=e.config,s=e.datasource.mericoMetricInfo;return f.useEffect(()=>{s.selectMetric(t.id)},[t.id,s]),n.jsxs(a.Stack,{gap:7,children:[n.jsxs(a.Group,{justify:"flex-start",gap:8,children:[n.jsx(a.Text,{size:"sm",children:"看板变量与指标维度关联"}),n.jsx(a.Tooltip,{label:"将看板的筛选器参数与指标的查询维度关联上,使指标可以按照看板的筛选条件和背景变量进行关联展示。",children:n.jsx(a.ActionIcon,{size:"xs",variant:"subtle",color:"gray",children:n.jsx(C.IconInfoCircle,{})})})]}),n.jsxs(a.Table,{withTableBorder:!0,withColumnBorders:!0,layout:"fixed",styles:Og,children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:250}}),n.jsx("col",{}),n.jsx("col",{style:{width:130}}),n.jsx("col",{style:{width:40}})]}),n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:"指标筛选维度"}),n.jsx(a.Table.Td,{children:"看板变量"}),n.jsx(a.Table.Td,{colSpan:2,children:"变量值为真时运行查询"})]})}),n.jsxs(a.Table.Tbody,{children:[t.filters.map(i=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{pr:0,children:n.jsx(Lg,{mmInfo:s,value:i.dimension,onChange:i.setDimension,usedKeys:t.usedFilterDimensionKeys})}),n.jsx(a.Table.Td,{colSpan:2,pr:0,children:n.jsxs(a.Group,{justify:"flex-start",grow:!0,gap:0,w:"100%",children:[n.jsx(Ho,{variable:i.variable}),n.jsx(Fs,{queryModel:e,value:i.variable,onChange:i.setVariable,usedKeys:t.usedFilterVariableSet})]})}),n.jsx(a.Table.Td,{children:n.jsx(a.Checkbox,{size:"xs",checked:e.keyInRunBy(i.variable),onChange:o=>e.changeRunByRecord(i.variable,o.currentTarget.checked),color:"red"})})]},i.dimension)),n.jsxs(a.Table.Tr,{className:"add-a-row",children:[n.jsx(a.Table.Td,{pr:0,children:n.jsx(Lg,{mmInfo:s,value:null,onChange:i=>i&&t.addFilter(i,""),usedKeys:t.usedFilterDimensionKeys})}),n.jsx(a.Table.Td,{colSpan:2,pr:0,children:n.jsx(Fs,{queryModel:e,value:null,onChange:i=>i&&t.addFilter("",i),usedKeys:t.usedFilterVariableSet})}),n.jsx(a.Table.Td,{})]})]})]})]})}),ZM=k.observer(({queryModel:e,variable:t})=>{const r=e.keyInRunBy(t),s=i=>{e.changeRunByRecord(t,i.currentTarget.checked)};return n.jsx(a.Checkbox,{size:"xs",checked:r,onChange:s,color:"red"})}),Vg=({queryModel:e,variable:t})=>t?n.jsx(ZM,{queryModel:e,variable:t}):null,JM=k.observer(({queryModel:e})=>{const t=e.config,o=e.datasource.mericoMetricInfo.metricDetail.trendingDateCol;return!t.timeQuery.enabled||!o?null:n.jsxs(a.Table,{withTableBorder:!0,withColumnBorders:!0,layout:"fixed",styles:Og,children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:250}}),n.jsx("col",{}),n.jsx("col",{style:{width:130}}),n.jsx("col",{style:{width:40}})]}),n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{}),n.jsx(a.Table.Td,{children:"看板变量"}),n.jsx(a.Table.Td,{colSpan:2,children:"变量值为真时运行查询"})]})}),n.jsxs(a.Table.Tbody,{children:[n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{pr:0,children:n.jsxs(a.Group,{gap:4,children:[n.jsx(a.Text,{size:"xs",children:"时间维度:"}),n.jsx(a.Text,{size:"xs",c:"dimmed",ff:"monospace",children:o.name})]})}),n.jsx(a.Table.Td,{colSpan:2,pr:0,children:n.jsxs(a.Group,{justify:"flex-start",gap:0,grow:!0,children:[n.jsx(Ho,{variable:t.timeQuery.range_variable}),n.jsx(Fs,{queryModel:e,value:t.timeQuery.range_variable,onChange:t.setRangeVariable,usedKeys:t.usedTimeQueryVariableSet})]})}),n.jsx(a.Table.Td,{children:n.jsx(Vg,{queryModel:e,variable:t.timeQuery.range_variable})})]},"dimension.time"),n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:n.jsx(a.Text,{size:"xs",children:"步长"})}),n.jsx(a.Table.Td,{colSpan:2,pr:0,children:n.jsxs(a.Group,{justify:"flex-start",gap:0,grow:!0,children:[n.jsx(Ho,{variable:t.timeQuery.unit_variable}),n.jsx(Fs,{queryModel:e,value:t.timeQuery.unit_variable,onChange:t.setUnitVariable,usedKeys:t.usedTimeQueryVariableSet})]})}),n.jsx(a.Table.Td,{children:n.jsx(Vg,{queryModel:e,variable:t.timeQuery.unit_variable})})]},"dimension.step")]})]})}),e4=k.observer(({queryModel:e})=>{const t=e.config,o=e.datasource.mericoMetricInfo.metricDetail.trendingDateCol;return n.jsxs(a.Stack,{gap:7,children:[n.jsxs(a.Group,{justify:"flex-start",gap:8,children:[n.jsx(a.Text,{size:"sm",children:"按时间序列展示"}),n.jsx(a.Tooltip,{label:"将看板的时间&步长筛选器与相应的查询维度关联上。",children:n.jsx(a.ActionIcon,{size:"xs",variant:"subtle",color:"gray",children:n.jsx(C.IconInfoCircle,{})})}),o?n.jsx(a.Switch,{size:"xs",color:"red",checked:t.timeQuery.enabled,onChange:l=>t.setTimeQueryEnabled(l.currentTarget.checked)}):n.jsx(a.Tooltip,{label:"由于指标未设定时序维度,所以不具备时间序列展示功能。",children:n.jsx(a.Box,{children:n.jsx(a.Switch,{size:"xs",color:"red",disabled:!o})})})]}),n.jsx(JM,{queryModel:e})]})}),t4={label:{fontWeight:"normal"},input:{fontSize:"12px"},groupLabel:{cursor:"default",fontWeight:"normal","&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",borderBottom:"1px dashed var(--mantine-color-gray-2)"},"&::after":{borderBottom:"1px dashed var(--mantine-color-gray-2)",background:"none"}},option:{fontFamily:"monospace"}},n4=e=>{const t=e.option;return n.jsxs(a.Stack,{gap:1,styles:{root:{flexGrow:1}},children:[n.jsxs(a.Group,{gap:4,children:[n.jsx(Xo,{type:t.dataType}),n.jsx(a.Text,{size:"xs",children:t.label})]}),n.jsx(a.Text,{size:"xs",c:"dimmed",pl:18,children:t.description})]})},r4=k.observer(({queryModel:e})=>{const t=e.config,s=e.datasource.mericoMetricInfo,i=s.metricDetail,o=s.metrics.loading||i.loading,l=i.groupByColOptions,c=u=>{const d=i.getGroupByOptions(u),p=[];d.forEach(h=>{h.dimension?h.dimension.fields.forEach(x=>{p.push(`${h.value} -> ${x.field}`)}):p.push(h.value)}),t.setGroupBys(p)};return n.jsx(a.MultiSelect,{size:"sm",label:"分组聚合维度",description:"指标在查询时按照哪些维度进行聚合计算。最多支持两个维度的聚合计算。若选择按时间序列展示,则仅可选择一个聚合维度。",data:l,searchable:!0,styles:t4,renderOption:n4,rightSection:o?n.jsx(a.Loader,{size:"xs"}):null,value:[...t.groupByValues],onChange:c,maxValues:t.timeQuery.enabled?1:2,placeholder:t.timeQuery.enabled?"仅可选一个维度":"最多选两个维度",disabled:o})}),s4=k.observer(({queryModel:e})=>{const t=e.config,r=t.id;return f.useEffect(()=>{if(e.run_by.length===0)return;const s=[],i=t.usedFilterVariableSet,o=t.usedTimeQueryVariableSet;e.run_by.forEach(l=>{(i.has(l)||o.has(l))&&s.push(l)}),e.setRunBy(s)},[t.usedFilterVariableSet,t.usedTimeQueryVariableSet,e.run_by]),n.jsxs(a.Stack,{gap:16,pos:"relative",children:[!r&&n.jsx(a.Overlay,{color:"#fff",backgroundOpacity:.5,blur:3,children:n.jsx(a.Center,{h:"100%",children:n.jsx(a.Text,{size:"sm",c:"black",children:"请先选择指标"})})}),n.jsx(HM,{queryModel:e}),n.jsx(e4,{queryModel:e}),n.jsx(r4,{queryModel:e})]})}),i4=k.observer(({queryModel:e})=>(e.config,n.jsx(a.Stack,{children:n.jsx(Dt.CodeHighlight,{language:"json",sx:{width:"100%",height:"100%",minHeight:"400px",overflowY:"auto"},withCopyButton:!1,code:e.metricQueryPayloadString})}))),a4=["function process_result(resp, utils, state) {"," return resp.data","}"].join(`
518
- `),o4={root:{minHeight:"350px",maxHeight:"50vh",height:"100%",overflow:"hidden"},list:{"&::before":{borderColor:"transparent"}},panel:{height:"calc(100% - 36px)",overflowY:"auto"}},l4=k.observer(({queryModel:e})=>{const[t,r]=f.useState("编辑查询");return n.jsxs(a.Tabs,{color:"red",defaultValue:"编辑查询",styles:o4,value:t,onChange:r,children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"编辑查询",size:"xs",children:"编辑查询"}),n.jsx(a.Tabs.Tab,{value:"加工结果",size:"xs",children:"加工结果"}),n.jsx(a.Tabs.Tab,{value:"使用情况",size:"xs",children:"使用情况"}),n.jsx(a.Tabs.Tab,{value:"预览查询",size:"xs",leftSection:n.jsx(C.IconEye,{size:14}),ml:"auto",children:"预览查询"})]}),n.jsx(a.Tabs.Panel,{value:"编辑查询",pt:"xs",children:n.jsx(s4,{queryModel:e})}),n.jsx(a.Tabs.Panel,{value:"加工结果",pt:"xs",children:n.jsx(Sn,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:a4})}),n.jsx(a.Tabs.Panel,{value:"使用情况",pt:"xs",children:n.jsx(Ig,{queryModel:e})}),n.jsx(a.Tabs.Panel,{value:"预览查询",pt:"xs",children:n.jsx(i4,{queryModel:e})})]})}),c4=k.observer(()=>{const e=se();return n.jsxs(a.Stack,{styles:{root:{borderRadius:4,backgroundColor:"#F9F9FA",height:"100%",minHeight:"350px",maxHeight:"50vh",overflow:"hidden"}},children:[n.jsx(a.Box,{py:7,px:8,children:n.jsx(a.Text,{fw:"bold",size:"sm",children:"看板变量预览"})}),n.jsx(Dt.CodeHighlight,{language:"json",sx:{width:"100%",height:"100%",minHeight:"400px",overflowY:"auto"},withCopyButton:!1,code:e.queryVariablesString})]})}),u4=k.observer(({queryModel:e})=>{const t=e.metricQueryPayloadError;return t.length>0?n.jsxs(a.HoverCard,{shadow:"md",children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.Box,{children:n.jsx(a.Button,{size:"xs",leftSection:n.jsx(Eg,{width:14,height:14,color:"rgb(173, 181, 189)"}),variant:"filled",color:"red",disabled:!0,children:"执行查询"})})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsx(a.List,{size:"xs",children:t.map(r=>n.jsx(a.List.Item,{children:r},r))})})]}):n.jsx(a.Button,{size:"xs",leftSection:n.jsx(Eg,{width:14,height:14}),variant:"filled",color:"red",onClick:()=>e.fetchData(!0),children:"执行查询"})}),d4=({option:e,...t})=>{const r=e;return n.jsxs(a.Stack,{gap:0,py:4,styles:{root:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}}},...t,children:[n.jsxs(a.Group,{flex:"1",gap:4,children:[n.jsx(C.IconHash,{size:12}),n.jsx(a.Text,{size:"xs",children:r.label})]}),n.jsx(a.Text,{ml:16,size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",children:r.description})]})},p4=k.observer(({queryModel:e})=>{const t=e.config,s=e.datasource.mericoMetricInfo,i=s.metrics;f.useEffect(()=>{i.load()},[i]),f.useEffect(()=>{!s.metricID&&t.id&&s.selectMetric(t.id)},[t.id]);const o=f.useMemo(()=>i.data.map(d=>({label:d.name,value:d.id,description:d.description,type:d.type})),[i.data]),l=f.useCallback((d,p)=>{d&&(s.selectMetric(d),t.setID(d),t.setType(p.type))},[s,t]),{loading:c,error:u}=i;return n.jsx(Ie,{children:n.jsxs(a.Group,{justify:"flex-end",gap:12,align:"flex-end",children:[u?n.jsx(a.Tooltip,{label:u,children:n.jsx(a.Select,{size:"xs",label:"指标",error:!0,styles:{root:{flexGrow:1}}})}):n.jsx(a.Select,{size:"xs",label:"指标",data:o,renderOption:d4,styles:{root:{flexGrow:1}},maxDropdownHeight:500,value:t.id,onChange:l,rightSection:c?n.jsx(a.Loader,{size:"xs"}):null}),n.jsx(a.Tooltip,{label:"跳转到指标明细页查看详情。",disabled:c,children:n.jsx(a.Anchor,{size:"md",variant:"subtle",mb:2,href:`/admin/metrics/detail/${t.id}`,target:"_blank",underline:"never",children:n.jsx(IM,{width:14,height:14})})})]})})}),h4=k.observer(({queryModel:e})=>{const{t}=_.useTranslation();return n.jsxs(a.Stack,{pt:8,pb:16,px:24,gap:8,styles:{root:{height:"100vh",overflow:"hidden"}},children:[n.jsx(a.Group,{styles:{root:{flexGrow:0,flexShrink:0}},children:n.jsx(a.TextInput,{size:"xs",placeholder:t("query.name_description"),label:t("query.name"),value:e.name,onChange:r=>{e.setName(r.currentTarget.value)},styles:{root:{flexGrow:0,width:"calc(50% - 44px)"}}})}),n.jsxs(a.Group,{justify:"space-between",grow:!0,gap:8,align:"flex-end",styles:{root:{flexGrow:0,flexShrink:0}},children:[n.jsxs(a.Group,{justify:"flex-start",grow:!0,gap:24,align:"flex-end",children:[n.jsx(kg,{queryModel:e,size:"xs"}),n.jsx(p4,{queryModel:e})]}),n.jsxs(a.Group,{justify:"flex-end",children:[n.jsx(u4,{queryModel:e}),n.jsx(PM,{queryModel:e})]})]}),n.jsxs(a.Group,{justify:"space-between",grow:!0,gap:12,align:"flex-start",sx:{flexGrow:0,flexShrink:1,overflowY:"hidden"},children:[n.jsx(l4,{queryModel:e}),n.jsx(c4,{})]}),n.jsx($M,{queryModel:e})]})}),g4=k.observer(({id:e})=>{const r=re().queries.findByID(e);return e===""?null:r?r.isMericoMetricQuery?n.jsx(h4,{queryModel:r}):n.jsx(zM,{queryModel:r}):n.jsx(a.Text,{size:"14px",c:"red",children:"Invalid Query ID"})}),f4=k.observer(({value:e})=>{const r=Te().payloadForSQL,s=f.useMemo(()=>Hs(e,r),[e,r]);return n.jsx(fa,{height:"100%",value:s})}),x4=k.observer(({item:e,remove:t,onKeyChanged:r})=>{const{t:s}=_.useTranslation(),[i,o]=f.useState("SQL"),[l,c]=f.useState(e.key),u=()=>{e.setKey(l),r(l)},d=l!==e.key,p=e.isADuplicatedKey(l),[h,x]=f.useState(e.value),b=()=>{e.setValue(h)};f.useEffect(()=>{c(e.key),x(e.value)},[e]);const m=h!==e.value,j=dt.useModals(),D=()=>{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 n.jsxs(a.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},gap:"sm",children:[n.jsxs(a.Group,{sx:{alignItems:"end"},gap:40,children:[n.jsx(a.TextInput,{label:s(p?"sql_snippet.key_occupied":"sql_snippet.key"),value:l,onChange:T=>{c(T.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:n.jsx(a.ActionIcon,{color:"blue",variant:"subtle",onClick:u,disabled:!d||p,children:n.jsx(C.IconDeviceFloppy,{size:16})}),error:p}),n.jsx(a.Button,{leftSection:n.jsx(C.IconTrash,{size:16}),color:"red",variant:"light",onClick:D,children:s("sql_snippet.delete")})]}),n.jsxs(a.Tabs,{value:i,onChange:o,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[n.jsxs(a.Tabs.List,{sx:{position:"relative"},children:[n.jsx(a.Tabs.Tab,{value:"SQL",children:s("sql_snippet.edit_snippet")}),n.jsx(a.Tabs.Tab,{value:"Preview",children:s("sql_snippet.preview_snippet")}),n.jsx(Ko,{}),n.jsx(a.ActionIcon,{color:"blue",variant:"filled",onClick:b,disabled:!m,sx:{position:"absolute",top:0,right:10},children:n.jsx(C.IconDeviceFloppy,{size:18})})]}),n.jsx(a.Tabs.Panel,{value:"SQL",pt:"sm",children:n.jsx(fa,{height:"100%",value:h,onChange:x,defaultLanguage:"sql",theme:"sql-dark"})}),n.jsx(a.Tabs.Panel,{value:"Preview",pt:"sm",children:n.jsx(f4,{value:h})})]})]})}),m4=k.observer(({id:e})=>{const t=se(),r=re(),s=f.useMemo(()=>r.sqlSnippets.findByKey(e),[e]);if(!e)return null;if(!s)return n.jsxs(a.Text,{size:"14px",children:["SQL Snippet by key[",e,"] is not found"]});const i=()=>{t.editor.setPath(["_SQL_SNIPPETS_",""])},o=()=>{r.sqlSnippets.removeByKey(e),i()},l=c=>{t.editor.setPath(["_SQL_SNIPPETS_",c])};return n.jsx(x4,{item:s,remove:o,onKeyChanged:l})}),b4=k.observer(()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState([]),s=dt.useModals(),i=se(),o=x=>{i.editor.setPath(["_SQL_SNIPPETS_",x])},l=()=>{s.openConfirmModal({title:"Delete ununsed SQL snippets?",children:n.jsx(a.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=f.useMemo(()=>i.content.sqlSnippets.sortedList.map(x=>x.key),[i.content.sqlSnippets.sortedList]),d=()=>{r(u)},p=()=>{r([])},h=i.content.sqlSnippetsUsage;return n.jsxs(a.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(a.Text,{size:"sm",px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("sql_snippet.manage")})}),n.jsxs(a.Flex,{justify:"space-between",align:"center",px:12,children:[n.jsxs(a.Group,{justify:"flex-start",children:[n.jsxs(a.Button.Group,{children:[n.jsx(a.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),n.jsx(a.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),n.jsx(a.Button,{size:"xs",color:"blue",leftSection:n.jsx(C.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),n.jsx(a.Button,{variant:"subtle",size:"xs",color:"red",leftSection:n.jsx(C.IconTrash,{size:14}),disabled:!i.content.hasUnusedSQLSnippets,onClick:l,children:e("sql_snippet.delete_unused")})]}),n.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(a.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"40px"}}),n.jsx(a.Table.Th,{children:e("common.key")}),n.jsx(a.Table.Th,{style:{width:"100px",textAlign:"center"},children:e("sql_snippet.usage.label")}),n.jsx(a.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(a.Table.Tbody,{children:i.content.sqlSnippets.sortedList.map(x=>{var m;const b=((m=h[x.key])==null?void 0:m.length)??0;return n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:n.jsx(a.Checkbox,{value:x.key,styles:{input:{cursor:"pointer"}}})}),n.jsx(a.Table.Td,{children:x.key}),n.jsx(a.Table.Td,{style:{color:b===0?"#ff0000":"#000",fontWeight:b===0?"bold":"normal",textAlign:"center"},children:b}),n.jsx(a.Table.Td,{children:n.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>o(x.key),children:e("common.actions.open")})})]},x.key)})})]})})})]})}),y4=k.observer(({view:e})=>!e||e.type!==F.Division?null:n.jsx(a.Stack,{})),v4=k.observer(({view:e})=>{const{t,i18n:r}=_.useTranslation(),s=f.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")}],[r.language]),i=f.useMemo(()=>[{value:"horizontal",label:t("common.tabs.orientation.horizontal")},{value:"vertical",label:t("common.tabs.orientation.vertical")}],[r.language]);if(!e||e.type!==F.Tabs)return null;const o=e.config;return n.jsxs(a.Stack,{children:[n.jsx(a.Divider,{mt:8,mb:0,label:t("view.component.tabs.tabs_settings"),labelPosition:"center"}),n.jsx(a.Select,{label:t("common.tabs.variant.label"),value:o.variant,onChange:o.setVariant,data:s}),n.jsx(a.Select,{label:t("common.tabs.orientation.label"),value:o.orientation,onChange:o.setOrientation,data:i}),n.jsx(a.Switch,{label:t("common.tabs.grow_tabs"),checked:o.grow,onChange:l=>o.setGrow(l.currentTarget.checked)})]})}),_4=({disabled:e,value:t,onChange:r})=>{const s=i=>{i&&r(i)};return n.jsxs(a.Box,{sx:{position:"relative"},children:[e&&n.jsx(a.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),n.jsx(ht,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},j4=({value:e,onChange:t})=>{const{t:r}=_.useTranslation(),[s,{setTrue:i,setFalse:o}]=Y.useBoolean(),[l,c]=f.useState(e??Ps),u=b=>{c({...l,enabled:b})},d=()=>{o();const{enabled:b,func_content:m}=l,j={enabled:b,func_content:m};c(j),t(j)},p=()=>{o(),c(e)},h=b=>{c(m=>({...m,func_content:b}))},x=()=>{h(Ps.func_content)};return n.jsxs(n.Fragment,{children:[n.jsx(a.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:i,sx:{flexGrow:0},children:n.jsx(C.IconSettings,{size:14})}),n.jsx(a.Modal,{size:800,title:r("view.component.modal.custom_title"),opened:s,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&n.jsxs(a.Stack,{children:[n.jsx(a.Checkbox,{mt:10,label:r("common.enabled"),checked:l.enabled,onChange:b=>u(b.currentTarget.checked)}),n.jsx(_4,{value:l.func_content,onChange:h,disabled:!l.enabled}),n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Button,{onClick:x,color:"red",leftSection:n.jsx(C.IconRecycle,{size:20}),children:r("common.actions.revert")}),n.jsxs(a.Group,{justify:"flex-end",children:[n.jsx(a.Button,{onClick:p,variant:"subtle",children:r("common.actions.cancel")}),n.jsx(a.Button,{onClick:d,children:r("common.actions.save")})]})]})]})})]})},w4=k.observer(({view:e})=>{const{t}=_.useTranslation();if(!e||e.type!==F.Modal)return null;const r=e.config,s=r.custom_modal_title.value;return n.jsxs(a.Stack,{children:[n.jsx(a.Divider,{mt:8,label:t("view.component.modal.modal_settings"),labelPosition:"center"}),n.jsxs(a.Flex,{gap:10,children:[n.jsx(a.TextInput,{label:t("view.component.modal.title"),value:s,onChange:v.noop,disabled:!0,sx:{flexGrow:1}}),n.jsx(j4,{value:r.custom_modal_title,onChange:r.custom_modal_title.replace})]}),n.jsxs(a.Group,{grow:!0,children:[n.jsx(a.TextInput,{label:t("view.component.modal.width"),value:r.width,onChange:i=>r.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),n.jsx(a.TextInput,{label:t("view.component.modal.height"),value:r.height,onChange:i=>r.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),C4=k.observer(({view:e})=>n.jsxs(n.Fragment,{children:[n.jsx(y4,{view:e}),n.jsx(w4,{view:e}),n.jsx(v4,{view:e})]})),S4=k.observer(({view:e})=>{const{t,i18n:r}=_.useTranslation(),s=f.useMemo(()=>[{label:t("view.component.div.label"),value:F.Division},{label:t("view.component.modal.label"),value:F.Modal},{label:t("view.component.tabs.label"),value:F.Tabs}],[r.language]);return e?n.jsxs(a.Stack,{sx:{position:"relative"},children:[n.jsx(a.TextInput,{label:t("common.name"),value:e.name,onChange:i=>{e.setName(i.currentTarget.value)}}),n.jsx(a.Select,{label:t("common.type"),comboboxProps:{withinPortal:!0,zIndex:320},value:e.type,onChange:e.setType,data:s}),n.jsx(C4,{view:e})]}):null}),T4=k.observer(({id:e})=>{const{t}=_.useTranslation(),r=dt.useModals(),s=se(),i=re();if(e==="")return null;const o=i.views.findByID(e);if(!o)return n.jsxs(a.Text,{size:"14px",children:["View by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_VIEWS_",""])},c=()=>{r.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()},confirmProps:{color:"red"},zIndex:320})};return n.jsxs(a.Stack,{sx:{maxWidth:"600px",height:"100%"},gap:"sm",children:[n.jsx(a.Group,{justify:"flex-end",pt:10,children:n.jsx(a.Button,{size:"xs",color:"red",leftSection:n.jsx(C.IconTrash,{size:16}),onClick:c,children:t("view.delete")})}),n.jsx(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n.jsx(S4,{view:o})})]})}),k4=k.observer(()=>n.jsx(a.Stack,{sx:{height:"100%"},p:"sm",children:n.jsx(Dg,{})})),D4=k.observer(()=>{const e=se().editor,t=e.path;return F5(t)?n.jsx(k4,{}):Q5(t)?n.jsx(mI,{}):R5(t)?n.jsx(xI,{}):W5(t)?n.jsx(a.Box,{p:"xs",pl:20,children:n.jsx(fI,{id:t[1]})}):U5(t)?n.jsx(b4,{}):Y5(t)?n.jsx(m4,{id:t[1]}):X5(t)?n.jsx(XI,{}):K5(t)?n.jsx(g4,{id:t[1]}):H5(t)?n.jsx(a.Box,{p:"xs",pl:20,children:n.jsx(T4,{id:t[1]})}):No(t)?n.jsx(KI,{viewID:t[1],panelID:t[3]}):n.jsx(a.Box,{children:e.path})}),z4=k.observer(()=>n.jsx(D4,{})),I4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=()=>{const s=new Date().getTime().toString(),i={id:s,key:s,label:s,order:t.content.filters.current.length+1,type:Q.TextInput,config:fo(),visibleInViewsIDs:["Main"],auto_submit:!1};t.content.filters.append(i),t.editor.setPath(["_FILTERS_",s])};return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("filter.add")})}),M4=k.observer(({parentID:e})=>{const{t}=_.useTranslation(),r=re();if(!e)return null;const s=r.views.findByID(e);return!s||s.type===F.Tabs?null:n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>r.addANewPanel(s.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("panel.add")})}),E4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=()=>{const s=new Date().getTime().toString(),i={id:s,name:s,type:J.Postgresql,key:"",config:{_type:J.Postgresql,sql:""}};t.content.queries.append(i),t.editor.setPath(["_QUERIES_",s])};return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("query.add")})}),P4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=()=>{const s=new Date().getTime().toString(),i={key:s,value:""};t.content.sqlSnippets.append(i),t.editor.setPath(["_SQL_SNIPPETS_",s])};return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("sql_snippet.add")})}),A4=k.observer(()=>{const{t:e}=_.useTranslation(),t=re();return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.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")})}),L4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.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")})}),O4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.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")})}),V4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.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")})}),B4=k.observer(({action_type:e,parentID:t})=>e==="_Add_A_Filter_"?n.jsx(I4,{}):e==="_Add_A_SQL_SNIPPET_"?n.jsx(P4,{}):e==="_Add_A_QUERY_"?n.jsx(E4,{}):e==="_Add_A_VIEW_"?n.jsx(A4,{}):e==="_Add_A_PANEL_"?n.jsx(M4,{parentID:t}):e==="_QUERIES_SETTINGS_"?n.jsx(L4,{}):e==="_SQL_SNIPPETS_SETTINGS_"?n.jsx(O4,{}):e==="_FILTERS_SETTINGS_"?n.jsx(V4,{}):null),Bg=k.observer(({option:e})=>{var p;const{t}=_.useTranslation(),r=se().editor,s=r.isOptionActive,i=s(r.path,e),o=r.isOptionOpened,l=r.navigate,c=o(e),[u,d]=f.useState(c);return f.useEffect(()=>{d(c)},[c]),n.jsx(a.NavLink,{active:i,defaultOpened:c,opened:u,onChange:d,label:t(e.label),onClick:()=>l(e),leftSection:e.Icon?n.jsx(e.Icon,{size:18}):null,children:(p=e.children)==null?void 0:p.map(h=>h._type==="ACTION"?n.jsx(B4,{action_type:h._action_type,parentID:h.parentID},`_ADD_${h.value}_`):n.jsx(Bg,{option:h},h.value))},e.label)}),q4=k.observer(()=>{const e=se();return n.jsx(a.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>n.jsx(Bg,{option:t},t.value))})}),N4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsxs(a.AppShell.Navbar,{p:0,sx:{height:"100vh - 60px - 60px",".mantine-NavLink-body":{wordWrap:"break-word"}},children:[n.jsx(a.AppShell.Section,{sx:{borderBottom:"1px solid #eee",padding:"var(--mantine-spacing-xs) var(--mantine-spacing-md)"},children:n.jsx(a.Text,{size:"sm",ta:"center",sx:{userSelect:"none",cursor:"default"},children:e("common.titles.settings")})}),n.jsx(a.AppShell.Section,{grow:!0,sx:{overflow:"auto"},children:n.jsx(q4,{})}),n.jsx(a.AppShell.Section,{children:n.jsx(a.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n.jsx(a.Button,{size:"xs",color:"red",leftSection:n.jsx(C.IconX,{size:18}),onClick:()=>t.editor.close(),children:e("common.actions.close")})})})]})}),$4={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"calc(var(--app-shell-navbar-width, 0px) + 1200px)"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},G4=k.observer(()=>{const e=se().editor;return n.jsx(a.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:n.jsxs(a.AppShell,{padding:0,navbar:{width:{base:220,xs:220,sm:240,md:260,lg:300,xl:320},breakpoint:"xxs"},styles:$4,children:[n.jsx(N4,{}),n.jsx(a.AppShell.Main,{children:n.jsx(z4,{})})]})})}),F4=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function Q4(e){f.useEffect(()=>{if(ht.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const r=F4(e);ht.loader.config({paths:{vs:r}}),ht.loader.init().then(s=>console.log("monaco instance:",s))},[])}Hl(),bd();const R4={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden","--app-shell-header-offset":"calc(3.75rem * var(--mantine-scale))"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},W4=({context:e,dashboard:t,content:r,update:s,className:i="dashboard",config:o,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h},x)=>{Q4(o.monacoPath),Zs(o);const{data:b=[]}=Y.useRequest(ba),{data:m=[]}=Y.useRequest(yd),j=f.useMemo(()=>ig(t,r,b,m,e,u??{}),[t,r]);f.useImperativeHandle(x,()=>j,[j]),og(j.content,!0),f.useEffect(()=>{j.context.replace(e)},[e]),f.useEffect(()=>{j.datasources.replace(b)},[b]),f.useEffect(()=>{j.globalSQLSnippets.replace(m)},[m]),f.useEffect(()=>{d==null||d(j.content.filters.values)},[d,j.content.filters.values]),f.useEffect(()=>{u&&j.content.filters.patchValues(u)},[u,j.content.filters.patchValues]),f.useEffect(()=>te.reaction(()=>te.toJS(j.json),I=>{l==null||l(I)}),[j]);const D=async()=>{await s(j.json,j.content.json)},T=Y.useCreation(no,[]),z=lg(T);return Y.useWhyDidYouUpdate("@devtable/dashboard editor",{context:e,dashboard:t,content:r,update:s,className:i,config:o,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h}),n.jsx(on.MantineEmotionProvider,{children:n.jsx(ag,{lang:h,children:n.jsx(dt.ModalsProvider,{children:n.jsx(li,{children:n.jsx(ri,{value:{searchButtonProps:o.searchButtonProps},children:n.jsx(ti,{value:j,children:n.jsx(si,{value:j.content,children:n.jsxs($r.Provider,{value:{inEditMode:!0},children:[n.jsx(Tz,{}),n.jsx(tn.Provider,{value:T,children:n.jsxs(Ms,{configure:z,children:[n.jsxs(a.AppShell,{padding:0,navbar:{width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},breakpoint:"xxs"},styles:R4,children:[n.jsx(Iz,{onExit:p,saveDashboardChanges:D,headerSlot:c}),n.jsx(rI,{}),n.jsx(a.AppShell.Main,{children:n.jsx(a.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:j.content.views.visibleViews.map(I=>n.jsx(Rh,{view:I},I.id))})})]}),n.jsx(G4,{})]})})]})})})})})})})})},U4=k.observer(f.forwardRef(W4)),CE="",Zo=g.types.model({id:g.types.string,name:g.types.string,dashboard_id:g.types.string,create_time:g.types.string,update_time:g.types.string,version:g.types.string,filters:Io,queries:Po,sqlSnippets:Lo,views:ko,panels:zo,layouts:Ao,mock_context:so}).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=g.getParent(e).context.current,r=g.getParent(e).globalSQLSnippets,s={context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload};return{...s,sql_snippets:Ir(e.sqlSnippets.current,"key","value",s),global_sql_snippets:Ir(r.list,"id","content",s)}},get payloadForViz(){const t=g.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload}},get dashboardState(){return ma(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardState}},get data(){return e.queries.current.map(({id:r,data:s})=>({id:r,data:s})).reduce((r,s)=>(r[s.id]=s.data,r),{})},getDataStuffByID(t){const r=e.queries.findByID(t);return r?{data:r.data,len:r.data.length,state:r.state,error:r.error??r.metricQueryPayloadErrorString}:{data:[],len:0,state:"idle",error:void 0}}})).actions(e=>({}));function qg({id:e,name:t,dashboard_id:r,create_time:s,update_time:i,content:o},l,c,u){if(!o)throw new Error("unexpected null content when creating a content model");const{version:d,filters:p,views:h,panels:x,layouts:b,definition:{queries:m,sqlSnippets:j,mock_context:D={}}}=o;return Zo.create({id:e,name:t,dashboard_id:r,create_time:s,update_time:i,version:d,filters:Mo(p,l,D,c),queries:jh(m),sqlSnippets:Sh(j),mock_context:io(D),views:ph(h,u),panels:{list:x},layouts:{list:b,currentBreakpoint:b[0].id}})}const Ng=g.types.model({id:g.types.identifier,name:g.types.string,group:g.types.string,content:Zo,content_id:g.types.string,datasources:uh,globalSQLSnippets:Co,context:As});function $g({id:e,name:t,group:r,content_id:s},i,o,l,c,u,d){return Ng.create({id:e,name:t,group:r,content_id:s,content:qg(i,c,u,d),datasources:{list:o},globalSQLSnippets:{list:l},context:So(c)})}Hl(),bd();const Y4=({context:e,dashboard:t,content:r,className:s="dashboard",config:i,fullScreenPanelID:o,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h})=>{Zs(i);const{data:x=[]}=Y.useRequest(ba),{data:b=[]}=Y.useRequest(yd),m=f.useMemo(()=>$g(t,r,x,b,e,c??{},d??null),[t,r,d]);og(m.content,!1),f.useEffect(()=>{m.context.replace(e)},[e]),f.useEffect(()=>{m.datasources.replace(x)},[x]),f.useEffect(()=>{m.globalSQLSnippets.replace(b)},[b]),f.useEffect(()=>{console.log("⚪️ calling onFilterValuesChange: ",m.content.filters.values),u==null||u(m.content.filters.values)},[u,m.content.filters.valuesString]),f.useEffect(()=>{c&&m.content.filters.patchValues(c)},[c,m.content.filters.patchValues]),f.useEffect(()=>{p==null||p(m.content.views.firstVisibleTabsViewActiveTab)},[p,m.content.views.firstVisibleTabsViewActiveTabStr]),f.useEffect(()=>{d&&m.content.views.setFirstVisibleTabsViewActiveTab(d)},[d,m.content.views.setFirstVisibleTabsViewActiveTab]);const j=Y.useCreation(no,[]),D=lg(j);return Y.useWhyDidYouUpdate("@devtable/dashboard render",{context:e,dashboard:t,content:r,className:s,config:i,fullScreenPanelID:o,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h}),n.jsx(on.MantineEmotionProvider,{children:n.jsx(ag,{lang:h,children:n.jsx(dt.ModalsProvider,{children:n.jsx(li,{children:n.jsx(ri,{value:{searchButtonProps:i.searchButtonProps},children:n.jsx(ti,{value:m,children:n.jsx(si,{value:m.content,children:n.jsx(oi.Provider,{value:{fullScreenPanelID:o,setFullScreenPanelID:l},children:n.jsx($r.Provider,{value:{inEditMode:!1},children:n.jsx(a.Box,{className:`${s} dashboard-root`,children:n.jsx(tn.Provider,{value:j,children:n.jsx(Ms,{configure:D,children:m.content.views.visibleViews.map(T=>n.jsx(Vs,{view:T},T.id))})})})})})})})})})})})})},K4=k.observer(Y4);A.extend(pf),A.extend(hf),A.extend(gf),A.extend(ff),A.extend(xf),A.extend(mf),A.extend(bf),A.extend(yf),A.extend(vf),A.extend(_f),A.extend(Cf),A.extend(Sf),A.extend(Tf),A.extend(kf),A.extend(Df),A.extend(jf),A.extend(wf),A.extend(zf),A.extend(If),A.extend(Mf),A.extend(Ef),A.extend(Pf),A.extend(Af),A.extend(Lf),A.extend(Of),A.extend(Vf),A.extend(Bf),A.extend(qf),A.extend(Nf),A.extend($f),A.extend(Ff),A.extend(Qf),A.extend(Gf),A.tz.setDefault("UTC"),A.updateLocale("en",{weekStart:1});const X4=()=>Promise.resolve().then(()=>zy).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));w.APIClient=gt,w.CURRENT_SCHEMA_VERSION=nn,w.ContentModel=Go,w.ContentModelContextProvider=si,w.ContentRenderModel=Zo,w.ContextMeta=As,w.DEFAULT_CUSTOM_MODAL_TITLE=Ps,w.DashboardApiClient=El,w.DashboardApiFacadeClient=Pl,w.DashboardEditor=U4,w.DashboardFilterType=Q,w.DashboardMode=Wh,w.DashboardModel=sg,w.DashboardModelContextProvider=ti,w.DashboardRenderModel=Ng,w.DashboardThemeContextProvider=ri,w.DashboardViewEditor=Rh,w.DashboardViewRender=Vs,w.DataSourceMetaModel=wo,w.DataSourceType=J,w.DataSourcesMetaModel=uh,w.DatesProvider=li,w.DefaultApiClient=Ml,w.DescriptionPopover=Oo,w.DraftModel=Th,w.EViewComponentType=F,w.FacadeApiClient=ix,w.FilterCheckboxConfigMeta=oo,w.FilterDateRangeConfigMeta=co,w.FilterMeta=yo,w.FilterMultiSelectConfigMeta=po,w.FilterSelectConfigMeta=ho,w.FilterTextInputConfigMeta=go,w.FilterTreeSelectConfigMeta=mo,w.FilterTreeSingleSelectConfigMeta=bo,w.FiltersModel=Yh,w.FiltersRenderModel=Io,w.FullScreenPanel=Nh,w.FullScreenPanelContext=oi,w.GlobalSQLSnippetMeta=dh,w.GlobalSQLSnippetsMeta=Co,w.LayoutItemMeta=Gp,w.LayoutSetMeta=Fp,w.LayoutStateContext=$r,w.LayoutsRenderModel=Ao,w.MericoMetricQueryMeta=ao,w.MockContextMeta=so,w.MuteQueryModel=_h,w.Panel=qh,w.PanelContextProvider=ii,w.PanelErrorOrStateMessage=Vh,w.PanelMeta=Lp,w.PanelModel=eg,w.PanelRender=Bo,w.PanelRenderModel=Do,w.PanelStyleMeta=Mp,w.PanelTitleMeta=Ep,w.PanelVizMeta=Ap,w.PanelVizSection=Vo,w.PanelsModel=tg,w.PanelsRenderModel=zo,w.QueriesModel=Xh,w.QueriesRenderModel=Po,w.QueryMeta=$p,w.QueryModel=Kh,w.QueryRenderModel=Eo,w.ReadOnlyDashboard=K4,w.SQLSnippetMeta=Qp,w.SQLSnippetRenderModel=Ch,w.SQLSnippetsModel=Hh,w.SQLSnippetsRenderModel=Lo,w.VariableMeta=Pp,w.ViewComponentTypeBackground=Uh,w.ViewComponentTypeColor=k5,w.ViewComponentTypeName=T5,w.ViewDivisionConfig=vo,w.ViewMeta=ch,w.ViewModalConfig=_o,w.ViewRenderModel=To,w.ViewTabsConfig=jo,w.ViewsModel=ng,w.ViewsRenderModel=ko,w.Viz=Oh,w.applyPartialDashboard=rz,w.configureAPIClient=Zs,w.createContentModel=rg,w.createContentRenderModel=qg,w.createContextMeta=So,w.createDashboardModel=ig,w.createDashboardRenderModel=$g,w.createDraft=kh,w.createFilterCheckboxConfig=Rp,w.createFilterDateRangeConfig=Xp,w.createFilterMultiSelectConfig=Zp,w.createFilterSelectConfig=Jp,w.createFilterTextInputConfig=fo,w.createFilterTreeSelectConfig=sh,w.createFilterTreeSingleSelectConfig=ih,w.createMericoMetricQueryMetaConfig=Np,w.createViewDivisionConfig=ah,w.createViewModalConfig=oh,w.createViewTabsConfig=lh,w.facadeApiClient=Al,w.formatSQLSnippet=Ir,w.getInitialDashboardViewsModel=$o,w.getInitialFiltersConfig=Mo,w.getInitialMockContextMeta=io,w.getInitialQueriesRenderModel=jh,w.getInitialSQLSnippetsRenderModel=Sh,w.getInitialViewsRenderModel=ph,w.getNewPanel=xh,w.getStaticDateRangeDefaultValue=Yp,w.getVersion=X4,w.initialDashboardContent=C3,w.useDashboardContext=ni,w.useDashboardThemeContext=ql,w.useEditContentModelContext=re,w.useEditDashboardContext=se,w.useEditPanelContext=Le,w.useFullScreenPanelContext=Wl,w.useIsInEditPanelContext=Rl,w.useIsInRenderPanelContext=Ql,w.usePanelFullScreen=$h,w.useRenderContentModelContext=Te,w.useRenderDashboardContext=Vl,w.useRenderPanelContext=He,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
517
+ `),post:""},DM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),r=re();if(!e.isTransform)return null;const s=e.config;return n.jsxs(a.Stack,{py:20,px:20,sx:{height:"100%"},children:[n.jsx(a.Text,{size:"sm",children:t("query.transform.guide.pick_queries")}),n.jsx(a.MultiSelect,{data:r.queries.optionsWithoutTransform,value:[...s.dep_query_ids],onChange:s.setDependantQueryIDs,maxDropdownHeight:800}),n.jsx(a.Text,{size:"sm",children:t("query.transform.guide.write_function")}),n.jsx(a.Box,{sx:{flexGrow:1},children:n.jsx(Sn,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:kM.pre})})]})}),Er={height:"calc(100% - 44px)",padding:0},zM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),r=re(),s=f.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),[i,o]=f.useState(s);f.useEffect(()=>{o(u=>u!=="Configurations"&&s==="Configurations"?"Configurations":u)},[s]);const c=r.findQueryUsage(e.id).length===0;return n.jsxs(a.Tabs,{value:i,onChange:o,defaultValue:s,orientation:"horizontal",keepMounted:!1,sx:{height:"100vh"},children:[n.jsxs(a.Tabs.List,{grow:!0,children:[n.jsx(a.Tabs.Tab,{value:"Configurations",children:t("query.configurations")}),e.typedAsSQL&&n.jsx(a.Tabs.Tab,{value:"SQL",children:t("query.request")}),e.typedAsHTTP&&n.jsx(a.Tabs.Tab,{value:"HTTP",children:t("query.request")}),e.isTransform&&n.jsx(a.Tabs.Tab,{value:"Transform",children:t("query.transform.label")}),n.jsx(a.Tabs.Tab,{value:"Data",disabled:!e.canPreviewData,children:n.jsx(a.Tooltip,{label:e.guideToPreviewData,disabled:e.canPreviewData,withinPortal:!0,children:n.jsx(a.Text,{size:"sm",children:t("data.preview_data")})})}),n.jsx(a.Tabs.Tab,{value:"Usage",disabled:c,children:n.jsx(a.Tooltip,{label:t("query.usage.unused_description"),disabled:!c,withinPortal:!0,children:n.jsx(a.Text,{size:"sm",children:t("query.usage.label")})})})]}),n.jsx(a.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:n.jsx(xM,{queryModel:e})}),e.typedAsSQL&&n.jsx(a.Tabs.Panel,{value:"SQL",sx:Er,children:n.jsx(a.Stack,{sx:{height:"100%"},children:n.jsx(TM,{queryModel:e})})}),e.typedAsHTTP&&n.jsx(a.Tabs.Panel,{value:"HTTP",sx:Er,children:n.jsx(a.Stack,{sx:{height:"100%"},children:n.jsx(vM,{queryModel:e})})}),e.isTransform&&n.jsx(a.Tabs.Panel,{value:"Transform",sx:Er,children:n.jsx(a.Stack,{sx:{height:"100%"},children:n.jsx(DM,{queryModel:e})})}),n.jsx(a.Tabs.Panel,{value:"Data",sx:{...Er,overflow:"hidden"},children:n.jsx(Wo,{id:e.id,moreActions:null,refreshOnMount:!0})}),n.jsx(a.Tabs.Panel,{value:"Usage",py:"sm",px:"md",sx:{...Er,overflow:"hidden"},children:n.jsx(Ig,{queryModel:e})})]})}),IM=({width:e,height:t})=>n.jsxs("svg",{width:e,height:t,viewBox:"0 0 36 36",fill:"none",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.5 10.5C7.10217 10.5 6.72064 10.658 6.43934 10.9393C6.15804 11.2206 6 11.6022 6 12V28.5C6 28.8978 6.15804 29.2794 6.43934 29.5607C6.72064 29.842 7.10218 30 7.5 30H24C24.3978 30 24.7794 29.842 25.0607 29.5607C25.342 29.2794 25.5 28.8978 25.5 28.5V19.5C25.5 18.6716 26.1716 18 27 18C27.8284 18 28.5 18.6716 28.5 19.5V28.5C28.5 29.6935 28.0259 30.8381 27.182 31.682C26.3381 32.5259 25.1935 33 24 33H7.5C6.30653 33 5.16193 32.5259 4.31802 31.682C3.47411 30.8381 3 29.6935 3 28.5V12C3 10.8065 3.47411 9.66193 4.31802 8.81802C5.16193 7.97411 6.30653 7.5 7.5 7.5H16.5C17.3284 7.5 18 8.17157 18 9C18 9.82843 17.3284 10.5 16.5 10.5H7.5Z",fill:"#3D3E45"}),n.jsx("path",{d:"M32.8862 3.92582C32.8135 3.75021 32.7061 3.5856 32.5638 3.44253C32.5617 3.4404 32.5596 3.43828 32.5575 3.43616C32.2863 3.16658 31.9126 3 31.5 3H22.5C21.6716 3 21 3.67157 21 4.5C21 5.32843 21.6716 6 22.5 6H27.8787L13.9393 19.9393C13.3536 20.5251 13.3536 21.4749 13.9393 22.0607C14.5251 22.6464 15.4749 22.6464 16.0607 22.0607L30 8.12132V13.5C30 14.3284 30.6716 15 31.5 15C32.3284 15 33 14.3284 33 13.5V4.5C33 4.29662 32.9595 4.10268 32.8862 3.92582Z",fill:"#3D3E45"})]}),Eg=({width:e,height:t,color:r="#FFFFFF"})=>n.jsxs("svg",{viewBox:"0 0 36 36",fill:"none",width:e,height:t,children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24.6931 20.547C26.1129 19.5516 26.113 17.4483 24.6931 16.4529L16.9351 11.0141C15.2783 9.85255 13 11.0377 13 13.0611L13 23.9389C13 25.9623 15.2783 27.1474 16.9351 25.9859L24.6931 20.547ZM16 14.0223L22.387 18.5L16 22.9777L16 14.0223Z",fill:r}),n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18 1.5C8.8873 1.5 1.5 8.8873 1.5 18C1.5 27.1127 8.8873 34.5 18 34.5C27.1127 34.5 34.5 27.1127 34.5 18C34.5 8.8873 27.1127 1.5 18 1.5ZM4.5 18C4.5 10.5442 10.5442 4.5 18 4.5C25.4558 4.5 31.5 10.5442 31.5 18C31.5 25.4558 25.4558 31.5 18 31.5C10.5442 31.5 4.5 25.4558 4.5 18Z",fill:r})]}),Pg=({width:e,height:t,color:r="#EB1212"})=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",width:e,height:t,children:[n.jsx("path",{d:"M6.66665 6.66699C7.03484 6.66699 7.33331 6.96547 7.33331 7.33366V11.3337C7.33331 11.7018 7.03484 12.0003 6.66665 12.0003C6.29846 12.0003 5.99998 11.7018 5.99998 11.3337V7.33366C5.99998 6.96547 6.29846 6.66699 6.66665 6.66699Z",fill:r}),n.jsx("path",{d:"M9.99998 11.3337V7.33366C9.99998 6.96547 9.7015 6.66699 9.33331 6.66699C8.96512 6.66699 8.66665 6.96547 8.66665 7.33366V11.3337C8.66665 11.7018 8.96512 12.0003 9.33331 12.0003C9.7015 12.0003 9.99998 11.7018 9.99998 11.3337Z",fill:r}),n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66665 3.33366V2.66699C4.66665 2.13656 4.87736 1.62785 5.25243 1.25278C5.62751 0.877706 6.13621 0.666992 6.66665 0.666992H9.33331C9.86375 0.666992 10.3725 0.877706 10.7475 1.25278C11.1226 1.62785 11.3333 2.13656 11.3333 2.66699V3.33366H14C14.3682 3.33366 14.6666 3.63214 14.6666 4.00033C14.6666 4.36852 14.3682 4.66699 14 4.66699H13.3333V13.3337C13.3333 13.8641 13.1226 14.3728 12.7475 14.7479C12.3725 15.1229 11.8637 15.3337 11.3333 15.3337H4.66665C4.13621 15.3337 3.62751 15.1229 3.25243 14.7479C2.87736 14.3728 2.66665 13.8641 2.66665 13.3337V4.66699H1.99998C1.63179 4.66699 1.33331 4.36852 1.33331 4.00033C1.33331 3.63214 1.63179 3.33366 1.99998 3.33366H4.66665ZM6.19524 2.19559C6.32027 2.07056 6.48984 2.00033 6.66665 2.00033H9.33331C9.51012 2.00033 9.67969 2.07056 9.80472 2.19559C9.92974 2.32061 9.99998 2.49018 9.99998 2.66699V3.33366H5.99998V2.66699C5.99998 2.49018 6.07022 2.32061 6.19524 2.19559ZM3.99998 4.66699V13.3337C3.99998 13.5105 4.07022 13.68 4.19524 13.8051C4.32027 13.9301 4.48984 14.0003 4.66665 14.0003H11.3333C11.5101 14.0003 11.6797 13.9301 11.8047 13.8051C11.9297 13.68 12 13.5105 12 13.3337V4.66699H3.99998Z",fill:r})]}),MM=({width:e,height:t})=>n.jsxs("svg",{viewBox:"0 0 18 18",fill:"none",width:e,height:t,children:[n.jsx("path",{d:"M7.5 3.75C7.5 2.92157 8.17157 2.25 9 2.25C9.82843 2.25 10.5 2.92157 10.5 3.75C10.5 4.57843 9.82843 5.25 9 5.25C8.17157 5.25 7.5 4.57843 7.5 3.75Z",fill:"#3D3E45"}),n.jsx("path",{d:"M7.5 9C7.5 8.17157 8.17157 7.5 9 7.5C9.82843 7.5 10.5 8.17157 10.5 9C10.5 9.82843 9.82843 10.5 9 10.5C8.17157 10.5 7.5 9.82843 7.5 9Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9 12.75C8.17157 12.75 7.5 13.4216 7.5 14.25C7.5 15.0784 8.17157 15.75 9 15.75C9.82843 15.75 10.5 15.0784 10.5 14.25C10.5 13.4216 9.82843 12.75 9 12.75Z",fill:"#3D3E45"})]}),EM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),r=se(),s=re(),o=s.findQueryUsage(e.id).length>0,l=dt.useModals(),c=()=>{l.openConfirmModal({title:`${t("query.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{s.queries.removeQuery(e.id),r.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return o?n.jsx(a.Tooltip,{label:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"bottom-end",children:n.jsx(a.Button,{leftSection:n.jsx(Pg,{width:14,height:14,color:"gray"}),variant:"subtle",color:"gray",onClick:u=>{u.stopPropagation()},children:"删除查询"})}):n.jsx(a.Menu.Item,{leftSection:n.jsx(Pg,{width:14,height:14}),color:"red",onClick:c,children:"删除查询"})}),PM=k.observer(({queryModel:e})=>n.jsxs(a.Menu,{shadow:"md",width:120,trigger:"hover",children:[n.jsx(a.Menu.Target,{children:n.jsx(a.ActionIcon,{variant:"subtle","aria-label":"Settings",children:n.jsx(MM,{width:18,height:18})})}),n.jsx(a.Menu.Dropdown,{children:n.jsx(EM,{queryModel:e})})]})),AM={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 LM({data:e}){const t=f.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const s=Re.createColumnHelper();return Object.keys(e[0]).map(i=>s.accessor(i,{cell:o=>o.getValue()}))},[e]),r=Re.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Re.getCoreRowModel()});return e.length===0?n.jsx(a.Box,{sx:{height:"5em"}}):n.jsx(Ie,{children:n.jsxs(a.Table,{sx:AM,stickyHeader:!0,stickyHeaderOffset:0,children:[n.jsx(a.Table.Thead,{style:{backgroundColor:"#F9F9FA"},children:r.getHeaderGroups().map(s=>n.jsx(a.Table.Tr,{children:s.headers.map(i=>n.jsxs(a.Table.Th,{style:{width:i.getSize()},children:[i.isPlaceholder?null:Re.flexRender(i.column.columnDef.header,i.getContext()),n.jsx(a.ActionIcon,{variant:"subtle",onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:n.jsx(C.IconArrowBarToRight,{})})]},i.id))},s.id))}),n.jsx(a.Table.Tbody,{children:r.getRowModel().rows.map(s=>n.jsx(a.Table.Tr,{children:s.getVisibleCells().map(i=>n.jsx(a.Table.Td,{children:n.jsx(Ie,{children:typeof i.getValue()=="object"?n.jsx("pre",{children:JSON.stringify(i.getValue(),null,2)}):Re.flexRender(i.column.columnDef.cell,i.getContext())})},i.id))},s.id))})]})})}const OM=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],VM={root:{width:"150px"},section:{"&[data-position=left]":{width:"70px",textAlign:"center"}},input:{paddingLeft:"70px",paddingRight:0}},BM=({data:e,page:t,setPage:r,limit:s,setLimit:i})=>{const{t:o}=_.useTranslation(),l=e.length,c=Math.ceil(l/s),u=p=>{p&&(r(1),i(Number(p)))};if(l===0)return null;const d=c===1&&l<=10;return n.jsxs(a.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(a.Group,{justify:"flex-start",children:[!d&&n.jsx(a.Select,{leftSection:n.jsx(a.Text,{ta:"center",c:"dimmed",size:"xs",children:o("common.pagination.page_size")}),size:"xs",styles:VM,data:OM,value:String(s),onChange:u}),c>1&&n.jsx(a.Pagination,{size:"sm",value:t,onChange:r,total:c,withEdges:c>7,styles:{control:{height:"30px"}},color:"red"})]}),n.jsx(a.Group,{justify:"flex-end",children:n.jsx(a.Text,{c:"dimmed",my:0,size:"14px",children:o("common.pagination.total_rows",{total:l})})})]})},qM=xd(({data:e,loading:t})=>{const[r,s]=f.useState(1),[i,o]=f.useState(20),l=f.useMemo(()=>{const c=(r-1)*i,u=c+i;return e.slice(c,u)},[e,r,i]);return n.jsx(Ie,{children:n.jsxs(a.Stack,{gap:10,styles:{root:{height:"100%",overflow:"hidden"}},children:[n.jsx(BM,{data:e,page:r,setPage:s,limit:i,setLimit:o}),n.jsxs(a.Box,{sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(a.LoadingOverlay,{visible:t,overlayProps:{blur:2}}),n.jsx(LM,{data:l})]})]})})}),NM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),{state:r,error:s,metricQueryPayloadErrorString:i,stateMessage:o}=e;return r==="loading"?null:s?n.jsx(a.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:s}):i?n.jsx(a.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:i}):o?n.jsx(a.Text,{size:"sm",mt:10,c:"gray",ta:"center",children:t(o)}):null}),$M=k.observer(({queryModel:e})=>{_.useTranslation();const{data:t,state:r}=e,s=r==="loading",i=f.useCallback(()=>{e.fetchData(!0)},[e.fetchData]),o=()=>{gh(e.name,e.data)};f.useEffect(()=>{i()},[i]);const l=!Array.isArray(t)||t.length===0;return n.jsxs(a.Stack,{gap:0,sx:{minHeight:"250px",maxHeight:"calc(50vh - 48px)",flexGrow:1,flexShrink:0,background:"#F9F9FA"},children:[n.jsxs(a.Group,{justify:"space-between",py:7,px:8,children:[n.jsx(a.Text,{size:"sm",fw:500,children:"查询结果"}),n.jsx(a.Button,{size:"xs",variant:"transparent",color:"gray",leftSection:n.jsx(C.IconDownload,{size:16}),disabled:s||l,onClick:o,children:"下载查询结果"})]}),n.jsxs(a.Box,{sx:{position:"relative",flexGrow:1,overflow:"hidden"},children:[n.jsx(NM,{queryModel:e}),n.jsx(qM,{data:t,loading:s})]})]})}),GM=k.observer(({queryModel:e})=>{const t=se();return n.jsxs(a.Tabs,{defaultValue:"查询预览",styles:{root:{borderRadius:4,backgroundColor:"#F9F9FA",height:"100%",minHeight:"350px",maxHeight:"50vh",overflow:"hidden"}},color:"red",children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"查询预览",children:"查询预览"}),n.jsx(a.Tabs.Tab,{value:"看板变量预览",children:"看板变量预览"})]}),n.jsx(a.Tabs.Panel,{value:"查询预览",children:n.jsx(Dt.CodeHighlight,{language:"json",sx:{width:"100%",height:"100%",minHeight:"400px",overflowY:"auto"},withCopyButton:!1,code:e.metricQueryPayloadString})}),n.jsx(a.Tabs.Panel,{value:"看板变量预览",children:n.jsx(Dt.CodeHighlight,{language:"json",sx:{width:"100%",height:"100%",minHeight:"400px",overflowY:"auto"},withCopyButton:!1,code:t.queryVariablesString})})]})}),FM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.24335 1.62305C7.50108 1.62305 7.71001 1.83198 7.71001 2.08971L7.71001 11.423C7.71001 11.6808 7.50108 11.8897 7.24335 11.8897C6.98561 11.8897 6.77668 11.6808 6.77668 11.423L6.77668 2.08971C6.77668 1.83198 6.98561 1.62305 7.24335 1.62305Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9.93845 9.4786C9.80779 9.4786 9.70045 9.43893 9.61645 9.3596C9.53712 9.2756 9.49745 9.17293 9.49745 9.0516L9.49745 5.0056C9.49745 4.88427 9.53712 4.78393 9.61645 4.7046C9.70045 4.6206 9.80312 4.5786 9.92445 4.5786L12.1995 4.5786C12.3208 4.5786 12.4211 4.61827 12.5005 4.6976C12.5845 4.77227 12.6265 4.87027 12.6265 4.9916C12.6265 5.09427 12.5845 5.18527 12.5005 5.2646C12.4211 5.34393 12.3208 5.3836 12.1995 5.3836L10.3725 5.3836V6.6156H11.8845C12.0058 6.6156 12.1061 6.65527 12.1855 6.7346C12.2695 6.80927 12.3115 6.90727 12.3115 7.0286C12.3115 7.13127 12.2695 7.22227 12.1855 7.3016C12.1061 7.38093 12.0058 7.4206 11.8845 7.4206H10.3725L10.3725 9.0516C10.3725 9.17293 10.3281 9.2756 10.2395 9.3596C10.1555 9.43893 10.0551 9.4786 9.93845 9.4786Z",fill:"#3D3E45"}),n.jsx("path",{d:"M3.34754 9.4786C3.21687 9.4786 3.10954 9.43893 3.02554 9.3596C2.94154 9.2756 2.89954 9.17293 2.89954 9.0516L2.89954 5.3836H1.80054C1.6792 5.3836 1.57654 5.34627 1.49254 5.2716C1.4132 5.19693 1.37354 5.09893 1.37354 4.9776C1.37354 4.85627 1.4132 4.7606 1.49254 4.6906C1.57654 4.61593 1.6792 4.5786 1.80054 4.5786H4.90854C5.02987 4.5786 5.1302 4.61593 5.20954 4.6906C5.29354 4.76527 5.33554 4.86327 5.33554 4.9846C5.33554 5.10593 5.29354 5.20393 5.20954 5.2786C5.1302 5.3486 5.02987 5.3836 4.90854 5.3836H3.80954L3.80954 9.0516C3.80954 9.17293 3.7652 9.2756 3.67654 9.3596C3.59254 9.43893 3.48287 9.4786 3.34754 9.4786Z",fill:"#3D3E45"})]}),QM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("g",{clipPath:"url(#clip0_245_10828)",children:n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.91663 1.16634C9.91663 0.844175 9.65546 0.583008 9.33329 0.583008C9.01113 0.583008 8.74996 0.844175 8.74996 1.16634V1.74967L5.24996 1.74967V1.16634C5.24996 0.844175 4.98879 0.583008 4.66663 0.583008C4.34446 0.583008 4.08329 0.844175 4.08329 1.16634V1.74967H2.91663C1.95013 1.74967 1.16663 2.53318 1.16663 3.49967L1.16663 11.6663C1.16663 12.6328 1.95013 13.4163 2.91663 13.4163L11.0833 13.4163C12.0498 13.4163 12.8333 12.6328 12.8333 11.6663L12.8333 3.49967C12.8333 2.53318 12.0498 1.74967 11.0833 1.74967H9.91663V1.16634ZM11.6666 5.24967V3.49967C11.6666 3.17751 11.4055 2.91634 11.0833 2.91634H9.91663V3.49967C9.91663 3.82184 9.65546 4.08301 9.33329 4.08301C9.01113 4.08301 8.74996 3.82184 8.74996 3.49967V2.91634L5.24996 2.91634V3.49967C5.24996 3.82184 4.98879 4.08301 4.66663 4.08301C4.34446 4.08301 4.08329 3.82184 4.08329 3.49967V2.91634L2.91663 2.91634C2.59446 2.91634 2.33329 3.17751 2.33329 3.49967L2.33329 5.24967L11.6666 5.24967ZM2.33329 6.41634L11.6666 6.41634L11.6666 11.6663C11.6666 11.9885 11.4055 12.2497 11.0833 12.2497L2.91663 12.2497C2.59446 12.2497 2.33329 11.9885 2.33329 11.6663V6.41634Z",fill:"#3D3E45"})}),n.jsx("defs",{children:n.jsx("clipPath",{id:"clip0_245_10828",children:n.jsx("rect",{width:"14",height:"14",fill:"white"})})})]}),RM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.11108 2.13932C2.78892 2.13932 2.52775 2.40049 2.52775 2.72266V10.8893C2.52775 11.2115 2.78892 11.4727 3.11108 11.4727H11.2778C11.5999 11.4727 11.8611 11.2115 11.8611 10.8893V2.72266C11.8611 2.40049 11.5999 2.13932 11.2778 2.13932H3.11108ZM1.36108 2.72266C1.36108 1.75616 2.14459 0.972656 3.11108 0.972656H11.2778C12.2442 0.972656 13.0278 1.75616 13.0278 2.72266V10.8893C13.0278 11.8558 12.2442 12.6393 11.2778 12.6393H3.11108C2.14459 12.6393 1.36108 11.8558 1.36108 10.8893V2.72266Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9.84418 8.37166C9.94816 8.37166 10.0348 8.40631 10.1041 8.47563C10.1734 8.54494 10.2081 8.63159 10.2081 8.73556C10.2081 8.8352 10.1734 8.91968 10.1041 8.989C10.0348 9.05398 9.94816 9.08647 9.84418 9.08647H7.63475C7.52211 9.08647 7.4333 9.05182 7.36832 8.9825C7.30334 8.91318 7.27084 8.82437 7.27084 8.71607C7.27084 8.60776 7.30983 8.51245 7.38781 8.43014L8.80445 6.91603C8.96474 6.74274 9.09038 6.56512 9.18135 6.38317C9.27666 6.20121 9.32432 6.04309 9.32432 5.90879C9.32432 5.69218 9.2615 5.51889 9.13587 5.38892C9.01023 5.25462 8.84344 5.18747 8.63549 5.18747C8.55318 5.18747 8.4687 5.20697 8.38206 5.24596C8.29541 5.28495 8.21094 5.3391 8.12862 5.40842C8.05064 5.47773 7.977 5.55788 7.90768 5.64885C7.85569 5.71817 7.80371 5.76149 7.75172 5.77882C7.69973 5.79615 7.65208 5.80481 7.60876 5.80481C7.51345 5.80481 7.42464 5.77016 7.34233 5.70084C7.26435 5.62719 7.22536 5.54271 7.22536 5.44741C7.22536 5.37376 7.24918 5.30228 7.29684 5.23296C7.34882 5.16365 7.41164 5.09216 7.48529 5.01852C7.59359 4.91021 7.7149 4.8149 7.8492 4.73259C7.98349 4.65028 8.12213 4.58746 8.26509 4.54414C8.40805 4.49648 8.54668 4.47266 8.68098 4.47266C8.97124 4.47266 9.22251 4.53114 9.43479 4.64811C9.6514 4.76075 9.81819 4.92321 9.93516 5.13549C10.0521 5.34343 10.1106 5.59037 10.1106 5.8763C10.1106 6.11457 10.0391 6.381 9.89617 6.67559C9.75754 6.96585 9.56909 7.23878 9.33081 7.49438L8.50837 8.37166H9.84418Z",fill:"#3D3E45"}),n.jsx("path",{d:"M5.49994 9.08647C5.37864 9.08647 5.279 9.04965 5.20102 8.976C5.12304 8.89802 5.08405 8.80271 5.08405 8.69007V5.62518L4.70065 5.90879C4.64 5.95644 4.56418 5.98027 4.47321 5.98027C4.36923 5.98027 4.27826 5.94128 4.20028 5.8633C4.1223 5.78532 4.08331 5.69218 4.08331 5.58387C4.08331 5.44524 4.15046 5.3326 4.28475 5.24596L5.22051 4.62212C5.26384 4.59179 5.31149 4.57013 5.36348 4.55713C5.4198 4.54414 5.47178 4.53764 5.51944 4.53764C5.64507 4.53764 5.74471 4.57663 5.81836 4.65461C5.89201 4.72826 5.92883 4.8214 5.92883 4.93404V8.69007C5.92883 8.80271 5.88768 8.89802 5.80536 8.976C5.72738 9.04965 5.62558 9.08647 5.49994 9.08647Z",fill:"#3D3E45"})]}),WM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M12.0334 5.64833C12.3099 5.64833 12.55 5.67744 12.7537 5.73565C12.9623 5.79386 13.1224 5.87632 13.2339 5.98303C13.3504 6.0849 13.4086 6.20859 13.4086 6.35412C13.4086 6.45113 13.3795 6.5433 13.3213 6.63061C13.263 6.71307 13.1782 6.7543 13.0666 6.7543C12.989 6.7543 12.9235 6.7446 12.8701 6.7252C12.8216 6.70094 12.778 6.67184 12.7392 6.63788C12.7004 6.60393 12.6543 6.5724 12.6009 6.54329C12.5524 6.51419 12.4772 6.49236 12.3754 6.47781C12.2783 6.45841 12.2056 6.44871 12.1571 6.44871C11.9097 6.44871 11.6987 6.50206 11.5241 6.60878C11.3543 6.7155 11.2233 6.86102 11.1311 7.04535C11.039 7.22482 10.9929 7.43341 10.9929 7.67109C10.9929 7.90393 11.039 8.11251 11.1311 8.29684C11.2282 8.47631 11.3591 8.61941 11.5241 8.72613C11.6938 8.83284 11.8879 8.8862 12.1061 8.8862C12.2274 8.8862 12.3317 8.87893 12.419 8.86437C12.5063 8.84982 12.5791 8.82799 12.6373 8.79889C12.7052 8.76008 12.7658 8.71885 12.8192 8.6752C12.8726 8.63154 12.9526 8.60971 13.0593 8.60971C13.1854 8.60971 13.2824 8.65094 13.3504 8.7334C13.4183 8.81102 13.4522 8.90803 13.4522 9.02445C13.4522 9.14572 13.3843 9.25728 13.2485 9.35915C13.1127 9.45616 12.9332 9.5362 12.7101 9.59926C12.4918 9.65747 12.2541 9.68657 11.997 9.68657C11.6138 9.68657 11.2815 9.59926 11.0002 9.42463C10.7188 9.24516 10.5005 9.00262 10.3453 8.69702C10.1949 8.39143 10.1198 8.04945 10.1198 7.67109C10.1198 7.27333 10.1998 6.92408 10.3599 6.62333C10.5248 6.31774 10.7504 6.08005 11.0366 5.91027C11.3276 5.73565 11.6599 5.64833 12.0334 5.64833Z",fill:"#3D3E45"}),n.jsx("path",{d:"M7.74826 5.64833C8.08781 5.64833 8.39099 5.73565 8.65778 5.91027C8.92942 6.08005 9.14285 6.31531 9.29807 6.61606C9.45815 6.9168 9.53819 7.26606 9.53819 7.66382C9.53819 8.06158 9.45815 8.41326 9.29807 8.71885C9.14285 9.0196 8.93184 9.25728 8.66505 9.43191C8.40311 9.60169 8.10722 9.68657 7.77737 9.68657C7.58334 9.68657 7.40143 9.65505 7.23166 9.59199C7.06188 9.52893 6.91151 9.44889 6.78054 9.35187C6.65442 9.25486 6.55498 9.15784 6.48222 9.06083C6.41431 8.95896 6.38035 8.87408 6.38035 8.80617L6.60591 8.71158V9.24273C6.60591 9.36885 6.56468 9.47557 6.48222 9.56288C6.39976 9.64534 6.29547 9.68657 6.16935 9.68657C6.04323 9.68657 5.93894 9.64534 5.85647 9.56288C5.77401 9.48042 5.73278 9.3737 5.73278 9.24273V4.67333C5.73278 4.54722 5.77401 4.44292 5.85647 4.36046C5.93894 4.27315 6.04323 4.22949 6.16935 4.22949C6.29547 4.22949 6.39976 4.27315 6.48222 4.36046C6.56468 4.44292 6.60591 4.54722 6.60591 4.67333V6.52147L6.48222 6.45598C6.48222 6.39292 6.51617 6.31774 6.58408 6.23042C6.652 6.13826 6.74416 6.04852 6.86058 5.96121C6.97699 5.86904 7.11039 5.79386 7.26076 5.73565C7.41599 5.67744 7.57849 5.64833 7.74826 5.64833ZM7.63912 6.44871C7.42569 6.44871 7.23893 6.50206 7.07886 6.60878C6.91879 6.7155 6.79267 6.86102 6.7005 7.04535C6.61319 7.22482 6.56953 7.43098 6.56953 7.66382C6.56953 7.8918 6.61319 8.10038 6.7005 8.28956C6.79267 8.47389 6.91879 8.61941 7.07886 8.72613C7.23893 8.83285 7.42569 8.8862 7.63912 8.8862C7.85255 8.8862 8.03688 8.83285 8.19211 8.72613C8.35218 8.61941 8.47587 8.47389 8.56319 8.28956C8.65535 8.10038 8.70143 7.8918 8.70143 7.66382C8.70143 7.43098 8.65535 7.22482 8.56319 7.04535C8.47587 6.86102 8.35218 6.7155 8.19211 6.60878C8.03688 6.50206 7.85255 6.44871 7.63912 6.44871Z",fill:"#3D3E45"}),n.jsx("path",{d:"M3.02845 5.66289L1.45681 9.35915C1.42286 9.45131 1.3695 9.52408 1.29674 9.57743C1.22883 9.62594 1.15364 9.65019 1.07118 9.65019C0.940211 9.65019 0.843196 9.61381 0.780136 9.54105C0.717077 9.46829 0.685547 9.37855 0.685547 9.27184C0.685547 9.22818 0.692823 9.1821 0.707375 9.13359L2.51913 4.78248C2.55793 4.68546 2.61614 4.61028 2.69375 4.55692C2.77622 4.50356 2.86353 4.48173 2.95569 4.49143C3.04301 4.49143 3.12304 4.51811 3.19581 4.57147C3.27342 4.61998 3.3292 4.69031 3.36316 4.78248L5.15308 9.04628C5.17733 9.10934 5.18946 9.16755 5.18946 9.2209C5.18946 9.35187 5.1458 9.45616 5.05849 9.53378C4.97603 9.61139 4.88386 9.65019 4.782 9.65019C4.69468 9.65019 4.61465 9.62352 4.54189 9.57016C4.47398 9.5168 4.42062 9.44404 4.38181 9.35187L2.81745 5.70654L3.02845 5.66289ZM1.68237 8.47146L2.08256 7.63471H4.04711L4.18536 8.47146H1.68237Z",fill:"#3D3E45"})]}),UM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("g",{clipPath:"url(#clip0_567_6919)",children:n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.00001 1.02051C7.29533 1.02051 7.53473 1.25991 7.53473 1.55523V2.99492L11.3486 5.17429C11.5152 5.2695 11.6181 5.44667 11.6181 5.63856V9.97475L13.0725 10.702C13.3366 10.834 13.4437 11.1552 13.3116 11.4194C13.1795 11.6835 12.8583 11.7906 12.5942 11.6585L11.1002 10.9115L7.26531 13.1028C7.10091 13.1968 6.8991 13.1968 6.73471 13.1028L2.89985 10.9115L1.40581 11.6585C1.14167 11.7906 0.820476 11.6835 0.688405 11.4194C0.556335 11.1552 0.663399 10.834 0.92754 10.702L2.38195 9.97475V5.63856C2.38195 5.44667 2.48477 5.2695 2.65138 5.17429L6.46529 2.99492V1.55523C6.46529 1.25991 6.70469 1.02051 7.00001 1.02051ZM7.00001 3.9211L3.99444 5.63856L7.00001 7.35603L10.0056 5.63856L7.00001 3.9211ZM10.5486 6.55999L7.53473 8.28221V11.7171L10.5486 9.99492V6.55999ZM6.46529 11.7171V8.28221L3.4514 6.55999V9.99492L6.46529 11.7171Z",fill:"#3D3E45"})}),n.jsx("defs",{children:n.jsx("clipPath",{id:"clip0_567_6919",children:n.jsx("rect",{width:"14",height:"14",fill:"white"})})})]}),Xo=({type:e})=>{switch(e){case"boolean":return n.jsx(FM,{});case"date":return n.jsx(QM,{});case"number":return n.jsx(RM,{});case"string":return n.jsx(WM,{});case"dimension":return n.jsx(UM,{});default:return null}},YM={option:{fontFamily:"monospace","&.sub-option":{position:"relative",marginLeft:"22px"},"&.sub-option::before":{content:'""',width:"1px",height:"100%",position:"absolute",left:"-6px",borderLeft:"1px solid #E7E7E9"}},groupLabel:{cursor:"default",fontWeight:"normal","&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",borderBottom:"1px dashed var(--mantine-color-gray-2)"},"&::after":{borderBottom:"1px dashed var(--mantine-color-gray-2)",background:"none"}},group:{"&.dimension-group":{paddingBottom:"4px",".mantine-Combobox-groupLabel":{color:"#000"},".mantine-Combobox-groupLabel::before":{display:"none"},".mantine-Combobox-groupLabel::after":{display:"none"}}}},KM={root:{maxWidth:"unset"},option:{fontFamily:"monospace"},input:{paddingInlineStart:"var(--input-padding-inline-start)",color:"black",fontFamily:"monospace"}},Ag=(e,t,r)=>{const s=[];return t&&s.push("sub-option"),r&&s.push("disabled"),n.jsx(a.Combobox.Option,{value:e.value,className:s.join(" "),disabled:r,children:n.jsxs(a.Stack,{gap:1,children:[n.jsxs(a.Group,{gap:4,children:[n.jsx(Xo,{type:e.dataType}),n.jsx(a.Text,{size:"xs",children:e.label})]}),n.jsx(a.Text,{size:"xs",c:"dimmed",pl:18,children:e.description})]})},e.value)},Lg=k.observer(({mmInfo:e,value:t,onChange:r,usedKeys:s})=>{const i=e.metricDetail,o=e.metrics.loading||i.loading,l=i.error,c=i.filterColOptions,u=a.useCombobox({onDropdownClose:()=>u.resetSelectedOption()}),d=f.useMemo(()=>o?n.jsx(a.Loader,{size:"xs"}):t?n.jsx(a.CloseButton,{size:"xs",onClick:()=>r(null)}):n.jsx(a.Combobox.Chevron,{size:"xs"}),[o,t]),p=n.jsx(a.InputBase,{component:"button",type:"button",variant:"unstyled",size:"xs",pointer:!0,rightSection:d,rightSectionPointerEvents:!o&&t?"all":"none",onClick:()=>u.toggleDropdown(),disabled:o||c.length===0,styles:KM,error:!!l,children:t||n.jsx(a.Input.Placeholder,{children:"选择维度"})});return n.jsxs(a.Combobox,{store:u,onOptionSubmit:h=>{r(h),u.closeDropdown()},styles:YM,children:[n.jsx(a.Combobox.Target,{children:l?n.jsx(a.Tooltip,{label:l,children:p}):p}),n.jsx(a.Combobox.Dropdown,{miw:300,children:n.jsx(a.Combobox.Options,{children:c.map(({group:h,items:x})=>n.jsx(a.Combobox.Group,{label:h,children:x.map(b=>{var m;return"group"in b?n.jsx(a.Combobox.Group,{className:"dimension-group",label:n.jsxs(a.Group,{gap:4,children:[n.jsx(Xo,{type:"dimension"}),n.jsx(a.Text,{size:"sm",children:b.group}),n.jsx(a.Text,{size:"xs",c:"dimmed",children:b.description})]}),children:(m=b.items)==null?void 0:m.map(j=>Ag(j,!0,s.has(j.value)))},b.group):Ag(b,!1,s.has(b.value))})},h))})})]})}),Og={tbody:{td:{fontFamily:"monospace"}}},XM={root:{maxWidth:"unset"},option:{fontFamily:"monospace","&[data-checked=true][data-combobox-disabled]":{opacity:1}},input:{fontFamily:"monospace"},groupLabel:{"&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",backgroundColor:"var(--mantine-color-gray-2)"}}},HM=({option:e,...t})=>{const{t:r}=_.useTranslation(),s=e,i=s.type==="filter";return n.jsxs(a.Stack,{gap:0,py:4,styles:{root:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}}},...t,children:[n.jsx(a.Group,{flex:"1",gap:4,children:n.jsx(a.Text,{size:"xs",children:e.value})}),i&&n.jsxs(a.Group,{justify:"space-between",wrap:"nowrap",children:[n.jsx(a.Text,{size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",style:{flexShrink:1,flexGrow:1},children:s.widget_label}),n.jsx(a.Text,{size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",style:{flexShrink:0,flexGrow:0},children:r(rn[s.widget])})]})]})},Fs=k.observer(({queryModel:e,value:t,onChange:r,usedKeys:s})=>{const{t:i}=_.useTranslation();e.config;const o=f.useMemo(()=>e.getConditionOptionsWithInvalidValue(t).optionGroups.map(u=>{const d=u.items.length;return{group:`${i(u.group)}(${d})`,items:u.items.map(h=>({...h,label:h.value,widget_label:h.label,disabled:s.has(h.value)}))}}),[e.getConditionOptionsWithInvalidValue,i,t,s]),l=f.useCallback((c,u)=>{r(c,u)},[r]);return n.jsx(a.Select,{size:"xs",variant:"unstyled",placeholder:"选择变量",styles:XM,data:o,renderOption:HM,maxDropdownHeight:600,value:t,onChange:l,clearable:!0})}),Ho=k.observer(({variable:e})=>{const t=se();if(!e)return null;const r=v.has(t.queryVariables,e);return n.jsx(a.ThemeIcon,{variant:"white",size:"xs",color:r?"#88CE98":"#F15050",styles:{root:{flexGrow:0,flexShrink:0}},children:n.jsx(C.IconPointFilled,{})})}),ZM=k.observer(({queryModel:e})=>{const t=e.config,s=e.datasource.mericoMetricInfo;return f.useEffect(()=>{s.selectMetric(t.id)},[t.id,s]),n.jsxs(a.Stack,{gap:7,children:[n.jsxs(a.Group,{justify:"flex-start",gap:8,children:[n.jsx(a.Text,{size:"sm",children:"看板变量与指标维度关联"}),n.jsx(a.Tooltip,{label:"将看板的筛选器参数与指标的查询维度关联上,使指标可以按照看板的筛选条件和背景变量进行关联展示。",children:n.jsx(a.ActionIcon,{size:"xs",variant:"subtle",color:"gray",children:n.jsx(C.IconInfoCircle,{})})})]}),n.jsxs(a.Table,{withTableBorder:!0,withColumnBorders:!0,layout:"fixed",styles:Og,children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:250}}),n.jsx("col",{}),n.jsx("col",{style:{width:130}}),n.jsx("col",{style:{width:40}})]}),n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:"指标筛选维度"}),n.jsx(a.Table.Td,{children:"看板变量"}),n.jsx(a.Table.Td,{colSpan:2,children:"变量值为真时运行查询"})]})}),n.jsxs(a.Table.Tbody,{children:[t.filters.map(i=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{pr:0,children:n.jsx(Lg,{mmInfo:s,value:i.dimension,onChange:i.setDimension,usedKeys:t.usedFilterDimensionKeys})}),n.jsx(a.Table.Td,{colSpan:2,pr:0,children:n.jsxs(a.Group,{justify:"flex-start",grow:!0,gap:0,w:"100%",children:[n.jsx(Ho,{variable:i.variable}),n.jsx(Fs,{queryModel:e,value:i.variable,onChange:i.setVariable,usedKeys:t.usedFilterVariableSet})]})}),n.jsx(a.Table.Td,{children:n.jsx(a.Checkbox,{size:"xs",checked:e.keyInRunBy(i.variable),onChange:o=>e.changeRunByRecord(i.variable,o.currentTarget.checked),color:"red"})})]},i.dimension)),n.jsxs(a.Table.Tr,{className:"add-a-row",children:[n.jsx(a.Table.Td,{pr:0,children:n.jsx(Lg,{mmInfo:s,value:null,onChange:i=>i&&t.addFilter(i,""),usedKeys:t.usedFilterDimensionKeys})}),n.jsx(a.Table.Td,{colSpan:2,pr:0,children:n.jsx(Fs,{queryModel:e,value:null,onChange:i=>i&&t.addFilter("",i),usedKeys:t.usedFilterVariableSet})}),n.jsx(a.Table.Td,{})]})]})]})]})}),JM=k.observer(({queryModel:e,variable:t})=>{const r=e.keyInRunBy(t),s=i=>{e.changeRunByRecord(t,i.currentTarget.checked)};return n.jsx(a.Checkbox,{size:"xs",checked:r,onChange:s,color:"red"})}),Vg=({queryModel:e,variable:t})=>t?n.jsx(JM,{queryModel:e,variable:t}):null,e4=k.observer(({queryModel:e})=>{const t=e.config,o=e.datasource.mericoMetricInfo.metricDetail.trendingDateCol;return!t.timeQuery.enabled||!o?null:n.jsxs(a.Table,{withTableBorder:!0,withColumnBorders:!0,layout:"fixed",styles:Og,children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:250}}),n.jsx("col",{}),n.jsx("col",{style:{width:130}}),n.jsx("col",{style:{width:40}})]}),n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{}),n.jsx(a.Table.Td,{children:"看板变量"}),n.jsx(a.Table.Td,{colSpan:2,children:"变量值为真时运行查询"})]})}),n.jsxs(a.Table.Tbody,{children:[n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{pr:0,children:n.jsxs(a.Group,{gap:4,children:[n.jsx(a.Text,{size:"xs",children:"时间维度:"}),n.jsx(a.Text,{size:"xs",c:"dimmed",ff:"monospace",children:o.name})]})}),n.jsx(a.Table.Td,{colSpan:2,pr:0,children:n.jsxs(a.Group,{justify:"flex-start",gap:0,grow:!0,children:[n.jsx(Ho,{variable:t.timeQuery.range_variable}),n.jsx(Fs,{queryModel:e,value:t.timeQuery.range_variable,onChange:t.setRangeVariable,usedKeys:t.usedTimeQueryVariableSet})]})}),n.jsx(a.Table.Td,{children:n.jsx(Vg,{queryModel:e,variable:t.timeQuery.range_variable})})]},"dimension.time"),n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:n.jsx(a.Text,{size:"xs",children:"步长"})}),n.jsx(a.Table.Td,{colSpan:2,pr:0,children:n.jsxs(a.Group,{justify:"flex-start",gap:0,grow:!0,children:[n.jsx(Ho,{variable:t.timeQuery.unit_variable}),n.jsx(Fs,{queryModel:e,value:t.timeQuery.unit_variable,onChange:t.setUnitVariable,usedKeys:t.usedTimeQueryVariableSet})]})}),n.jsx(a.Table.Td,{children:n.jsx(Vg,{queryModel:e,variable:t.timeQuery.unit_variable})})]},"dimension.step")]})]})}),t4=k.observer(({queryModel:e})=>{const t=e.config,o=e.datasource.mericoMetricInfo.metricDetail.trendingDateCol;return n.jsxs(a.Stack,{gap:7,children:[n.jsxs(a.Group,{justify:"flex-start",gap:8,children:[n.jsx(a.Text,{size:"sm",children:"按时间序列展示"}),n.jsx(a.Tooltip,{label:"将看板的时间&步长筛选器与相应的查询维度关联上。",children:n.jsx(a.ActionIcon,{size:"xs",variant:"subtle",color:"gray",children:n.jsx(C.IconInfoCircle,{})})}),o?n.jsx(a.Switch,{size:"xs",color:"red",checked:t.timeQuery.enabled,onChange:l=>t.setTimeQueryEnabled(l.currentTarget.checked)}):n.jsx(a.Tooltip,{label:"由于指标未设定时序维度,所以不具备时间序列展示功能。",children:n.jsx(a.Box,{children:n.jsx(a.Switch,{size:"xs",color:"red",disabled:!o})})})]}),n.jsx(e4,{queryModel:e})]})}),n4={label:{fontWeight:"normal"},input:{fontSize:"12px"},groupLabel:{cursor:"default",fontWeight:"normal","&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",borderBottom:"1px dashed var(--mantine-color-gray-2)"},"&::after":{borderBottom:"1px dashed var(--mantine-color-gray-2)",background:"none"}},option:{fontFamily:"monospace"}},r4=e=>{const t=e.option;return n.jsxs(a.Stack,{gap:1,styles:{root:{flexGrow:1}},children:[n.jsxs(a.Group,{gap:4,children:[n.jsx(Xo,{type:t.dataType}),n.jsx(a.Text,{size:"xs",children:t.label})]}),n.jsx(a.Text,{size:"xs",c:"dimmed",pl:18,children:t.description})]})},s4=k.observer(({queryModel:e})=>{const t=e.config,s=e.datasource.mericoMetricInfo,i=s.metricDetail,o=s.metrics.loading||i.loading,l=i.groupByColOptions,c=u=>{const d=i.getGroupByOptions(u),p=[];d.forEach(h=>{h.dimension?h.dimension.fields.forEach(x=>{p.push(`${h.value} -> ${x.field}`)}):p.push(h.value)}),t.setGroupBys(p)};return n.jsx(a.MultiSelect,{size:"sm",label:"分组聚合维度",description:"指标在查询时按照哪些维度进行聚合计算。最多支持两个维度的聚合计算。若选择按时间序列展示,则仅可选择一个聚合维度。",data:l,searchable:!0,styles:n4,renderOption:r4,rightSection:o?n.jsx(a.Loader,{size:"xs"}):null,value:[...t.groupByValues],onChange:c,maxValues:t.timeQuery.enabled?1:2,placeholder:t.timeQuery.enabled?"仅可选一个维度":"最多选两个维度",disabled:o})}),i4=k.observer(({queryModel:e})=>{const t=e.config,r=t.id;return f.useEffect(()=>{if(e.run_by.length===0)return;const s=[],i=t.usedFilterVariableSet,o=t.usedTimeQueryVariableSet;e.run_by.forEach(l=>{(i.has(l)||o.has(l))&&s.push(l)}),e.setRunBy(s)},[t.usedFilterVariableSet,t.usedTimeQueryVariableSet,e.run_by]),n.jsxs(a.Stack,{gap:16,pos:"relative",children:[!r&&n.jsx(a.Overlay,{color:"#fff",backgroundOpacity:.5,blur:3,children:n.jsx(a.Center,{h:"100%",children:n.jsx(a.Text,{size:"sm",c:"black",children:"请先选择指标"})})}),n.jsx(ZM,{queryModel:e}),n.jsx(t4,{queryModel:e}),n.jsx(s4,{queryModel:e})]})}),a4=["function process_result(resp, utils, state) {"," return resp.data","}"].join(`
518
+ `),o4={root:{minHeight:"350px",maxHeight:"50vh",height:"100%",overflow:"hidden"},list:{"&::before":{borderColor:"transparent"}},panel:{height:"calc(100% - 36px)",overflowY:"auto"}},l4=k.observer(({queryModel:e})=>{const[t,r]=f.useState("编辑查询");return n.jsxs(a.Tabs,{color:"red",defaultValue:"编辑查询",styles:o4,value:t,onChange:r,children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"编辑查询",size:"xs",children:"编辑查询"}),n.jsx(a.Tabs.Tab,{value:"加工结果",size:"xs",children:"加工结果"}),n.jsx(a.Tabs.Tab,{value:"使用情况",size:"xs",children:"使用情况"})]}),n.jsx(a.Tabs.Panel,{value:"编辑查询",pt:"xs",children:n.jsx(i4,{queryModel:e})}),n.jsx(a.Tabs.Panel,{value:"加工结果",pt:"xs",children:n.jsx(Sn,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:a4})}),n.jsx(a.Tabs.Panel,{value:"使用情况",pt:"xs",children:n.jsx(Ig,{queryModel:e})})]})}),c4=k.observer(({queryModel:e})=>{const t=e.metricQueryPayloadError;return t.length>0?n.jsxs(a.HoverCard,{shadow:"md",children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.Box,{children:n.jsx(a.Button,{size:"xs",leftSection:n.jsx(Eg,{width:14,height:14,color:"rgb(173, 181, 189)"}),variant:"filled",color:"red",disabled:!0,children:"执行查询"})})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsx(a.List,{size:"xs",children:t.map(r=>n.jsx(a.List.Item,{children:r},r))})})]}):n.jsx(a.Button,{size:"xs",leftSection:n.jsx(Eg,{width:14,height:14}),variant:"filled",color:"red",onClick:()=>e.fetchData(!0),children:"执行查询"})}),u4=({option:e,...t})=>{const r=e;return n.jsxs(a.Stack,{gap:0,py:4,styles:{root:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}}},...t,children:[n.jsxs(a.Group,{flex:"1",gap:4,children:[n.jsx(C.IconHash,{size:12}),n.jsx(a.Text,{size:"xs",children:r.label})]}),n.jsx(a.Text,{ml:16,size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",children:r.description})]})},d4=k.observer(({queryModel:e})=>{const t=e.config,s=e.datasource.mericoMetricInfo,i=s.metrics;f.useEffect(()=>{i.load()},[i]),f.useEffect(()=>{!s.metricID&&t.id&&s.selectMetric(t.id)},[t.id]);const o=f.useMemo(()=>i.data.map(d=>({label:d.name,value:d.id,description:d.description,type:d.type})),[i.data]),l=f.useCallback((d,p)=>{d&&(s.selectMetric(d),t.setID(d),t.setType(p.type))},[s,t]),{loading:c,error:u}=i;return n.jsx(Ie,{children:n.jsxs(a.Group,{justify:"flex-end",gap:12,align:"flex-end",children:[u?n.jsx(a.Tooltip,{label:u,children:n.jsx(a.Select,{size:"xs",label:"指标",error:!0,styles:{root:{flexGrow:1}}})}):n.jsx(a.Select,{size:"xs",label:"指标",data:o,renderOption:u4,styles:{root:{flexGrow:1}},maxDropdownHeight:500,value:t.id,onChange:l,rightSection:c?n.jsx(a.Loader,{size:"xs"}):null}),n.jsx(a.Tooltip,{label:"跳转到指标明细页查看详情。",disabled:c,children:n.jsx(a.Anchor,{size:"md",variant:"subtle",mb:2,href:`/admin/metrics/detail/${t.id}`,target:"_blank",underline:"never",children:n.jsx(IM,{width:14,height:14})})})]})})}),p4=k.observer(({queryModel:e})=>{const{t}=_.useTranslation();return n.jsxs(a.Stack,{pt:8,pb:16,px:24,gap:8,styles:{root:{height:"100vh",overflow:"hidden"}},children:[n.jsx(a.Group,{styles:{root:{flexGrow:0,flexShrink:0}},children:n.jsx(a.TextInput,{size:"xs",placeholder:t("query.name_description"),label:t("query.name"),value:e.name,onChange:r=>{e.setName(r.currentTarget.value)},styles:{root:{flexGrow:0,width:"calc(50% - 44px)"}}})}),n.jsxs(a.Group,{justify:"space-between",grow:!0,gap:8,align:"flex-end",styles:{root:{flexGrow:0,flexShrink:0}},children:[n.jsxs(a.Group,{justify:"flex-start",grow:!0,gap:24,align:"flex-end",children:[n.jsx(kg,{queryModel:e,size:"xs"}),n.jsx(d4,{queryModel:e})]}),n.jsxs(a.Group,{justify:"flex-end",children:[n.jsx(c4,{queryModel:e}),n.jsx(PM,{queryModel:e})]})]}),n.jsxs(a.Group,{justify:"space-between",grow:!0,gap:12,align:"flex-start",sx:{flexGrow:0,flexShrink:1,overflowY:"hidden"},children:[n.jsx(l4,{queryModel:e}),n.jsx(GM,{queryModel:e})]}),n.jsx($M,{queryModel:e})]})}),h4=k.observer(({id:e})=>{const r=re().queries.findByID(e);return e===""?null:r?r.isMericoMetricQuery?n.jsx(p4,{queryModel:r}):n.jsx(zM,{queryModel:r}):n.jsx(a.Text,{size:"14px",c:"red",children:"Invalid Query ID"})}),g4=k.observer(({value:e})=>{const r=Te().payloadForSQL,s=f.useMemo(()=>Hs(e,r),[e,r]);return n.jsx(fa,{height:"100%",value:s})}),f4=k.observer(({item:e,remove:t,onKeyChanged:r})=>{const{t:s}=_.useTranslation(),[i,o]=f.useState("SQL"),[l,c]=f.useState(e.key),u=()=>{e.setKey(l),r(l)},d=l!==e.key,p=e.isADuplicatedKey(l),[h,x]=f.useState(e.value),b=()=>{e.setValue(h)};f.useEffect(()=>{c(e.key),x(e.value)},[e]);const m=h!==e.value,j=dt.useModals(),D=()=>{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 n.jsxs(a.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},gap:"sm",children:[n.jsxs(a.Group,{sx:{alignItems:"end"},gap:40,children:[n.jsx(a.TextInput,{label:s(p?"sql_snippet.key_occupied":"sql_snippet.key"),value:l,onChange:T=>{c(T.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:n.jsx(a.ActionIcon,{color:"blue",variant:"subtle",onClick:u,disabled:!d||p,children:n.jsx(C.IconDeviceFloppy,{size:16})}),error:p}),n.jsx(a.Button,{leftSection:n.jsx(C.IconTrash,{size:16}),color:"red",variant:"light",onClick:D,children:s("sql_snippet.delete")})]}),n.jsxs(a.Tabs,{value:i,onChange:o,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[n.jsxs(a.Tabs.List,{sx:{position:"relative"},children:[n.jsx(a.Tabs.Tab,{value:"SQL",children:s("sql_snippet.edit_snippet")}),n.jsx(a.Tabs.Tab,{value:"Preview",children:s("sql_snippet.preview_snippet")}),n.jsx(Ko,{}),n.jsx(a.ActionIcon,{color:"blue",variant:"filled",onClick:b,disabled:!m,sx:{position:"absolute",top:0,right:10},children:n.jsx(C.IconDeviceFloppy,{size:18})})]}),n.jsx(a.Tabs.Panel,{value:"SQL",pt:"sm",children:n.jsx(fa,{height:"100%",value:h,onChange:x,defaultLanguage:"sql",theme:"sql-dark"})}),n.jsx(a.Tabs.Panel,{value:"Preview",pt:"sm",children:n.jsx(g4,{value:h})})]})]})}),x4=k.observer(({id:e})=>{const t=se(),r=re(),s=f.useMemo(()=>r.sqlSnippets.findByKey(e),[e]);if(!e)return null;if(!s)return n.jsxs(a.Text,{size:"14px",children:["SQL Snippet by key[",e,"] is not found"]});const i=()=>{t.editor.setPath(["_SQL_SNIPPETS_",""])},o=()=>{r.sqlSnippets.removeByKey(e),i()},l=c=>{t.editor.setPath(["_SQL_SNIPPETS_",c])};return n.jsx(f4,{item:s,remove:o,onKeyChanged:l})}),m4=k.observer(()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState([]),s=dt.useModals(),i=se(),o=x=>{i.editor.setPath(["_SQL_SNIPPETS_",x])},l=()=>{s.openConfirmModal({title:"Delete ununsed SQL snippets?",children:n.jsx(a.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=f.useMemo(()=>i.content.sqlSnippets.sortedList.map(x=>x.key),[i.content.sqlSnippets.sortedList]),d=()=>{r(u)},p=()=>{r([])},h=i.content.sqlSnippetsUsage;return n.jsxs(a.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(a.Text,{size:"sm",px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("sql_snippet.manage")})}),n.jsxs(a.Flex,{justify:"space-between",align:"center",px:12,children:[n.jsxs(a.Group,{justify:"flex-start",children:[n.jsxs(a.Button.Group,{children:[n.jsx(a.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),n.jsx(a.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),n.jsx(a.Button,{size:"xs",color:"blue",leftSection:n.jsx(C.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),n.jsx(a.Button,{variant:"subtle",size:"xs",color:"red",leftSection:n.jsx(C.IconTrash,{size:14}),disabled:!i.content.hasUnusedSQLSnippets,onClick:l,children:e("sql_snippet.delete_unused")})]}),n.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(a.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"40px"}}),n.jsx(a.Table.Th,{children:e("common.key")}),n.jsx(a.Table.Th,{style:{width:"100px",textAlign:"center"},children:e("sql_snippet.usage.label")}),n.jsx(a.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(a.Table.Tbody,{children:i.content.sqlSnippets.sortedList.map(x=>{var m;const b=((m=h[x.key])==null?void 0:m.length)??0;return n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:n.jsx(a.Checkbox,{value:x.key,styles:{input:{cursor:"pointer"}}})}),n.jsx(a.Table.Td,{children:x.key}),n.jsx(a.Table.Td,{style:{color:b===0?"#ff0000":"#000",fontWeight:b===0?"bold":"normal",textAlign:"center"},children:b}),n.jsx(a.Table.Td,{children:n.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>o(x.key),children:e("common.actions.open")})})]},x.key)})})]})})})]})}),b4=k.observer(({view:e})=>!e||e.type!==F.Division?null:n.jsx(a.Stack,{})),y4=k.observer(({view:e})=>{const{t,i18n:r}=_.useTranslation(),s=f.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")}],[r.language]),i=f.useMemo(()=>[{value:"horizontal",label:t("common.tabs.orientation.horizontal")},{value:"vertical",label:t("common.tabs.orientation.vertical")}],[r.language]);if(!e||e.type!==F.Tabs)return null;const o=e.config;return n.jsxs(a.Stack,{children:[n.jsx(a.Divider,{mt:8,mb:0,label:t("view.component.tabs.tabs_settings"),labelPosition:"center"}),n.jsx(a.Select,{label:t("common.tabs.variant.label"),value:o.variant,onChange:o.setVariant,data:s}),n.jsx(a.Select,{label:t("common.tabs.orientation.label"),value:o.orientation,onChange:o.setOrientation,data:i}),n.jsx(a.Switch,{label:t("common.tabs.grow_tabs"),checked:o.grow,onChange:l=>o.setGrow(l.currentTarget.checked)})]})}),v4=({disabled:e,value:t,onChange:r})=>{const s=i=>{i&&r(i)};return n.jsxs(a.Box,{sx:{position:"relative"},children:[e&&n.jsx(a.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),n.jsx(ht,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},_4=({value:e,onChange:t})=>{const{t:r}=_.useTranslation(),[s,{setTrue:i,setFalse:o}]=Y.useBoolean(),[l,c]=f.useState(e??Ps),u=b=>{c({...l,enabled:b})},d=()=>{o();const{enabled:b,func_content:m}=l,j={enabled:b,func_content:m};c(j),t(j)},p=()=>{o(),c(e)},h=b=>{c(m=>({...m,func_content:b}))},x=()=>{h(Ps.func_content)};return n.jsxs(n.Fragment,{children:[n.jsx(a.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:i,sx:{flexGrow:0},children:n.jsx(C.IconSettings,{size:14})}),n.jsx(a.Modal,{size:800,title:r("view.component.modal.custom_title"),opened:s,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&n.jsxs(a.Stack,{children:[n.jsx(a.Checkbox,{mt:10,label:r("common.enabled"),checked:l.enabled,onChange:b=>u(b.currentTarget.checked)}),n.jsx(v4,{value:l.func_content,onChange:h,disabled:!l.enabled}),n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Button,{onClick:x,color:"red",leftSection:n.jsx(C.IconRecycle,{size:20}),children:r("common.actions.revert")}),n.jsxs(a.Group,{justify:"flex-end",children:[n.jsx(a.Button,{onClick:p,variant:"subtle",children:r("common.actions.cancel")}),n.jsx(a.Button,{onClick:d,children:r("common.actions.save")})]})]})]})})]})},j4=k.observer(({view:e})=>{const{t}=_.useTranslation();if(!e||e.type!==F.Modal)return null;const r=e.config,s=r.custom_modal_title.value;return n.jsxs(a.Stack,{children:[n.jsx(a.Divider,{mt:8,label:t("view.component.modal.modal_settings"),labelPosition:"center"}),n.jsxs(a.Flex,{gap:10,children:[n.jsx(a.TextInput,{label:t("view.component.modal.title"),value:s,onChange:v.noop,disabled:!0,sx:{flexGrow:1}}),n.jsx(_4,{value:r.custom_modal_title,onChange:r.custom_modal_title.replace})]}),n.jsxs(a.Group,{grow:!0,children:[n.jsx(a.TextInput,{label:t("view.component.modal.width"),value:r.width,onChange:i=>r.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),n.jsx(a.TextInput,{label:t("view.component.modal.height"),value:r.height,onChange:i=>r.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),w4=k.observer(({view:e})=>n.jsxs(n.Fragment,{children:[n.jsx(b4,{view:e}),n.jsx(j4,{view:e}),n.jsx(y4,{view:e})]})),C4=k.observer(({view:e})=>{const{t,i18n:r}=_.useTranslation(),s=f.useMemo(()=>[{label:t("view.component.div.label"),value:F.Division},{label:t("view.component.modal.label"),value:F.Modal},{label:t("view.component.tabs.label"),value:F.Tabs}],[r.language]);return e?n.jsxs(a.Stack,{sx:{position:"relative"},children:[n.jsx(a.TextInput,{label:t("common.name"),value:e.name,onChange:i=>{e.setName(i.currentTarget.value)}}),n.jsx(a.Select,{label:t("common.type"),comboboxProps:{withinPortal:!0,zIndex:320},value:e.type,onChange:e.setType,data:s}),n.jsx(w4,{view:e})]}):null}),S4=k.observer(({id:e})=>{const{t}=_.useTranslation(),r=dt.useModals(),s=se(),i=re();if(e==="")return null;const o=i.views.findByID(e);if(!o)return n.jsxs(a.Text,{size:"14px",children:["View by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_VIEWS_",""])},c=()=>{r.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()},confirmProps:{color:"red"},zIndex:320})};return n.jsxs(a.Stack,{sx:{maxWidth:"600px",height:"100%"},gap:"sm",children:[n.jsx(a.Group,{justify:"flex-end",pt:10,children:n.jsx(a.Button,{size:"xs",color:"red",leftSection:n.jsx(C.IconTrash,{size:16}),onClick:c,children:t("view.delete")})}),n.jsx(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n.jsx(C4,{view:o})})]})}),T4=k.observer(()=>n.jsx(a.Stack,{sx:{height:"100%"},p:"sm",children:n.jsx(Dg,{})})),k4=k.observer(()=>{const e=se().editor,t=e.path;return F5(t)?n.jsx(T4,{}):Q5(t)?n.jsx(mI,{}):R5(t)?n.jsx(xI,{}):W5(t)?n.jsx(a.Box,{p:"xs",pl:20,children:n.jsx(fI,{id:t[1]})}):U5(t)?n.jsx(m4,{}):Y5(t)?n.jsx(x4,{id:t[1]}):X5(t)?n.jsx(XI,{}):K5(t)?n.jsx(h4,{id:t[1]}):H5(t)?n.jsx(a.Box,{p:"xs",pl:20,children:n.jsx(S4,{id:t[1]})}):No(t)?n.jsx(KI,{viewID:t[1],panelID:t[3]}):n.jsx(a.Box,{children:e.path})}),D4=k.observer(()=>n.jsx(k4,{})),z4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=()=>{const s=new Date().getTime().toString(),i={id:s,key:s,label:s,order:t.content.filters.current.length+1,type:Q.TextInput,config:fo(),visibleInViewsIDs:["Main"],auto_submit:!1};t.content.filters.append(i),t.editor.setPath(["_FILTERS_",s])};return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("filter.add")})}),I4=k.observer(({parentID:e})=>{const{t}=_.useTranslation(),r=re();if(!e)return null;const s=r.views.findByID(e);return!s||s.type===F.Tabs?null:n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>r.addANewPanel(s.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("panel.add")})}),M4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=()=>{const s=new Date().getTime().toString(),i={id:s,name:s,type:J.Postgresql,key:"",config:{_type:J.Postgresql,sql:""}};t.content.queries.append(i),t.editor.setPath(["_QUERIES_",s])};return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("query.add")})}),E4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=()=>{const s=new Date().getTime().toString(),i={key:s,value:""};t.content.sqlSnippets.append(i),t.editor.setPath(["_SQL_SNIPPETS_",s])};return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("sql_snippet.add")})}),P4=k.observer(()=>{const{t:e}=_.useTranslation(),t=re();return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.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")})}),A4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.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")})}),L4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.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")})}),O4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.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")})}),V4=k.observer(({action_type:e,parentID:t})=>e==="_Add_A_Filter_"?n.jsx(z4,{}):e==="_Add_A_SQL_SNIPPET_"?n.jsx(E4,{}):e==="_Add_A_QUERY_"?n.jsx(M4,{}):e==="_Add_A_VIEW_"?n.jsx(P4,{}):e==="_Add_A_PANEL_"?n.jsx(I4,{parentID:t}):e==="_QUERIES_SETTINGS_"?n.jsx(A4,{}):e==="_SQL_SNIPPETS_SETTINGS_"?n.jsx(L4,{}):e==="_FILTERS_SETTINGS_"?n.jsx(O4,{}):null),Bg=k.observer(({option:e})=>{var p;const{t}=_.useTranslation(),r=se().editor,s=r.isOptionActive,i=s(r.path,e),o=r.isOptionOpened,l=r.navigate,c=o(e),[u,d]=f.useState(c);return f.useEffect(()=>{d(c)},[c]),n.jsx(a.NavLink,{active:i,defaultOpened:c,opened:u,onChange:d,label:t(e.label),onClick:()=>l(e),leftSection:e.Icon?n.jsx(e.Icon,{size:18}):null,children:(p=e.children)==null?void 0:p.map(h=>h._type==="ACTION"?n.jsx(V4,{action_type:h._action_type,parentID:h.parentID},`_ADD_${h.value}_`):n.jsx(Bg,{option:h},h.value))},e.label)}),B4=k.observer(()=>{const e=se();return n.jsx(a.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>n.jsx(Bg,{option:t},t.value))})}),q4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsxs(a.AppShell.Navbar,{p:0,sx:{height:"100vh - 60px - 60px",".mantine-NavLink-body":{wordWrap:"break-word"}},children:[n.jsx(a.AppShell.Section,{sx:{borderBottom:"1px solid #eee",padding:"var(--mantine-spacing-xs) var(--mantine-spacing-md)"},children:n.jsx(a.Text,{size:"sm",ta:"center",sx:{userSelect:"none",cursor:"default"},children:e("common.titles.settings")})}),n.jsx(a.AppShell.Section,{grow:!0,sx:{overflow:"auto"},children:n.jsx(B4,{})}),n.jsx(a.AppShell.Section,{children:n.jsx(a.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n.jsx(a.Button,{size:"xs",color:"red",leftSection:n.jsx(C.IconX,{size:18}),onClick:()=>t.editor.close(),children:e("common.actions.close")})})})]})}),N4={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"calc(var(--app-shell-navbar-width, 0px) + 1200px)"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},$4=k.observer(()=>{const e=se().editor;return n.jsx(a.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:n.jsxs(a.AppShell,{padding:0,navbar:{width:{base:220,xs:220,sm:240,md:260,lg:300,xl:320},breakpoint:"xxs"},styles:N4,children:[n.jsx(q4,{}),n.jsx(a.AppShell.Main,{children:n.jsx(D4,{})})]})})}),G4=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function F4(e){f.useEffect(()=>{if(ht.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const r=G4(e);ht.loader.config({paths:{vs:r}}),ht.loader.init().then(s=>console.log("monaco instance:",s))},[])}Hl(),bd();const Q4={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden","--app-shell-header-offset":"calc(3.75rem * var(--mantine-scale))"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},R4=({context:e,dashboard:t,content:r,update:s,className:i="dashboard",config:o,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h},x)=>{F4(o.monacoPath),Zs(o);const{data:b=[]}=Y.useRequest(ba),{data:m=[]}=Y.useRequest(yd),j=f.useMemo(()=>ig(t,r,b,m,e,u??{}),[t,r]);f.useImperativeHandle(x,()=>j,[j]),og(j.content,!0),f.useEffect(()=>{j.context.replace(e)},[e]),f.useEffect(()=>{j.datasources.replace(b)},[b]),f.useEffect(()=>{j.globalSQLSnippets.replace(m)},[m]),f.useEffect(()=>{d==null||d(j.content.filters.values)},[d,j.content.filters.values]),f.useEffect(()=>{u&&j.content.filters.patchValues(u)},[u,j.content.filters.patchValues]),f.useEffect(()=>te.reaction(()=>te.toJS(j.json),I=>{l==null||l(I)}),[j]);const D=async()=>{await s(j.json,j.content.json)},T=Y.useCreation(no,[]),z=lg(T);return Y.useWhyDidYouUpdate("@devtable/dashboard editor",{context:e,dashboard:t,content:r,update:s,className:i,config:o,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h}),n.jsx(on.MantineEmotionProvider,{children:n.jsx(ag,{lang:h,children:n.jsx(dt.ModalsProvider,{children:n.jsx(li,{children:n.jsx(ri,{value:{searchButtonProps:o.searchButtonProps},children:n.jsx(ti,{value:j,children:n.jsx(si,{value:j.content,children:n.jsxs($r.Provider,{value:{inEditMode:!0},children:[n.jsx(Tz,{}),n.jsx(tn.Provider,{value:T,children:n.jsxs(Ms,{configure:z,children:[n.jsxs(a.AppShell,{padding:0,navbar:{width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},breakpoint:"xxs"},styles:Q4,children:[n.jsx(Iz,{onExit:p,saveDashboardChanges:D,headerSlot:c}),n.jsx(rI,{}),n.jsx(a.AppShell.Main,{children:n.jsx(a.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:j.content.views.visibleViews.map(I=>n.jsx(Rh,{view:I},I.id))})})]}),n.jsx($4,{})]})})]})})})})})})})})},W4=k.observer(f.forwardRef(R4)),wE="",Zo=g.types.model({id:g.types.string,name:g.types.string,dashboard_id:g.types.string,create_time:g.types.string,update_time:g.types.string,version:g.types.string,filters:Io,queries:Po,sqlSnippets:Lo,views:ko,panels:zo,layouts:Ao,mock_context:so}).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=g.getParent(e).context.current,r=g.getParent(e).globalSQLSnippets,s={context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload};return{...s,sql_snippets:Ir(e.sqlSnippets.current,"key","value",s),global_sql_snippets:Ir(r.list,"id","content",s)}},get payloadForViz(){const t=g.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload}},get dashboardState(){return ma(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardState}},get data(){return e.queries.current.map(({id:r,data:s})=>({id:r,data:s})).reduce((r,s)=>(r[s.id]=s.data,r),{})},getDataStuffByID(t){const r=e.queries.findByID(t);return r?{data:r.data,len:r.data.length,state:r.state,error:r.error??r.metricQueryPayloadErrorString}:{data:[],len:0,state:"idle",error:void 0}}})).actions(e=>({}));function qg({id:e,name:t,dashboard_id:r,create_time:s,update_time:i,content:o},l,c,u){if(!o)throw new Error("unexpected null content when creating a content model");const{version:d,filters:p,views:h,panels:x,layouts:b,definition:{queries:m,sqlSnippets:j,mock_context:D={}}}=o;return Zo.create({id:e,name:t,dashboard_id:r,create_time:s,update_time:i,version:d,filters:Mo(p,l,D,c),queries:jh(m),sqlSnippets:Sh(j),mock_context:io(D),views:ph(h,u),panels:{list:x},layouts:{list:b,currentBreakpoint:b[0].id}})}const Ng=g.types.model({id:g.types.identifier,name:g.types.string,group:g.types.string,content:Zo,content_id:g.types.string,datasources:uh,globalSQLSnippets:Co,context:As});function $g({id:e,name:t,group:r,content_id:s},i,o,l,c,u,d){return Ng.create({id:e,name:t,group:r,content_id:s,content:qg(i,c,u,d),datasources:{list:o},globalSQLSnippets:{list:l},context:So(c)})}Hl(),bd();const U4=({context:e,dashboard:t,content:r,className:s="dashboard",config:i,fullScreenPanelID:o,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h})=>{Zs(i);const{data:x=[]}=Y.useRequest(ba),{data:b=[]}=Y.useRequest(yd),m=f.useMemo(()=>$g(t,r,x,b,e,c??{},d??null),[t,r,d]);og(m.content,!1),f.useEffect(()=>{m.context.replace(e)},[e]),f.useEffect(()=>{m.datasources.replace(x)},[x]),f.useEffect(()=>{m.globalSQLSnippets.replace(b)},[b]),f.useEffect(()=>{console.log("⚪️ calling onFilterValuesChange: ",m.content.filters.values),u==null||u(m.content.filters.values)},[u,m.content.filters.valuesString]),f.useEffect(()=>{c&&m.content.filters.patchValues(c)},[c,m.content.filters.patchValues]),f.useEffect(()=>{p==null||p(m.content.views.firstVisibleTabsViewActiveTab)},[p,m.content.views.firstVisibleTabsViewActiveTabStr]),f.useEffect(()=>{d&&m.content.views.setFirstVisibleTabsViewActiveTab(d)},[d,m.content.views.setFirstVisibleTabsViewActiveTab]);const j=Y.useCreation(no,[]),D=lg(j);return Y.useWhyDidYouUpdate("@devtable/dashboard render",{context:e,dashboard:t,content:r,className:s,config:i,fullScreenPanelID:o,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h}),n.jsx(on.MantineEmotionProvider,{children:n.jsx(ag,{lang:h,children:n.jsx(dt.ModalsProvider,{children:n.jsx(li,{children:n.jsx(ri,{value:{searchButtonProps:i.searchButtonProps},children:n.jsx(ti,{value:m,children:n.jsx(si,{value:m.content,children:n.jsx(oi.Provider,{value:{fullScreenPanelID:o,setFullScreenPanelID:l},children:n.jsx($r.Provider,{value:{inEditMode:!1},children:n.jsx(a.Box,{className:`${s} dashboard-root`,children:n.jsx(tn.Provider,{value:j,children:n.jsx(Ms,{configure:D,children:m.content.views.visibleViews.map(T=>n.jsx(Vs,{view:T},T.id))})})})})})})})})})})})})},Y4=k.observer(U4);A.extend(pf),A.extend(hf),A.extend(gf),A.extend(ff),A.extend(xf),A.extend(mf),A.extend(bf),A.extend(yf),A.extend(vf),A.extend(_f),A.extend(Cf),A.extend(Sf),A.extend(Tf),A.extend(kf),A.extend(Df),A.extend(jf),A.extend(wf),A.extend(zf),A.extend(If),A.extend(Mf),A.extend(Ef),A.extend(Pf),A.extend(Af),A.extend(Lf),A.extend(Of),A.extend(Vf),A.extend(Bf),A.extend(qf),A.extend(Nf),A.extend($f),A.extend(Ff),A.extend(Qf),A.extend(Gf),A.tz.setDefault("UTC"),A.updateLocale("en",{weekStart:1});const K4=()=>Promise.resolve().then(()=>zy).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));w.APIClient=gt,w.CURRENT_SCHEMA_VERSION=nn,w.ContentModel=Go,w.ContentModelContextProvider=si,w.ContentRenderModel=Zo,w.ContextMeta=As,w.DEFAULT_CUSTOM_MODAL_TITLE=Ps,w.DashboardApiClient=El,w.DashboardApiFacadeClient=Pl,w.DashboardEditor=W4,w.DashboardFilterType=Q,w.DashboardMode=Wh,w.DashboardModel=sg,w.DashboardModelContextProvider=ti,w.DashboardRenderModel=Ng,w.DashboardThemeContextProvider=ri,w.DashboardViewEditor=Rh,w.DashboardViewRender=Vs,w.DataSourceMetaModel=wo,w.DataSourceType=J,w.DataSourcesMetaModel=uh,w.DatesProvider=li,w.DefaultApiClient=Ml,w.DescriptionPopover=Oo,w.DraftModel=Th,w.EViewComponentType=F,w.FacadeApiClient=ix,w.FilterCheckboxConfigMeta=oo,w.FilterDateRangeConfigMeta=co,w.FilterMeta=yo,w.FilterMultiSelectConfigMeta=po,w.FilterSelectConfigMeta=ho,w.FilterTextInputConfigMeta=go,w.FilterTreeSelectConfigMeta=mo,w.FilterTreeSingleSelectConfigMeta=bo,w.FiltersModel=Yh,w.FiltersRenderModel=Io,w.FullScreenPanel=Nh,w.FullScreenPanelContext=oi,w.GlobalSQLSnippetMeta=dh,w.GlobalSQLSnippetsMeta=Co,w.LayoutItemMeta=Gp,w.LayoutSetMeta=Fp,w.LayoutStateContext=$r,w.LayoutsRenderModel=Ao,w.MericoMetricQueryMeta=ao,w.MockContextMeta=so,w.MuteQueryModel=_h,w.Panel=qh,w.PanelContextProvider=ii,w.PanelErrorOrStateMessage=Vh,w.PanelMeta=Lp,w.PanelModel=eg,w.PanelRender=Bo,w.PanelRenderModel=Do,w.PanelStyleMeta=Mp,w.PanelTitleMeta=Ep,w.PanelVizMeta=Ap,w.PanelVizSection=Vo,w.PanelsModel=tg,w.PanelsRenderModel=zo,w.QueriesModel=Xh,w.QueriesRenderModel=Po,w.QueryMeta=$p,w.QueryModel=Kh,w.QueryRenderModel=Eo,w.ReadOnlyDashboard=Y4,w.SQLSnippetMeta=Qp,w.SQLSnippetRenderModel=Ch,w.SQLSnippetsModel=Hh,w.SQLSnippetsRenderModel=Lo,w.VariableMeta=Pp,w.ViewComponentTypeBackground=Uh,w.ViewComponentTypeColor=k5,w.ViewComponentTypeName=T5,w.ViewDivisionConfig=vo,w.ViewMeta=ch,w.ViewModalConfig=_o,w.ViewRenderModel=To,w.ViewTabsConfig=jo,w.ViewsModel=ng,w.ViewsRenderModel=ko,w.Viz=Oh,w.applyPartialDashboard=rz,w.configureAPIClient=Zs,w.createContentModel=rg,w.createContentRenderModel=qg,w.createContextMeta=So,w.createDashboardModel=ig,w.createDashboardRenderModel=$g,w.createDraft=kh,w.createFilterCheckboxConfig=Rp,w.createFilterDateRangeConfig=Xp,w.createFilterMultiSelectConfig=Zp,w.createFilterSelectConfig=Jp,w.createFilterTextInputConfig=fo,w.createFilterTreeSelectConfig=sh,w.createFilterTreeSingleSelectConfig=ih,w.createMericoMetricQueryMetaConfig=Np,w.createViewDivisionConfig=ah,w.createViewModalConfig=oh,w.createViewTabsConfig=lh,w.facadeApiClient=Al,w.formatSQLSnippet=Ir,w.getInitialDashboardViewsModel=$o,w.getInitialFiltersConfig=Mo,w.getInitialMockContextMeta=io,w.getInitialQueriesRenderModel=jh,w.getInitialSQLSnippetsRenderModel=Sh,w.getInitialViewsRenderModel=ph,w.getNewPanel=xh,w.getStaticDateRangeDefaultValue=Yp,w.getVersion=K4,w.initialDashboardContent=C3,w.useDashboardContext=ni,w.useDashboardThemeContext=ql,w.useEditContentModelContext=re,w.useEditDashboardContext=se,w.useEditPanelContext=Le,w.useFullScreenPanelContext=Wl,w.useIsInEditPanelContext=Rl,w.useIsInRenderPanelContext=Ql,w.usePanelFullScreen=$h,w.useRenderContentModelContext=Te,w.useRenderDashboardContext=Vl,w.useRenderPanelContext=He,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});