@devtable/dashboard 9.16.0 → 9.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3002,7 +3002,7 @@ class Qi {
3002
3002
  }), this.instanceRegistry.clear(), this.factoryRegistry.clear();
3003
3003
  }
3004
3004
  }
3005
- const Gs = "@devtable/dashboard", Ui = "9.16.0", Hs = "Apache-2.0", Qs = {
3005
+ const Gs = "@devtable/dashboard", Ui = "9.16.1", Hs = "Apache-2.0", Qs = {
3006
3006
  access: "public",
3007
3007
  registry: "https://registry.npmjs.org/"
3008
3008
  }, Us = [
@@ -22294,7 +22294,7 @@ function _S({
22294
22294
  }
22295
22295
  const CS = D(() => {
22296
22296
  const t = [...De().globalSQLSnippets.list];
22297
- return /* @__PURE__ */ d(Lt, { horizontalSpacing: "xs", verticalSpacing: "xs", fontSize: "sm", highlightOnHover: !0, children: [
22297
+ return t.length === 0 ? null : /* @__PURE__ */ d(Lt, { horizontalSpacing: "xs", verticalSpacing: "xs", fontSize: "sm", highlightOnHover: !0, children: [
22298
22298
  /* @__PURE__ */ n("thead", { children: /* @__PURE__ */ d("tr", { children: [
22299
22299
  /* @__PURE__ */ n("th", { children: "Key" }),
22300
22300
  /* @__PURE__ */ n("th", { children: "Value" })
@@ -116,7 +116,7 @@ Check the top-level render call using <`+E+">.")}return M}}function oo(_,M){{if(
116
116
  SELECT count(*) AS total
117
117
  FROM ${r}.${t}
118
118
  `}})).actions(e=>({setPage(t){e.page=t},resetPage(){e.page=1},setLimit(t){e.limit=t}})).actions(e=>({afterCreate(){b.addDisposer(e,ie.reaction(()=>e.keywordString,e.resetPage,{fireImmediately:!1,delay:0})),b.addDisposer(e,ie.reaction(()=>e.limit,e.resetPage,{fireImmediately:!1,delay:0}))}})),al=b.types.model("DataSourceModel",{id:b.types.string,type:b.types.enumeration("DataSourceType",[pe.HTTP,pe.MySQL,pe.Postgresql]),key:b.types.string,config:b.types.frozen(),tables:b.types.optional(rl,{}),columns:b.types.optional(tl,{}),tableData:b.types.optional(il,{}),indexes:b.types.optional(nl,{}),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(e=>({setKeywords(t,r){e.table_schema=t,e.table_name=r}})).actions(e=>({initKeywords(){if(e.tables.empty)return;const t=Object.keys(e.tables.data)[0],r=e.tables.data[t][0].table_name;e.setKeywords(t,r)}})).actions(e=>{const t=b.flow(function*(){var r;(r=e.controllers.tables)==null||r.abort(),e.controllers.tables=new AbortController,e.tables.state="loading";try{const i=yield*b.toGenerator($e.query(e.controllers.tables.signal)({type:e.type,key:e.key,query:e.tables.sql},{}));e.tables.data=v.groupBy(i,"table_schema"),e.tables.state="idle",e.tables.error=null,e.initKeywords()}catch(i){if(!Xe.isCancel(i)){e.tables.data={};const s=v.get(i,"message","unkown error");e.tables.error=v.get(i,"response.data.detail.message",s),e.tables.state="error"}}});return{loadTables:t,loadTablesIfEmpty(){e.tables.empty&&t()},loadColumns:b.flow(function*(){var r;(r=e.controllers.columns)==null||r.abort(),e.controllers.columns=new AbortController,e.columns.state="loading";try{e.columns.data=yield*b.toGenerator($e.query(e.controllers.columns.signal)({type:e.type,key:e.key,query:e.columns.sql},{})),e.columns.state="idle",e.columns.error=null}catch(i){if(Xe.isCancel(i))e.columns.state="idle",e.columns.error=null;else{e.columns.data=[];const s=v.get(i,"message","unkown error");e.columns.error=v.get(i,"response.data.detail.message",s),e.columns.state="error"}}}),loadIndexes:b.flow(function*(){var r;(r=e.controllers.indexes)==null||r.abort(),e.controllers.indexes=new AbortController,e.indexes.state="loading";try{e.indexes.data=yield*b.toGenerator($e.query(e.controllers.indexes.signal)({type:e.type,key:e.key,query:e.indexes.sql},{})),e.indexes.state="idle",e.indexes.error=null}catch(i){if(Xe.isCancel(i))e.indexes.state="idle",e.indexes.error=null;else{e.indexes.data=[];const s=v.get(i,"message","unkown error");e.indexes.error=v.get(i,"response.data.detail.message",s),e.indexes.state="error"}}}),loadTableData:b.flow(function*(){var i;(i=e.controllers.tableData)==null||i.abort(),e.controllers.tableData=new AbortController;const r=e.tableData;r.state="loading";try{r.data=yield*b.toGenerator($e.query(e.controllers.tableData.signal)({type:e.type,key:e.key,query:r.sql},{}));const[{total:s}]=yield*b.toGenerator($e.query(e.controllers.tableData.signal)({type:e.type,key:e.key,query:r.countSql},{}));r.total=Number(s),r.state="idle",r.error=null}catch(s){if(Xe.isCancel(s))r.state="idle",r.error=null;else{r.data=[];const o=v.get(s,"message","unkown error");r.error=v.get(s,"response.data.detail.message",o),r.state="error"}}})}}).actions(e=>({afterCreate(){b.addDisposer(e,ie.reaction(()=>e.columns.sql,e.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(e=>({afterCreate(){b.addDisposer(e,ie.reaction(()=>e.indexes.sql,e.loadIndexes,{fireImmediately:!1,delay:500})),b.addDisposer(e,ie.reaction(()=>e.tableData.sql,e.loadTableData,{fireImmediately:!1,delay:0}))}})),sl=b.types.model("DataSourcesModel",{list:b.types.optional(b.types.array(al),[])}).views(e=>({find({type:t,key:r}){return e.list.find(i=>i.key===r&&i.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}}));function qt(e){return{label:e,value:e,_type:"ACTION",_action_type:e,Icon:null,children:null}}function ol(e){switch(e._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",e.value];case"sql_snippet":return["_SQL_SNIPPETS_",e.value];case"query":return["_QUERIES_",e.value];case"view":return["_VIEWS_",e.value];case"panel":return e.parentID?["_VIEWS_",e.parentID,"_PANELS_",e.value]:(console.error("[getPathFromOption] parentID is required"),null)}}const ll=b.types.model("EditorModel",{path:b.types.optional(b.types.frozen(),[]),settings_open:b.types.optional(b.types.boolean,!1)}).views(e=>({get navOptions(){const{content:t}=b.getRoot(e),{filters:r,views:i,sqlSnippets:s,queries:o}=t;return[{label:"Query Variables",value:"_QUERY_VARS_",_type:"query_variables",Icon:P.IconVariable},{label:"Mock Context",value:"_MOCK_CONTEXT_",Icon:P.IconCodeDots,_type:"mock_context"},{label:"Filters",value:"_FILTERS_",Icon:P.IconFilter,children:[...r.options,qt("_Add_A_Filter_")],_type:"GROUP"},{label:"SQL Snippets",value:"_SQL_SNIPPETS_",Icon:P.IconCopy,children:[...s.options,qt("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"Queries",value:"_QUERIES_",Icon:P.IconDatabase,children:[...o.options,qt("_Add_A_QUERY_")],_type:"GROUP"},{label:"Views",value:"_VIEWS_",Icon:P.IconBoxMultiple,children:[...i.editorOptions,qt("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(t,r){return t.length===0?!1:t[t.length-1]===r.value},isOptionOpened(t){const{path:r}=e;return r.length===0||!t.children||t.children.length===0?!1:r.includes(t.value)}})).actions(e=>({setPath(t){e.path=t},setSettingsOpen(t){e.settings_open=t}})).actions(e=>({open(t){e.setPath(t),e.setSettingsOpen(!0)},close(){e.setSettingsOpen(!1)},navigate(t){const r=ol(t);r&&e.setPath(r)}})),ul=b.types.model("MockContextModel",{current:b.types.optional(b.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,r){e.current[t]=r}})),dl=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(e=>({get json(){const{name:t,size:r,weight:i,color:s,formatter:o,data_field:u,aggregation:l}=e;return v.cloneDeep({name:t,size:r,color:s,weight:i,formatter:o,data_field:u,aggregation:l})}}));class cl{constructor(t){O(this,"origin");O(this,"copy");this.origin=t,this.copy=b.clone(t),ie.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!v.isEqual(b.getSnapshot(this.origin),b.getSnapshot(this.copy))}commit(){b.applySnapshot(this.origin,b.getSnapshot(this.copy))}update(t){b.applySnapshot(this.copy,t)}}const pl=e=>new cl(e);class hl{constructor(){O(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,i){var u;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const s=this.migrations.filter(l=>l.version>t.from&&l.version<=t.to),o=v.orderBy(s,"version","asc");if(((u=v.last(o))==null?void 0:u.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((l,d)=>d.handler(l,i),r)}}class fe extends hl{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(i,s)=>({version:t,...r(i,s)}))}async migrate({configData:t,panelModel:r}){const i=await t.getItem(null),s=v.get(i,"version",0),o=this.run({from:s,to:this.VERSION},i,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return v.get(r,"version",0)<this.VERSION}}var Oe=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e.custom="custom",e))(Oe||{});const na=["function text({ value }) {"," // your code goes here"," return value","}"].join(`
119
- `),_n={columns:[],fontSize:"1rem",highlightOnHover:!1,horizontalSpacing:"1em",id_field:"",striped:!1,use_raw_columns:!0,verticalSpacing:"1em"};class ut{constructor(t,r){this.root=t,this.path=r}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,v.omit(r,t))}async getItem(t){const r=await this.root.getItem(this.path);return t===null?r:v.get(r,t)}async setItem(t,r){if(t===null)await this.root.setItem(this.path,r);else{const i=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...i,[t]:r})}return await this.getItem(t)}watchItem(t,r,i){return t===null?this.root.watchItem(this.path,(s,o)=>{r(s,o)},i):this.root.watchItem(this.path,(s,o)=>{const u=v.get(s,t),l=v.get(o,t);u!==l&&r(u,l)},i)}}class Sn{constructor(t,r,i){O(this,"attachmentStorage");this.instance=t,this.attachmentKey=r,this.constructInstance=i,this.attachmentStorage=new ut(t.instanceData,r)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new ut(this.attachmentStorage,t))}async create(t,r){return await this.attachmentStorage.setItem(t,r),this.constructInstance(new ut(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(v.values(t).map(r=>this.constructInstance(new ut(this.attachmentStorage,r.id))))}}class ra{constructor(t){O(this,"rootRef");this.rootRef=ie.observable({current:t})}async deleteItem(t){ie.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?ie.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(v.isObject(r))ie.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else ie.runInAction(()=>{v.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,i){return ie.reaction(()=>this.getValueFromRoot(t),(s,o)=>{r(s,o)},{requiresObservable:!0,fireImmediately:v.get(i,"fireImmediately",!1)})}}class fl{constructor(){O(this,"channels",new Map);O(this,"globalChannel",new hi)}getChannel(t){const r=this.channels.get(t);if(r)return r;const i=new hi;return this.channels.set(t,i),i}}class gl{constructor(t){O(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const r=this.instances.get(t.id);if(r)return r;const i={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new fl,instanceData:new ra(t.viz.conf)};return this.instances.set(t.id,i),i}}function ia(e,t,r,i){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new ra({}),colorPalette:{getColor(){return()=>""}},data:t,variables:i}}const ml=e=>{const{panel:t,vizManager:r,data:i,variables:s}=e,o=r.resolveComponent(t.viz.type),u=r.getOrCreateInstance(t),l={...ia(u,i,r,s),viewport:{width:t.layout.w,height:t.layout.h}},d=o.viewRender;return n(d,{context:l,instance:u,...v.omit(e,["panel","vizManager","data"])})},bl=e=>{const{vizManager:t,panel:r,panelInfoEditor:i,data:s,variables:o}=e,u=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),d={...ia(l,s,t,o),panelInfoEditor:i},p=u.configRender;return n(p,{context:d,instance:l,...v.omit(e,["panel","vizManager","data","panelInfoEditor"])})},aa=(e,t)=>{const r=je.bezier(e),i=je.bezier(t);return function(s){return s<50?r(s*2/100).hex():i((s-50)*2/100).hex()}},Ft=e=>{const t=je.bezier(e);return function(r){return t(r/100).hex()}},yl={type:"interpolation",displayName:"Red / Green",getColor:aa(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},vl={type:"interpolation",displayName:"Yellow / Blue",getColor:aa(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},xl={type:"interpolation",displayName:"Red",getColor:Ft(["#fff7f1","darkred"]),name:"red",category:"sequential"},Cl={type:"interpolation",displayName:"Green",getColor:Ft(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},wl={type:"interpolation",displayName:"Blue",getColor:Ft(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},_l={type:"interpolation",displayName:"Orange",getColor:Ft(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Sl{constructor(t){O(this,"symbol");this.symbol=Symbol(t)}}function Ye(e){return new Sl(e)}class Tn{constructor(){O(this,"parent");O(this,"factoryRegistry",new Map);O(this,"instanceRegistry",new Map)}createScoped(){const t=new Tn;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const r=this.factoryRegistry.get(t.symbol);if(r){const i=r(this);return this.instanceRegistry.set(t.symbol,i),i}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=v.get(t,"dispose");v.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const sa="@devtable/dashboard",kn="9.16.0",oa="Apache-2.0",la={access:"public",registry:"https://registry.npmjs.org/"},ua=["dist"],da="./dist/dashboard.umd.js",ca="./dist/dashboard.es.js",pa="./dist/index.d.ts",ha={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},fa={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},ga={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5",mathjs:"11.8.0","monaco-editor":"0.36.0","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-select":"14.1.0","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},ma={"@emotion/babel-plugin":"11.11.0","@faker-js/faker":"7.6.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"1.119.0","@testing-library/cypress":"^9.0.0","@testing-library/jest-dom":"^5.16.4","@testing-library/react":"^13.3.0","@testing-library/react-hooks":"^8.0.1","@testing-library/user-event":"^14.3.0","@tiptap/extension-code-block-lowlight":"2.0.3","@tiptap/extension-color":"2.0.3","@tiptap/extension-highlight":"2.0.3","@tiptap/extension-link":"2.0.3","@tiptap/extension-placeholder":"2.0.3","@tiptap/extension-subscript":"2.0.3","@tiptap/extension-superscript":"2.0.3","@tiptap/extension-table":"2.0.3","@tiptap/extension-table-cell":"2.0.3","@tiptap/extension-table-header":"2.0.3","@tiptap/extension-table-row":"2.0.3","@tiptap/extension-text-align":"2.0.3","@tiptap/extension-text-style":"2.0.3","@tiptap/extension-underline":"2.0.3","@tiptap/pm":"2.0.3","@tiptap/react":"2.0.3","@tiptap/starter-kit":"2.0.3","@types/crypto-js":"v4.1.1","@types/d3-array":"3.0.4","@types/eventemitter2":"^4.1.0","@types/file-saver":"2.0.5","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2",ahooks:"^3.3.11",ajv:"8.12.0",axios:"^0.27.2","crypto-js":"^4.1.1",cypress:"^12.9.0","cypress-wait-until":"^1.7.2",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",jsdom:"^20.0.0","jsdom-testing-mocks":"^1.5.0",lodash:"^4.17.21",lowlight:"^2.8.0",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","rollup-plugin-visualizer":"5.9.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3","vite-plugin-static-copy":"0.13.1"},ba={"@emotion/react":"11.10.6","@faker-js/faker":"7.6.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"1.119.0","@tanstack/react-table":"^8.5.13","@tiptap/extension-code-block-lowlight":"2.0.3","@tiptap/extension-color":"2.0.3","@tiptap/extension-highlight":"2.0.3","@tiptap/extension-link":"2.0.3","@tiptap/extension-placeholder":"2.0.3","@tiptap/extension-subscript":"2.0.3","@tiptap/extension-superscript":"2.0.3","@tiptap/extension-table":"2.0.3","@tiptap/extension-table-cell":"2.0.3","@tiptap/extension-table-header":"2.0.3","@tiptap/extension-table-row":"2.0.3","@tiptap/extension-text-align":"2.0.3","@tiptap/extension-text-style":"2.0.3","@tiptap/extension-underline":"2.0.3","@tiptap/pm":"2.0.3","@tiptap/react":"2.0.3","@tiptap/starter-kit":"2.0.3",ahooks:"^3.3.11",axios:"^0.27.2","chroma-js":"^2.4.2","crypto-js":"^4.1.1","d3-array":"3.2.3","d3-regression":"1.3.10",dayjs:"1.11.7",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",eventemitter2:"^6.4.6",jszip:"3.10.1",lodash:"^4.17.21",lowlight:"^2.8.0",mobx:"^6.6.1","mobx-react-lite":"^3.4.0","mobx-state-tree":"^5.1.5",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","react-router-dom":"^6.3.0","react-virtual":"^2.10.4","tabler-icons-react":"^1.48.0"},Tl=Object.freeze(Object.defineProperty({__proto__:null,default:{name:sa,version:kn,license:oa,publishConfig:la,files:ua,main:da,module:ca,types:pa,exports:ha,scripts:fa,dependencies:ga,devDependencies:ma,peerDependencies:ba},dependencies:ga,devDependencies:ma,exports:ha,files:ua,license:oa,main:da,module:ca,name:sa,peerDependencies:ba,publishConfig:la,scripts:fa,types:pa,version:kn},Symbol.toStringTag,{value:"Module"}));class kl{constructor(t){O(this,"staticColors",new Map);O(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(i=>{this.register(i)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(r,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class Dl{constructor(){O(this,"plugins",new Map);O(this,"vizComponents",new Map);O(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}const W=(e,t)=>{const[r,{setFalse:i}]=X.useBoolean(!0),[s,o]=m.useState();m.useEffect(()=>(e.getItem(t).then(l=>{o(l),i()}),e.watchItem(t,l=>{o(l)})));const u=m.useCallback(async l=>{await e.setItem(t,l),o(l)},[e,t]);return{loading:r,value:s,set:u}},Dn={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"}};le.use([N.GridComponent,N.VisualMapComponent,N.LegendComponent,N.TooltipComponent,Me.CanvasRenderer]);function Il({context:e}){const{value:t}=W(e.instanceData,"config"),r=e.data,{width:i,height:s}=e.viewport,{x_axis_data_key:o,y_axis_data_key:u,z_axis_data_key:l,xAxis3D:d,yAxis3D:p,zAxis3D:f}=v.defaults({},t,Dn),g=m.useMemo(()=>{const C=v.minBy(r,w=>w[l]);return v.get(C,l)},[r,l]),h=m.useMemo(()=>{const C=v.maxBy(r,w=>w[l]);return v.get(C,l)},[r,l]),y={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:g,max:h,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:d,yAxis3D:p,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:r.map(C=>[C[o],C[u],C[l]])}]};return t?n(Ae,{echarts:le,option:y,style:{width:i,height:s},notMerge:!0,theme:"merico-light"}):null}function Ml({label:e,required:t,value:r,onChange:i,data:s,clearable:o=!1,sx:u,...l},d){const p=m.useMemo(()=>{if(!Array.isArray(s)||s.length===0)return[];const g=Object.keys(s[0]).map(h=>({label:h,value:h}));return o?g.concat([{label:"unset",value:""}]):g},[s]);return n(a.Select,{ref:d,label:e,data:p,value:r,onChange:i,required:t,sx:u,...l})}const F=m.forwardRef(Ml);function Al({context:e}){const{value:t,set:r}=W(e.instanceData,"config"),i=e.data,s=v.defaults({},t,Dn),{control:o,handleSubmit:u,reset:l}=x.useForm({defaultValues:s});return m.useEffect(()=>{l(s)},[t]),t?n(a.Stack,{spacing:"xs",children:c("form",{onSubmit:u(r),children:[n(a.Text,{children:"X Axis"}),c(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"x_axis_data_key",control:o,render:({field:d})=>n(F,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"xAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Y Axis"}),c(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"y_axis_data_key",control:o,render:({field:d})=>n(F,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"yAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Z Axis"}),c(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"z_axis_data_key",control:o,render:({field:d})=>n(F,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"zAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:c(a.Button,{color:"blue",type:"submit",children:[n(k.DeviceFloppy,{size:20}),n(a.Text,{ml:"md",children:"Save"})]})})]})}):null}class $l extends fe{constructor(){super(...arguments);O(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const zl={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new $l,name:"bar-3d",viewRender:Il,configRender:Al,createConfig(){return{version:1,config:v.cloneDeep(Dn)}}};class ke extends m.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const r=()=>{this.setState({error:null})};return c(a.Box,{children:[n(a.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),n(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:r,children:"Retry"})]})}return this.props.children}}const Se={mantissa:0,output:"number",trimMantissa:!1,average:!1};function El({value:e,onChange:t},r){const i=l=>{t({...e,output:l})},s=l=>{const d=l===0?!1:e.trimMantissa;t({...e,mantissa:l,trimMantissa:d})},o=l=>{t({...e,trimMantissa:l.currentTarget.checked})},u=l=>{t({...e,average:l.currentTarget.checked})};return c(a.Stack,{ref:r,children:[c(a.Group,{grow:!0,children:[n(a.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:i,sx:{flexGrow:1}}),n(a.Switch,{label:c(a.Stack,{spacing:0,children:[n(a.Text,{children:"Average"}),n(a.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:u,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),c(a.Group,{grow:!0,children:[n(a.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:s}),n(a.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),c(a.Stack,{spacing:0,children:[n(a.Text,{weight:"bold",children:"Preview"}),n(ke,{children:c(a.Group,{position:"apart",children:[c(a.Text,{size:12,color:"gray",children:["123456789 ",n(k.ArrowRight,{size:9})," ",H(123456789).format(e)]}),c(a.Text,{size:12,color:"gray",children:["1234 ",n(k.ArrowRight,{size:9})," ",H(1234).format(e)]}),c(a.Text,{size:12,color:"gray",children:["0.1234 ",n(k.ArrowRight,{size:9})," ",H(.1234).format(e)]})]})})]})]})}const Ve=m.forwardRef(El),Ne={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
119
+ `),_n={columns:[],fontSize:"1rem",highlightOnHover:!1,horizontalSpacing:"1em",id_field:"",striped:!1,use_raw_columns:!0,verticalSpacing:"1em"};class ut{constructor(t,r){this.root=t,this.path=r}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,v.omit(r,t))}async getItem(t){const r=await this.root.getItem(this.path);return t===null?r:v.get(r,t)}async setItem(t,r){if(t===null)await this.root.setItem(this.path,r);else{const i=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...i,[t]:r})}return await this.getItem(t)}watchItem(t,r,i){return t===null?this.root.watchItem(this.path,(s,o)=>{r(s,o)},i):this.root.watchItem(this.path,(s,o)=>{const u=v.get(s,t),l=v.get(o,t);u!==l&&r(u,l)},i)}}class Sn{constructor(t,r,i){O(this,"attachmentStorage");this.instance=t,this.attachmentKey=r,this.constructInstance=i,this.attachmentStorage=new ut(t.instanceData,r)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new ut(this.attachmentStorage,t))}async create(t,r){return await this.attachmentStorage.setItem(t,r),this.constructInstance(new ut(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(v.values(t).map(r=>this.constructInstance(new ut(this.attachmentStorage,r.id))))}}class ra{constructor(t){O(this,"rootRef");this.rootRef=ie.observable({current:t})}async deleteItem(t){ie.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?ie.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(v.isObject(r))ie.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else ie.runInAction(()=>{v.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,i){return ie.reaction(()=>this.getValueFromRoot(t),(s,o)=>{r(s,o)},{requiresObservable:!0,fireImmediately:v.get(i,"fireImmediately",!1)})}}class fl{constructor(){O(this,"channels",new Map);O(this,"globalChannel",new hi)}getChannel(t){const r=this.channels.get(t);if(r)return r;const i=new hi;return this.channels.set(t,i),i}}class gl{constructor(t){O(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const r=this.instances.get(t.id);if(r)return r;const i={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new fl,instanceData:new ra(t.viz.conf)};return this.instances.set(t.id,i),i}}function ia(e,t,r,i){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new ra({}),colorPalette:{getColor(){return()=>""}},data:t,variables:i}}const ml=e=>{const{panel:t,vizManager:r,data:i,variables:s}=e,o=r.resolveComponent(t.viz.type),u=r.getOrCreateInstance(t),l={...ia(u,i,r,s),viewport:{width:t.layout.w,height:t.layout.h}},d=o.viewRender;return n(d,{context:l,instance:u,...v.omit(e,["panel","vizManager","data"])})},bl=e=>{const{vizManager:t,panel:r,panelInfoEditor:i,data:s,variables:o}=e,u=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),d={...ia(l,s,t,o),panelInfoEditor:i},p=u.configRender;return n(p,{context:d,instance:l,...v.omit(e,["panel","vizManager","data","panelInfoEditor"])})},aa=(e,t)=>{const r=je.bezier(e),i=je.bezier(t);return function(s){return s<50?r(s*2/100).hex():i((s-50)*2/100).hex()}},Ft=e=>{const t=je.bezier(e);return function(r){return t(r/100).hex()}},yl={type:"interpolation",displayName:"Red / Green",getColor:aa(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},vl={type:"interpolation",displayName:"Yellow / Blue",getColor:aa(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},xl={type:"interpolation",displayName:"Red",getColor:Ft(["#fff7f1","darkred"]),name:"red",category:"sequential"},Cl={type:"interpolation",displayName:"Green",getColor:Ft(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},wl={type:"interpolation",displayName:"Blue",getColor:Ft(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},_l={type:"interpolation",displayName:"Orange",getColor:Ft(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Sl{constructor(t){O(this,"symbol");this.symbol=Symbol(t)}}function Ye(e){return new Sl(e)}class Tn{constructor(){O(this,"parent");O(this,"factoryRegistry",new Map);O(this,"instanceRegistry",new Map)}createScoped(){const t=new Tn;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const r=this.factoryRegistry.get(t.symbol);if(r){const i=r(this);return this.instanceRegistry.set(t.symbol,i),i}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=v.get(t,"dispose");v.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const sa="@devtable/dashboard",kn="9.16.1",oa="Apache-2.0",la={access:"public",registry:"https://registry.npmjs.org/"},ua=["dist"],da="./dist/dashboard.umd.js",ca="./dist/dashboard.es.js",pa="./dist/index.d.ts",ha={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},fa={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},ga={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5",mathjs:"11.8.0","monaco-editor":"0.36.0","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-select":"14.1.0","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},ma={"@emotion/babel-plugin":"11.11.0","@faker-js/faker":"7.6.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"1.119.0","@testing-library/cypress":"^9.0.0","@testing-library/jest-dom":"^5.16.4","@testing-library/react":"^13.3.0","@testing-library/react-hooks":"^8.0.1","@testing-library/user-event":"^14.3.0","@tiptap/extension-code-block-lowlight":"2.0.3","@tiptap/extension-color":"2.0.3","@tiptap/extension-highlight":"2.0.3","@tiptap/extension-link":"2.0.3","@tiptap/extension-placeholder":"2.0.3","@tiptap/extension-subscript":"2.0.3","@tiptap/extension-superscript":"2.0.3","@tiptap/extension-table":"2.0.3","@tiptap/extension-table-cell":"2.0.3","@tiptap/extension-table-header":"2.0.3","@tiptap/extension-table-row":"2.0.3","@tiptap/extension-text-align":"2.0.3","@tiptap/extension-text-style":"2.0.3","@tiptap/extension-underline":"2.0.3","@tiptap/pm":"2.0.3","@tiptap/react":"2.0.3","@tiptap/starter-kit":"2.0.3","@types/crypto-js":"v4.1.1","@types/d3-array":"3.0.4","@types/eventemitter2":"^4.1.0","@types/file-saver":"2.0.5","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2",ahooks:"^3.3.11",ajv:"8.12.0",axios:"^0.27.2","crypto-js":"^4.1.1",cypress:"^12.9.0","cypress-wait-until":"^1.7.2",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",jsdom:"^20.0.0","jsdom-testing-mocks":"^1.5.0",lodash:"^4.17.21",lowlight:"^2.8.0",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","rollup-plugin-visualizer":"5.9.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3","vite-plugin-static-copy":"0.13.1"},ba={"@emotion/react":"11.10.6","@faker-js/faker":"7.6.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"1.119.0","@tanstack/react-table":"^8.5.13","@tiptap/extension-code-block-lowlight":"2.0.3","@tiptap/extension-color":"2.0.3","@tiptap/extension-highlight":"2.0.3","@tiptap/extension-link":"2.0.3","@tiptap/extension-placeholder":"2.0.3","@tiptap/extension-subscript":"2.0.3","@tiptap/extension-superscript":"2.0.3","@tiptap/extension-table":"2.0.3","@tiptap/extension-table-cell":"2.0.3","@tiptap/extension-table-header":"2.0.3","@tiptap/extension-table-row":"2.0.3","@tiptap/extension-text-align":"2.0.3","@tiptap/extension-text-style":"2.0.3","@tiptap/extension-underline":"2.0.3","@tiptap/pm":"2.0.3","@tiptap/react":"2.0.3","@tiptap/starter-kit":"2.0.3",ahooks:"^3.3.11",axios:"^0.27.2","chroma-js":"^2.4.2","crypto-js":"^4.1.1","d3-array":"3.2.3","d3-regression":"1.3.10",dayjs:"1.11.7",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",eventemitter2:"^6.4.6",jszip:"3.10.1",lodash:"^4.17.21",lowlight:"^2.8.0",mobx:"^6.6.1","mobx-react-lite":"^3.4.0","mobx-state-tree":"^5.1.5",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","react-router-dom":"^6.3.0","react-virtual":"^2.10.4","tabler-icons-react":"^1.48.0"},Tl=Object.freeze(Object.defineProperty({__proto__:null,default:{name:sa,version:kn,license:oa,publishConfig:la,files:ua,main:da,module:ca,types:pa,exports:ha,scripts:fa,dependencies:ga,devDependencies:ma,peerDependencies:ba},dependencies:ga,devDependencies:ma,exports:ha,files:ua,license:oa,main:da,module:ca,name:sa,peerDependencies:ba,publishConfig:la,scripts:fa,types:pa,version:kn},Symbol.toStringTag,{value:"Module"}));class kl{constructor(t){O(this,"staticColors",new Map);O(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(i=>{this.register(i)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(r,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class Dl{constructor(){O(this,"plugins",new Map);O(this,"vizComponents",new Map);O(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}const W=(e,t)=>{const[r,{setFalse:i}]=X.useBoolean(!0),[s,o]=m.useState();m.useEffect(()=>(e.getItem(t).then(l=>{o(l),i()}),e.watchItem(t,l=>{o(l)})));const u=m.useCallback(async l=>{await e.setItem(t,l),o(l)},[e,t]);return{loading:r,value:s,set:u}},Dn={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"}};le.use([N.GridComponent,N.VisualMapComponent,N.LegendComponent,N.TooltipComponent,Me.CanvasRenderer]);function Il({context:e}){const{value:t}=W(e.instanceData,"config"),r=e.data,{width:i,height:s}=e.viewport,{x_axis_data_key:o,y_axis_data_key:u,z_axis_data_key:l,xAxis3D:d,yAxis3D:p,zAxis3D:f}=v.defaults({},t,Dn),g=m.useMemo(()=>{const C=v.minBy(r,w=>w[l]);return v.get(C,l)},[r,l]),h=m.useMemo(()=>{const C=v.maxBy(r,w=>w[l]);return v.get(C,l)},[r,l]),y={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:g,max:h,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:d,yAxis3D:p,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:r.map(C=>[C[o],C[u],C[l]])}]};return t?n(Ae,{echarts:le,option:y,style:{width:i,height:s},notMerge:!0,theme:"merico-light"}):null}function Ml({label:e,required:t,value:r,onChange:i,data:s,clearable:o=!1,sx:u,...l},d){const p=m.useMemo(()=>{if(!Array.isArray(s)||s.length===0)return[];const g=Object.keys(s[0]).map(h=>({label:h,value:h}));return o?g.concat([{label:"unset",value:""}]):g},[s]);return n(a.Select,{ref:d,label:e,data:p,value:r,onChange:i,required:t,sx:u,...l})}const F=m.forwardRef(Ml);function Al({context:e}){const{value:t,set:r}=W(e.instanceData,"config"),i=e.data,s=v.defaults({},t,Dn),{control:o,handleSubmit:u,reset:l}=x.useForm({defaultValues:s});return m.useEffect(()=>{l(s)},[t]),t?n(a.Stack,{spacing:"xs",children:c("form",{onSubmit:u(r),children:[n(a.Text,{children:"X Axis"}),c(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"x_axis_data_key",control:o,render:({field:d})=>n(F,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"xAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Y Axis"}),c(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"y_axis_data_key",control:o,render:({field:d})=>n(F,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"yAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Z Axis"}),c(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"z_axis_data_key",control:o,render:({field:d})=>n(F,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"zAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:c(a.Button,{color:"blue",type:"submit",children:[n(k.DeviceFloppy,{size:20}),n(a.Text,{ml:"md",children:"Save"})]})})]})}):null}class $l extends fe{constructor(){super(...arguments);O(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const zl={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new $l,name:"bar-3d",viewRender:Il,configRender:Al,createConfig(){return{version:1,config:v.cloneDeep(Dn)}}};class ke extends m.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const r=()=>{this.setState({error:null})};return c(a.Box,{children:[n(a.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),n(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:r,children:"Retry"})]})}return this.props.children}}const Se={mantissa:0,output:"number",trimMantissa:!1,average:!1};function El({value:e,onChange:t},r){const i=l=>{t({...e,output:l})},s=l=>{const d=l===0?!1:e.trimMantissa;t({...e,mantissa:l,trimMantissa:d})},o=l=>{t({...e,trimMantissa:l.currentTarget.checked})},u=l=>{t({...e,average:l.currentTarget.checked})};return c(a.Stack,{ref:r,children:[c(a.Group,{grow:!0,children:[n(a.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:i,sx:{flexGrow:1}}),n(a.Switch,{label:c(a.Stack,{spacing:0,children:[n(a.Text,{children:"Average"}),n(a.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:u,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),c(a.Group,{grow:!0,children:[n(a.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:s}),n(a.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),c(a.Stack,{spacing:0,children:[n(a.Text,{weight:"bold",children:"Preview"}),n(ke,{children:c(a.Group,{position:"apart",children:[c(a.Text,{size:12,color:"gray",children:["123456789 ",n(k.ArrowRight,{size:9})," ",H(123456789).format(e)]}),c(a.Text,{size:12,color:"gray",children:["1234 ",n(k.ArrowRight,{size:9})," ",H(1234).format(e)]}),c(a.Text,{size:12,color:"gray",children:["0.1234 ",n(k.ArrowRight,{size:9})," ",H(.1234).format(e)]})]})})]})]})}const Ve=m.forwardRef(El),Ne={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
120
120
  `)},ya={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:Pl,configRender:Ll,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 Ll(e){return n(V,{})}function Pl(e){return n(a.Text,{children:"Click chart's series"})}const Ol=[{label:"Truncate",value:"truncate"},{label:"Break Line",value:"break"},{label:"Break Word",value:"breakAll"}],Wt=m.forwardRef(({sectionTitle:e,value:t,onChange:r},i)=>{const s=o=>u=>{const l=v.cloneDeep(t);v.set(l,o,u),r(l)};return c(a.Stack,{spacing:0,children:[e&&n(a.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),c(a.Group,{grow:!0,noWrap:!0,children:[n(a.NumberInput,{label:"Max Width",hideControls:!0,value:t.width,onChange:s("width")}),n(a.Select,{label:"Overflow",data:Ol,value:t.overflow,onChange:s("overflow")}),n(a.TextInput,{label:"Ellipsis",value:t.ellipsis,disabled:!0})]})]})}),Je=m.forwardRef(({value:e,onChange:t},r)=>{const i=o=>{t({...e,on_axis:o})},s=o=>{t({...e,in_tooltip:o})};return c(a.Stack,{ref:r,spacing:0,children:[n(Wt,{sectionTitle:"Overflow on Axis",value:e.on_axis,onChange:i}),n(Wt,{sectionTitle:"Overflow in Tooltip",value:e.in_tooltip,onChange:s})]})}),Be={on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}};function He({overflow:e,width:t}){const r={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],i=e==="truncate"?"nowrap":"initial",s={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
121
121
  max-width: ${t}px;
122
122
  word-break: ${r};
@@ -482,7 +482,7 @@ Check the top-level render call using <`+E+">.")}return M}}function oo(_,M){{if(
482
482
  parent_value: string;
483
483
  description?: string;
484
484
  }
485
- `,h0=()=>{const[e,t]=m.useState(!1);return c(V,{children:[n(a.Button,{variant:"subtle",compact:!0,onClick:()=>t(r=>!r),children:e?"Close":"Click to see expected data structure"}),n(a.Collapse,{in:e,children:n(it.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:p0})})]})},f0=T.observer(function({config:t}){return c(V,{children:[n(a.TextInput,{label:"Min-width",value:t.min_width,onChange:r=>t.setMinWidth(r.currentTarget.value),placeholder:"200px"}),n(a.Divider,{label:"Fetch options from database",labelPosition:"center"}),n(a.NumberInput,{value:t.default_selection_count,onChange:t.setDefaultSelectionCount,label:"Select first N options by default"}),n(Cr,{value:t.options_query_id,onChange:t.setOptionsQueryID}),n(h0,{})]})}),g0=T.observer(function({filter:t}){const[r,i]=m.useState(t.plainDefaultValue);return m.useEffect(()=>{i(t.plainDefaultValue)},[t]),c(a.Box,{sx:{maxWidth:"480px"},children:[n(a.Text,{pb:"md",color:"gray",children:"Preview"}),n(Ts,{filter:t,value:r,onChange:i}),n(a.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),n(it.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),m0={select:d0,"multi-select":u0,"tree-select":f0,"text-input":c0,checkbox:a0,"date-range":o0},b0=[{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"}],y0=T.observer(function({filter:t}){const r=Y(),i=m.useMemo(()=>m0[t.type],[t.type]);return c(a.Group,{grow:!0,spacing:20,align:"top",children:[c(a.Box,{sx:{maxWidth:"600px"},children:[n(a.Text,{pb:"md",color:"gray",children:"Edit"}),c(a.Stack,{children:[c(a.Group,{noWrap:!0,children:[n(a.NumberInput,{label:"Placement Order",required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&n(a.Checkbox,{label:"Submit automatically",checked:t.auto_submit,onChange:s=>t.setAutoSubmit(s.currentTarget.checked),mt:22})]}),n(a.MultiSelect,{label:"Visible in...",data:r.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),n(a.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:t.key,onChange:s=>{t.setKey(s.currentTarget.value)}}),n(a.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:t.label,onChange:s=>{t.setLabel(s.currentTarget.value)}}),n(a.Select,{label:"Widget",data:b0,required:!0,value:t.type,onChange:t.setType}),n(i,{config:t.config})]})]}),n(g0,{filter:t})]})}),v0=T.observer(({id:e})=>{const t=Le.useModals(),r=ce(),i=Y();if(e==="")return null;const s=i.filters.findByID(e);if(!s)return c(a.Text,{size:14,children:["Filter by ID[",e,"] is not found"]});const o=()=>{r.editor.setPath(["_FILTERS_",""])},u=()=>{t.openConfirmModal({title:"Delete this filter?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.filters.removeByID(e),o()},confirmProps:{color:"red"},zIndex:320})};return c(a.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[n(a.Group,{position:"right",pt:10,children:n(a.Button,{size:"xs",color:"red",leftIcon:n(k.Trash,{size:16}),onClick:u,children:"Delete this filter"})}),n(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n(y0,{filter:s})})]})}),x0=T.observer(()=>{const e=Y(),[t,r]=m.useState(()=>JSON.stringify(e.mock_context.current,null,4)),i=()=>{try{e.mock_context.replace(JSON.parse(t))}catch(o){Ot.showNotification({title:"Failed",message:o.message,color:"red"})}},s=m.useMemo(()=>{try{return JSON.stringify(JSON.parse(t))!==JSON.stringify(e.mock_context.current)}catch{return!1}},[t,e.mock_context.current]);return c(a.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[n(a.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:n(a.Text,{weight:500,children:"Mock Context"})}),c(a.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[c(a.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[n(a.Text,{children:"A valid json string is required"}),n(a.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:t,onChange:r,sx:{flexGrow:1}})]}),n(a.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!s,onClick:i,children:n(k.DeviceFloppy,{size:20})})]})]})}),C0=T.observer(()=>{const{panel:e}=we();return n(Un,{label:"Description",value:e.description,onChange:e.setDescription,styles:{root:{flexGrow:1}}})}),w0=T.observer(()=>{const{panel:e}=we(),{style:t}=e;return n(V,{children:n(a.Switch,{label:"Border",checked:t.border.enabled,onChange:r=>t.border.setEnabled(r.currentTarget.checked)})})}),_0=T.observer(()=>{const{panel:e}=we(),{title:t,setTitle:r}=e,[i,s]=ve.useInputState(t),o=t!==i,u=m.useCallback(()=>{o&&r(i)},[o,i]);return m.useEffect(()=>{s(t)},[t]),n(a.TextInput,{value:i,onChange:s,label:c(a.Group,{children:[n(a.Text,{children:"Panel Title"}),n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:u,children:n(k.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function S0(){return c(a.Stack,{sx:{height:"100%"},children:[n(a.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),n(w0,{}),n(a.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),n(_0,{}),n(C0,{})]})}const T0=({queryID:e})=>{const t=Y(),{state:r,error:i}=t.getDataStuffByID(e),s=m.useMemo(()=>t.queries.findByID(e),[t,e]);return r==="loading"?null:i?n(a.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:i}):s!=null&&s.stateMessage?n(a.Text,{color:"gray",align:"center",children:s.stateMessage}):null},k0={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 qs({data:e}){const t=m.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const i=Pe.createColumnHelper();return Object.keys(e[0]).map(s=>i.accessor(s,{cell:o=>o.getValue()}))},[e]),r=Pe.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Pe.getCoreRowModel()});return e.length===0?n(a.Box,{sx:{height:"5em"}}):n(ke,{children:c(a.Table,{sx:k0,children:[n("thead",{children:r.getHeaderGroups().map(i=>n("tr",{children:i.headers.map(s=>c("th",{style:{width:s.getSize()},children:[s.isPlaceholder?null:Pe.flexRender(s.column.columnDef.header,s.getContext()),n(a.ActionIcon,{onMouseDown:s.getResizeHandler(),onTouchStart:s.getResizeHandler(),className:`resizer ${s.column.getIsResizing()?"isResizing":""}`,children:n(k.ArrowBarToRight,{})})]},s.id))},i.id))}),n("tbody",{children:r.getRowModel().rows.map(i=>n("tr",{children:i.getVisibleCells().map(s=>n("td",{children:n(ke,{children:Pe.flexRender(s.column.columnDef.cell,s.getContext())})},s.id))},i.id))})]})})}const Fs=T.observer(function({id:t}){const r=Y(),{data:i,state:s}=r.getDataStuffByID(t),o=s==="loading",u=()=>{r.queries.refetchDataByQueryID(t)},l=()=>{r.queries.downloadDataByQueryID(t)},d=m.useMemo(()=>Array.isArray(i)?i.slice(0,10):[],[i]),p=!Array.isArray(i)||i.length===0;return c(a.Stack,{sx:{border:"1px solid #eee"},children:[c(a.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[c(a.Group,{position:"left",children:[n(a.Text,{weight:500,children:"Preview Data"}),i.length>10&&c(a.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",i.length]})]}),c(a.Group,{pr:15,children:[n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:o,onClick:u,children:n(k.Refresh,{size:15})}),n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:o||p,onClick:l,children:n(k.Download,{size:15})})]})]}),c(a.Box,{sx:{position:"relative",overflow:"auto"},children:[n(a.LoadingOverlay,{visible:o}),n(T0,{queryID:t}),n(qs,{data:d})]})]})}),D0=T.observer(function(){const t=ce(),r=Y(),{panel:{queryID:i,setQueryID:s}}=we(),o=()=>{t.editor.setPath(["_QUERIES_",i])};return c(a.Stack,{children:[c(a.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[n(a.Text,{children:"Use query"}),n(a.Select,{data:r.queries.options,value:i,onChange:s,allowDeselect:!1,clearable:!1,sx:{flexGrow:"1 !important"},maxDropdownHeight:300,rightSection:i&&n(a.Tooltip,{label:"Open this query",children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:o,children:n(P.IconArrowCurveRight,{size:16})})})})]}),n(Fs,{id:i})]})}),I0=T.observer(({height:e})=>{const t=Y(),{data:r,loading:i,error:s,panel:{viz:o,queryID:u}}=we(),l=t.queries.findByID(u);return n(a.Flex,{direction:"column",sx:{width:"100%",height:e},children:n(zs,{viz:o,data:r,loading:i,error:s,query:l})})}),M0=T.observer(()=>{const{panel:{title:e,style:{border:t}}}=we();return n(ke,{children:n(a.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:c(a.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.enabled?"1px":"0px"},children:[c(a.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[n(a.Group,{children:n(Ds,{})}),n(a.Group,{grow:!0,position:"center",children:n(a.Text,{lineClamp:1,weight:"bold",children:e})}),n(a.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),n(a.Group,{px:5,pb:5,sx:{flexGrow:1},children:n(I0,{height:"410px"})})]})})})}),wr={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 A0{constructor(t){O(this,"panel");O(this,"selected");this.panel=t,ie.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const t=this.panel.variables.filter(r=>r.name.startsWith(wr.name)).length;this.panel.addVariable(v.cloneDeep({...wr,name:`${wr.name}${t||""}`})),this.selected=v.last(this.panel.variables)}select(t){this.selected=t}remove(t){this.selected===t&&(this.selected=void 0);const r=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!v.isEmpty(this.panel.variables)){const i=Math.min(this.panel.variables.length-1,r);this.selected=this.panel.variables[i]}}}function $0(){const{panel:e}=we();return X.useCreation(()=>new A0(e),[e])}const z0=m.forwardRef(function({value:t,onChange:r,data:i,withStyle:s=!0},o){const u=(l,d)=>{const p=v.cloneDeep(t);v.set(p,l,d),r(p)};return c(a.Box,{px:"sm",py:"md",ref:o,children:[c(a.Group,{grow:!0,noWrap:!0,children:[n(a.TextInput,{label:"Name",required:!0,value:t.name,onChange:l=>u("name",l.currentTarget.value)}),n(F,{label:"Data Field",required:!0,data:i,value:t.data_field,onChange:l=>u("data_field",l)})]}),n(jt,{label:"Aggregation",value:t.aggregation,onChange:l=>u("aggregation",l)}),n(a.Divider,{my:"xs",label:"Format",labelPosition:"center"}),n(Ve,{value:t.formatter,onChange:l=>u("formatter",l)}),s&&n(Sa,{value:t,onChange:r})]})}),Ws=a.createStyles(e=>({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}})),E0=e=>{const{uiModel:t}=e;return n(a.Stack,{className:"var-list",children:t.variables.map(r=>n(a.Button,{variant:t.selected===r?"filled":"subtle",color:"gray",onClick:()=>t.select(r),children:r.name},r.name))})},L0=T.observer(E0),P0=({variable:e,data:t})=>n(a.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:n(a.Paper,{withBorder:!0,p:"md",children:Ta(e,t)})}),O0=T.observer(P0),V0=e=>{const t=X.useCreation(()=>pl(e.variable),[e.variable]),{classes:r}=Ws(),{data:i}=we();return c(a.Group,{style:{height:"100%"},align:"start",children:[c(a.Stack,{"data-testid":"variable-editor",align:"stretch",className:r.config,children:[c(a.Group,{position:"right",children:[n(a.ActionIcon,{variant:"filled",disabled:!t.changed,color:"primary",onClick:t.commit,children:n(P.IconDeviceFloppy,{size:18})}),n(a.ActionIcon,{color:"red",onClick:()=>e.uiModel.remove(e.variable),children:n(P.IconTrash,{size:18})})]}),n(z0,{value:b.getSnapshot(t.copy),onChange:t.update,data:i})]}),n(O0,{variable:b.getSnapshot(t.copy),data:i})]})},B0=T.observer(V0),N0=()=>{const e=$0(),{classes:t}=Ws();return c(a.Group,{className:t.root,noWrap:!0,align:"start",children:[n(a.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:c(a.Stack,{justify:"space-between",children:[n(a.Box,{className:"var-list-actions",children:n(a.Button,{variant:"light",size:"sm",onClick:e.addNew,fullWidth:!0,children:"Add Variable"})}),n(L0,{uiModel:e})]})}),e.selected?n(V,{children:n(B0,{uiModel:e,variable:e.selected})}):n("span",{children:"Select or create a new variable on right side"})]})},G0=T.observer(N0);function q0(){const{vizManager:e}=m.useContext(qe);return m.useMemo(()=>{const t=e.availableVizList.map(r=>({value:r.name,label:r.displayName??r.name,group:r.displayGroup??""}));return v.orderBy(t,[r=>r.group,r=>r.label],["asc","asc"])},[e])}const F0=T.observer(({value:e,submit:t})=>{const[r,i]=ve.useInputState(e);m.useEffect(()=>{i(e)},[e]);const s=q0(),o=e!==r;return n(a.Select,{label:"Visualization",value:r,searchable:!0,onChange:i,data:s,rightSection:n(a.ActionIcon,{disabled:!o,onClick:()=>t(r),children:n(k.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),js=[];function W0(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function j0(){const{data:e,panel:{variables:t,viz:r,title:i,queryID:s,description:o,setDescription:u,setTitle:l,setQueryID:d,id:p}}=we(),{vizManager:f}=m.useContext(qe),g={title:i,description:o,viz:r,queryID:s,id:p},h={setDescription:u,setQueryID:d,setTitle:l},y=Ms(g);try{return f.resolveComponent(g.viz.type),n(rn,{configure:y,children:n(Hv,{variables:t,setVizConf:r.setConf,panel:g,panelInfoEditor:h,vizManager:f,data:e})})}catch(C){return console.info(v.get(C,"message")),null}}const Y0=T.observer(()=>{const{data:e,panel:{viz:t}}=we(),{vizManager:r}=m.useContext(qe),i=m.useCallback(p=>{if(p===t.type)return;const f=W0(r,p);t.setType(p),t.setConf(f||{})},[t.type]),s=p=>{try{t.setConf(JSON.parse(p))}catch(f){console.error(f)}},o=m.useMemo(()=>{var p;return(p=js.find(f=>f.value===t.type))==null?void 0:p.Panel},[t.type,js]),u=j0(),l=o?m.createElement(o,{data:e,conf:t.conf,setConf:t.setConf}):null,d=u||l;return c(a.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[n(F0,{submit:i,value:t.type}),c(ke,{children:[n(a.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:d}),!d&&n(a.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:s})]})]})}),R0=T.observer(({panel:e,sourceViewID:t})=>{const r=Y(),[i,s]=m.useState(t);m.useEffect(()=>{s(t)},[t]);const[o,{open:u,close:l}]=ve.useDisclosure(!1),d=()=>{e.moveToView(t,i),l()};return c(V,{children:[n(a.Button,{size:"xs",variant:"subtle",color:"blue",onClick:u,leftIcon:n(P.IconBoxMultiple,{size:14}),children:"Move into Another View"}),n(a.Modal,{opened:o,onClose:l,title:"Move panel into another view",zIndex:320,overflow:"inside",children:c(a.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[n(a.Radio.Group,{value:i,onChange:s,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:n(a.Stack,{spacing:"xs",children:r.views.options.map(p=>n(a.Radio,{value:p.value,label:p.label},p.value))})}),c(a.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[n(a.Button,{size:"xs",color:"red",leftIcon:n(P.IconX,{size:14}),onClick:l,children:"Cancel"}),n(a.Button,{size:"xs",color:"blue",leftIcon:n(P.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:"Confirm"})]})]})})]})}),Q0={root:{flexGrow:1,width:"100%",overflow:"hidden"},panel:{width:"100%",height:"calc(100% - 44px)",padding:10,overflow:"scroll"}},Ys=({children:e})=>c(a.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"100%"},children:[n(a.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),n(M0,{})]});function U0(e){return!["richText","button"].includes(e)}const X0=T.observer(({panel:e})=>{const t=Le.useModals(),r=ce(),i=Y(),[s,o]=m.useState("Data"),{data:u,state:l,error:d}=i.getDataStuffByID(e.queryID),p=i.queries.findByID(e.queryID),g=U0(e.viz.type)&&l==="loading",h=g||d||!p||!!p.stateMessage,y=r.editor.path[1];m.useEffect(()=>{o(S=>h&&S==="Visualization"?"Data":S)},[e.id,h]);const C=()=>{r.editor.setPath(["_VIEWS_",y])},w=()=>t.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.removePanelByID(e.id,y),C()},confirmProps:{color:"red"},zIndex:320});return c(Mn,{value:{panel:e,data:u,loading:g,error:d},children:[c(a.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[c(a.Text,{pt:9,pb:8,children:[e.title?e.title:e.viz.type," "]}),c(a.Group,{position:"right",noWrap:!0,children:[n(R0,{panel:e,sourceViewID:y}),n(a.Button,{size:"xs",variant:"subtle",color:"red",onClick:w,leftIcon:n(P.IconTrash,{size:14}),children:"Delete This Panel"})]})]}),c(a.Tabs,{value:s,onTabChange:o,keepMounted:!1,styles:Q0,children:[c(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"Data",disabled:g,children:"Data"}),n(a.Tabs.Tab,{value:"Panel",children:"Panel"}),n(a.Tabs.Tab,{value:"Variables",disabled:h,children:n(a.Tooltip,{label:"Requires data",disabled:!h,withinPortal:!0,zIndex:310,children:n(a.Text,{children:"Variables"})})}),n(a.Tabs.Tab,{value:"Visualization",disabled:h,children:n(a.Tooltip,{label:"Requires data",disabled:!h,withinPortal:!0,zIndex:310,children:n(a.Text,{children:"Visualization"})})}),n(a.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),c(a.Tabs.Panel,{value:"Data",children:[n(a.LoadingOverlay,{visible:g,exitTransitionDuration:0}),n(D0,{})]}),n(a.Tabs.Panel,{value:"Panel",children:n(Ys,{children:n(S0,{})})}),n(a.Tabs.Panel,{value:"Variables",children:n(G0,{})}),n(a.Tabs.Panel,{value:"Visualization",children:n(ke,{children:n(Ys,{children:n(Y0,{})})})}),n(a.Tabs.Panel,{value:"Interactions",children:n(ke,{children:n(tu,{})})})]})]})}),Z0=T.observer(({viewID:e,panelID:t})=>{const r=Y();if(!r.views.findByID(e))return c(a.Text,{size:14,children:["View by ID[",e,"] is not found"]});const s=r.panels.findByID(t);return s?n(X0,{panel:s}):c(a.Text,{size:14,children:["Panel by ID[",t,"] is not found"]})}),Rs=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:r,count:i,spacing:s=16,pl:o=0})=>c(a.Stack,{spacing:s,mt:6,pl:o,children:[Array.from(new Array(i-1),(u,l)=>n(a.Skeleton,{width:e,height:r,radius:"xs"},l)),n(a.Skeleton,{width:t,height:r,radius:"xs"})]}),At=({value:e})=>e===null||e===""?null:n(a.Tooltip,{label:e,disabled:!e,multiline:!0,children:n(a.ActionIcon,{children:n(P.IconInfoCircle,{size:14})})}),K0=({column:e})=>{const{column_key:t,column_key_text:r}=e;return t?n(a.Tooltip,{label:r,disabled:!r,children:n(a.Badge,{children:t})}):null},J0=T.observer(({dataSource:e})=>{const{columns:t}=e;return t.loading?n(Rs,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:c(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[c("colgroup",{children:[n("col",{style:{width:50}}),n("col",{style:{minWidth:300}}),n("col",{style:{width:30}}),n("col",{style:{width:70}}),n("col",{style:{minWidth:300}}),n("col",{style:{minWidth:80,width:80}}),n("col",{style:{minWidth:120,width:120}})]}),n("thead",{children:c("tr",{children:[n("th",{children:"#"}),n("th",{children:"Column Name"}),n("th",{}),n("th",{}),n("th",{children:"Type"}),n("th",{children:"Nullable"}),n("th",{children:"Default Value"})]})}),n("tbody",{children:t.data.map(r=>c("tr",{children:[n("td",{children:r.ordinal_position}),n("td",{children:r.column_name}),n("td",{children:n(At,{value:r.column_comment})}),n("td",{children:n(K0,{column:r})}),n("td",{children:r.column_type}),n("td",{children:r.is_nullable}),n("td",{children:n(At,{value:r.column_default})})]},r.column_name))})]})}),H0=T.observer(({dataSource:e})=>{const{indexes:t}=e,r=t.data;return c(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[c("colgroup",{children:[n("col",{style:{width:100}}),n("col",{style:{minWidth:300}}),n("col",{style:{width:150}}),n("col",{style:{width:150}}),n("col",{style:{width:250}})]}),n("thead",{children:c("tr",{children:[n("th",{children:"Index Length"}),n("th",{children:"Index Name"}),n("th",{children:"Index Algorithm"}),n("th",{children:"Unique"}),n("th",{children:"Column Name"})]})}),n("tbody",{children:r.map(i=>c("tr",{children:[n("td",{children:i.index_length}),n("td",{children:i.index_name}),n("td",{children:i.index_algorithm}),n("td",{children:i.is_unique?"YES":"NO"}),n("td",{children:i.column_name})]},i.index_name))})]})}),eC=T.observer(({dataSource:e})=>{const{indexes:t}=e,r=t.data;return c(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[c("colgroup",{children:[n("col",{style:{minWidth:300}}),n("col",{style:{width:150}}),n("col",{style:{width:100}}),n("col",{style:{width:100}}),n("col",{style:{width:100}}),n("col",{style:{width:100}})]}),n("thead",{children:c("tr",{children:[n("th",{children:"Index Name"}),n("th",{children:"Index Algorithm"}),n("th",{children:"Unique"}),n("th",{children:"Definition"}),n("th",{children:"Condition"}),n("th",{children:"Comment"})]})}),n("tbody",{children:r.map(i=>c("tr",{children:[n("td",{children:i.index_name}),n("td",{children:i.index_algorithm}),n("td",{children:i.is_unique?"YES":"NO"}),n("td",{children:n(At,{value:i.index_definition})}),n("td",{children:n(At,{value:i.condition})}),n("td",{children:n(At,{value:i.comment})})]},i.index_name))})]})}),tC=T.observer(({dataSource:e})=>{const{indexes:t}=e;return t.loading||t.empty?null:e.type===pe.MySQL?n(H0,{dataSource:e}):e.type===pe.Postgresql?n(eC,{dataSource:e}):null}),nC=T.observer(({dataSource:e})=>c(a.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[n(ke,{children:n(J0,{dataSource:e})}),n(ke,{children:n(tC,{dataSource:e})})]}));function rC({table_type:e}){return e==="VIEW"?n(P.IconEye,{size:14}):e==="BASE TABLE"?n(P.IconTable,{size:14}):null}const iC=T.observer(({dataSource:e})=>{const{tables:t}=e;return t.loading?n(Rs,{height:"24px",lastWidth:"50%",count:15}):n(a.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(t.data).map(([r,i])=>n(a.NavLink,{label:r,icon:n(P.IconDatabase,{size:14}),defaultOpened:e.table_schema===r,pl:0,childrenOffset:14,children:i.map(s=>n(a.NavLink,{label:s.table_name,icon:n(rC,{table_type:s.table_type}),onClick:()=>{e.setKeywords(r,s.table_name)},active:e.table_name===s.table_name},s.table_name))},r))})}),aC=({visible:e})=>n(a.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:n(a.LoadingOverlay,{visible:e})}),sC=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],oC={icon:{width:"50px",textAlign:"center"},input:{"&.mantine-Input-withIcon":{paddingLeft:"50px"}}},lC=T.observer(({dataSource:e})=>{const{tableData:t}=e;return c(a.Group,{pt:10,px:10,position:"apart",children:[c(a.Group,{position:"left",children:[t.maxPage>1&&n(a.Pagination,{size:"sm",page:t.page,onChange:t.setPage,total:t.maxPage,withEdges:t.maxPage>7,styles:{item:{height:"30px"}}}),n(a.Select,{icon:n(a.Text,{ta:"center",color:"dimmed",size:14,children:"Limit"}),size:"xs",styles:oC,data:sC,value:String(t.limit),onChange:r=>t.setLimit(Number(r))})]}),n(a.Group,{position:"right",children:c(a.Text,{color:"dimmed",my:0,size:14,children:["Total ",t.total," rows"]})})]})}),uC=T.observer(({dataSource:e})=>{const t=e.tableData;return t.maxPage===0?n(a.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):t.error?n(a.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:t.error}):t.page===1&&t.loading?n(aC,{visible:!0}):c(ke,{children:[n(lC,{dataSource:e}),c(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n(a.LoadingOverlay,{visible:t.loading,overlayBlur:2}),n(qs,{data:t.data})]})]})}),dC={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},cC=T.observer(({dataSource:e})=>(m.useEffect(()=>{e.loadTablesIfEmpty()},[e]),e.tables.error?n(a.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.tables.error}):c(a.Flex,{sx:{height:"100%"},children:[n(a.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:n(ke,{children:n(iC,{dataSource:e})})}),c(a.Tabs,{defaultValue:"structure",styles:dC,children:[c(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"structure",icon:n(P.IconColumns,{size:14}),children:"Structure"}),n(a.Tabs.Tab,{value:"data",icon:n(P.IconDatabase,{size:14}),children:"Data"})]}),n(a.Tabs.Panel,{value:"structure",children:n(nC,{dataSource:e})}),n(a.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:n(uC,{dataSource:e})})]})]}))),pC={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"0 20px 10px",borderBottom:"1px solid #efefef"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},Qs=T.observer(({dataSource:e,triggerButtonProps:t={}})=>{const[r,i]=m.useState(!1);return e.type==="http"?null:c(V,{children:[n(a.Modal,{opened:r,onClose:()=>i(!1),title:c(a.Group,{position:"apart",sx:{flexGrow:1},children:[n(a.Text,{fw:500,children:"Explorer Data Source"}),c(a.Group,{spacing:7,children:[n(a.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),n(a.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",overflow:"inside",styles:pC,children:n(a.Box,{sx:{height:"calc(100vh - 220px)"},children:n(cC,{dataSource:e})})}),n(a.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:"See Table Structure"})]})}),hC=m.forwardRef(({label:e,type:t,...r},i)=>c(a.Group,{position:"apart",ref:i,...r,children:[n(a.Text,{children:e}),n(a.Text,{children:t})]})),fC=T.observer(({value:e,onChange:t})=>{const r=ce(),{data:i=[],loading:s}=X.useRequest(yn,{refreshDeps:[]},[]),o=m.useMemo(()=>i.map(p=>({label:p.key,value:p.key,type:p.type})),[i]),u=m.useMemo(()=>o.reduce((p,f)=>(p[f.value]=f.type,p),{}),[o]),l=p=>{p!==null&&t({key:p,type:u[p]})},d=m.useMemo(()=>r.datasources.find(e),[r,e]);return n(a.Select,{data:o,label:c(a.Group,{position:"apart",children:[n(a.Box,{children:"Data Source"}),d&&n(Qs,{dataSource:d,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:hC,rightSection:d?n(a.Text,{size:"xs",color:"dimmed",children:d.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:s,value:e.key,onChange:l})}),gC=e=>{const{queryModel:t}=e,r=ce(),i=Y(),o=i.findQueryUsage(t.id).length>0,u=Le.useModals(),l=()=>{u.openConfirmModal({title:"Delete this query?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.queries.removeQuery(t.id),r.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return o?n(a.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:n(a.Button,{color:"gray",size:"xs",leftIcon:n(P.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})}):n(a.Button,{color:"red",size:"xs",onClick:l,leftIcon:n(P.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})},mC=T.observer(gC),bC=T.observer(({queryModel:e})=>n(a.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:c(a.Stack,{spacing:10,sx:{width:"100%"},children:[n(a.Divider,{mb:-10,variant:"dashed",label:"Basics",labelPosition:"center"}),n(a.TextInput,{placeholder:"A unique name",label:"Name",required:!0,sx:{flex:1},value:e.name,onChange:t=>{e.setName(t.currentTarget.value)}}),n(fC,{value:{type:e.type,key:e.key},onChange:({type:t,key:r})=>{e.setKey(r),e.setType(t)}}),n(a.Divider,{mt:10,mb:-10,variant:"dashed",label:"Conditions",labelPosition:"center"}),n(a.MultiSelect,{label:"Run query when these are truthy",placeholder:"Always run this query on load",data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy}),e.typedAsHTTP&&n(a.MultiSelect,{label:"Re-run query when these changed",placeholder:"Leave it empty to never re-run this query",data:e.conditionOptions,value:[...e.react_to],onChange:e.setReactTo}),n(a.Divider,{mt:20,mb:10,variant:"dashed"}),n(mC,{queryModel:e})]})}));function yC(){const[e,{open:t,close:r}]=ve.useDisclosure(!1);return c(V,{children:[n(a.Modal,{opened:e,onClose:r,title:"About FunctionUtils",zIndex:320,children:n(en,{value:Do,styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),n(a.Button,{variant:"light",color:"violet",size:"xs",onClick:t,leftIcon:n(P.IconInfoCircle,{size:16}),children:"About parameter 'utils'"})]})}const vC=({value:e,onChange:t})=>{const r=i=>{i&&t(i)};return n(a.Box,{sx:{position:"relative",flexGrow:1},children:n(_e,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}}})})},dn=m.forwardRef(({value:e,onChange:t,label:r,defaultValue:i},s)=>{const[o,u]=m.useState(e),l=()=>{t(o)},d=()=>{u(e)},p=()=>{u(i)};m.useEffect(()=>{u(e)},[e]);const f=o!==e;return c(a.Stack,{spacing:4,sx:{height:"100%"},children:[c(a.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[n(a.Group,{position:"left",children:n(yC,{})}),c(a.Group,{position:"right",children:[n(a.Button,{onClick:p,size:"xs",variant:"default",leftIcon:n(P.IconPlayerSkipBack,{size:16}),children:"Reset to default"}),n(a.Button,{onClick:d,color:"red",size:"xs",disabled:!f,leftIcon:n(P.IconRecycle,{size:16}),children:"Revert Changes"}),n(a.Button,{size:"xs",onClick:l,disabled:!f,leftIcon:n(P.IconDeviceFloppy,{size:16}),children:"Confirm Changes"})]})]}),n(a.Text,{size:14,children:r}),n(vC,{value:o,onChange:u})]})});function xC({content:e}){return c(a.HoverCard,{width:"60vw",shadow:"md",children:[n(a.HoverCard.Target,{children:n(a.ActionIcon,{size:16,color:"blue",children:n(P.IconEye,{})})}),n(a.HoverCard.Dropdown,{children:n(it.Prism,{language:"sql",noCopy:!0,withLineNumbers:!0,children:e})})]})}const CC=T.observer(()=>{const t=[...ce().globalSQLSnippets.list];return c(a.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fontSize:"sm",highlightOnHover:!0,children:[n("thead",{children:c("tr",{children:[n("th",{children:"Key"}),n("th",{children:"Value"})]})}),n("tbody",{children:t.map(r=>{const{id:i,content:s}=r;return c("tr",{children:[n("td",{children:i}),n("td",{width:200,children:n(xC,{content:s})})]},i)})})]})}),wC=`
485
+ `,h0=()=>{const[e,t]=m.useState(!1);return c(V,{children:[n(a.Button,{variant:"subtle",compact:!0,onClick:()=>t(r=>!r),children:e?"Close":"Click to see expected data structure"}),n(a.Collapse,{in:e,children:n(it.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:p0})})]})},f0=T.observer(function({config:t}){return c(V,{children:[n(a.TextInput,{label:"Min-width",value:t.min_width,onChange:r=>t.setMinWidth(r.currentTarget.value),placeholder:"200px"}),n(a.Divider,{label:"Fetch options from database",labelPosition:"center"}),n(a.NumberInput,{value:t.default_selection_count,onChange:t.setDefaultSelectionCount,label:"Select first N options by default"}),n(Cr,{value:t.options_query_id,onChange:t.setOptionsQueryID}),n(h0,{})]})}),g0=T.observer(function({filter:t}){const[r,i]=m.useState(t.plainDefaultValue);return m.useEffect(()=>{i(t.plainDefaultValue)},[t]),c(a.Box,{sx:{maxWidth:"480px"},children:[n(a.Text,{pb:"md",color:"gray",children:"Preview"}),n(Ts,{filter:t,value:r,onChange:i}),n(a.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),n(it.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),m0={select:d0,"multi-select":u0,"tree-select":f0,"text-input":c0,checkbox:a0,"date-range":o0},b0=[{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"}],y0=T.observer(function({filter:t}){const r=Y(),i=m.useMemo(()=>m0[t.type],[t.type]);return c(a.Group,{grow:!0,spacing:20,align:"top",children:[c(a.Box,{sx:{maxWidth:"600px"},children:[n(a.Text,{pb:"md",color:"gray",children:"Edit"}),c(a.Stack,{children:[c(a.Group,{noWrap:!0,children:[n(a.NumberInput,{label:"Placement Order",required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&n(a.Checkbox,{label:"Submit automatically",checked:t.auto_submit,onChange:s=>t.setAutoSubmit(s.currentTarget.checked),mt:22})]}),n(a.MultiSelect,{label:"Visible in...",data:r.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),n(a.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:t.key,onChange:s=>{t.setKey(s.currentTarget.value)}}),n(a.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:t.label,onChange:s=>{t.setLabel(s.currentTarget.value)}}),n(a.Select,{label:"Widget",data:b0,required:!0,value:t.type,onChange:t.setType}),n(i,{config:t.config})]})]}),n(g0,{filter:t})]})}),v0=T.observer(({id:e})=>{const t=Le.useModals(),r=ce(),i=Y();if(e==="")return null;const s=i.filters.findByID(e);if(!s)return c(a.Text,{size:14,children:["Filter by ID[",e,"] is not found"]});const o=()=>{r.editor.setPath(["_FILTERS_",""])},u=()=>{t.openConfirmModal({title:"Delete this filter?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.filters.removeByID(e),o()},confirmProps:{color:"red"},zIndex:320})};return c(a.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[n(a.Group,{position:"right",pt:10,children:n(a.Button,{size:"xs",color:"red",leftIcon:n(k.Trash,{size:16}),onClick:u,children:"Delete this filter"})}),n(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n(y0,{filter:s})})]})}),x0=T.observer(()=>{const e=Y(),[t,r]=m.useState(()=>JSON.stringify(e.mock_context.current,null,4)),i=()=>{try{e.mock_context.replace(JSON.parse(t))}catch(o){Ot.showNotification({title:"Failed",message:o.message,color:"red"})}},s=m.useMemo(()=>{try{return JSON.stringify(JSON.parse(t))!==JSON.stringify(e.mock_context.current)}catch{return!1}},[t,e.mock_context.current]);return c(a.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[n(a.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:n(a.Text,{weight:500,children:"Mock Context"})}),c(a.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[c(a.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[n(a.Text,{children:"A valid json string is required"}),n(a.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:t,onChange:r,sx:{flexGrow:1}})]}),n(a.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!s,onClick:i,children:n(k.DeviceFloppy,{size:20})})]})]})}),C0=T.observer(()=>{const{panel:e}=we();return n(Un,{label:"Description",value:e.description,onChange:e.setDescription,styles:{root:{flexGrow:1}}})}),w0=T.observer(()=>{const{panel:e}=we(),{style:t}=e;return n(V,{children:n(a.Switch,{label:"Border",checked:t.border.enabled,onChange:r=>t.border.setEnabled(r.currentTarget.checked)})})}),_0=T.observer(()=>{const{panel:e}=we(),{title:t,setTitle:r}=e,[i,s]=ve.useInputState(t),o=t!==i,u=m.useCallback(()=>{o&&r(i)},[o,i]);return m.useEffect(()=>{s(t)},[t]),n(a.TextInput,{value:i,onChange:s,label:c(a.Group,{children:[n(a.Text,{children:"Panel Title"}),n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:u,children:n(k.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function S0(){return c(a.Stack,{sx:{height:"100%"},children:[n(a.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),n(w0,{}),n(a.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),n(_0,{}),n(C0,{})]})}const T0=({queryID:e})=>{const t=Y(),{state:r,error:i}=t.getDataStuffByID(e),s=m.useMemo(()=>t.queries.findByID(e),[t,e]);return r==="loading"?null:i?n(a.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:i}):s!=null&&s.stateMessage?n(a.Text,{color:"gray",align:"center",children:s.stateMessage}):null},k0={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 qs({data:e}){const t=m.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const i=Pe.createColumnHelper();return Object.keys(e[0]).map(s=>i.accessor(s,{cell:o=>o.getValue()}))},[e]),r=Pe.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Pe.getCoreRowModel()});return e.length===0?n(a.Box,{sx:{height:"5em"}}):n(ke,{children:c(a.Table,{sx:k0,children:[n("thead",{children:r.getHeaderGroups().map(i=>n("tr",{children:i.headers.map(s=>c("th",{style:{width:s.getSize()},children:[s.isPlaceholder?null:Pe.flexRender(s.column.columnDef.header,s.getContext()),n(a.ActionIcon,{onMouseDown:s.getResizeHandler(),onTouchStart:s.getResizeHandler(),className:`resizer ${s.column.getIsResizing()?"isResizing":""}`,children:n(k.ArrowBarToRight,{})})]},s.id))},i.id))}),n("tbody",{children:r.getRowModel().rows.map(i=>n("tr",{children:i.getVisibleCells().map(s=>n("td",{children:n(ke,{children:Pe.flexRender(s.column.columnDef.cell,s.getContext())})},s.id))},i.id))})]})})}const Fs=T.observer(function({id:t}){const r=Y(),{data:i,state:s}=r.getDataStuffByID(t),o=s==="loading",u=()=>{r.queries.refetchDataByQueryID(t)},l=()=>{r.queries.downloadDataByQueryID(t)},d=m.useMemo(()=>Array.isArray(i)?i.slice(0,10):[],[i]),p=!Array.isArray(i)||i.length===0;return c(a.Stack,{sx:{border:"1px solid #eee"},children:[c(a.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[c(a.Group,{position:"left",children:[n(a.Text,{weight:500,children:"Preview Data"}),i.length>10&&c(a.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",i.length]})]}),c(a.Group,{pr:15,children:[n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:o,onClick:u,children:n(k.Refresh,{size:15})}),n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:o||p,onClick:l,children:n(k.Download,{size:15})})]})]}),c(a.Box,{sx:{position:"relative",overflow:"auto"},children:[n(a.LoadingOverlay,{visible:o}),n(T0,{queryID:t}),n(qs,{data:d})]})]})}),D0=T.observer(function(){const t=ce(),r=Y(),{panel:{queryID:i,setQueryID:s}}=we(),o=()=>{t.editor.setPath(["_QUERIES_",i])};return c(a.Stack,{children:[c(a.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[n(a.Text,{children:"Use query"}),n(a.Select,{data:r.queries.options,value:i,onChange:s,allowDeselect:!1,clearable:!1,sx:{flexGrow:"1 !important"},maxDropdownHeight:300,rightSection:i&&n(a.Tooltip,{label:"Open this query",children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:o,children:n(P.IconArrowCurveRight,{size:16})})})})]}),n(Fs,{id:i})]})}),I0=T.observer(({height:e})=>{const t=Y(),{data:r,loading:i,error:s,panel:{viz:o,queryID:u}}=we(),l=t.queries.findByID(u);return n(a.Flex,{direction:"column",sx:{width:"100%",height:e},children:n(zs,{viz:o,data:r,loading:i,error:s,query:l})})}),M0=T.observer(()=>{const{panel:{title:e,style:{border:t}}}=we();return n(ke,{children:n(a.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:c(a.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.enabled?"1px":"0px"},children:[c(a.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[n(a.Group,{children:n(Ds,{})}),n(a.Group,{grow:!0,position:"center",children:n(a.Text,{lineClamp:1,weight:"bold",children:e})}),n(a.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),n(a.Group,{px:5,pb:5,sx:{flexGrow:1},children:n(I0,{height:"410px"})})]})})})}),wr={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 A0{constructor(t){O(this,"panel");O(this,"selected");this.panel=t,ie.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const t=this.panel.variables.filter(r=>r.name.startsWith(wr.name)).length;this.panel.addVariable(v.cloneDeep({...wr,name:`${wr.name}${t||""}`})),this.selected=v.last(this.panel.variables)}select(t){this.selected=t}remove(t){this.selected===t&&(this.selected=void 0);const r=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!v.isEmpty(this.panel.variables)){const i=Math.min(this.panel.variables.length-1,r);this.selected=this.panel.variables[i]}}}function $0(){const{panel:e}=we();return X.useCreation(()=>new A0(e),[e])}const z0=m.forwardRef(function({value:t,onChange:r,data:i,withStyle:s=!0},o){const u=(l,d)=>{const p=v.cloneDeep(t);v.set(p,l,d),r(p)};return c(a.Box,{px:"sm",py:"md",ref:o,children:[c(a.Group,{grow:!0,noWrap:!0,children:[n(a.TextInput,{label:"Name",required:!0,value:t.name,onChange:l=>u("name",l.currentTarget.value)}),n(F,{label:"Data Field",required:!0,data:i,value:t.data_field,onChange:l=>u("data_field",l)})]}),n(jt,{label:"Aggregation",value:t.aggregation,onChange:l=>u("aggregation",l)}),n(a.Divider,{my:"xs",label:"Format",labelPosition:"center"}),n(Ve,{value:t.formatter,onChange:l=>u("formatter",l)}),s&&n(Sa,{value:t,onChange:r})]})}),Ws=a.createStyles(e=>({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}})),E0=e=>{const{uiModel:t}=e;return n(a.Stack,{className:"var-list",children:t.variables.map(r=>n(a.Button,{variant:t.selected===r?"filled":"subtle",color:"gray",onClick:()=>t.select(r),children:r.name},r.name))})},L0=T.observer(E0),P0=({variable:e,data:t})=>n(a.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:n(a.Paper,{withBorder:!0,p:"md",children:Ta(e,t)})}),O0=T.observer(P0),V0=e=>{const t=X.useCreation(()=>pl(e.variable),[e.variable]),{classes:r}=Ws(),{data:i}=we();return c(a.Group,{style:{height:"100%"},align:"start",children:[c(a.Stack,{"data-testid":"variable-editor",align:"stretch",className:r.config,children:[c(a.Group,{position:"right",children:[n(a.ActionIcon,{variant:"filled",disabled:!t.changed,color:"primary",onClick:t.commit,children:n(P.IconDeviceFloppy,{size:18})}),n(a.ActionIcon,{color:"red",onClick:()=>e.uiModel.remove(e.variable),children:n(P.IconTrash,{size:18})})]}),n(z0,{value:b.getSnapshot(t.copy),onChange:t.update,data:i})]}),n(O0,{variable:b.getSnapshot(t.copy),data:i})]})},B0=T.observer(V0),N0=()=>{const e=$0(),{classes:t}=Ws();return c(a.Group,{className:t.root,noWrap:!0,align:"start",children:[n(a.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:c(a.Stack,{justify:"space-between",children:[n(a.Box,{className:"var-list-actions",children:n(a.Button,{variant:"light",size:"sm",onClick:e.addNew,fullWidth:!0,children:"Add Variable"})}),n(L0,{uiModel:e})]})}),e.selected?n(V,{children:n(B0,{uiModel:e,variable:e.selected})}):n("span",{children:"Select or create a new variable on right side"})]})},G0=T.observer(N0);function q0(){const{vizManager:e}=m.useContext(qe);return m.useMemo(()=>{const t=e.availableVizList.map(r=>({value:r.name,label:r.displayName??r.name,group:r.displayGroup??""}));return v.orderBy(t,[r=>r.group,r=>r.label],["asc","asc"])},[e])}const F0=T.observer(({value:e,submit:t})=>{const[r,i]=ve.useInputState(e);m.useEffect(()=>{i(e)},[e]);const s=q0(),o=e!==r;return n(a.Select,{label:"Visualization",value:r,searchable:!0,onChange:i,data:s,rightSection:n(a.ActionIcon,{disabled:!o,onClick:()=>t(r),children:n(k.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),js=[];function W0(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function j0(){const{data:e,panel:{variables:t,viz:r,title:i,queryID:s,description:o,setDescription:u,setTitle:l,setQueryID:d,id:p}}=we(),{vizManager:f}=m.useContext(qe),g={title:i,description:o,viz:r,queryID:s,id:p},h={setDescription:u,setQueryID:d,setTitle:l},y=Ms(g);try{return f.resolveComponent(g.viz.type),n(rn,{configure:y,children:n(Hv,{variables:t,setVizConf:r.setConf,panel:g,panelInfoEditor:h,vizManager:f,data:e})})}catch(C){return console.info(v.get(C,"message")),null}}const Y0=T.observer(()=>{const{data:e,panel:{viz:t}}=we(),{vizManager:r}=m.useContext(qe),i=m.useCallback(p=>{if(p===t.type)return;const f=W0(r,p);t.setType(p),t.setConf(f||{})},[t.type]),s=p=>{try{t.setConf(JSON.parse(p))}catch(f){console.error(f)}},o=m.useMemo(()=>{var p;return(p=js.find(f=>f.value===t.type))==null?void 0:p.Panel},[t.type,js]),u=j0(),l=o?m.createElement(o,{data:e,conf:t.conf,setConf:t.setConf}):null,d=u||l;return c(a.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[n(F0,{submit:i,value:t.type}),c(ke,{children:[n(a.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:d}),!d&&n(a.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:s})]})]})}),R0=T.observer(({panel:e,sourceViewID:t})=>{const r=Y(),[i,s]=m.useState(t);m.useEffect(()=>{s(t)},[t]);const[o,{open:u,close:l}]=ve.useDisclosure(!1),d=()=>{e.moveToView(t,i),l()};return c(V,{children:[n(a.Button,{size:"xs",variant:"subtle",color:"blue",onClick:u,leftIcon:n(P.IconBoxMultiple,{size:14}),children:"Move into Another View"}),n(a.Modal,{opened:o,onClose:l,title:"Move panel into another view",zIndex:320,overflow:"inside",children:c(a.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[n(a.Radio.Group,{value:i,onChange:s,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:n(a.Stack,{spacing:"xs",children:r.views.options.map(p=>n(a.Radio,{value:p.value,label:p.label},p.value))})}),c(a.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[n(a.Button,{size:"xs",color:"red",leftIcon:n(P.IconX,{size:14}),onClick:l,children:"Cancel"}),n(a.Button,{size:"xs",color:"blue",leftIcon:n(P.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:"Confirm"})]})]})})]})}),Q0={root:{flexGrow:1,width:"100%",overflow:"hidden"},panel:{width:"100%",height:"calc(100% - 44px)",padding:10,overflow:"scroll"}},Ys=({children:e})=>c(a.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"100%"},children:[n(a.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),n(M0,{})]});function U0(e){return!["richText","button"].includes(e)}const X0=T.observer(({panel:e})=>{const t=Le.useModals(),r=ce(),i=Y(),[s,o]=m.useState("Data"),{data:u,state:l,error:d}=i.getDataStuffByID(e.queryID),p=i.queries.findByID(e.queryID),g=U0(e.viz.type)&&l==="loading",h=g||d||!p||!!p.stateMessage,y=r.editor.path[1];m.useEffect(()=>{o(S=>h&&S==="Visualization"?"Data":S)},[e.id,h]);const C=()=>{r.editor.setPath(["_VIEWS_",y])},w=()=>t.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.removePanelByID(e.id,y),C()},confirmProps:{color:"red"},zIndex:320});return c(Mn,{value:{panel:e,data:u,loading:g,error:d},children:[c(a.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[c(a.Text,{pt:9,pb:8,children:[e.title?e.title:e.viz.type," "]}),c(a.Group,{position:"right",noWrap:!0,children:[n(R0,{panel:e,sourceViewID:y}),n(a.Button,{size:"xs",variant:"subtle",color:"red",onClick:w,leftIcon:n(P.IconTrash,{size:14}),children:"Delete This Panel"})]})]}),c(a.Tabs,{value:s,onTabChange:o,keepMounted:!1,styles:Q0,children:[c(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"Data",disabled:g,children:"Data"}),n(a.Tabs.Tab,{value:"Panel",children:"Panel"}),n(a.Tabs.Tab,{value:"Variables",disabled:h,children:n(a.Tooltip,{label:"Requires data",disabled:!h,withinPortal:!0,zIndex:310,children:n(a.Text,{children:"Variables"})})}),n(a.Tabs.Tab,{value:"Visualization",disabled:h,children:n(a.Tooltip,{label:"Requires data",disabled:!h,withinPortal:!0,zIndex:310,children:n(a.Text,{children:"Visualization"})})}),n(a.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),c(a.Tabs.Panel,{value:"Data",children:[n(a.LoadingOverlay,{visible:g,exitTransitionDuration:0}),n(D0,{})]}),n(a.Tabs.Panel,{value:"Panel",children:n(Ys,{children:n(S0,{})})}),n(a.Tabs.Panel,{value:"Variables",children:n(G0,{})}),n(a.Tabs.Panel,{value:"Visualization",children:n(ke,{children:n(Ys,{children:n(Y0,{})})})}),n(a.Tabs.Panel,{value:"Interactions",children:n(ke,{children:n(tu,{})})})]})]})}),Z0=T.observer(({viewID:e,panelID:t})=>{const r=Y();if(!r.views.findByID(e))return c(a.Text,{size:14,children:["View by ID[",e,"] is not found"]});const s=r.panels.findByID(t);return s?n(X0,{panel:s}):c(a.Text,{size:14,children:["Panel by ID[",t,"] is not found"]})}),Rs=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:r,count:i,spacing:s=16,pl:o=0})=>c(a.Stack,{spacing:s,mt:6,pl:o,children:[Array.from(new Array(i-1),(u,l)=>n(a.Skeleton,{width:e,height:r,radius:"xs"},l)),n(a.Skeleton,{width:t,height:r,radius:"xs"})]}),At=({value:e})=>e===null||e===""?null:n(a.Tooltip,{label:e,disabled:!e,multiline:!0,children:n(a.ActionIcon,{children:n(P.IconInfoCircle,{size:14})})}),K0=({column:e})=>{const{column_key:t,column_key_text:r}=e;return t?n(a.Tooltip,{label:r,disabled:!r,children:n(a.Badge,{children:t})}):null},J0=T.observer(({dataSource:e})=>{const{columns:t}=e;return t.loading?n(Rs,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:c(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[c("colgroup",{children:[n("col",{style:{width:50}}),n("col",{style:{minWidth:300}}),n("col",{style:{width:30}}),n("col",{style:{width:70}}),n("col",{style:{minWidth:300}}),n("col",{style:{minWidth:80,width:80}}),n("col",{style:{minWidth:120,width:120}})]}),n("thead",{children:c("tr",{children:[n("th",{children:"#"}),n("th",{children:"Column Name"}),n("th",{}),n("th",{}),n("th",{children:"Type"}),n("th",{children:"Nullable"}),n("th",{children:"Default Value"})]})}),n("tbody",{children:t.data.map(r=>c("tr",{children:[n("td",{children:r.ordinal_position}),n("td",{children:r.column_name}),n("td",{children:n(At,{value:r.column_comment})}),n("td",{children:n(K0,{column:r})}),n("td",{children:r.column_type}),n("td",{children:r.is_nullable}),n("td",{children:n(At,{value:r.column_default})})]},r.column_name))})]})}),H0=T.observer(({dataSource:e})=>{const{indexes:t}=e,r=t.data;return c(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[c("colgroup",{children:[n("col",{style:{width:100}}),n("col",{style:{minWidth:300}}),n("col",{style:{width:150}}),n("col",{style:{width:150}}),n("col",{style:{width:250}})]}),n("thead",{children:c("tr",{children:[n("th",{children:"Index Length"}),n("th",{children:"Index Name"}),n("th",{children:"Index Algorithm"}),n("th",{children:"Unique"}),n("th",{children:"Column Name"})]})}),n("tbody",{children:r.map(i=>c("tr",{children:[n("td",{children:i.index_length}),n("td",{children:i.index_name}),n("td",{children:i.index_algorithm}),n("td",{children:i.is_unique?"YES":"NO"}),n("td",{children:i.column_name})]},i.index_name))})]})}),eC=T.observer(({dataSource:e})=>{const{indexes:t}=e,r=t.data;return c(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[c("colgroup",{children:[n("col",{style:{minWidth:300}}),n("col",{style:{width:150}}),n("col",{style:{width:100}}),n("col",{style:{width:100}}),n("col",{style:{width:100}}),n("col",{style:{width:100}})]}),n("thead",{children:c("tr",{children:[n("th",{children:"Index Name"}),n("th",{children:"Index Algorithm"}),n("th",{children:"Unique"}),n("th",{children:"Definition"}),n("th",{children:"Condition"}),n("th",{children:"Comment"})]})}),n("tbody",{children:r.map(i=>c("tr",{children:[n("td",{children:i.index_name}),n("td",{children:i.index_algorithm}),n("td",{children:i.is_unique?"YES":"NO"}),n("td",{children:n(At,{value:i.index_definition})}),n("td",{children:n(At,{value:i.condition})}),n("td",{children:n(At,{value:i.comment})})]},i.index_name))})]})}),tC=T.observer(({dataSource:e})=>{const{indexes:t}=e;return t.loading||t.empty?null:e.type===pe.MySQL?n(H0,{dataSource:e}):e.type===pe.Postgresql?n(eC,{dataSource:e}):null}),nC=T.observer(({dataSource:e})=>c(a.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[n(ke,{children:n(J0,{dataSource:e})}),n(ke,{children:n(tC,{dataSource:e})})]}));function rC({table_type:e}){return e==="VIEW"?n(P.IconEye,{size:14}):e==="BASE TABLE"?n(P.IconTable,{size:14}):null}const iC=T.observer(({dataSource:e})=>{const{tables:t}=e;return t.loading?n(Rs,{height:"24px",lastWidth:"50%",count:15}):n(a.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(t.data).map(([r,i])=>n(a.NavLink,{label:r,icon:n(P.IconDatabase,{size:14}),defaultOpened:e.table_schema===r,pl:0,childrenOffset:14,children:i.map(s=>n(a.NavLink,{label:s.table_name,icon:n(rC,{table_type:s.table_type}),onClick:()=>{e.setKeywords(r,s.table_name)},active:e.table_name===s.table_name},s.table_name))},r))})}),aC=({visible:e})=>n(a.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:n(a.LoadingOverlay,{visible:e})}),sC=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],oC={icon:{width:"50px",textAlign:"center"},input:{"&.mantine-Input-withIcon":{paddingLeft:"50px"}}},lC=T.observer(({dataSource:e})=>{const{tableData:t}=e;return c(a.Group,{pt:10,px:10,position:"apart",children:[c(a.Group,{position:"left",children:[t.maxPage>1&&n(a.Pagination,{size:"sm",page:t.page,onChange:t.setPage,total:t.maxPage,withEdges:t.maxPage>7,styles:{item:{height:"30px"}}}),n(a.Select,{icon:n(a.Text,{ta:"center",color:"dimmed",size:14,children:"Limit"}),size:"xs",styles:oC,data:sC,value:String(t.limit),onChange:r=>t.setLimit(Number(r))})]}),n(a.Group,{position:"right",children:c(a.Text,{color:"dimmed",my:0,size:14,children:["Total ",t.total," rows"]})})]})}),uC=T.observer(({dataSource:e})=>{const t=e.tableData;return t.maxPage===0?n(a.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):t.error?n(a.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:t.error}):t.page===1&&t.loading?n(aC,{visible:!0}):c(ke,{children:[n(lC,{dataSource:e}),c(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n(a.LoadingOverlay,{visible:t.loading,overlayBlur:2}),n(qs,{data:t.data})]})]})}),dC={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},cC=T.observer(({dataSource:e})=>(m.useEffect(()=>{e.loadTablesIfEmpty()},[e]),e.tables.error?n(a.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.tables.error}):c(a.Flex,{sx:{height:"100%"},children:[n(a.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:n(ke,{children:n(iC,{dataSource:e})})}),c(a.Tabs,{defaultValue:"structure",styles:dC,children:[c(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"structure",icon:n(P.IconColumns,{size:14}),children:"Structure"}),n(a.Tabs.Tab,{value:"data",icon:n(P.IconDatabase,{size:14}),children:"Data"})]}),n(a.Tabs.Panel,{value:"structure",children:n(nC,{dataSource:e})}),n(a.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:n(uC,{dataSource:e})})]})]}))),pC={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"0 20px 10px",borderBottom:"1px solid #efefef"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},Qs=T.observer(({dataSource:e,triggerButtonProps:t={}})=>{const[r,i]=m.useState(!1);return e.type==="http"?null:c(V,{children:[n(a.Modal,{opened:r,onClose:()=>i(!1),title:c(a.Group,{position:"apart",sx:{flexGrow:1},children:[n(a.Text,{fw:500,children:"Explorer Data Source"}),c(a.Group,{spacing:7,children:[n(a.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),n(a.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",overflow:"inside",styles:pC,children:n(a.Box,{sx:{height:"calc(100vh - 220px)"},children:n(cC,{dataSource:e})})}),n(a.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:"See Table Structure"})]})}),hC=m.forwardRef(({label:e,type:t,...r},i)=>c(a.Group,{position:"apart",ref:i,...r,children:[n(a.Text,{children:e}),n(a.Text,{children:t})]})),fC=T.observer(({value:e,onChange:t})=>{const r=ce(),{data:i=[],loading:s}=X.useRequest(yn,{refreshDeps:[]},[]),o=m.useMemo(()=>i.map(p=>({label:p.key,value:p.key,type:p.type})),[i]),u=m.useMemo(()=>o.reduce((p,f)=>(p[f.value]=f.type,p),{}),[o]),l=p=>{p!==null&&t({key:p,type:u[p]})},d=m.useMemo(()=>r.datasources.find(e),[r,e]);return n(a.Select,{data:o,label:c(a.Group,{position:"apart",children:[n(a.Box,{children:"Data Source"}),d&&n(Qs,{dataSource:d,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:hC,rightSection:d?n(a.Text,{size:"xs",color:"dimmed",children:d.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:s,value:e.key,onChange:l})}),gC=e=>{const{queryModel:t}=e,r=ce(),i=Y(),o=i.findQueryUsage(t.id).length>0,u=Le.useModals(),l=()=>{u.openConfirmModal({title:"Delete this query?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.queries.removeQuery(t.id),r.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return o?n(a.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:n(a.Button,{color:"gray",size:"xs",leftIcon:n(P.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})}):n(a.Button,{color:"red",size:"xs",onClick:l,leftIcon:n(P.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})},mC=T.observer(gC),bC=T.observer(({queryModel:e})=>n(a.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:c(a.Stack,{spacing:10,sx:{width:"100%"},children:[n(a.Divider,{mb:-10,variant:"dashed",label:"Basics",labelPosition:"center"}),n(a.TextInput,{placeholder:"A unique name",label:"Name",required:!0,sx:{flex:1},value:e.name,onChange:t=>{e.setName(t.currentTarget.value)}}),n(fC,{value:{type:e.type,key:e.key},onChange:({type:t,key:r})=>{e.setKey(r),e.setType(t)}}),n(a.Divider,{mt:10,mb:-10,variant:"dashed",label:"Conditions",labelPosition:"center"}),n(a.MultiSelect,{label:"Run query when these are truthy",placeholder:"Always run this query on load",data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy}),e.typedAsHTTP&&n(a.MultiSelect,{label:"Re-run query when these changed",placeholder:"Leave it empty to never re-run this query",data:e.conditionOptions,value:[...e.react_to],onChange:e.setReactTo}),n(a.Divider,{mt:20,mb:10,variant:"dashed"}),n(mC,{queryModel:e})]})}));function yC(){const[e,{open:t,close:r}]=ve.useDisclosure(!1);return c(V,{children:[n(a.Modal,{opened:e,onClose:r,title:"About FunctionUtils",zIndex:320,children:n(en,{value:Do,styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),n(a.Button,{variant:"light",color:"violet",size:"xs",onClick:t,leftIcon:n(P.IconInfoCircle,{size:16}),children:"About parameter 'utils'"})]})}const vC=({value:e,onChange:t})=>{const r=i=>{i&&t(i)};return n(a.Box,{sx:{position:"relative",flexGrow:1},children:n(_e,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}}})})},dn=m.forwardRef(({value:e,onChange:t,label:r,defaultValue:i},s)=>{const[o,u]=m.useState(e),l=()=>{t(o)},d=()=>{u(e)},p=()=>{u(i)};m.useEffect(()=>{u(e)},[e]);const f=o!==e;return c(a.Stack,{spacing:4,sx:{height:"100%"},children:[c(a.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[n(a.Group,{position:"left",children:n(yC,{})}),c(a.Group,{position:"right",children:[n(a.Button,{onClick:p,size:"xs",variant:"default",leftIcon:n(P.IconPlayerSkipBack,{size:16}),children:"Reset to default"}),n(a.Button,{onClick:d,color:"red",size:"xs",disabled:!f,leftIcon:n(P.IconRecycle,{size:16}),children:"Revert Changes"}),n(a.Button,{size:"xs",onClick:l,disabled:!f,leftIcon:n(P.IconDeviceFloppy,{size:16}),children:"Confirm Changes"})]})]}),n(a.Text,{size:14,children:r}),n(vC,{value:o,onChange:u})]})});function xC({content:e}){return c(a.HoverCard,{width:"60vw",shadow:"md",children:[n(a.HoverCard.Target,{children:n(a.ActionIcon,{size:16,color:"blue",children:n(P.IconEye,{})})}),n(a.HoverCard.Dropdown,{children:n(it.Prism,{language:"sql",noCopy:!0,withLineNumbers:!0,children:e})})]})}const CC=T.observer(()=>{const t=[...ce().globalSQLSnippets.list];return t.length===0?null:c(a.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fontSize:"sm",highlightOnHover:!0,children:[n("thead",{children:c("tr",{children:[n("th",{children:"Key"}),n("th",{children:"Value"})]})}),n("tbody",{children:t.map(r=>{const{id:i,content:s}=r;return c("tr",{children:[n("td",{children:i}),n("td",{width:200,children:n(xC,{content:s})})]},i)})})]})}),wC=`
486
486
  -- You may reference query variables in SQL or VizConfig.
487
487
  SELECT *
488
488
  FROM commit
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- export declare const GlobalSQLSnippetsTable: (() => JSX.Element) & {
2
+ export declare const GlobalSQLSnippetsTable: (() => JSX.Element | null) & {
3
3
  displayName: string;
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtable/dashboard",
3
- "version": "9.16.0",
3
+ "version": "9.16.1",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public",