@devtable/dashboard 10.44.0 → 10.44.1
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 +2 -2
- package/dist/dashboard.umd.js +2 -2
- package/dist/stats.html +1 -1
- package/package.json +1 -1
package/dist/dashboard.es.js
CHANGED
|
@@ -1286,7 +1286,7 @@ class ga {
|
|
|
1286
1286
|
}), this.instanceRegistry.clear(), this.factoryRegistry.clear();
|
|
1287
1287
|
}
|
|
1288
1288
|
}
|
|
1289
|
-
const wc = "10.44.
|
|
1289
|
+
const wc = "10.44.1", $m = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1290
1290
|
__proto__: null,
|
|
1291
1291
|
version: wc
|
|
1292
1292
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
@@ -23581,7 +23581,7 @@ const RD = b.model("FilterDateRangeConfigMeta", {
|
|
|
23581
23581
|
state: n,
|
|
23582
23582
|
error: r
|
|
23583
23583
|
} = Ae(e).content.getDataStuffByID(e.options_query_id);
|
|
23584
|
-
return n === "idle" ? t : [];
|
|
23584
|
+
return n === "idle" ? Array.isArray(t) ? t : [] : [];
|
|
23585
23585
|
}
|
|
23586
23586
|
})).actions((e) => ({
|
|
23587
23587
|
setRequired(t) {
|
package/dist/dashboard.umd.js
CHANGED
|
@@ -51,7 +51,7 @@ Check the top-level render call using <`+V+">.")}return z}}function Ou(S,z){{if(
|
|
|
51
51
|
${tc.map(nc).join("")}
|
|
52
52
|
</tbody>
|
|
53
53
|
</table>
|
|
54
|
-
`;function xr(e,t){const n=Object.keys(t),r=Object.values(t);try{return new Function(...n,`return \`${e}\`;`)(...r)}catch(a){throw n.length===0&&e.includes("$")?new Error("[formatSQL] insufficient payload"):a}}function wr(e,t){try{return xr(e,t)}catch(n){return console.error(n),n.message}}function ic({sql:e,pre_process:t}){if(!t.trim())return e;try{return new Function(`return ${t}`)()({sql:e},At)}catch(n){return console.error(n),e}}function ac(e,t,n){if(!e.trim())return t;try{return new Function(`return ${e}`)()(t,At,n)}catch(r){return console.error(r),t}}function sc(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const a=t[r];if(a!="authentication"&&e[a])n.push(t[r]+"="+(typeof e[a]=="object"?JSON.stringify(e[a]):e[a]));else{const o=Object.keys(e[a]).sort();for(let l=0;l<o.length;l++){const u=o[l];u!="sign"&&e[a][u]&&n.push(o[l]+"="+(typeof e[a][u]=="object"?JSON.stringify(e[a][u]):e[a][u]))}}}return n.sort().join("&")}function oc(e,t){let n=sc(e);return n+="&key="+t,Xu.MD5(n).toString().toUpperCase()}class is{constructor(){this.type="default_api_client",this.baseURL="http://localhost:31200",this.app_id="",this.app_secret=""}getAuthentication(t){if(!this.app_id||!this.app_secret)return;const n=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:n,sign:oc({app_id:this.app_id,nonce_str:n,...t},this.app_secret)}}getRequest(t,n){return(r,a,o,l)=>{const u=this.buildHeader(o),c=this.buildAxiosConfig(t,r,a,o,u,n);return pt(c).then(d=>l?d:d.data).catch(d=>Promise.reject(d))}}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}buildAxiosConfig(t,n,r,a,o,l){const u={baseURL:this.baseURL,method:t,url:n,params:t==="GET"?r:a.params,headers:o,signal:l};return["POST","PUT"].includes(t)&&(u.data=a.string?JSON.stringify(r):r,u.data.authentication=this.getAuthentication(u.data)),u}buildHeader(t){const n=window.localStorage.getItem("token");return{"X-Requested-With":"XMLHttpRequest","Content-Type":t.string?"application/x-www-form-urlencoded":"application/json",authorization:n?`bearer ${n}`:"",...t.headers}}}class lc{constructor(t){this.implementation=t}getRequest(t,n){return this.implementation.getRequest(t,n)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}class as extends is{constructor(){super(...arguments);q(this,"makeQueryENV",null)}query(n){return async(r,a={})=>{var o;return r.env||(r.env=((o=this.makeQueryENV)==null?void 0:o.call(this))??{error:"failed to run makeQueryENV"}),this.post(n)("/query",r,a)}}httpDataSourceQuery(n){return async(r,a={})=>{var o;return r.env||(r.env=((o=this.makeQueryENV)==null?void 0:o.call(this))??{error:"failed to run makeQueryENV"}),this.getRequest("POST",n)("/query",r,a,!0)}}structure(n){return async(r,a={})=>this.post(n)("/query/structure",r,a)}}class ss{constructor(t){this.implementation=t}query(t){return this.implementation.query(t)}httpDataSourceQuery(t){return this.implementation.httpDataSourceQuery(t)}structure(t){return this.implementation.structure(t)}getRequest(t,n){return this.implementation.getRequest(t,n)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}const Nt=new as;function Cr(e){Nt.baseURL!==e.apiBaseURL&&(Nt.baseURL=e.apiBaseURL),e.app_id&&(Nt.app_id=e.app_id),e.app_secret&&(Nt.app_secret=e.app_secret),e.makeQueryENV&&(Nt.makeQueryENV=e.makeQueryENV)}const os=new ss(Nt),at=os;function ls(){return{filters:{},context:{}}}function Sr(e){const t=ls();if(!e)return ls();const{filters:n=t.filters,context:r=t.context}=e;return{filters:n,context:r}}async function uc({query:e,name:t,payload:n,additionals:r},a){if(!e.sql)return[];const{type:o,key:l,sql:u,pre_process:c,post_process:d}=e,f=xr(u,n),h=ic({sql:f,pre_process:c});let g=await at.query(a)({type:o,key:l,query:h,...r},{params:{name:t}});return g=ac(d,g,Sr(n)),g}async function cc({type:e,key:t,configString:n,name:r,additionals:a},o){try{return await at.httpDataSourceQuery(o)({type:e,key:t,query:n,...a},{params:{name:r}})}catch(l){if(pt.isCancel(l))throw l;return console.error(l),l}}async function _r(){try{return(await at.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function us(){try{return(await at.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class cs{constructor(t){q(this,"rootRef");this.rootRef=te.observable({current:t})}async deleteItem(t){te.runInAction(()=>{x.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?te.toJS(this.rootRef.current):x.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(x.isObject(n))te.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else te.runInAction(()=>{x.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return te.reaction(()=>this.getValueFromRoot(t),(a,o)=>{n(a,o)},{requiresObservable:!0,fireImmediately:x.get(r,"fireImmediately",!1)})}}class dc{constructor(){q(this,"channels",new Map);q(this,"globalChannel",new Va)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new Va;return this.channels.set(t,r),r}}class pc{constructor(t){q(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 dc,instanceData:new cs(t.viz.conf)};return this.instances.set(t.id,r),r}}function ds(e,t,n,r){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new cs({}),colorPalette:{getColor(){return()=>""}},data:t,variables:r}}const hc=e=>{const{panel:t,vizManager:n,data:r,variables:a}=e,o=n.resolveComponent(t.viz.type),l=n.getOrCreateInstance(t),u={...ds(l,r,n,a),viewport:{width:t.layout.w,height:t.layout.h}},c=o.viewRender;return i(c,{context:u,instance:l,...x.omit(e,["panel","vizManager","data"])})},fc=e=>{const{vizManager:t,panel:n,data:r,variables:a}=e,o=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),u={...ds(l,r,t,a)},c=o.configRender;return i(c,{context:u,instance:l,...x.omit(e,["panel","vizManager","data"])})},ps=(e,t)=>{const n=ht.bezier(e),r=ht.bezier(t);return function(a){return a<50?n(a*2/100).hex():r((a-50)*2/100).hex()}},Mn=e=>{const t=ht.bezier(e);return function(n){return t(n/100).hex()}},gc={type:"interpolation",displayName:"Red / Green",getColor:ps(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},mc={type:"interpolation",displayName:"Yellow / Blue",getColor:ps(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},yc={type:"interpolation",displayName:"Red",getColor:Mn(["#fff7f1","darkred"]),name:"red",category:"sequential"},bc={type:"interpolation",displayName:"Green",getColor:Mn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},vc={type:"interpolation",displayName:"Blue",getColor:Mn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},xc={type:"interpolation",displayName:"Orange",getColor:Mn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class wc{constructor(t){q(this,"symbol");this.symbol=Symbol(t)}}function ft(e){return new wc(e)}class kr{constructor(){q(this,"parent");q(this,"factoryRegistry",new Map);q(this,"instanceRegistry",new Map)}createScoped(){const t=new kr;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const r=n(this);return this.instanceRegistry.set(t.symbol,r),r}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=x.get(t,"dispose");x.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const hs="10.44.0",Cc=Object.freeze(Object.defineProperty({__proto__:null,version:hs},Symbol.toStringTag,{value:"Module"}));class Sc{constructor(t){q(this,"staticColors",new Map);q(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 _c{constructor(){q(this,"plugins",new Map);q(this,"vizComponents",new Map);q(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 kc{constructor(){q(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,r){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 a=this.migrations.filter(u=>u.version>t.from&&u.version<=t.to),o=x.orderBy(a,"version","asc");if(((l=x.last(o))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((u,c)=>c.handler(u,r),n)}}class ge extends kc{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(r,a)=>({version:t,...n(r,a)}))}async migrate({configData:t,panelModel:n}){const r=await t.getItem(null),a=x.get(r,"version",0),o=this.run({from:a,to:this.VERSION},r,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return x.get(n,"version",0)<this.VERSION}}const R=(e,t)=>{const[n,{setFalse:r}]=Q.useBoolean(!0),[a,o]=m.useState();m.useEffect(()=>(e.getItem(t).then(u=>{o(u),r()}),e.watchItem(t,u=>{o(u)})));const l=m.useCallback(async u=>{await e.setItem(t,u),o(u)},[e,t]);return{loading:n,value:a,set:l}},Oe={top:16,right:16,bottom:16,left:16},tt=e=>Math.max(0,e-Oe.left-Oe.right),nt=e=>Math.max(0,e-Oe.top-Oe.bottom),on=(e,t)=>({width:tt(e),height:nt(t)}),Be=({width:e,height:t,children:n})=>i(s.Box,{pt:Oe.top,pr:Oe.right,pb:Oe.bottom,pl:Oe.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n});function P(e){const[t,n]=e.split(".");return{queryID:t,columnKey:n}}function Tc(e){return e.includes(".")?P(e):{queryID:"",columnKey:e}}function gt(e,t){var a;const{queryID:n,columnKey:r}=P(t);return n?r?((a=e[n])==null?void 0:a.map(o=>o[r]))??[]:e[n]:[]}function ln(e,t){const{queryID:n}=P(t);return n?e[n]:[]}function Dc(e){return Object.values(e)[0]}function An(e,t){const{queryID:n,columnKey:r}=P(t);return e[r]}const Tr={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};ie.use([F.GridComponent,F.VisualMapComponent,F.LegendComponent,F.TooltipComponent,ze.CanvasRenderer]);function Ic({context:e}){const{value:t}=R(e.instanceData,"config"),n=e.data,{width:r,height:a}=e.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:u,xAxis3D:c,yAxis3D:d,zAxis3D:f}=x.defaults({},t,Tr),h=m.useMemo(()=>ln(n,o),[n,o]),{x:g,y,z:C}=m.useMemo(()=>({x:P(o),y:P(l),z:P(u)}),[o,l,u]),{min:w,max:_}=m.useMemo(()=>{const M=x.minBy(h,G=>G[C.columnKey]),O=x.maxBy(h,G=>G[C.columnKey]);return{min:x.get(M,C.columnKey),max:x.get(O,C.columnKey)}},[h,C]),D={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:w,max:_,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:c,yAxis3D:d,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(M=>[M[g.columnKey],M[y.columnKey],M[C.columnKey]])}]};return t?i(Be,{width:r,height:a,children:i(Ae,{echarts:ie,option:D,style:on(r,a),notMerge:!0,theme:"merico-light"})}):null}const fs=m.createContext(null),Dr=fs.Provider;function Ir(){const e=m.useContext(fs);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const ue=()=>Ir(),Mr=()=>Ir(),gs=m.createContext({searchButtonProps:{}}),Ar=gs.Provider;function ms(){return m.useContext(gs)}const ys=m.createContext(null),zr=ys.Provider;function bs(){const e=m.useContext(ys);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const le=()=>bs(),ye=()=>bs(),Mc={inEditMode:!1},zn=m.createContext(Mc),vs=m.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),Er=vs.Provider;function xs(){const e=m.useContext(vs);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const Ct=()=>xs(),Qe=()=>xs(),Ac={fullScreenPanelID:"",setFullScreenPanelID:x.noop},$r=m.createContext(Ac);function ws(){const e=m.useContext($r);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const W=k.observer(m.forwardRef(({label:e,required:t,value:n,onChange:r,clearable:a=!1,sx:o,...l},u)=>{const{panel:c}=Qe(),d=m.useMemo(()=>{const f=[...c.dataFieldOptions];return a&&f.unshift({label:"unset",value:"",group:""}),f},[c.dataFieldOptions]);return i(s.Select,{ref:u,label:e,data:d,value:n,onChange:r,required:t,sx:o,maxDropdownHeight:500,...l})}));function zc({context:e}){const{value:t,set:n}=R(e.instanceData,"config"),r=x.defaults({},t,Tr),{control:a,handleSubmit:o,reset:l}=v.useForm({defaultValues:r});return m.useEffect(()=>{l(r)},[t]),t?i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[i(s.Text,{children:"X Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"x_axis_data_key",control:a,render:({field:u})=>i(W,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"xAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Text,{mt:"lg",children:"Y Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"y_axis_data_key",control:a,render:({field:u})=>i(W,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"yAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Text,{mt:"lg",children:"Z Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"z_axis_data_key",control:a,render:({field:u})=>i(W,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"zAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(s.Button,{color:"blue",type:"submit",children:[i(I.DeviceFloppy,{size:20}),i(s.Text,{ml:"md",children:"Save"})]})})]})}):null}function Ec(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis_data_key:a,y_axis_data_key:o,z_axis_data_key:l,...u}=e;return{...u,x_axis_data_key:r(a),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class $c extends ge{constructor(){super(...arguments);q(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:a}=n;return{...n,version:2,config:Ec(a,r)}})}}const Lc={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new $c,name:"bar-3d",viewRender:Ic,configRender:zc,createConfig(){return{version:2,config:x.cloneDeep(Tr)}}};class Ee extends m.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 p(s.Box,{children:[i(s.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),i(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}const De={mantissa:0,output:"number",trimMantissa:!1,average:!1};function Pc({value:e,onChange:t},n){const r=u=>{t({...e,output:u})},a=u=>{const c=u===0?!1:e.trimMantissa;t({...e,mantissa:u,trimMantissa:c})},o=u=>{t({...e,trimMantissa:u.currentTarget.checked})},l=u=>{t({...e,average:u.currentTarget.checked})};return p(s.Stack,{ref:n,children:[p(s.Group,{grow:!0,children:[i(s.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:r,sx:{flexGrow:1}}),i(s.Switch,{label:p(s.Stack,{spacing:0,children:[i(s.Text,{children:"Average"}),i(s.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:l,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(s.Group,{grow:!0,children:[i(s.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:a}),i(s.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(s.Stack,{spacing:0,children:[i(s.Text,{weight:"bold",children:"Preview"}),i(Ee,{children:p(s.Group,{position:"apart",children:[p(s.Text,{size:12,color:"gray",children:["123456789 ",i(I.ArrowRight,{size:9})," ",Z(123456789).format(e)]}),p(s.Text,{size:12,color:"gray",children:["1234 ",i(I.ArrowRight,{size:9})," ",Z(1234).format(e)]}),p(s.Text,{size:12,color:"gray",children:["0.1234 ",i(I.ArrowRight,{size:9})," ",Z(.1234).format(e)]})]})})]})]})}const Ge=m.forwardRef(Pc),Ue={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
54
|
+
`;function xr(e,t){const n=Object.keys(t),r=Object.values(t);try{return new Function(...n,`return \`${e}\`;`)(...r)}catch(a){throw n.length===0&&e.includes("$")?new Error("[formatSQL] insufficient payload"):a}}function wr(e,t){try{return xr(e,t)}catch(n){return console.error(n),n.message}}function ic({sql:e,pre_process:t}){if(!t.trim())return e;try{return new Function(`return ${t}`)()({sql:e},At)}catch(n){return console.error(n),e}}function ac(e,t,n){if(!e.trim())return t;try{return new Function(`return ${e}`)()(t,At,n)}catch(r){return console.error(r),t}}function sc(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const a=t[r];if(a!="authentication"&&e[a])n.push(t[r]+"="+(typeof e[a]=="object"?JSON.stringify(e[a]):e[a]));else{const o=Object.keys(e[a]).sort();for(let l=0;l<o.length;l++){const u=o[l];u!="sign"&&e[a][u]&&n.push(o[l]+"="+(typeof e[a][u]=="object"?JSON.stringify(e[a][u]):e[a][u]))}}}return n.sort().join("&")}function oc(e,t){let n=sc(e);return n+="&key="+t,Xu.MD5(n).toString().toUpperCase()}class is{constructor(){this.type="default_api_client",this.baseURL="http://localhost:31200",this.app_id="",this.app_secret=""}getAuthentication(t){if(!this.app_id||!this.app_secret)return;const n=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:n,sign:oc({app_id:this.app_id,nonce_str:n,...t},this.app_secret)}}getRequest(t,n){return(r,a,o,l)=>{const u=this.buildHeader(o),c=this.buildAxiosConfig(t,r,a,o,u,n);return pt(c).then(d=>l?d:d.data).catch(d=>Promise.reject(d))}}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}buildAxiosConfig(t,n,r,a,o,l){const u={baseURL:this.baseURL,method:t,url:n,params:t==="GET"?r:a.params,headers:o,signal:l};return["POST","PUT"].includes(t)&&(u.data=a.string?JSON.stringify(r):r,u.data.authentication=this.getAuthentication(u.data)),u}buildHeader(t){const n=window.localStorage.getItem("token");return{"X-Requested-With":"XMLHttpRequest","Content-Type":t.string?"application/x-www-form-urlencoded":"application/json",authorization:n?`bearer ${n}`:"",...t.headers}}}class lc{constructor(t){this.implementation=t}getRequest(t,n){return this.implementation.getRequest(t,n)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}class as extends is{constructor(){super(...arguments);q(this,"makeQueryENV",null)}query(n){return async(r,a={})=>{var o;return r.env||(r.env=((o=this.makeQueryENV)==null?void 0:o.call(this))??{error:"failed to run makeQueryENV"}),this.post(n)("/query",r,a)}}httpDataSourceQuery(n){return async(r,a={})=>{var o;return r.env||(r.env=((o=this.makeQueryENV)==null?void 0:o.call(this))??{error:"failed to run makeQueryENV"}),this.getRequest("POST",n)("/query",r,a,!0)}}structure(n){return async(r,a={})=>this.post(n)("/query/structure",r,a)}}class ss{constructor(t){this.implementation=t}query(t){return this.implementation.query(t)}httpDataSourceQuery(t){return this.implementation.httpDataSourceQuery(t)}structure(t){return this.implementation.structure(t)}getRequest(t,n){return this.implementation.getRequest(t,n)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}const Nt=new as;function Cr(e){Nt.baseURL!==e.apiBaseURL&&(Nt.baseURL=e.apiBaseURL),e.app_id&&(Nt.app_id=e.app_id),e.app_secret&&(Nt.app_secret=e.app_secret),e.makeQueryENV&&(Nt.makeQueryENV=e.makeQueryENV)}const os=new ss(Nt),at=os;function ls(){return{filters:{},context:{}}}function Sr(e){const t=ls();if(!e)return ls();const{filters:n=t.filters,context:r=t.context}=e;return{filters:n,context:r}}async function uc({query:e,name:t,payload:n,additionals:r},a){if(!e.sql)return[];const{type:o,key:l,sql:u,pre_process:c,post_process:d}=e,f=xr(u,n),h=ic({sql:f,pre_process:c});let g=await at.query(a)({type:o,key:l,query:h,...r},{params:{name:t}});return g=ac(d,g,Sr(n)),g}async function cc({type:e,key:t,configString:n,name:r,additionals:a},o){try{return await at.httpDataSourceQuery(o)({type:e,key:t,query:n,...a},{params:{name:r}})}catch(l){if(pt.isCancel(l))throw l;return console.error(l),l}}async function _r(){try{return(await at.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function us(){try{return(await at.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class cs{constructor(t){q(this,"rootRef");this.rootRef=te.observable({current:t})}async deleteItem(t){te.runInAction(()=>{x.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?te.toJS(this.rootRef.current):x.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(x.isObject(n))te.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else te.runInAction(()=>{x.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return te.reaction(()=>this.getValueFromRoot(t),(a,o)=>{n(a,o)},{requiresObservable:!0,fireImmediately:x.get(r,"fireImmediately",!1)})}}class dc{constructor(){q(this,"channels",new Map);q(this,"globalChannel",new Va)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new Va;return this.channels.set(t,r),r}}class pc{constructor(t){q(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 dc,instanceData:new cs(t.viz.conf)};return this.instances.set(t.id,r),r}}function ds(e,t,n,r){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new cs({}),colorPalette:{getColor(){return()=>""}},data:t,variables:r}}const hc=e=>{const{panel:t,vizManager:n,data:r,variables:a}=e,o=n.resolveComponent(t.viz.type),l=n.getOrCreateInstance(t),u={...ds(l,r,n,a),viewport:{width:t.layout.w,height:t.layout.h}},c=o.viewRender;return i(c,{context:u,instance:l,...x.omit(e,["panel","vizManager","data"])})},fc=e=>{const{vizManager:t,panel:n,data:r,variables:a}=e,o=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),u={...ds(l,r,t,a)},c=o.configRender;return i(c,{context:u,instance:l,...x.omit(e,["panel","vizManager","data"])})},ps=(e,t)=>{const n=ht.bezier(e),r=ht.bezier(t);return function(a){return a<50?n(a*2/100).hex():r((a-50)*2/100).hex()}},Mn=e=>{const t=ht.bezier(e);return function(n){return t(n/100).hex()}},gc={type:"interpolation",displayName:"Red / Green",getColor:ps(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},mc={type:"interpolation",displayName:"Yellow / Blue",getColor:ps(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},yc={type:"interpolation",displayName:"Red",getColor:Mn(["#fff7f1","darkred"]),name:"red",category:"sequential"},bc={type:"interpolation",displayName:"Green",getColor:Mn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},vc={type:"interpolation",displayName:"Blue",getColor:Mn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},xc={type:"interpolation",displayName:"Orange",getColor:Mn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class wc{constructor(t){q(this,"symbol");this.symbol=Symbol(t)}}function ft(e){return new wc(e)}class kr{constructor(){q(this,"parent");q(this,"factoryRegistry",new Map);q(this,"instanceRegistry",new Map)}createScoped(){const t=new kr;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const r=n(this);return this.instanceRegistry.set(t.symbol,r),r}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=x.get(t,"dispose");x.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const hs="10.44.1",Cc=Object.freeze(Object.defineProperty({__proto__:null,version:hs},Symbol.toStringTag,{value:"Module"}));class Sc{constructor(t){q(this,"staticColors",new Map);q(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 _c{constructor(){q(this,"plugins",new Map);q(this,"vizComponents",new Map);q(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 kc{constructor(){q(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,r){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 a=this.migrations.filter(u=>u.version>t.from&&u.version<=t.to),o=x.orderBy(a,"version","asc");if(((l=x.last(o))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((u,c)=>c.handler(u,r),n)}}class ge extends kc{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(r,a)=>({version:t,...n(r,a)}))}async migrate({configData:t,panelModel:n}){const r=await t.getItem(null),a=x.get(r,"version",0),o=this.run({from:a,to:this.VERSION},r,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return x.get(n,"version",0)<this.VERSION}}const R=(e,t)=>{const[n,{setFalse:r}]=Q.useBoolean(!0),[a,o]=m.useState();m.useEffect(()=>(e.getItem(t).then(u=>{o(u),r()}),e.watchItem(t,u=>{o(u)})));const l=m.useCallback(async u=>{await e.setItem(t,u),o(u)},[e,t]);return{loading:n,value:a,set:l}},Oe={top:16,right:16,bottom:16,left:16},tt=e=>Math.max(0,e-Oe.left-Oe.right),nt=e=>Math.max(0,e-Oe.top-Oe.bottom),on=(e,t)=>({width:tt(e),height:nt(t)}),Be=({width:e,height:t,children:n})=>i(s.Box,{pt:Oe.top,pr:Oe.right,pb:Oe.bottom,pl:Oe.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n});function P(e){const[t,n]=e.split(".");return{queryID:t,columnKey:n}}function Tc(e){return e.includes(".")?P(e):{queryID:"",columnKey:e}}function gt(e,t){var a;const{queryID:n,columnKey:r}=P(t);return n?r?((a=e[n])==null?void 0:a.map(o=>o[r]))??[]:e[n]:[]}function ln(e,t){const{queryID:n}=P(t);return n?e[n]:[]}function Dc(e){return Object.values(e)[0]}function An(e,t){const{queryID:n,columnKey:r}=P(t);return e[r]}const Tr={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};ie.use([F.GridComponent,F.VisualMapComponent,F.LegendComponent,F.TooltipComponent,ze.CanvasRenderer]);function Ic({context:e}){const{value:t}=R(e.instanceData,"config"),n=e.data,{width:r,height:a}=e.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:u,xAxis3D:c,yAxis3D:d,zAxis3D:f}=x.defaults({},t,Tr),h=m.useMemo(()=>ln(n,o),[n,o]),{x:g,y,z:C}=m.useMemo(()=>({x:P(o),y:P(l),z:P(u)}),[o,l,u]),{min:w,max:_}=m.useMemo(()=>{const M=x.minBy(h,G=>G[C.columnKey]),O=x.maxBy(h,G=>G[C.columnKey]);return{min:x.get(M,C.columnKey),max:x.get(O,C.columnKey)}},[h,C]),D={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:w,max:_,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:c,yAxis3D:d,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(M=>[M[g.columnKey],M[y.columnKey],M[C.columnKey]])}]};return t?i(Be,{width:r,height:a,children:i(Ae,{echarts:ie,option:D,style:on(r,a),notMerge:!0,theme:"merico-light"})}):null}const fs=m.createContext(null),Dr=fs.Provider;function Ir(){const e=m.useContext(fs);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const ue=()=>Ir(),Mr=()=>Ir(),gs=m.createContext({searchButtonProps:{}}),Ar=gs.Provider;function ms(){return m.useContext(gs)}const ys=m.createContext(null),zr=ys.Provider;function bs(){const e=m.useContext(ys);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const le=()=>bs(),ye=()=>bs(),Mc={inEditMode:!1},zn=m.createContext(Mc),vs=m.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),Er=vs.Provider;function xs(){const e=m.useContext(vs);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const Ct=()=>xs(),Qe=()=>xs(),Ac={fullScreenPanelID:"",setFullScreenPanelID:x.noop},$r=m.createContext(Ac);function ws(){const e=m.useContext($r);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const W=k.observer(m.forwardRef(({label:e,required:t,value:n,onChange:r,clearable:a=!1,sx:o,...l},u)=>{const{panel:c}=Qe(),d=m.useMemo(()=>{const f=[...c.dataFieldOptions];return a&&f.unshift({label:"unset",value:"",group:""}),f},[c.dataFieldOptions]);return i(s.Select,{ref:u,label:e,data:d,value:n,onChange:r,required:t,sx:o,maxDropdownHeight:500,...l})}));function zc({context:e}){const{value:t,set:n}=R(e.instanceData,"config"),r=x.defaults({},t,Tr),{control:a,handleSubmit:o,reset:l}=v.useForm({defaultValues:r});return m.useEffect(()=>{l(r)},[t]),t?i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[i(s.Text,{children:"X Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"x_axis_data_key",control:a,render:({field:u})=>i(W,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"xAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Text,{mt:"lg",children:"Y Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"y_axis_data_key",control:a,render:({field:u})=>i(W,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"yAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Text,{mt:"lg",children:"Z Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"z_axis_data_key",control:a,render:({field:u})=>i(W,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"zAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(s.Button,{color:"blue",type:"submit",children:[i(I.DeviceFloppy,{size:20}),i(s.Text,{ml:"md",children:"Save"})]})})]})}):null}function Ec(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis_data_key:a,y_axis_data_key:o,z_axis_data_key:l,...u}=e;return{...u,x_axis_data_key:r(a),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class $c extends ge{constructor(){super(...arguments);q(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:a}=n;return{...n,version:2,config:Ec(a,r)}})}}const Lc={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new $c,name:"bar-3d",viewRender:Ic,configRender:zc,createConfig(){return{version:2,config:x.cloneDeep(Tr)}}};class Ee extends m.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 p(s.Box,{children:[i(s.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),i(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}const De={mantissa:0,output:"number",trimMantissa:!1,average:!1};function Pc({value:e,onChange:t},n){const r=u=>{t({...e,output:u})},a=u=>{const c=u===0?!1:e.trimMantissa;t({...e,mantissa:u,trimMantissa:c})},o=u=>{t({...e,trimMantissa:u.currentTarget.checked})},l=u=>{t({...e,average:u.currentTarget.checked})};return p(s.Stack,{ref:n,children:[p(s.Group,{grow:!0,children:[i(s.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:r,sx:{flexGrow:1}}),i(s.Switch,{label:p(s.Stack,{spacing:0,children:[i(s.Text,{children:"Average"}),i(s.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:l,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(s.Group,{grow:!0,children:[i(s.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:a}),i(s.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(s.Stack,{spacing:0,children:[i(s.Text,{weight:"bold",children:"Preview"}),i(Ee,{children:p(s.Group,{position:"apart",children:[p(s.Text,{size:12,color:"gray",children:["123456789 ",i(I.ArrowRight,{size:9})," ",Z(123456789).format(e)]}),p(s.Text,{size:12,color:"gray",children:["1234 ",i(I.ArrowRight,{size:9})," ",Z(1234).format(e)]}),p(s.Text,{size:12,color:"gray",children:["0.1234 ",i(I.ArrowRight,{size:9})," ",Z(.1234).format(e)]})]})})]})]})}const Ge=m.forwardRef(Pc),Ue={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
55
55
|
`)},Cs={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:Bc,configRender:Oc,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'boxplot'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Record of 'name', 'min', 'q1', 'median', 'q3', 'max'",valueType:"object"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Oc(e){return i(B,{})}function Bc(e){return i(s.Text,{children:"Click chart's series"})}const Vc=[{label:"Truncate",value:"truncate"},{label:"Break Line",value:"break"},{label:"Break Word",value:"breakAll"}],En=m.forwardRef(({sectionTitle:e,value:t,onChange:n},r)=>{const a=o=>l=>{const u=x.cloneDeep(t);x.set(u,o,l),n(u)};return p(s.Stack,{spacing:0,children:[e&&i(s.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),p(s.Group,{grow:!0,noWrap:!0,children:[i(s.NumberInput,{label:"Max Width",hideControls:!0,value:t.width,onChange:a("width")}),i(s.Select,{label:"Overflow",data:Vc,value:t.overflow,onChange:a("overflow")}),i(s.TextInput,{label:"Ellipsis",value:t.ellipsis,disabled:!0})]})]})}),st=m.forwardRef(({value:e,onChange:t},n)=>{const r=o=>{t({...e,on_axis:o})},a=o=>{t({...e,in_tooltip:o})};return p(s.Stack,{ref:n,spacing:0,children:[i(En,{sectionTitle:"Overflow on Axis",value:e.on_axis,onChange:r}),i(En,{sectionTitle:"Overflow in Tooltip",value:e.in_tooltip,onChange:a})]})}),We={on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}};function ot({overflow:e,width:t}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],r=e==="truncate"?"nowrap":"initial",a={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
|
|
56
56
|
max-width: ${t}px;
|
|
57
57
|
word-break: ${n};
|
|
@@ -436,7 +436,7 @@ Check the top-level render call using <`+V+">.")}return z}}function Ou(S,z){{if(
|
|
|
436
436
|
</thead>
|
|
437
437
|
<tbody>${g.join("")}</tbody>
|
|
438
438
|
</table>
|
|
439
|
-
`}}}function k1(e,t){const n=Qt(e.heat_block.min,t),r=Qt(e.heat_block.max,t);return{min:n,max:r,calculable:!0,orient:"horizontal",left:"center",top:0,itemWidth:15}}function T1(e,t,n){const r=P(e.x_axis.data_key),a=x.uniq(t[r.queryID].map(c=>c[r.columnKey])),{overflow:o,rotate:l}=e.x_axis.axisLabel,u=rt(o.on_axis);return{id:"main-x-axis",type:"category",data:a,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:l,...u,formatter:n},splitArea:{show:!0},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:2}}function D1(e,t,n){const r=P(e.x_axis.data_key),a=P(e.y_axis.data_key),{nameAlignment:o,data_key:l,...u}=e.y_axis,c=x.uniq(t[r.queryID].map(g=>g[a.columnKey])),{overflow:d,rotate:f}=e.y_axis.axisLabel,h=rt(d.on_axis);return{...u,type:"category",data:c,axisLabel:{rotate:f,...h,formatter:n},axisLine:{show:!0,color:"blue"},axisTick:{show:!0,alignWithLabel:!0},splitArea:{show:!0},nameTextStyle:{fontWeight:"bold",align:o},nameLocation:"end",nameGap:15,z:2}}const I1={tooltip:{confine:!0}};function M1(e,t,n){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const r=n.reduce((u,c)=>{const d=yt(c,t);return u[c.name]=Ze(c,d),u},{}),a=b1(e),o=v1(e),l={xAxis:T1(e,t,a.x_axis),yAxis:D1(e,t,a.y_axis),series:w1(e,t),tooltip:_1(e,t,a,o),grid:x1(e),visualMap:k1(e,r)};return x.defaultsDeep({},l,I1)}ie.use([F.DataZoomComponent,he.HeatmapChart,F.GridComponent,F.LegendComponent,F.TooltipComponent,F.VisualMapComponent,ze.CanvasRenderer]);function A1({conf:e,data:t,width:n,height:r,interactionManager:a,variables:o}){const l=m.useMemo(()=>{const h=P(e.x_axis.data_key),g=P(e.y_axis.data_key);return x.keyBy(t[h.queryID],y=>`${y[h.columnKey]}---${y[g.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),u=Ke(a.triggerManager,tl.id),c=m.useCallback(h=>{const[g,y]=h.value,C=x.get(l,`${g}---${y}`,{error:"rowData is not found"});u.forEach(w=>{a.runInteraction(w.id,{...h,rowData:C})})},[l,u,a]),d=m.useMemo(()=>({click:c}),[c]),f=m.useMemo(()=>M1(e,t,o),[e,t]);return i(Ae,{echarts:ie,option:f,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function z1({context:e,instance:t}){const n=Xe({vizManager:e.vizManager,instance:t}),{value:r}=R(e.instanceData,"config"),{variables:a}=e,o=m.useMemo(()=>x.defaults({},r,zi),[r]),l=e.data,{width:u,height:c}=e.viewport;return!u||!c?null:i(Be,{width:u,height:c,children:i(A1,{variables:a,width:tt(u),height:nt(c),data:l,conf:o,interactionManager:n})})}class E1 extends ge{constructor(){super(...arguments);q(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const $1={displayName:"Merico Heatmap",displayGroup:"Merico suite",migrator:new E1,name:"merico-heatmap",viewRender:z1,configRender:g1,createConfig:()=>({version:1,config:zi}),triggers:[tl]},L1=[{value:"#25262B",name:"Dark"},{value:"#868E96",name:"Gray"},{value:"#FA5252",name:"Red"},{value:"#E64980",name:"Pink"},{value:"#BE4BDB",name:"Grape"},{value:"#7950F2",name:"Violet"},{value:"#4C6EF5",name:"Indigo"},{value:"#228BE6",name:"Blue"},{value:"#15AABF",name:"Cyan"},{value:"#12B886",name:"Teal"},{value:"#40C057",name:"Green"},{value:"#82C91E",name:"Lime"},{value:"#FAB005",name:"Yellow"},{value:"#FD7E14",name:"Orange"}].map(e=>({name:e.name,value:e.value,type:"single",category:"basic"})),P1=[gc,mc,vc,bc,yc,xc],rl=()=>({id:"dashboard",version:hs,manifest:{viz:[Ci,xx,j0,Jb,Gx,Gy,hC,Lc,ef,hm,Xm,Dw,My,jg,lx,hb,Gb,Z0,RC,$1,a1,gf],color:[...L1,...P1]}}),vn=new _c,be={pluginManager:ft("pluginManager"),vizManager:ft("vizManager"),colorManager:ft("colorManager"),instanceScope:{panelModel:ft("panelModel"),vizInstance:ft("vizInstance"),interactionManager:ft("interactionManager"),migrator:ft("migrator"),operationManager:ft("operationManager"),triggerManager:ft("triggerManager")}},Ei=()=>{try{vn.install(rl())}catch{}const e=new pc(vn),t=new Sc(vn);return{pluginManager:vn,vizManager:e,colorManager:t}},ct=m.createContext(Ei());try{vn.install(rl())}catch{}const $i=m.createContext(null);function sr(e){const t=m.useContext($i),n=Q.useCreation(()=>e.configure(t||new kr),[e.configure]),r=Q.usePrevious(n);return r&&r!==n&&r.dispose(),i($i.Provider,{value:n,children:e.children})}function il(){return m.useContext($i)}const O1=({description:e,isDescriptionEmpty:t})=>t?null:i(s.Tooltip,{color:"white",label:i(Yn,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:i(s.Box,{sx:{height:"16px",alignSelf:"center"},children:i(E.IconInfoCircle,{size:16,color:"gray"})})}),B1=k.observer(({label:e,config:{default_value:t,description:n,isDescriptionEmpty:r,...a},value:o,onChange:l})=>p(s.Box,{children:[i(s.Text,{children:" "}),i(s.Checkbox,{label:p(s.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[i(s.Box,{sx:{flexGrow:1},children:e}),i(O1,{description:n,isDescriptionEmpty:r})]}),checked:o||!1,onChange:u=>l(u.currentTarget.checked),...a,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),al=k.observer(({label:e,config:t,value:n=[null,null],onChange:r})=>{const{inputFormat:a,...o}=t,l=Array.isArray(n)?n.map(f=>f?U(f).toDate():null):[null,null],u=f=>{r(f.map(h=>h&&U(h).format(a)))},c=t.getMinDate(l[0]),d=t.getMaxDate(l[0]);return i(Ru.DatePickerInput,{type:"range",label:e,value:l,onChange:u,icon:i(I.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:c,maxDate:d,valueFormat:a,styles:{input:{borderColor:"#e9ecef"}},...o})}),V1=s.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-select.rc-select-open":{borderColor:"#228be6 !important",".rc-select-selection-overflow-item-rest":{display:"none"},".rc-select-selection-overflow-item-suffix":{display:"block"}},".rc-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-select-selection-search-mirror":{display:"none"},".rc-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,backgroundColor:"#fff",border:"1px solid #e9ecef",marginTop:6,padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px","&.rc-select-dropdown-slide-up-leave-active":{display:"none"},".rc-select-item-empty":{padding:"8px 12px"},".rc-select-item-option":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px 8px 2px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},flexDirection:"row-reverse",".rc-select-item-option-state":{flexGrow:0,flexShrink:0,width:"30px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},".rc-select-item-option-content":{width:"calc(100% - 30px)",overflow:"hidden",'div[data-role="label"]':{overflowWrap:"break-word"}}},".rc-virtual-list-holder-inner":{alignItems:"flex-start"}}})),sl=({errorMessage:e})=>e?i(s.Text,{color:"red",size:12,children:e}):i(s.Text,{color:"dimmed",size:12,children:"Not found"}),N1=({disabled:e,classNames:t,styles:n,unstyled:r,radius:a,style:o,label:l,value:u,onChange:c,options:d,errorMessage:f,required:h})=>{const{classes:g,cx:y}=V1({radius:a},{name:"MultiSelectWidget",classNames:t,styles:n,unstyled:r}),[C,w]=m.useState(!1),_=$=>{w($)},D=C&&(u==null?void 0:u.length)>0,[M,O]=m.useState(""),G=m.useMemo(()=>{if(!M)return d;const $=M.toLowerCase(),L=A=>{var N;return((N=A.description)==null?void 0:N.toLowerCase().includes($))||A.label.toLowerCase().includes($)};return d.filter(L)},[M,d]);return p(s.Stack,{spacing:3,children:[p(s.Group,{position:"apart",children:[p(s.Text,{className:g.label,children:[l,h&&i("span",{className:g.required,"aria-hidden":"true",children:"*"})]}),D&&i(s.Tooltip,{label:`${u.length} selected`,children:i(s.Badge,{children:u.length})})]}),i(Ha,{disabled:e,allowClear:!0,className:y(g.root,"check-select"),dropdownClassName:y(g.dropdown,""),onDropdownVisibleChange:_,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:o,clearIcon:()=>i(s.CloseButton,{}),value:u,onChange:c,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:i(sl,{errorMessage:f}),maxTagTextLength:10,maxTagPlaceholder:$=>`${$.length} selected`,searchValue:M,onSearch:O,filterOption:!1,children:G.map($=>p(Ha.Option,{title:$.label,children:[i(s.Text,{size:"sm","data-role":"label",children:$.label}),$.description&&i(s.Text,{size:"xs",color:"dimmed","data-role":"description",children:$.description})]},$.value))})]})},q1=k.observer(({label:e,config:t,value:n,onChange:r})=>{const a=ye(),o=!!t.options_query_id,{state:l,error:u}=a.getDataStuffByID(t.options_query_id),c=l==="loading",d=t.min_width?t.min_width:"200px",f=o?c:!1,h=g=>r(g,!1);return i(N1,{label:e,options:t.options,style:{minWidth:"160px",width:d,maxWidth:f?d:"unset",borderColor:"#e9ecef"},disabled:f,value:n,onChange:h,errorMessage:u,required:t.required})}),F1=m.forwardRef(({label:e,description:t,...n},r)=>i("div",{ref:r,...n,children:i(s.Group,{noWrap:!0,children:p("div",{children:[i(s.Text,{size:"sm","data-role":"label",children:e}),i(s.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),G1=k.observer(({label:e,config:t,value:n,onChange:r})=>{const a=ye(),o=!!t.options_query_id,{state:l,error:u}=a.getDataStuffByID(t.options_query_id),c=l==="loading";return i(s.Select,{label:e,data:t.options,disabled:o?c:!1,value:n,onChange:r,error:!!u,placeholder:u,maxDropdownHeight:500,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"}},itemComponent:F1})});function W1({label:e,config:t,value:n,onChange:r}){return i(s.TextInput,{label:e,value:n||"",onChange:a=>r(a.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const j1=({rotate:e,onClick:t})=>i("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:i("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),R1=({expanded:e,isLeaf:t,value:n,onClick:r,...a})=>(n==="0-0-value"&&console.log(a),t?i("span",{style:{width:"14px",display:"inline-block"}}):i(j1,{rotate:e?"0":"-90",onClick:r,...a})),Y1=({onClick:e})=>p("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),i("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),i("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),i("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),Q1=({onClick:e,...t})=>i(Y1,{onClick:e,...t}),U1=s.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),K1=({disabled:e,classNames:t,styles:n,unstyled:r,radius:a,style:o,label:l,value:u,onChange:c,treeData:d,errorMessage:f,required:h,treeCheckStrictly:g})=>{const{classes:y,cx:C}=U1({radius:a},{name:"FilterTreeSelectWidget",classNames:t,styles:n,unstyled:r}),[w,_]=m.useState(!1),D=O=>{_(O)},M=w&&(u==null?void 0:u.length)>0;return p(s.Stack,{spacing:3,children:[p(s.Group,{position:"apart",children:[p(s.Text,{className:y.label,children:[l,h&&i("span",{className:y.required,"aria-hidden":"true",children:"*"})]}),M&&i(s.Tooltip,{label:`${u.length} selected`,children:i(s.Badge,{children:u.length})})]}),i(es,{disabled:e,allowClear:!0,treeCheckStrictly:g,className:C(y.root,"check-select"),dropdownClassName:C(y.dropdown,""),onDropdownVisibleChange:D,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,listHeight:510,treeLine:!0,clearIcon:()=>i(s.CloseButton,{}),switcherIcon:R1,treeIcon:Q1,maxTagTextLength:10,value:u,treeData:d,notFoundContent:i(sl,{errorMessage:f}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:es.SHOW_PARENT,onChange:c,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:O=>`${O.length} selected`})]})},X1=k.observer(({label:e,config:t,value:n,onChange:r})=>{const{treeData:a,treeDataLoading:o,errorMessage:l}=t,u=t.min_width?t.min_width:"200px",d=!!t.options_query_id?o:!1;return i(K1,{disabled:d,style:{minWidth:"160px",width:u,maxWidth:d?u:"unset",borderColor:"#e9ecef"},value:n,onChange:f=>r(f,!1),treeData:a,errorMessage:l,label:e,required:t.required,treeCheckStrictly:t.treeCheckStrictly})}),J1=k.observer(({filter:{type:e,config:t,key:n,...r},formFieldProps:a})=>{switch(e){case"select":return i(G1,{...r,...a,config:t});case"multi-select":return i(q1,{...r,...a,config:t});case"tree-select":return i(X1,{...r,...a,config:t});case"text-input":return i(W1,{...r,...a,config:t});case"date-range":return i(al,{...r,...a,config:t});case"checkbox":return i(B1,{...r,...a,config:t});default:return null}}),Z1=k.observer(m.forwardRef(({filter:e,...t},n)=>i("div",{className:"filter-root",ref:n,children:i(Ee,{children:i(J1,{filter:e,formFieldProps:t})})}))),H1=({disabled:e})=>{const{searchButtonProps:t}=ms(),{children:n="Search",type:r,...a}=t;return i(s.Button,{color:"blue",size:"sm",type:"submit",...a,disabled:e||a.disabled,children:n})};function eS(e){const t=le();m.useEffect(()=>{var n,r;(r=(n=t.filters).updatePreviewValues)==null||r.call(n,e)},[e])}const ol=k.observer(function({view:t}){const n=ye(),{control:r,handleSubmit:a,reset:o}=v.useForm({defaultValues:n.filters.values,reValidateMode:"onBlur"}),l=v.useWatch({control:r});m.useEffect(()=>{o(n.filters.values)},[n.filters.values,o]),eS(l);const u=n.filters.visibleInView(t.id),c=m.useMemo(()=>u.every(g=>g.should_auto_submit),[u]),d=m.useMemo(()=>u.filter(g=>x.get(g,"config.required",!1)),[u]),f=m.useMemo(()=>d.length===0?!1:d.some(g=>!g.requiredAndPass(l[g.key])),[l,d]);if(u.length===0)return null;const h=(g,y)=>(C,w)=>{y(C),(g.should_auto_submit||w)&&n.filters.setValueByKey(g.key,C)};return i("form",{onSubmit:a(n.filters.setValues),children:p(s.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:c?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[i(s.Group,{align:"flex-start",children:u.map(g=>i(v.Controller,{name:g.key,control:r,render:({field:y})=>i(Z1,{filter:g,value:y.value,onChange:h(g,y.onChange)})},g.id))}),!c&&i(s.Group,{sx:{alignSelf:"flex-end"},children:i(H1,{disabled:f})})]})})}),tS={viewPanelInFullScreen:x.noop,inFullScreen:!1},or=m.createContext(tS),ll=b.types.model("MockContextMeta",{current:b.types.optional(b.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function ul(e){return{current:e}}const nS=b.types.model("PanelLayoutMeta",{x:b.types.number,y:b.types.maybeNull(b.types.number),w:b.types.number,h:b.types.number,moved:b.types.optional(b.types.boolean,!1),static:b.types.optional(b.types.boolean,!1)}).views(e=>({get json(){const{x:t,y:n,w:r,h:a,moved:o}=e;return{h:a,w:r,x:t,y:n===null?0:n,moved:o,static:e.static}}})).actions(e=>({set(t){const{x:n,y:r,w:a,h:o,moved:l}=t;e.x=n,e.y=r,e.w=a,e.h=o,e.moved=!!l,e.static=!!t.static},setWidth(t){e.w=t},setHeight(t){e.h=t}})),rS=b.types.model("PanelStyleBorderMeta",{enabled:b.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),iS=b.types.model("PanelStyleMeta",{border:rS}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),aS=b.types.model("VariableMeta",{name:b.types.string,size:b.types.string,weight:b.types.string,color:b.types.union(b.types.model({type:b.types.literal("static"),staticColor:b.types.string}),b.types.model({type:b.types.literal("continuous"),valueRange:b.types.array(b.types.number),colorRange:b.types.array(b.types.string)}),b.types.model({type:b.types.literal("piecewise")})),formatter:b.types.model({output:b.types.enumeration("Output",["number","percent"]),average:b.types.optional(b.types.boolean,!1),mantissa:b.types.number,trimMantissa:b.types.optional(b.types.boolean,!1)}),data_field:b.types.string,aggregation:b.types.union(b.types.model({type:b.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:b.types.frozen()}),b.types.model({type:b.types.literal("quantile"),config:b.types.model({p:b.types.number})}),b.types.model({type:b.types.literal("custom"),config:b.types.model({func:b.types.string})}))}).views(e=>({get json(){const{name:t,size:n,weight:r,color:a,formatter:o,data_field:l,aggregation:u}=e;return x.cloneDeep({name:t,size:n,color:a,weight:r,formatter:o,data_field:l,aggregation:u})}})),sS=b.types.model("PanelVizMeta",{type:b.types.string,conf:b.types.frozen()}).views(e=>({get json(){return{conf:e.conf,type:e.type}}})).actions(e=>({setType(t){e.type=t},setConf(t){e.conf=t}})),oS=b.types.model("PanelTitleMeta",{show:b.types.optional(b.types.boolean,!0)}).views(e=>({get json(){const{show:t}=e;return{show:t}}})).actions(e=>({setShow(t){e.show=t}})),lS=b.types.model({id:b.types.string,name:b.types.optional(b.types.string,""),title:oS,description:b.types.string,layout:nS,queryIDs:b.types.array(b.types.string),viz:sS,style:iS,variables:b.types.optional(b.types.array(aS),[])}).views(e=>({get json(){const{id:t,name:n,title:r,description:a,queryIDs:o}=e;return{id:t,viz:e.viz.json,name:n,style:e.style.json,title:r,layout:e.layout.json,queryIDs:[...o],variables:e.variables.map(l=>l.json),description:a}},get queryIDSet(){return new Set(e.queryIDs)}})).actions(e=>({setID(t){e.id=t},setName(t){e.name=t},setDescription(t){e.description=t},addQueryID(t){e.queryIDSet.has(t)||e.queryIDs.push(t)},removeQueryID(t){if(!e.queryIDSet.has(t))return;const n=new Set(e.queryIDSet);n.delete(t),e.queryIDs=b.cast(Array.from(n))},setQueryIDs(t){e.queryIDs=b.cast(t)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)}})),lr=e=>x.cloneDeepWith(e,(t,n)=>{if(n!==void 0&&t)return te.toJS(t)});var Ne=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e))(Ne||{});const uS=b.types.model("QueryMeta",{id:b.types.string,name:b.types.string,type:b.types.enumeration("DataSourceType",[Ne.Postgresql,Ne.MySQL,Ne.HTTP]),key:b.types.string,sql:b.types.string,pre_process:b.types.optional(b.types.string,""),post_process:b.types.optional(b.types.string,""),run_by:b.types.optional(b.types.array(b.types.string),[]),react_to:b.types.optional(b.types.array(b.types.string),[])}).views(e=>({get valid(){return e.id&&e.type&&e.key&&e.name?e.type===Ne.HTTP?!!e.pre_process:!!e.sql:!1},get json(){const{id:t,name:n,type:r,key:a,sql:o,run_by:l,react_to:u,pre_process:c,post_process:d}=e;return lr({id:t,key:a,sql:o,name:n,type:r,run_by:l,react_to:u,pre_process:c,post_process:d})}})).actions(e=>({setName(t){e.name=t},setKey(t){e.key=t},setType(t){e.type=t},setSQL(t){e.sql=t},setRunBy(t){e.run_by.length=0,e.run_by.push(...t)},setReactTo(t){e.react_to.length=0,e.react_to.push(...t)},setPreProcess(t){e.pre_process=t},setPostProcess(t){e.post_process=t}})),cS=b.types.model("SQLSnippetMeta",{key:b.types.string,value:b.types.string}).views(e=>({get json(){const{key:t,value:n}=e;return{key:t,value:n}}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.value=t}}));var ve=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(ve||{});const cl=b.types.model("FilterCheckboxConfigMeta",{_name:b.types.literal("checkbox"),description:b.types.optional(b.types.string,""),default_value:b.types.boolean}).views(e=>({get json(){const{_name:t,description:n,default_value:r}=e;return{_name:t,description:n,default_value:r}},get isDescriptionEmpty(){const{description:t}=e;return t===""||t==="<p></p>"}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDescription(t){e.description=t}})),dS=()=>cl.create({_name:"checkbox",description:"",default_value:!1});function dl(e,t){return e.map(n=>{try{return n?U.tz(n,"UTC").format(t):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}const pS=b.types.model("FilterDateRangeConfigMeta",{_name:b.types.literal("date-range"),required:b.types.boolean,inputFormat:b.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:b.types.optional(b.types.array(b.types.union(b.types.string,b.types.null)),[null,null]),clearable:b.types.boolean,max_days:b.types.optional(b.types.number,0),allowSingleDateInRange:b.types.optional(b.types.boolean,!1)}).views(e=>({get json(){const{_name:t,max_days:n,required:r,clearable:a,inputFormat:o,default_value:l,allowSingleDateInRange:u}=e;return{_name:t,max_days:n,required:r,clearable:a,inputFormat:o,default_value:dl(l,o),allowSingleDateInRange:u}},truthy(t){return Array.isArray(t)&&t.length===2&&t.every(n=>!!n)}})).views(e=>({getMaxDate(t){const{max_days:n}=e;if(!(!n||!t))return U(t).startOf("day").add(n,"days").toDate()},getMinDate(t){const{max_days:n}=e;if(!(!n||!t))return U(t).startOf("day").subtract(n,"days").toDate()}})).actions(e=>({setFilterValue(t){try{const n=b.getParent(e);b.getRoot(e).filters.setValueByKey(n.key,t)}catch(n){console.error(n)}}})).actions(e=>({setRequired(t){e.required=t},setClearable(t){e.clearable=t},setInputFormat(t){e.inputFormat=t},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t),e.setFilterValue(t)},setMaxDays(t){e.max_days=t,t>0&&(e.clearable=!0)},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),pl=b.types.snapshotProcessor(pS,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>n===null?null:U.tz(n,"UTC").toISOString())}},postProcessor(e){const{default_value:t,...n}=e;return{...n,default_value:dl(t,n.inputFormat)}}}),hS=()=>pl.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),fS=b.types.model({label:b.types.string,value:b.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),Li=b.types.model("FilterConfigModel_BaseSelect",{static_options:b.types.optional(b.types.array(fS),[]),options_query_id:b.types.optional(b.types.string,""),default_selection_count:b.types.optional(b.types.number,0),required:b.types.optional(b.types.boolean,!1)}).views(e=>({get usingQuery(){return!!e.options_query_id}})).views(e=>({get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:n,error:r}=b.getRoot(e).content.getDataStuffByID(e.options_query_id);return n==="idle"?t:[]}})).actions(e=>({setRequired(t){e.required=t},addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},setDefaultSelectionCount(t){e.default_selection_count=t},setOptionsQueryID(t){e.options_query_id=t??""}})),hl=b.types.compose("FilterMultiSelectConfigMeta",b.types.model({_name:b.types.literal("multi-select"),min_width:b.types.optional(b.types.string,""),default_value:b.types.optional(b.types.array(b.types.string),[])}),Li).views(e=>({get json(){const{_name:t,default_value:n,required:r,min_width:a,static_options:o,options_query_id:l,default_selection_count:u}=e;return lr({_name:t,required:!!r,min_width:a,default_value:n,static_options:o,options_query_id:l,default_selection_count:u})},get default_selection(){return e.usingQuery?e.options.slice(0,e.default_selection_count).map(t=>t.value):e.default_value},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=b.cast(t)},setMinWidth(t){e.min_width=t},setDefaultSelection(){const t=b.getRoot(e).content.filters,n=b.getParent(e).key;t.setValueByKey(n,e.default_selection)}})).actions(e=>({afterCreate(){b.addDisposer(e,te.reaction(()=>te.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),gS=()=>hl.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),fl=b.types.compose("FilterConfigModel_Select",b.types.model({_name:b.types.literal("select"),default_value:b.types.string,width:b.types.optional(b.types.string,"")}),Li).views(e=>({get json(){const{_name:t,default_value:n,required:r,width:a,static_options:o,options_query_id:l,default_selection_count:u}=e;return lr({_name:t,width:a,required:r,default_value:n,static_options:o,options_query_id:l,default_selection_count:u})},truthy(t){return!!t},getSelectOption(t){return e.options.find(n=>n.value===t)},get default_selection(){return e.usingQuery?e.default_selection_count>0&&e.options.length>0?e.options[0].value:"":e.default_value}})).actions(e=>({setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t},setDefaultSelection(){const t=b.getRoot(e).content.filters,n=b.getParent(e).key;t.setValueByKey(n,e.default_selection)}})).actions(e=>({afterCreate(){b.addDisposer(e,te.reaction(()=>te.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),mS=()=>fl.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),gl=b.types.model("FilterTextInputConfigMeta",{_name:b.types.literal("text-input"),required:b.types.boolean,default_value:b.types.string}).views(e=>({get json(){const{_name:t,required:n,default_value:r}=e;return{_name:t,required:n,default_value:r}},truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),ml=()=>gl.create({_name:"text-input",required:!1,default_value:""});function yS(e){return Yu.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function bS(e){return e.map(t=>{const{label:n,description:r,...a}=t,o={...a,filterBasis:`${n}___${r??""}`,description:r,label:n};return r&&(o.label=m.createElement("div",{},[m.createElement(s.Text,{key:0,title:t.label},t.label),m.createElement(s.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description},t.description)])),o})}const yl=b.types.compose("FilterTreeSelectConfigMeta",b.types.model({_name:b.types.literal("tree-select"),min_width:b.types.optional(b.types.string,""),default_value:b.types.optional(b.types.array(b.types.string),[]),treeCheckStrictly:b.types.optional(b.types.boolean,!1)}),Li).views(e=>({get json(){const{_name:t,default_value:n,required:r,min_width:a,static_options:o,options_query_id:l,default_selection_count:u,treeCheckStrictly:c}=e;return{_name:t,required:!!r,min_width:a,default_value:n,static_options:o,options_query_id:l,treeCheckStrictly:c,default_selection_count:u}},get treeData(){const{data:t}=b.getRoot(e).content.getDataStuffByID(e.options_query_id),n=bS(t);return yS(n)},get errorMessage(){const{error:t}=b.getRoot(e).content.getDataStuffByID(e.options_query_id);return t},get treeDataLoading(){const{state:t}=b.getRoot(e).content.getDataStuffByID(e.options_query_id);return t==="loading"},get defaultSelection(){const{default_selection_count:t}=e;return t?this.treeData.slice(0,t).map(r=>r.value):[]},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=b.cast(t)},setMinWidth(t){e.min_width=t},setTreeCheckStrictly(t){e.treeCheckStrictly=t},applyDefaultSelection(){const t=b.getParent(e,1).key;b.getRoot(e).content.filters.setValueByKey(t,e.defaultSelection)},afterCreate(){b.addDisposer(e,te.reaction(()=>JSON.stringify(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!0,delay:0}))}})),vS=()=>yl.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),bl=b.types.model("FilterMeta",{id:b.types.identifier,key:b.types.string,label:b.types.string,order:b.types.number,visibleInViewsIDs:b.types.array(b.types.string),auto_submit:b.types.optional(b.types.boolean,!1),type:b.types.enumeration("DashboardFilterType",[ve.Select,ve.MultiSelect,ve.TreeSelect,ve.TextInput,ve.Checkbox,ve.DateRange]),config:b.types.union(fl,hl,yl,gl,cl,pl)}).views(e=>({get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==ve.TreeSelect},get auto_submit_supported(){return[ve.Select,ve.Checkbox,ve.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:n,label:r,order:a,visibleInViewsIDs:o,auto_submit:l,type:u,config:c}=e;return{id:t,key:n,type:u,label:r,order:a,config:c.json,auto_submit:l,visibleInViewsIDs:te.toJS(o)}},get visibleInViewsIDSet(){return new Set(e.visibleInViewsIDs)},get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return x.get(e.config,"required",!1)?x.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setLabel(t){e.label=t},setOrder(t){e.order=t},setType(t){switch(t){case ve.Select:e.config=mS();break;case ve.MultiSelect:e.config=gS();break;case ve.TreeSelect:e.config=vS();break;case ve.TextInput:e.config=ml();break;case ve.Checkbox:e.config=dS();break;case ve.DateRange:e.config=hS();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t}}));var j=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(j||{});const vl=b.types.model("ViewDivisionConfig",{_name:b.types.literal(j.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})),xS=()=>vl.create({_name:j.Division}),wS=b.types.model("CustomModalTitleModel",{enabled:b.types.optional(b.types.boolean,!1),func_content:b.types.optional(b.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:n}=e;return{enabled:t,func_content:n}},get value(){const{enabled:t,func_content:n}=e,r=b.getParent(e,2),a=b.getRoot(e);if(!t)return r.name;try{const o={filters:a.content.filters.values,context:a.context.current};return new Function(`return ${n}`)()(o)}catch(o){return console.error(o),r.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:n}){e.enabled=t,e.func_content=n}})),Pi={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
439
|
+
`}}}function k1(e,t){const n=Qt(e.heat_block.min,t),r=Qt(e.heat_block.max,t);return{min:n,max:r,calculable:!0,orient:"horizontal",left:"center",top:0,itemWidth:15}}function T1(e,t,n){const r=P(e.x_axis.data_key),a=x.uniq(t[r.queryID].map(c=>c[r.columnKey])),{overflow:o,rotate:l}=e.x_axis.axisLabel,u=rt(o.on_axis);return{id:"main-x-axis",type:"category",data:a,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:l,...u,formatter:n},splitArea:{show:!0},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:2}}function D1(e,t,n){const r=P(e.x_axis.data_key),a=P(e.y_axis.data_key),{nameAlignment:o,data_key:l,...u}=e.y_axis,c=x.uniq(t[r.queryID].map(g=>g[a.columnKey])),{overflow:d,rotate:f}=e.y_axis.axisLabel,h=rt(d.on_axis);return{...u,type:"category",data:c,axisLabel:{rotate:f,...h,formatter:n},axisLine:{show:!0,color:"blue"},axisTick:{show:!0,alignWithLabel:!0},splitArea:{show:!0},nameTextStyle:{fontWeight:"bold",align:o},nameLocation:"end",nameGap:15,z:2}}const I1={tooltip:{confine:!0}};function M1(e,t,n){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const r=n.reduce((u,c)=>{const d=yt(c,t);return u[c.name]=Ze(c,d),u},{}),a=b1(e),o=v1(e),l={xAxis:T1(e,t,a.x_axis),yAxis:D1(e,t,a.y_axis),series:w1(e,t),tooltip:_1(e,t,a,o),grid:x1(e),visualMap:k1(e,r)};return x.defaultsDeep({},l,I1)}ie.use([F.DataZoomComponent,he.HeatmapChart,F.GridComponent,F.LegendComponent,F.TooltipComponent,F.VisualMapComponent,ze.CanvasRenderer]);function A1({conf:e,data:t,width:n,height:r,interactionManager:a,variables:o}){const l=m.useMemo(()=>{const h=P(e.x_axis.data_key),g=P(e.y_axis.data_key);return x.keyBy(t[h.queryID],y=>`${y[h.columnKey]}---${y[g.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),u=Ke(a.triggerManager,tl.id),c=m.useCallback(h=>{const[g,y]=h.value,C=x.get(l,`${g}---${y}`,{error:"rowData is not found"});u.forEach(w=>{a.runInteraction(w.id,{...h,rowData:C})})},[l,u,a]),d=m.useMemo(()=>({click:c}),[c]),f=m.useMemo(()=>M1(e,t,o),[e,t]);return i(Ae,{echarts:ie,option:f,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function z1({context:e,instance:t}){const n=Xe({vizManager:e.vizManager,instance:t}),{value:r}=R(e.instanceData,"config"),{variables:a}=e,o=m.useMemo(()=>x.defaults({},r,zi),[r]),l=e.data,{width:u,height:c}=e.viewport;return!u||!c?null:i(Be,{width:u,height:c,children:i(A1,{variables:a,width:tt(u),height:nt(c),data:l,conf:o,interactionManager:n})})}class E1 extends ge{constructor(){super(...arguments);q(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const $1={displayName:"Merico Heatmap",displayGroup:"Merico suite",migrator:new E1,name:"merico-heatmap",viewRender:z1,configRender:g1,createConfig:()=>({version:1,config:zi}),triggers:[tl]},L1=[{value:"#25262B",name:"Dark"},{value:"#868E96",name:"Gray"},{value:"#FA5252",name:"Red"},{value:"#E64980",name:"Pink"},{value:"#BE4BDB",name:"Grape"},{value:"#7950F2",name:"Violet"},{value:"#4C6EF5",name:"Indigo"},{value:"#228BE6",name:"Blue"},{value:"#15AABF",name:"Cyan"},{value:"#12B886",name:"Teal"},{value:"#40C057",name:"Green"},{value:"#82C91E",name:"Lime"},{value:"#FAB005",name:"Yellow"},{value:"#FD7E14",name:"Orange"}].map(e=>({name:e.name,value:e.value,type:"single",category:"basic"})),P1=[gc,mc,vc,bc,yc,xc],rl=()=>({id:"dashboard",version:hs,manifest:{viz:[Ci,xx,j0,Jb,Gx,Gy,hC,Lc,ef,hm,Xm,Dw,My,jg,lx,hb,Gb,Z0,RC,$1,a1,gf],color:[...L1,...P1]}}),vn=new _c,be={pluginManager:ft("pluginManager"),vizManager:ft("vizManager"),colorManager:ft("colorManager"),instanceScope:{panelModel:ft("panelModel"),vizInstance:ft("vizInstance"),interactionManager:ft("interactionManager"),migrator:ft("migrator"),operationManager:ft("operationManager"),triggerManager:ft("triggerManager")}},Ei=()=>{try{vn.install(rl())}catch{}const e=new pc(vn),t=new Sc(vn);return{pluginManager:vn,vizManager:e,colorManager:t}},ct=m.createContext(Ei());try{vn.install(rl())}catch{}const $i=m.createContext(null);function sr(e){const t=m.useContext($i),n=Q.useCreation(()=>e.configure(t||new kr),[e.configure]),r=Q.usePrevious(n);return r&&r!==n&&r.dispose(),i($i.Provider,{value:n,children:e.children})}function il(){return m.useContext($i)}const O1=({description:e,isDescriptionEmpty:t})=>t?null:i(s.Tooltip,{color:"white",label:i(Yn,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:i(s.Box,{sx:{height:"16px",alignSelf:"center"},children:i(E.IconInfoCircle,{size:16,color:"gray"})})}),B1=k.observer(({label:e,config:{default_value:t,description:n,isDescriptionEmpty:r,...a},value:o,onChange:l})=>p(s.Box,{children:[i(s.Text,{children:" "}),i(s.Checkbox,{label:p(s.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[i(s.Box,{sx:{flexGrow:1},children:e}),i(O1,{description:n,isDescriptionEmpty:r})]}),checked:o||!1,onChange:u=>l(u.currentTarget.checked),...a,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),al=k.observer(({label:e,config:t,value:n=[null,null],onChange:r})=>{const{inputFormat:a,...o}=t,l=Array.isArray(n)?n.map(f=>f?U(f).toDate():null):[null,null],u=f=>{r(f.map(h=>h&&U(h).format(a)))},c=t.getMinDate(l[0]),d=t.getMaxDate(l[0]);return i(Ru.DatePickerInput,{type:"range",label:e,value:l,onChange:u,icon:i(I.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:c,maxDate:d,valueFormat:a,styles:{input:{borderColor:"#e9ecef"}},...o})}),V1=s.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-select.rc-select-open":{borderColor:"#228be6 !important",".rc-select-selection-overflow-item-rest":{display:"none"},".rc-select-selection-overflow-item-suffix":{display:"block"}},".rc-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-select-selection-search-mirror":{display:"none"},".rc-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,backgroundColor:"#fff",border:"1px solid #e9ecef",marginTop:6,padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px","&.rc-select-dropdown-slide-up-leave-active":{display:"none"},".rc-select-item-empty":{padding:"8px 12px"},".rc-select-item-option":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px 8px 2px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},flexDirection:"row-reverse",".rc-select-item-option-state":{flexGrow:0,flexShrink:0,width:"30px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},".rc-select-item-option-content":{width:"calc(100% - 30px)",overflow:"hidden",'div[data-role="label"]':{overflowWrap:"break-word"}}},".rc-virtual-list-holder-inner":{alignItems:"flex-start"}}})),sl=({errorMessage:e})=>e?i(s.Text,{color:"red",size:12,children:e}):i(s.Text,{color:"dimmed",size:12,children:"Not found"}),N1=({disabled:e,classNames:t,styles:n,unstyled:r,radius:a,style:o,label:l,value:u,onChange:c,options:d,errorMessage:f,required:h})=>{const{classes:g,cx:y}=V1({radius:a},{name:"MultiSelectWidget",classNames:t,styles:n,unstyled:r}),[C,w]=m.useState(!1),_=$=>{w($)},D=C&&(u==null?void 0:u.length)>0,[M,O]=m.useState(""),G=m.useMemo(()=>{if(!M)return d;const $=M.toLowerCase(),L=A=>{var N;return((N=A.description)==null?void 0:N.toLowerCase().includes($))||A.label.toLowerCase().includes($)};return d.filter(L)},[M,d]);return p(s.Stack,{spacing:3,children:[p(s.Group,{position:"apart",children:[p(s.Text,{className:g.label,children:[l,h&&i("span",{className:g.required,"aria-hidden":"true",children:"*"})]}),D&&i(s.Tooltip,{label:`${u.length} selected`,children:i(s.Badge,{children:u.length})})]}),i(Ha,{disabled:e,allowClear:!0,className:y(g.root,"check-select"),dropdownClassName:y(g.dropdown,""),onDropdownVisibleChange:_,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:o,clearIcon:()=>i(s.CloseButton,{}),value:u,onChange:c,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:i(sl,{errorMessage:f}),maxTagTextLength:10,maxTagPlaceholder:$=>`${$.length} selected`,searchValue:M,onSearch:O,filterOption:!1,children:G.map($=>p(Ha.Option,{title:$.label,children:[i(s.Text,{size:"sm","data-role":"label",children:$.label}),$.description&&i(s.Text,{size:"xs",color:"dimmed","data-role":"description",children:$.description})]},$.value))})]})},q1=k.observer(({label:e,config:t,value:n,onChange:r})=>{const a=ye(),o=!!t.options_query_id,{state:l,error:u}=a.getDataStuffByID(t.options_query_id),c=l==="loading",d=t.min_width?t.min_width:"200px",f=o?c:!1,h=g=>r(g,!1);return i(N1,{label:e,options:t.options,style:{minWidth:"160px",width:d,maxWidth:f?d:"unset",borderColor:"#e9ecef"},disabled:f,value:n,onChange:h,errorMessage:u,required:t.required})}),F1=m.forwardRef(({label:e,description:t,...n},r)=>i("div",{ref:r,...n,children:i(s.Group,{noWrap:!0,children:p("div",{children:[i(s.Text,{size:"sm","data-role":"label",children:e}),i(s.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),G1=k.observer(({label:e,config:t,value:n,onChange:r})=>{const a=ye(),o=!!t.options_query_id,{state:l,error:u}=a.getDataStuffByID(t.options_query_id),c=l==="loading";return i(s.Select,{label:e,data:t.options,disabled:o?c:!1,value:n,onChange:r,error:!!u,placeholder:u,maxDropdownHeight:500,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"}},itemComponent:F1})});function W1({label:e,config:t,value:n,onChange:r}){return i(s.TextInput,{label:e,value:n||"",onChange:a=>r(a.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const j1=({rotate:e,onClick:t})=>i("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:i("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),R1=({expanded:e,isLeaf:t,value:n,onClick:r,...a})=>(n==="0-0-value"&&console.log(a),t?i("span",{style:{width:"14px",display:"inline-block"}}):i(j1,{rotate:e?"0":"-90",onClick:r,...a})),Y1=({onClick:e})=>p("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[i("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),i("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),i("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),i("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),Q1=({onClick:e,...t})=>i(Y1,{onClick:e,...t}),U1=s.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),K1=({disabled:e,classNames:t,styles:n,unstyled:r,radius:a,style:o,label:l,value:u,onChange:c,treeData:d,errorMessage:f,required:h,treeCheckStrictly:g})=>{const{classes:y,cx:C}=U1({radius:a},{name:"FilterTreeSelectWidget",classNames:t,styles:n,unstyled:r}),[w,_]=m.useState(!1),D=O=>{_(O)},M=w&&(u==null?void 0:u.length)>0;return p(s.Stack,{spacing:3,children:[p(s.Group,{position:"apart",children:[p(s.Text,{className:y.label,children:[l,h&&i("span",{className:y.required,"aria-hidden":"true",children:"*"})]}),M&&i(s.Tooltip,{label:`${u.length} selected`,children:i(s.Badge,{children:u.length})})]}),i(es,{disabled:e,allowClear:!0,treeCheckStrictly:g,className:C(y.root,"check-select"),dropdownClassName:C(y.dropdown,""),onDropdownVisibleChange:D,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,listHeight:510,treeLine:!0,clearIcon:()=>i(s.CloseButton,{}),switcherIcon:R1,treeIcon:Q1,maxTagTextLength:10,value:u,treeData:d,notFoundContent:i(sl,{errorMessage:f}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:es.SHOW_PARENT,onChange:c,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:O=>`${O.length} selected`})]})},X1=k.observer(({label:e,config:t,value:n,onChange:r})=>{const{treeData:a,treeDataLoading:o,errorMessage:l}=t,u=t.min_width?t.min_width:"200px",d=!!t.options_query_id?o:!1;return i(K1,{disabled:d,style:{minWidth:"160px",width:u,maxWidth:d?u:"unset",borderColor:"#e9ecef"},value:n,onChange:f=>r(f,!1),treeData:a,errorMessage:l,label:e,required:t.required,treeCheckStrictly:t.treeCheckStrictly})}),J1=k.observer(({filter:{type:e,config:t,key:n,...r},formFieldProps:a})=>{switch(e){case"select":return i(G1,{...r,...a,config:t});case"multi-select":return i(q1,{...r,...a,config:t});case"tree-select":return i(X1,{...r,...a,config:t});case"text-input":return i(W1,{...r,...a,config:t});case"date-range":return i(al,{...r,...a,config:t});case"checkbox":return i(B1,{...r,...a,config:t});default:return null}}),Z1=k.observer(m.forwardRef(({filter:e,...t},n)=>i("div",{className:"filter-root",ref:n,children:i(Ee,{children:i(J1,{filter:e,formFieldProps:t})})}))),H1=({disabled:e})=>{const{searchButtonProps:t}=ms(),{children:n="Search",type:r,...a}=t;return i(s.Button,{color:"blue",size:"sm",type:"submit",...a,disabled:e||a.disabled,children:n})};function eS(e){const t=le();m.useEffect(()=>{var n,r;(r=(n=t.filters).updatePreviewValues)==null||r.call(n,e)},[e])}const ol=k.observer(function({view:t}){const n=ye(),{control:r,handleSubmit:a,reset:o}=v.useForm({defaultValues:n.filters.values,reValidateMode:"onBlur"}),l=v.useWatch({control:r});m.useEffect(()=>{o(n.filters.values)},[n.filters.values,o]),eS(l);const u=n.filters.visibleInView(t.id),c=m.useMemo(()=>u.every(g=>g.should_auto_submit),[u]),d=m.useMemo(()=>u.filter(g=>x.get(g,"config.required",!1)),[u]),f=m.useMemo(()=>d.length===0?!1:d.some(g=>!g.requiredAndPass(l[g.key])),[l,d]);if(u.length===0)return null;const h=(g,y)=>(C,w)=>{y(C),(g.should_auto_submit||w)&&n.filters.setValueByKey(g.key,C)};return i("form",{onSubmit:a(n.filters.setValues),children:p(s.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:c?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[i(s.Group,{align:"flex-start",children:u.map(g=>i(v.Controller,{name:g.key,control:r,render:({field:y})=>i(Z1,{filter:g,value:y.value,onChange:h(g,y.onChange)})},g.id))}),!c&&i(s.Group,{sx:{alignSelf:"flex-end"},children:i(H1,{disabled:f})})]})})}),tS={viewPanelInFullScreen:x.noop,inFullScreen:!1},or=m.createContext(tS),ll=b.types.model("MockContextMeta",{current:b.types.optional(b.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function ul(e){return{current:e}}const nS=b.types.model("PanelLayoutMeta",{x:b.types.number,y:b.types.maybeNull(b.types.number),w:b.types.number,h:b.types.number,moved:b.types.optional(b.types.boolean,!1),static:b.types.optional(b.types.boolean,!1)}).views(e=>({get json(){const{x:t,y:n,w:r,h:a,moved:o}=e;return{h:a,w:r,x:t,y:n===null?0:n,moved:o,static:e.static}}})).actions(e=>({set(t){const{x:n,y:r,w:a,h:o,moved:l}=t;e.x=n,e.y=r,e.w=a,e.h=o,e.moved=!!l,e.static=!!t.static},setWidth(t){e.w=t},setHeight(t){e.h=t}})),rS=b.types.model("PanelStyleBorderMeta",{enabled:b.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),iS=b.types.model("PanelStyleMeta",{border:rS}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),aS=b.types.model("VariableMeta",{name:b.types.string,size:b.types.string,weight:b.types.string,color:b.types.union(b.types.model({type:b.types.literal("static"),staticColor:b.types.string}),b.types.model({type:b.types.literal("continuous"),valueRange:b.types.array(b.types.number),colorRange:b.types.array(b.types.string)}),b.types.model({type:b.types.literal("piecewise")})),formatter:b.types.model({output:b.types.enumeration("Output",["number","percent"]),average:b.types.optional(b.types.boolean,!1),mantissa:b.types.number,trimMantissa:b.types.optional(b.types.boolean,!1)}),data_field:b.types.string,aggregation:b.types.union(b.types.model({type:b.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:b.types.frozen()}),b.types.model({type:b.types.literal("quantile"),config:b.types.model({p:b.types.number})}),b.types.model({type:b.types.literal("custom"),config:b.types.model({func:b.types.string})}))}).views(e=>({get json(){const{name:t,size:n,weight:r,color:a,formatter:o,data_field:l,aggregation:u}=e;return x.cloneDeep({name:t,size:n,color:a,weight:r,formatter:o,data_field:l,aggregation:u})}})),sS=b.types.model("PanelVizMeta",{type:b.types.string,conf:b.types.frozen()}).views(e=>({get json(){return{conf:e.conf,type:e.type}}})).actions(e=>({setType(t){e.type=t},setConf(t){e.conf=t}})),oS=b.types.model("PanelTitleMeta",{show:b.types.optional(b.types.boolean,!0)}).views(e=>({get json(){const{show:t}=e;return{show:t}}})).actions(e=>({setShow(t){e.show=t}})),lS=b.types.model({id:b.types.string,name:b.types.optional(b.types.string,""),title:oS,description:b.types.string,layout:nS,queryIDs:b.types.array(b.types.string),viz:sS,style:iS,variables:b.types.optional(b.types.array(aS),[])}).views(e=>({get json(){const{id:t,name:n,title:r,description:a,queryIDs:o}=e;return{id:t,viz:e.viz.json,name:n,style:e.style.json,title:r,layout:e.layout.json,queryIDs:[...o],variables:e.variables.map(l=>l.json),description:a}},get queryIDSet(){return new Set(e.queryIDs)}})).actions(e=>({setID(t){e.id=t},setName(t){e.name=t},setDescription(t){e.description=t},addQueryID(t){e.queryIDSet.has(t)||e.queryIDs.push(t)},removeQueryID(t){if(!e.queryIDSet.has(t))return;const n=new Set(e.queryIDSet);n.delete(t),e.queryIDs=b.cast(Array.from(n))},setQueryIDs(t){e.queryIDs=b.cast(t)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)}})),lr=e=>x.cloneDeepWith(e,(t,n)=>{if(n!==void 0&&t)return te.toJS(t)});var Ne=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e))(Ne||{});const uS=b.types.model("QueryMeta",{id:b.types.string,name:b.types.string,type:b.types.enumeration("DataSourceType",[Ne.Postgresql,Ne.MySQL,Ne.HTTP]),key:b.types.string,sql:b.types.string,pre_process:b.types.optional(b.types.string,""),post_process:b.types.optional(b.types.string,""),run_by:b.types.optional(b.types.array(b.types.string),[]),react_to:b.types.optional(b.types.array(b.types.string),[])}).views(e=>({get valid(){return e.id&&e.type&&e.key&&e.name?e.type===Ne.HTTP?!!e.pre_process:!!e.sql:!1},get json(){const{id:t,name:n,type:r,key:a,sql:o,run_by:l,react_to:u,pre_process:c,post_process:d}=e;return lr({id:t,key:a,sql:o,name:n,type:r,run_by:l,react_to:u,pre_process:c,post_process:d})}})).actions(e=>({setName(t){e.name=t},setKey(t){e.key=t},setType(t){e.type=t},setSQL(t){e.sql=t},setRunBy(t){e.run_by.length=0,e.run_by.push(...t)},setReactTo(t){e.react_to.length=0,e.react_to.push(...t)},setPreProcess(t){e.pre_process=t},setPostProcess(t){e.post_process=t}})),cS=b.types.model("SQLSnippetMeta",{key:b.types.string,value:b.types.string}).views(e=>({get json(){const{key:t,value:n}=e;return{key:t,value:n}}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.value=t}}));var ve=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(ve||{});const cl=b.types.model("FilterCheckboxConfigMeta",{_name:b.types.literal("checkbox"),description:b.types.optional(b.types.string,""),default_value:b.types.boolean}).views(e=>({get json(){const{_name:t,description:n,default_value:r}=e;return{_name:t,description:n,default_value:r}},get isDescriptionEmpty(){const{description:t}=e;return t===""||t==="<p></p>"}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDescription(t){e.description=t}})),dS=()=>cl.create({_name:"checkbox",description:"",default_value:!1});function dl(e,t){return e.map(n=>{try{return n?U.tz(n,"UTC").format(t):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}const pS=b.types.model("FilterDateRangeConfigMeta",{_name:b.types.literal("date-range"),required:b.types.boolean,inputFormat:b.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:b.types.optional(b.types.array(b.types.union(b.types.string,b.types.null)),[null,null]),clearable:b.types.boolean,max_days:b.types.optional(b.types.number,0),allowSingleDateInRange:b.types.optional(b.types.boolean,!1)}).views(e=>({get json(){const{_name:t,max_days:n,required:r,clearable:a,inputFormat:o,default_value:l,allowSingleDateInRange:u}=e;return{_name:t,max_days:n,required:r,clearable:a,inputFormat:o,default_value:dl(l,o),allowSingleDateInRange:u}},truthy(t){return Array.isArray(t)&&t.length===2&&t.every(n=>!!n)}})).views(e=>({getMaxDate(t){const{max_days:n}=e;if(!(!n||!t))return U(t).startOf("day").add(n,"days").toDate()},getMinDate(t){const{max_days:n}=e;if(!(!n||!t))return U(t).startOf("day").subtract(n,"days").toDate()}})).actions(e=>({setFilterValue(t){try{const n=b.getParent(e);b.getRoot(e).filters.setValueByKey(n.key,t)}catch(n){console.error(n)}}})).actions(e=>({setRequired(t){e.required=t},setClearable(t){e.clearable=t},setInputFormat(t){e.inputFormat=t},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t),e.setFilterValue(t)},setMaxDays(t){e.max_days=t,t>0&&(e.clearable=!0)},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),pl=b.types.snapshotProcessor(pS,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>n===null?null:U.tz(n,"UTC").toISOString())}},postProcessor(e){const{default_value:t,...n}=e;return{...n,default_value:dl(t,n.inputFormat)}}}),hS=()=>pl.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),fS=b.types.model({label:b.types.string,value:b.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),Li=b.types.model("FilterConfigModel_BaseSelect",{static_options:b.types.optional(b.types.array(fS),[]),options_query_id:b.types.optional(b.types.string,""),default_selection_count:b.types.optional(b.types.number,0),required:b.types.optional(b.types.boolean,!1)}).views(e=>({get usingQuery(){return!!e.options_query_id}})).views(e=>({get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:n,error:r}=b.getRoot(e).content.getDataStuffByID(e.options_query_id);return n==="idle"?Array.isArray(t)?t:[]:[]}})).actions(e=>({setRequired(t){e.required=t},addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},setDefaultSelectionCount(t){e.default_selection_count=t},setOptionsQueryID(t){e.options_query_id=t??""}})),hl=b.types.compose("FilterMultiSelectConfigMeta",b.types.model({_name:b.types.literal("multi-select"),min_width:b.types.optional(b.types.string,""),default_value:b.types.optional(b.types.array(b.types.string),[])}),Li).views(e=>({get json(){const{_name:t,default_value:n,required:r,min_width:a,static_options:o,options_query_id:l,default_selection_count:u}=e;return lr({_name:t,required:!!r,min_width:a,default_value:n,static_options:o,options_query_id:l,default_selection_count:u})},get default_selection(){return e.usingQuery?e.options.slice(0,e.default_selection_count).map(t=>t.value):e.default_value},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=b.cast(t)},setMinWidth(t){e.min_width=t},setDefaultSelection(){const t=b.getRoot(e).content.filters,n=b.getParent(e).key;t.setValueByKey(n,e.default_selection)}})).actions(e=>({afterCreate(){b.addDisposer(e,te.reaction(()=>te.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),gS=()=>hl.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),fl=b.types.compose("FilterConfigModel_Select",b.types.model({_name:b.types.literal("select"),default_value:b.types.string,width:b.types.optional(b.types.string,"")}),Li).views(e=>({get json(){const{_name:t,default_value:n,required:r,width:a,static_options:o,options_query_id:l,default_selection_count:u}=e;return lr({_name:t,width:a,required:r,default_value:n,static_options:o,options_query_id:l,default_selection_count:u})},truthy(t){return!!t},getSelectOption(t){return e.options.find(n=>n.value===t)},get default_selection(){return e.usingQuery?e.default_selection_count>0&&e.options.length>0?e.options[0].value:"":e.default_value}})).actions(e=>({setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t},setDefaultSelection(){const t=b.getRoot(e).content.filters,n=b.getParent(e).key;t.setValueByKey(n,e.default_selection)}})).actions(e=>({afterCreate(){b.addDisposer(e,te.reaction(()=>te.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),mS=()=>fl.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),gl=b.types.model("FilterTextInputConfigMeta",{_name:b.types.literal("text-input"),required:b.types.boolean,default_value:b.types.string}).views(e=>({get json(){const{_name:t,required:n,default_value:r}=e;return{_name:t,required:n,default_value:r}},truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),ml=()=>gl.create({_name:"text-input",required:!1,default_value:""});function yS(e){return Yu.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function bS(e){return e.map(t=>{const{label:n,description:r,...a}=t,o={...a,filterBasis:`${n}___${r??""}`,description:r,label:n};return r&&(o.label=m.createElement("div",{},[m.createElement(s.Text,{key:0,title:t.label},t.label),m.createElement(s.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description},t.description)])),o})}const yl=b.types.compose("FilterTreeSelectConfigMeta",b.types.model({_name:b.types.literal("tree-select"),min_width:b.types.optional(b.types.string,""),default_value:b.types.optional(b.types.array(b.types.string),[]),treeCheckStrictly:b.types.optional(b.types.boolean,!1)}),Li).views(e=>({get json(){const{_name:t,default_value:n,required:r,min_width:a,static_options:o,options_query_id:l,default_selection_count:u,treeCheckStrictly:c}=e;return{_name:t,required:!!r,min_width:a,default_value:n,static_options:o,options_query_id:l,treeCheckStrictly:c,default_selection_count:u}},get treeData(){const{data:t}=b.getRoot(e).content.getDataStuffByID(e.options_query_id),n=bS(t);return yS(n)},get errorMessage(){const{error:t}=b.getRoot(e).content.getDataStuffByID(e.options_query_id);return t},get treeDataLoading(){const{state:t}=b.getRoot(e).content.getDataStuffByID(e.options_query_id);return t==="loading"},get defaultSelection(){const{default_selection_count:t}=e;return t?this.treeData.slice(0,t).map(r=>r.value):[]},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=b.cast(t)},setMinWidth(t){e.min_width=t},setTreeCheckStrictly(t){e.treeCheckStrictly=t},applyDefaultSelection(){const t=b.getParent(e,1).key;b.getRoot(e).content.filters.setValueByKey(t,e.defaultSelection)},afterCreate(){b.addDisposer(e,te.reaction(()=>JSON.stringify(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!0,delay:0}))}})),vS=()=>yl.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),bl=b.types.model("FilterMeta",{id:b.types.identifier,key:b.types.string,label:b.types.string,order:b.types.number,visibleInViewsIDs:b.types.array(b.types.string),auto_submit:b.types.optional(b.types.boolean,!1),type:b.types.enumeration("DashboardFilterType",[ve.Select,ve.MultiSelect,ve.TreeSelect,ve.TextInput,ve.Checkbox,ve.DateRange]),config:b.types.union(fl,hl,yl,gl,cl,pl)}).views(e=>({get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==ve.TreeSelect},get auto_submit_supported(){return[ve.Select,ve.Checkbox,ve.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:n,label:r,order:a,visibleInViewsIDs:o,auto_submit:l,type:u,config:c}=e;return{id:t,key:n,type:u,label:r,order:a,config:c.json,auto_submit:l,visibleInViewsIDs:te.toJS(o)}},get visibleInViewsIDSet(){return new Set(e.visibleInViewsIDs)},get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return x.get(e.config,"required",!1)?x.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setLabel(t){e.label=t},setOrder(t){e.order=t},setType(t){switch(t){case ve.Select:e.config=mS();break;case ve.MultiSelect:e.config=gS();break;case ve.TreeSelect:e.config=vS();break;case ve.TextInput:e.config=ml();break;case ve.Checkbox:e.config=dS();break;case ve.DateRange:e.config=hS();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t}}));var j=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(j||{});const vl=b.types.model("ViewDivisionConfig",{_name:b.types.literal(j.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})),xS=()=>vl.create({_name:j.Division}),wS=b.types.model("CustomModalTitleModel",{enabled:b.types.optional(b.types.boolean,!1),func_content:b.types.optional(b.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:n}=e;return{enabled:t,func_content:n}},get value(){const{enabled:t,func_content:n}=e,r=b.getParent(e,2),a=b.getRoot(e);if(!t)return r.name;try{const o={filters:a.content.filters.values,context:a.context.current};return new Function(`return ${n}`)()(o)}catch(o){return console.error(o),r.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:n}){e.enabled=t,e.func_content=n}})),Pi={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
440
440
|
`)},xl=b.types.model("ViewModalConfig",{_name:b.types.literal(j.Modal),width:b.types.string,height:b.types.string,custom_modal_title:b.types.optional(wS,Pi)}).views(e=>({get json(){const{_name:t,width:n,height:r,custom_modal_title:a}=e;return{_name:t,width:n,height:r,custom_modal_title:a.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),CS=()=>xl.create({_name:j.Modal,width:"90vw",height:"90vh"}),SS=b.types.model("ViewTabsTabModel",{id:b.types.identifier,name:b.types.string,view_id:b.types.string,color:b.types.optional(b.types.string,"")}).views(e=>({get json(){const{id:t,name:n,view_id:r,color:a}=e;return{id:t,name:n,color:a,view_id:r}}})).actions(e=>({setName(t){e.name=t},setViewID(t){e.view_id=t},setColor(t){e.color=t}})),wl=b.types.model("ViewTabsConfig",{_name:b.types.literal(j.Modal),tabs:b.types.optional(b.types.array(SS),[]),variant:b.types.optional(b.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:b.types.optional(b.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:b.types.optional(b.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:n,orientation:r,tabs:a,grow:o}=e;return{grow:o,tabs:a.map(l=>l.json),_name:t,variant:n,orientation:r}}})).actions(e=>({setVariant(t){e.variant=t},setOrientation(t){e.orientation=t},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=b.cast(t)},addTab(){const t=_e.randomId(),n={id:t,name:t,view_id:""};e.tabs.push(n)},removeTab(t){e.tabs.splice(t,1)}})),_S=()=>wl.create({_name:j.Modal,tabs:[]}),kS=b.types.model({id:b.types.identifier,name:b.types.string,type:b.types.enumeration("EViewComponentType",[j.Division,j.Modal,j.Tabs]),config:b.types.union(vl,xl,wl),panelIDs:b.types.optional(b.types.array(b.types.string),[])}).views(e=>({get json(){const{id:t,name:n,type:r,config:a}=e;return{id:t,name:n,type:r,config:a.json,panelIDs:e.panelIDs}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case j.Division:e.config=xS();break;case j.Modal:e.config=CS();break;case j.Tabs:e.config=_S();break}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},removePanelID(t){const n=e.panelIDs.filter(r=>r!==t);e.panelIDs.length=0,e.panelIDs.push(...n)}})),Cl=b.types.model("DataSourceMetaModel",{id:b.types.string,type:b.types.enumeration("DataSourceType",[Ne.HTTP,Ne.MySQL,Ne.Postgresql]),key:b.types.string,config:b.types.frozen()}),TS=b.types.model("DataSourcesMetaModel",{list:b.types.optional(b.types.array(Cl),[])}).views(e=>({find({type:t,key:n}){return e.list.find(r=>r.key===n&&r.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),DS=b.types.model({id:b.types.string,content:b.types.string,create_time:b.types.string,update_time:b.types.string,is_preset:b.types.boolean}),Sl=b.types.model("GlobalSQLSnippetsMeta",{list:b.types.optional(b.types.array(DS),[])}).views(e=>({find(t){return e.list.find(n=>n.id===t)},get options(){return e.list.map(t=>({value:t.id,label:t.id}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),Oi=b.types.model("ContextMeta",{current:b.types.optional(b.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function _l(e){return Oi.create({current:e})}const IS=b.types.compose("ViewRenderModel",kS,b.types.model({tab:b.types.optional(b.types.string,"")})).views(e=>({get defaultTab(){if(e.type!==j.Tabs)return"";const t=e.config;return t.tabs.length>0?t.tabs[0].id:""},get tabViewID(){var n;return e.type!==j.Tabs?"":((n=e.config.tabs.find(r=>r.id===e.tab))==null?void 0:n.view_id)??""},get contentModel(){return b.getParent(e,3)},get panels(){if(e.type!==j.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs).panels;const t=this.tabViewID;return this.contentModel.views.findByID(t).panels},get renderViewIDs(){const t=[e.id];return e.type===j.Tabs&&t.push(this.tabViewID),t}})).actions(e=>({setTab(t){e.tab=t??""},afterCreate(){b.addDisposer(e,te.reaction(()=>e.defaultTab,t=>this.setTab(t),{fireImmediately:!0,delay:0}))}})),kl=b.types.model("ViewsRenderModel",{current:b.types.optional(b.types.array(IS),[]),visibleViewIDs:b.types.array(b.types.string)}).views(e=>({get json(){return e.current.map(t=>lr(t.json))},get idMap(){const t=new Map;return e.current.forEach(n=>{t.set(n.id,n)}),t},findByID(t){return e.current.find(n=>n.id===t)},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:n})=>n===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:n})=>t.has(n))}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(r=>r)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const n=e.visibleViewIDs.findIndex(r=>r===t);n!==-1&&e.visibleViewIDs.splice(n,1)}}));function MS(e){const t=e.length>0?[e[0].id]:[];return{current:e.map(r=>{const{_name:a=r.type}=r.config;return{...r,config:{...r.config,_name:a},panelIDs:r.panelIDs}}),visibleViewIDs:t}}const Tl=lS.views(e=>({get contentModel(){return b.getRoot(e).content}})).views(e=>({get queries(){return e.contentModel.queries.findByIDSet(e.queryIDSet)},get data(){return this.queries.reduce((t,n)=>(t[n.id]=n.data,t),{})},get dataLoading(){return this.queries.some(t=>t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(o=>!o.runByConditionsMet);if(t.length===0)return"";const n=new Set,r=new Set;t.forEach(o=>{const l=o.conditionNames;l.context.forEach(u=>n.add(u)),l.filters.forEach(u=>r.add(u))});const a=[];return n.size>0&&(console.log(n),a.push(`context: ${Array.from(n).join(", ")}`)),r.size>0&&a.push(`filter${r.size>1?"s":""}: ${Array.from(r).join(", ")}`),a.length===2&&a.splice(1,0,"and"),a.unshift("Waiting for"),a.join(" ")},get queryErrors(){return this.queries.map(t=>t.error).filter(t=>!!t)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading}})).actions(e=>({refreshData(){e.queries.forEach(t=>t.fetchData(!0))},downloadData(){b.getRoot(e).content.queries.downloadDataByQueryIDs(e.queryIDs)}}));function AS(e){return{id:e,name:e,layout:{x:0,y:1/0,w:18,h:300},title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:Ci.name,conf:Ci.createConfig()},style:{border:{enabled:!0}}}}const Dl=b.types.model("PanelsRenderModel",{list:b.types.optional(b.types.array(Tl),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(n=>n.id===t)},get idMap(){const t=new Map;return e.list.forEach(n=>{t.set(n.id,n)}),t}})).views(e=>({panelsByIDs(t){const n=[];t.forEach(a=>{const o=e.idMap.get(a);o?n.push(o):console.warn(`Panel is not found, id:${a}`)});const r=n.map(a=>({...a.layout.json,i:a.id}));return{panels:n,layouts:r}}}));function Il(e,t){if(e===void 0)return e;if(t._name==="date-range")try{const[...n]=e;return n.map(r=>r===null?r:U.tz(r,"UTC").format(t.inputFormat)??r)}catch(n){return console.error(n),e}return e}function zS(e){return e.reduce((t,n)=>(t[n.key]=Il(n.config.default_value,n.config),t),{})}const Ml=b.types.model("FiltersRenderModel",{current:b.types.optional(b.types.array(bl),[]),values:b.types.optional(b.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},get inOrder(){return x.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return x.sortBy(e.current.filter(n=>n.visibleInViewsIDSet.has(t)),"order")},get firstFilterValueKey(){return Object.keys(e.values)[0]??""},get keyLabelMap(){return e.current.reduce((t,n)=>(t[n.key]=n.label,t),{})},getSelectOption(t){const n=this.findByID(t);if(!n||!("getSelectOption"in n.config))return null;const r=e.values[n.key];return n.config.getSelectOption(r)}})).actions(e=>({setValues(t){e.values=t},setValueByKey(t,n){e.values={...e.values,[t]:n}},getValueByKey(t){return e.values[t]}}));function Al(e){return{current:e,values:zS(e)}}const ES=new Qu.AsyncParser({withBOM:!0});async function zl(e){return!Array.isArray(e)||e.length===0?"":await ES.parse(e).promise()}async function $S(e,t){const n=await zl(t),r=new Blob([n],{type:"text/csv"});vr.saveAs(r,`${e}.csv`)}function El(e){const t=new Uu;e.forEach(({id:n,data:r})=>{t.file(`${n}.csv`,zl(r))}),t.generateAsync({type:"blob"}).then(n=>{vr.saveAs(n,"dashboard_data.zip")})}function $l(e,t){const n=new Blob([t],{type:"application/json"});vr.saveAs(n,`${e}.json`)}function LS(e,t){return new Function(`return ${e}`)()(t,At)}function PS(e,t,n){return LS(e,{context:t,filters:n})}function OS(e,t){try{return new Function(`return ${e.config.processing.pre}`)()(t,At)}catch(n){return console.error(n),t}}function BS(e,t){return new Function(`return ${e.config.processing.post}`)()(t,At)}function VS(e,t,n){return e?new Function(`return ${e}`)()(t,At,n):t}const NS=uS.views(e=>({get conditionOptions(){if(!b.isAlive(e))return[];const t=b.getRoot(e).content,{context:n}=t.payloadForSQL,r=Object.keys(n).map(o=>({group:"Context",label:o,value:`context.${o}`,description:void 0})),a=t.filters.keyLabelOptions.map(o=>({group:"Filters",label:o.label,value:`filters.${o.value}`,description:o.value}));return[...r,...a]},get unmetRunByConditions(){if(!b.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const n=b.getRoot(e).content.payloadForSQL;return t.filter(r=>{const a=x.get(n,r);return Array.isArray(a)?a.length===0:typeof a=="number"?Number.isNaN(a):!a})}})).views(e=>({get reQueryKey(){const{react_to:t=[]}=e;if(t.length===0)return"";const n=b.getRoot(e).content.payloadForSQL,r=[...t].reduce((a,o)=>(a[o]=x.get(n,o),a),{});return JSON.stringify(r)},get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=b.getRoot(e).content.filters,n=e.unmetRunByConditions.filter(a=>a.startsWith("context.")).map(a=>a.split("context.")[0]),r=e.unmetRunByConditions.filter(a=>a.startsWith("filters.")).map(a=>x.get({filters:t},a)).filter(a=>!!a);return{context:n,filters:r}},get queries(){return b.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)}})),qS=b.types.compose("QueryRenderModel",NS,b.types.model({state:b.types.optional(b.types.enumeration(["idle","loading","error"]),"idle"),data:b.types.optional(b.types.frozen([]),[]),error:b.types.frozen()})).views(e=>({get rootModel(){return b.getRoot(e)},get contentModel(){return this.rootModel.content},get payload(){return this.contentModel.payloadForSQL},get formattedSQL(){return wr(e.sql,this.payload)},get typedAsSQL(){return[Ne.Postgresql,Ne.MySQL].includes(e.type)},get typedAsHTTP(){return[Ne.HTTP].includes(e.type)},get datasource(){const{key:t,type:n}=e;return this.rootModel.datasources.find({type:n,key:t})},get httpConfigString(){const{context:t,filters:n}=this.payload,{name:r,pre_process:a}=e.json,o=PS(a,t,n);return console.groupCollapsed(`Request config for: ${r}`),console.log(o),console.groupEnd(),JSON.stringify(o)},get additionalQueryInfo(){return this.contentModel.getAdditionalQueryInfo(e.id)}})).views(e=>({get stateMessage(){if(e.state!=="idle")return"";if(!e.runByConditionsMet){const{context:t,filters:n}=e.conditionNames;if(t.length===0&&n.length===0)return"Waiting";const r=[];return t.length>0&&r.push(`context: ${t.join(", ")}`),n.length>0&&r.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),r.length===2&&r.splice(1,0,"and"),r.unshift("Waiting for"),r.join(" ")}return e.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:b.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const n=e.payload;e.data=yield*b.toGenerator(uc({payload:n,name:e.name,query:e.json,additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(!pt.isCancel(n)){e.data=[];const r=x.get(n,"message","unkown error");e.error=x.get(n,"response.data.detail.message",r),e.state="error"}}}}),runHTTP:b.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{type:n,key:r,post_process:a}=e.json;let o=JSON.parse(e.httpConfigString);o=OS(e.datasource,o);const l=yield*b.toGenerator(cc({type:n,key:r,configString:JSON.stringify(o),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),u=BS(e.datasource,l),c=VS(a,u,e.contentModel.dashboardState);e.data=c,e.state="idle",e.error=null}catch(n){if(console.error(n),!pt.isCancel(n)){e.data=[];const r=x.get(n,"message","unkown error");e.error=x.get(n,"response.data.detail.message",r),e.state="error"}}}})})).actions(e=>({fetchData:t=>{if(!e.inUse&&!t){console.debug(`Skipping query[${e.name}]`);return}return e.typedAsHTTP?e.runHTTP():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){b.addDisposer(e,te.reaction(()=>{var n;return e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(n=e.datasource)==null?void 0:n.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},()=>e.fetchData(!1),{fireImmediately:!0,delay:0}))}})),Ll=b.types.model("QueriesRenderModel",{current:b.types.optional(b.types.array(qS),[])}).views(e=>({get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get contentModel(){return b.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:n}=this.contentModel,r=[];t.visibleViews.forEach(l=>{l.panels.forEach(u=>{r.push(...u.queryIDs)})});const a=x.uniq(t.visibleViews.map(l=>l.renderViewIDs).flat());n.current.forEach(l=>{const u=x.get(l,"config.options_query_id");if(!u)return;a.some(d=>l.visibleInViewsIDSet.has(d))&&r.push(u)});const o=new Set(r);return console.debug("QueryIDs:",o),o},isQueryInUse(t){return this.visibleQueryIDSet.has(t)}})).actions(e=>({downloadAllData(){const t=e.current.map(({name:n,data:r})=>({id:n,data:r}));El(t)},downloadDataByQueryIDs(t){const n=new Set(t),r=e.current.filter(a=>n.has(a.id)).map(({name:a,data:o})=>({id:a,data:o}));El(r)},downloadDataByQueryID(t){const n=e.findByID(t);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:r,data:a}=n;$S(r,a)},refetchDataByQueryID(t){const n=e.findByID(t);if(!n){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return n.fetchData(!0)}}));function FS(e){return{current:e}}const GS=cS.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!b.getParent(e,2).findByKey(t)}})),Pl=b.types.model("SQLSnippetsRenderModel",{current:b.types.optional(b.types.array(GS),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,n)=>(t[n.key]=n.value,t),{})},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(n=>n.key===t)}}));function WS(e){return{current:e}}function ur(e,t,n,r){return e.reduce((a,o)=>{try{a[o[t]]=xr(o[n],r)}catch(l){a[o[t]]=l.message}return a},{})}class jS{constructor(t){q(this,"origin");q(this,"copy");this.origin=t,this.copy=b.clone(t),te.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!x.isEqual(b.getSnapshot(this.origin),b.getSnapshot(this.copy))}commit(){b.applySnapshot(this.origin,b.getSnapshot(this.copy))}update(t){b.applySnapshot(this.copy,t)}}const RS=e=>new jS(e),YS=k.observer(({view:e})=>{const t=ue(),n=le(),r=Fe.useModals(),{panel:a,downloadPanelScreenshot:o}=Qe(),{id:l}=a,{viewPanelInFullScreen:u,inFullScreen:c}=m.useContext(or),d=()=>{n.duplicatePanelByID(l,e.id)},f=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",l])},h=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>n.removePanelByID(l,e.id),confirmProps:{color:"red"},zIndex:320}),g=m.useCallback(()=>{u(l)},[l,u]),y=!c&&e.type!==j.Modal;return i(B,{children:i(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(s.Menu,{withinPortal:!0,children:[i(s.Menu.Target,{children:i(s.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),p(s.Menu.Dropdown,{children:[i(s.Menu.Item,{onClick:a.refreshData,icon:i(I.Refresh,{size:14}),children:"Refresh"}),i(s.Menu.Item,{onClick:a.downloadData,icon:i(I.Download,{size:14}),children:"Download Data"}),i(s.Menu.Item,{onClick:o,icon:i(E.IconCamera,{size:14}),children:"Screenshot"}),y&&i(s.Menu.Item,{onClick:g,icon:i(I.ArrowsMaximize,{size:14}),disabled:!0,children:"Full Screen"}),i(s.Divider,{label:"Edit",labelPosition:"center"}),i(s.Menu.Item,{onClick:f,icon:i(I.Settings,{size:14}),children:"Settings"}),i(s.Menu.Item,{onClick:d,icon:i(I.Copy,{size:14}),children:"Duplicate"}),i(s.Menu.Item,{color:"red",onClick:h,icon:i(I.Trash,{size:14}),children:"Delete"})]})]})})})});function QS(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const Bi=k.observer(()=>{const[e,t]=m.useState(!1),{panel:n}=Ct();return QS(n.description)?null:p(B,{children:[i(s.Modal,{opened:e,onClose:()=>t(!1),title:n.name,withCloseButton:!1,withinPortal:!0,zIndex:310,children:i(Yn,{value:n.description,styles:{root:{border:"none"},content:{padding:0}}})}),i(s.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>t(r=>!r),sx:{verticalAlign:"baseline",cursor:"pointer"},children:i(I.InfoCircle,{size:20})})})]})}),PM="",US=k.observer(function(){const{panel:t}=Ct(),{name:n,title:r}=t;return r.show?i(s.Group,{grow:!0,position:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:i(s.Text,{align:"center",lineClamp:1,className:"panel-title-text",children:n})}):null});function KS(e){const t=m.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const r=t.current;if(!r)return;const a=r.offsetWidth*2,o=r.offsetHeight*2;ts.toBlob(t.current,{bgcolor:"white",width:a,height:o,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(l=>{window.saveAs(l,`${e.title?e.title:e.viz.type}.png`)})}}}var Ol=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(Ol||{}),cr=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(cr||{});class XS{constructor(t){q(this,"vizInstance");q(this,"operationManager");q(this,"triggerManager");q(this,"vizManager");q(this,"runningMigration");q(this,"panelModel");q(this,"status","notStarted");this.panelModel=t.getRequired(be.instanceScope.panelModel),this.vizInstance=t.getRequired(be.instanceScope.vizInstance),this.operationManager=t.getRequired(be.instanceScope.operationManager),this.triggerManager=t.getRequired(be.instanceScope.triggerManager),this.vizManager=t.getRequired(be.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(t=>(this.status="done",t))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(n)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return t.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function Bl(e){const{panel:t}=Ct();return m.useCallback(n=>{const r=n.getRequired(be.vizManager),a=r.resolveComponent(e.viz.type);return n.createScoped().provideFactory(be.instanceScope.vizInstance,()=>r.getOrCreateInstance(e)).provideFactory(be.instanceScope.interactionManager,o=>{const l=o.getRequired(be.instanceScope.vizInstance);return new Or(l,a,$n)}).provideFactory(be.instanceScope.operationManager,o=>o.getRequired(be.instanceScope.interactionManager).operationManager).provideFactory(be.instanceScope.triggerManager,o=>o.getRequired(be.instanceScope.interactionManager).triggerManager).provideValue(be.instanceScope.panelModel,t).provideFactory(be.instanceScope.migrator,o=>new XS(o))},[e.viz.type,e.viz.conf])}function Vl(e){const[t,n]=m.useState(!1),r=il().getRequired(be.instanceScope.migrator);return Q.useAsyncEffect(async()=>{const a=r.status===cr.notStarted;n(r.status===cr.done),r.status===cr.notStarted&&r.runMigration().then(o=>{o===Ol.migrated&&a&&(e==null||e())}).finally(()=>{n(!0)})},[r]),t}function Nl(e,t){const n=il().getRequired(be.instanceScope.vizInstance);return m.useEffect(()=>(n.instanceData.setItem(null,t.viz.conf),n.instanceData.watchItem(null,r=>{e(r)})),[e,t.viz.type]),n}function JS({setVizConf:e,...t}){const{panel:n}=t,r=Nl(e,n),a=Vl(()=>{Tn.showNotification({title:`${n.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return Q.useAsyncEffect(async()=>{await r.instanceData.setItem(null,n.viz.conf)},[r,n.viz.type]),a?i(fc,{...t}):i(s.Text,{children:"Checking update..."})}function ZS(e){const{panel:t,setVizConf:n}=e;Nl(n,t);const{inEditMode:r}=m.useContext(zn);return Vl(()=>{r&&Tn.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?i(hc,{...e}):i(s.Text,{children:"Checking update"})}const OM="";function HS(e,t){const{vizManager:n}=m.useContext(ct),{panel:{viz:r,title:a,id:o,name:l,description:u,queryIDs:c,variables:d}}=Ct(),f={id:o,name:l,title:a,description:u,queryIDs:c,viz:r,layout:t},h=Bl(f);try{return n.resolveComponent(r.type),i(sr,{configure:h,children:i(ZS,{setVizConf:r.setConf,panel:f,data:e,variables:d,vizManager:n})})}catch(g){return console.info(x.get(g,"message")),null}}const ql=k.observer(function({data:t}){const{ref:n,width:r,height:a}=_e.useElementSize(),o=HS(t,{w:r,h:a}),l=r>0&&a>0;return i("div",{className:"viz-root",ref:n,children:i(s.Box,{sx:{width:r,height:a,overflow:"hidden"},children:l&&i(Ee,{children:o})})})}),Fl=k.observer(({panel:e})=>p(s.Stack,{children:[e.queryErrors.map((t,n)=>i(s.Text,{color:"red",size:"sm",align:"center",sx:{fontFamily:"monospace"},children:t},`${n}-${t}`)),i(s.Text,{color:"gray",align:"center",size:"sm",children:e.queryStateMessages})]})),Vi=k.observer(({panel:e})=>p(s.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[i(s.LoadingOverlay,{visible:e.dataLoading,exitTransitionDuration:0}),!e.canRenderViz&&i(Fl,{panel:e}),e.canRenderViz&&i(ql,{data:e.data})]})),e_={border:"1px solid #e9ecef"},Gl=k.observer(({panel:e,panelStyle:t,dropdownContent:n})=>{const{ref:r,downloadPanelScreenshot:a}=KS(e);return e.title.show,i(Er,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:a},children:p(s.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,ref:r,p:0,sx:{...e_,...t},children:[i(s.Box,{className:"panel-description-popover-wrapper",children:i(Bi,{})}),n,i(US,{}),i(Vi,{panel:e})]})})}),t_={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function n_(e){return e.style.border.enabled?{}:t_}const Wl=k.observer(function({panel:t,view:n}){const r=n_(t);return i(Gl,{panel:t,panelStyle:r,dropdownContent:i(YS,{view:n})})});function r_(e){return!["richText","button"].includes(e)}const i_=k.observer(({view:e})=>{const{panel:t,downloadPanelScreenshot:n}=Ct(),{id:r}=t,{viewPanelInFullScreen:a,inFullScreen:o}=m.useContext(or),l=m.useCallback(()=>{a(r)},[r,a]),u=!o&&e.type!==j.Modal;return r_(t.viz.type)?i(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(s.Menu,{withinPortal:!0,children:[i(s.Menu.Target,{children:i(s.Box,{className:"panel-dropdown-target"})}),p(s.Menu.Dropdown,{children:[i(s.Menu.Item,{onClick:t.refreshData,icon:i(I.Refresh,{size:14}),children:"Refresh"}),i(s.Menu.Item,{onClick:t.downloadData,icon:i(I.Download,{size:14}),children:"Download Data"}),i(s.Menu.Item,{onClick:n,icon:i(E.IconCamera,{size:14}),children:"Screenshot"}),u&&i(s.Menu.Item,{onClick:l,icon:i(I.ArrowsMaximize,{size:14}),children:"Full Screen"})]})]})}):null});function a_(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const Ni=k.observer(({panel:e,view:t})=>{const n=a_(e);return i(Gl,{panel:e,panelStyle:n,dropdownContent:i(i_,{view:t})})}),s_={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},jl=k.observer(function({view:t,panel:n,exitFullScreen:r}){return i(s.Modal,{opened:!0,fullScreen:!0,onClose:r,title:i(s.Button,{color:"blue",size:"xs",onClick:r,leftIcon:i(I.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:s_,children:i(s.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:i(Ni,{view:t,panel:n})})})});function Rl(e,t,n){const{panels:r}=ye(),a=e.id==="Main",[o,l]=m.useState(()=>a&&r.findByID(t)?t:null),u=m.useCallback(h=>{l(h),a&&n(h)},[a,n]),c=m.useCallback(()=>{l(null),a&&n("")},[a,n]),d=o?r.findByID(o):null;return{viewPanelInFullScreen:u,exitFullScreen:c,inFullScreen:!!d,fullScreenPanel:d}}const BM="",o_=m.forwardRef(({h:e},t)=>i(s.ActionIcon,{ref:t,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:e>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:i(I.ArrowsMove,{size:16})})),l_=m.forwardRef(({handleAxis:e,...t},n)=>i(s.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:i(I.ChevronDownRight,{size:16})})),u_=Dn.WidthProvider(Dn),c_=k.observer(({view:e,className:t="layout"})=>{const n=ye(),{panels:r,layouts:a}=n.panels.panelsByIDs(e.panelIDs),o=m.useCallback(u=>{u.forEach(({i:c,...d})=>{const f=n.panels.findByID(c);f&&f.layout.set(d)})},[n]),l=(u,c,d,f)=>{d.h<30&&(d.h=30,f.h=30),d.w<4&&(d.w=4,f.w=4)};return i(u_,{onLayoutChange:o,className:`dashboard-layout ${t}`,rowHeight:1,cols:36,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,layout:a,draggableHandle:".react-grid-customDragHandle",resizeHandle:i(l_,{}),onResize:l,children:r.map((u,c)=>p("div",{"data-grid":{...u.layout},className:"panel-grid-item",children:[i(o_,{h:u.layout.h}),i(Wl,{view:e,panel:u})]},u.id))})}),d_=Dn.WidthProvider(Dn),p_=k.observer(function({view:t,className:n="layout"}){const{panels:r,layouts:a}=ye().panels.panelsByIDs(t.panelIDs);return i(d_,{className:`dashboard-layout ${n}`,cols:36,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,layout:a,children:r.map(o=>i("div",{"data-grid":{...o.layout},className:"panel-grid-item",children:i(Ni,{view:t,panel:o})},o.id))})});function qi(e){const t=m.useRef(null);return{ref:t,downloadScreenshot:()=>{var l;const r=(l=t.current)==null?void 0:l.querySelector(".react-grid-layout");if(!r)return;const a=r.offsetWidth*2+10,o=r.offsetHeight*2+10;ts.toBlob(r,{bgcolor:"white",width:a,height:o,style:{transformOrigin:"0 0",transform:"scale(2)"}}).then(u=>{window.saveAs(u,`${e.name}.png`)})}}}const h_=k.observer(({downloadScreenShot:e})=>{const[t,{setTrue:n,setFalse:r}]=Q.useBoolean(!1),a=Mr(),o=ye(),l=()=>{const u=JSON.stringify(o.json,null,2),c=`${a.name}__${o.name}`;$l(c,u)};return p(s.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[i(s.Menu.Target,{children:i(s.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:i(s.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:n,onMouseLeave:r,sx:{opacity:t?1:.6,transform:`translateX(${t?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:i(E.IconShare3,{size:"1rem"})})})}),p(s.Menu.Dropdown,{children:[i(s.Menu.Item,{icon:i(E.IconCamera,{size:14}),onClick:e,children:"Screenshot"}),i(s.Menu.Divider,{}),i(s.Menu.Item,{icon:i(E.IconDownload,{size:14}),onClick:o.queries.downloadAllData,children:"Download Data"}),i(s.Menu.Item,{icon:i(E.IconCode,{size:14}),onClick:l,children:"Download Schema"})]})]})}),Yl=k.observer(({children:e,view:t,sx:n={}})=>{const{ref:r,downloadScreenshot:a}=qi(t);return p(B,{children:[i(s.Box,{ref:r,sx:n,children:e}),i(h_,{downloadScreenShot:a})]})}),Ql=k.observer(({downloadScreenshot:e})=>i(s.ActionIcon,{className:"download-screenshot-button",color:"blue",onClick:e,children:i(E.IconCamera,{size:14})})),f_=k.observer(({children:e,view:t})=>{const n=ye(),r=t.config,a=n.views.visibleViewIDs.includes(t.id),o=()=>n.views.rmVisibleViewID(t.id),{ref:l,downloadScreenshot:u}=qi(t);return i(s.Modal,{size:r.width,centered:!0,opened:a,onClose:o,withCloseButton:!1,title:p(s.Group,{position:"apart",px:"1rem",h:"48px",children:[i(s.Box,{children:r.custom_modal_title.value}),i(Ql,{downloadScreenshot:u})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:r.height,overflow:"auto",position:"relative"},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:i(s.Box,{ref:l,children:e})})}),g_=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},m_=k.observer(({view:e})=>{const t=ye(),n=e.config;return p(s.Tabs,{className:"render-view-tabs",variant:n.variant,orientation:n.orientation,value:e.tab,onTabChange:e.setTab,styles:{root:{height:"100%",overflow:n.orientation==="horizontal"?"hidden":"auto"},panel:{padding:n.orientation==="horizontal"?"8px 0px 8px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[i(s.Tabs.List,{grow:n.grow,children:n.tabs.map(r=>i(s.Tabs.Tab,{value:r.id,sx:g_(r),disabled:!r.view_id,children:r.name??r.id},r.id))}),n.tabs.map(r=>{const a=t.views.findByID(r.view_id);return a?i(s.Tabs.Panel,{value:r.id,children:i(dr,{view:a})},r.id):null})]})}),y_=k.observer(({view:e,children:t})=>{switch(e.type){case j.Modal:return i(f_,{view:e,children:t});case j.Tabs:return i(m_,{view:e});case j.Division:default:return i(Yl,{view:e,children:t})}}),b_=k.observer(({children:e,view:t})=>i(Yl,{sx:{paddingTop:"10px",paddingBottom:"100px"},view:t,children:e}));function Ul(e){return e.replace(/(vw|vh)/,"%")}const v_=k.observer(({children:e,view:t})=>{const n=t.config,{width:r,height:a}=m.useMemo(()=>({width:Ul(n.width),height:Ul(n.height)}),[n.width,n.height]),{ref:o,downloadScreenshot:l}=qi(t);return i(s.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:i(s.Modal,{size:n.width,opened:!0,onClose:x.noop,withCloseButton:!1,title:p(s.Group,{position:"apart",px:"1rem",h:"48px",children:[i(s.Box,{children:n.custom_modal_title.value}),i(Ql,{downloadScreenshot:l})]}),trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:r,height:a,maxHeight:a},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:i(s.Box,{ref:o,children:e})})})}),x_=({variant:e,orientation:t})=>{const n={root:{height:"100%",overflow:"hidden"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(n.tab.paddingTop="6px",n.tab.paddingBottom="6px"),t==="vertical"&&(n.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},n.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),n},w_=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},C_=k.observer(({view:e})=>{const t=Fe.useModals(),n=le(),r=m.useMemo(()=>n.views.options.filter(u=>u.type===j.Division),[e.id,n.views.options]),a=e.config,o=u=>t.openConfirmModal({title:"Delete this tab?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{a.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),l=a.tabs.length===0;return p(s.Tabs,{className:"preview-view-tabs",variant:a.variant,orientation:a.orientation,value:e.tab,onTabChange:e.setTab,styles:x_(a),children:[p(s.Tabs.List,{grow:a.grow,children:[a.tabs.map(u=>i(s.Tabs.Tab,{value:u.id,sx:w_(u),children:u.name??u.id},u.id)),i(s.Tabs.Tab,{onClick:a.addTab,value:"add",className:"add-a-tab",children:i(I.Plus,{size:18,color:"#228be6"})})]}),a.tabs.map((u,c)=>{const d=n.views.findByID(u.view_id);return p(s.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[p(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[i(s.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),p(s.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[i(s.TextInput,{label:"Tab Name",value:u.name,onChange:f=>u.setName(f.currentTarget.value)}),i(s.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:r}),i(s.ColorInput,{label:"Color",value:u.color,onChange:u.setColor,disabled:a.variant!=="default"}),d&&p(s.Button,{mt:20,variant:"gradient",leftIcon:i(E.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>n.views.setIDOfVIE(d.id),children:["Swith to View: ",d.name]}),i(s.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>o(c),disabled:l,leftIcon:i(E.IconTrash,{size:14}),children:"Delete This Tab"})]})]}),d&&i(dr,{view:d})]},u.id)})]})}),S_=k.observer(({view:e,children:t})=>{switch(e.type){case j.Modal:return i(v_,{view:e,children:t});case j.Tabs:return i(C_,{view:e});case j.Division:default:return i(b_,{view:e,children:t})}}),Kl=k.observer(function({view:t}){return i(or.Provider,{value:{viewPanelInFullScreen:x.noop,inFullScreen:!1},children:i(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:i(S_,{view:t,children:p(s.Box,{sx:{position:"relative"},children:[i(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:i(ol,{view:t})}),i(c_,{view:t})]})})})})}),dr=k.observer(function({view:t}){const{fullScreenPanelID:n,setFullScreenPanelID:r}=ws(),{viewPanelInFullScreen:a,exitFullScreen:o,inFullScreen:l,fullScreenPanel:u}=Rl(t,n,r);return i(or.Provider,{value:{viewPanelInFullScreen:a,inFullScreen:l},children:p(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===j.Modal?"0 !important":"100%"},children:[l&&i(jl,{view:t,panel:u,exitFullScreen:o}),i(y_,{view:t,children:p(s.Box,{sx:{position:"relative"},children:[!l&&i(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:i(ol,{view:t})}),!l&&i(p_,{view:t})]})})]})})});var Xl=(e=>(e.Use="use",e.Edit="edit",e))(Xl||{});const __={[j.Division]:"Division",[j.Tabs]:"Tabs",[j.Modal]:"Modal"},Jl={[j.Division]:"rgba(255, 0, 0, 0.2)",[j.Modal]:"rgba(0, 0, 0, 0.2)",[j.Tabs]:"rgba(255, 200, 100, 0.4)"},k_={[j.Division]:"#ff4000",[j.Modal]:"#000",[j.Tabs]:"#ffad18"},T_={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:j.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:"9.19.0"};function D_(e,t,n){b.addDisposer(e,b.addMiddleware(e,(r,a)=>{a(r,()=>{b.getType(r.context)===t&&r.type==="action"&&n(r.name,r.context)})}))}const Zl=b.types.compose("FiltersModel",Ml,b.types.model("FiltersModel",{previewValues:b.types.optional(b.types.frozen(),{})})).views(e=>({get options(){return e.current.map(t=>({label:t.label??t.id,value:t.id,_type:"filter"}))},get selects(){return e.current.filter(t=>t.type===ve.Select).map(t=>({label:t.label??t.id,value:t.id}))},get keyLabelOptions(){return e.current.map(t=>({label:t.label??t.key,value:t.key}))}})).actions(e=>({replace(t){e.current=b.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(r=>r.id===t);n>=0&&e.current.splice(n,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){D_(e.current,bl,(n,r)=>{if(n==="setType"){const a=Il(r.config.default_value,r.config);e.setValueByKey(r.key,a),e.updatePreviewValues({...e.previewValues,[r.key]:a})}})}return{afterCreate(){t()}}}),Hl=Ll.views(e=>({get options(){const t=e.current.map(n=>({value:n.id,label:n.name,_type:"query"}));return x.sortBy(t,n=>n.label.toLowerCase())},get sortedList(){return x.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=b.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},removeQuery(t){const n=e.current.find(r=>r.id===t);n&&(b.detach(n),e.current.remove(n))},removeQueries(t){const n=new Set(t);e.current.forEach(a=>{n.has(a.id)&&b.detach(a)});const r=[...e.current];x.remove(r,a=>n.has(a.id)),e.current=b.cast(r)}})),eu=Pl.views(e=>({get sortedList(){return x.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(n=>({label:n.key,value:n.key,_type:"sql_snippet"}));return x.sortBy(t,n=>n.label.toLowerCase())}})).actions(e=>({replace(t){e.current=b.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByKey(t){const n=e.current.findIndex(r=>r.key===t);n>=0&&e.current.splice(n,1)},removeByKeys(t){const n=new Set(t);e.current.forEach(a=>{n.has(a.key)&&b.detach(a)});const r=[...e.current];x.remove(r,a=>n.has(a.key)),e.current=b.cast(r)},replaceByIndex(t,n){e.current.splice(t,1,n)}})),I_=b.types.model({data:b.types.optional(b.types.frozen(),[]),state:b.types.optional(b.types.enumeration(["idle","loading","error"]),"idle"),error:b.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),M_=b.types.model({data:b.types.optional(b.types.frozen(),[]),state:b.types.optional(b.types.enumeration(["idle","loading","error"]),"idle"),error:b.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),A_=b.types.model({page:b.types.optional(b.types.number,1),limit:b.types.optional(b.types.number,20),data:b.types.optional(b.types.frozen(),[]),total:b.types.optional(b.types.number,0),state:b.types.optional(b.types.enumeration(["idle","loading","error"]),"idle"),error:b.types.frozen()}).views(e=>({get keywords(){return b.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:n}=b.getParent(e,1);return`${n}||${t}`}})).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0},get maxPage(){return Math.ceil(e.total/e.limit)},get offset(){return(e.page-1)*e.limit},get countSql(){const{table_name:t,table_schema:n}=e.keywords;return`
|
|
441
441
|
SELECT count(*) AS total
|
|
442
442
|
FROM ${n}.${t}
|