@devtable/dashboard 5.6.0-alpha → 5.6.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.
- package/dist/dashboard.es.js +16 -7
- package/dist/dashboard.umd.js +2 -2
- package/package.json +1 -1
package/dist/dashboard.es.js
CHANGED
|
@@ -846,12 +846,21 @@ const tt = {
|
|
|
846
846
|
app_id: "",
|
|
847
847
|
app_secret: "",
|
|
848
848
|
getAuthentication(e) {
|
|
849
|
-
if (!
|
|
850
|
-
return
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
849
|
+
if (!this.app_id || !this.app_secret)
|
|
850
|
+
return;
|
|
851
|
+
const t = new Date().getTime().toString();
|
|
852
|
+
return {
|
|
853
|
+
app_id: this.app_id,
|
|
854
|
+
nonce_str: t,
|
|
855
|
+
sign: kl(
|
|
856
|
+
{
|
|
857
|
+
app_id: this.app_id,
|
|
858
|
+
nonce_str: t,
|
|
859
|
+
...e
|
|
860
|
+
},
|
|
861
|
+
this.app_secret
|
|
862
|
+
)
|
|
863
|
+
};
|
|
855
864
|
},
|
|
856
865
|
getRequest(e) {
|
|
857
866
|
return (t, n, r = {}) => {
|
|
@@ -3336,7 +3345,7 @@ const Gs = (e) => {
|
|
|
3336
3345
|
getColor: en(["#fff7f1", "darkorange", "#b60000"]),
|
|
3337
3346
|
name: "orange",
|
|
3338
3347
|
category: "sequential"
|
|
3339
|
-
}, Xs = "5.6.0
|
|
3348
|
+
}, Xs = "5.6.0";
|
|
3340
3349
|
class Js {
|
|
3341
3350
|
constructor(t) {
|
|
3342
3351
|
z(this, "staticColors", /* @__PURE__ */ new Map());
|
package/dist/dashboard.umd.js
CHANGED
|
@@ -24,7 +24,7 @@ Check the render method of \``+m+"`."}return""}}function Fg(m){{if(m!==void 0){v
|
|
|
24
24
|
|
|
25
25
|
Check your code at `+_+":"+A+"."}return""}}var Ji={};function Og(m){{var _=Xi();if(!_){var A=typeof m=="string"?m:m.displayName||m.name;A&&(_=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+A+">.")}return _}}function Ki(m,_){{if(!m._store||m._store.validated||m.key!=null)return;m._store.validated=!0;var A=Og(_);if(Ji[A])return;Ji[A]=!0;var R="";m&&m._owner&&m._owner!==Rn.current&&(R=" It was passed a child from "+le(m._owner.type)+"."),Be(m),$('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',A,R),Be(null)}}function Zi(m,_){{if(typeof m!="object")return;if(Tn(m))for(var A=0;A<m.length;A++){var R=m[A];On(R)&&Ki(R,_)}else if(On(m))m._store&&(m._store.validated=!0);else if(m){var L=S(m);if(typeof L=="function"&&L!==m.entries)for(var j=L.call(m),G;!(G=j.next()).done;)On(G.value)&&Ki(G.value,_)}}}function kg(m){{var _=m.type;if(_==null||typeof _=="string")return;var A;if(typeof _=="function")A=_.propTypes;else if(typeof _=="object"&&(_.$$typeof===d||_.$$typeof===f))A=_.propTypes;else return;if(A){var R=le(_);wg(A,m.props,"prop",R,m)}else if(_.PropTypes!==void 0&&!Fn){Fn=!0;var L=le(_);$("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",L||"Unknown")}typeof _.getDefaultProps=="function"&&!_.getDefaultProps.isReactClassApproved&&$("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Pg(m){{for(var _=Object.keys(m.props),A=0;A<_.length;A++){var R=_[A];if(R!=="children"&&R!=="key"){Be(m),$("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",R),Be(null);break}}m.ref!==null&&(Be(m),$("Invalid attribute `ref` supplied to `React.Fragment`."),Be(null))}}function eo(m,_,A,R,L,j){{var G=be(m);if(!G){var z="";(m===void 0||typeof m=="object"&&m!==null&&Object.keys(m).length===0)&&(z+=" 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 oe=Fg(L);oe?z+=oe:z+=Xi();var X;m===null?X="null":Tn(m)?X="array":m!==void 0&&m.$$typeof===t?(X="<"+(le(m.type)||"Unknown")+" />",z=" Did you accidentally export a JSX literal instead of a component?"):X=typeof m,$("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",X,z)}var J=Rg(m,_,A,L,j);if(J==null)return J;if(G){var he=_.children;if(he!==void 0)if(R)if(Tn(he)){for(var je=0;je<he.length;je++)Zi(he[je],m);Object.freeze&&Object.freeze(he)}else $("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 Zi(he,m)}return m===r?Pg(J):kg(J),J}}function zg(m,_,A){return eo(m,_,A,!0)}function Gg(m,_,A){return eo(m,_,A,!1)}var Ng=Gg,Lg=zg;Ye.Fragment=r,Ye.jsx=Ng,Ye.jsxs=Lg}()),Ye}(function(e){process.env.NODE_ENV==="production"?e.exports=wo():e.exports=So()})(rt);const Y=rt.exports.Fragment,o=rt.exports.jsx,g=rt.exports.jsxs;class Le extends D.default.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const n=()=>{this.setState({error:null})};return g(a.Box,{children:[o(a.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),o(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}function _o({label:e,config:{default_value:t,...n},value:r,onChange:i}){return g(a.Box,{children:[o(a.Text,{children:"\xA0"}),o(a.Checkbox,{label:e,checked:r,onChange:l=>i(l.currentTarget.checked),...n,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})}const Wn=M.observer(({label:e,config:t,value:n=[null,null],onChange:r})=>{const i=Array.isArray(n)?n.map(s=>s?Me.default(s).toDate():null):[null,null],l=s=>{r(s.map(u=>u&&Me.default(u).format(t.inputFormat)))};return o(no.DateRangePicker,{label:e,value:i,onChange:l,icon:o(T.Calendar,{size:16}),sx:{minWidth:"16em"},styles:{input:{borderColor:"#e9ecef"}},...t})});function Do(e,t,n){const r=Rt(t,[],n),i=Object.keys(r),l=Object.values(r);try{return new Function(...i,`return \`${e}\`;`)(...l)}catch(s){return console.error(s),s.message}}function $t(e,t={}){const n=Object.keys(t),r=Object.values(t);try{return new Function(...n,`return \`${e}\`;`)(...r)}catch(i){throw n.length===0&&e.includes("$")?new Error("[formatSQL] insufficient params"):i}}function Rt(e,t,n){const r={...e,filters:n},i=t.reduce((l,s)=>(l[s.key]=$t(s.value,r),l),{});return N.default.merge({},{context:e,filters:n,sql_snippets:i})}function Un(e,t,n,r){try{const i=Rt(t,n,r);return $t(e,i)}catch(i){return console.error(i),i.message}}function Io(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const i=t[r];if(i!="authentication"&&e[i])n.push(t[r]+"="+(typeof e[i]=="object"?JSON.stringify(e[i]):e[i]));else{const l=Object.keys(e[i]).sort();for(let s=0;s<l.length;s++){const u=l[s];u!="sign"&&e[i][u]&&n.push(l[s]+"="+(typeof e[i][u]=="object"?JSON.stringify(e[i][u]):e[i][u]))}}}return n.sort().join("&")}function Ao(e,t){let n=Io(e);return n+="&key="+t,yo.default.MD5(n).toString().toUpperCase()}const ze={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(e){if(!(!this.app_id||!this.app_secret))return{app_id:this.app_id,nonce_str:new Date().getTime().toString(),sign:Ao(e,this.app_secret)}},getRequest(e){return(t,n,r={})=>{const i=window.localStorage.getItem("token"),l={"X-Requested-With":"XMLHttpRequest","Content-Type":r.string?"application/x-www-form-urlencoded":"application/json",authorization:i?`bearer ${i}`:"",...r.headers},s={baseURL:this.baseURL,method:e,url:t,params:e==="GET"?n:r.params,headers:l};return["POST","PUT"].includes(e)&&(s.data=r.string?JSON.stringify(n):n,s.data.authentication=this.getAuthentication(s.data)),vo.default(s).then(u=>u.data).catch(u=>Promise.reject(u))}}};function Yn(e){ze.baseURL!==e.apiBaseURL&&(ze.baseURL=e.apiBaseURL),e.app_id&&(ze.app_id=e.app_id),e.app_secret&&(ze.app_secret=e.app_secret)}const Ft=({type:e,key:t,sql:n})=>async()=>{if(!e||!t||!n)return[];try{return await ze.getRequest("POST")("/query",{type:e,key:t,query:n})}catch(r){return console.error(r),[]}};async function Mo({context:e,sqlSnippets:t,title:n,query:r,filterValues:i}){if(!r.sql)return[];const{type:l,key:s,sql:u}=r,d=u.includes("$"),p=Rt(e,t,i),c=$t(u,p);return d&&(console.groupCollapsed(`Final SQL for: ${n}`),console.log(c),console.groupEnd()),await ze.getRequest("POST")("/query",{type:l,key:s,query:c})}async function Vo(){try{return(await ze.getRequest("POST")("/datasource/list",{filter:{},sort:{field:"create_time",order:"ASC"},pagination:{page:1,pagesize:100}})).data}catch(e){return console.error(e),[]}}function Eo({label:e,config:t,value:n,onChange:r}){const i=!!t.options_query.sql,{data:l=[],loading:s}=U.useRequest(Ft(t.options_query),{refreshDeps:[t.options_query,i]});return o(a.MultiSelect,{label:e,data:i?l:t.static_options,disabled:i?s:!1,value:n,onChange:r,sx:{minWidth:"14em"},styles:{input:{borderColor:"#e9ecef"}}})}function To({label:e,config:t,value:n,onChange:r}){const i=!!t.options_query.sql,{data:l=[],loading:s}=U.useRequest(Ft(t.options_query),{refreshDeps:[t.options_query,i]});return o(a.Select,{label:e,data:i?l:t.static_options,disabled:i?s:!1,value:n,onChange:r,styles:{input:{borderColor:"#e9ecef"}}})}function $o({label:e,config:t,value:n,onChange:r}){return o(a.TextInput,{label:e,value:n,onChange:r,...t,styles:{input:{borderColor:"#e9ecef"}}})}const Ro=M.observer(({filter:{type:e,config:t,key:n,...r},formFieldProps:i})=>{switch(e){case"select":return o(To,{...r,...i,config:t});case"multi-select":return o(Eo,{...r,...i,config:t});case"text-input":return o($o,{...r,...i,config:t});case"date-range":return o(Wn,{...r,...i,config:t});case"checkbox":return o(_o,{...r,...i,config:t});default:return null}}),Qn=M.observer(D.default.forwardRef(({filter:e,...t},n)=>o("div",{className:"filter-root",ref:n,children:o(Le,{children:o(Ro,{filter:e,formFieldProps:t})})}))),Hn=M.observer(function({view:t}){const n=Q(),{control:r,handleSubmit:i}=x.useForm({defaultValues:n.filters.values}),l=n.filters.visibleInView(t.id);return l.length===0?null:o("form",{onSubmit:i(n.filters.setValues),children:g(a.Group,{className:"dashboard-filters",position:"apart",p:"md",noWrap:!0,sx:{border:"1px solid #e9ecef",borderRadius:"4px"},children:[o(a.Group,{align:"flex-start",children:l.map(s=>o(x.Controller,{name:s.key,control:r,render:({field:u})=>o(Qn,{filter:s,...u})},s.id))}),o(a.Group,{sx:{alignSelf:"flex-end"},children:o(a.Button,{color:"blue",size:"sm",type:"submit",children:"Submit"})})]})})});var it={exports:{}};(function(e,t){(function(n,r){r()})(Pe,function(){function n(p,c){return typeof c>"u"?c={autoBom:!1}:typeof c!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),c={autoBom:!c}),c.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(p.type)?new Blob(["\uFEFF",p],{type:p.type}):p}function r(p,c,f){var h=new XMLHttpRequest;h.open("GET",p),h.responseType="blob",h.onload=function(){d(h.response,c,f)},h.onerror=function(){console.error("could not download file")},h.send()}function i(p){var c=new XMLHttpRequest;c.open("HEAD",p,!1);try{c.send()}catch{}return 200<=c.status&&299>=c.status}function l(p){try{p.dispatchEvent(new MouseEvent("click"))}catch{var c=document.createEvent("MouseEvents");c.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),p.dispatchEvent(c)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Pe=="object"&&Pe.global===Pe?Pe:void 0,u=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),d=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!u?function(p,c,f){var h=s.URL||s.webkitURL,v=document.createElement("a");c=c||p.name||"download",v.download=c,v.rel="noopener",typeof p=="string"?(v.href=p,v.origin===location.origin?l(v):i(v.href)?r(p,c,f):l(v,v.target="_blank")):(v.href=h.createObjectURL(p),setTimeout(function(){h.revokeObjectURL(v.href)},4e4),setTimeout(function(){l(v)},0))}:"msSaveOrOpenBlob"in navigator?function(p,c,f){if(c=c||p.name||"download",typeof p!="string")navigator.msSaveOrOpenBlob(n(p,f),c);else if(i(p))r(p,c,f);else{var h=document.createElement("a");h.href=p,h.target="_blank",setTimeout(function(){l(h)})}}:function(p,c,f,h){if(h=h||open("","_blank"),h&&(h.document.title=h.document.body.innerText="downloading..."),typeof p=="string")return r(p,c,f);var v=p.type==="application/octet-stream",C=/constructor/i.test(s.HTMLElement)||s.safari,y=/CriOS\/[\d]+/.test(navigator.userAgent);if((y||v&&C||u)&&typeof FileReader<"u"){var S=new FileReader;S.onloadend=function(){var F=S.result;F=y?F:F.replace(/^data:[^;]*;/,"data:attachment/file;"),h?h.location.href=F:location=F,h=null},S.readAsDataURL(p)}else{var E=s.URL||s.webkitURL,$=E.createObjectURL(p);h?h.location=$:location.href=$,h=null,setTimeout(function(){E.revokeObjectURL($)},4e4)}});s.saveAs=d.saveAs=d,e.exports=d})})(it);function Fo(e,t){const n=new Blob([t],{type:"text/csv"});it.exports.saveAs(n,`${e}.csv`)}function Oo(e,t){const n=new Blob([t],{type:"application/json"});it.exports.saveAs(n,`${e}.json`)}function ko(e){const t=new bo.default;e.forEach(({id:n,data:r})=>{t.file(`${n}.csv`,Xn(r))}),t.generateAsync({type:"blob"}).then(n=>{it.exports.saveAs(n,"dashboard_data.zip")})}function Xn(e){if(!Array.isArray(e)||e.length===0)return"";const t=[],n=Object.keys(e[0]);return t.push(n.join(",")),e.forEach(r=>{const i=Object.values(r).join(",");t.push(i)}),t.join(`
|
|
27
|
+
Check the top-level render call using <`+A+">.")}return _}}function Ki(m,_){{if(!m._store||m._store.validated||m.key!=null)return;m._store.validated=!0;var A=Og(_);if(Ji[A])return;Ji[A]=!0;var R="";m&&m._owner&&m._owner!==Rn.current&&(R=" It was passed a child from "+le(m._owner.type)+"."),Be(m),$('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',A,R),Be(null)}}function Zi(m,_){{if(typeof m!="object")return;if(Tn(m))for(var A=0;A<m.length;A++){var R=m[A];On(R)&&Ki(R,_)}else if(On(m))m._store&&(m._store.validated=!0);else if(m){var L=S(m);if(typeof L=="function"&&L!==m.entries)for(var j=L.call(m),G;!(G=j.next()).done;)On(G.value)&&Ki(G.value,_)}}}function kg(m){{var _=m.type;if(_==null||typeof _=="string")return;var A;if(typeof _=="function")A=_.propTypes;else if(typeof _=="object"&&(_.$$typeof===d||_.$$typeof===f))A=_.propTypes;else return;if(A){var R=le(_);wg(A,m.props,"prop",R,m)}else if(_.PropTypes!==void 0&&!Fn){Fn=!0;var L=le(_);$("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",L||"Unknown")}typeof _.getDefaultProps=="function"&&!_.getDefaultProps.isReactClassApproved&&$("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Pg(m){{for(var _=Object.keys(m.props),A=0;A<_.length;A++){var R=_[A];if(R!=="children"&&R!=="key"){Be(m),$("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",R),Be(null);break}}m.ref!==null&&(Be(m),$("Invalid attribute `ref` supplied to `React.Fragment`."),Be(null))}}function eo(m,_,A,R,L,j){{var G=be(m);if(!G){var z="";(m===void 0||typeof m=="object"&&m!==null&&Object.keys(m).length===0)&&(z+=" 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 oe=Fg(L);oe?z+=oe:z+=Xi();var X;m===null?X="null":Tn(m)?X="array":m!==void 0&&m.$$typeof===t?(X="<"+(le(m.type)||"Unknown")+" />",z=" Did you accidentally export a JSX literal instead of a component?"):X=typeof m,$("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",X,z)}var J=Rg(m,_,A,L,j);if(J==null)return J;if(G){var he=_.children;if(he!==void 0)if(R)if(Tn(he)){for(var je=0;je<he.length;je++)Zi(he[je],m);Object.freeze&&Object.freeze(he)}else $("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 Zi(he,m)}return m===r?Pg(J):kg(J),J}}function zg(m,_,A){return eo(m,_,A,!0)}function Gg(m,_,A){return eo(m,_,A,!1)}var Ng=Gg,Lg=zg;Ye.Fragment=r,Ye.jsx=Ng,Ye.jsxs=Lg}()),Ye}(function(e){process.env.NODE_ENV==="production"?e.exports=wo():e.exports=So()})(rt);const Y=rt.exports.Fragment,o=rt.exports.jsx,g=rt.exports.jsxs;class Le extends D.default.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const n=()=>{this.setState({error:null})};return g(a.Box,{children:[o(a.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),o(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}function _o({label:e,config:{default_value:t,...n},value:r,onChange:i}){return g(a.Box,{children:[o(a.Text,{children:"\xA0"}),o(a.Checkbox,{label:e,checked:r,onChange:l=>i(l.currentTarget.checked),...n,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})}const Wn=M.observer(({label:e,config:t,value:n=[null,null],onChange:r})=>{const i=Array.isArray(n)?n.map(s=>s?Me.default(s).toDate():null):[null,null],l=s=>{r(s.map(u=>u&&Me.default(u).format(t.inputFormat)))};return o(no.DateRangePicker,{label:e,value:i,onChange:l,icon:o(T.Calendar,{size:16}),sx:{minWidth:"16em"},styles:{input:{borderColor:"#e9ecef"}},...t})});function Do(e,t,n){const r=Rt(t,[],n),i=Object.keys(r),l=Object.values(r);try{return new Function(...i,`return \`${e}\`;`)(...l)}catch(s){return console.error(s),s.message}}function $t(e,t={}){const n=Object.keys(t),r=Object.values(t);try{return new Function(...n,`return \`${e}\`;`)(...r)}catch(i){throw n.length===0&&e.includes("$")?new Error("[formatSQL] insufficient params"):i}}function Rt(e,t,n){const r={...e,filters:n},i=t.reduce((l,s)=>(l[s.key]=$t(s.value,r),l),{});return N.default.merge({},{context:e,filters:n,sql_snippets:i})}function Un(e,t,n,r){try{const i=Rt(t,n,r);return $t(e,i)}catch(i){return console.error(i),i.message}}function Io(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const i=t[r];if(i!="authentication"&&e[i])n.push(t[r]+"="+(typeof e[i]=="object"?JSON.stringify(e[i]):e[i]));else{const l=Object.keys(e[i]).sort();for(let s=0;s<l.length;s++){const u=l[s];u!="sign"&&e[i][u]&&n.push(l[s]+"="+(typeof e[i][u]=="object"?JSON.stringify(e[i][u]):e[i][u]))}}}return n.sort().join("&")}function Ao(e,t){let n=Io(e);return n+="&key="+t,yo.default.MD5(n).toString().toUpperCase()}const ze={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(e){if(!this.app_id||!this.app_secret)return;const t=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:t,sign:Ao({app_id:this.app_id,nonce_str:t,...e},this.app_secret)}},getRequest(e){return(t,n,r={})=>{const i=window.localStorage.getItem("token"),l={"X-Requested-With":"XMLHttpRequest","Content-Type":r.string?"application/x-www-form-urlencoded":"application/json",authorization:i?`bearer ${i}`:"",...r.headers},s={baseURL:this.baseURL,method:e,url:t,params:e==="GET"?n:r.params,headers:l};return["POST","PUT"].includes(e)&&(s.data=r.string?JSON.stringify(n):n,s.data.authentication=this.getAuthentication(s.data)),vo.default(s).then(u=>u.data).catch(u=>Promise.reject(u))}}};function Yn(e){ze.baseURL!==e.apiBaseURL&&(ze.baseURL=e.apiBaseURL),e.app_id&&(ze.app_id=e.app_id),e.app_secret&&(ze.app_secret=e.app_secret)}const Ft=({type:e,key:t,sql:n})=>async()=>{if(!e||!t||!n)return[];try{return await ze.getRequest("POST")("/query",{type:e,key:t,query:n})}catch(r){return console.error(r),[]}};async function Mo({context:e,sqlSnippets:t,title:n,query:r,filterValues:i}){if(!r.sql)return[];const{type:l,key:s,sql:u}=r,d=u.includes("$"),p=Rt(e,t,i),c=$t(u,p);return d&&(console.groupCollapsed(`Final SQL for: ${n}`),console.log(c),console.groupEnd()),await ze.getRequest("POST")("/query",{type:l,key:s,query:c})}async function Vo(){try{return(await ze.getRequest("POST")("/datasource/list",{filter:{},sort:{field:"create_time",order:"ASC"},pagination:{page:1,pagesize:100}})).data}catch(e){return console.error(e),[]}}function Eo({label:e,config:t,value:n,onChange:r}){const i=!!t.options_query.sql,{data:l=[],loading:s}=U.useRequest(Ft(t.options_query),{refreshDeps:[t.options_query,i]});return o(a.MultiSelect,{label:e,data:i?l:t.static_options,disabled:i?s:!1,value:n,onChange:r,sx:{minWidth:"14em"},styles:{input:{borderColor:"#e9ecef"}}})}function To({label:e,config:t,value:n,onChange:r}){const i=!!t.options_query.sql,{data:l=[],loading:s}=U.useRequest(Ft(t.options_query),{refreshDeps:[t.options_query,i]});return o(a.Select,{label:e,data:i?l:t.static_options,disabled:i?s:!1,value:n,onChange:r,styles:{input:{borderColor:"#e9ecef"}}})}function $o({label:e,config:t,value:n,onChange:r}){return o(a.TextInput,{label:e,value:n,onChange:r,...t,styles:{input:{borderColor:"#e9ecef"}}})}const Ro=M.observer(({filter:{type:e,config:t,key:n,...r},formFieldProps:i})=>{switch(e){case"select":return o(To,{...r,...i,config:t});case"multi-select":return o(Eo,{...r,...i,config:t});case"text-input":return o($o,{...r,...i,config:t});case"date-range":return o(Wn,{...r,...i,config:t});case"checkbox":return o(_o,{...r,...i,config:t});default:return null}}),Qn=M.observer(D.default.forwardRef(({filter:e,...t},n)=>o("div",{className:"filter-root",ref:n,children:o(Le,{children:o(Ro,{filter:e,formFieldProps:t})})}))),Hn=M.observer(function({view:t}){const n=Q(),{control:r,handleSubmit:i}=x.useForm({defaultValues:n.filters.values}),l=n.filters.visibleInView(t.id);return l.length===0?null:o("form",{onSubmit:i(n.filters.setValues),children:g(a.Group,{className:"dashboard-filters",position:"apart",p:"md",noWrap:!0,sx:{border:"1px solid #e9ecef",borderRadius:"4px"},children:[o(a.Group,{align:"flex-start",children:l.map(s=>o(x.Controller,{name:s.key,control:r,render:({field:u})=>o(Qn,{filter:s,...u})},s.id))}),o(a.Group,{sx:{alignSelf:"flex-end"},children:o(a.Button,{color:"blue",size:"sm",type:"submit",children:"Submit"})})]})})});var it={exports:{}};(function(e,t){(function(n,r){r()})(Pe,function(){function n(p,c){return typeof c>"u"?c={autoBom:!1}:typeof c!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),c={autoBom:!c}),c.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(p.type)?new Blob(["\uFEFF",p],{type:p.type}):p}function r(p,c,f){var h=new XMLHttpRequest;h.open("GET",p),h.responseType="blob",h.onload=function(){d(h.response,c,f)},h.onerror=function(){console.error("could not download file")},h.send()}function i(p){var c=new XMLHttpRequest;c.open("HEAD",p,!1);try{c.send()}catch{}return 200<=c.status&&299>=c.status}function l(p){try{p.dispatchEvent(new MouseEvent("click"))}catch{var c=document.createEvent("MouseEvents");c.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),p.dispatchEvent(c)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Pe=="object"&&Pe.global===Pe?Pe:void 0,u=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),d=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!u?function(p,c,f){var h=s.URL||s.webkitURL,v=document.createElement("a");c=c||p.name||"download",v.download=c,v.rel="noopener",typeof p=="string"?(v.href=p,v.origin===location.origin?l(v):i(v.href)?r(p,c,f):l(v,v.target="_blank")):(v.href=h.createObjectURL(p),setTimeout(function(){h.revokeObjectURL(v.href)},4e4),setTimeout(function(){l(v)},0))}:"msSaveOrOpenBlob"in navigator?function(p,c,f){if(c=c||p.name||"download",typeof p!="string")navigator.msSaveOrOpenBlob(n(p,f),c);else if(i(p))r(p,c,f);else{var h=document.createElement("a");h.href=p,h.target="_blank",setTimeout(function(){l(h)})}}:function(p,c,f,h){if(h=h||open("","_blank"),h&&(h.document.title=h.document.body.innerText="downloading..."),typeof p=="string")return r(p,c,f);var v=p.type==="application/octet-stream",C=/constructor/i.test(s.HTMLElement)||s.safari,y=/CriOS\/[\d]+/.test(navigator.userAgent);if((y||v&&C||u)&&typeof FileReader<"u"){var S=new FileReader;S.onloadend=function(){var F=S.result;F=y?F:F.replace(/^data:[^;]*;/,"data:attachment/file;"),h?h.location.href=F:location=F,h=null},S.readAsDataURL(p)}else{var E=s.URL||s.webkitURL,$=E.createObjectURL(p);h?h.location=$:location.href=$,h=null,setTimeout(function(){E.revokeObjectURL($)},4e4)}});s.saveAs=d.saveAs=d,e.exports=d})})(it);function Fo(e,t){const n=new Blob([t],{type:"text/csv"});it.exports.saveAs(n,`${e}.csv`)}function Oo(e,t){const n=new Blob([t],{type:"application/json"});it.exports.saveAs(n,`${e}.json`)}function ko(e){const t=new bo.default;e.forEach(({id:n,data:r})=>{t.file(`${n}.csv`,Xn(r))}),t.generateAsync({type:"blob"}).then(n=>{it.exports.saveAs(n,"dashboard_data.zip")})}function Xn(e){if(!Array.isArray(e)||e.length===0)return"";const t=[],n=Object.keys(e[0]);return t.push(n.join(",")),e.forEach(r=>{const i=Object.values(r).join(",");t.push(i)}),t.join(`
|
|
28
28
|
`)}const Po={layoutFrozen:!1,freezeLayout:N.default.noop,inEditMode:!1,inUseMode:!0},me=D.default.createContext(Po),Jn=D.default.createContext({panel:null,data:[],loading:!1}),Kn=Jn.Provider;function re(){const e=D.default.useContext(Jn);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const zo=`
|
|
29
29
|
-- You may reference global variables in SQL or VizConfig.
|
|
30
30
|
SELECT *
|
|
@@ -37,7 +37,7 @@ WHERE
|
|
|
37
37
|
-- SQL snippets
|
|
38
38
|
AND \${sql_snippets.author_email_condition}
|
|
39
39
|
\${sql_snippets.order_by_clause}
|
|
40
|
-
`,Zn=M.observer(function({showSQLSnippets:t=!0,sx:n={}}){const r=Q(),i=r.context.current,l=D.default.useMemo(()=>{const s={context:i,filters:r.filters.values};return t&&(s.sql_snippets=r.sqlSnippets.record),JSON.stringify(s,null,2)},[i,r.sqlSnippets.record,r.filters.values,t]);return g(a.Stack,{sx:{border:"1px solid #eee",maxWidth:"40%",overflow:"hidden",...n},children:[o(a.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:o(a.Text,{weight:500,children:"Global Variables"})}),g(a.Stack,{px:"md",pb:"md",sx:{width:"100%"},children:[o(Ne.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:zo}),o(a.Text,{weight:500,sx:{flexGrow:0},children:"Current Values"}),o(Ne.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:l})]})]})});function Go({data:e}){return e.length===0?o(a.Box,{sx:{height:"5em"}}):g(a.Table,{children:[o("thead",{children:o("tr",{children:Object.keys(e==null?void 0:e[0]).map(t=>o("th",{children:o(a.Text,{weight:700,color:"#000",children:t})},t))})}),o("tbody",{children:e.slice(0,10).map((t,n)=>o("tr",{children:Object.values(t).map((r,i)=>o("td",{children:o(a.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:o(a.Text,{children:r})})},`${r}--${i}`))},`row-${n}`))})]})}const er=M.observer(function({id:t}){const n=Q(),{data:r,state:i}=n.getDataStuffByID(t),l=i==="loading",s=()=>{n.queries.refetchDataByQueryID(t)};return g(a.Stack,{my:"xl",sx:{border:"1px solid #eee"},children:[g(a.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[g(a.Group,{position:"left",children:[o(a.Text,{weight:500,children:"Preview Data"}),r.length>10&&g(a.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",r.length]})]}),o(a.ActionIcon,{mr:15,variant:"subtle",color:"blue",disabled:l,onClick:s,children:o(T.Refresh,{size:15})})]}),g(a.Box,{sx:{position:"relative"},children:[o(a.LoadingOverlay,{visible:l}),o(Go,{data:r})]})]})}),No=w.forwardRef(({label:e,type:t,...n},r)=>g(a.Group,{position:"apart",ref:r,...n,children:[o(a.Text,{children:e}),o(a.Text,{children:t})]})),tr=M.observer(function({value:t,onChange:n}){const{data:r=[],loading:i}=U.useRequest(Vo,{refreshDeps:[]},[]),l=w.useMemo(()=>r.map(u=>({label:u.key,value:u.key,type:u.type})),[r]),s=w.useMemo(()=>l.reduce((u,d)=>(u[d.value]=d.type,u),{}),[l]);return o(a.Select,{label:"Data Source",data:l,itemComponent:No,sx:{flex:1},disabled:i,value:t.key,onChange:u=>{u!==null&&n({key:u,type:s[u]})}})}),nr=M.observer(({value:e})=>{const t=Q(),n=t.context.current,r=D.default.useMemo(()=>Un(e,n,t.sqlSnippets.current,t.filters.values),[e,n,t.sqlSnippets.current,t.filters.values]);return o(Ne.Prism,{language:"sql",colorScheme:"light",children:r})}),Lo=M.observer(function({queryModel:t,setCurrentID:n}){const r=D.default.useRef(t.id),[i,l]=D.default.useState(r.current);D.default.useEffect(()=>{r.current!==t.id&&(l(t.id),r.current=t.id)},[r,t.id]);const[s,u]=D.default.useState(t.sql);D.default.useEffect(()=>{u(f=>f!==t.sql?t.sql:f)},[t.sql]);const d=s!==t.sql,p=()=>{t.setSQL(s)},c=()=>{n(i),t.setID(i)};return g(a.Stack,{sx:{border:"1px solid #eee",flexGrow:1},children:[o(a.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:o(a.Text,{weight:500,children:"Edit Query"})}),g(a.Stack,{my:0,p:"md",pr:40,children:[g(a.Group,{grow:!0,children:[o(a.TextInput,{placeholder:"An ID unique in this dashboard",label:"ID",required:!0,sx:{flex:1},value:i,onChange:f=>{l(f.currentTarget.value)},rightSection:o(a.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:i===t.id,onClick:c,children:o(T.DeviceFloppy,{size:18})})}),o(tr,{value:{type:t.type,key:t.key},onChange:({type:f,key:h})=>{t.setKey(h),t.setType(f)}})]}),g(a.Tabs,{defaultValue:"SQL",children:[g(a.Tabs.List,{children:[o(a.Tabs.Tab,{value:"SQL",children:"SQL"}),o(a.Tabs.Tab,{value:"Preview",children:"Preview"})]}),o(a.Tabs.Panel,{value:"SQL",pt:"sm",children:g(a.Box,{sx:{position:"relative"},children:[o(a.Textarea,{autosize:!0,minRows:12,maxRows:24,className:"code-textarea",value:s,onChange:f=>{u(f.currentTarget.value)}}),o(a.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:10,top:10},disabled:!d,onClick:p,children:o(T.DeviceFloppy,{size:20})})]})}),o(a.Tabs.Panel,{value:"Preview",pt:"sm",children:o(nr,{value:t.sql})})]})]})]})}),qo=M.observer(function({id:t,setID:n}){const r=Q(),i=D.default.useMemo(()=>r.queries.findByID(t),[r.queries,t]);return t?i?o(Lo,{queryModel:i,setCurrentID:n}):o("span",{children:"Invalid Query ID"}):null});var we=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e))(we||{});const Bo=M.observer(function({id:t,setID:n}){const r=Q(),i=()=>{var s;n((s=r.queries.firstID)!=null?s:"")};D.default.useEffect(()=>{if(!t){i();return}r.queries.current.findIndex(u=>u.id===t)===-1&&i()},[t,r.queries.current,i]);const l=()=>{const s=K.randomId();r.queries.append(b.cast({id:s,type:we.Postgresql,key:"",sql:""})),n(s)};return o(a.Group,{pb:"xl",grow:!0,sx:{width:"100%"},children:g(a.Group,{position:"left",sx:{flexGrow:1,maxWidth:"600px",alignItems:"baseline"},children:[o(a.Text,{children:"Select a Query"}),o(a.Select,{data:r.queries.options,value:t,onChange:n,allowDeselect:!1,clearable:!1,sx:{flexGrow:1,maxWidth:"300px"}}),o(a.Text,{children:"or"}),o(a.Group,{position:"center",mt:"md",children:o(a.Button,{onClick:l,children:"Add a Query"})})]})})}),jo=M.observer(function(){const[t,n]=D.default.useState("");return g(a.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:[g(a.Group,{position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[g(a.Stack,{sx:{flexGrow:1,maxWidth:"calc(60% - 16px)"},children:[o(Bo,{id:t,setID:n}),o(qo,{id:t,setID:n})]}),o(Zn,{})]}),o(er,{id:t})]})}),Wo=M.observer(({value:e})=>{const t=Q(),n=t.context.current,r=D.default.useMemo(()=>Do(e,n,t.filters.values),[e,n]);return g(a.Stack,{children:[o(a.Text,{children:"Preview"}),o(Ne.Prism,{language:"sql",noCopy:!0,colorScheme:"dark",children:r})]})}),Uo=M.observer(function(){const t=Q(),n=()=>t.sqlSnippets.append(b.cast({key:K.randomId(),value:""}));return g(a.Stack,{sx:{border:"1px solid #eee",flexGrow:1},children:[o(a.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:o(a.Text,{weight:500,children:"SQL Snippets"})}),o(a.Group,{px:"md",pb:"md",pt:"md",children:g(a.Stack,{sx:{width:"100%",position:"relative"},children:[t.sqlSnippets.current.map((r,i)=>g(a.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[o(a.TextInput,{label:"Key",required:!0,value:r.key,onChange:l=>{r.setKey(l.currentTarget.value)}}),o(a.Textarea,{minRows:3,label:"Value",required:!0,value:r.value,onChange:l=>{r.setValue(l.currentTarget.value)},className:"code-textarea"}),o(Wo,{value:r.value}),o(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t.sqlSnippets.remove(i),sx:{position:"absolute",top:15,right:5},children:o(T.Trash,{size:16})})]},i)),o(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:o(a.Button,{variant:"default",onClick:n,children:"Add a snippet"})})]})})]})});function Yo(){return o(a.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:g(a.Group,{position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[o(Uo,{}),o(Zn,{showSQLSnippets:!1})]})})}const Qo=M.observer(function({opened:t,close:n}){const{freezeLayout:r}=D.default.useContext(me);return D.default.useEffect(()=>{r(t)},[t]),o(a.Modal,{size:"96vw",overflow:"inside",opened:t,onClose:n,title:"Data Settings",trapFocus:!0,onDragStart:i=>{i.stopPropagation()},children:g(a.Tabs,{defaultValue:"Queries",children:[g(a.Tabs.List,{children:[o(a.Tabs.Tab,{value:"SQL Snippet",children:"SQL Snippet"}),o(a.Tabs.Tab,{value:"Queries",children:"Queries"})]}),o(a.Tabs.Panel,{value:"SQL Snippet",pt:"sm",children:o(Yo,{})}),o(a.Tabs.Panel,{value:"Queries",pt:"sm",children:o(jo,{})})]})})});var ce=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(ce||{});const rr=b.types.model({type:b.types.enumeration("DataSourceType",[we.Postgresql,we.MySQL,we.HTTP]),key:b.types.string,sql:b.types.string}),ir=b.types.model("FilterConfigModel_TextInput",{required:b.types.boolean,default_value:b.types.string}).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),or=()=>ir.create({required:!1,default_value:""}),Ho=M.observer(function({config:t}){return o(Y,{children:o(a.Checkbox,{checked:t.default_value,onChange:n=>t.setDefaultValue(n.currentTarget.checked),label:"Default Checked"})})}),Xo=[{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"}],Jo=M.observer(function({config:t}){return g(Y,{children:[g(a.Group,{children:[o(a.Checkbox,{checked:t.required,onChange:n=>t.setRequired(n.currentTarget.checked),label:"Required"}),o(a.Checkbox,{checked:t.clearable,onChange:n=>t.setClearable(n.currentTarget.checked),label:"Clearable"})]}),o(a.Select,{data:Xo,label:"Display Format",value:t.inputFormat,onChange:t.setInputFormat}),o(Wn,{label:"Default Value",config:t,value:t.default_value,onChange:t.setDefaultValue})]})});function Ko({data:e}){return e.length===0?o(a.Box,{sx:{height:"5em"}}):g(a.Table,{children:[o("thead",{children:o("tr",{children:Object.keys(e==null?void 0:e[0]).map(t=>o("th",{children:o(a.Text,{weight:700,color:"#000",children:t})},t))})}),o("tbody",{children:e.slice(0,3).map((t,n)=>o("tr",{children:Object.values(t).map((r,i)=>o("td",{children:o(a.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:o(a.Text,{children:r})})},`${r}--${i}`))},`row-${n}`))}),e.length>3&&o("tfoot",{children:o("tr",{children:o("td",{colSpan:Object.keys(e==null?void 0:e[0]).length,children:g(a.Text,{color:"gray",size:"sm",children:[e.length-3," more row(s) hidden"]})})})})]})}const Zo=M.observer(function({query:t}){const{data:n=[],loading:r,refresh:i}=U.useRequest(Ft(t),{refreshDeps:[t]});return g(a.Stack,{my:0,children:[g(a.Group,{position:"apart",children:[o(a.Text,{size:"md",pl:"sm",children:"Fetched Data"}),o(a.Button,{size:"xs",onClick:i,disabled:!t.sql||!t.key,children:"Retry"})]}),g(a.Box,{sx:{position:"relative"},children:[o(a.LoadingOverlay,{visible:r,exitTransitionDuration:0}),o(Ko,{data:n})]})]})}),ar=M.observer(function({value:t,onChange:n}){return g(a.Stack,{my:0,children:[o(tr,{value:t,onChange:({type:r,key:i})=>{n({...t,type:r,key:i})}}),g(a.Tabs,{defaultValue:"SQL",children:[g(a.Tabs.List,{children:[o(a.Tabs.Tab,{value:"SQL",children:"SQL"}),o(a.Tabs.Tab,{value:"Preview",children:"Preview"}),o(a.Tabs.Tab,{value:"Data",children:"Data"})]}),o(a.Tabs.Panel,{value:"SQL",pt:"sm",children:o(a.Textarea,{autosize:!0,minRows:12,maxRows:24,className:"code-textarea",value:t.sql,onChange:r=>{n({...t,sql:r.currentTarget.value})},placeholder:"SELECT name AS label, id AS value"})}),o(a.Tabs.Panel,{value:"Preview",pt:"sm",children:o(nr,{value:t.sql})}),o(a.Tabs.Panel,{value:"Data",pt:"sm",children:o(Zo,{query:t})})]})]})}),ea=M.observer(function({config:t}){const n=()=>{t.addStaticOption({label:"",value:""})},r=t.static_options,i=[...r];return g(Y,{children:[o(a.Divider,{label:"Configure options",labelPosition:"center"}),r.length>0&&o(a.MultiSelect,{label:"Default Selection",data:i,value:t.default_value,onChange:t.setDefaultValue}),r.map((l,s)=>g(a.Group,{sx:{position:"relative"},pr:"40px",children:[o(a.TextInput,{label:"Label",required:!0,value:t.static_options[s].label,onChange:u=>{t.static_options[s].setLabel(u.currentTarget.value)},sx:{flexGrow:1}}),o(a.TextInput,{label:"Value",required:!0,value:t.static_options[s].value,onChange:u=>{t.static_options[s].setValue(u.currentTarget.value)},sx:{flexGrow:1}}),o(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t.removeStaticOption(s),sx:{position:"absolute",top:28,right:5},children:o(T.Trash,{size:16})})]})),o(a.Button,{size:"xs",color:"blue",leftIcon:o(T.PlaylistAdd,{size:20}),onClick:n,sx:{width:"50%"},mx:"auto",children:"Add an Option"}),o(a.Divider,{label:"Or fetch options from database",labelPosition:"center"}),o(ar,{value:t.options_query,onChange:t.setOptionsQuery})]})}),ta=M.observer(function({config:t}){const n=()=>{t.addStaticOption({label:"",value:""})},r=t.static_options,i=[{label:"No default selection",value:""},...r];return g(Y,{children:[o(a.Checkbox,{checked:t.required,onChange:l=>t.setRequired(l.currentTarget.checked),label:"Required"}),o(a.Divider,{label:"Configure options",labelPosition:"center"}),r.length>0&&o(a.Select,{label:"Default Selection",data:i,value:t.default_value,onChange:t.setDefaultValue}),r.map((l,s)=>g(a.Group,{sx:{position:"relative"},pr:"40px",children:[o(a.TextInput,{label:"Label",required:!0,value:t.static_options[s].label,onChange:u=>{t.static_options[s].setLabel(u.currentTarget.value)},sx:{flexGrow:1}}),o(a.TextInput,{label:"Value",required:!0,value:t.static_options[s].value,onChange:u=>{t.static_options[s].setValue(u.currentTarget.value)},sx:{flexGrow:1}}),o(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t.removeStaticOption(s),sx:{position:"absolute",top:28,right:5},children:o(T.Trash,{size:16})})]},s)),o(a.Button,{size:"xs",color:"blue",leftIcon:o(T.PlaylistAdd,{size:20}),onClick:n,sx:{width:"50%"},mx:"auto",children:"Add an Option"}),o(a.Divider,{label:"Or fetch options from database",labelPosition:"center"}),o(ar,{value:t.options_query,onChange:t.setOptionsQuery})]})}),na=M.observer(function({config:t}){return g(Y,{children:[o(a.TextInput,{label:"Default Value",value:t.default_value,onChange:n=>{t.setDefaultValue(n.currentTarget.value)}}),o(a.Checkbox,{checked:t.required,onChange:n=>t.setRequired(n.currentTarget.checked),label:"Required"})]})}),ra=M.observer(function({filter:t}){const n=t.plainDefaultValue,[r,i]=D.default.useState(n);return D.default.useEffect(()=>{i(n)},[n]),g(a.Box,{sx:{maxWidth:"30em"},children:[o(a.Text,{pb:"md",color:"gray",children:"Preview"}),o(Qn,{filter:t,value:r,onChange:i}),o(a.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),o(Ne.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),ia={select:ta,"multi-select":ea,"text-input":na,checkbox:Ho,"date-range":Jo},oa=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],aa=M.observer(function({filter:t,index:n}){const r=Q(),i=D.default.useMemo(()=>ia[t.type],[t.type]);return g(a.SimpleGrid,{cols:2,children:[g(a.Box,{pl:"md",children:[o(a.Text,{pb:"md",color:"gray",children:"Edit"}),g(a.Stack,{sx:{maxWidth:"30em"},children:[o(a.NumberInput,{label:"Placement Order",required:!0,value:t.order,onChange:t.setOrder,hideControls:!0}),o(a.MultiSelect,{label:"Visible in...",data:r.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),o(a.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:t.key,onChange:l=>{t.setKey(l.currentTarget.value)}}),o(a.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:t.label,onChange:l=>{t.setLabel(l.currentTarget.value)}}),o(a.Select,{label:"Widget",data:oa,required:!0,value:t.type,onChange:t.setType}),o(i,{config:t.config,index:n})]})]}),o(ra,{filter:t})]})}),Wg="",la=M.observer(function(){const t=Q(),n=t.filters.current,r=()=>{const i=K.randomId(),l={id:i,key:i,label:i,order:n.length+1,type:ce.TextInput,config:or(),visibleInViewsIDs:["Main"]};t.filters.append(l)};return g(a.Box,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)"},p:0,children:[o(a.Group,{sx:{position:"absolute",top:"16px",right:"16px"},children:o(a.Button,{size:"xs",color:"red",leftIcon:o(T.Recycle,{size:20}),disabled:!t.filters.changed,onClick:t.filters.reset,children:"Revert Changes"})}),o(a.Tabs,{className:"filter-settings-tabs",orientation:"vertical",defaultValue:t.filters.firstID,styles:{root:{display:"block"}},children:g(a.Group,{sx:{height:"100%"},children:[g(a.Stack,{sx:{height:"100%"},children:[o(a.Tabs.List,{position:"left",sx:{flexGrow:1,width:"200px"},children:t.filters.current.map(i=>o(a.Tabs.Tab,{value:i.id,sx:{maxWidth:"100%",overflow:"scroll"},children:i.label},i.id))}),o(a.Button,{size:"xs",color:"blue",leftIcon:o(T.PlaylistAdd,{size:20}),onClick:r,children:"Add a Filter"})]}),o(a.Box,{sx:{flexGrow:1,height:"100%"},children:t.filters.current.map((i,l)=>o(a.Tabs.Panel,{value:i.id,sx:{height:"100%"},children:g(a.Stack,{sx:{height:"100%"},spacing:"sm",children:[o(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"scroll"},children:o(aa,{filter:i,index:l})}),o(a.Group,{position:"right",pt:10,children:o(a.Button,{size:"xs",color:"red",leftIcon:o(T.Trash,{size:20}),onClick:()=>t.filters.remove(l),children:"Delete this filter"})})]})},i.id))})]})})]})}),sa=M.observer(function({opened:t,close:n}){const{freezeLayout:r}=D.default.useContext(me);return D.default.useEffect(()=>{r(t)},[t]),o(a.Modal,{size:"96vw",overflow:"inside",opened:t,onClose:n,title:"Filters",trapFocus:!0,onDragStart:i=>{i.stopPropagation()},withCloseButton:!1,children:o(la,{})})});var lr=(e=>(e.Use="use",e.Edit="edit",e))(lr||{}),ge=(e=>(e.Division="div",e.Modal="modal",e))(ge||{}),sr=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(sr||{});const ua=M.observer(()=>{const t=Q().views.VIE;return!t||t.type!==ge.Division?null:g(a.Stack,{children:[o(a.Divider,{mt:8,mb:0,label:"Division settings",labelPosition:"center"}),o(a.Text,{align:"center",size:"xs",color:"dimmed",children:"Under construction"})]})}),da=M.observer(()=>{const t=Q().views.VIE;return!t||t.type!==ge.Modal?null:g(a.Stack,{children:[o(a.Divider,{mt:8,label:"Modal settings",labelPosition:"center"}),g(a.Group,{grow:!0,children:[o(a.TextInput,{label:"Width",value:t.config.width,onChange:n=>t.updateConfig("width",n.currentTarget.value),placeholder:"600px / 50vw"}),o(a.TextInput,{label:"Height",value:t.config.height,onChange:n=>t.updateConfig("height",n.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),ca=M.observer(()=>g(Y,{children:[o(ua,{}),o(da,{})]})),ga=[{label:"Division",value:ge.Division},{label:"Modal",value:ge.Modal}],pa=M.observer(()=>{const t=Q().views.VIE;return t?g(a.Stack,{sx:{position:"relative"},children:[o(a.TextInput,{label:"Name",value:t.name,onChange:n=>{t.setName(n.currentTarget.value)}}),o(a.Select,{label:"Type",value:t.type,onChange:t.setType,data:ga}),o(ca,{})]}):null}),fa=M.observer(({opened:e,close:t})=>{var i;const n=Q(),{freezeLayout:r}=D.default.useContext(me);return D.default.useEffect(()=>{r(e)},[e]),o(a.Modal,{size:"500px",overflow:"inside",opened:e,onClose:t,withCloseButton:!1,styles:{header:{width:"100%"},title:{width:"100%"}},title:g(a.Group,{position:"apart",children:[g(a.Text,{sx:{flexGrow:1},children:["Editing ",(i=n.views.VIE)==null?void 0:i.name]}),o(a.ActionIcon,{size:18,color:"red",onClick:n.views.removeVIE,disabled:n.views.isVIETheFirstView,children:o(T.Trash,{size:18})})]}),trapFocus:!0,onDragStart:l=>{l.stopPropagation()},children:o(pa,{})})}),ha=w.forwardRef(({label:e,type:t,...n},r)=>t!=="TRIGGER_TO_ADD"?o("div",{ref:r,...n,children:g(a.Group,{noWrap:!0,position:"apart",children:[o(a.Text,{size:"sm",children:e}),o(a.Text,{size:"xs",color:"dimmed",children:t})]})}):o("div",{ref:r,...n,children:o(a.Group,{noWrap:!0,grow:!0,children:o(a.Text,{size:"sm",align:"center",color:"#228be6",children:e})})})),ur="TRIGGER_TO_ADD",ma=M.observer(({value:e,onChange:t,triggerAdd:n,triggerEdit:r,options:i})=>{const l=w.useMemo(()=>[...i,{label:"Add a View",value:ur,type:"TRIGGER_TO_ADD"}],[i,n]),s=u=>{u!==ur?t(u):n()};return g(a.Group,{position:"left",spacing:0,sx:{minWidth:"260px"},children:[o(a.Select,{value:e,onChange:s,placeholder:"Pick a View",itemComponent:ha,data:l,nothingFound:"Empty",sx:{flexGrow:1},styles:{input:{borderTopRightRadius:0,borderBottomRightRadius:0}}}),o(a.ActionIcon,{onClick:r,variant:"default",size:36,sx:{borderLeft:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,"&:active":{transform:"none",svg:{transform:"translateY(1px)"}}},children:o(T.Settings,{size:20})})]})}),va=M.observer(()=>{const e=Q(),[t,n]=w.useState(!1),r=()=>{n(!0)},i=()=>{n(!1)};return g(Y,{children:[o(ma,{value:e.views.idOfVIE,onChange:e.views.setIDOfVIE,triggerAdd:e.views.addARandomNewView,triggerEdit:r,options:e.views.options}),o(fa,{opened:t,close:i})]})}),dr={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}},cr=M.observer(function({saveChanges:t}){const n=Q(),r=D.default.useCallback(()=>{const E=n.queries.current,$=n.views.current,F=n.sqlSnippets.current;return{filters:n.filters.current,views:$,definition:{sqlSnippets:F,queries:E}}},[n]),i=()=>{n.filters.reset(),n.views.reset(),n.sqlSnippets.reset(),n.queries.reset()},l=n.views.changed||n.sqlSnippets.changed||n.queries.changed||n.filters.changed,{inEditMode:s,inUseMode:u}=D.default.useContext(me),[d,p]=D.default.useState(!1),c=()=>p(!0),f=()=>p(!1),[h,v]=D.default.useState(!1),C=()=>v(!0),y=()=>v(!1),S=()=>{const E=JSON.stringify(r(),null,2);Oo(n.name,E)};return g(a.Group,{position:"apart",pt:0,px:10,pb:"xs",children:[o(a.Group,{position:"left",children:s&&o(va,{})}),g(a.Group,{position:"right",sx:{button:{minWidth:"40px"}},children:[s&&g(Y,{children:[o(a.Button,{variant:"filled",size:"xs",disabled:!n.views.VIE,onClick:n.views.addAPanelToVIE,leftIcon:o(T.PlaylistAdd,{size:20}),children:"Add a Panel"}),g(a.Group,{spacing:0,sx:dr,children:[o(a.Tooltip,{label:"Filters",children:o(a.ActionIcon,{variant:"default",size:"md",onClick:C,children:o(T.Filter,{size:20})})}),o(a.Tooltip,{label:"Data Settings",children:o(a.ActionIcon,{variant:"default",size:"md",onClick:c,children:o(T.Database,{size:20})})})]}),g(a.Group,{spacing:0,sx:dr,children:[o(a.Tooltip,{label:"Save Changes",children:o(a.ActionIcon,{variant:"default",size:"md",onClick:t,disabled:!l,children:o(T.DeviceFloppy,{size:20,color:"green"})})}),o(a.Tooltip,{label:"Revert Changes",children:o(a.ActionIcon,{variant:"default",size:"md",disabled:!l,onClick:i,children:o(T.Recycle,{size:20,color:"red"})})})]})]}),!u&&g(a.Menu,{width:180,trigger:"hover",children:[o(a.Menu.Target,{children:o(a.ActionIcon,{variant:"default",size:"md",children:o(T.Share,{size:20})})}),g(a.Menu.Dropdown,{children:[o(a.Menu.Item,{icon:o(T.Download,{size:14}),onClick:n.queries.downloadAllData,children:"Download Data"}),o(a.Menu.Item,{icon:o(T.Code,{size:14}),onClick:S,children:"Download Schema"})]})]})]}),o(sa,{opened:h,close:y}),o(Qo,{opened:d,close:f})]})}),Ug="",gr=M.observer(()=>{const{freezeLayout:e}=D.default.useContext(me),[t,n]=D.default.useState(!1),{panel:r}=re();return D.default.useEffect(()=>{e(t)},[t]),!r.description||r.description==="<p><br></p>"?null:g(Y,{children:[o(a.Modal,{opened:t,onClose:()=>n(!1),title:r.title,withCloseButton:!1,children:o(zn.default,{readOnly:!0,value:r.description,onChange:N.default.noop,sx:{border:"none"}})}),o(a.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:o(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:o(T.InfoCircle,{size:20})})})]})}),pr=e=>{const{title:t="Variables",variables:n}=e,r=K.useClipboard(),i=l=>{r.copy(l),It.showNotification({color:"green",message:"Copied to clipboard"})};return g(a.Paper,{withBorder:!0,p:"sm",children:[o(a.Text,{size:"xs",color:"dimmed",mb:"sm",children:t}),o(a.Stack,{style:{maxHeight:"300px"},children:n.map(l=>g(a.Text,{size:"sm",children:[g(a.Code,{color:"teal",children:["// ",l.description]}),o("br",{}),g(a.Code,{onClick:()=>i(l.name),style:{cursor:"pointer"},children:[l.name," : ",l.valueType]})]},l.name))})]})};class ya{constructor(t,n){k(this,"operationId");k(this,"operation");k(this,"operationSchema");k(this,"variables",[]);this.operationManager=t,this.instance=n,Z.makeAutoObservable(this)}get schemaList(){return this.operationManager.getOperationSchemaList()}async configOperation(t,n){const r=await this.operationManager.retrieveTrigger(t),i=this.operationManager.getOperationSchemaList().find(l=>l.id===(r==null?void 0:r.schemaRef));Z.runInAction(()=>{this.operationId=t,this.operation=r,this.operationSchema=i,this.variables=n})}async changeSchema(t){this.operationId&&(await this.operationManager.createOrGetOperation(this.operationId,t),await this.configOperation(this.operationId,this.variables))}}function ba(e){return!!e.operationId}const Ca=M.observer(({model:e,onClick:t})=>{var r;const n=(r=e.operationSchema)==null?void 0:r.displayName;return o(a.Button,{variant:"outline",onClick:t,children:n})}),xa=M.observer(({model:e})=>{const t={operation:e.operation,instance:e.instance,variables:[]};return w.createElement(e.operationSchema.configRender,t)});function wa({model:e}){const t=e.schemaList,n=t.map(i=>({label:i.displayName,value:i.id}));async function r(i){await e.changeSchema(t.find(l=>l.id===i))}return o(a.Select,{label:"Operation",data:n,onChange:r,value:e.operationSchema.id})}const Sa=M.observer(e=>{const[t,{setTrue:n,setFalse:r}]=U.useBoolean(!1),{operationManager:i,operationId:l,instance:s,variables:u}=e,d=U.useCreation(()=>new ya(i,s),[i,s]);return U.useAsyncEffect(async()=>{await d.configOperation(l,u)},[l,d]),ba(d)?g(Y,{children:[o(Ca,{model:d,onClick:n}),o(a.Modal,{opened:t,onClose:r,title:"Operation Settings",closeButtonLabel:"close",children:g(a.Stack,{children:[o(wa,{model:d}),o(xa,{model:d}),o(pr,{title:"Variables",variables:d.variables})]})})]}):null});class _a{constructor(t,n){k(this,"triggerId");k(this,"trigger");k(this,"triggerSchema");k(this,"sampleData");this.triggerManager=t,this.instance=n,Z.makeAutoObservable(this)}get schemaList(){return this.triggerManager.getTriggerSchemaList()}async configTrigger(t,n){const r=await this.triggerManager.retrieveTrigger(t),i=this.triggerManager.getTriggerSchemaList().find(l=>l.id===(r==null?void 0:r.schemaRef));Z.runInAction(()=>{this.triggerId=t,this.trigger=r,this.triggerSchema=i,this.sampleData=n})}async changeSchema(t){this.triggerId&&(await this.triggerManager.createOrGetTrigger(this.triggerId,t),await this.configTrigger(this.triggerId,this.sampleData))}isReady(){return Da(this)}}function Da(e){return!!e.triggerId&&!!e.triggerSchema}function Ia(e,t){return U.useCreation(()=>new _a(e,t),[e,t])}const Aa=M.observer(({model:e,onClick:t})=>{const n=e.triggerSchema.nameRender,r={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return o(a.Button,{variant:"outline",onClick:t,children:w.createElement(n,r)})}),Ma=M.observer(({model:e})=>{const t=e.schemaList,n=t.map(i=>({label:i.displayName,value:i.id}));async function r(i){await e.changeSchema(t.find(l=>l.id===i))}return o(a.Select,{label:"Trigger",data:n,value:e.triggerSchema.id,onChange:r})}),Va=M.observer(({model:e})=>{const t={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return w.createElement(e.triggerSchema.configRender,t)}),Ea=M.observer(e=>{const[t,{setTrue:n,setFalse:r}]=U.useBoolean(!1),i=e.model;return g(Y,{children:[o(a.Modal,{opened:t,onClose:r,title:"Setup Trigger",closeButtonLabel:"close setup",children:g(a.Stack,{children:[o(Ma,{model:i}),o(Va,{model:i}),o(pr,{title:"Payload",variables:i.triggerSchema.payload})]})}),o(Aa,{onClick:n,model:i})]})});class qe{constructor(t,n){this.root=t,this.path=n}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,I.omit(n,t))}async getItem(t){const n=await this.root.getItem(this.path);return t===null?n:I.get(n,t)}async setItem(t,n){if(t===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[t]:n})}return await this.getItem(t)}watchItem(t,n,r){return t===null?this.root.watchItem(this.path,(i,l)=>{n(i,l)},r):this.root.watchItem(this.path,(i,l)=>{const s=I.get(i,t),u=I.get(l,t);s!==u&&n(s,u)},r)}}class Ot{constructor(t,n,r){k(this,"attachmentStorage");this.instance=t,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new qe(t.instanceData,n)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new qe(this.attachmentStorage,t))}async create(t,n){return await this.attachmentStorage.setItem(t,n),this.constructInstance(new qe(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(I.values(t).map(n=>this.constructInstance(new qe(this.attachmentStorage,n.id))))}}class fr{constructor(t){k(this,"rootRef");this.rootRef=Z.observable({current:t})}async deleteItem(t){Z.runInAction(()=>{I.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?Z.toJS(this.rootRef.current):I.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(I.isObject(n))Z.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else Z.runInAction(()=>{I.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return Z.reaction(()=>this.getValueFromRoot(t),(i,l)=>{n(i,l)},{requiresObservable:!0,fireImmediately:I.get(r,"fireImmediately",!1)})}}class Ta{constructor(){k(this,"channels",new Map);k(this,"globalChannel",new Gn.default)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new Gn.default;return this.channels.set(t,r),r}}class $a{constructor(t){k(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const r={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Ta,instanceData:new fr(t.viz.conf)};return this.instances.set(t.id,r),r}}function hr(e,t,n){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new fr({}),colorPalette:{getColor(){return()=>""}},data:t}}const Ra=e=>{const{panel:t,vizManager:n,data:r}=e,i=n.resolveComponent(t.viz.type),l=n.getOrCreateInstance(t),s={...hr(l,r,n),viewport:{width:t.layout.w,height:t.layout.h}},u=i.viewRender;return o(u,{context:s,instance:l,...I.omit(e,["panel","vizManager","data"])})},Fa=e=>{const{vizManager:t,panel:n,panelInfoEditor:r,data:i}=e,l=t.resolveComponent(n.viz.type),s=t.getOrCreateInstance(n),u={...hr(s,i,t),panelInfoEditor:r},d=l.configRender;return o(d,{context:u,instance:s,...I.omit(e,["panel","vizManager","data","panelInfoEditor"])})},mr=(e,t)=>{const n=We.default.bezier(e),r=We.default.bezier(t);return function(i){return i<50?n(i*2/100).hex():r((i-50)*2/100).hex()}},ot=e=>{const t=We.default.bezier(e);return function(n){return t(n/100).hex()}},Oa={type:"interpolation",displayName:"Red / Green",getColor:mr(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},ka={type:"interpolation",displayName:"Yellow / Blue",getColor:mr(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Pa={type:"interpolation",displayName:"Red",getColor:ot(["#fff7f1","darkred"]),name:"red",category:"sequential"},za={type:"interpolation",displayName:"Green",getColor:ot(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ga={type:"interpolation",displayName:"Blue",getColor:ot(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Na={type:"interpolation",displayName:"Orange",getColor:ot(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},La="5.6.0-alpha";class qa{constructor(t){k(this,"staticColors",new Map);k(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class Ba{constructor(){k(this,"plugins",new Map);k(this,"vizComponents",new Map);k(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class ja{constructor(){k(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const r=this.migrations.filter(s=>s.version>t.from&&s.version<=t.to),i=I.orderBy(r,"version","asc");if(((l=I.last(i))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return i.reduce((s,u)=>u.handler(s),n)}}class ve extends ja{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,r=>({version:t,...n(r)}))}async migrate({instanceData:t}){const n=await t.getItem(null),r=I.get(n,"version",0),i=this.run({from:r,to:this.VERSION},n);await t.setItem(null,i)}async needMigration({instanceData:t}){const n=await t.getItem(null);return I.get(n,"version",0)<this.VERSION}}const kt={content:""},q=(e,t)=>{const[n,{setFalse:r}]=U.useBoolean(!0),[i,l]=w.useState();w.useEffect(()=>(e.getItem(t).then(u=>{l(u),r()}),e.watchItem(t,u=>{l(u)})));const s=w.useCallback(async u=>{await e.setItem(t,u),l(u)},[e,t]);return{loading:n,value:i,set:s}};function vr(e){const t=w.useRef(null);return w.useEffect(()=>{var n,r,i;e&&((i=(r=(n=t.current)==null?void 0:n.editor)==null?void 0:r.clipboard)==null||i.dangerouslyPasteHTML(e))},[e]),t}function Wa({context:e}){const{panel:t}=re(),{value:n}=q(e.instanceData,"config"),r=n==null?void 0:n.content,i=vr(r);return n!=null&&n.content?o(Dt.RichTextEditor,{id:t.id,ref:i,readOnly:!0,value:n.content,onChange:I.noop,sx:{border:"none",".ql-editor":{padding:0,"h1, h2, h3, h4, h5, p, ul, ol":{"&:last-child":{marginBottom:0}}}}}):null}function Ua({context:e}){const{value:t,set:n}=q(e.instanceData,"config"),r=w.useMemo(()=>I.defaults({},t,kt),[t]),{control:i,handleSubmit:l,watch:s,getValues:u}=x.useForm({defaultValues:r});s("content");const d=u(),p=w.useMemo(()=>!I.isEqual(d,t),[d,t]),c=vr(t==null?void 0:t.content);return o(a.Stack,{mt:"md",spacing:"xs",children:g("form",{onSubmit:l(n),children:[g(a.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[o(a.Text,{children:"Content"}),o(a.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!p,children:o(T.DeviceFloppy,{size:20})})]}),o(x.Controller,{name:"content",control:i,render:({field:f})=>o(zn.default,{ref:c,sx:{flex:1},...I.omit(f,"ref")})})]})})}class Ya extends ve{constructor(){super(...arguments);k(this,"VERSION",1)}fixMalformedConfig(n){return I.defaults({},n,kt)}configVersions(){this.version(1,n=>({version:1,config:this.fixMalformedConfig(n)}))}}const Qa={displayName:"RichText",migrator:new Ya,name:"richText",viewRender:Wa,configRender:Ua,createConfig:()=>kt},Pt={align:"center",template:"The variable ${value} is defined in Variables section",variables:[{name:"value",size:"20px",weight:"bold",color:{type:"static",staticColor:"blue"},data_field:"",aggregation:{type:"none",config:{}},formatter:{output:"number",mantissa:0}}]};function Ha(e){if("variables"in e)return e;const{align:t,size:n,weight:r,color:i,content:{prefix:l="",data_field:s="value",formatter:u={output:"number",mantissa:0},postfix:d=""}={}}=e;return{align:t,template:`${l} \${value} ${d}`,variables:[{name:"value",data_field:s,aggregation:{type:"none",config:{}},formatter:u,color:i,weight:r,size:n}]}}class Xa extends ve{constructor(){super(...arguments);k(this,"VERSION",1)}configVersions(){this.version(1,n=>({config:Ha(n)}))}}const zt=w.forwardRef(function({value:t,onChange:n,...r},i){return o(a.TextInput,{ref:i,value:t,onChange:n,...r})}),Qe={mantissa:0,output:"number",trimMantissa:!1,average:!1};function Ja({value:e,onChange:t},n){const r=u=>{t({...e,output:u})},i=u=>{const d=u===0?!1:e.trimMantissa;t({...e,mantissa:u,trimMantissa:d})},l=u=>{t({...e,trimMantissa:u.currentTarget.checked})},s=u=>{t({...e,average:u.currentTarget.checked})};return g(a.Stack,{ref:n,children:[g(a.Group,{grow:!0,children:[o(a.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:r,sx:{flexGrow:1}}),o(a.Switch,{label:g(a.Stack,{spacing:0,children:[o(a.Text,{children:"Average"}),o(a.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:s,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),g(a.Group,{grow:!0,children:[o(a.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:i}),o(a.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:l,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),g(a.Stack,{spacing:0,children:[o(a.Text,{weight:"bold",children:"Preview"}),o(Le,{children:g(a.Group,{position:"apart",children:[g(a.Text,{size:12,color:"gray",children:["123456789 ",o(T.ArrowRight,{size:9})," ",de.default(123456789).format(e)]}),g(a.Text,{size:12,color:"gray",children:["1234 ",o(T.ArrowRight,{size:9})," ",de.default(1234).format(e)]}),g(a.Text,{size:12,color:"gray",children:["0.1234 ",o(T.ArrowRight,{size:9})," ",de.default(.1234).format(e)]})]})})]})]})}const Gt=D.default.forwardRef(Ja);function at(){return{name:K.randomId(),size:"20px",weight:"bold",color:{type:"static",staticColor:"blue"},data_field:"",aggregation:{type:"none",config:{}},formatter:Qe}}const Ka=[{label:"None",value:"none"},{label:"Sum",value:"sum"},{label:"Mean",value:"mean"},{label:"Median",value:"median"},{label:"Max",value:"max"},{label:"Min",value:"min"},{label:"Quantile(99%, 95%, ...)",value:"quantile"}];function Za({label:e,value:t,onChange:n},r){w.useEffect(()=>{typeof t=="string"&&(console.log(t),n({type:t,config:{}}))},[t,n]);const i=s=>{n(s==="quantile"?{type:"quantile",config:{p:.99}}:{type:s,config:{}})},l=s=>{n({type:"quantile",config:{p:s}})};return g(a.Group,{grow:!0,noWrap:!0,pt:"sm",children:[o(a.Select,{ref:r,label:e,data:Ka,value:t.type,onChange:i}),t.type==="quantile"&&o(a.NumberInput,{label:"p",value:t.config.p,onChange:l,precision:2,min:.05,step:.05,max:1})]})}const el=D.default.forwardRef(Za);function tl({label:e,required:t,value:n,onChange:r,data:i,clearable:l=!1,sx:s,...u},d){const p=D.default.useMemo(()=>{if(!Array.isArray(i)||i.length===0)return[];const f=Object.keys(i[0]).map(h=>({label:h,value:h}));return l?f.concat([{label:"unset",value:""}]):f},[i]);return o(a.Select,{ref:d,label:e,data:p,value:n,onChange:r,required:t,sx:s,...u})}const H=D.default.forwardRef(tl);function nl({label:e,value:t,onChange:n},r){const[i,l]=D.default.useState(Array.isArray(t)?[...t]:[]),s=D.default.useCallback(()=>{l(h=>[...h,""])},[l]),u=D.default.useCallback(h=>{l(v=>(v.splice(h,1),[...v]))},[l]),d=D.default.useMemo(()=>!N.default.isEqual(i,t),[i,t]),p=()=>{n(i.map(h=>h.toString()))},c=a.useMantineTheme(),f=D.default.useMemo(()=>Object.entries(c.colors).map(([h,v])=>v[6]),[c]);return g(Y,{children:[g(a.Group,{position:"left",ref:r,children:[o(a.Text,{children:e}),o(a.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:p,children:o(T.DeviceFloppy,{size:20})})]}),g(a.Group,{children:[i.map((h,v)=>o(a.ColorInput,{value:h,onChange:C=>{l(y=>(y.splice(v,1,C),[...y]))},swatches:f,rightSection:o(a.ActionIcon,{onClick:()=>u(v),color:"red",children:o(T.Trash,{size:14})}),sx:{width:"45%"}})),o(a.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:o(T.PlaylistAdd,{size:20})})]})]})}const rl=D.default.forwardRef(nl);function il({value:e,onChange:t},n){const{colorManager:r}=w.useContext(De),i=D.default.useMemo(()=>r.getStaticColors().map(u=>({label:u.name,group:u.category,value:u.value})),[r]),l=D.default.useMemo(()=>i.some(s=>s.value===e),[e,i]);return g(a.Group,{position:"apart",spacing:4,ref:n,children:[o(a.TextInput,{placeholder:"Set any color",value:l?"":e,onChange:s=>t(s.currentTarget.value),rightSection:o(a.ColorSwatch,{color:l?"transparent":e,radius:4}),variant:l?"filled":"default",sx:{maxWidth:"46%",flexGrow:1}}),o(a.Text,{sx:{flexGrow:0},children:"or"}),o(a.Select,{data:i,value:e,onChange:t,variant:l?"default":"filled",placeholder:"Pick a theme color",icon:o(a.ColorSwatch,{color:l?e:"transparent",radius:4}),sx:{maxWidth:"46%",flexGrow:1}})]})}const Te=D.default.forwardRef(il),lt=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function ol({label:e,value:t,onChange:n},r){var s,u;const[i,l]=D.default.useState((u=(s=lt.find(d=>d.label===t))==null?void 0:s.value)!=null?u:lt[0].value);return D.default.useEffect(()=>{const d=lt.find(p=>p.value===i);d&&n(d.label)},[i]),g(a.Stack,{spacing:0,mt:"sm",mb:"lg",children:[o(a.Text,{size:"sm",children:e}),o(a.Slider,{label:null,marks:lt,value:i,onChange:l,step:25,placeholder:"Pick a font size",ref:r})]})}const al=D.default.forwardRef(ol);function ll({label:e,value:t,onChange:n},r){const[i,l]=D.default.useState(Array.isArray(t)?[...t]:[]),s=D.default.useCallback(()=>{l(c=>[...c,""])},[l]),u=D.default.useCallback(c=>{l(f=>(f.splice(c,1),[...f]))},[l]),d=D.default.useMemo(()=>!N.default.isEqual(i,t),[i,t]),p=()=>{n(i.map(c=>c.toString()))};return g(Y,{children:[g(a.Group,{position:"left",ref:r,children:[o(a.Text,{children:e}),o(a.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:p,children:o(T.DeviceFloppy,{size:20})})]}),g(a.Group,{children:[i.map((c,f)=>o(a.TextInput,{value:c,onChange:h=>{const v=h.currentTarget.value;l(C=>(C.splice(f,1,v),[...C]))},rightSection:o(a.ActionIcon,{onClick:()=>u(f),color:"red",children:o(T.Trash,{size:14})}),sx:{width:"45%"}})),o(a.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:o(T.PlaylistAdd,{size:20})})]})]})}const sl=D.default.forwardRef(ll),ul=D.default.forwardRef(function({value:t,onChange:n},r){const i=t.color.type,l=(s,u)=>{const d=N.default.cloneDeep(t);N.default.set(d,s,u),n(d)};return g(Y,{children:[o(a.Divider,{my:"xs",label:"Typography",labelPosition:"center"}),o(a.Stack,{children:o(a.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},value:t.size,onChange:s=>l("size",s.currentTarget.value)})}),o(a.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:o(al,{label:"Font Weight",value:t.weight,onChange:s=>l("weight",s)})}),o(a.Divider,{my:"xs",label:"Style",labelPosition:"center"}),g(a.Stack,{children:[o(a.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:t.color.type,onChange:s=>l("color.type",s)}),i==="static"&&o(Te,{value:t.color.staticColor,onChange:s=>l("color.staticColor",s)}),i==="continuous"&&g(Y,{children:[o(sl,{label:"Value Range",value:t.color.valueRange,onChange:s=>l("color.valueRange",s)}),o(rl,{label:"Color Range",value:t.color.colorRange,onChange:s=>l("color.colorRange",s)})]})]})]})}),st=D.default.forwardRef(function({value:t,onChange:n,data:r,withStyle:i=!0},l){const s=(u,d)=>{const p=N.default.cloneDeep(t);N.default.set(p,u,d),n(p)};return g(a.Box,{px:"sm",py:"md",ref:l,children:[o(a.Text,{weight:"bold",pb:0,children:t.name}),o(a.Divider,{my:"xs",label:"Data",labelPosition:"center"}),g(a.Group,{grow:!0,noWrap:!0,children:[o(a.TextInput,{label:"Name",required:!0,value:t.name,onChange:u=>s("name",u.currentTarget.value)}),o(H,{label:"Data Field",required:!0,data:r,value:t.data_field,onChange:u=>s("data_field",u)})]}),o(el,{label:"Aggregation",value:t.aggregation,onChange:u=>s("aggregation",u)}),o(a.Divider,{my:"xs",label:"Format",labelPosition:"center"}),o(Gt,{value:t.formatter,onChange:u=>s("formatter",u)}),i&&o(ul,{value:t,onChange:n})]})});function dl(e){const t=Array.from(e).sort((r,i)=>r-i),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}function Nt(e,t,n){var i,l,s,u;const r=e.map(d=>d[t]);switch(n.type){case"sum":return N.default.sum(r);case"mean":return N.default.mean(r);case"median":return dl(r);case"max":return(i=N.default.max(r))!=null?i:0;case"min":return(l=N.default.min(r))!=null?l:0;case"quantile":return(s=co.quantile(r,n.config.p))!=null?s:0;default:return(u=e[0])==null?void 0:u[t]}}var yr=function(){},He=function(){};process.env.NODE_ENV!=="production"&&(yr=function(e,t){!e&&typeof console<"u"&&console.warn(t)},He=function(e,t){if(!e)throw new Error(t)});const cl=(e,t,n)=>Math.min(Math.max(n,e),t),br=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r},Lt=(e,t,n)=>-n*e+n*t+e,Cr=(e,t)=>n=>Math.max(Math.min(n,t),e),Xe=e=>e%1?Number(e.toFixed(5)):e,ut=/(-)?([\d]*\.?[\d])+/g,qt=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,gl=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function Je(e){return typeof e=="string"}const dt={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},xr=Object.assign(Object.assign({},dt),{transform:Cr(0,1)});Object.assign(Object.assign({},dt),{default:1});const Ke=(e=>({test:t=>Je(t)&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}))("%");Object.assign(Object.assign({},Ke),{parse:e=>Ke.parse(e)/100,transform:e=>Ke.transform(e*100)});const Bt=(e,t)=>n=>Boolean(Je(n)&&gl.test(n)&&n.startsWith(e)||t&&Object.prototype.hasOwnProperty.call(n,t)),wr=(e,t,n)=>r=>{if(!Je(r))return r;const[i,l,s,u]=r.match(ut);return{[e]:parseFloat(i),[t]:parseFloat(l),[n]:parseFloat(s),alpha:u!==void 0?parseFloat(u):1}},Ge={test:Bt("hsl","hue"),parse:wr("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+Ke.transform(Xe(t))+", "+Ke.transform(Xe(n))+", "+Xe(xr.transform(r))+")"},pl=Cr(0,255),jt=Object.assign(Object.assign({},dt),{transform:e=>Math.round(pl(e))}),$e={test:Bt("rgb","red"),parse:wr("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+jt.transform(e)+", "+jt.transform(t)+", "+jt.transform(n)+", "+Xe(xr.transform(r))+")"};function fl(e){let t="",n="",r="",i="";return e.length>5?(t=e.substr(1,2),n=e.substr(3,2),r=e.substr(5,2),i=e.substr(7,2)):(t=e.substr(1,1),n=e.substr(2,1),r=e.substr(3,1),i=e.substr(4,1),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const Wt={test:Bt("#"),parse:fl,transform:$e.transform},ct={test:e=>$e.test(e)||Wt.test(e)||Ge.test(e),parse:e=>$e.test(e)?$e.parse(e):Ge.test(e)?Ge.parse(e):Wt.parse(e),transform:e=>Je(e)?e:e.hasOwnProperty("red")?$e.transform(e):Ge.transform(e)},Sr="${c}",_r="${n}";function hl(e){var t,n,r,i;return isNaN(e)&&Je(e)&&((n=(t=e.match(ut))===null||t===void 0?void 0:t.length)!==null&&n!==void 0?n:0)+((i=(r=e.match(qt))===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0)>0}function Dr(e){typeof e=="number"&&(e=`${e}`);const t=[];let n=0;const r=e.match(qt);r&&(n=r.length,e=e.replace(qt,Sr),t.push(...r.map(ct.parse)));const i=e.match(ut);return i&&(e=e.replace(ut,_r),t.push(...i.map(dt.parse))),{values:t,numColors:n,tokenised:e}}function Ir(e){return Dr(e).values}function Ar(e){const{values:t,numColors:n,tokenised:r}=Dr(e),i=t.length;return l=>{let s=r;for(let u=0;u<i;u++)s=s.replace(u<n?Sr:_r,u<n?ct.transform(l[u]):Xe(l[u]));return s}}const ml=e=>typeof e=="number"?0:e;function vl(e){const t=Ir(e);return Ar(e)(t.map(ml))}const Mr={test:hl,parse:Ir,createTransformer:Ar,getAnimatableNone:vl};function Ut(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Vr({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,l=0,s=0;if(!t)i=l=s=n;else{const u=n<.5?n*(1+t):n+t-n*t,d=2*n-u;i=Ut(d,u,e+1/3),l=Ut(d,u,e),s=Ut(d,u,e-1/3)}return{red:Math.round(i*255),green:Math.round(l*255),blue:Math.round(s*255),alpha:r}}const yl=(e,t,n)=>{const r=e*e,i=t*t;return Math.sqrt(Math.max(0,n*(i-r)+r))},bl=[Wt,$e,Ge],Er=e=>bl.find(t=>t.test(e)),Tr=e=>`'${e}' is not an animatable color. Use the equivalent color code instead.`,$r=(e,t)=>{let n=Er(e),r=Er(t);He(!!n,Tr(e)),He(!!r,Tr(t));let i=n.parse(e),l=r.parse(t);n===Ge&&(i=Vr(i),n=$e),r===Ge&&(l=Vr(l),r=$e);const s=Object.assign({},i);return u=>{for(const d in s)d!=="alpha"&&(s[d]=yl(i[d],l[d],u));return s.alpha=Lt(i.alpha,l.alpha,u),n.transform(s)}},Cl=e=>typeof e=="number",xl=(e,t)=>n=>t(e(n)),Rr=(...e)=>e.reduce(xl);function Fr(e,t){return Cl(e)?n=>Lt(e,t,n):ct.test(e)?$r(e,t):Pr(e,t)}const Or=(e,t)=>{const n=[...e],r=n.length,i=e.map((l,s)=>Fr(l,t[s]));return l=>{for(let s=0;s<r;s++)n[s]=i[s](l);return n}},wl=(e,t)=>{const n=Object.assign(Object.assign({},e),t),r={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Fr(e[i],t[i]));return i=>{for(const l in r)n[l]=r[l](i);return n}};function kr(e){const t=Mr.parse(e),n=t.length;let r=0,i=0,l=0;for(let s=0;s<n;s++)r||typeof t[s]=="number"?r++:t[s].hue!==void 0?l++:i++;return{parsed:t,numNumbers:r,numRGB:i,numHSL:l}}const Pr=(e,t)=>{const n=Mr.createTransformer(t),r=kr(e),i=kr(t);return r.numHSL===i.numHSL&&r.numRGB===i.numRGB&&r.numNumbers>=i.numNumbers?Rr(Or(r.parsed,i.parsed),n):(yr(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),s=>`${s>0?t:e}`)},Sl=(e,t)=>n=>Lt(e,t,n);function _l(e){if(typeof e=="number")return Sl;if(typeof e=="string")return ct.test(e)?$r:Pr;if(Array.isArray(e))return Or;if(typeof e=="object")return wl}function Dl(e,t,n){const r=[],i=n||_l(e[0]),l=e.length-1;for(let s=0;s<l;s++){let u=i(e[s],e[s+1]);if(t){const d=Array.isArray(t)?t[s]:t;u=Rr(d,u)}r.push(u)}return r}function Il([e,t],[n]){return r=>n(br(e,t,r))}function Al(e,t){const n=e.length,r=n-1;return i=>{let l=0,s=!1;if(i<=e[0]?s=!0:i>=e[r]&&(l=r-1,s=!0),!s){let d=1;for(;d<n&&!(e[d]>i||d===r);d++);l=d-1}const u=br(e[l],e[l+1],i);return t[l](u)}}function Ml(e,t,{clamp:n=!0,ease:r,mixer:i}={}){const l=e.length;He(l===t.length,"Both input and output ranges must be the same length"),He(!r||!Array.isArray(r)||r.length===l-1,"Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values."),e[0]>e[l-1]&&(e=[].concat(e),t=[].concat(t),e.reverse(),t.reverse());const s=Dl(t,r,i),u=l===2?Il(e,s):Al(e,s);return n?d=>u(cl(e[0],e[l-1],d)):u}class Vl{constructor({valueRange:t,colorRange:n}){k(this,"mapper");this.mapper=Ml(t,n)}getColor(t){return this.mapper(t)}}function El(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Yt({data_field:e,aggregation:t},n){return Nt(n,e,t)}function Ze({formatter:e},t){return["string","number"].includes(typeof t)?de.default(t).format(e):El(t)}function Tl(e,t){return e.type==="static"?e.staticColor:e.type==="continuous"?new Vl(e).getColor(t):"black"}function $l(e,t){const n={};return e.forEach(r=>{const{name:i,color:l,data_field:s,aggregation:u,size:d,weight:p}=r,c=Nt(t,s,u),f=Ze(r,c);n[i]=o(a.Text,{sx:{fontSize:d,display:"inline"},color:Tl(l,c),weight:p,children:f})}),n}function Rl(e){return e.split(" ").map(t=>g(Y,{children:[t,"\xA0"]}))}function Fl(e){const n=e.replaceAll("<br />","<br/>").replaceAll(`
|
|
40
|
+
`,Zn=M.observer(function({showSQLSnippets:t=!0,sx:n={}}){const r=Q(),i=r.context.current,l=D.default.useMemo(()=>{const s={context:i,filters:r.filters.values};return t&&(s.sql_snippets=r.sqlSnippets.record),JSON.stringify(s,null,2)},[i,r.sqlSnippets.record,r.filters.values,t]);return g(a.Stack,{sx:{border:"1px solid #eee",maxWidth:"40%",overflow:"hidden",...n},children:[o(a.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:o(a.Text,{weight:500,children:"Global Variables"})}),g(a.Stack,{px:"md",pb:"md",sx:{width:"100%"},children:[o(Ne.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:zo}),o(a.Text,{weight:500,sx:{flexGrow:0},children:"Current Values"}),o(Ne.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:l})]})]})});function Go({data:e}){return e.length===0?o(a.Box,{sx:{height:"5em"}}):g(a.Table,{children:[o("thead",{children:o("tr",{children:Object.keys(e==null?void 0:e[0]).map(t=>o("th",{children:o(a.Text,{weight:700,color:"#000",children:t})},t))})}),o("tbody",{children:e.slice(0,10).map((t,n)=>o("tr",{children:Object.values(t).map((r,i)=>o("td",{children:o(a.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:o(a.Text,{children:r})})},`${r}--${i}`))},`row-${n}`))})]})}const er=M.observer(function({id:t}){const n=Q(),{data:r,state:i}=n.getDataStuffByID(t),l=i==="loading",s=()=>{n.queries.refetchDataByQueryID(t)};return g(a.Stack,{my:"xl",sx:{border:"1px solid #eee"},children:[g(a.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[g(a.Group,{position:"left",children:[o(a.Text,{weight:500,children:"Preview Data"}),r.length>10&&g(a.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",r.length]})]}),o(a.ActionIcon,{mr:15,variant:"subtle",color:"blue",disabled:l,onClick:s,children:o(T.Refresh,{size:15})})]}),g(a.Box,{sx:{position:"relative"},children:[o(a.LoadingOverlay,{visible:l}),o(Go,{data:r})]})]})}),No=w.forwardRef(({label:e,type:t,...n},r)=>g(a.Group,{position:"apart",ref:r,...n,children:[o(a.Text,{children:e}),o(a.Text,{children:t})]})),tr=M.observer(function({value:t,onChange:n}){const{data:r=[],loading:i}=U.useRequest(Vo,{refreshDeps:[]},[]),l=w.useMemo(()=>r.map(u=>({label:u.key,value:u.key,type:u.type})),[r]),s=w.useMemo(()=>l.reduce((u,d)=>(u[d.value]=d.type,u),{}),[l]);return o(a.Select,{label:"Data Source",data:l,itemComponent:No,sx:{flex:1},disabled:i,value:t.key,onChange:u=>{u!==null&&n({key:u,type:s[u]})}})}),nr=M.observer(({value:e})=>{const t=Q(),n=t.context.current,r=D.default.useMemo(()=>Un(e,n,t.sqlSnippets.current,t.filters.values),[e,n,t.sqlSnippets.current,t.filters.values]);return o(Ne.Prism,{language:"sql",colorScheme:"light",children:r})}),Lo=M.observer(function({queryModel:t,setCurrentID:n}){const r=D.default.useRef(t.id),[i,l]=D.default.useState(r.current);D.default.useEffect(()=>{r.current!==t.id&&(l(t.id),r.current=t.id)},[r,t.id]);const[s,u]=D.default.useState(t.sql);D.default.useEffect(()=>{u(f=>f!==t.sql?t.sql:f)},[t.sql]);const d=s!==t.sql,p=()=>{t.setSQL(s)},c=()=>{n(i),t.setID(i)};return g(a.Stack,{sx:{border:"1px solid #eee",flexGrow:1},children:[o(a.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:o(a.Text,{weight:500,children:"Edit Query"})}),g(a.Stack,{my:0,p:"md",pr:40,children:[g(a.Group,{grow:!0,children:[o(a.TextInput,{placeholder:"An ID unique in this dashboard",label:"ID",required:!0,sx:{flex:1},value:i,onChange:f=>{l(f.currentTarget.value)},rightSection:o(a.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:i===t.id,onClick:c,children:o(T.DeviceFloppy,{size:18})})}),o(tr,{value:{type:t.type,key:t.key},onChange:({type:f,key:h})=>{t.setKey(h),t.setType(f)}})]}),g(a.Tabs,{defaultValue:"SQL",children:[g(a.Tabs.List,{children:[o(a.Tabs.Tab,{value:"SQL",children:"SQL"}),o(a.Tabs.Tab,{value:"Preview",children:"Preview"})]}),o(a.Tabs.Panel,{value:"SQL",pt:"sm",children:g(a.Box,{sx:{position:"relative"},children:[o(a.Textarea,{autosize:!0,minRows:12,maxRows:24,className:"code-textarea",value:s,onChange:f=>{u(f.currentTarget.value)}}),o(a.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:10,top:10},disabled:!d,onClick:p,children:o(T.DeviceFloppy,{size:20})})]})}),o(a.Tabs.Panel,{value:"Preview",pt:"sm",children:o(nr,{value:t.sql})})]})]})]})}),qo=M.observer(function({id:t,setID:n}){const r=Q(),i=D.default.useMemo(()=>r.queries.findByID(t),[r.queries,t]);return t?i?o(Lo,{queryModel:i,setCurrentID:n}):o("span",{children:"Invalid Query ID"}):null});var we=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e))(we||{});const Bo=M.observer(function({id:t,setID:n}){const r=Q(),i=()=>{var s;n((s=r.queries.firstID)!=null?s:"")};D.default.useEffect(()=>{if(!t){i();return}r.queries.current.findIndex(u=>u.id===t)===-1&&i()},[t,r.queries.current,i]);const l=()=>{const s=K.randomId();r.queries.append(b.cast({id:s,type:we.Postgresql,key:"",sql:""})),n(s)};return o(a.Group,{pb:"xl",grow:!0,sx:{width:"100%"},children:g(a.Group,{position:"left",sx:{flexGrow:1,maxWidth:"600px",alignItems:"baseline"},children:[o(a.Text,{children:"Select a Query"}),o(a.Select,{data:r.queries.options,value:t,onChange:n,allowDeselect:!1,clearable:!1,sx:{flexGrow:1,maxWidth:"300px"}}),o(a.Text,{children:"or"}),o(a.Group,{position:"center",mt:"md",children:o(a.Button,{onClick:l,children:"Add a Query"})})]})})}),jo=M.observer(function(){const[t,n]=D.default.useState("");return g(a.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:[g(a.Group,{position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[g(a.Stack,{sx:{flexGrow:1,maxWidth:"calc(60% - 16px)"},children:[o(Bo,{id:t,setID:n}),o(qo,{id:t,setID:n})]}),o(Zn,{})]}),o(er,{id:t})]})}),Wo=M.observer(({value:e})=>{const t=Q(),n=t.context.current,r=D.default.useMemo(()=>Do(e,n,t.filters.values),[e,n]);return g(a.Stack,{children:[o(a.Text,{children:"Preview"}),o(Ne.Prism,{language:"sql",noCopy:!0,colorScheme:"dark",children:r})]})}),Uo=M.observer(function(){const t=Q(),n=()=>t.sqlSnippets.append(b.cast({key:K.randomId(),value:""}));return g(a.Stack,{sx:{border:"1px solid #eee",flexGrow:1},children:[o(a.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:o(a.Text,{weight:500,children:"SQL Snippets"})}),o(a.Group,{px:"md",pb:"md",pt:"md",children:g(a.Stack,{sx:{width:"100%",position:"relative"},children:[t.sqlSnippets.current.map((r,i)=>g(a.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[o(a.TextInput,{label:"Key",required:!0,value:r.key,onChange:l=>{r.setKey(l.currentTarget.value)}}),o(a.Textarea,{minRows:3,label:"Value",required:!0,value:r.value,onChange:l=>{r.setValue(l.currentTarget.value)},className:"code-textarea"}),o(Wo,{value:r.value}),o(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t.sqlSnippets.remove(i),sx:{position:"absolute",top:15,right:5},children:o(T.Trash,{size:16})})]},i)),o(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:o(a.Button,{variant:"default",onClick:n,children:"Add a snippet"})})]})})]})});function Yo(){return o(a.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:g(a.Group,{position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[o(Uo,{}),o(Zn,{showSQLSnippets:!1})]})})}const Qo=M.observer(function({opened:t,close:n}){const{freezeLayout:r}=D.default.useContext(me);return D.default.useEffect(()=>{r(t)},[t]),o(a.Modal,{size:"96vw",overflow:"inside",opened:t,onClose:n,title:"Data Settings",trapFocus:!0,onDragStart:i=>{i.stopPropagation()},children:g(a.Tabs,{defaultValue:"Queries",children:[g(a.Tabs.List,{children:[o(a.Tabs.Tab,{value:"SQL Snippet",children:"SQL Snippet"}),o(a.Tabs.Tab,{value:"Queries",children:"Queries"})]}),o(a.Tabs.Panel,{value:"SQL Snippet",pt:"sm",children:o(Yo,{})}),o(a.Tabs.Panel,{value:"Queries",pt:"sm",children:o(jo,{})})]})})});var ce=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(ce||{});const rr=b.types.model({type:b.types.enumeration("DataSourceType",[we.Postgresql,we.MySQL,we.HTTP]),key:b.types.string,sql:b.types.string}),ir=b.types.model("FilterConfigModel_TextInput",{required:b.types.boolean,default_value:b.types.string}).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),or=()=>ir.create({required:!1,default_value:""}),Ho=M.observer(function({config:t}){return o(Y,{children:o(a.Checkbox,{checked:t.default_value,onChange:n=>t.setDefaultValue(n.currentTarget.checked),label:"Default Checked"})})}),Xo=[{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"}],Jo=M.observer(function({config:t}){return g(Y,{children:[g(a.Group,{children:[o(a.Checkbox,{checked:t.required,onChange:n=>t.setRequired(n.currentTarget.checked),label:"Required"}),o(a.Checkbox,{checked:t.clearable,onChange:n=>t.setClearable(n.currentTarget.checked),label:"Clearable"})]}),o(a.Select,{data:Xo,label:"Display Format",value:t.inputFormat,onChange:t.setInputFormat}),o(Wn,{label:"Default Value",config:t,value:t.default_value,onChange:t.setDefaultValue})]})});function Ko({data:e}){return e.length===0?o(a.Box,{sx:{height:"5em"}}):g(a.Table,{children:[o("thead",{children:o("tr",{children:Object.keys(e==null?void 0:e[0]).map(t=>o("th",{children:o(a.Text,{weight:700,color:"#000",children:t})},t))})}),o("tbody",{children:e.slice(0,3).map((t,n)=>o("tr",{children:Object.values(t).map((r,i)=>o("td",{children:o(a.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:o(a.Text,{children:r})})},`${r}--${i}`))},`row-${n}`))}),e.length>3&&o("tfoot",{children:o("tr",{children:o("td",{colSpan:Object.keys(e==null?void 0:e[0]).length,children:g(a.Text,{color:"gray",size:"sm",children:[e.length-3," more row(s) hidden"]})})})})]})}const Zo=M.observer(function({query:t}){const{data:n=[],loading:r,refresh:i}=U.useRequest(Ft(t),{refreshDeps:[t]});return g(a.Stack,{my:0,children:[g(a.Group,{position:"apart",children:[o(a.Text,{size:"md",pl:"sm",children:"Fetched Data"}),o(a.Button,{size:"xs",onClick:i,disabled:!t.sql||!t.key,children:"Retry"})]}),g(a.Box,{sx:{position:"relative"},children:[o(a.LoadingOverlay,{visible:r,exitTransitionDuration:0}),o(Ko,{data:n})]})]})}),ar=M.observer(function({value:t,onChange:n}){return g(a.Stack,{my:0,children:[o(tr,{value:t,onChange:({type:r,key:i})=>{n({...t,type:r,key:i})}}),g(a.Tabs,{defaultValue:"SQL",children:[g(a.Tabs.List,{children:[o(a.Tabs.Tab,{value:"SQL",children:"SQL"}),o(a.Tabs.Tab,{value:"Preview",children:"Preview"}),o(a.Tabs.Tab,{value:"Data",children:"Data"})]}),o(a.Tabs.Panel,{value:"SQL",pt:"sm",children:o(a.Textarea,{autosize:!0,minRows:12,maxRows:24,className:"code-textarea",value:t.sql,onChange:r=>{n({...t,sql:r.currentTarget.value})},placeholder:"SELECT name AS label, id AS value"})}),o(a.Tabs.Panel,{value:"Preview",pt:"sm",children:o(nr,{value:t.sql})}),o(a.Tabs.Panel,{value:"Data",pt:"sm",children:o(Zo,{query:t})})]})]})}),ea=M.observer(function({config:t}){const n=()=>{t.addStaticOption({label:"",value:""})},r=t.static_options,i=[...r];return g(Y,{children:[o(a.Divider,{label:"Configure options",labelPosition:"center"}),r.length>0&&o(a.MultiSelect,{label:"Default Selection",data:i,value:t.default_value,onChange:t.setDefaultValue}),r.map((l,s)=>g(a.Group,{sx:{position:"relative"},pr:"40px",children:[o(a.TextInput,{label:"Label",required:!0,value:t.static_options[s].label,onChange:u=>{t.static_options[s].setLabel(u.currentTarget.value)},sx:{flexGrow:1}}),o(a.TextInput,{label:"Value",required:!0,value:t.static_options[s].value,onChange:u=>{t.static_options[s].setValue(u.currentTarget.value)},sx:{flexGrow:1}}),o(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t.removeStaticOption(s),sx:{position:"absolute",top:28,right:5},children:o(T.Trash,{size:16})})]})),o(a.Button,{size:"xs",color:"blue",leftIcon:o(T.PlaylistAdd,{size:20}),onClick:n,sx:{width:"50%"},mx:"auto",children:"Add an Option"}),o(a.Divider,{label:"Or fetch options from database",labelPosition:"center"}),o(ar,{value:t.options_query,onChange:t.setOptionsQuery})]})}),ta=M.observer(function({config:t}){const n=()=>{t.addStaticOption({label:"",value:""})},r=t.static_options,i=[{label:"No default selection",value:""},...r];return g(Y,{children:[o(a.Checkbox,{checked:t.required,onChange:l=>t.setRequired(l.currentTarget.checked),label:"Required"}),o(a.Divider,{label:"Configure options",labelPosition:"center"}),r.length>0&&o(a.Select,{label:"Default Selection",data:i,value:t.default_value,onChange:t.setDefaultValue}),r.map((l,s)=>g(a.Group,{sx:{position:"relative"},pr:"40px",children:[o(a.TextInput,{label:"Label",required:!0,value:t.static_options[s].label,onChange:u=>{t.static_options[s].setLabel(u.currentTarget.value)},sx:{flexGrow:1}}),o(a.TextInput,{label:"Value",required:!0,value:t.static_options[s].value,onChange:u=>{t.static_options[s].setValue(u.currentTarget.value)},sx:{flexGrow:1}}),o(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t.removeStaticOption(s),sx:{position:"absolute",top:28,right:5},children:o(T.Trash,{size:16})})]},s)),o(a.Button,{size:"xs",color:"blue",leftIcon:o(T.PlaylistAdd,{size:20}),onClick:n,sx:{width:"50%"},mx:"auto",children:"Add an Option"}),o(a.Divider,{label:"Or fetch options from database",labelPosition:"center"}),o(ar,{value:t.options_query,onChange:t.setOptionsQuery})]})}),na=M.observer(function({config:t}){return g(Y,{children:[o(a.TextInput,{label:"Default Value",value:t.default_value,onChange:n=>{t.setDefaultValue(n.currentTarget.value)}}),o(a.Checkbox,{checked:t.required,onChange:n=>t.setRequired(n.currentTarget.checked),label:"Required"})]})}),ra=M.observer(function({filter:t}){const n=t.plainDefaultValue,[r,i]=D.default.useState(n);return D.default.useEffect(()=>{i(n)},[n]),g(a.Box,{sx:{maxWidth:"30em"},children:[o(a.Text,{pb:"md",color:"gray",children:"Preview"}),o(Qn,{filter:t,value:r,onChange:i}),o(a.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),o(Ne.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),ia={select:ta,"multi-select":ea,"text-input":na,checkbox:Ho,"date-range":Jo},oa=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],aa=M.observer(function({filter:t,index:n}){const r=Q(),i=D.default.useMemo(()=>ia[t.type],[t.type]);return g(a.SimpleGrid,{cols:2,children:[g(a.Box,{pl:"md",children:[o(a.Text,{pb:"md",color:"gray",children:"Edit"}),g(a.Stack,{sx:{maxWidth:"30em"},children:[o(a.NumberInput,{label:"Placement Order",required:!0,value:t.order,onChange:t.setOrder,hideControls:!0}),o(a.MultiSelect,{label:"Visible in...",data:r.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),o(a.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:t.key,onChange:l=>{t.setKey(l.currentTarget.value)}}),o(a.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:t.label,onChange:l=>{t.setLabel(l.currentTarget.value)}}),o(a.Select,{label:"Widget",data:oa,required:!0,value:t.type,onChange:t.setType}),o(i,{config:t.config,index:n})]})]}),o(ra,{filter:t})]})}),Wg="",la=M.observer(function(){const t=Q(),n=t.filters.current,r=()=>{const i=K.randomId(),l={id:i,key:i,label:i,order:n.length+1,type:ce.TextInput,config:or(),visibleInViewsIDs:["Main"]};t.filters.append(l)};return g(a.Box,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)"},p:0,children:[o(a.Group,{sx:{position:"absolute",top:"16px",right:"16px"},children:o(a.Button,{size:"xs",color:"red",leftIcon:o(T.Recycle,{size:20}),disabled:!t.filters.changed,onClick:t.filters.reset,children:"Revert Changes"})}),o(a.Tabs,{className:"filter-settings-tabs",orientation:"vertical",defaultValue:t.filters.firstID,styles:{root:{display:"block"}},children:g(a.Group,{sx:{height:"100%"},children:[g(a.Stack,{sx:{height:"100%"},children:[o(a.Tabs.List,{position:"left",sx:{flexGrow:1,width:"200px"},children:t.filters.current.map(i=>o(a.Tabs.Tab,{value:i.id,sx:{maxWidth:"100%",overflow:"scroll"},children:i.label},i.id))}),o(a.Button,{size:"xs",color:"blue",leftIcon:o(T.PlaylistAdd,{size:20}),onClick:r,children:"Add a Filter"})]}),o(a.Box,{sx:{flexGrow:1,height:"100%"},children:t.filters.current.map((i,l)=>o(a.Tabs.Panel,{value:i.id,sx:{height:"100%"},children:g(a.Stack,{sx:{height:"100%"},spacing:"sm",children:[o(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"scroll"},children:o(aa,{filter:i,index:l})}),o(a.Group,{position:"right",pt:10,children:o(a.Button,{size:"xs",color:"red",leftIcon:o(T.Trash,{size:20}),onClick:()=>t.filters.remove(l),children:"Delete this filter"})})]})},i.id))})]})})]})}),sa=M.observer(function({opened:t,close:n}){const{freezeLayout:r}=D.default.useContext(me);return D.default.useEffect(()=>{r(t)},[t]),o(a.Modal,{size:"96vw",overflow:"inside",opened:t,onClose:n,title:"Filters",trapFocus:!0,onDragStart:i=>{i.stopPropagation()},withCloseButton:!1,children:o(la,{})})});var lr=(e=>(e.Use="use",e.Edit="edit",e))(lr||{}),ge=(e=>(e.Division="div",e.Modal="modal",e))(ge||{}),sr=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(sr||{});const ua=M.observer(()=>{const t=Q().views.VIE;return!t||t.type!==ge.Division?null:g(a.Stack,{children:[o(a.Divider,{mt:8,mb:0,label:"Division settings",labelPosition:"center"}),o(a.Text,{align:"center",size:"xs",color:"dimmed",children:"Under construction"})]})}),da=M.observer(()=>{const t=Q().views.VIE;return!t||t.type!==ge.Modal?null:g(a.Stack,{children:[o(a.Divider,{mt:8,label:"Modal settings",labelPosition:"center"}),g(a.Group,{grow:!0,children:[o(a.TextInput,{label:"Width",value:t.config.width,onChange:n=>t.updateConfig("width",n.currentTarget.value),placeholder:"600px / 50vw"}),o(a.TextInput,{label:"Height",value:t.config.height,onChange:n=>t.updateConfig("height",n.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),ca=M.observer(()=>g(Y,{children:[o(ua,{}),o(da,{})]})),ga=[{label:"Division",value:ge.Division},{label:"Modal",value:ge.Modal}],pa=M.observer(()=>{const t=Q().views.VIE;return t?g(a.Stack,{sx:{position:"relative"},children:[o(a.TextInput,{label:"Name",value:t.name,onChange:n=>{t.setName(n.currentTarget.value)}}),o(a.Select,{label:"Type",value:t.type,onChange:t.setType,data:ga}),o(ca,{})]}):null}),fa=M.observer(({opened:e,close:t})=>{var i;const n=Q(),{freezeLayout:r}=D.default.useContext(me);return D.default.useEffect(()=>{r(e)},[e]),o(a.Modal,{size:"500px",overflow:"inside",opened:e,onClose:t,withCloseButton:!1,styles:{header:{width:"100%"},title:{width:"100%"}},title:g(a.Group,{position:"apart",children:[g(a.Text,{sx:{flexGrow:1},children:["Editing ",(i=n.views.VIE)==null?void 0:i.name]}),o(a.ActionIcon,{size:18,color:"red",onClick:n.views.removeVIE,disabled:n.views.isVIETheFirstView,children:o(T.Trash,{size:18})})]}),trapFocus:!0,onDragStart:l=>{l.stopPropagation()},children:o(pa,{})})}),ha=w.forwardRef(({label:e,type:t,...n},r)=>t!=="TRIGGER_TO_ADD"?o("div",{ref:r,...n,children:g(a.Group,{noWrap:!0,position:"apart",children:[o(a.Text,{size:"sm",children:e}),o(a.Text,{size:"xs",color:"dimmed",children:t})]})}):o("div",{ref:r,...n,children:o(a.Group,{noWrap:!0,grow:!0,children:o(a.Text,{size:"sm",align:"center",color:"#228be6",children:e})})})),ur="TRIGGER_TO_ADD",ma=M.observer(({value:e,onChange:t,triggerAdd:n,triggerEdit:r,options:i})=>{const l=w.useMemo(()=>[...i,{label:"Add a View",value:ur,type:"TRIGGER_TO_ADD"}],[i,n]),s=u=>{u!==ur?t(u):n()};return g(a.Group,{position:"left",spacing:0,sx:{minWidth:"260px"},children:[o(a.Select,{value:e,onChange:s,placeholder:"Pick a View",itemComponent:ha,data:l,nothingFound:"Empty",sx:{flexGrow:1},styles:{input:{borderTopRightRadius:0,borderBottomRightRadius:0}}}),o(a.ActionIcon,{onClick:r,variant:"default",size:36,sx:{borderLeft:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,"&:active":{transform:"none",svg:{transform:"translateY(1px)"}}},children:o(T.Settings,{size:20})})]})}),va=M.observer(()=>{const e=Q(),[t,n]=w.useState(!1),r=()=>{n(!0)},i=()=>{n(!1)};return g(Y,{children:[o(ma,{value:e.views.idOfVIE,onChange:e.views.setIDOfVIE,triggerAdd:e.views.addARandomNewView,triggerEdit:r,options:e.views.options}),o(fa,{opened:t,close:i})]})}),dr={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}},cr=M.observer(function({saveChanges:t}){const n=Q(),r=D.default.useCallback(()=>{const E=n.queries.current,$=n.views.current,F=n.sqlSnippets.current;return{filters:n.filters.current,views:$,definition:{sqlSnippets:F,queries:E}}},[n]),i=()=>{n.filters.reset(),n.views.reset(),n.sqlSnippets.reset(),n.queries.reset()},l=n.views.changed||n.sqlSnippets.changed||n.queries.changed||n.filters.changed,{inEditMode:s,inUseMode:u}=D.default.useContext(me),[d,p]=D.default.useState(!1),c=()=>p(!0),f=()=>p(!1),[h,v]=D.default.useState(!1),C=()=>v(!0),y=()=>v(!1),S=()=>{const E=JSON.stringify(r(),null,2);Oo(n.name,E)};return g(a.Group,{position:"apart",pt:0,px:10,pb:"xs",children:[o(a.Group,{position:"left",children:s&&o(va,{})}),g(a.Group,{position:"right",sx:{button:{minWidth:"40px"}},children:[s&&g(Y,{children:[o(a.Button,{variant:"filled",size:"xs",disabled:!n.views.VIE,onClick:n.views.addAPanelToVIE,leftIcon:o(T.PlaylistAdd,{size:20}),children:"Add a Panel"}),g(a.Group,{spacing:0,sx:dr,children:[o(a.Tooltip,{label:"Filters",children:o(a.ActionIcon,{variant:"default",size:"md",onClick:C,children:o(T.Filter,{size:20})})}),o(a.Tooltip,{label:"Data Settings",children:o(a.ActionIcon,{variant:"default",size:"md",onClick:c,children:o(T.Database,{size:20})})})]}),g(a.Group,{spacing:0,sx:dr,children:[o(a.Tooltip,{label:"Save Changes",children:o(a.ActionIcon,{variant:"default",size:"md",onClick:t,disabled:!l,children:o(T.DeviceFloppy,{size:20,color:"green"})})}),o(a.Tooltip,{label:"Revert Changes",children:o(a.ActionIcon,{variant:"default",size:"md",disabled:!l,onClick:i,children:o(T.Recycle,{size:20,color:"red"})})})]})]}),!u&&g(a.Menu,{width:180,trigger:"hover",children:[o(a.Menu.Target,{children:o(a.ActionIcon,{variant:"default",size:"md",children:o(T.Share,{size:20})})}),g(a.Menu.Dropdown,{children:[o(a.Menu.Item,{icon:o(T.Download,{size:14}),onClick:n.queries.downloadAllData,children:"Download Data"}),o(a.Menu.Item,{icon:o(T.Code,{size:14}),onClick:S,children:"Download Schema"})]})]})]}),o(sa,{opened:h,close:y}),o(Qo,{opened:d,close:f})]})}),Ug="",gr=M.observer(()=>{const{freezeLayout:e}=D.default.useContext(me),[t,n]=D.default.useState(!1),{panel:r}=re();return D.default.useEffect(()=>{e(t)},[t]),!r.description||r.description==="<p><br></p>"?null:g(Y,{children:[o(a.Modal,{opened:t,onClose:()=>n(!1),title:r.title,withCloseButton:!1,children:o(zn.default,{readOnly:!0,value:r.description,onChange:N.default.noop,sx:{border:"none"}})}),o(a.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:o(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:o(T.InfoCircle,{size:20})})})]})}),pr=e=>{const{title:t="Variables",variables:n}=e,r=K.useClipboard(),i=l=>{r.copy(l),It.showNotification({color:"green",message:"Copied to clipboard"})};return g(a.Paper,{withBorder:!0,p:"sm",children:[o(a.Text,{size:"xs",color:"dimmed",mb:"sm",children:t}),o(a.Stack,{style:{maxHeight:"300px"},children:n.map(l=>g(a.Text,{size:"sm",children:[g(a.Code,{color:"teal",children:["// ",l.description]}),o("br",{}),g(a.Code,{onClick:()=>i(l.name),style:{cursor:"pointer"},children:[l.name," : ",l.valueType]})]},l.name))})]})};class ya{constructor(t,n){k(this,"operationId");k(this,"operation");k(this,"operationSchema");k(this,"variables",[]);this.operationManager=t,this.instance=n,Z.makeAutoObservable(this)}get schemaList(){return this.operationManager.getOperationSchemaList()}async configOperation(t,n){const r=await this.operationManager.retrieveTrigger(t),i=this.operationManager.getOperationSchemaList().find(l=>l.id===(r==null?void 0:r.schemaRef));Z.runInAction(()=>{this.operationId=t,this.operation=r,this.operationSchema=i,this.variables=n})}async changeSchema(t){this.operationId&&(await this.operationManager.createOrGetOperation(this.operationId,t),await this.configOperation(this.operationId,this.variables))}}function ba(e){return!!e.operationId}const Ca=M.observer(({model:e,onClick:t})=>{var r;const n=(r=e.operationSchema)==null?void 0:r.displayName;return o(a.Button,{variant:"outline",onClick:t,children:n})}),xa=M.observer(({model:e})=>{const t={operation:e.operation,instance:e.instance,variables:[]};return w.createElement(e.operationSchema.configRender,t)});function wa({model:e}){const t=e.schemaList,n=t.map(i=>({label:i.displayName,value:i.id}));async function r(i){await e.changeSchema(t.find(l=>l.id===i))}return o(a.Select,{label:"Operation",data:n,onChange:r,value:e.operationSchema.id})}const Sa=M.observer(e=>{const[t,{setTrue:n,setFalse:r}]=U.useBoolean(!1),{operationManager:i,operationId:l,instance:s,variables:u}=e,d=U.useCreation(()=>new ya(i,s),[i,s]);return U.useAsyncEffect(async()=>{await d.configOperation(l,u)},[l,d]),ba(d)?g(Y,{children:[o(Ca,{model:d,onClick:n}),o(a.Modal,{opened:t,onClose:r,title:"Operation Settings",closeButtonLabel:"close",children:g(a.Stack,{children:[o(wa,{model:d}),o(xa,{model:d}),o(pr,{title:"Variables",variables:d.variables})]})})]}):null});class _a{constructor(t,n){k(this,"triggerId");k(this,"trigger");k(this,"triggerSchema");k(this,"sampleData");this.triggerManager=t,this.instance=n,Z.makeAutoObservable(this)}get schemaList(){return this.triggerManager.getTriggerSchemaList()}async configTrigger(t,n){const r=await this.triggerManager.retrieveTrigger(t),i=this.triggerManager.getTriggerSchemaList().find(l=>l.id===(r==null?void 0:r.schemaRef));Z.runInAction(()=>{this.triggerId=t,this.trigger=r,this.triggerSchema=i,this.sampleData=n})}async changeSchema(t){this.triggerId&&(await this.triggerManager.createOrGetTrigger(this.triggerId,t),await this.configTrigger(this.triggerId,this.sampleData))}isReady(){return Da(this)}}function Da(e){return!!e.triggerId&&!!e.triggerSchema}function Ia(e,t){return U.useCreation(()=>new _a(e,t),[e,t])}const Aa=M.observer(({model:e,onClick:t})=>{const n=e.triggerSchema.nameRender,r={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return o(a.Button,{variant:"outline",onClick:t,children:w.createElement(n,r)})}),Ma=M.observer(({model:e})=>{const t=e.schemaList,n=t.map(i=>({label:i.displayName,value:i.id}));async function r(i){await e.changeSchema(t.find(l=>l.id===i))}return o(a.Select,{label:"Trigger",data:n,value:e.triggerSchema.id,onChange:r})}),Va=M.observer(({model:e})=>{const t={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return w.createElement(e.triggerSchema.configRender,t)}),Ea=M.observer(e=>{const[t,{setTrue:n,setFalse:r}]=U.useBoolean(!1),i=e.model;return g(Y,{children:[o(a.Modal,{opened:t,onClose:r,title:"Setup Trigger",closeButtonLabel:"close setup",children:g(a.Stack,{children:[o(Ma,{model:i}),o(Va,{model:i}),o(pr,{title:"Payload",variables:i.triggerSchema.payload})]})}),o(Aa,{onClick:n,model:i})]})});class qe{constructor(t,n){this.root=t,this.path=n}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,I.omit(n,t))}async getItem(t){const n=await this.root.getItem(this.path);return t===null?n:I.get(n,t)}async setItem(t,n){if(t===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[t]:n})}return await this.getItem(t)}watchItem(t,n,r){return t===null?this.root.watchItem(this.path,(i,l)=>{n(i,l)},r):this.root.watchItem(this.path,(i,l)=>{const s=I.get(i,t),u=I.get(l,t);s!==u&&n(s,u)},r)}}class Ot{constructor(t,n,r){k(this,"attachmentStorage");this.instance=t,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new qe(t.instanceData,n)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new qe(this.attachmentStorage,t))}async create(t,n){return await this.attachmentStorage.setItem(t,n),this.constructInstance(new qe(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(I.values(t).map(n=>this.constructInstance(new qe(this.attachmentStorage,n.id))))}}class fr{constructor(t){k(this,"rootRef");this.rootRef=Z.observable({current:t})}async deleteItem(t){Z.runInAction(()=>{I.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?Z.toJS(this.rootRef.current):I.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(I.isObject(n))Z.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else Z.runInAction(()=>{I.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return Z.reaction(()=>this.getValueFromRoot(t),(i,l)=>{n(i,l)},{requiresObservable:!0,fireImmediately:I.get(r,"fireImmediately",!1)})}}class Ta{constructor(){k(this,"channels",new Map);k(this,"globalChannel",new Gn.default)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new Gn.default;return this.channels.set(t,r),r}}class $a{constructor(t){k(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const r={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Ta,instanceData:new fr(t.viz.conf)};return this.instances.set(t.id,r),r}}function hr(e,t,n){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new fr({}),colorPalette:{getColor(){return()=>""}},data:t}}const Ra=e=>{const{panel:t,vizManager:n,data:r}=e,i=n.resolveComponent(t.viz.type),l=n.getOrCreateInstance(t),s={...hr(l,r,n),viewport:{width:t.layout.w,height:t.layout.h}},u=i.viewRender;return o(u,{context:s,instance:l,...I.omit(e,["panel","vizManager","data"])})},Fa=e=>{const{vizManager:t,panel:n,panelInfoEditor:r,data:i}=e,l=t.resolveComponent(n.viz.type),s=t.getOrCreateInstance(n),u={...hr(s,i,t),panelInfoEditor:r},d=l.configRender;return o(d,{context:u,instance:s,...I.omit(e,["panel","vizManager","data","panelInfoEditor"])})},mr=(e,t)=>{const n=We.default.bezier(e),r=We.default.bezier(t);return function(i){return i<50?n(i*2/100).hex():r((i-50)*2/100).hex()}},ot=e=>{const t=We.default.bezier(e);return function(n){return t(n/100).hex()}},Oa={type:"interpolation",displayName:"Red / Green",getColor:mr(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},ka={type:"interpolation",displayName:"Yellow / Blue",getColor:mr(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Pa={type:"interpolation",displayName:"Red",getColor:ot(["#fff7f1","darkred"]),name:"red",category:"sequential"},za={type:"interpolation",displayName:"Green",getColor:ot(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ga={type:"interpolation",displayName:"Blue",getColor:ot(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Na={type:"interpolation",displayName:"Orange",getColor:ot(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},La="5.6.0";class qa{constructor(t){k(this,"staticColors",new Map);k(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class Ba{constructor(){k(this,"plugins",new Map);k(this,"vizComponents",new Map);k(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class ja{constructor(){k(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const r=this.migrations.filter(s=>s.version>t.from&&s.version<=t.to),i=I.orderBy(r,"version","asc");if(((l=I.last(i))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return i.reduce((s,u)=>u.handler(s),n)}}class ve extends ja{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,r=>({version:t,...n(r)}))}async migrate({instanceData:t}){const n=await t.getItem(null),r=I.get(n,"version",0),i=this.run({from:r,to:this.VERSION},n);await t.setItem(null,i)}async needMigration({instanceData:t}){const n=await t.getItem(null);return I.get(n,"version",0)<this.VERSION}}const kt={content:""},q=(e,t)=>{const[n,{setFalse:r}]=U.useBoolean(!0),[i,l]=w.useState();w.useEffect(()=>(e.getItem(t).then(u=>{l(u),r()}),e.watchItem(t,u=>{l(u)})));const s=w.useCallback(async u=>{await e.setItem(t,u),l(u)},[e,t]);return{loading:n,value:i,set:s}};function vr(e){const t=w.useRef(null);return w.useEffect(()=>{var n,r,i;e&&((i=(r=(n=t.current)==null?void 0:n.editor)==null?void 0:r.clipboard)==null||i.dangerouslyPasteHTML(e))},[e]),t}function Wa({context:e}){const{panel:t}=re(),{value:n}=q(e.instanceData,"config"),r=n==null?void 0:n.content,i=vr(r);return n!=null&&n.content?o(Dt.RichTextEditor,{id:t.id,ref:i,readOnly:!0,value:n.content,onChange:I.noop,sx:{border:"none",".ql-editor":{padding:0,"h1, h2, h3, h4, h5, p, ul, ol":{"&:last-child":{marginBottom:0}}}}}):null}function Ua({context:e}){const{value:t,set:n}=q(e.instanceData,"config"),r=w.useMemo(()=>I.defaults({},t,kt),[t]),{control:i,handleSubmit:l,watch:s,getValues:u}=x.useForm({defaultValues:r});s("content");const d=u(),p=w.useMemo(()=>!I.isEqual(d,t),[d,t]),c=vr(t==null?void 0:t.content);return o(a.Stack,{mt:"md",spacing:"xs",children:g("form",{onSubmit:l(n),children:[g(a.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[o(a.Text,{children:"Content"}),o(a.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!p,children:o(T.DeviceFloppy,{size:20})})]}),o(x.Controller,{name:"content",control:i,render:({field:f})=>o(zn.default,{ref:c,sx:{flex:1},...I.omit(f,"ref")})})]})})}class Ya extends ve{constructor(){super(...arguments);k(this,"VERSION",1)}fixMalformedConfig(n){return I.defaults({},n,kt)}configVersions(){this.version(1,n=>({version:1,config:this.fixMalformedConfig(n)}))}}const Qa={displayName:"RichText",migrator:new Ya,name:"richText",viewRender:Wa,configRender:Ua,createConfig:()=>kt},Pt={align:"center",template:"The variable ${value} is defined in Variables section",variables:[{name:"value",size:"20px",weight:"bold",color:{type:"static",staticColor:"blue"},data_field:"",aggregation:{type:"none",config:{}},formatter:{output:"number",mantissa:0}}]};function Ha(e){if("variables"in e)return e;const{align:t,size:n,weight:r,color:i,content:{prefix:l="",data_field:s="value",formatter:u={output:"number",mantissa:0},postfix:d=""}={}}=e;return{align:t,template:`${l} \${value} ${d}`,variables:[{name:"value",data_field:s,aggregation:{type:"none",config:{}},formatter:u,color:i,weight:r,size:n}]}}class Xa extends ve{constructor(){super(...arguments);k(this,"VERSION",1)}configVersions(){this.version(1,n=>({config:Ha(n)}))}}const zt=w.forwardRef(function({value:t,onChange:n,...r},i){return o(a.TextInput,{ref:i,value:t,onChange:n,...r})}),Qe={mantissa:0,output:"number",trimMantissa:!1,average:!1};function Ja({value:e,onChange:t},n){const r=u=>{t({...e,output:u})},i=u=>{const d=u===0?!1:e.trimMantissa;t({...e,mantissa:u,trimMantissa:d})},l=u=>{t({...e,trimMantissa:u.currentTarget.checked})},s=u=>{t({...e,average:u.currentTarget.checked})};return g(a.Stack,{ref:n,children:[g(a.Group,{grow:!0,children:[o(a.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:r,sx:{flexGrow:1}}),o(a.Switch,{label:g(a.Stack,{spacing:0,children:[o(a.Text,{children:"Average"}),o(a.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:s,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),g(a.Group,{grow:!0,children:[o(a.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:i}),o(a.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:l,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),g(a.Stack,{spacing:0,children:[o(a.Text,{weight:"bold",children:"Preview"}),o(Le,{children:g(a.Group,{position:"apart",children:[g(a.Text,{size:12,color:"gray",children:["123456789 ",o(T.ArrowRight,{size:9})," ",de.default(123456789).format(e)]}),g(a.Text,{size:12,color:"gray",children:["1234 ",o(T.ArrowRight,{size:9})," ",de.default(1234).format(e)]}),g(a.Text,{size:12,color:"gray",children:["0.1234 ",o(T.ArrowRight,{size:9})," ",de.default(.1234).format(e)]})]})})]})]})}const Gt=D.default.forwardRef(Ja);function at(){return{name:K.randomId(),size:"20px",weight:"bold",color:{type:"static",staticColor:"blue"},data_field:"",aggregation:{type:"none",config:{}},formatter:Qe}}const Ka=[{label:"None",value:"none"},{label:"Sum",value:"sum"},{label:"Mean",value:"mean"},{label:"Median",value:"median"},{label:"Max",value:"max"},{label:"Min",value:"min"},{label:"Quantile(99%, 95%, ...)",value:"quantile"}];function Za({label:e,value:t,onChange:n},r){w.useEffect(()=>{typeof t=="string"&&(console.log(t),n({type:t,config:{}}))},[t,n]);const i=s=>{n(s==="quantile"?{type:"quantile",config:{p:.99}}:{type:s,config:{}})},l=s=>{n({type:"quantile",config:{p:s}})};return g(a.Group,{grow:!0,noWrap:!0,pt:"sm",children:[o(a.Select,{ref:r,label:e,data:Ka,value:t.type,onChange:i}),t.type==="quantile"&&o(a.NumberInput,{label:"p",value:t.config.p,onChange:l,precision:2,min:.05,step:.05,max:1})]})}const el=D.default.forwardRef(Za);function tl({label:e,required:t,value:n,onChange:r,data:i,clearable:l=!1,sx:s,...u},d){const p=D.default.useMemo(()=>{if(!Array.isArray(i)||i.length===0)return[];const f=Object.keys(i[0]).map(h=>({label:h,value:h}));return l?f.concat([{label:"unset",value:""}]):f},[i]);return o(a.Select,{ref:d,label:e,data:p,value:n,onChange:r,required:t,sx:s,...u})}const H=D.default.forwardRef(tl);function nl({label:e,value:t,onChange:n},r){const[i,l]=D.default.useState(Array.isArray(t)?[...t]:[]),s=D.default.useCallback(()=>{l(h=>[...h,""])},[l]),u=D.default.useCallback(h=>{l(v=>(v.splice(h,1),[...v]))},[l]),d=D.default.useMemo(()=>!N.default.isEqual(i,t),[i,t]),p=()=>{n(i.map(h=>h.toString()))},c=a.useMantineTheme(),f=D.default.useMemo(()=>Object.entries(c.colors).map(([h,v])=>v[6]),[c]);return g(Y,{children:[g(a.Group,{position:"left",ref:r,children:[o(a.Text,{children:e}),o(a.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:p,children:o(T.DeviceFloppy,{size:20})})]}),g(a.Group,{children:[i.map((h,v)=>o(a.ColorInput,{value:h,onChange:C=>{l(y=>(y.splice(v,1,C),[...y]))},swatches:f,rightSection:o(a.ActionIcon,{onClick:()=>u(v),color:"red",children:o(T.Trash,{size:14})}),sx:{width:"45%"}})),o(a.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:o(T.PlaylistAdd,{size:20})})]})]})}const rl=D.default.forwardRef(nl);function il({value:e,onChange:t},n){const{colorManager:r}=w.useContext(De),i=D.default.useMemo(()=>r.getStaticColors().map(u=>({label:u.name,group:u.category,value:u.value})),[r]),l=D.default.useMemo(()=>i.some(s=>s.value===e),[e,i]);return g(a.Group,{position:"apart",spacing:4,ref:n,children:[o(a.TextInput,{placeholder:"Set any color",value:l?"":e,onChange:s=>t(s.currentTarget.value),rightSection:o(a.ColorSwatch,{color:l?"transparent":e,radius:4}),variant:l?"filled":"default",sx:{maxWidth:"46%",flexGrow:1}}),o(a.Text,{sx:{flexGrow:0},children:"or"}),o(a.Select,{data:i,value:e,onChange:t,variant:l?"default":"filled",placeholder:"Pick a theme color",icon:o(a.ColorSwatch,{color:l?e:"transparent",radius:4}),sx:{maxWidth:"46%",flexGrow:1}})]})}const Te=D.default.forwardRef(il),lt=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function ol({label:e,value:t,onChange:n},r){var s,u;const[i,l]=D.default.useState((u=(s=lt.find(d=>d.label===t))==null?void 0:s.value)!=null?u:lt[0].value);return D.default.useEffect(()=>{const d=lt.find(p=>p.value===i);d&&n(d.label)},[i]),g(a.Stack,{spacing:0,mt:"sm",mb:"lg",children:[o(a.Text,{size:"sm",children:e}),o(a.Slider,{label:null,marks:lt,value:i,onChange:l,step:25,placeholder:"Pick a font size",ref:r})]})}const al=D.default.forwardRef(ol);function ll({label:e,value:t,onChange:n},r){const[i,l]=D.default.useState(Array.isArray(t)?[...t]:[]),s=D.default.useCallback(()=>{l(c=>[...c,""])},[l]),u=D.default.useCallback(c=>{l(f=>(f.splice(c,1),[...f]))},[l]),d=D.default.useMemo(()=>!N.default.isEqual(i,t),[i,t]),p=()=>{n(i.map(c=>c.toString()))};return g(Y,{children:[g(a.Group,{position:"left",ref:r,children:[o(a.Text,{children:e}),o(a.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:p,children:o(T.DeviceFloppy,{size:20})})]}),g(a.Group,{children:[i.map((c,f)=>o(a.TextInput,{value:c,onChange:h=>{const v=h.currentTarget.value;l(C=>(C.splice(f,1,v),[...C]))},rightSection:o(a.ActionIcon,{onClick:()=>u(f),color:"red",children:o(T.Trash,{size:14})}),sx:{width:"45%"}})),o(a.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:o(T.PlaylistAdd,{size:20})})]})]})}const sl=D.default.forwardRef(ll),ul=D.default.forwardRef(function({value:t,onChange:n},r){const i=t.color.type,l=(s,u)=>{const d=N.default.cloneDeep(t);N.default.set(d,s,u),n(d)};return g(Y,{children:[o(a.Divider,{my:"xs",label:"Typography",labelPosition:"center"}),o(a.Stack,{children:o(a.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},value:t.size,onChange:s=>l("size",s.currentTarget.value)})}),o(a.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:o(al,{label:"Font Weight",value:t.weight,onChange:s=>l("weight",s)})}),o(a.Divider,{my:"xs",label:"Style",labelPosition:"center"}),g(a.Stack,{children:[o(a.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:t.color.type,onChange:s=>l("color.type",s)}),i==="static"&&o(Te,{value:t.color.staticColor,onChange:s=>l("color.staticColor",s)}),i==="continuous"&&g(Y,{children:[o(sl,{label:"Value Range",value:t.color.valueRange,onChange:s=>l("color.valueRange",s)}),o(rl,{label:"Color Range",value:t.color.colorRange,onChange:s=>l("color.colorRange",s)})]})]})]})}),st=D.default.forwardRef(function({value:t,onChange:n,data:r,withStyle:i=!0},l){const s=(u,d)=>{const p=N.default.cloneDeep(t);N.default.set(p,u,d),n(p)};return g(a.Box,{px:"sm",py:"md",ref:l,children:[o(a.Text,{weight:"bold",pb:0,children:t.name}),o(a.Divider,{my:"xs",label:"Data",labelPosition:"center"}),g(a.Group,{grow:!0,noWrap:!0,children:[o(a.TextInput,{label:"Name",required:!0,value:t.name,onChange:u=>s("name",u.currentTarget.value)}),o(H,{label:"Data Field",required:!0,data:r,value:t.data_field,onChange:u=>s("data_field",u)})]}),o(el,{label:"Aggregation",value:t.aggregation,onChange:u=>s("aggregation",u)}),o(a.Divider,{my:"xs",label:"Format",labelPosition:"center"}),o(Gt,{value:t.formatter,onChange:u=>s("formatter",u)}),i&&o(ul,{value:t,onChange:n})]})});function dl(e){const t=Array.from(e).sort((r,i)=>r-i),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}function Nt(e,t,n){var i,l,s,u;const r=e.map(d=>d[t]);switch(n.type){case"sum":return N.default.sum(r);case"mean":return N.default.mean(r);case"median":return dl(r);case"max":return(i=N.default.max(r))!=null?i:0;case"min":return(l=N.default.min(r))!=null?l:0;case"quantile":return(s=co.quantile(r,n.config.p))!=null?s:0;default:return(u=e[0])==null?void 0:u[t]}}var yr=function(){},He=function(){};process.env.NODE_ENV!=="production"&&(yr=function(e,t){!e&&typeof console<"u"&&console.warn(t)},He=function(e,t){if(!e)throw new Error(t)});const cl=(e,t,n)=>Math.min(Math.max(n,e),t),br=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r},Lt=(e,t,n)=>-n*e+n*t+e,Cr=(e,t)=>n=>Math.max(Math.min(n,t),e),Xe=e=>e%1?Number(e.toFixed(5)):e,ut=/(-)?([\d]*\.?[\d])+/g,qt=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,gl=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function Je(e){return typeof e=="string"}const dt={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},xr=Object.assign(Object.assign({},dt),{transform:Cr(0,1)});Object.assign(Object.assign({},dt),{default:1});const Ke=(e=>({test:t=>Je(t)&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}))("%");Object.assign(Object.assign({},Ke),{parse:e=>Ke.parse(e)/100,transform:e=>Ke.transform(e*100)});const Bt=(e,t)=>n=>Boolean(Je(n)&&gl.test(n)&&n.startsWith(e)||t&&Object.prototype.hasOwnProperty.call(n,t)),wr=(e,t,n)=>r=>{if(!Je(r))return r;const[i,l,s,u]=r.match(ut);return{[e]:parseFloat(i),[t]:parseFloat(l),[n]:parseFloat(s),alpha:u!==void 0?parseFloat(u):1}},Ge={test:Bt("hsl","hue"),parse:wr("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+Ke.transform(Xe(t))+", "+Ke.transform(Xe(n))+", "+Xe(xr.transform(r))+")"},pl=Cr(0,255),jt=Object.assign(Object.assign({},dt),{transform:e=>Math.round(pl(e))}),$e={test:Bt("rgb","red"),parse:wr("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+jt.transform(e)+", "+jt.transform(t)+", "+jt.transform(n)+", "+Xe(xr.transform(r))+")"};function fl(e){let t="",n="",r="",i="";return e.length>5?(t=e.substr(1,2),n=e.substr(3,2),r=e.substr(5,2),i=e.substr(7,2)):(t=e.substr(1,1),n=e.substr(2,1),r=e.substr(3,1),i=e.substr(4,1),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const Wt={test:Bt("#"),parse:fl,transform:$e.transform},ct={test:e=>$e.test(e)||Wt.test(e)||Ge.test(e),parse:e=>$e.test(e)?$e.parse(e):Ge.test(e)?Ge.parse(e):Wt.parse(e),transform:e=>Je(e)?e:e.hasOwnProperty("red")?$e.transform(e):Ge.transform(e)},Sr="${c}",_r="${n}";function hl(e){var t,n,r,i;return isNaN(e)&&Je(e)&&((n=(t=e.match(ut))===null||t===void 0?void 0:t.length)!==null&&n!==void 0?n:0)+((i=(r=e.match(qt))===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0)>0}function Dr(e){typeof e=="number"&&(e=`${e}`);const t=[];let n=0;const r=e.match(qt);r&&(n=r.length,e=e.replace(qt,Sr),t.push(...r.map(ct.parse)));const i=e.match(ut);return i&&(e=e.replace(ut,_r),t.push(...i.map(dt.parse))),{values:t,numColors:n,tokenised:e}}function Ir(e){return Dr(e).values}function Ar(e){const{values:t,numColors:n,tokenised:r}=Dr(e),i=t.length;return l=>{let s=r;for(let u=0;u<i;u++)s=s.replace(u<n?Sr:_r,u<n?ct.transform(l[u]):Xe(l[u]));return s}}const ml=e=>typeof e=="number"?0:e;function vl(e){const t=Ir(e);return Ar(e)(t.map(ml))}const Mr={test:hl,parse:Ir,createTransformer:Ar,getAnimatableNone:vl};function Ut(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Vr({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,l=0,s=0;if(!t)i=l=s=n;else{const u=n<.5?n*(1+t):n+t-n*t,d=2*n-u;i=Ut(d,u,e+1/3),l=Ut(d,u,e),s=Ut(d,u,e-1/3)}return{red:Math.round(i*255),green:Math.round(l*255),blue:Math.round(s*255),alpha:r}}const yl=(e,t,n)=>{const r=e*e,i=t*t;return Math.sqrt(Math.max(0,n*(i-r)+r))},bl=[Wt,$e,Ge],Er=e=>bl.find(t=>t.test(e)),Tr=e=>`'${e}' is not an animatable color. Use the equivalent color code instead.`,$r=(e,t)=>{let n=Er(e),r=Er(t);He(!!n,Tr(e)),He(!!r,Tr(t));let i=n.parse(e),l=r.parse(t);n===Ge&&(i=Vr(i),n=$e),r===Ge&&(l=Vr(l),r=$e);const s=Object.assign({},i);return u=>{for(const d in s)d!=="alpha"&&(s[d]=yl(i[d],l[d],u));return s.alpha=Lt(i.alpha,l.alpha,u),n.transform(s)}},Cl=e=>typeof e=="number",xl=(e,t)=>n=>t(e(n)),Rr=(...e)=>e.reduce(xl);function Fr(e,t){return Cl(e)?n=>Lt(e,t,n):ct.test(e)?$r(e,t):Pr(e,t)}const Or=(e,t)=>{const n=[...e],r=n.length,i=e.map((l,s)=>Fr(l,t[s]));return l=>{for(let s=0;s<r;s++)n[s]=i[s](l);return n}},wl=(e,t)=>{const n=Object.assign(Object.assign({},e),t),r={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Fr(e[i],t[i]));return i=>{for(const l in r)n[l]=r[l](i);return n}};function kr(e){const t=Mr.parse(e),n=t.length;let r=0,i=0,l=0;for(let s=0;s<n;s++)r||typeof t[s]=="number"?r++:t[s].hue!==void 0?l++:i++;return{parsed:t,numNumbers:r,numRGB:i,numHSL:l}}const Pr=(e,t)=>{const n=Mr.createTransformer(t),r=kr(e),i=kr(t);return r.numHSL===i.numHSL&&r.numRGB===i.numRGB&&r.numNumbers>=i.numNumbers?Rr(Or(r.parsed,i.parsed),n):(yr(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),s=>`${s>0?t:e}`)},Sl=(e,t)=>n=>Lt(e,t,n);function _l(e){if(typeof e=="number")return Sl;if(typeof e=="string")return ct.test(e)?$r:Pr;if(Array.isArray(e))return Or;if(typeof e=="object")return wl}function Dl(e,t,n){const r=[],i=n||_l(e[0]),l=e.length-1;for(let s=0;s<l;s++){let u=i(e[s],e[s+1]);if(t){const d=Array.isArray(t)?t[s]:t;u=Rr(d,u)}r.push(u)}return r}function Il([e,t],[n]){return r=>n(br(e,t,r))}function Al(e,t){const n=e.length,r=n-1;return i=>{let l=0,s=!1;if(i<=e[0]?s=!0:i>=e[r]&&(l=r-1,s=!0),!s){let d=1;for(;d<n&&!(e[d]>i||d===r);d++);l=d-1}const u=br(e[l],e[l+1],i);return t[l](u)}}function Ml(e,t,{clamp:n=!0,ease:r,mixer:i}={}){const l=e.length;He(l===t.length,"Both input and output ranges must be the same length"),He(!r||!Array.isArray(r)||r.length===l-1,"Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values."),e[0]>e[l-1]&&(e=[].concat(e),t=[].concat(t),e.reverse(),t.reverse());const s=Dl(t,r,i),u=l===2?Il(e,s):Al(e,s);return n?d=>u(cl(e[0],e[l-1],d)):u}class Vl{constructor({valueRange:t,colorRange:n}){k(this,"mapper");this.mapper=Ml(t,n)}getColor(t){return this.mapper(t)}}function El(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Yt({data_field:e,aggregation:t},n){return Nt(n,e,t)}function Ze({formatter:e},t){return["string","number"].includes(typeof t)?de.default(t).format(e):El(t)}function Tl(e,t){return e.type==="static"?e.staticColor:e.type==="continuous"?new Vl(e).getColor(t):"black"}function $l(e,t){const n={};return e.forEach(r=>{const{name:i,color:l,data_field:s,aggregation:u,size:d,weight:p}=r,c=Nt(t,s,u),f=Ze(r,c);n[i]=o(a.Text,{sx:{fontSize:d,display:"inline"},color:Tl(l,c),weight:p,children:f})}),n}function Rl(e){return e.split(" ").map(t=>g(Y,{children:[t,"\xA0"]}))}function Fl(e){const n=e.replaceAll("<br />","<br/>").replaceAll(`
|
|
41
41
|
`,"<br/>").split("<br/>");return n.map((i,l)=>{const s=[Rl(i)];return l!==n.length-1&&s.push(o("br",{})),s}).flat().filter(i=>i!==void 0)}function Qt(e){return Fl(e)}function Ht(e,t,n){const r=$l(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map(l=>{var p;const s=i.exec(l);if(!s)return Qt(l);const u=r[s[1]];if(!u)return Qt(l);const d=(p=s[2])!=null?p:"";return g(Y,{children:[u,Qt(d)]})})}function Ol(e,t){const n={};return e.forEach(r=>{const{name:i,data_field:l,aggregation:s}=r,u=Nt(t,l,s);n[i]=Ze(r,u)}),n}function zr(e,t,n){const r=Ol(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map(l=>{var p;const s=i.exec(l);if(!s)return l;const u=r[s[1]];if(!u)return l;const d=(p=s[2])!=null?p:"";return`${u}${d}`}).join("")}function kl({context:e}){const{value:t=Pt}=q(e.instanceData,"config"),{template:n,variables:r,align:i}=t,l=w.useMemo(()=>Ht(n,r,e.data),[n,r,e.data]);return o(a.Text,{align:i,children:Object.values(l).map(s=>s)})}function Pl({control:e,index:t,remove:n,data:r}){return g(a.Stack,{my:"sm",p:0,sx:{border:"1px solid #eee",borderTopColor:"#333",borderTopWidth:2,position:"relative"},children:[o(x.Controller,{name:`variables.${t}`,control:e,render:({field:i})=>o(st,{data:r,...i})}),o(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>n(t),sx:{position:"absolute",top:15,right:5},children:o(T.Trash,{size:16})})]},t)}function zl({control:e,watch:t,data:n}){const{fields:r,append:i,remove:l}=x.useFieldArray({control:e,name:"variables"}),s=t("variables"),u=r.map((p,c)=>({...p,...s[c]})),d=()=>i(at());return g(a.Stack,{children:[u.map((p,c)=>o(Pl,{control:e,index:c,remove:l,data:n},p.name)),o(a.Group,{position:"center",mt:"xs",children:o(a.Button,{onClick:d,children:"Add a Variable"})})]})}function Gl({context:e}){const t=e.data||[],{value:n,set:r}=q(e.instanceData,"config"),i=D.default.useMemo(()=>{const{align:h,template:v="",variables:C=[]}=I.defaultsDeep({},n,Pt);return{variables:C,template:v,align:h}},[n]),{control:l,handleSubmit:s,watch:u,getValues:d,reset:p}=x.useForm({defaultValues:i});D.default.useEffect(()=>{p(i)},[i]),u(["variables","template"]);const c=d(),f=D.default.useMemo(()=>!N.default.isEqual(c,n),[c,n]);return o(a.Stack,{mt:"md",spacing:"xs",children:g("form",{onSubmit:s(r),children:[g(a.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[o(a.Text,{weight:500,children:"Stats Configurations"}),o(a.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!f,children:o(T.DeviceFloppy,{size:20})})]}),o(x.Controller,{name:"template",control:l,render:({field:h})=>o(zt,{label:"Template",py:"md",sx:{flexGrow:1},...h})}),o(a.Text,{pb:"sm",pt:"md",size:"sm",children:"Variables"}),o(zl,{control:l,watch:u,data:t})]})})}const Nl={createConfig(){return{version:1,config:Pt}},displayName:"Stats",migrator:new Xa,name:"stats",viewRender:kl,configRender:Gl};var Re=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e))(Re||{});const gt={columns:[],fontSize:"1rem",highlightOnHover:!1,horizontalSpacing:"1em",id_field:"",striped:!1,use_raw_columns:!1,verticalSpacing:"1em"};/**
|
|
42
42
|
* react-table
|
|
43
43
|
*
|