@devtable/dashboard 10.9.4 → 10.9.5
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 +4 -1
- package/dist/dashboard.umd.js +2 -2
- package/dist/stats.html +1 -1
- package/package.json +1 -1
package/dist/dashboard.es.js
CHANGED
|
@@ -3024,7 +3024,7 @@ class Zo {
|
|
|
3024
3024
|
}), this.instanceRegistry.clear(), this.factoryRegistry.clear();
|
|
3025
3025
|
}
|
|
3026
3026
|
}
|
|
3027
|
-
const yc = "10.9.
|
|
3027
|
+
const yc = "10.9.5", Cf = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
3028
3028
|
__proto__: null,
|
|
3029
3029
|
version: yc
|
|
3030
3030
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
@@ -26044,6 +26044,9 @@ const lI = ({
|
|
|
26044
26044
|
th: {
|
|
26045
26045
|
position: "relative"
|
|
26046
26046
|
},
|
|
26047
|
+
"th, td": {
|
|
26048
|
+
wordBreak: "break-word"
|
|
26049
|
+
},
|
|
26047
26050
|
".resizer": {
|
|
26048
26051
|
position: "absolute",
|
|
26049
26052
|
right: 0,
|
package/dist/dashboard.umd.js
CHANGED
|
@@ -116,7 +116,7 @@ Check the top-level render call using <`+P+">.")}return z}}function Yl(S,z){{if(
|
|
|
116
116
|
SELECT count(*) AS total
|
|
117
117
|
FROM ${n}.${e}
|
|
118
118
|
`}})).actions(t=>({setPage(e){t.page=e},resetPage(){t.page=1},setLimit(e){t.limit=e}})).actions(t=>({afterCreate(){b.addDisposer(t,ie.reaction(()=>t.keywordString,t.resetPage,{fireImmediately:!1,delay:0})),b.addDisposer(t,ie.reaction(()=>t.limit,t.resetPage,{fireImmediately:!1,delay:0}))}})),Gu=b.types.model("DataSourceModel",{id:b.types.string,type:b.types.enumeration("DataSourceType",[ye.HTTP,ye.MySQL,ye.Postgresql]),key:b.types.string,config:b.types.frozen(),tables:b.types.optional(qu,{}),columns:b.types.optional(Vu,{}),tableData:b.types.optional(Fu,{}),indexes:b.types.optional(Nu,{}),table_schema:b.types.optional(b.types.string,""),table_name:b.types.optional(b.types.string,"")}).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(t=>({setKeywords(e,n){t.table_schema=e,t.table_name=n}})).actions(t=>({initKeywords(){if(t.tables.empty)return;const e=Object.keys(t.tables.data)[0],n=t.tables.data[e][0].table_name;t.setKeywords(e,n)}})).actions(t=>{const e=b.flow(function*(){var n;(n=t.controllers.tables)==null||n.abort(),t.controllers.tables=new AbortController,t.tables.state="loading";try{const r=yield*b.toGenerator(qe.query(t.controllers.tables.signal)({type:t.type,key:t.key,query:t.tables.sql},{}));t.tables.data=x.groupBy(r,"table_schema"),t.tables.state="idle",t.tables.error=null,t.initKeywords()}catch(r){if(!pt.isCancel(r)){t.tables.data={};const a=x.get(r,"message","unkown error");t.tables.error=x.get(r,"response.data.detail.message",a),t.tables.state="error"}}});return{loadTables:e,loadTablesIfEmpty(){t.tables.empty&&e()},loadColumns:b.flow(function*(){var n;(n=t.controllers.columns)==null||n.abort(),t.controllers.columns=new AbortController,t.columns.state="loading";try{t.columns.data=yield*b.toGenerator(qe.query(t.controllers.columns.signal)({type:t.type,key:t.key,query:t.columns.sql},{})),t.columns.state="idle",t.columns.error=null}catch(r){if(pt.isCancel(r))t.columns.state="idle",t.columns.error=null;else{t.columns.data=[];const a=x.get(r,"message","unkown error");t.columns.error=x.get(r,"response.data.detail.message",a),t.columns.state="error"}}}),loadIndexes:b.flow(function*(){var n;(n=t.controllers.indexes)==null||n.abort(),t.controllers.indexes=new AbortController,t.indexes.state="loading";try{t.indexes.data=yield*b.toGenerator(qe.query(t.controllers.indexes.signal)({type:t.type,key:t.key,query:t.indexes.sql},{})),t.indexes.state="idle",t.indexes.error=null}catch(r){if(pt.isCancel(r))t.indexes.state="idle",t.indexes.error=null;else{t.indexes.data=[];const a=x.get(r,"message","unkown error");t.indexes.error=x.get(r,"response.data.detail.message",a),t.indexes.state="error"}}}),loadTableData:b.flow(function*(){var r;(r=t.controllers.tableData)==null||r.abort(),t.controllers.tableData=new AbortController;const n=t.tableData;n.state="loading";try{n.data=yield*b.toGenerator(qe.query(t.controllers.tableData.signal)({type:t.type,key:t.key,query:n.sql},{}));const[{total:a}]=yield*b.toGenerator(qe.query(t.controllers.tableData.signal)({type:t.type,key:t.key,query:n.countSql},{}));n.total=Number(a),n.state="idle",n.error=null}catch(a){if(pt.isCancel(a))n.state="idle",n.error=null;else{n.data=[];const o=x.get(a,"message","unkown error");n.error=x.get(a,"response.data.detail.message",o),n.state="error"}}})}}).actions(t=>({afterCreate(){b.addDisposer(t,ie.reaction(()=>t.columns.sql,t.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(t=>({afterCreate(){b.addDisposer(t,ie.reaction(()=>t.indexes.sql,t.loadIndexes,{fireImmediately:!1,delay:500})),b.addDisposer(t,ie.reaction(()=>t.tableData.sql,t.loadTableData,{fireImmediately:!1,delay:0}))}})),Wu=b.types.model("DataSourcesModel",{list:b.types.optional(b.types.array(Gu),[])}).views(t=>({find({type:e,key:n}){return t.list.find(r=>r.key===n&&r.type===e)},get options(){return t.list.map(e=>({value:e.key,label:e.key}))}})).actions(t=>({replace(e){t.list.length=0,t.list.push(...e)}}));function bn(t){return{label:t,value:t,_type:"ACTION",_action_type:t,Icon:null,children:null}}function ju(t){switch(t._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",t.value];case"sql_snippet":return["_SQL_SNIPPETS_",t.value];case"query":return["_QUERIES_",t.value];case"view":return["_VIEWS_",t.value];case"panel":return t.parentID?["_VIEWS_",t.parentID,"_PANELS_",t.value]:(console.error("[getPathFromOption] parentID is required"),null)}}const Ru=b.types.model("EditorModel",{path:b.types.optional(b.types.frozen(),[]),settings_open:b.types.optional(b.types.boolean,!1)}).views(t=>({get navOptions(){const{content:e}=b.getRoot(t),{filters:n,views:r,sqlSnippets:a,queries:o}=e;return[{label:"Query Variables",value:"_QUERY_VARS_",_type:"query_variables",Icon:L.IconVariable},{label:"Mock Context",value:"_MOCK_CONTEXT_",Icon:L.IconCodeDots,_type:"mock_context"},{label:"Filters",value:"_FILTERS_",Icon:L.IconFilter,children:[...n.options,bn("_Add_A_Filter_")],_type:"GROUP"},{label:"SQL Snippets",value:"_SQL_SNIPPETS_",Icon:L.IconCopy,children:[...a.options,bn("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"Queries",value:"_QUERIES_",Icon:L.IconDatabase,children:[...o.options,bn("_Add_A_QUERY_")],_type:"GROUP"},{label:"Views",value:"_VIEWS_",Icon:L.IconBoxMultiple,children:[...r.editorOptions,bn("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(e,n){return e.length===0?!1:e[e.length-1]===n.value},isOptionOpened(e){const{path:n}=t;return n.length===0||!e.children||e.children.length===0?!1:n.includes(e.value)}})).actions(t=>({setPath(e){t.path=e},setSettingsOpen(e){t.settings_open=e}})).actions(t=>({open(e){t.setPath(e),t.setSettingsOpen(!0)},close(){t.setSettingsOpen(!1)},navigate(e){const n=ju(e);n&&t.setPath(n)}})),Yu=b.types.model("MockContextModel",{current:b.types.optional(b.types.frozen(),{})}).views(t=>({get keys(){return Object.keys(t.current)},get entries(){return Object.entries(t.current)}})).actions(t=>({replace(e){t.current=e},get(e){return t.current[e]},set(e,n){t.current[e]=n}})),Qu=b.types.model("VariableModel",{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})}))}).views(t=>({get json(){const{name:e,size:n,weight:r,color:a,formatter:o,data_field:l,aggregation:u}=t;return x.cloneDeep({name:e,size:n,color:a,weight:r,formatter:o,data_field:l,aggregation:u})}}));class Ku{constructor(e){N(this,"origin");N(this,"copy");this.origin=e,this.copy=b.clone(e),ie.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(e){b.applySnapshot(this.copy,e)}}const Uu=t=>new Ku(t);class Xu{constructor(){N(this,"migrations",[])}version(e,n){return this.migrations.push({version:e,handler:n}),this}run(e,n,r){var l;if(e.from===e.to)return n;if(e.from>e.to)throw new Error(`Can not downgrade from version '${e.from}' to (${e.to})`);const a=this.migrations.filter(u=>u.version>e.from&&u.version<=e.to),o=x.orderBy(a,"version","asc");if(((l=x.last(o))==null?void 0:l.version)!==e.to)throw new Error(`Migration to version ${e.to} not found`);return o.reduce((u,c)=>c.handler(u,r),n)}}class ve extends Xu{constructor(){super(),this.configVersions()}version(e,n){return super.version(e,(r,a)=>({version:e,...n(r,a)}))}async migrate({configData:e,panelModel:n}){const r=await e.getItem(null),a=x.get(r,"version",0),o=this.run({from:a,to:this.VERSION},r,{panelModel:n});await e.setItem(null,o)}async needMigration({configData:e}){const n=await e.getItem(null);return x.get(n,"version",0)<this.VERSION}}var Je=(t=>(t.string="string",t.number="number",t.eloc="eloc",t.percentage="percentage",t.custom="custom",t))(Je||{});const gs=["function text({ value }) {"," // your code goes here"," return value","}"].join(`
|
|
119
|
-
`),vr={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",id_field:"",striped:!0,use_raw_columns:!0,verticalSpacing:"14px"};class Lt{constructor(e,n){this.root=e,this.path=n}async deleteItem(e){e===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,x.omit(n,e))}async getItem(e){const n=await this.root.getItem(this.path);return e===null?n:x.get(n,e)}async setItem(e,n){if(e===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[e]:n})}return await this.getItem(e)}watchItem(e,n,r){return e===null?this.root.watchItem(this.path,(a,o)=>{n(a,o)},r):this.root.watchItem(this.path,(a,o)=>{const l=x.get(a,e),u=x.get(o,e);l!==u&&n(l,u)},r)}}class xr{constructor(e,n,r){N(this,"attachmentStorage");this.instance=e,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new Lt(e.instanceData,n)}async getInstance(e){if(await this.attachmentStorage.getItem(e))return this.constructInstance(new Lt(this.attachmentStorage,e))}async create(e,n){return await this.attachmentStorage.setItem(e,n),this.constructInstance(new Lt(this.attachmentStorage,e))}async remove(e){await this.attachmentStorage.deleteItem(e)}async list(){const e=await this.attachmentStorage.getItem(null);return Promise.all(x.values(e).map(n=>this.constructInstance(new Lt(this.attachmentStorage,n.id))))}}class ms{constructor(e){N(this,"rootRef");this.rootRef=ie.observable({current:e})}async deleteItem(e){ie.runInAction(()=>{x.unset(this.rootRef.current,[e])})}getItem(e){const n=this.getValueFromRoot(e);return Promise.resolve(n)}getValueFromRoot(e){return e===null?ie.toJS(this.rootRef.current):x.get(this.rootRef.current,[e])}setItem(e,n){if(e===null)if(x.isObject(n))ie.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else ie.runInAction(()=>{x.set(this.rootRef.current,[e],n)});return Promise.resolve(this.getItem(e))}watchItem(e,n,r){return ie.reaction(()=>this.getValueFromRoot(e),(a,o)=>{n(a,o)},{requiresObservable:!0,fireImmediately:x.get(r,"fireImmediately",!1)})}}class Ju{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new ka)}getChannel(e){const n=this.channels.get(e);if(n)return n;const r=new ka;return this.channels.set(e,r),r}}class Zu{constructor(e){N(this,"instances",new Map);this.pluginManager=e}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(e=>e.manifest.viz)}resolveComponent(e){return this.pluginManager.factory.viz(e)}getOrCreateInstance(e){const n=this.instances.get(e.id);if(n)return n;const r={id:e.id,name:e.viz.type,type:e.viz.type,messageChannels:new Ju,instanceData:new ms(e.viz.conf)};return this.instances.set(e.id,r),r}}function ys(t,e,n,r){return{vizManager:n,locale:"zh",msgChannels:t.messageChannels,instanceData:t.instanceData,pluginData:new ms({}),colorPalette:{getColor(){return()=>""}},data:e,variables:r}}const Hu=t=>{const{panel:e,vizManager:n,data:r,variables:a}=t,o=n.resolveComponent(e.viz.type),l=n.getOrCreateInstance(e),u={...ys(l,r,n,a),viewport:{width:e.layout.w,height:e.layout.h}},c=o.viewRender;return i(c,{context:u,instance:l,...x.omit(t,["panel","vizManager","data"])})},ec=t=>{const{vizManager:e,panel:n,panelInfoEditor:r,data:a,variables:o}=t,l=e.resolveComponent(n.viz.type),u=e.getOrCreateInstance(n),c={...ys(u,a,e,o),panelInfoEditor:r},d=l.configRender;return i(d,{context:c,instance:u,...x.omit(t,["panel","vizManager","data","panelInfoEditor"])})},bs=(t,e)=>{const n=st.bezier(t),r=st.bezier(e);return function(a){return a<50?n(a*2/100).hex():r((a-50)*2/100).hex()}},vn=t=>{const e=st.bezier(t);return function(n){return e(n/100).hex()}},tc={type:"interpolation",displayName:"Red / Green",getColor:bs(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},nc={type:"interpolation",displayName:"Yellow / Blue",getColor:bs(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},rc={type:"interpolation",displayName:"Red",getColor:vn(["#fff7f1","darkred"]),name:"red",category:"sequential"},ic={type:"interpolation",displayName:"Green",getColor:vn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},ac={type:"interpolation",displayName:"Blue",getColor:vn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},sc={type:"interpolation",displayName:"Orange",getColor:vn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class oc{constructor(e){N(this,"symbol");this.symbol=Symbol(e)}}function ot(t){return new oc(t)}class wr{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const e=new wr;return e.parent=this,e}getRequired(e){return this.get(e)}get(e){if(this.instanceRegistry.has(e.symbol))return this.instanceRegistry.get(e.symbol);const n=this.factoryRegistry.get(e.symbol);if(n){const r=n(this);return this.instanceRegistry.set(e.symbol,r),r}if(this.parent)return this.parent.get(e)}provideFactory(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,n),this}provideValue(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(e=>{const n=x.get(e,"dispose");x.isFunction(n)&&n.bind(e)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const vs="10.9.4",lc=Object.freeze(Object.defineProperty({__proto__:null,version:vs},Symbol.toStringTag,{value:"Module"}));class uc{constructor(e){N(this,"staticColors",new Map);N(this,"interpolations",new Map);e.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(e){const n=this.encodeColor(e);e.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.staticColors.set(n,e)):e.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`,`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.interpolations.set(n,e))}decodeStaticColor(e){return this.staticColors.get(e)}encodeColor(e){return`\${${e.category}}.{${e.name}}`}decodeInterpolation(e){return this.interpolations.get(e)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class cc{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:e=>{const n=this.vizComponents.get(e);if(n)return n;throw new Error(`Viz Component (${e}) not found`)}})}install(e){if(this.plugins.has(e.id))throw new Error(`Plugin (${e.id}) has been installed before`);this.plugins.set(e.id,e);for(const n of e.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())}}const W=(t,e)=>{const[n,{setFalse:r}]=X.useBoolean(!0),[a,o]=y.useState();y.useEffect(()=>(t.getItem(e).then(u=>{o(u),r()}),t.watchItem(e,u=>{o(u)})));const l=y.useCallback(async u=>{await t.setItem(e,u),o(u)},[t,e]);return{loading:n,value:a,set:l}},Cr={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function q(t){const[e,n]=t.split(".");return{queryID:e,columnKey:n}}function lt(t,e){var a;const{queryID:n,columnKey:r}=q(e);return n?r?((a=t[n])==null?void 0:a.map(o=>o[r]))??[]:t[n]:[]}function xn(t,e){const{queryID:n}=q(e);return n?t[n]:[]}function dc(t){return Object.values(t)[0]}function wn(t,e){const{queryID:n,columnKey:r}=q(e);return t[r]}le.use([G.GridComponent,G.VisualMapComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function pc({context:t}){const{value:e}=W(t.instanceData,"config"),n=t.data,{width:r,height:a}=t.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:u,xAxis3D:c,yAxis3D:d,zAxis3D:f}=x.defaults({},e,Cr),h=y.useMemo(()=>xn(n,o),[n,o]),{x:g,y:m,z:w}=y.useMemo(()=>({x:q(o),y:q(l),z:q(u)}),[o,l,u]),{min:C,max:_}=y.useMemo(()=>{const I=x.minBy(h,B=>B[w.columnKey]),O=x.maxBy(h,B=>B[w.columnKey]);return{min:x.get(I,w.columnKey),max:x.get(O,w.columnKey)}},[h,w]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:C,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(I=>[I[g.columnKey],I[m.columnKey],I[w.columnKey]])}]};return e?i(Ne,{echarts:le,option:T,style:{width:r,height:a},notMerge:!0,theme:"merico-light"}):null}const xs=y.createContext({panel:null,data:{},loading:!1,errors:[]}),Sr=xs.Provider;function ze(){const t=y.useContext(xs);if(!t.panel)throw new Error("Please use PanelContextProvider");return t}const hc={fullScreenPanelID:"",setFullScreenPanelID:x.noop},_r=y.createContext(hc);function ws(){const t=y.useContext(_r);if(!t)throw new Error("Please use FullScreenPanelContext.Provider");return t}const j=k.observer(y.forwardRef(({label:t,required:e,value:n,onChange:r,clearable:a=!1,sx:o,...l},u)=>{const{panel:c}=ze(),d=y.useMemo(()=>{const f=[...c.dataFieldOptions];return a&&f.unshift({label:"unset",value:"",group:""}),f},[c.dataFieldOptions]);return i(s.Select,{ref:u,label:t,data:d,value:n,onChange:r,required:e,sx:o,...l})}));function fc({context:t}){const{value:e,set:n}=W(t.instanceData,"config"),r=x.defaults({},e,Cr),{control:a,handleSubmit:o,reset:l}=v.useForm({defaultValues:r});return y.useEffect(()=>{l(r)},[e]),e?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(j,{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(j,{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(j,{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(D.DeviceFloppy,{size:20}),i(s.Text,{ml:"md",children:"Save"})]})})]})}):null}function gc(t,{panelModel:e}){try{const n=e.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}=t;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 mc extends ve{constructor(){super(...arguments);N(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:gc(a,r)}})}}const yc={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new mc,name:"bar-3d",viewRender:pc,configRender:fc,createConfig(){return{version:2,config:x.cloneDeep(Cr)}}};class Fe extends y.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){var e;if(this.state.error){const n=()=>{this.setState({error:null})};return p(s.Box,{children:[i(s.Text,{size:"xs",children:(e=this.state.error)==null?void 0:e.message}),i(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}const $e={mantissa:0,output:"number",trimMantissa:!1,average:!1};function bc({value:t,onChange:e},n){const r=u=>{e({...t,output:u})},a=u=>{const c=u===0?!1:t.trimMantissa;e({...t,mantissa:u,trimMantissa:c})},o=u=>{e({...t,trimMantissa:u.currentTarget.checked})},l=u=>{e({...t,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:t.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:t.average,onChange:l,disabled:t.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:t.mantissa,onChange:a}),i(s.Switch,{label:"Trim mantissa",checked:t.trimMantissa,onChange:o,disabled:t.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(s.Stack,{spacing:0,children:[i(s.Text,{weight:"bold",children:"Preview"}),i(Fe,{children:p(s.Group,{position:"apart",children:[p(s.Text,{size:12,color:"gray",children:["123456789 ",i(D.ArrowRight,{size:9})," ",ee(123456789).format(t)]}),p(s.Text,{size:12,color:"gray",children:["1234 ",i(D.ArrowRight,{size:9})," ",ee(1234).format(t)]}),p(s.Text,{size:12,color:"gray",children:["0.1234 ",i(D.ArrowRight,{size:9})," ",ee(.1234).format(t)]})]})})]})]})}const Re=y.forwardRef(bc),nt={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
119
|
+
`),vr={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",id_field:"",striped:!0,use_raw_columns:!0,verticalSpacing:"14px"};class Lt{constructor(e,n){this.root=e,this.path=n}async deleteItem(e){e===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,x.omit(n,e))}async getItem(e){const n=await this.root.getItem(this.path);return e===null?n:x.get(n,e)}async setItem(e,n){if(e===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[e]:n})}return await this.getItem(e)}watchItem(e,n,r){return e===null?this.root.watchItem(this.path,(a,o)=>{n(a,o)},r):this.root.watchItem(this.path,(a,o)=>{const l=x.get(a,e),u=x.get(o,e);l!==u&&n(l,u)},r)}}class xr{constructor(e,n,r){N(this,"attachmentStorage");this.instance=e,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new Lt(e.instanceData,n)}async getInstance(e){if(await this.attachmentStorage.getItem(e))return this.constructInstance(new Lt(this.attachmentStorage,e))}async create(e,n){return await this.attachmentStorage.setItem(e,n),this.constructInstance(new Lt(this.attachmentStorage,e))}async remove(e){await this.attachmentStorage.deleteItem(e)}async list(){const e=await this.attachmentStorage.getItem(null);return Promise.all(x.values(e).map(n=>this.constructInstance(new Lt(this.attachmentStorage,n.id))))}}class ms{constructor(e){N(this,"rootRef");this.rootRef=ie.observable({current:e})}async deleteItem(e){ie.runInAction(()=>{x.unset(this.rootRef.current,[e])})}getItem(e){const n=this.getValueFromRoot(e);return Promise.resolve(n)}getValueFromRoot(e){return e===null?ie.toJS(this.rootRef.current):x.get(this.rootRef.current,[e])}setItem(e,n){if(e===null)if(x.isObject(n))ie.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else ie.runInAction(()=>{x.set(this.rootRef.current,[e],n)});return Promise.resolve(this.getItem(e))}watchItem(e,n,r){return ie.reaction(()=>this.getValueFromRoot(e),(a,o)=>{n(a,o)},{requiresObservable:!0,fireImmediately:x.get(r,"fireImmediately",!1)})}}class Ju{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new ka)}getChannel(e){const n=this.channels.get(e);if(n)return n;const r=new ka;return this.channels.set(e,r),r}}class Zu{constructor(e){N(this,"instances",new Map);this.pluginManager=e}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(e=>e.manifest.viz)}resolveComponent(e){return this.pluginManager.factory.viz(e)}getOrCreateInstance(e){const n=this.instances.get(e.id);if(n)return n;const r={id:e.id,name:e.viz.type,type:e.viz.type,messageChannels:new Ju,instanceData:new ms(e.viz.conf)};return this.instances.set(e.id,r),r}}function ys(t,e,n,r){return{vizManager:n,locale:"zh",msgChannels:t.messageChannels,instanceData:t.instanceData,pluginData:new ms({}),colorPalette:{getColor(){return()=>""}},data:e,variables:r}}const Hu=t=>{const{panel:e,vizManager:n,data:r,variables:a}=t,o=n.resolveComponent(e.viz.type),l=n.getOrCreateInstance(e),u={...ys(l,r,n,a),viewport:{width:e.layout.w,height:e.layout.h}},c=o.viewRender;return i(c,{context:u,instance:l,...x.omit(t,["panel","vizManager","data"])})},ec=t=>{const{vizManager:e,panel:n,panelInfoEditor:r,data:a,variables:o}=t,l=e.resolveComponent(n.viz.type),u=e.getOrCreateInstance(n),c={...ys(u,a,e,o),panelInfoEditor:r},d=l.configRender;return i(d,{context:c,instance:u,...x.omit(t,["panel","vizManager","data","panelInfoEditor"])})},bs=(t,e)=>{const n=st.bezier(t),r=st.bezier(e);return function(a){return a<50?n(a*2/100).hex():r((a-50)*2/100).hex()}},vn=t=>{const e=st.bezier(t);return function(n){return e(n/100).hex()}},tc={type:"interpolation",displayName:"Red / Green",getColor:bs(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},nc={type:"interpolation",displayName:"Yellow / Blue",getColor:bs(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},rc={type:"interpolation",displayName:"Red",getColor:vn(["#fff7f1","darkred"]),name:"red",category:"sequential"},ic={type:"interpolation",displayName:"Green",getColor:vn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},ac={type:"interpolation",displayName:"Blue",getColor:vn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},sc={type:"interpolation",displayName:"Orange",getColor:vn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class oc{constructor(e){N(this,"symbol");this.symbol=Symbol(e)}}function ot(t){return new oc(t)}class wr{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const e=new wr;return e.parent=this,e}getRequired(e){return this.get(e)}get(e){if(this.instanceRegistry.has(e.symbol))return this.instanceRegistry.get(e.symbol);const n=this.factoryRegistry.get(e.symbol);if(n){const r=n(this);return this.instanceRegistry.set(e.symbol,r),r}if(this.parent)return this.parent.get(e)}provideFactory(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,n),this}provideValue(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(e=>{const n=x.get(e,"dispose");x.isFunction(n)&&n.bind(e)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const vs="10.9.5",lc=Object.freeze(Object.defineProperty({__proto__:null,version:vs},Symbol.toStringTag,{value:"Module"}));class uc{constructor(e){N(this,"staticColors",new Map);N(this,"interpolations",new Map);e.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(e){const n=this.encodeColor(e);e.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.staticColors.set(n,e)):e.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`,`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.interpolations.set(n,e))}decodeStaticColor(e){return this.staticColors.get(e)}encodeColor(e){return`\${${e.category}}.{${e.name}}`}decodeInterpolation(e){return this.interpolations.get(e)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class cc{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:e=>{const n=this.vizComponents.get(e);if(n)return n;throw new Error(`Viz Component (${e}) not found`)}})}install(e){if(this.plugins.has(e.id))throw new Error(`Plugin (${e.id}) has been installed before`);this.plugins.set(e.id,e);for(const n of e.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())}}const W=(t,e)=>{const[n,{setFalse:r}]=X.useBoolean(!0),[a,o]=y.useState();y.useEffect(()=>(t.getItem(e).then(u=>{o(u),r()}),t.watchItem(e,u=>{o(u)})));const l=y.useCallback(async u=>{await t.setItem(e,u),o(u)},[t,e]);return{loading:n,value:a,set:l}},Cr={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function q(t){const[e,n]=t.split(".");return{queryID:e,columnKey:n}}function lt(t,e){var a;const{queryID:n,columnKey:r}=q(e);return n?r?((a=t[n])==null?void 0:a.map(o=>o[r]))??[]:t[n]:[]}function xn(t,e){const{queryID:n}=q(e);return n?t[n]:[]}function dc(t){return Object.values(t)[0]}function wn(t,e){const{queryID:n,columnKey:r}=q(e);return t[r]}le.use([G.GridComponent,G.VisualMapComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function pc({context:t}){const{value:e}=W(t.instanceData,"config"),n=t.data,{width:r,height:a}=t.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:u,xAxis3D:c,yAxis3D:d,zAxis3D:f}=x.defaults({},e,Cr),h=y.useMemo(()=>xn(n,o),[n,o]),{x:g,y:m,z:w}=y.useMemo(()=>({x:q(o),y:q(l),z:q(u)}),[o,l,u]),{min:C,max:_}=y.useMemo(()=>{const I=x.minBy(h,B=>B[w.columnKey]),O=x.maxBy(h,B=>B[w.columnKey]);return{min:x.get(I,w.columnKey),max:x.get(O,w.columnKey)}},[h,w]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:C,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(I=>[I[g.columnKey],I[m.columnKey],I[w.columnKey]])}]};return e?i(Ne,{echarts:le,option:T,style:{width:r,height:a},notMerge:!0,theme:"merico-light"}):null}const xs=y.createContext({panel:null,data:{},loading:!1,errors:[]}),Sr=xs.Provider;function ze(){const t=y.useContext(xs);if(!t.panel)throw new Error("Please use PanelContextProvider");return t}const hc={fullScreenPanelID:"",setFullScreenPanelID:x.noop},_r=y.createContext(hc);function ws(){const t=y.useContext(_r);if(!t)throw new Error("Please use FullScreenPanelContext.Provider");return t}const j=k.observer(y.forwardRef(({label:t,required:e,value:n,onChange:r,clearable:a=!1,sx:o,...l},u)=>{const{panel:c}=ze(),d=y.useMemo(()=>{const f=[...c.dataFieldOptions];return a&&f.unshift({label:"unset",value:"",group:""}),f},[c.dataFieldOptions]);return i(s.Select,{ref:u,label:t,data:d,value:n,onChange:r,required:e,sx:o,...l})}));function fc({context:t}){const{value:e,set:n}=W(t.instanceData,"config"),r=x.defaults({},e,Cr),{control:a,handleSubmit:o,reset:l}=v.useForm({defaultValues:r});return y.useEffect(()=>{l(r)},[e]),e?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(j,{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(j,{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(j,{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(D.DeviceFloppy,{size:20}),i(s.Text,{ml:"md",children:"Save"})]})})]})}):null}function gc(t,{panelModel:e}){try{const n=e.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}=t;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 mc extends ve{constructor(){super(...arguments);N(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:gc(a,r)}})}}const yc={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new mc,name:"bar-3d",viewRender:pc,configRender:fc,createConfig(){return{version:2,config:x.cloneDeep(Cr)}}};class Fe extends y.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){var e;if(this.state.error){const n=()=>{this.setState({error:null})};return p(s.Box,{children:[i(s.Text,{size:"xs",children:(e=this.state.error)==null?void 0:e.message}),i(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}const $e={mantissa:0,output:"number",trimMantissa:!1,average:!1};function bc({value:t,onChange:e},n){const r=u=>{e({...t,output:u})},a=u=>{const c=u===0?!1:t.trimMantissa;e({...t,mantissa:u,trimMantissa:c})},o=u=>{e({...t,trimMantissa:u.currentTarget.checked})},l=u=>{e({...t,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:t.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:t.average,onChange:l,disabled:t.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:t.mantissa,onChange:a}),i(s.Switch,{label:"Trim mantissa",checked:t.trimMantissa,onChange:o,disabled:t.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(s.Stack,{spacing:0,children:[i(s.Text,{weight:"bold",children:"Preview"}),i(Fe,{children:p(s.Group,{position:"apart",children:[p(s.Text,{size:12,color:"gray",children:["123456789 ",i(D.ArrowRight,{size:9})," ",ee(123456789).format(t)]}),p(s.Text,{size:12,color:"gray",children:["1234 ",i(D.ArrowRight,{size:9})," ",ee(1234).format(t)]}),p(s.Text,{size:12,color:"gray",children:["0.1234 ",i(D.ArrowRight,{size:9})," ",ee(.1234).format(t)]})]})})]})]})}const Re=y.forwardRef(bc),nt={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
120
120
|
`)},Cs={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:xc,configRender:vc,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 vc(t){return i(V,{})}function xc(t){return i(s.Text,{children:"Click chart's series"})}const wc=[{label:"Truncate",value:"truncate"},{label:"Break Line",value:"break"},{label:"Break Word",value:"breakAll"}],Cn=y.forwardRef(({sectionTitle:t,value:e,onChange:n},r)=>{const a=o=>l=>{const u=x.cloneDeep(e);x.set(u,o,l),n(u)};return p(s.Stack,{spacing:0,children:[t&&i(s.Divider,{mb:-5,mt:5,variant:"dotted",label:t,labelPosition:"right",labelProps:{color:"dimmed"}}),p(s.Group,{grow:!0,noWrap:!0,children:[i(s.NumberInput,{label:"Max Width",hideControls:!0,value:e.width,onChange:a("width")}),i(s.Select,{label:"Overflow",data:wc,value:e.overflow,onChange:a("overflow")}),i(s.TextInput,{label:"Ellipsis",value:e.ellipsis,disabled:!0})]})]})}),gt=y.forwardRef(({value:t,onChange:e},n)=>{const r=o=>{e({...t,on_axis:o})},a=o=>{e({...t,in_tooltip:o})};return p(s.Stack,{ref:n,spacing:0,children:[i(Cn,{sectionTitle:"Overflow on Axis",value:t.on_axis,onChange:r}),i(Cn,{sectionTitle:"Overflow in Tooltip",value:t.in_tooltip,onChange:a})]})}),Ze={on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}};function mt({overflow:t,width:e}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[t],r=t==="truncate"?"nowrap":"initial",a={truncate:"ellipsis",break:"clip",breakAll:"clip"}[t];return`
|
|
121
121
|
max-width: ${e}px;
|
|
122
122
|
word-break: ${n};
|
|
@@ -493,7 +493,7 @@ Check the top-level render call using <`+P+">.")}return z}}function Yl(S,z){{if(
|
|
|
493
493
|
parent_value: string;
|
|
494
494
|
description?: string;
|
|
495
495
|
}
|
|
496
|
-
`,bS=()=>{const[t,e]=y.useState(!1);return p(V,{children:[i(s.Button,{variant:"subtle",compact:!0,onClick:()=>e(n=>!n),children:t?"Close":"Click to see expected data structure"}),i(s.Collapse,{in:t,children:i(kt.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:yS})})]})},vS=k.observer(function({config:e}){return p(V,{children:[i(s.TextInput,{label:"Min-width",value:e.min_width,onChange:n=>e.setMinWidth(n.currentTarget.value),placeholder:"200px"}),i(s.Divider,{label:"Fetch options from database",labelPosition:"center"}),i(s.NumberInput,{value:e.default_selection_count,onChange:e.setDefaultSelectionCount,label:"Select first N options by default"}),i(zi,{value:e.options_query_id,onChange:e.setOptionsQueryID}),i(bS,{})]})}),xS=k.observer(function({filter:e}){const[n,r]=y.useState(e.plainDefaultValue);return y.useEffect(()=>{r(e.plainDefaultValue)},[e]),p(s.Box,{sx:{maxWidth:"480px"},children:[i(s.Text,{pb:"md",color:"gray",children:"Preview"}),i(dl,{filter:e,value:n,onChange:r}),i(s.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),i(kt.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(e,null,4)})]})}),wS={select:gS,"multi-select":fS,"tree-select":vS,"text-input":mS,checkbox:cS,"date-range":pS},CS=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Tree Select",value:"tree-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],SS=k.observer(function({filter:e}){const n=K(),r=y.useMemo(()=>wS[e.type],[e.type]);return p(s.Group,{grow:!0,spacing:20,align:"top",children:[p(s.Box,{sx:{maxWidth:"600px"},children:[i(s.Text,{pb:"md",color:"gray",children:"Edit"}),p(s.Stack,{children:[p(s.Group,{noWrap:!0,children:[i(s.NumberInput,{label:"Placement Order",required:!0,value:e.order,onChange:e.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),e.auto_submit_supported&&i(s.Checkbox,{label:"Submit automatically",checked:e.auto_submit,onChange:a=>e.setAutoSubmit(a.currentTarget.checked),mt:22})]}),i(s.MultiSelect,{label:"Visible in...",data:n.views.options,value:[...e.visibleInViewsIDs],onChange:e.setVisibleInViewsIDs}),i(s.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:e.key,onChange:a=>{e.setKey(a.currentTarget.value)}}),i(s.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:e.label,onChange:a=>{e.setLabel(a.currentTarget.value)}}),i(s.Select,{label:"Widget",data:CS,required:!0,value:e.type,onChange:e.setType}),i(r,{config:e.config})]})]}),i(xS,{filter:e})]})}),_S=k.observer(({id:t})=>{const e=Ue.useModals(),n=he(),r=K();if(t==="")return null;const a=r.filters.findByID(t);if(!a)return p(s.Text,{size:14,children:["Filter by ID[",t,"] is not found"]});const o=()=>{n.editor.setPath(["_FILTERS_",""])},l=()=>{e.openConfirmModal({title:"Delete this filter?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.filters.removeByID(t),o()},confirmProps:{color:"red"},zIndex:320})};return p(s.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[i(s.Group,{position:"right",pt:10,children:i(s.Button,{size:"xs",color:"red",leftIcon:i(D.Trash,{size:16}),onClick:l,children:"Delete this filter"})}),i(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:i(SS,{filter:a})})]})}),kS=k.observer(()=>{const t=K(),[e,n]=y.useState(()=>JSON.stringify(t.mock_context.current,null,4)),r=()=>{try{t.mock_context.replace(JSON.parse(e))}catch(o){hn.showNotification({title:"Failed",message:o.message,color:"red"})}},a=y.useMemo(()=>{try{return JSON.stringify(JSON.parse(e))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[e,t.mock_context.current]);return p(s.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[i(s.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:i(s.Text,{weight:500,children:"Mock Context"})}),p(s.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[p(s.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[i(s.Text,{children:"A valid json string is required"}),i(s.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:e,onChange:n,sx:{flexGrow:1}})]}),i(s.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!a,onClick:r,children:i(D.DeviceFloppy,{size:20})})]})]})}),TS=k.observer(()=>{const{panel:t}=ze();return i(ai,{label:"Description",value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}})}),DS=k.observer(()=>{const{panel:t}=ze(),{style:e}=t;return i(V,{children:i(s.Switch,{label:"Border",checked:e.border.enabled,onChange:n=>e.border.setEnabled(n.currentTarget.checked)})})}),MS=k.observer(()=>{const{panel:t}=ze(),{title:e,setTitle:n}=t,[r,a]=Me.useInputState(e),o=e!==r,l=y.useCallback(()=>{o&&n(r)},[o,r]);return y.useEffect(()=>{a(e)},[e]),i(s.TextInput,{value:r,onChange:a,label:p(s.Group,{children:[i(s.Text,{children:"Panel Title"}),i(s.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:l,children:i(D.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function IS(){return p(s.Stack,{sx:{height:"100%"},children:[i(s.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),i(DS,{}),i(s.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),i(MS,{}),i(TS,{})]})}const ES=({queryID:t})=>{const e=K(),{state:n,error:r}=e.getDataStuffByID(t),a=y.useMemo(()=>e.queries.findByID(t),[e,t]);return n==="loading"?null:r?i(s.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:r}):a!=null&&a.stateMessage?i(s.Text,{color:"gray",align:"center",children:a.stateMessage}):null},AS={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function Dl({data:t}){const e=y.useMemo(()=>{if(!Array.isArray(t)||t.length===0)return[];const r=Xe.createColumnHelper();return Object.keys(t[0]).map(a=>r.accessor(a,{cell:o=>o.getValue()}))},[t]),n=Xe.useReactTable({data:t,columns:e,columnResizeMode:"onChange",getCoreRowModel:Xe.getCoreRowModel()});return t.length===0?i(s.Box,{sx:{height:"5em"}}):i(Fe,{children:p(s.Table,{sx:AS,children:[i("thead",{children:n.getHeaderGroups().map(r=>i("tr",{children:r.headers.map(a=>p("th",{style:{width:a.getSize()},children:[a.isPlaceholder?null:Xe.flexRender(a.column.columnDef.header,a.getContext()),i(s.ActionIcon,{onMouseDown:a.getResizeHandler(),onTouchStart:a.getResizeHandler(),className:`resizer ${a.column.getIsResizing()?"isResizing":""}`,children:i(D.ArrowBarToRight,{})})]},a.id))},r.id))}),i("tbody",{children:n.getRowModel().rows.map(r=>i("tr",{children:r.getVisibleCells().map(a=>i("td",{children:i(Fe,{children:Xe.flexRender(a.column.columnDef.cell,a.getContext())})},a.id))},r.id))})]})})}const $i=k.observer(function({id:e,moreActions:n=null}){const r=K(),{data:a,state:o}=r.getDataStuffByID(e),l=o==="loading",u=()=>{r.queries.refetchDataByQueryID(e)},c=()=>{r.queries.downloadDataByQueryID(e)},d=y.useMemo(()=>Array.isArray(a)?a.slice(0,10):[],[a]),f=!Array.isArray(a)||a.length===0;return p(s.Stack,{sx:{border:"1px solid #eee"},children:[p(s.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[p(s.Group,{position:"left",children:[i(s.Text,{weight:500,children:"Preview Data"}),a.length>10&&p(s.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",a.length]})]}),p(s.Group,{pr:15,children:[n,i(s.ActionIcon,{variant:"subtle",color:"blue",disabled:l,onClick:u,children:i(D.Refresh,{size:16})}),i(s.ActionIcon,{variant:"subtle",color:"blue",disabled:l||f,onClick:c,children:i(D.Download,{size:16})})]})]}),p(s.Box,{sx:{position:"relative",overflow:"auto"},children:[i(s.LoadingOverlay,{visible:l}),i(ES,{queryID:e}),i(Dl,{data:d})]})]})}),zS=k.observer(function(){const e=he(),n=K(),{panel:r}=ze(),[a,o]=y.useState(!1),l=u=>{e.editor.setPath(["_QUERIES_",u])};return p(V,{children:[i(s.Drawer,{opened:a,onClose:()=>o(!1),title:"Choose queries",padding:"xl",size:500,zIndex:320,children:i(s.Checkbox.Group,{value:[...r.queryIDs],onChange:r.setQueryIDs,children:i(s.Stack,{spacing:"lg",children:n.queries.options.map(u=>i(s.Checkbox,{label:u.label,value:u.value},u.value))})})}),p(s.Stack,{spacing:6,children:[i(s.Group,{position:"right",children:i(s.Button,{variant:"light",size:"sm",leftIcon:i(L.IconLine,{size:16}),onClick:()=>o(!0),children:"Click me to choose queries for this panel"})}),r.queryIDs.length===1&&i($i,{id:r.queryIDs[0],moreActions:i(s.Tooltip,{label:"Open this query",children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>l(r.queryIDs[0]),children:i(L.IconArrowCurveRight,{size:16})})})}),r.queryIDs.length>1&&p(s.Tabs,{defaultValue:r.queryIDs[0],children:[i(s.Tabs.List,{children:r.queries.map(u=>i(s.Tabs.Tab,{value:u.id,children:u.name},u.id))}),r.queries.map(u=>i(s.Tabs.Panel,{value:u.id,children:i($i,{id:u.id,moreActions:i(s.Tooltip,{label:"Open this query",children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>l(u.id),children:i(L.IconArrowCurveRight,{size:16})})})})},u.id))]})]})]})}),$S=k.observer(()=>{const{panel:t}=ze();return i(Fe,{children:i(s.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:p(s.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.style.border.enabled?"1px":"0px"},children:[p(s.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[i(s.Group,{children:i(hl,{})}),i(s.Group,{grow:!0,position:"center",children:i(s.Text,{lineClamp:1,weight:"bold",children:t.title})}),i(s.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),i(s.Group,{px:5,pb:5,sx:{flexGrow:1},children:i(bl,{panel:t,height:"410px"})})]})})})}),Li={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{}},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class LS{constructor(e){N(this,"panel");N(this,"selected");this.panel=e,ie.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const e=this.panel.variables.filter(n=>n.name.startsWith(Li.name)).length;this.panel.addVariable(x.cloneDeep({...Li,name:`${Li.name}${e||""}`})),this.selected=x.last(this.panel.variables)}select(e){this.selected=e}remove(e){this.selected===e&&(this.selected=void 0);const n=this.panel.variables.indexOf(e);if(this.panel.removeVariable(e),!this.selected&&!x.isEmpty(this.panel.variables)){const r=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[r]}}}function OS(){const{panel:t}=ze();return X.useCreation(()=>new LS(t),[t])}const Ml=s.createStyles(t=>({root:{height:"100%",overflow:"hidden",".var-list-container":{"& > *":{height:"100%"},width:250,height:"100%"},".var-list-actions":{height:"fit-content",flexShrink:0,width:"100%"},".var-list":{flex:"1 1 auto",overflow:"auto",minHeight:0,"& > *":{flex:"0 0 auto"}}},config:{height:"100%",overflow:"auto",paddingRight:10}})),PS=y.forwardRef(function({value:e,onChange:n,data:r,withStyle:a=!0},o){const l=(u,c)=>{const d=x.cloneDeep(e);x.set(d,u,c),n(d)};return p(s.Box,{px:"sm",py:"md",ref:o,children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(s.TextInput,{label:"Name",required:!0,value:e.name,onChange:u=>l("name",u.currentTarget.value)}),i(j,{label:"Data Field",required:!0,value:e.data_field,onChange:u=>l("data_field",u)})]}),i(Sn,{label:"Aggregation",value:e.aggregation,onChange:u=>l("aggregation",u)}),i(s.Divider,{my:"xs",label:"Format",labelPosition:"center"}),i(Re,{value:e.formatter,onChange:u=>l("formatter",u)}),a&&i(Ts,{value:e,onChange:n})]})}),BS=t=>{const{uiModel:e}=t;return i(s.Stack,{className:"var-list",children:e.variables.map(n=>i(s.Button,{variant:e.selected===n?"filled":"subtle",color:"gray",onClick:()=>e.select(n),children:n.name},n.name))})},VS=k.observer(BS),NS=({variable:t,data:e})=>i(s.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:i(s.Paper,{withBorder:!0,p:"md",children:Ds(t,e)})}),qS=k.observer(NS),FS=t=>{const e=X.useCreation(()=>Uu(t.variable),[t.variable]),{classes:n}=Ml(),{data:r}=ze();return p(s.Group,{style:{height:"100%"},align:"start",children:[p(s.Stack,{"data-testid":"variable-editor",align:"stretch",className:n.config,children:[p(s.Group,{position:"right",children:[i(s.ActionIcon,{variant:"filled",disabled:!e.changed,color:"primary",onClick:e.commit,children:i(L.IconDeviceFloppy,{size:18})}),i(s.ActionIcon,{color:"red",onClick:()=>t.uiModel.remove(t.variable),children:i(L.IconTrash,{size:18})})]}),i(PS,{value:b.getSnapshot(e.copy),onChange:e.update,data:r})]}),i(qS,{variable:b.getSnapshot(e.copy),data:r})]})},GS=k.observer(FS),WS=()=>{const t=OS(),{classes:e}=Ml();return p(s.Group,{className:e.root,noWrap:!0,align:"start",children:[i(s.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:p(s.Stack,{justify:"space-between",children:[i(s.Box,{className:"var-list-actions",children:i(s.Button,{variant:"light",size:"sm",onClick:t.addNew,fullWidth:!0,children:"Add Variable"})}),i(VS,{uiModel:t})]})}),t.selected?i(V,{children:i(GS,{uiModel:t,variable:t.selected})}):i("span",{children:"Select or create a new variable on right side"})]})},jS=k.observer(WS);function RS(){const{vizManager:t}=y.useContext(at);return y.useMemo(()=>{const e=t.availableVizList.map(n=>({value:n.name,label:n.displayName??n.name,group:n.displayGroup??""}));return x.orderBy(e,[n=>n.group,n=>n.label],["asc","asc"])},[t])}const YS=k.observer(({value:t,submit:e})=>{const[n,r]=Me.useInputState(t);y.useEffect(()=>{r(t)},[t]);const a=RS(),o=t!==n;return i(s.Select,{label:"Visualization",value:n,searchable:!0,onChange:r,data:a,rightSection:i(s.ActionIcon,{disabled:!o,onClick:()=>e(n),children:i(D.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),Il=[];function QS(t,e){try{return t.resolveComponent(e).createConfig()}catch{return null}}function KS(){const{data:t,panel:{variables:e,viz:n,title:r,queryIDs:a,description:o,setDescription:l,setTitle:u,addQueryID:c,removeQueryID:d,id:f}}=ze(),{vizManager:h}=y.useContext(at),g={title:r,description:o,viz:n,queryIDs:a,id:f},m={setDescription:l,addQueryID:c,removeQueryID:d,setTitle:u},w=gl(g);try{return h.resolveComponent(g.viz.type),i(Hn,{configure:w,children:i(n1,{variables:e,setVizConf:n.setConf,panel:g,panelInfoEditor:m,vizManager:h,data:t})})}catch(C){return console.info(x.get(C,"message")),null}}const US=k.observer(()=>{const{data:t,panel:{viz:e}}=ze(),{vizManager:n}=y.useContext(at),r=y.useCallback(d=>{if(d===e.type)return;const f=QS(n,d);e.setType(d),e.setConf(f||{})},[e.type]),a=d=>{try{e.setConf(JSON.parse(d))}catch(f){console.error(f)}},o=y.useMemo(()=>{var d;return(d=Il.find(f=>f.value===e.type))==null?void 0:d.Panel},[e.type,Il]),l=KS(),u=o?y.createElement(o,{data:t,conf:e.conf,setConf:e.setConf}):null,c=l||u;return p(s.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[i(YS,{submit:r,value:e.type}),p(Fe,{children:[i(s.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:c}),!c&&i(s.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(e.conf,null,2),onChange:a})]})]})}),XS=k.observer(({panel:t,sourceViewID:e})=>{const n=K(),[r,a]=y.useState(e);y.useEffect(()=>{a(e)},[e]);const[o,{open:l,close:u}]=Me.useDisclosure(!1),c=()=>{t.moveToView(e,r),u()};return p(V,{children:[i(s.Button,{size:"xs",variant:"subtle",color:"blue",onClick:l,leftIcon:i(L.IconBoxMultiple,{size:14}),children:"Move into Another View"}),i(s.Modal,{opened:o,onClose:u,title:"Move panel into another view",zIndex:320,children:p(s.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[i(s.Radio.Group,{value:r,onChange:a,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:i(s.Stack,{spacing:"xs",children:n.views.options.map(d=>i(s.Radio,{value:d.value,label:d.label},d.value))})}),p(s.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[i(s.Button,{size:"xs",color:"red",leftIcon:i(L.IconX,{size:14}),onClick:u,children:"Cancel"}),i(s.Button,{size:"xs",color:"blue",leftIcon:i(L.IconDeviceFloppy,{size:14}),onClick:c,disabled:r===e,children:"Confirm"})]})]})})]})}),JS={root:{flexGrow:1,width:"100%",overflow:"hidden"},panel:{width:"100%",height:"calc(100% - 44px)",padding:10,overflow:"scroll"}},El=({children:t})=>p(s.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"100%"},children:[i(s.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:t}),i($S,{})]});function ZS(t){return!["richText","button"].includes(t)}const HS=k.observer(({panel:t})=>{const e=Ue.useModals(),n=he(),r=K(),[a,o]=y.useState("Data"),l=t.queries,c=ZS(t.viz.type)&&t.dataLoading,d=c||t.queryErrors.length>0||t.queryStateMessages.length>0||l.length===0,f=n.editor.path[1];y.useEffect(()=>{o(m=>d&&m==="Visualization"?"Data":m)},[t.id,d]);const h=()=>{n.editor.setPath(["_VIEWS_",f])},g=()=>e.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.removePanelByID(t.id,f),h()},confirmProps:{color:"red"},zIndex:320});return p(Sr,{value:{panel:t,data:t.data,loading:c,errors:t.queryErrors},children:[p(s.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[p(s.Text,{pt:9,pb:8,children:[t.title?t.title:t.viz.type," "]}),p(s.Group,{position:"right",noWrap:!0,children:[i(XS,{panel:t,sourceViewID:f}),i(s.Button,{size:"xs",variant:"subtle",color:"red",onClick:g,leftIcon:i(L.IconTrash,{size:14}),children:"Delete This Panel"})]})]}),p(s.Tabs,{value:a,onTabChange:o,keepMounted:!1,styles:JS,children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"Data",disabled:c,children:"Data"}),i(s.Tabs.Tab,{value:"Panel",children:"Panel"}),i(s.Tabs.Tab,{value:"Variables",disabled:d,children:i(s.Tooltip,{label:"Requires data",disabled:!d,withinPortal:!0,zIndex:310,children:i(s.Text,{children:"Variables"})})}),i(s.Tabs.Tab,{value:"Visualization",disabled:d,children:i(s.Tooltip,{label:"Requires data",disabled:!d,withinPortal:!0,zIndex:310,children:i(s.Text,{children:"Visualization"})})}),i(s.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),p(s.Tabs.Panel,{value:"Data",children:[i(s.LoadingOverlay,{visible:c,exitTransitionDuration:0}),i(zS,{})]}),i(s.Tabs.Panel,{value:"Panel",children:i(El,{children:i(IS,{})})}),i(s.Tabs.Panel,{value:"Variables",children:i(jS,{})}),i(s.Tabs.Panel,{value:"Visualization",children:i(Fe,{children:i(El,{children:i(US,{})})})}),i(s.Tabs.Panel,{value:"Interactions",children:i(Fe,{children:i(Nc,{})})})]})]})}),e_=k.observer(({viewID:t,panelID:e})=>{const n=K();if(!n.views.findByID(t))return p(s.Text,{size:14,children:["View by ID[",t,"] is not found"]});const a=n.panels.findByID(e);return a?i(HS,{panel:a}):p(s.Text,{size:14,children:["Panel by ID[",e,"] is not found"]})}),Al=({width:t="calc(100% - 32px)",lastWidth:e="50%",height:n,count:r,spacing:a=16,pl:o=0})=>p(s.Stack,{spacing:a,mt:6,pl:o,children:[Array.from(new Array(r-1),(l,u)=>i(s.Skeleton,{width:t,height:n,radius:"xs"},u)),i(s.Skeleton,{width:e,height:n,radius:"xs"})]}),on=({value:t})=>t===null||t===""?null:i(s.Tooltip,{label:t,disabled:!t,multiline:!0,children:i(s.ActionIcon,{children:i(L.IconInfoCircle,{size:14})})}),t_=({column:t})=>{const{column_key:e,column_key_text:n}=t;return e?i(s.Tooltip,{label:n,disabled:!n,children:i(s.Badge,{children:e})}):null},n_=k.observer(({dataSource:t})=>{const{columns:e}=t;return e.loading?i(Al,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):e.empty?null:p(s.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("colgroup",{children:[i("col",{style:{width:50}}),i("col",{style:{minWidth:300}}),i("col",{style:{width:30}}),i("col",{style:{width:70}}),i("col",{style:{minWidth:300}}),i("col",{style:{minWidth:80,width:80}}),i("col",{style:{minWidth:120,width:120}})]}),i("thead",{children:p("tr",{children:[i("th",{children:"#"}),i("th",{children:"Column Name"}),i("th",{}),i("th",{}),i("th",{children:"Type"}),i("th",{children:"Nullable"}),i("th",{children:"Default Value"})]})}),i("tbody",{children:e.data.map(n=>p("tr",{children:[i("td",{children:n.ordinal_position}),i("td",{children:n.column_name}),i("td",{children:i(on,{value:n.column_comment})}),i("td",{children:i(t_,{column:n})}),i("td",{children:n.column_type}),i("td",{children:n.is_nullable}),i("td",{children:i(on,{value:n.column_default})})]},n.column_name))})]})}),r_=k.observer(({dataSource:t})=>{const{indexes:e}=t,n=e.data;return p(s.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("colgroup",{children:[i("col",{style:{width:100}}),i("col",{style:{minWidth:300}}),i("col",{style:{width:150}}),i("col",{style:{width:150}}),i("col",{style:{width:250}})]}),i("thead",{children:p("tr",{children:[i("th",{children:"Index Length"}),i("th",{children:"Index Name"}),i("th",{children:"Index Algorithm"}),i("th",{children:"Unique"}),i("th",{children:"Column Name"})]})}),i("tbody",{children:n.map(r=>p("tr",{children:[i("td",{children:r.index_length}),i("td",{children:r.index_name}),i("td",{children:r.index_algorithm}),i("td",{children:r.is_unique?"YES":"NO"}),i("td",{children:r.column_name})]},r.index_name))})]})}),i_=k.observer(({dataSource:t})=>{const{indexes:e}=t,n=e.data;return p(s.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("colgroup",{children:[i("col",{style:{minWidth:300}}),i("col",{style:{width:150}}),i("col",{style:{width:100}}),i("col",{style:{width:100}}),i("col",{style:{width:100}}),i("col",{style:{width:100}})]}),i("thead",{children:p("tr",{children:[i("th",{children:"Index Name"}),i("th",{children:"Index Algorithm"}),i("th",{children:"Unique"}),i("th",{children:"Definition"}),i("th",{children:"Condition"}),i("th",{children:"Comment"})]})}),i("tbody",{children:n.map(r=>p("tr",{children:[i("td",{children:r.index_name}),i("td",{children:r.index_algorithm}),i("td",{children:r.is_unique?"YES":"NO"}),i("td",{children:i(on,{value:r.index_definition})}),i("td",{children:i(on,{value:r.condition})}),i("td",{children:i(on,{value:r.comment})})]},r.index_name))})]})}),a_=k.observer(({dataSource:t})=>{const{indexes:e}=t;return e.loading||e.empty?null:t.type===ye.MySQL?i(r_,{dataSource:t}):t.type===ye.Postgresql?i(i_,{dataSource:t}):null}),s_=k.observer(({dataSource:t})=>p(s.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[i(Fe,{children:i(n_,{dataSource:t})}),i(Fe,{children:i(a_,{dataSource:t})})]}));function o_({table_type:t}){return t==="VIEW"?i(L.IconEye,{size:14}):t==="BASE TABLE"?i(L.IconTable,{size:14}):null}const l_=k.observer(({dataSource:t})=>{const{tables:e}=t;return e.loading?i(Al,{height:"24px",lastWidth:"50%",count:15}):i(s.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(e.data).map(([n,r])=>i(s.NavLink,{label:n,icon:i(L.IconDatabase,{size:14}),defaultOpened:t.table_schema===n,pl:0,childrenOffset:14,children:r.map(a=>i(s.NavLink,{label:a.table_name,icon:i(o_,{table_type:a.table_type}),onClick:()=>{t.setKeywords(n,a.table_name)},active:t.table_name===a.table_name},a.table_name))},n))})}),u_=({visible:t})=>i(s.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:i(s.LoadingOverlay,{visible:t})}),c_=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],d_={icon:{width:"50px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"50px"}}},p_=k.observer(({dataSource:t})=>{const{tableData:e}=t;return p(s.Group,{pt:10,px:10,position:"apart",children:[p(s.Group,{position:"left",children:[e.maxPage>1&&i(s.Pagination,{size:"sm",value:e.page,onChange:e.setPage,total:e.maxPage,withEdges:e.maxPage>7,styles:{control:{height:"30px"}}}),i(s.Select,{icon:i(s.Text,{ta:"center",color:"dimmed",size:14,children:"Limit"}),size:"xs",styles:d_,data:c_,value:String(e.limit),onChange:n=>e.setLimit(Number(n))})]}),i(s.Group,{position:"right",children:p(s.Text,{color:"dimmed",my:0,size:14,children:["Total ",e.total," rows"]})})]})}),h_=k.observer(({dataSource:t})=>{const e=t.tableData;return e.maxPage===0?i(s.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):e.error?i(s.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.error}):e.page===1&&e.loading?i(u_,{visible:!0}):p(Fe,{children:[i(p_,{dataSource:t}),p(s.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[i(s.LoadingOverlay,{visible:e.loading,overlayBlur:2}),i(Dl,{data:e.data})]})]})}),f_={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},g_=k.observer(({dataSource:t})=>(y.useEffect(()=>{t.loadTablesIfEmpty()},[t]),t.tables.error?i(s.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:t.tables.error}):p(s.Flex,{sx:{height:"100%"},children:[i(s.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:i(Fe,{children:i(l_,{dataSource:t})})}),p(s.Tabs,{defaultValue:"structure",styles:f_,children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"structure",icon:i(L.IconColumns,{size:14}),children:"Structure"}),i(s.Tabs.Tab,{value:"data",icon:i(L.IconDatabase,{size:14}),children:"Data"})]}),i(s.Tabs.Panel,{value:"structure",children:i(s_,{dataSource:t})}),i(s.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:i(h_,{dataSource:t})})]})]}))),m_={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"20px 20px 10px",borderBottom:"1px solid #efefef",gap:"20px"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},zl=k.observer(({dataSource:t,triggerButtonProps:e={}})=>{const[n,r]=y.useState(!1);return t.type==="http"?null:p(V,{children:[i(s.Modal,{opened:n,onClose:()=>r(!1),title:p(s.Group,{position:"apart",sx:{flexGrow:1},children:[i(s.Text,{fw:500,children:"Explorer Data Source"}),p(s.Group,{spacing:7,children:[i(s.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:t.key}),i(s.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:t.type})]})]}),zIndex:320,size:"96vw",styles:m_,children:i(s.Box,{sx:{height:"calc(100vh - 220px)"},children:i(g_,{dataSource:t})})}),i(s.Button,{variant:"subtle",onClick:()=>r(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...e,children:"See Table Structure"})]})}),y_=y.forwardRef(({label:t,type:e,...n},r)=>p(s.Group,{position:"apart",ref:r,...n,children:[i(s.Text,{children:t}),i(s.Text,{children:e})]})),b_=k.observer(({value:t,onChange:e})=>{const n=he(),{data:r=[],loading:a}=X.useRequest(fr,{refreshDeps:[]},[]),o=y.useMemo(()=>r.map(d=>({label:d.key,value:d.key,type:d.type})),[r]),l=y.useMemo(()=>o.reduce((d,f)=>(d[f.value]=f.type,d),{}),[o]),u=d=>{d!==null&&e({key:d,type:l[d]})},c=y.useMemo(()=>n.datasources.find(t),[n,t]);return i(s.Select,{data:o,label:p(s.Group,{position:"apart",children:[i(s.Box,{children:"Data Source"}),c&&i(zl,{dataSource:c,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:y_,rightSection:c?i(s.Text,{size:"xs",color:"dimmed",children:c.type}):void 0,rightSectionWidth:85,maxDropdownHeight:280,styles:{root:{flex:1},label:{display:"block"},rightSection:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:a,value:t.key,onChange:u})}),v_=t=>{const{queryModel:e}=t,n=he(),r=K(),o=r.findQueryUsage(e.id).length>0,l=Ue.useModals(),u=()=>{l.openConfirmModal({title:"Delete this query?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.queries.removeQuery(e.id),n.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return o?i(s.Tooltip,{label:"Can't delete this query for it's being used, check out Usage tab for details",withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,children:i(s.Button,{color:"gray",size:"xs",leftIcon:i(L.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})}):i(s.Button,{color:"red",size:"xs",onClick:u,leftIcon:i(L.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})},x_=k.observer(v_),w_=k.observer(({queryModel:t})=>{const[e,n]=y.useState(t.name);return y.useEffect(()=>{n(t.name)},[t.name]),i(s.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:p(s.Stack,{spacing:10,sx:{width:"100%"},children:[i(s.Divider,{mb:-10,variant:"dashed",label:"Basics",labelPosition:"center"}),i(s.TextInput,{placeholder:"A unique name",label:"Name",required:!0,sx:{flex:1},value:e,onChange:r=>{n(r.currentTarget.value)},rightSection:i(s.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>t.setName(e),disabled:e===t.name,children:i(L.IconDeviceFloppy,{size:16})}),onBlur:()=>{t.setName(e)}}),i(b_,{value:{type:t.type,key:t.key},onChange:({type:r,key:a})=>{t.setKey(a),t.setType(r)}}),i(s.Divider,{mt:10,mb:-10,variant:"dashed",label:"Conditions",labelPosition:"center"}),i(s.MultiSelect,{label:"Run query when these are truthy",placeholder:"Always run this query on load",data:t.conditionOptions,value:[...t.run_by],onChange:t.setRunBy}),t.typedAsHTTP&&i(s.MultiSelect,{label:"Re-run query when these changed",placeholder:"Leave it empty to never re-run this query",data:t.conditionOptions,value:[...t.react_to],onChange:t.setReactTo}),i(s.Divider,{mt:20,mb:10,variant:"dashed"}),i(x_,{queryModel:t})]})})});function C_(){const[t,{open:e,close:n}]=Me.useDisclosure(!1);return p(V,{children:[i(s.Modal,{opened:t,onClose:n,title:"About FunctionUtils",zIndex:320,children:i(Kn,{value:du,styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),i(s.Button,{variant:"light",color:"violet",size:"xs",onClick:e,leftIcon:i(L.IconInfoCircle,{size:16}),children:"About parameter 'utils'"})]})}const S_=({value:t,onChange:e})=>{const n=r=>{r&&e(r)};return i(s.Box,{sx:{position:"relative",flexGrow:1},children:i(Ie,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:t,onChange:n,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}}})})},ar=y.forwardRef(({value:t,onChange:e,label:n,defaultValue:r},a)=>{const[o,l]=y.useState(t),u=()=>{e(o)},c=()=>{l(t)},d=()=>{l(r)};y.useEffect(()=>{l(t)},[t]);const f=o!==t;return p(s.Stack,{spacing:4,sx:{height:"100%"},children:[p(s.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[i(s.Group,{position:"left",children:i(C_,{})}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:d,size:"xs",variant:"default",leftIcon:i(L.IconPlayerSkipBack,{size:16}),children:"Reset to default"}),i(s.Button,{onClick:c,color:"red",size:"xs",disabled:!f,leftIcon:i(L.IconRecycle,{size:16}),children:"Revert Changes"}),i(s.Button,{size:"xs",onClick:u,disabled:!f,leftIcon:i(L.IconDeviceFloppy,{size:16}),children:"Confirm Changes"})]})]}),i(s.Text,{size:14,children:n}),i(S_,{value:o,onChange:l})]})});function __({content:t}){return p(s.HoverCard,{width:"60vw",shadow:"md",children:[i(s.HoverCard.Target,{children:i(s.ActionIcon,{size:16,color:"blue",children:i(L.IconEye,{})})}),i(s.HoverCard.Dropdown,{children:i(kt.Prism,{language:"sql",noCopy:!0,withLineNumbers:!0,children:t})})]})}const k_=k.observer(()=>{const e=[...he().globalSQLSnippets.list];return e.length===0?null:p(s.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fontSize:"sm",highlightOnHover:!0,children:[i("thead",{children:p("tr",{children:[i("th",{children:"Key"}),i("th",{children:"Value"})]})}),i("tbody",{children:e.map(n=>{const{id:r,content:a}=n;return p("tr",{children:[i("td",{children:r}),i("td",{width:200,children:i(__,{content:a})})]},r)})})]})}),T_=`
|
|
496
|
+
`,bS=()=>{const[t,e]=y.useState(!1);return p(V,{children:[i(s.Button,{variant:"subtle",compact:!0,onClick:()=>e(n=>!n),children:t?"Close":"Click to see expected data structure"}),i(s.Collapse,{in:t,children:i(kt.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:yS})})]})},vS=k.observer(function({config:e}){return p(V,{children:[i(s.TextInput,{label:"Min-width",value:e.min_width,onChange:n=>e.setMinWidth(n.currentTarget.value),placeholder:"200px"}),i(s.Divider,{label:"Fetch options from database",labelPosition:"center"}),i(s.NumberInput,{value:e.default_selection_count,onChange:e.setDefaultSelectionCount,label:"Select first N options by default"}),i(zi,{value:e.options_query_id,onChange:e.setOptionsQueryID}),i(bS,{})]})}),xS=k.observer(function({filter:e}){const[n,r]=y.useState(e.plainDefaultValue);return y.useEffect(()=>{r(e.plainDefaultValue)},[e]),p(s.Box,{sx:{maxWidth:"480px"},children:[i(s.Text,{pb:"md",color:"gray",children:"Preview"}),i(dl,{filter:e,value:n,onChange:r}),i(s.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),i(kt.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(e,null,4)})]})}),wS={select:gS,"multi-select":fS,"tree-select":vS,"text-input":mS,checkbox:cS,"date-range":pS},CS=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Tree Select",value:"tree-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],SS=k.observer(function({filter:e}){const n=K(),r=y.useMemo(()=>wS[e.type],[e.type]);return p(s.Group,{grow:!0,spacing:20,align:"top",children:[p(s.Box,{sx:{maxWidth:"600px"},children:[i(s.Text,{pb:"md",color:"gray",children:"Edit"}),p(s.Stack,{children:[p(s.Group,{noWrap:!0,children:[i(s.NumberInput,{label:"Placement Order",required:!0,value:e.order,onChange:e.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),e.auto_submit_supported&&i(s.Checkbox,{label:"Submit automatically",checked:e.auto_submit,onChange:a=>e.setAutoSubmit(a.currentTarget.checked),mt:22})]}),i(s.MultiSelect,{label:"Visible in...",data:n.views.options,value:[...e.visibleInViewsIDs],onChange:e.setVisibleInViewsIDs}),i(s.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:e.key,onChange:a=>{e.setKey(a.currentTarget.value)}}),i(s.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:e.label,onChange:a=>{e.setLabel(a.currentTarget.value)}}),i(s.Select,{label:"Widget",data:CS,required:!0,value:e.type,onChange:e.setType}),i(r,{config:e.config})]})]}),i(xS,{filter:e})]})}),_S=k.observer(({id:t})=>{const e=Ue.useModals(),n=he(),r=K();if(t==="")return null;const a=r.filters.findByID(t);if(!a)return p(s.Text,{size:14,children:["Filter by ID[",t,"] is not found"]});const o=()=>{n.editor.setPath(["_FILTERS_",""])},l=()=>{e.openConfirmModal({title:"Delete this filter?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.filters.removeByID(t),o()},confirmProps:{color:"red"},zIndex:320})};return p(s.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[i(s.Group,{position:"right",pt:10,children:i(s.Button,{size:"xs",color:"red",leftIcon:i(D.Trash,{size:16}),onClick:l,children:"Delete this filter"})}),i(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:i(SS,{filter:a})})]})}),kS=k.observer(()=>{const t=K(),[e,n]=y.useState(()=>JSON.stringify(t.mock_context.current,null,4)),r=()=>{try{t.mock_context.replace(JSON.parse(e))}catch(o){hn.showNotification({title:"Failed",message:o.message,color:"red"})}},a=y.useMemo(()=>{try{return JSON.stringify(JSON.parse(e))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[e,t.mock_context.current]);return p(s.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[i(s.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:i(s.Text,{weight:500,children:"Mock Context"})}),p(s.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[p(s.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[i(s.Text,{children:"A valid json string is required"}),i(s.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:e,onChange:n,sx:{flexGrow:1}})]}),i(s.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!a,onClick:r,children:i(D.DeviceFloppy,{size:20})})]})]})}),TS=k.observer(()=>{const{panel:t}=ze();return i(ai,{label:"Description",value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}})}),DS=k.observer(()=>{const{panel:t}=ze(),{style:e}=t;return i(V,{children:i(s.Switch,{label:"Border",checked:e.border.enabled,onChange:n=>e.border.setEnabled(n.currentTarget.checked)})})}),MS=k.observer(()=>{const{panel:t}=ze(),{title:e,setTitle:n}=t,[r,a]=Me.useInputState(e),o=e!==r,l=y.useCallback(()=>{o&&n(r)},[o,r]);return y.useEffect(()=>{a(e)},[e]),i(s.TextInput,{value:r,onChange:a,label:p(s.Group,{children:[i(s.Text,{children:"Panel Title"}),i(s.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:l,children:i(D.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function IS(){return p(s.Stack,{sx:{height:"100%"},children:[i(s.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),i(DS,{}),i(s.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),i(MS,{}),i(TS,{})]})}const ES=({queryID:t})=>{const e=K(),{state:n,error:r}=e.getDataStuffByID(t),a=y.useMemo(()=>e.queries.findByID(t),[e,t]);return n==="loading"?null:r?i(s.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:r}):a!=null&&a.stateMessage?i(s.Text,{color:"gray",align:"center",children:a.stateMessage}):null},AS={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},"th, td":{wordBreak:"break-word"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function Dl({data:t}){const e=y.useMemo(()=>{if(!Array.isArray(t)||t.length===0)return[];const r=Xe.createColumnHelper();return Object.keys(t[0]).map(a=>r.accessor(a,{cell:o=>o.getValue()}))},[t]),n=Xe.useReactTable({data:t,columns:e,columnResizeMode:"onChange",getCoreRowModel:Xe.getCoreRowModel()});return t.length===0?i(s.Box,{sx:{height:"5em"}}):i(Fe,{children:p(s.Table,{sx:AS,children:[i("thead",{children:n.getHeaderGroups().map(r=>i("tr",{children:r.headers.map(a=>p("th",{style:{width:a.getSize()},children:[a.isPlaceholder?null:Xe.flexRender(a.column.columnDef.header,a.getContext()),i(s.ActionIcon,{onMouseDown:a.getResizeHandler(),onTouchStart:a.getResizeHandler(),className:`resizer ${a.column.getIsResizing()?"isResizing":""}`,children:i(D.ArrowBarToRight,{})})]},a.id))},r.id))}),i("tbody",{children:n.getRowModel().rows.map(r=>i("tr",{children:r.getVisibleCells().map(a=>i("td",{children:i(Fe,{children:Xe.flexRender(a.column.columnDef.cell,a.getContext())})},a.id))},r.id))})]})})}const $i=k.observer(function({id:e,moreActions:n=null}){const r=K(),{data:a,state:o}=r.getDataStuffByID(e),l=o==="loading",u=()=>{r.queries.refetchDataByQueryID(e)},c=()=>{r.queries.downloadDataByQueryID(e)},d=y.useMemo(()=>Array.isArray(a)?a.slice(0,10):[],[a]),f=!Array.isArray(a)||a.length===0;return p(s.Stack,{sx:{border:"1px solid #eee"},children:[p(s.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[p(s.Group,{position:"left",children:[i(s.Text,{weight:500,children:"Preview Data"}),a.length>10&&p(s.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",a.length]})]}),p(s.Group,{pr:15,children:[n,i(s.ActionIcon,{variant:"subtle",color:"blue",disabled:l,onClick:u,children:i(D.Refresh,{size:16})}),i(s.ActionIcon,{variant:"subtle",color:"blue",disabled:l||f,onClick:c,children:i(D.Download,{size:16})})]})]}),p(s.Box,{sx:{position:"relative",overflow:"auto"},children:[i(s.LoadingOverlay,{visible:l}),i(ES,{queryID:e}),i(Dl,{data:d})]})]})}),zS=k.observer(function(){const e=he(),n=K(),{panel:r}=ze(),[a,o]=y.useState(!1),l=u=>{e.editor.setPath(["_QUERIES_",u])};return p(V,{children:[i(s.Drawer,{opened:a,onClose:()=>o(!1),title:"Choose queries",padding:"xl",size:500,zIndex:320,children:i(s.Checkbox.Group,{value:[...r.queryIDs],onChange:r.setQueryIDs,children:i(s.Stack,{spacing:"lg",children:n.queries.options.map(u=>i(s.Checkbox,{label:u.label,value:u.value},u.value))})})}),p(s.Stack,{spacing:6,children:[i(s.Group,{position:"right",children:i(s.Button,{variant:"light",size:"sm",leftIcon:i(L.IconLine,{size:16}),onClick:()=>o(!0),children:"Click me to choose queries for this panel"})}),r.queryIDs.length===1&&i($i,{id:r.queryIDs[0],moreActions:i(s.Tooltip,{label:"Open this query",children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>l(r.queryIDs[0]),children:i(L.IconArrowCurveRight,{size:16})})})}),r.queryIDs.length>1&&p(s.Tabs,{defaultValue:r.queryIDs[0],children:[i(s.Tabs.List,{children:r.queries.map(u=>i(s.Tabs.Tab,{value:u.id,children:u.name},u.id))}),r.queries.map(u=>i(s.Tabs.Panel,{value:u.id,children:i($i,{id:u.id,moreActions:i(s.Tooltip,{label:"Open this query",children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>l(u.id),children:i(L.IconArrowCurveRight,{size:16})})})})},u.id))]})]})]})}),$S=k.observer(()=>{const{panel:t}=ze();return i(Fe,{children:i(s.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:p(s.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.style.border.enabled?"1px":"0px"},children:[p(s.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[i(s.Group,{children:i(hl,{})}),i(s.Group,{grow:!0,position:"center",children:i(s.Text,{lineClamp:1,weight:"bold",children:t.title})}),i(s.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),i(s.Group,{px:5,pb:5,sx:{flexGrow:1},children:i(bl,{panel:t,height:"410px"})})]})})})}),Li={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{}},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class LS{constructor(e){N(this,"panel");N(this,"selected");this.panel=e,ie.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const e=this.panel.variables.filter(n=>n.name.startsWith(Li.name)).length;this.panel.addVariable(x.cloneDeep({...Li,name:`${Li.name}${e||""}`})),this.selected=x.last(this.panel.variables)}select(e){this.selected=e}remove(e){this.selected===e&&(this.selected=void 0);const n=this.panel.variables.indexOf(e);if(this.panel.removeVariable(e),!this.selected&&!x.isEmpty(this.panel.variables)){const r=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[r]}}}function OS(){const{panel:t}=ze();return X.useCreation(()=>new LS(t),[t])}const Ml=s.createStyles(t=>({root:{height:"100%",overflow:"hidden",".var-list-container":{"& > *":{height:"100%"},width:250,height:"100%"},".var-list-actions":{height:"fit-content",flexShrink:0,width:"100%"},".var-list":{flex:"1 1 auto",overflow:"auto",minHeight:0,"& > *":{flex:"0 0 auto"}}},config:{height:"100%",overflow:"auto",paddingRight:10}})),PS=y.forwardRef(function({value:e,onChange:n,data:r,withStyle:a=!0},o){const l=(u,c)=>{const d=x.cloneDeep(e);x.set(d,u,c),n(d)};return p(s.Box,{px:"sm",py:"md",ref:o,children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(s.TextInput,{label:"Name",required:!0,value:e.name,onChange:u=>l("name",u.currentTarget.value)}),i(j,{label:"Data Field",required:!0,value:e.data_field,onChange:u=>l("data_field",u)})]}),i(Sn,{label:"Aggregation",value:e.aggregation,onChange:u=>l("aggregation",u)}),i(s.Divider,{my:"xs",label:"Format",labelPosition:"center"}),i(Re,{value:e.formatter,onChange:u=>l("formatter",u)}),a&&i(Ts,{value:e,onChange:n})]})}),BS=t=>{const{uiModel:e}=t;return i(s.Stack,{className:"var-list",children:e.variables.map(n=>i(s.Button,{variant:e.selected===n?"filled":"subtle",color:"gray",onClick:()=>e.select(n),children:n.name},n.name))})},VS=k.observer(BS),NS=({variable:t,data:e})=>i(s.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:i(s.Paper,{withBorder:!0,p:"md",children:Ds(t,e)})}),qS=k.observer(NS),FS=t=>{const e=X.useCreation(()=>Uu(t.variable),[t.variable]),{classes:n}=Ml(),{data:r}=ze();return p(s.Group,{style:{height:"100%"},align:"start",children:[p(s.Stack,{"data-testid":"variable-editor",align:"stretch",className:n.config,children:[p(s.Group,{position:"right",children:[i(s.ActionIcon,{variant:"filled",disabled:!e.changed,color:"primary",onClick:e.commit,children:i(L.IconDeviceFloppy,{size:18})}),i(s.ActionIcon,{color:"red",onClick:()=>t.uiModel.remove(t.variable),children:i(L.IconTrash,{size:18})})]}),i(PS,{value:b.getSnapshot(e.copy),onChange:e.update,data:r})]}),i(qS,{variable:b.getSnapshot(e.copy),data:r})]})},GS=k.observer(FS),WS=()=>{const t=OS(),{classes:e}=Ml();return p(s.Group,{className:e.root,noWrap:!0,align:"start",children:[i(s.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:p(s.Stack,{justify:"space-between",children:[i(s.Box,{className:"var-list-actions",children:i(s.Button,{variant:"light",size:"sm",onClick:t.addNew,fullWidth:!0,children:"Add Variable"})}),i(VS,{uiModel:t})]})}),t.selected?i(V,{children:i(GS,{uiModel:t,variable:t.selected})}):i("span",{children:"Select or create a new variable on right side"})]})},jS=k.observer(WS);function RS(){const{vizManager:t}=y.useContext(at);return y.useMemo(()=>{const e=t.availableVizList.map(n=>({value:n.name,label:n.displayName??n.name,group:n.displayGroup??""}));return x.orderBy(e,[n=>n.group,n=>n.label],["asc","asc"])},[t])}const YS=k.observer(({value:t,submit:e})=>{const[n,r]=Me.useInputState(t);y.useEffect(()=>{r(t)},[t]);const a=RS(),o=t!==n;return i(s.Select,{label:"Visualization",value:n,searchable:!0,onChange:r,data:a,rightSection:i(s.ActionIcon,{disabled:!o,onClick:()=>e(n),children:i(D.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),Il=[];function QS(t,e){try{return t.resolveComponent(e).createConfig()}catch{return null}}function KS(){const{data:t,panel:{variables:e,viz:n,title:r,queryIDs:a,description:o,setDescription:l,setTitle:u,addQueryID:c,removeQueryID:d,id:f}}=ze(),{vizManager:h}=y.useContext(at),g={title:r,description:o,viz:n,queryIDs:a,id:f},m={setDescription:l,addQueryID:c,removeQueryID:d,setTitle:u},w=gl(g);try{return h.resolveComponent(g.viz.type),i(Hn,{configure:w,children:i(n1,{variables:e,setVizConf:n.setConf,panel:g,panelInfoEditor:m,vizManager:h,data:t})})}catch(C){return console.info(x.get(C,"message")),null}}const US=k.observer(()=>{const{data:t,panel:{viz:e}}=ze(),{vizManager:n}=y.useContext(at),r=y.useCallback(d=>{if(d===e.type)return;const f=QS(n,d);e.setType(d),e.setConf(f||{})},[e.type]),a=d=>{try{e.setConf(JSON.parse(d))}catch(f){console.error(f)}},o=y.useMemo(()=>{var d;return(d=Il.find(f=>f.value===e.type))==null?void 0:d.Panel},[e.type,Il]),l=KS(),u=o?y.createElement(o,{data:t,conf:e.conf,setConf:e.setConf}):null,c=l||u;return p(s.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[i(YS,{submit:r,value:e.type}),p(Fe,{children:[i(s.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:c}),!c&&i(s.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(e.conf,null,2),onChange:a})]})]})}),XS=k.observer(({panel:t,sourceViewID:e})=>{const n=K(),[r,a]=y.useState(e);y.useEffect(()=>{a(e)},[e]);const[o,{open:l,close:u}]=Me.useDisclosure(!1),c=()=>{t.moveToView(e,r),u()};return p(V,{children:[i(s.Button,{size:"xs",variant:"subtle",color:"blue",onClick:l,leftIcon:i(L.IconBoxMultiple,{size:14}),children:"Move into Another View"}),i(s.Modal,{opened:o,onClose:u,title:"Move panel into another view",zIndex:320,children:p(s.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[i(s.Radio.Group,{value:r,onChange:a,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:i(s.Stack,{spacing:"xs",children:n.views.options.map(d=>i(s.Radio,{value:d.value,label:d.label},d.value))})}),p(s.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[i(s.Button,{size:"xs",color:"red",leftIcon:i(L.IconX,{size:14}),onClick:u,children:"Cancel"}),i(s.Button,{size:"xs",color:"blue",leftIcon:i(L.IconDeviceFloppy,{size:14}),onClick:c,disabled:r===e,children:"Confirm"})]})]})})]})}),JS={root:{flexGrow:1,width:"100%",overflow:"hidden"},panel:{width:"100%",height:"calc(100% - 44px)",padding:10,overflow:"scroll"}},El=({children:t})=>p(s.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"100%"},children:[i(s.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:t}),i($S,{})]});function ZS(t){return!["richText","button"].includes(t)}const HS=k.observer(({panel:t})=>{const e=Ue.useModals(),n=he(),r=K(),[a,o]=y.useState("Data"),l=t.queries,c=ZS(t.viz.type)&&t.dataLoading,d=c||t.queryErrors.length>0||t.queryStateMessages.length>0||l.length===0,f=n.editor.path[1];y.useEffect(()=>{o(m=>d&&m==="Visualization"?"Data":m)},[t.id,d]);const h=()=>{n.editor.setPath(["_VIEWS_",f])},g=()=>e.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.removePanelByID(t.id,f),h()},confirmProps:{color:"red"},zIndex:320});return p(Sr,{value:{panel:t,data:t.data,loading:c,errors:t.queryErrors},children:[p(s.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[p(s.Text,{pt:9,pb:8,children:[t.title?t.title:t.viz.type," "]}),p(s.Group,{position:"right",noWrap:!0,children:[i(XS,{panel:t,sourceViewID:f}),i(s.Button,{size:"xs",variant:"subtle",color:"red",onClick:g,leftIcon:i(L.IconTrash,{size:14}),children:"Delete This Panel"})]})]}),p(s.Tabs,{value:a,onTabChange:o,keepMounted:!1,styles:JS,children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"Data",disabled:c,children:"Data"}),i(s.Tabs.Tab,{value:"Panel",children:"Panel"}),i(s.Tabs.Tab,{value:"Variables",disabled:d,children:i(s.Tooltip,{label:"Requires data",disabled:!d,withinPortal:!0,zIndex:310,children:i(s.Text,{children:"Variables"})})}),i(s.Tabs.Tab,{value:"Visualization",disabled:d,children:i(s.Tooltip,{label:"Requires data",disabled:!d,withinPortal:!0,zIndex:310,children:i(s.Text,{children:"Visualization"})})}),i(s.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),p(s.Tabs.Panel,{value:"Data",children:[i(s.LoadingOverlay,{visible:c,exitTransitionDuration:0}),i(zS,{})]}),i(s.Tabs.Panel,{value:"Panel",children:i(El,{children:i(IS,{})})}),i(s.Tabs.Panel,{value:"Variables",children:i(jS,{})}),i(s.Tabs.Panel,{value:"Visualization",children:i(Fe,{children:i(El,{children:i(US,{})})})}),i(s.Tabs.Panel,{value:"Interactions",children:i(Fe,{children:i(Nc,{})})})]})]})}),e_=k.observer(({viewID:t,panelID:e})=>{const n=K();if(!n.views.findByID(t))return p(s.Text,{size:14,children:["View by ID[",t,"] is not found"]});const a=n.panels.findByID(e);return a?i(HS,{panel:a}):p(s.Text,{size:14,children:["Panel by ID[",e,"] is not found"]})}),Al=({width:t="calc(100% - 32px)",lastWidth:e="50%",height:n,count:r,spacing:a=16,pl:o=0})=>p(s.Stack,{spacing:a,mt:6,pl:o,children:[Array.from(new Array(r-1),(l,u)=>i(s.Skeleton,{width:t,height:n,radius:"xs"},u)),i(s.Skeleton,{width:e,height:n,radius:"xs"})]}),on=({value:t})=>t===null||t===""?null:i(s.Tooltip,{label:t,disabled:!t,multiline:!0,children:i(s.ActionIcon,{children:i(L.IconInfoCircle,{size:14})})}),t_=({column:t})=>{const{column_key:e,column_key_text:n}=t;return e?i(s.Tooltip,{label:n,disabled:!n,children:i(s.Badge,{children:e})}):null},n_=k.observer(({dataSource:t})=>{const{columns:e}=t;return e.loading?i(Al,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):e.empty?null:p(s.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("colgroup",{children:[i("col",{style:{width:50}}),i("col",{style:{minWidth:300}}),i("col",{style:{width:30}}),i("col",{style:{width:70}}),i("col",{style:{minWidth:300}}),i("col",{style:{minWidth:80,width:80}}),i("col",{style:{minWidth:120,width:120}})]}),i("thead",{children:p("tr",{children:[i("th",{children:"#"}),i("th",{children:"Column Name"}),i("th",{}),i("th",{}),i("th",{children:"Type"}),i("th",{children:"Nullable"}),i("th",{children:"Default Value"})]})}),i("tbody",{children:e.data.map(n=>p("tr",{children:[i("td",{children:n.ordinal_position}),i("td",{children:n.column_name}),i("td",{children:i(on,{value:n.column_comment})}),i("td",{children:i(t_,{column:n})}),i("td",{children:n.column_type}),i("td",{children:n.is_nullable}),i("td",{children:i(on,{value:n.column_default})})]},n.column_name))})]})}),r_=k.observer(({dataSource:t})=>{const{indexes:e}=t,n=e.data;return p(s.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("colgroup",{children:[i("col",{style:{width:100}}),i("col",{style:{minWidth:300}}),i("col",{style:{width:150}}),i("col",{style:{width:150}}),i("col",{style:{width:250}})]}),i("thead",{children:p("tr",{children:[i("th",{children:"Index Length"}),i("th",{children:"Index Name"}),i("th",{children:"Index Algorithm"}),i("th",{children:"Unique"}),i("th",{children:"Column Name"})]})}),i("tbody",{children:n.map(r=>p("tr",{children:[i("td",{children:r.index_length}),i("td",{children:r.index_name}),i("td",{children:r.index_algorithm}),i("td",{children:r.is_unique?"YES":"NO"}),i("td",{children:r.column_name})]},r.index_name))})]})}),i_=k.observer(({dataSource:t})=>{const{indexes:e}=t,n=e.data;return p(s.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("colgroup",{children:[i("col",{style:{minWidth:300}}),i("col",{style:{width:150}}),i("col",{style:{width:100}}),i("col",{style:{width:100}}),i("col",{style:{width:100}}),i("col",{style:{width:100}})]}),i("thead",{children:p("tr",{children:[i("th",{children:"Index Name"}),i("th",{children:"Index Algorithm"}),i("th",{children:"Unique"}),i("th",{children:"Definition"}),i("th",{children:"Condition"}),i("th",{children:"Comment"})]})}),i("tbody",{children:n.map(r=>p("tr",{children:[i("td",{children:r.index_name}),i("td",{children:r.index_algorithm}),i("td",{children:r.is_unique?"YES":"NO"}),i("td",{children:i(on,{value:r.index_definition})}),i("td",{children:i(on,{value:r.condition})}),i("td",{children:i(on,{value:r.comment})})]},r.index_name))})]})}),a_=k.observer(({dataSource:t})=>{const{indexes:e}=t;return e.loading||e.empty?null:t.type===ye.MySQL?i(r_,{dataSource:t}):t.type===ye.Postgresql?i(i_,{dataSource:t}):null}),s_=k.observer(({dataSource:t})=>p(s.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[i(Fe,{children:i(n_,{dataSource:t})}),i(Fe,{children:i(a_,{dataSource:t})})]}));function o_({table_type:t}){return t==="VIEW"?i(L.IconEye,{size:14}):t==="BASE TABLE"?i(L.IconTable,{size:14}):null}const l_=k.observer(({dataSource:t})=>{const{tables:e}=t;return e.loading?i(Al,{height:"24px",lastWidth:"50%",count:15}):i(s.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(e.data).map(([n,r])=>i(s.NavLink,{label:n,icon:i(L.IconDatabase,{size:14}),defaultOpened:t.table_schema===n,pl:0,childrenOffset:14,children:r.map(a=>i(s.NavLink,{label:a.table_name,icon:i(o_,{table_type:a.table_type}),onClick:()=>{t.setKeywords(n,a.table_name)},active:t.table_name===a.table_name},a.table_name))},n))})}),u_=({visible:t})=>i(s.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:i(s.LoadingOverlay,{visible:t})}),c_=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],d_={icon:{width:"50px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"50px"}}},p_=k.observer(({dataSource:t})=>{const{tableData:e}=t;return p(s.Group,{pt:10,px:10,position:"apart",children:[p(s.Group,{position:"left",children:[e.maxPage>1&&i(s.Pagination,{size:"sm",value:e.page,onChange:e.setPage,total:e.maxPage,withEdges:e.maxPage>7,styles:{control:{height:"30px"}}}),i(s.Select,{icon:i(s.Text,{ta:"center",color:"dimmed",size:14,children:"Limit"}),size:"xs",styles:d_,data:c_,value:String(e.limit),onChange:n=>e.setLimit(Number(n))})]}),i(s.Group,{position:"right",children:p(s.Text,{color:"dimmed",my:0,size:14,children:["Total ",e.total," rows"]})})]})}),h_=k.observer(({dataSource:t})=>{const e=t.tableData;return e.maxPage===0?i(s.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):e.error?i(s.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.error}):e.page===1&&e.loading?i(u_,{visible:!0}):p(Fe,{children:[i(p_,{dataSource:t}),p(s.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[i(s.LoadingOverlay,{visible:e.loading,overlayBlur:2}),i(Dl,{data:e.data})]})]})}),f_={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},g_=k.observer(({dataSource:t})=>(y.useEffect(()=>{t.loadTablesIfEmpty()},[t]),t.tables.error?i(s.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:t.tables.error}):p(s.Flex,{sx:{height:"100%"},children:[i(s.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:i(Fe,{children:i(l_,{dataSource:t})})}),p(s.Tabs,{defaultValue:"structure",styles:f_,children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"structure",icon:i(L.IconColumns,{size:14}),children:"Structure"}),i(s.Tabs.Tab,{value:"data",icon:i(L.IconDatabase,{size:14}),children:"Data"})]}),i(s.Tabs.Panel,{value:"structure",children:i(s_,{dataSource:t})}),i(s.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:i(h_,{dataSource:t})})]})]}))),m_={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"20px 20px 10px",borderBottom:"1px solid #efefef",gap:"20px"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},zl=k.observer(({dataSource:t,triggerButtonProps:e={}})=>{const[n,r]=y.useState(!1);return t.type==="http"?null:p(V,{children:[i(s.Modal,{opened:n,onClose:()=>r(!1),title:p(s.Group,{position:"apart",sx:{flexGrow:1},children:[i(s.Text,{fw:500,children:"Explorer Data Source"}),p(s.Group,{spacing:7,children:[i(s.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:t.key}),i(s.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:t.type})]})]}),zIndex:320,size:"96vw",styles:m_,children:i(s.Box,{sx:{height:"calc(100vh - 220px)"},children:i(g_,{dataSource:t})})}),i(s.Button,{variant:"subtle",onClick:()=>r(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...e,children:"See Table Structure"})]})}),y_=y.forwardRef(({label:t,type:e,...n},r)=>p(s.Group,{position:"apart",ref:r,...n,children:[i(s.Text,{children:t}),i(s.Text,{children:e})]})),b_=k.observer(({value:t,onChange:e})=>{const n=he(),{data:r=[],loading:a}=X.useRequest(fr,{refreshDeps:[]},[]),o=y.useMemo(()=>r.map(d=>({label:d.key,value:d.key,type:d.type})),[r]),l=y.useMemo(()=>o.reduce((d,f)=>(d[f.value]=f.type,d),{}),[o]),u=d=>{d!==null&&e({key:d,type:l[d]})},c=y.useMemo(()=>n.datasources.find(t),[n,t]);return i(s.Select,{data:o,label:p(s.Group,{position:"apart",children:[i(s.Box,{children:"Data Source"}),c&&i(zl,{dataSource:c,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:y_,rightSection:c?i(s.Text,{size:"xs",color:"dimmed",children:c.type}):void 0,rightSectionWidth:85,maxDropdownHeight:280,styles:{root:{flex:1},label:{display:"block"},rightSection:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:a,value:t.key,onChange:u})}),v_=t=>{const{queryModel:e}=t,n=he(),r=K(),o=r.findQueryUsage(e.id).length>0,l=Ue.useModals(),u=()=>{l.openConfirmModal({title:"Delete this query?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.queries.removeQuery(e.id),n.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return o?i(s.Tooltip,{label:"Can't delete this query for it's being used, check out Usage tab for details",withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,children:i(s.Button,{color:"gray",size:"xs",leftIcon:i(L.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})}):i(s.Button,{color:"red",size:"xs",onClick:u,leftIcon:i(L.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})},x_=k.observer(v_),w_=k.observer(({queryModel:t})=>{const[e,n]=y.useState(t.name);return y.useEffect(()=>{n(t.name)},[t.name]),i(s.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:p(s.Stack,{spacing:10,sx:{width:"100%"},children:[i(s.Divider,{mb:-10,variant:"dashed",label:"Basics",labelPosition:"center"}),i(s.TextInput,{placeholder:"A unique name",label:"Name",required:!0,sx:{flex:1},value:e,onChange:r=>{n(r.currentTarget.value)},rightSection:i(s.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>t.setName(e),disabled:e===t.name,children:i(L.IconDeviceFloppy,{size:16})}),onBlur:()=>{t.setName(e)}}),i(b_,{value:{type:t.type,key:t.key},onChange:({type:r,key:a})=>{t.setKey(a),t.setType(r)}}),i(s.Divider,{mt:10,mb:-10,variant:"dashed",label:"Conditions",labelPosition:"center"}),i(s.MultiSelect,{label:"Run query when these are truthy",placeholder:"Always run this query on load",data:t.conditionOptions,value:[...t.run_by],onChange:t.setRunBy}),t.typedAsHTTP&&i(s.MultiSelect,{label:"Re-run query when these changed",placeholder:"Leave it empty to never re-run this query",data:t.conditionOptions,value:[...t.react_to],onChange:t.setReactTo}),i(s.Divider,{mt:20,mb:10,variant:"dashed"}),i(x_,{queryModel:t})]})})});function C_(){const[t,{open:e,close:n}]=Me.useDisclosure(!1);return p(V,{children:[i(s.Modal,{opened:t,onClose:n,title:"About FunctionUtils",zIndex:320,children:i(Kn,{value:du,styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),i(s.Button,{variant:"light",color:"violet",size:"xs",onClick:e,leftIcon:i(L.IconInfoCircle,{size:16}),children:"About parameter 'utils'"})]})}const S_=({value:t,onChange:e})=>{const n=r=>{r&&e(r)};return i(s.Box,{sx:{position:"relative",flexGrow:1},children:i(Ie,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:t,onChange:n,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}}})})},ar=y.forwardRef(({value:t,onChange:e,label:n,defaultValue:r},a)=>{const[o,l]=y.useState(t),u=()=>{e(o)},c=()=>{l(t)},d=()=>{l(r)};y.useEffect(()=>{l(t)},[t]);const f=o!==t;return p(s.Stack,{spacing:4,sx:{height:"100%"},children:[p(s.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[i(s.Group,{position:"left",children:i(C_,{})}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:d,size:"xs",variant:"default",leftIcon:i(L.IconPlayerSkipBack,{size:16}),children:"Reset to default"}),i(s.Button,{onClick:c,color:"red",size:"xs",disabled:!f,leftIcon:i(L.IconRecycle,{size:16}),children:"Revert Changes"}),i(s.Button,{size:"xs",onClick:u,disabled:!f,leftIcon:i(L.IconDeviceFloppy,{size:16}),children:"Confirm Changes"})]})]}),i(s.Text,{size:14,children:n}),i(S_,{value:o,onChange:l})]})});function __({content:t}){return p(s.HoverCard,{width:"60vw",shadow:"md",children:[i(s.HoverCard.Target,{children:i(s.ActionIcon,{size:16,color:"blue",children:i(L.IconEye,{})})}),i(s.HoverCard.Dropdown,{children:i(kt.Prism,{language:"sql",noCopy:!0,withLineNumbers:!0,children:t})})]})}const k_=k.observer(()=>{const e=[...he().globalSQLSnippets.list];return e.length===0?null:p(s.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fontSize:"sm",highlightOnHover:!0,children:[i("thead",{children:p("tr",{children:[i("th",{children:"Key"}),i("th",{children:"Value"})]})}),i("tbody",{children:e.map(n=>{const{id:r,content:a}=n;return p("tr",{children:[i("td",{children:r}),i("td",{width:200,children:i(__,{content:a})})]},r)})})]})}),T_=`
|
|
497
497
|
-- You may reference query variables in SQL or VizConfig.
|
|
498
498
|
SELECT *
|
|
499
499
|
FROM commit
|