@devtable/dashboard 8.59.6 → 8.60.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.
@@ -1915,7 +1915,7 @@ const fu = (e) => {
1915
1915
  getColor: gr(["#fff7f1", "darkorange", "#b60000"]),
1916
1916
  name: "orange",
1917
1917
  category: "sequential"
1918
- }, _s = "@devtable/dashboard", Bi = "8.59.6", Cs = "Apache-2.0", Ss = {
1918
+ }, _s = "@devtable/dashboard", Bi = "8.60.1", Cs = "Apache-2.0", Ss = {
1919
1919
  access: "public",
1920
1920
  registry: "https://registry.npmjs.org/"
1921
1921
  }, ks = [
@@ -1940,7 +1940,7 @@ const fu = (e) => {
1940
1940
  "@monaco-editor/react": "4.4.6",
1941
1941
  "@types/chroma-js": "^2.1.4",
1942
1942
  "file-saver": "2.0.5",
1943
- mathjs: "11.7.0",
1943
+ mathjs: "11.8.0",
1944
1944
  "monaco-editor": "0.36.0",
1945
1945
  "performant-array-to-tree": "1.11.0",
1946
1946
  popmotion: "^11.0.3",
@@ -1988,7 +1988,7 @@ const fu = (e) => {
1988
1988
  "@types/react-dom": "^18.0.0",
1989
1989
  "@types/react-grid-layout": "^1.3.2",
1990
1990
  ahooks: "^3.3.11",
1991
- ajv: "8.11.0",
1991
+ ajv: "8.12.0",
1992
1992
  axios: "^0.27.2",
1993
1993
  "crypto-js": "^4.1.1",
1994
1994
  cypress: "^12.9.0",
@@ -2047,7 +2047,7 @@ const fu = (e) => {
2047
2047
  "chroma-js": "^2.4.2",
2048
2048
  "crypto-js": "^4.1.1",
2049
2049
  "d3-array": "3.2.3",
2050
- "d3-regression": "1.2.8",
2050
+ "d3-regression": "1.3.10",
2051
2051
  dayjs: "1.11.7",
2052
2052
  echarts: "^5.3.2",
2053
2053
  "echarts-for-react": "^3.0.2",
@@ -19005,7 +19005,16 @@ const p_ = D(() => {
19005
19005
  if (e === "")
19006
19006
  return null;
19007
19007
  const i = r.filters.findByID(e);
19008
- return i ? /* @__PURE__ */ u(S, { sx: {
19008
+ if (!i)
19009
+ return /* @__PURE__ */ u(C, { size: 14, children: [
19010
+ "Filter by ID[",
19011
+ e,
19012
+ "] is not found"
19013
+ ] });
19014
+ const a = () => {
19015
+ r.editor.setPath(["_FILTERS_", ""]);
19016
+ };
19017
+ return /* @__PURE__ */ u(S, { sx: {
19009
19018
  maxWidth: "1100px",
19010
19019
  height: "100vh"
19011
19020
  }, spacing: "sm", pb: 30, children: [
@@ -19017,7 +19026,9 @@ const p_ = D(() => {
19017
19026
  cancel: "Cancel"
19018
19027
  },
19019
19028
  onCancel: () => console.log("Cancel"),
19020
- onConfirm: () => r.filters.removeByID(e),
19029
+ onConfirm: () => {
19030
+ r.filters.removeByID(e), a();
19031
+ },
19021
19032
  zIndex: 320
19022
19033
  });
19023
19034
  }, children: "Delete this filter" }) }),
@@ -19026,10 +19037,6 @@ const p_ = D(() => {
19026
19037
  maxHeight: "calc(100% - 52px)",
19027
19038
  overflow: "auto"
19028
19039
  }, children: /* @__PURE__ */ n(I_, { filter: i }) })
19029
- ] }) : /* @__PURE__ */ u(C, { size: 14, children: [
19030
- "Filter by ID[",
19031
- e,
19032
- "] is not found"
19033
19040
  ] });
19034
19041
  }), z_ = D(() => {
19035
19042
  const e = G(), [t, r] = ee(() => JSON.stringify(e.mock_context.current, null, 4)), i = () => {
@@ -20581,13 +20588,22 @@ WHERE
20581
20588
  id: e
20582
20589
  }) => {
20583
20590
  const t = G(), r = I(() => t.sqlSnippets.findByKey(e), [e]);
20584
- return r ? /* @__PURE__ */ n(FC, { item: r, remove: () => t.sqlSnippets.removeByKey(e), onKeyChanged: (o) => {
20585
- t.editor.setPath(["_SQL_SNIPPETS_", o]);
20586
- } }) : /* @__PURE__ */ u(C, { size: 14, children: [
20587
- "SQL Snippet by key[",
20588
- e,
20589
- "] is not found"
20590
- ] });
20591
+ if (!e)
20592
+ return null;
20593
+ if (!r)
20594
+ return /* @__PURE__ */ u(C, { size: 14, children: [
20595
+ "SQL Snippet by key[",
20596
+ e,
20597
+ "] is not found"
20598
+ ] });
20599
+ const i = () => {
20600
+ t.editor.setPath(["_SQL_SNIPPETS_", ""]);
20601
+ };
20602
+ return /* @__PURE__ */ n(FC, { item: r, remove: () => {
20603
+ t.sqlSnippets.removeByKey(e), i();
20604
+ }, onKeyChanged: (l) => {
20605
+ t.editor.setPath(["_SQL_SNIPPETS_", l]);
20606
+ } });
20591
20607
  }), BC = D(({
20592
20608
  view: e
20593
20609
  }) => !e || e.type !== ae.Division ? null : /* @__PURE__ */ u(S, { children: [
@@ -20731,8 +20747,20 @@ WHERE
20731
20747
  ] }) : null), ZC = D(({
20732
20748
  id: e
20733
20749
  }) => {
20734
- const t = At(), r = G(), i = r.views.findByID(e);
20735
- return i ? /* @__PURE__ */ u(S, { sx: {
20750
+ const t = At(), r = G();
20751
+ if (e === "")
20752
+ return null;
20753
+ const i = r.views.findByID(e);
20754
+ if (!i)
20755
+ return /* @__PURE__ */ u(C, { size: 14, children: [
20756
+ "View by ID[",
20757
+ e,
20758
+ "] is not found"
20759
+ ] });
20760
+ const a = () => {
20761
+ r.editor.setPath(["_VIEWS_", ""]);
20762
+ };
20763
+ return /* @__PURE__ */ u(S, { sx: {
20736
20764
  maxWidth: "600px",
20737
20765
  height: "100%"
20738
20766
  }, spacing: "sm", children: [
@@ -20744,7 +20772,9 @@ WHERE
20744
20772
  cancel: "Cancel"
20745
20773
  },
20746
20774
  onCancel: () => console.log("Cancel"),
20747
- onConfirm: () => r.views.removeByID(e),
20775
+ onConfirm: () => {
20776
+ r.views.removeByID(e), a();
20777
+ },
20748
20778
  zIndex: 320
20749
20779
  });
20750
20780
  }, children: "Delete this view" }) }),
@@ -20753,10 +20783,6 @@ WHERE
20753
20783
  maxHeight: "calc(100% - 52px)",
20754
20784
  overflow: "auto"
20755
20785
  }, children: /* @__PURE__ */ n(XC, { view: i }) })
20756
- ] }) : /* @__PURE__ */ u(C, { size: 14, children: [
20757
- "View by ID[",
20758
- e,
20759
- "] is not found"
20760
20786
  ] });
20761
20787
  });
20762
20788
  function KC(e) {
@@ -24,7 +24,7 @@ Check the render method of \``+_+"`."}return""}}function J0(_){{if(_!==void 0){v
24
24
 
25
25
  Check your code at `+I+":"+E+"."}return""}}var Fs={};function H0(_){{var I=qs();if(!I){var E=typeof _=="string"?_:_.displayName||_.name;E&&(I=`
26
26
 
27
- Check the top-level render call using <`+E+">.")}return I}}function Ws(_,I){{if(!_._store||_._store.validated||_.key!=null)return;_._store.validated=!0;var E=H0(I);if(Fs[E])return;Fs[E]=!0;var R="";_&&_._owner&&_._owner!==ni.current&&(R=" It was passed a child from "+se(_._owner.type)+"."),gt(_),z('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',E,R),gt(null)}}function js(_,I){{if(typeof _!="object")return;if(ei(_))for(var E=0;E<_.length;E++){var R=_[E];ii(R)&&Ws(R,I)}else if(ii(_))_._store&&(_._store.validated=!0);else if(_){var ie=S(_);if(typeof ie=="function"&&ie!==_.entries)for(var le=ie.call(_),ee;!(ee=le.next()).done;)ii(ee.value)&&Ws(ee.value,I)}}}function ew(_){{var I=_.type;if(I==null||typeof I=="string")return;var E;if(typeof I=="function")E=I.propTypes;else if(typeof I=="object"&&(I.$$typeof===d||I.$$typeof===g))E=I.propTypes;else return;if(E){var R=se(I);G0(E,_.props,"prop",R,_)}else if(I.PropTypes!==void 0&&!ri){ri=!0;var ie=se(I);z("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ie||"Unknown")}typeof I.getDefaultProps=="function"&&!I.getDefaultProps.isReactClassApproved&&z("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function tw(_){{for(var I=Object.keys(_.props),E=0;E<I.length;E++){var R=I[E];if(R!=="children"&&R!=="key"){gt(_),z("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",R),gt(null);break}}_.ref!==null&&(gt(_),z("Invalid attribute `ref` supplied to `React.Fragment`."),gt(null))}}function Rs(_,I,E,R,ie,le){{var ee=Y(_);if(!ee){var J="";(_===void 0||typeof _=="object"&&_!==null&&Object.keys(_).length===0)&&(J+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Te=J0(ie);Te?J+=Te:J+=qs();var fe;_===null?fe="null":ei(_)?fe="array":_!==void 0&&_.$$typeof===t?(fe="<"+(se(_.type)||"Unknown")+" />",J=" Did you accidentally export a JSX literal instead of a component?"):fe=typeof _,z("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",fe,J)}var be=K0(_,I,E,ie,le);if(be==null)return be;if(ee){var $e=I.children;if($e!==void 0)if(R)if(ei($e)){for(var mt=0;mt<$e.length;mt++)js($e[mt],_);Object.freeze&&Object.freeze($e)}else z("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else js($e,_)}return _===i?tw(be):ew(be),be}}function nw(_,I,E){return Rs(_,I,E,!0)}function rw(_,I,E){return Rs(_,I,E,!1)}var iw=rw,aw=nw;xt.Fragment=i,xt.jsx=iw,xt.jsxs=aw}()),xt}(function(e){process.env.NODE_ENV==="production"?e.exports=io():e.exports=ao()})(ro);const O=vt.Fragment,n=vt.jsx,p=vt.jsxs;function Si(e,t){m.useEffect(()=>{const r=i=>{console.log(i);const{viewID:s}=i.detail;if(!s){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(s),t&&e.views.setIDOfVIE(s)};return window.addEventListener("open-view",r),()=>{window.removeEventListener("open-view",r)}},[e,t]),m.useEffect(()=>{const r=i=>{console.log(i);const{dictionary:s,payload:o}=i.detail;if(!o||Object.keys(o).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}Object.entries(s).forEach(([u,l])=>{e.filters.setValueByKey(u,y.get(o,l))})};return window.addEventListener("set-filter-values",r),()=>{window.removeEventListener("set-filter-values",r)}},[e]),m.useEffect(()=>{function r(s){return Array.isArray(s)?[]:typeof s=="object"?{}:typeof s=="boolean"?!1:typeof s=="string"?"":typeof s=="number"?0:s}const i=s=>{console.log(s);const{filter_keys:o}=s.detail;o.forEach(u=>{const l=y.get(e.filters.values,u),d=r(l);console.log(`${u}: ${d}`),e.filters.setValueByKey(u,d)})};return window.addEventListener("clear-filter-values",i),()=>{window.removeEventListener("clear-filter-values",i)}},[e]),m.useEffect(()=>{const r=i=>{console.log(i);const{urlTemplate:s,openInNewTab:o,enableEncoding:u=!1,payload:l}=i.detail;if(!s){console.error(new Error("[Open Link] URL is empty"));return}function d(g){return y.cloneDeepWith(g,b=>{if(u&&typeof b=="string")return encodeURIComponent(b)})}const f=y.template(s||"")(d({...l,filters:e.filters.values,context:e.context.current}));window.open(f,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",r),()=>{window.removeEventListener("open-link",r)}},[e])}class so{constructor(t){P(this,"symbol");this.symbol=Symbol(t)}}function We(e){return new so(e)}class hn{constructor(){P(this,"parent");P(this,"factoryRegistry",new Map);P(this,"instanceRegistry",new Map)}createScoped(){const t=new hn;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=y.get(t,"dispose");y.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const fn=m.createContext(null);function Bt(e){const t=m.useContext(fn),r=Z.useCreation(()=>e.configure(t||new hn),[e.configure]),i=Z.usePrevious(r);return i&&i!==r&&i.dispose(),n(fn.Provider,{value:r,children:e.children})}function Ti(){return m.useContext(fn)}const oo={viewPanelInFullScreen:y.noop,inFullScreen:!1},gn=m.createContext(oo),Di=m.createContext(null),mn=Di.Provider;function B(){const e=m.useContext(Di);if(!e)throw new Error("Please use ModelContextProvider");return e}class Ae 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 p(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 bn={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"}},Nt=({value:e,styles:t={}})=>{const r=bi.useEditor({extensions:[vi,mi,X.Link,ui,li,si,pi.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),gi,fi,hi,di.configure({types:["heading","paragraph"]}),oi.configure({placeholder:"This is placeholder"}),ci,ai.Color],content:e,editable:!1});m.useEffect(()=>{r==null||r.commands.setContent(e)},[e,r]);const i=m.useMemo(()=>y.defaultsDeep({},{content:bn},t),[t]);return n(X.RichTextEditor,{editor:r,styles:i,children:n(X.RichTextEditor.Content,{})})},lo=({description:e,isDescriptionEmpty:t})=>t?null:n(a.Tooltip,{color:"white",label:n(Nt,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:n(a.Box,{sx:{height:"16px",alignSelf:"center"},children:n(V.IconInfoCircle,{size:16,color:"gray"})})}),uo=T.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:i,...s},value:o,onChange:u})=>p(a.Box,{children:[n(a.Text,{children:" "}),n(a.Checkbox,{label:p(a.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[n(a.Box,{sx:{flexGrow:1},children:e}),n(lo,{description:r,isDescriptionEmpty:i})]}),checked:o||!1,onChange:l=>u(l.currentTarget.checked),...s,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),ki=T.observer(({label:e,config:t,value:r=[null,null],onChange:i})=>{const s=Array.isArray(r)?r.map(d=>d?W(d).toDate():null):[null,null],o=d=>{i(d.map(c=>c&&W(c).format(t.inputFormat)))},u=t.getMinDate(s[0]),l=t.getMaxDate(s[0]);return n(Qs.DateRangePicker,{label:e,value:s,onChange:o,icon:n(D.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:u,maxDate:l,styles:{input:{borderColor:"#e9ecef"}},...t})}),co={layoutFrozen:!1,freezeLayout:y.noop,inEditMode:!1},Xe=m.createContext(co),Ii=m.createContext({panel:null,data:[],loading:!1}),vn=Ii.Provider;function xe(){const e=m.useContext(Ii);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const po={fullScreenPanelID:"",setFullScreenPanelID:y.noop},yn=m.createContext(po);function Mi(){const e=m.useContext(yn);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const Ai=m.forwardRef(({label:e,description:t,...r},i)=>n("div",{ref:i,...r,children:n(a.Group,{noWrap:!0,children:p("div",{children:[n(a.Text,{size:"sm","data-role":"label",children:e}),n(a.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),ho=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading",d=t.min_width?t.min_width:"200px",c=o?l:!1;return n(a.MultiSelect,{label:e,data:t.options,disabled:c,value:r,onChange:i,styles:{root:{minWidth:d,maxWidth:c?d:"unset"},input:{borderColor:"#e9ecef"}},itemComponent:Ai})}),fo=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading";return m.useEffect(()=>{var f;const{default_selection_count:d}=t;if(!d)return;const c=((f=t.options[0])==null?void 0:f.value)??"";console.log("Selecting the first option by default. New value: ",c),i(c,!0)},[t.default_selection_count,t.options]),n(a.Select,{label:e,data:t.options,disabled:o?l:!1,value:r,onChange:i,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"}},itemComponent:Ai})});function go({label:e,config:t,value:r,onChange:i}){return n(a.TextInput,{label:e,value:r||"",onChange:s=>i(s.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}function mo(e){return Us.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}const bo=({rotate:e,onClick:t})=>n("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:n("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),vo=({expanded:e,isLeaf:t,value:r,onClick:i,...s})=>(r==="0-0-value"&&console.log(s),t?n("span",{style:{width:"14px",display:"inline-block"}}):n(bo,{rotate:e?"0":"-90",onClick:i,...s})),yo=({onClick:e})=>p("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[n("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),n("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),n("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),n("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),xo=({onClick:e,...t})=>n(yo,{onClick:e,...t}),Co=a.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),wo=({disabled:e,classNames:t,styles:r,unstyled:i,radius:s,style:o,label:u,value:l,onChange:d,treeData:c})=>{const{classes:f,cx:g}=Co({radius:s},{name:"FilterTreeSelectWidget",classNames:t,styles:r,unstyled:i}),[h,b]=m.useState((l==null?void 0:l.length)>0),w=S=>{b(S)},C=h&&(l==null?void 0:l.length)>0;return p(a.Stack,{spacing:3,children:[p(a.Group,{position:"apart",children:[n(a.Text,{className:f.label,children:u}),C&&n(a.Tooltip,{label:`${l.length} selected`,children:n(a.Badge,{children:l.length})})]}),n(yi,{disabled:e,allowClear:!0,className:g(f.root,"check-select"),dropdownClassName:g(f.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>n(a.CloseButton,{}),switcherIcon:vo,treeIcon:xo,maxTagTextLength:10,value:l,treeData:c,treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:yi.SHOW_PARENT,onChange:d,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:S=>`${S.length} selected`})]})};function _o(e){return e.map(t=>{const{label:r,description:i,...s}=t,o={...s,filterBasis:`${r}___${i??""}`,description:i,label:r};return i&&(o.label=p("div",{children:[n(a.Text,{title:t.label,children:t.label}),n(a.Text,{className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description,children:t.description})]})),o})}const So=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),{state:o,dataProxy:u,len:l}=s.getDataStuffByID(t.options_query_id),d=o==="loading",c=m.useMemo(()=>{if(!u)return[];const b=[...u],w=_o(b);return mo(w)},[u,l]);m.useEffect(()=>{const{default_selection_count:b}=t;if(!b)return;if(c.length===0){console.log("[filter.tree-select] Resetting to empty"),i([],!0);return}const w=c.slice(0,b).map(C=>C.value);console.log(`[filter.tree-select] Selecting first ${b} option(s)`),i(w,!0)},[t.default_selection_count,c]);const f=t.min_width?t.min_width:"200px",h=!!t.options_query_id?d:!1;return n(wo,{disabled:h,style:{minWidth:f,maxWidth:h?f:"unset",borderColor:"#e9ecef"},value:r,onChange:b=>i(b,!1),treeData:c,label:e})}),To=T.observer(({filter:{type:e,config:t,key:r,...i},formFieldProps:s})=>{switch(e){case"select":return n(fo,{...i,...s,config:t});case"multi-select":return n(ho,{...i,...s,config:t});case"tree-select":return n(So,{...i,...s,config:t});case"text-input":return n(go,{...i,...s,config:t});case"date-range":return n(ki,{...i,...s,config:t});case"checkbox":return n(uo,{...i,...s,config:t});default:return null}}),zi=T.observer(m.forwardRef(({filter:e,...t},r)=>n("div",{className:"filter-root",ref:r,children:n(Ae,{children:n(To,{filter:e,formFieldProps:t})})}))),$i=T.observer(function({view:t}){const r=B(),{control:i,handleSubmit:s,reset:o}=x.useForm({defaultValues:r.filters.values,reValidateMode:"onBlur"}),u=x.useWatch({control:i});m.useEffect(()=>{o(r.filters.values)},[r.filters.values,o]),m.useEffect(()=>{r.filters.updatePreviewValues(u)},[u]);const l=r.filters.visibleInView(t.id),d=m.useMemo(()=>l.every(h=>h.should_auto_submit),[l]),c=m.useMemo(()=>l.filter(h=>y.get(h,"config.required",!1)),[l]),f=m.useMemo(()=>c.length===0?!1:c.some(h=>!h.requiredAndPass(u[h.key])),[u,c]);if(l.length===0)return null;const g=(h,b)=>(w,C)=>{b(w),(h.should_auto_submit||C)&&r.filters.setValueByKey(h.key,w)};return n("form",{onSubmit:s(r.filters.setValues),children:p(a.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:d?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n(a.Group,{align:"flex-start",children:l.map(h=>n(x.Controller,{name:h.key,control:i,render:({field:b})=>n(zi,{filter:h,value:b.value,onChange:g(h,b.onChange)})},h.id))}),!d&&n(a.Group,{sx:{alignSelf:"flex-end"},children:n(a.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),uw="";function Do(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const Ei=T.observer(()=>{const{freezeLayout:e}=m.useContext(Xe),[t,r]=m.useState(!1),{panel:i}=xe();return m.useEffect(()=>{e(t)},[t]),Do(i.description)?null:p(O,{children:[n(a.Modal,{opened:t,onClose:()=>r(!1),title:i.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:n(Nt,{value:i.description,styles:{root:{border:"none"},content:{padding:0}}})}),n(a.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(s=>!s),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n(D.InfoCircle,{size:20})})})]})}),ko=T.observer(({view:e})=>{const t=B(),r=Pe.useModals(),{panel:i}=xe(),{id:s,query:o}=i,{inEditMode:u}=m.useContext(Xe),l=()=>o==null?void 0:o.fetchData(),{viewPanelInFullScreen:d,inFullScreen:c}=m.useContext(gn),f=()=>{t.duplicatePanelByID(s,e.id)},g=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",s])},h=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>t.removePanelByID(s,e.id),confirmProps:{color:"red"},zIndex:320}),b=m.useCallback(()=>{d(s)},[s,d]),w=!c&&e.type!==K.Modal;return n(O,{children:n(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(a.Menu,{withinPortal:!0,children:[n(a.Menu.Target,{children:n(a.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),p(a.Menu.Dropdown,{children:[n(a.Menu.Item,{onClick:l,icon:n(D.Refresh,{size:14}),children:"Refresh"}),n(a.Menu.Item,{onClick:()=>t.queries.downloadDataByQueryID((o==null?void 0:o.id)??""),icon:n(D.Download,{size:14}),children:"Download Data"}),w&&n(a.Menu.Item,{onClick:b,icon:n(D.ArrowsMaximize,{size:14}),disabled:u,children:"Full Screen"}),u&&p(O,{children:[n(a.Divider,{label:"Edit",labelPosition:"center"}),n(a.Menu.Item,{onClick:g,icon:n(D.Settings,{size:14}),children:"Settings"}),n(a.Menu.Item,{onClick:f,icon:n(D.Copy,{size:14}),children:"Duplicate"}),n(a.Menu.Item,{color:"red",onClick:h,icon:n(D.Trash,{size:14}),children:"Delete"})]})]})]})})})}),dw="",Io=T.observer(function(){const{panel:t}=xe(),{title:r}=t;return r?n(a.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:n(a.Text,{align:"center",lineClamp:1,weight:"bold",children:r})}):null}),Oe=(e,t)=>{const[r,i]=m.useState([]);return m.useEffect(()=>e.watchTriggerSnapshotList(s=>i(s.filter(o=>o.schemaRef===t))),[]),r};class st{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,y.omit(r,t))}async getItem(t){const r=await this.root.getItem(this.path);return t===null?r:y.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=y.get(s,t),l=y.get(o,t);u!==l&&r(u,l)},i)}}class xn{constructor(t,r,i){P(this,"attachmentStorage");this.instance=t,this.attachmentKey=r,this.constructInstance=i,this.attachmentStorage=new st(t.instanceData,r)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new st(this.attachmentStorage,t))}async create(t,r){return await this.attachmentStorage.setItem(t,r),this.constructInstance(new st(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(y.values(t).map(r=>this.constructInstance(new st(this.attachmentStorage,r.id))))}}class Li{constructor(t){P(this,"rootRef");this.rootRef=ae.observable({current:t})}async deleteItem(t){ae.runInAction(()=>{y.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?ae.toJS(this.rootRef.current):y.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(y.isObject(r))ae.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else ae.runInAction(()=>{y.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,i){return ae.reaction(()=>this.getValueFromRoot(t),(s,o)=>{r(s,o)},{requiresObservable:!0,fireImmediately:y.get(i,"fireImmediately",!1)})}}class Mo{constructor(){P(this,"channels",new Map);P(this,"globalChannel",new xi)}getChannel(t){const r=this.channels.get(t);if(r)return r;const i=new xi;return this.channels.set(t,i),i}}class Ao{constructor(t){P(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 Mo,instanceData:new Li(t.viz.conf)};return this.instances.set(t.id,i),i}}function Pi(e,t,r,i){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new Li({}),colorPalette:{getColor(){return()=>""}},data:t,variables:i}}const zo=e=>{const{panel:t,vizManager:r,data:i,variables:s}=e,o=r.resolveComponent(t.viz.type),u=r.getOrCreateInstance(t),l={...Pi(u,i,r,s),viewport:{width:t.layout.w,height:t.layout.h}},d=o.viewRender;return n(d,{context:l,instance:u,...y.omit(e,["panel","vizManager","data"])})},$o=e=>{const{vizManager:t,panel:r,panelInfoEditor:i,data:s,variables:o}=e,u=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),d={...Pi(l,s,t,o),panelInfoEditor:i},c=u.configRender;return n(c,{context:d,instance:l,...y.omit(e,["panel","vizManager","data","panelInfoEditor"])})},Oi=(e,t)=>{const r=Fe.bezier(e),i=Fe.bezier(t);return function(s){return s<50?r(s*2/100).hex():i((s-50)*2/100).hex()}},Gt=e=>{const t=Fe.bezier(e);return function(r){return t(r/100).hex()}},Eo={type:"interpolation",displayName:"Red / Green",getColor:Oi(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Lo={type:"interpolation",displayName:"Yellow / Blue",getColor:Oi(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Po={type:"interpolation",displayName:"Red",getColor:Gt(["#fff7f1","darkred"]),name:"red",category:"sequential"},Oo={type:"interpolation",displayName:"Green",getColor:Gt(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Vo={type:"interpolation",displayName:"Blue",getColor:Gt(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Bo={type:"interpolation",displayName:"Orange",getColor:Gt(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},Vi="@devtable/dashboard",Cn="8.59.6",Bi="Apache-2.0",Ni={access:"public",registry:"https://registry.npmjs.org/"},Gi=["dist"],qi="./dist/dashboard.umd.js",Fi="./dist/dashboard.es.js",Wi="./dist/index.d.ts",ji={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Ri={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},Yi={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5",mathjs:"11.7.0","monaco-editor":"0.36.0","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},Qi={"@emotion/babel-plugin":"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.118.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.11.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.6.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3","vite-plugin-static-copy":"0.13.1"},Ui={"@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.118.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.2.8",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"},No=Object.freeze(Object.defineProperty({__proto__:null,default:{name:Vi,version:Cn,license:Bi,publishConfig:Ni,files:Gi,main:qi,module:Fi,types:Wi,exports:ji,scripts:Ri,dependencies:Yi,devDependencies:Qi,peerDependencies:Ui},dependencies:Yi,devDependencies:Qi,exports:ji,files:Gi,license:Bi,main:qi,module:Fi,name:Vi,peerDependencies:Ui,publishConfig:Ni,scripts:Ri,types:Wi,version:Cn},Symbol.toStringTag,{value:"Module"}));class Go{constructor(t){P(this,"staticColors",new Map);P(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 qo{constructor(){P(this,"plugins",new Map);P(this,"vizComponents",new Map);P(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class Fo{constructor(){P(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=y.orderBy(s,"version","asc");if(((u=y.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 ge extends Fo{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=y.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 y.get(r,"version",0)<this.VERSION}}const j=(e,t)=>{const[r,{setFalse:i}]=Z.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}},wn={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"}};oe.use([q.GridComponent,q.VisualMapComponent,q.LegendComponent,q.TooltipComponent,Ie.CanvasRenderer]);function Wo({context:e}){const{value:t}=j(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:c,zAxis3D:f}=y.defaults({},t,wn),g=m.useMemo(()=>{const w=y.minBy(r,C=>C[l]);return y.get(w,l)},[r,l]),h=m.useMemo(()=>{const w=y.maxBy(r,C=>C[l]);return y.get(w,l)},[r,l]),b={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:c,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:r.map(w=>[w[o],w[u],w[l]])}]};return t?n(Me,{echarts:oe,option:b,style:{width:i,height:s},notMerge:!0,theme:"merico-light"}):null}function jo({label:e,required:t,value:r,onChange:i,data:s,clearable:o=!1,sx:u,...l},d){const c=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:c,value:r,onChange:i,required:t,sx:u,...l})}const U=m.forwardRef(jo);function Ro({context:e}){const{value:t,set:r}=j(e.instanceData,"config"),i=e.data,s=y.defaults({},t,wn),{control:o,handleSubmit:u,reset:l}=x.useForm({defaultValues:s});return m.useEffect(()=>{l(s)},[t]),t?n(a.Stack,{spacing:"xs",children:p("form",{onSubmit:u(r),children:[n(a.Text,{children:"X Axis"}),p(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(U,{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"}),p(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(U,{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"}),p(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(U,{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:p(a.Button,{color:"blue",type:"submit",children:[n(D.DeviceFloppy,{size:20}),n(a.Text,{ml:"md",children:"Save"})]})})]})}):null}class Yo extends ge{constructor(){super(...arguments);P(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const Qo={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new Yo,name:"bar-3d",viewRender:Wo,configRender:Ro,createConfig(){return{version:1,config:y.cloneDeep(wn)}}},De={mantissa:0,output:"number",trimMantissa:!1,average:!1};function Uo({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 p(a.Stack,{ref:r,children:[p(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:p(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"}}})]}),p(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"}}})]}),p(a.Stack,{spacing:0,children:[n(a.Text,{weight:"bold",children:"Preview"}),n(Ae,{children:p(a.Group,{position:"apart",children:[p(a.Text,{size:12,color:"gray",children:["123456789 ",n(D.ArrowRight,{size:9})," ",ue(123456789).format(e)]}),p(a.Text,{size:12,color:"gray",children:["1234 ",n(D.ArrowRight,{size:9})," ",ue(1234).format(e)]}),p(a.Text,{size:12,color:"gray",children:["0.1234 ",n(D.ArrowRight,{size:9})," ",ue(.1234).format(e)]})]})})]})]})}const Ve=m.forwardRef(Uo),Be={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
27
+ Check the top-level render call using <`+E+">.")}return I}}function Ws(_,I){{if(!_._store||_._store.validated||_.key!=null)return;_._store.validated=!0;var E=H0(I);if(Fs[E])return;Fs[E]=!0;var R="";_&&_._owner&&_._owner!==ni.current&&(R=" It was passed a child from "+se(_._owner.type)+"."),gt(_),z('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',E,R),gt(null)}}function js(_,I){{if(typeof _!="object")return;if(ei(_))for(var E=0;E<_.length;E++){var R=_[E];ii(R)&&Ws(R,I)}else if(ii(_))_._store&&(_._store.validated=!0);else if(_){var ie=S(_);if(typeof ie=="function"&&ie!==_.entries)for(var le=ie.call(_),ee;!(ee=le.next()).done;)ii(ee.value)&&Ws(ee.value,I)}}}function ew(_){{var I=_.type;if(I==null||typeof I=="string")return;var E;if(typeof I=="function")E=I.propTypes;else if(typeof I=="object"&&(I.$$typeof===d||I.$$typeof===g))E=I.propTypes;else return;if(E){var R=se(I);G0(E,_.props,"prop",R,_)}else if(I.PropTypes!==void 0&&!ri){ri=!0;var ie=se(I);z("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ie||"Unknown")}typeof I.getDefaultProps=="function"&&!I.getDefaultProps.isReactClassApproved&&z("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function tw(_){{for(var I=Object.keys(_.props),E=0;E<I.length;E++){var R=I[E];if(R!=="children"&&R!=="key"){gt(_),z("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",R),gt(null);break}}_.ref!==null&&(gt(_),z("Invalid attribute `ref` supplied to `React.Fragment`."),gt(null))}}function Rs(_,I,E,R,ie,le){{var ee=Y(_);if(!ee){var J="";(_===void 0||typeof _=="object"&&_!==null&&Object.keys(_).length===0)&&(J+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Te=J0(ie);Te?J+=Te:J+=qs();var fe;_===null?fe="null":ei(_)?fe="array":_!==void 0&&_.$$typeof===t?(fe="<"+(se(_.type)||"Unknown")+" />",J=" Did you accidentally export a JSX literal instead of a component?"):fe=typeof _,z("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",fe,J)}var be=K0(_,I,E,ie,le);if(be==null)return be;if(ee){var $e=I.children;if($e!==void 0)if(R)if(ei($e)){for(var mt=0;mt<$e.length;mt++)js($e[mt],_);Object.freeze&&Object.freeze($e)}else z("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else js($e,_)}return _===i?tw(be):ew(be),be}}function nw(_,I,E){return Rs(_,I,E,!0)}function rw(_,I,E){return Rs(_,I,E,!1)}var iw=rw,aw=nw;xt.Fragment=i,xt.jsx=iw,xt.jsxs=aw}()),xt}(function(e){process.env.NODE_ENV==="production"?e.exports=io():e.exports=ao()})(ro);const O=vt.Fragment,n=vt.jsx,p=vt.jsxs;function Si(e,t){m.useEffect(()=>{const r=i=>{console.log(i);const{viewID:s}=i.detail;if(!s){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(s),t&&e.views.setIDOfVIE(s)};return window.addEventListener("open-view",r),()=>{window.removeEventListener("open-view",r)}},[e,t]),m.useEffect(()=>{const r=i=>{console.log(i);const{dictionary:s,payload:o}=i.detail;if(!o||Object.keys(o).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}Object.entries(s).forEach(([u,l])=>{e.filters.setValueByKey(u,y.get(o,l))})};return window.addEventListener("set-filter-values",r),()=>{window.removeEventListener("set-filter-values",r)}},[e]),m.useEffect(()=>{function r(s){return Array.isArray(s)?[]:typeof s=="object"?{}:typeof s=="boolean"?!1:typeof s=="string"?"":typeof s=="number"?0:s}const i=s=>{console.log(s);const{filter_keys:o}=s.detail;o.forEach(u=>{const l=y.get(e.filters.values,u),d=r(l);console.log(`${u}: ${d}`),e.filters.setValueByKey(u,d)})};return window.addEventListener("clear-filter-values",i),()=>{window.removeEventListener("clear-filter-values",i)}},[e]),m.useEffect(()=>{const r=i=>{console.log(i);const{urlTemplate:s,openInNewTab:o,enableEncoding:u=!1,payload:l}=i.detail;if(!s){console.error(new Error("[Open Link] URL is empty"));return}function d(g){return y.cloneDeepWith(g,b=>{if(u&&typeof b=="string")return encodeURIComponent(b)})}const f=y.template(s||"")(d({...l,filters:e.filters.values,context:e.context.current}));window.open(f,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",r),()=>{window.removeEventListener("open-link",r)}},[e])}class so{constructor(t){P(this,"symbol");this.symbol=Symbol(t)}}function We(e){return new so(e)}class hn{constructor(){P(this,"parent");P(this,"factoryRegistry",new Map);P(this,"instanceRegistry",new Map)}createScoped(){const t=new hn;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=y.get(t,"dispose");y.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const fn=m.createContext(null);function Bt(e){const t=m.useContext(fn),r=Z.useCreation(()=>e.configure(t||new hn),[e.configure]),i=Z.usePrevious(r);return i&&i!==r&&i.dispose(),n(fn.Provider,{value:r,children:e.children})}function Ti(){return m.useContext(fn)}const oo={viewPanelInFullScreen:y.noop,inFullScreen:!1},gn=m.createContext(oo),Di=m.createContext(null),mn=Di.Provider;function B(){const e=m.useContext(Di);if(!e)throw new Error("Please use ModelContextProvider");return e}class Ae 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 p(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 bn={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"}},Nt=({value:e,styles:t={}})=>{const r=bi.useEditor({extensions:[vi,mi,X.Link,ui,li,si,pi.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),gi,fi,hi,di.configure({types:["heading","paragraph"]}),oi.configure({placeholder:"This is placeholder"}),ci,ai.Color],content:e,editable:!1});m.useEffect(()=>{r==null||r.commands.setContent(e)},[e,r]);const i=m.useMemo(()=>y.defaultsDeep({},{content:bn},t),[t]);return n(X.RichTextEditor,{editor:r,styles:i,children:n(X.RichTextEditor.Content,{})})},lo=({description:e,isDescriptionEmpty:t})=>t?null:n(a.Tooltip,{color:"white",label:n(Nt,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:n(a.Box,{sx:{height:"16px",alignSelf:"center"},children:n(V.IconInfoCircle,{size:16,color:"gray"})})}),uo=T.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:i,...s},value:o,onChange:u})=>p(a.Box,{children:[n(a.Text,{children:" "}),n(a.Checkbox,{label:p(a.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[n(a.Box,{sx:{flexGrow:1},children:e}),n(lo,{description:r,isDescriptionEmpty:i})]}),checked:o||!1,onChange:l=>u(l.currentTarget.checked),...s,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),ki=T.observer(({label:e,config:t,value:r=[null,null],onChange:i})=>{const s=Array.isArray(r)?r.map(d=>d?W(d).toDate():null):[null,null],o=d=>{i(d.map(c=>c&&W(c).format(t.inputFormat)))},u=t.getMinDate(s[0]),l=t.getMaxDate(s[0]);return n(Qs.DateRangePicker,{label:e,value:s,onChange:o,icon:n(D.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:u,maxDate:l,styles:{input:{borderColor:"#e9ecef"}},...t})}),co={layoutFrozen:!1,freezeLayout:y.noop,inEditMode:!1},Xe=m.createContext(co),Ii=m.createContext({panel:null,data:[],loading:!1}),vn=Ii.Provider;function xe(){const e=m.useContext(Ii);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const po={fullScreenPanelID:"",setFullScreenPanelID:y.noop},yn=m.createContext(po);function Mi(){const e=m.useContext(yn);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const Ai=m.forwardRef(({label:e,description:t,...r},i)=>n("div",{ref:i,...r,children:n(a.Group,{noWrap:!0,children:p("div",{children:[n(a.Text,{size:"sm","data-role":"label",children:e}),n(a.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),ho=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading",d=t.min_width?t.min_width:"200px",c=o?l:!1;return n(a.MultiSelect,{label:e,data:t.options,disabled:c,value:r,onChange:i,styles:{root:{minWidth:d,maxWidth:c?d:"unset"},input:{borderColor:"#e9ecef"}},itemComponent:Ai})}),fo=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading";return m.useEffect(()=>{var f;const{default_selection_count:d}=t;if(!d)return;const c=((f=t.options[0])==null?void 0:f.value)??"";console.log("Selecting the first option by default. New value: ",c),i(c,!0)},[t.default_selection_count,t.options]),n(a.Select,{label:e,data:t.options,disabled:o?l:!1,value:r,onChange:i,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"}},itemComponent:Ai})});function go({label:e,config:t,value:r,onChange:i}){return n(a.TextInput,{label:e,value:r||"",onChange:s=>i(s.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}function mo(e){return Us.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}const bo=({rotate:e,onClick:t})=>n("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:n("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),vo=({expanded:e,isLeaf:t,value:r,onClick:i,...s})=>(r==="0-0-value"&&console.log(s),t?n("span",{style:{width:"14px",display:"inline-block"}}):n(bo,{rotate:e?"0":"-90",onClick:i,...s})),yo=({onClick:e})=>p("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[n("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),n("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),n("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),n("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),xo=({onClick:e,...t})=>n(yo,{onClick:e,...t}),Co=a.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),wo=({disabled:e,classNames:t,styles:r,unstyled:i,radius:s,style:o,label:u,value:l,onChange:d,treeData:c})=>{const{classes:f,cx:g}=Co({radius:s},{name:"FilterTreeSelectWidget",classNames:t,styles:r,unstyled:i}),[h,b]=m.useState((l==null?void 0:l.length)>0),w=S=>{b(S)},C=h&&(l==null?void 0:l.length)>0;return p(a.Stack,{spacing:3,children:[p(a.Group,{position:"apart",children:[n(a.Text,{className:f.label,children:u}),C&&n(a.Tooltip,{label:`${l.length} selected`,children:n(a.Badge,{children:l.length})})]}),n(yi,{disabled:e,allowClear:!0,className:g(f.root,"check-select"),dropdownClassName:g(f.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>n(a.CloseButton,{}),switcherIcon:vo,treeIcon:xo,maxTagTextLength:10,value:l,treeData:c,treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:yi.SHOW_PARENT,onChange:d,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:S=>`${S.length} selected`})]})};function _o(e){return e.map(t=>{const{label:r,description:i,...s}=t,o={...s,filterBasis:`${r}___${i??""}`,description:i,label:r};return i&&(o.label=p("div",{children:[n(a.Text,{title:t.label,children:t.label}),n(a.Text,{className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description,children:t.description})]})),o})}const So=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=B(),{state:o,dataProxy:u,len:l}=s.getDataStuffByID(t.options_query_id),d=o==="loading",c=m.useMemo(()=>{if(!u)return[];const b=[...u],w=_o(b);return mo(w)},[u,l]);m.useEffect(()=>{const{default_selection_count:b}=t;if(!b)return;if(c.length===0){console.log("[filter.tree-select] Resetting to empty"),i([],!0);return}const w=c.slice(0,b).map(C=>C.value);console.log(`[filter.tree-select] Selecting first ${b} option(s)`),i(w,!0)},[t.default_selection_count,c]);const f=t.min_width?t.min_width:"200px",h=!!t.options_query_id?d:!1;return n(wo,{disabled:h,style:{minWidth:f,maxWidth:h?f:"unset",borderColor:"#e9ecef"},value:r,onChange:b=>i(b,!1),treeData:c,label:e})}),To=T.observer(({filter:{type:e,config:t,key:r,...i},formFieldProps:s})=>{switch(e){case"select":return n(fo,{...i,...s,config:t});case"multi-select":return n(ho,{...i,...s,config:t});case"tree-select":return n(So,{...i,...s,config:t});case"text-input":return n(go,{...i,...s,config:t});case"date-range":return n(ki,{...i,...s,config:t});case"checkbox":return n(uo,{...i,...s,config:t});default:return null}}),zi=T.observer(m.forwardRef(({filter:e,...t},r)=>n("div",{className:"filter-root",ref:r,children:n(Ae,{children:n(To,{filter:e,formFieldProps:t})})}))),$i=T.observer(function({view:t}){const r=B(),{control:i,handleSubmit:s,reset:o}=x.useForm({defaultValues:r.filters.values,reValidateMode:"onBlur"}),u=x.useWatch({control:i});m.useEffect(()=>{o(r.filters.values)},[r.filters.values,o]),m.useEffect(()=>{r.filters.updatePreviewValues(u)},[u]);const l=r.filters.visibleInView(t.id),d=m.useMemo(()=>l.every(h=>h.should_auto_submit),[l]),c=m.useMemo(()=>l.filter(h=>y.get(h,"config.required",!1)),[l]),f=m.useMemo(()=>c.length===0?!1:c.some(h=>!h.requiredAndPass(u[h.key])),[u,c]);if(l.length===0)return null;const g=(h,b)=>(w,C)=>{b(w),(h.should_auto_submit||C)&&r.filters.setValueByKey(h.key,w)};return n("form",{onSubmit:s(r.filters.setValues),children:p(a.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:d?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n(a.Group,{align:"flex-start",children:l.map(h=>n(x.Controller,{name:h.key,control:i,render:({field:b})=>n(zi,{filter:h,value:b.value,onChange:g(h,b.onChange)})},h.id))}),!d&&n(a.Group,{sx:{alignSelf:"flex-end"},children:n(a.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),uw="";function Do(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const Ei=T.observer(()=>{const{freezeLayout:e}=m.useContext(Xe),[t,r]=m.useState(!1),{panel:i}=xe();return m.useEffect(()=>{e(t)},[t]),Do(i.description)?null:p(O,{children:[n(a.Modal,{opened:t,onClose:()=>r(!1),title:i.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:n(Nt,{value:i.description,styles:{root:{border:"none"},content:{padding:0}}})}),n(a.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(s=>!s),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n(D.InfoCircle,{size:20})})})]})}),ko=T.observer(({view:e})=>{const t=B(),r=Pe.useModals(),{panel:i}=xe(),{id:s,query:o}=i,{inEditMode:u}=m.useContext(Xe),l=()=>o==null?void 0:o.fetchData(),{viewPanelInFullScreen:d,inFullScreen:c}=m.useContext(gn),f=()=>{t.duplicatePanelByID(s,e.id)},g=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",s])},h=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>t.removePanelByID(s,e.id),confirmProps:{color:"red"},zIndex:320}),b=m.useCallback(()=>{d(s)},[s,d]),w=!c&&e.type!==K.Modal;return n(O,{children:n(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(a.Menu,{withinPortal:!0,children:[n(a.Menu.Target,{children:n(a.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),p(a.Menu.Dropdown,{children:[n(a.Menu.Item,{onClick:l,icon:n(D.Refresh,{size:14}),children:"Refresh"}),n(a.Menu.Item,{onClick:()=>t.queries.downloadDataByQueryID((o==null?void 0:o.id)??""),icon:n(D.Download,{size:14}),children:"Download Data"}),w&&n(a.Menu.Item,{onClick:b,icon:n(D.ArrowsMaximize,{size:14}),disabled:u,children:"Full Screen"}),u&&p(O,{children:[n(a.Divider,{label:"Edit",labelPosition:"center"}),n(a.Menu.Item,{onClick:g,icon:n(D.Settings,{size:14}),children:"Settings"}),n(a.Menu.Item,{onClick:f,icon:n(D.Copy,{size:14}),children:"Duplicate"}),n(a.Menu.Item,{color:"red",onClick:h,icon:n(D.Trash,{size:14}),children:"Delete"})]})]})]})})})}),dw="",Io=T.observer(function(){const{panel:t}=xe(),{title:r}=t;return r?n(a.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:n(a.Text,{align:"center",lineClamp:1,weight:"bold",children:r})}):null}),Oe=(e,t)=>{const[r,i]=m.useState([]);return m.useEffect(()=>e.watchTriggerSnapshotList(s=>i(s.filter(o=>o.schemaRef===t))),[]),r};class st{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,y.omit(r,t))}async getItem(t){const r=await this.root.getItem(this.path);return t===null?r:y.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=y.get(s,t),l=y.get(o,t);u!==l&&r(u,l)},i)}}class xn{constructor(t,r,i){P(this,"attachmentStorage");this.instance=t,this.attachmentKey=r,this.constructInstance=i,this.attachmentStorage=new st(t.instanceData,r)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new st(this.attachmentStorage,t))}async create(t,r){return await this.attachmentStorage.setItem(t,r),this.constructInstance(new st(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(y.values(t).map(r=>this.constructInstance(new st(this.attachmentStorage,r.id))))}}class Li{constructor(t){P(this,"rootRef");this.rootRef=ae.observable({current:t})}async deleteItem(t){ae.runInAction(()=>{y.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?ae.toJS(this.rootRef.current):y.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(y.isObject(r))ae.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else ae.runInAction(()=>{y.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,i){return ae.reaction(()=>this.getValueFromRoot(t),(s,o)=>{r(s,o)},{requiresObservable:!0,fireImmediately:y.get(i,"fireImmediately",!1)})}}class Mo{constructor(){P(this,"channels",new Map);P(this,"globalChannel",new xi)}getChannel(t){const r=this.channels.get(t);if(r)return r;const i=new xi;return this.channels.set(t,i),i}}class Ao{constructor(t){P(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 Mo,instanceData:new Li(t.viz.conf)};return this.instances.set(t.id,i),i}}function Pi(e,t,r,i){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new Li({}),colorPalette:{getColor(){return()=>""}},data:t,variables:i}}const zo=e=>{const{panel:t,vizManager:r,data:i,variables:s}=e,o=r.resolveComponent(t.viz.type),u=r.getOrCreateInstance(t),l={...Pi(u,i,r,s),viewport:{width:t.layout.w,height:t.layout.h}},d=o.viewRender;return n(d,{context:l,instance:u,...y.omit(e,["panel","vizManager","data"])})},$o=e=>{const{vizManager:t,panel:r,panelInfoEditor:i,data:s,variables:o}=e,u=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),d={...Pi(l,s,t,o),panelInfoEditor:i},c=u.configRender;return n(c,{context:d,instance:l,...y.omit(e,["panel","vizManager","data","panelInfoEditor"])})},Oi=(e,t)=>{const r=Fe.bezier(e),i=Fe.bezier(t);return function(s){return s<50?r(s*2/100).hex():i((s-50)*2/100).hex()}},Gt=e=>{const t=Fe.bezier(e);return function(r){return t(r/100).hex()}},Eo={type:"interpolation",displayName:"Red / Green",getColor:Oi(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Lo={type:"interpolation",displayName:"Yellow / Blue",getColor:Oi(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Po={type:"interpolation",displayName:"Red",getColor:Gt(["#fff7f1","darkred"]),name:"red",category:"sequential"},Oo={type:"interpolation",displayName:"Green",getColor:Gt(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Vo={type:"interpolation",displayName:"Blue",getColor:Gt(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Bo={type:"interpolation",displayName:"Orange",getColor:Gt(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},Vi="@devtable/dashboard",Cn="8.60.1",Bi="Apache-2.0",Ni={access:"public",registry:"https://registry.npmjs.org/"},Gi=["dist"],qi="./dist/dashboard.umd.js",Fi="./dist/dashboard.es.js",Wi="./dist/index.d.ts",ji={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Ri={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},Yi={"@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-tree-select":"5.5.5",reactflow:"^11.5.3"},Qi={"@emotion/babel-plugin":"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.118.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.6.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3","vite-plugin-static-copy":"0.13.1"},Ui={"@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.118.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"},No=Object.freeze(Object.defineProperty({__proto__:null,default:{name:Vi,version:Cn,license:Bi,publishConfig:Ni,files:Gi,main:qi,module:Fi,types:Wi,exports:ji,scripts:Ri,dependencies:Yi,devDependencies:Qi,peerDependencies:Ui},dependencies:Yi,devDependencies:Qi,exports:ji,files:Gi,license:Bi,main:qi,module:Fi,name:Vi,peerDependencies:Ui,publishConfig:Ni,scripts:Ri,types:Wi,version:Cn},Symbol.toStringTag,{value:"Module"}));class Go{constructor(t){P(this,"staticColors",new Map);P(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 qo{constructor(){P(this,"plugins",new Map);P(this,"vizComponents",new Map);P(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class Fo{constructor(){P(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=y.orderBy(s,"version","asc");if(((u=y.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 ge extends Fo{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=y.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 y.get(r,"version",0)<this.VERSION}}const j=(e,t)=>{const[r,{setFalse:i}]=Z.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}},wn={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"}};oe.use([q.GridComponent,q.VisualMapComponent,q.LegendComponent,q.TooltipComponent,Ie.CanvasRenderer]);function Wo({context:e}){const{value:t}=j(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:c,zAxis3D:f}=y.defaults({},t,wn),g=m.useMemo(()=>{const w=y.minBy(r,C=>C[l]);return y.get(w,l)},[r,l]),h=m.useMemo(()=>{const w=y.maxBy(r,C=>C[l]);return y.get(w,l)},[r,l]),b={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:c,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:r.map(w=>[w[o],w[u],w[l]])}]};return t?n(Me,{echarts:oe,option:b,style:{width:i,height:s},notMerge:!0,theme:"merico-light"}):null}function jo({label:e,required:t,value:r,onChange:i,data:s,clearable:o=!1,sx:u,...l},d){const c=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:c,value:r,onChange:i,required:t,sx:u,...l})}const U=m.forwardRef(jo);function Ro({context:e}){const{value:t,set:r}=j(e.instanceData,"config"),i=e.data,s=y.defaults({},t,wn),{control:o,handleSubmit:u,reset:l}=x.useForm({defaultValues:s});return m.useEffect(()=>{l(s)},[t]),t?n(a.Stack,{spacing:"xs",children:p("form",{onSubmit:u(r),children:[n(a.Text,{children:"X Axis"}),p(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(U,{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"}),p(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(U,{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"}),p(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(U,{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:p(a.Button,{color:"blue",type:"submit",children:[n(D.DeviceFloppy,{size:20}),n(a.Text,{ml:"md",children:"Save"})]})})]})}):null}class Yo extends ge{constructor(){super(...arguments);P(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const Qo={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new Yo,name:"bar-3d",viewRender:Wo,configRender:Ro,createConfig(){return{version:1,config:y.cloneDeep(wn)}}},De={mantissa:0,output:"number",trimMantissa:!1,average:!1};function Uo({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 p(a.Stack,{ref:r,children:[p(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:p(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"}}})]}),p(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"}}})]}),p(a.Stack,{spacing:0,children:[n(a.Text,{weight:"bold",children:"Preview"}),n(Ae,{children:p(a.Group,{position:"apart",children:[p(a.Text,{size:12,color:"gray",children:["123456789 ",n(D.ArrowRight,{size:9})," ",ue(123456789).format(e)]}),p(a.Text,{size:12,color:"gray",children:["1234 ",n(D.ArrowRight,{size:9})," ",ue(1234).format(e)]}),p(a.Text,{size:12,color:"gray",children:["0.1234 ",n(D.ArrowRight,{size:9})," ",ue(.1234).format(e)]})]})})]})]})}const Ve=m.forwardRef(Uo),Be={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
28
28
  `)},Xi={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:Zo,configRender:Xo,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 Xo(e){return n(O,{})}function Zo(e){return n(a.Text,{children:"Click chart's series"})}const Ko=[{label:"Truncate",value:"truncate"},{label:"Break Line",value:"break"},{label:"Break Word",value:"breakAll"}],qt=m.forwardRef(({sectionTitle:e,value:t,onChange:r},i)=>{const s=o=>u=>{const l=y.cloneDeep(t);y.set(l,o,u),r(l)};return p(a.Stack,{spacing:0,children:[e&&n(a.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),p(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:Ko,value:t.overflow,onChange:s("overflow")}),n(a.TextInput,{label:"Ellipsis",value:t.ellipsis,disabled:!0})]})]})}),nt=m.forwardRef(({value:e,onChange:t},r)=>{const i=o=>{t({...e,on_axis:o})},s=o=>{t({...e,in_tooltip:o})};return p(a.Stack,{ref:r,spacing:0,children:[n(qt,{sectionTitle:"Overflow on Axis",value:e.on_axis,onChange:i}),n(qt,{sectionTitle:"Overflow in Tooltip",value:e.in_tooltip,onChange:s})]})}),je={on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}};function Ze({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`
29
29
  max-width: ${t}px;
30
30
  word-break: ${r};
@@ -371,7 +371,7 @@ Check the top-level render call using <`+E+">.")}return I}}function Ws(_,I){{if(
371
371
  parent_value: string;
372
372
  description?: string;
373
373
  }
374
- `,Sy=()=>{const[e,t]=m.useState(!1);return p(O,{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(at.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:_y})})]})},Ty=T.observer(function({config:t}){return p(O,{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(fr,{value:t.options_query_id,onChange:t.setOptionsQueryID}),n(Sy,{})]})}),Dy=T.observer(function({filter:t}){const[r,i]=m.useState(t.plainDefaultValue);return m.useEffect(()=>{i(t.plainDefaultValue)},[t]),p(a.Box,{sx:{maxWidth:"480px"},children:[n(a.Text,{pb:"md",color:"gray",children:"Preview"}),n(zi,{filter:t,value:r,onChange:i}),n(a.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),n(at.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),ky={select:Cy,"multi-select":xy,"tree-select":Ty,"text-input":wy,checkbox:my,"date-range":vy},Iy=[{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"}],My=T.observer(function({filter:t}){const r=B(),i=m.useMemo(()=>ky[t.type],[t.type]);return p(a.Group,{grow:!0,spacing:20,align:"top",children:[p(a.Box,{sx:{maxWidth:"600px"},children:[n(a.Text,{pb:"md",color:"gray",children:"Edit"}),p(a.Stack,{children:[p(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:Iy,required:!0,value:t.type,onChange:t.setType}),n(i,{config:t.config})]})]}),n(Dy,{filter:t})]})}),Ay=T.observer(({id:e})=>{const t=Pe.useModals(),r=B();if(e==="")return null;const i=r.filters.findByID(e);if(!i)return p(a.Text,{size:14,children:["Filter by ID[",e,"] is not found"]});const s=()=>{t.openConfirmModal({title:"Delete this filter?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>r.filters.removeByID(e),zIndex:320})};return p(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(D.Trash,{size:16}),onClick:s,children:"Delete this filter"})}),n(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n(My,{filter:i})})]})}),zy=T.observer(()=>{const e=B(),[t,r]=m.useState(()=>JSON.stringify(e.mock_context.current,null,4)),i=()=>{try{e.mock_context.replace(JSON.parse(t))}catch(o){Lt.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 p(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"})}),p(a.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[p(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(D.DeviceFloppy,{size:20})})]})]})}),$y=T.observer(()=>{const{panel:e}=xe();return n(Nn,{label:"Description",value:e.description,onChange:e.setDescription,styles:{root:{flexGrow:1}}})}),Ey=T.observer(()=>{const{panel:e}=xe(),{style:t}=e;return n(O,{children:n(a.Switch,{label:"Border",checked:t.border.enabled,onChange:r=>t.border.setEnabled(r.currentTarget.checked)})})}),Ly=T.observer(()=>{const{panel:e}=xe(),{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:p(a.Group,{children:[n(a.Text,{children:"Panel Title"}),n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:u,children:n(D.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function Py(){return p(a.Stack,{sx:{height:"100%"},children:[n(a.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),n(Ey,{}),n(a.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),n(Ly,{}),n($y,{})]})}const Oy=({queryID:e})=>{const t=B(),{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},Vy={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 Cs({data:e}){const t=m.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const i=Ee.createColumnHelper();return Object.keys(e[0]).map(s=>i.accessor(s,{cell:o=>o.getValue()}))},[e]),r=Ee.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Ee.getCoreRowModel()});return e.length===0?n(a.Box,{sx:{height:"5em"}}):n(Ae,{children:p(a.Table,{sx:Vy,children:[n("thead",{children:r.getHeaderGroups().map(i=>n("tr",{children:i.headers.map(s=>p("th",{style:{width:s.getSize()},children:[s.isPlaceholder?null:Ee.flexRender(s.column.columnDef.header,s.getContext()),n(a.ActionIcon,{onMouseDown:s.getResizeHandler(),onTouchStart:s.getResizeHandler(),className:`resizer ${s.column.getIsResizing()?"isResizing":""}`,children:n(D.ArrowBarToRight,{})})]},s.id))},i.id))}),n("tbody",{children:r.getRowModel().rows.map(i=>n("tr",{children:i.getVisibleCells().map(s=>n("td",{children:n(Ae,{children:Ee.flexRender(s.column.columnDef.cell,s.getContext())})},s.id))},i.id))})]})})}const ws=T.observer(function({id:t}){const r=B(),{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]),c=!Array.isArray(i)||i.length===0;return p(a.Stack,{sx:{border:"1px solid #eee"},children:[p(a.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[p(a.Group,{position:"left",children:[n(a.Text,{weight:500,children:"Preview Data"}),i.length>10&&p(a.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",i.length]})]}),p(a.Group,{pr:15,children:[n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:o,onClick:u,children:n(D.Refresh,{size:15})}),n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:o||c,onClick:l,children:n(D.Download,{size:15})})]})]}),p(a.Box,{sx:{position:"relative",overflow:"auto"},children:[n(a.LoadingOverlay,{visible:o}),n(Oy,{queryID:t}),n(Cs,{data:d})]})]})}),By=T.observer(function(){const t=B(),{panel:{queryID:r,setQueryID:i}}=xe(),s=()=>{t.editor.setPath(["_QUERIES_",r])};return p(a.Stack,{children:[p(a.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[n(a.Text,{children:"Use query"}),n(a.Select,{data:t.queries.options,value:r,onChange:i,allowDeselect:!1,clearable:!1,sx:{flexGrow:"1 !important"},maxDropdownHeight:300,rightSection:r&&n(a.Tooltip,{label:"Open this query",children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:s,children:n(V.IconArrowCurveRight,{size:16})})})})]}),n(ws,{id:r})]})}),Ny=T.observer(({height:e})=>{const t=B(),{data:r,loading:i,error:s,panel:{viz:o,queryID:u}}=xe(),l=t.queries.findByID(u);return n(La,{viz:o,data:r,loading:i,error:s,query:l,height:e})}),Gy=T.observer(()=>{const{panel:{title:e,style:{border:t}}}=xe();return n(Ae,{children:n(a.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:p(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:[p(a.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[n(a.Group,{children:n(Ei,{})}),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(Ny,{height:"410px"})})]})})})}),gr={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 qy{constructor(t){P(this,"panel");P(this,"selected");this.panel=t,ae.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const t=this.panel.variables.filter(r=>r.name.startsWith(gr.name)).length;this.panel.addVariable(y.cloneDeep({...gr,name:`${gr.name}${t||""}`})),this.selected=y.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&&!y.isEmpty(this.panel.variables)){const i=Math.min(this.panel.variables.length-1,r);this.selected=this.panel.variables[i]}}}function Fy(){const{panel:e}=xe();return Z.useCreation(()=>new qy(e),[e])}const Wy=m.forwardRef(function({value:t,onChange:r,data:i,withStyle:s=!0},o){const u=(l,d)=>{const c=y.cloneDeep(t);y.set(c,l,d),r(c)};return p(a.Box,{px:"sm",py:"md",ref:o,children:[p(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(U,{label:"Data Field",required:!0,data:i,value:t.data_field,onChange:l=>u("data_field",l)})]}),n(Ft,{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(Ki,{value:t,onChange:r})]})}),_s=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}})),jy=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))})},Ry=T.observer(jy),Yy=({variable:e,data:t})=>n(a.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:n(a.Paper,{withBorder:!0,p:"md",children:Ji(e,t)})}),Qy=T.observer(Yy),Uy=e=>{const t=Z.useCreation(()=>Pv(e.variable),[e.variable]),{classes:r}=_s(),{data:i}=xe();return p(a.Group,{style:{height:"100%"},align:"start",children:[p(a.Stack,{"data-testid":"variable-editor",align:"stretch",className:r.config,children:[p(a.Group,{position:"right",children:[n(a.ActionIcon,{variant:"filled",disabled:!t.changed,color:"primary",onClick:t.commit,children:n(V.IconDeviceFloppy,{size:18})}),n(a.ActionIcon,{color:"red",onClick:()=>e.uiModel.remove(e.variable),children:n(V.IconTrash,{size:18})})]}),n(Wy,{value:v.getSnapshot(t.copy),onChange:t.update,data:i})]}),n(Qy,{variable:v.getSnapshot(t.copy),data:i})]})},Xy=T.observer(Uy),Zy=()=>{const e=Fy(),{classes:t}=_s();return p(a.Group,{className:t.root,noWrap:!0,align:"start",children:[n(a.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:p(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(Ry,{uiModel:e})]})}),e.selected?n(O,{children:n(Xy,{uiModel:e,variable:e.selected})}):n("span",{children:"Select or create a new variable on right side"})]})},Ky=T.observer(Zy);function Jy(){const{vizManager:e}=m.useContext(Ne);return m.useMemo(()=>{const t=e.availableVizList.map(r=>({value:r.name,label:r.displayName??r.name,group:r.displayGroup??""}));return y.orderBy(t,[r=>r.group,r=>r.label],["asc","asc"])},[e])}const Hy=T.observer(({value:e,submit:t})=>{const[r,i]=ve.useInputState(e);m.useEffect(()=>{i(e)},[e]);const s=Jy(),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(D.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),Ss=[];function ex(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function tx(){const{data:e,panel:{variables:t,viz:r,title:i,queryID:s,description:o,setDescription:u,setTitle:l,setQueryID:d,id:c}}=xe(),{vizManager:f}=m.useContext(Ne),g={title:i,description:o,viz:r,queryID:s,id:c},h={setDescription:u,setQueryID:d,setTitle:l},b=za(g);try{return f.resolveComponent(g.viz.type),n(Bt,{configure:b,children:n(bb,{variables:t,setVizConf:r.setConf,panel:g,panelInfoEditor:h,vizManager:f,data:e})})}catch(w){return console.info(y.get(w,"message")),null}}const nx=T.observer(()=>{const{data:e,panel:{viz:t}}=xe(),{vizManager:r}=m.useContext(Ne),i=m.useCallback(c=>{if(c===t.type)return;const f=ex(r,c);t.setType(c),t.setConf(f||{})},[t.type]),s=c=>{try{t.setConf(JSON.parse(c))}catch(f){console.error(f)}},o=m.useMemo(()=>{var c;return(c=Ss.find(f=>f.value===t.type))==null?void 0:c.Panel},[t.type,Ss]),u=tx(),l=o?m.createElement(o,{data:e,conf:t.conf,setConf:t.setConf}):null,d=u||l;return p(a.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[n(Hy,{submit:i,value:t.type}),n(a.Stack,{pb:50,sx:{flexGrow:1,maxHeight:"calc(100% - 80px)",overflow:"auto"},children:d}),!d&&n(a.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:s})]})}),rx=T.observer(({panel:e,sourceViewID:t})=>{const r=B(),[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 p(O,{children:[n(a.Button,{size:"xs",variant:"subtle",color:"blue",onClick:u,leftIcon:n(V.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:p(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(c=>n(a.Radio,{value:c.value,label:c.label},c.value))})}),p(a.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[n(a.Button,{size:"xs",color:"red",leftIcon:n(V.IconX,{size:14}),onClick:l,children:"Cancel"}),n(a.Button,{size:"xs",color:"blue",leftIcon:n(V.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:"Confirm"})]})]})})]})}),ix={root:{flexGrow:1,width:"100%",height:"100%"},panel:{width:"100%",height:"100%",padding:10}},Ts=({children:e})=>p(a.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"calc(100% - 36px)"},children:[n(a.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),n(Gy,{})]});function ax(e){return!["richText","button"].includes(e)}const sx=T.observer(({panel:e})=>{const t=Pe.useModals(),r=B(),[i,s]=m.useState("Data"),{data:o,state:u,error:l}=r.getDataStuffByID(e.queryID),d=r.queries.findByID(e.queryID),f=ax(e.viz.type)&&u==="loading",g=f||l||!d||!!d.stateMessage,h=r.editor.path[1];m.useEffect(()=>{s(C=>g&&C==="Visualization"?"Data":C)},[e.id,g]);const b=()=>{r.editor.setPath(["_VIEWS_",h])},w=()=>t.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.removePanelByID(e.id,h),b()},confirmProps:{color:"red"},zIndex:320});return p(vn,{value:{panel:e,data:o,loading:f,error:l},children:[p(a.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[p(a.Text,{pt:9,pb:8,children:[e.title?e.title:e.viz.type," "]}),p(a.Group,{position:"right",noWrap:!0,children:[n(rx,{panel:e,sourceViewID:h}),n(a.Button,{size:"xs",variant:"subtle",color:"red",onClick:w,leftIcon:n(V.IconTrash,{size:14}),children:"Delete This Panel"})]})]}),p(a.Tabs,{value:i,onTabChange:s,keepMounted:!1,styles:ix,children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"Data",disabled:f,children:"Data"}),n(a.Tabs.Tab,{value:"Panel",children:"Panel"}),n(a.Tabs.Tab,{value:"Variables",disabled:g,children:n(a.Tooltip,{label:"Requires data",disabled:!g,withinPortal:!0,zIndex:310,children:n(a.Text,{children:"Variables"})})}),n(a.Tabs.Tab,{value:"Visualization",disabled:g,children:n(a.Tooltip,{label:"Requires data",disabled:!g,withinPortal:!0,zIndex:310,children:n(a.Text,{children:"Visualization"})})}),n(a.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),p(a.Tabs.Panel,{value:"Data",children:[n(a.LoadingOverlay,{visible:f,exitTransitionDuration:0}),n(By,{})]}),n(a.Tabs.Panel,{value:"Panel",children:n(Ts,{children:n(Py,{})})}),n(a.Tabs.Panel,{value:"Variables",children:n(Ky,{})}),n(a.Tabs.Panel,{value:"Visualization",children:n(Ae,{children:n(Ts,{children:n(nx,{})})})}),n(a.Tabs.Panel,{value:"Interactions",children:n(Ae,{children:n(gb,{})})})]})]})}),ox=T.observer(({viewID:e,panelID:t})=>{const r=B();if(!r.views.findByID(e))return p(a.Text,{size:14,children:["View by ID[",e,"] is not found"]});const s=r.panels.findByID(t);return s?n(sx,{panel:s}):p(a.Text,{size:14,children:["Panel by ID[",t,"] is not found"]})}),Ds=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:r,count:i,spacing:s=16,pl:o=0})=>p(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"})]}),kt=({value:e})=>e===null||e===""?null:n(a.Tooltip,{label:e,disabled:!e,multiline:!0,children:n(a.ActionIcon,{children:n(V.IconInfoCircle,{size:14})})}),lx=({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},ux=T.observer(({dataSource:e})=>{const{columns:t}=e;return t.loading?n(Ds,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:p(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("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:p("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=>p("tr",{children:[n("td",{children:r.ordinal_position}),n("td",{children:r.column_name}),n("td",{children:n(kt,{value:r.column_comment})}),n("td",{children:n(lx,{column:r})}),n("td",{children:r.column_type}),n("td",{children:r.is_nullable}),n("td",{children:n(kt,{value:r.column_default})})]},r.column_name))})]})}),dx=T.observer(({dataSource:e})=>{const{indexes:t}=e,r=t.data;return p(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("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:p("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=>p("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))})]})}),cx=T.observer(({dataSource:e})=>{const{indexes:t}=e,r=t.data;return p(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("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:p("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=>p("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(kt,{value:i.index_definition})}),n("td",{children:n(kt,{value:i.condition})}),n("td",{children:n(kt,{value:i.comment})})]},i.index_name))})]})}),px=T.observer(({dataSource:e})=>{const{indexes:t}=e;return t.loading||t.empty?null:e.type===ce.MySQL?n(dx,{dataSource:e}):e.type===ce.Postgresql?n(cx,{dataSource:e}):null}),hx=T.observer(({dataSource:e})=>p(a.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[n(Ae,{children:n(ux,{dataSource:e})}),n(Ae,{children:n(px,{dataSource:e})})]}));function fx({table_type:e}){return e==="VIEW"?n(V.IconEye,{size:14}):e==="BASE TABLE"?n(V.IconTable,{size:14}):null}const gx=T.observer(({dataSource:e})=>{const{tables:t}=e;return t.loading?n(Ds,{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(V.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(fx,{table_type:s.table_type}),onClick:()=>{e.setKeywords(r,s.table_name)},active:e.table_name===s.table_name},s.table_name))},r))})}),mx=({visible:e})=>n(a.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:n(a.LoadingOverlay,{visible:e})}),bx=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],vx={icon:{width:"50px",textAlign:"center"},input:{"&.mantine-Input-withIcon":{paddingLeft:"50px"}}},yx=T.observer(({dataSource:e})=>{const{tableData:t}=e;return p(a.Group,{pt:10,px:10,position:"apart",children:[p(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:vx,data:bx,value:String(t.limit),onChange:r=>t.setLimit(Number(r))})]}),n(a.Group,{position:"right",children:p(a.Text,{color:"dimmed",my:0,size:14,children:["Total ",t.total," rows"]})})]})}),xx=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(mx,{visible:!0}):p(Ae,{children:[n(yx,{dataSource:e}),p(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(Cs,{data:t.data})]})]})}),Cx={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},wx=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}):p(a.Flex,{sx:{height:"100%"},children:[n(a.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:n(Ae,{children:n(gx,{dataSource:e})})}),p(a.Tabs,{defaultValue:"structure",styles:Cx,children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"structure",icon:n(V.IconColumns,{size:14}),children:"Structure"}),n(a.Tabs.Tab,{value:"data",icon:n(V.IconDatabase,{size:14}),children:"Data"})]}),n(a.Tabs.Panel,{value:"structure",children:n(hx,{dataSource:e})}),n(a.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:n(xx,{dataSource:e})})]})]}))),_x={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"}},ks=T.observer(({dataSource:e,triggerButtonProps:t={}})=>{const[r,i]=m.useState(!1);return p(O,{children:[n(a.Modal,{opened:r,onClose:()=>i(!1),title:p(a.Group,{position:"apart",sx:{flexGrow:1},children:[n(a.Text,{fw:500,children:"Explorer Data Source"}),p(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:_x,children:n(a.Box,{sx:{height:"calc(100vh - 220px)"},children:n(wx,{dataSource:e})})}),n(a.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:"See Table Structure"})]})}),Sx=m.forwardRef(({label:e,type:t,...r},i)=>p(a.Group,{position:"apart",ref:i,...r,children:[n(a.Text,{children:e}),n(a.Text,{children:t})]})),Tx=T.observer(({value:e,onChange:t})=>{const r=B(),{data:i=[],loading:s}=Z.useRequest(sr,{refreshDeps:[]},[]),o=m.useMemo(()=>i.map(c=>({label:c.key,value:c.key,type:c.type})),[i]),u=m.useMemo(()=>o.reduce((c,f)=>(c[f.value]=f.type,c),{}),[o]),l=c=>{c!==null&&t({key:c,type:u[c]})},d=m.useMemo(()=>r.datasources.find(e),[r,e]);return n(a.Select,{data:o,label:p(a.Group,{position:"apart",children:[n(a.Box,{children:"Data Source"}),d&&n(ks,{dataSource:d,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:Sx,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",".mantine-Text-root":{userSelect:"none"}}},disabled:s,value:e.key,onChange:l})}),Dx=e=>{const{queryModel:t}=e,r=B(),s=r.findQueryUsage(t.id).length>0,o=Pe.useModals(),u=()=>{o.openConfirmModal({title:"Delete this query?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.queries.removeQuery(t.id),r.editor.setPath(["_QUERIES_",""])},zIndex:320})};return s?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(V.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})}):n(a.Button,{color:"red",size:"xs",onClick:u,leftIcon:n(V.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})},kx=T.observer(Dx),Ix=T.observer(({queryModel:e})=>n(a.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:p(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(Tx,{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",data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy}),n(a.Divider,{mt:20,mb:10,variant:"dashed"}),n(kx,{queryModel:e})]})}));function Mx(){const[e,{open:t,close:r}]=ve.useDisclosure(!1);return p(O,{children:[n(a.Modal,{opened:e,onClose:r,title:"About FunctionUtils",zIndex:320,children:n(Nt,{value:ov,styles:{root:{border:"none"},content:{padding:0}}})}),n(a.Button,{variant:"light",color:"violet",size:"xs",onClick:t,leftIcon:n(V.IconInfoCircle,{size:16}),children:"About parameter 'utils'"})]})}const Ax=({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}}})})},on=m.forwardRef(({value:e,onChange:t,label:r,defaultValue:i},s)=>{const[o,u]=m.useState(e),l=()=>{t(o)},d=()=>{u(e)},c=()=>{u(i)};m.useEffect(()=>{u(e)},[e]);const f=o!==e;return p(a.Stack,{spacing:4,sx:{height:"100%"},children:[p(a.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[n(a.Group,{position:"left",children:n(Mx,{})}),p(a.Group,{position:"right",children:[n(a.Button,{onClick:c,size:"xs",variant:"default",leftIcon:n(V.IconPlayerSkipBack,{size:16}),children:"Reset to default"}),n(a.Button,{onClick:d,color:"red",size:"xs",disabled:!f,leftIcon:n(V.IconRecycle,{size:16}),children:"Revert Changes"}),n(a.Button,{size:"xs",onClick:l,disabled:!f,leftIcon:n(V.IconDeviceFloppy,{size:16}),children:"Confirm Changes"})]})]}),n(a.Text,{size:14,children:r}),n(Ax,{value:o,onChange:u})]})}),zx=`
374
+ `,Sy=()=>{const[e,t]=m.useState(!1);return p(O,{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(at.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:_y})})]})},Ty=T.observer(function({config:t}){return p(O,{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(fr,{value:t.options_query_id,onChange:t.setOptionsQueryID}),n(Sy,{})]})}),Dy=T.observer(function({filter:t}){const[r,i]=m.useState(t.plainDefaultValue);return m.useEffect(()=>{i(t.plainDefaultValue)},[t]),p(a.Box,{sx:{maxWidth:"480px"},children:[n(a.Text,{pb:"md",color:"gray",children:"Preview"}),n(zi,{filter:t,value:r,onChange:i}),n(a.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),n(at.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),ky={select:Cy,"multi-select":xy,"tree-select":Ty,"text-input":wy,checkbox:my,"date-range":vy},Iy=[{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"}],My=T.observer(function({filter:t}){const r=B(),i=m.useMemo(()=>ky[t.type],[t.type]);return p(a.Group,{grow:!0,spacing:20,align:"top",children:[p(a.Box,{sx:{maxWidth:"600px"},children:[n(a.Text,{pb:"md",color:"gray",children:"Edit"}),p(a.Stack,{children:[p(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:Iy,required:!0,value:t.type,onChange:t.setType}),n(i,{config:t.config})]})]}),n(Dy,{filter:t})]})}),Ay=T.observer(({id:e})=>{const t=Pe.useModals(),r=B();if(e==="")return null;const i=r.filters.findByID(e);if(!i)return p(a.Text,{size:14,children:["Filter by ID[",e,"] is not found"]});const s=()=>{r.editor.setPath(["_FILTERS_",""])},o=()=>{t.openConfirmModal({title:"Delete this filter?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.filters.removeByID(e),s()},zIndex:320})};return p(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(D.Trash,{size:16}),onClick:o,children:"Delete this filter"})}),n(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n(My,{filter:i})})]})}),zy=T.observer(()=>{const e=B(),[t,r]=m.useState(()=>JSON.stringify(e.mock_context.current,null,4)),i=()=>{try{e.mock_context.replace(JSON.parse(t))}catch(o){Lt.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 p(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"})}),p(a.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[p(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(D.DeviceFloppy,{size:20})})]})]})}),$y=T.observer(()=>{const{panel:e}=xe();return n(Nn,{label:"Description",value:e.description,onChange:e.setDescription,styles:{root:{flexGrow:1}}})}),Ey=T.observer(()=>{const{panel:e}=xe(),{style:t}=e;return n(O,{children:n(a.Switch,{label:"Border",checked:t.border.enabled,onChange:r=>t.border.setEnabled(r.currentTarget.checked)})})}),Ly=T.observer(()=>{const{panel:e}=xe(),{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:p(a.Group,{children:[n(a.Text,{children:"Panel Title"}),n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:u,children:n(D.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function Py(){return p(a.Stack,{sx:{height:"100%"},children:[n(a.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),n(Ey,{}),n(a.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),n(Ly,{}),n($y,{})]})}const Oy=({queryID:e})=>{const t=B(),{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},Vy={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 Cs({data:e}){const t=m.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const i=Ee.createColumnHelper();return Object.keys(e[0]).map(s=>i.accessor(s,{cell:o=>o.getValue()}))},[e]),r=Ee.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Ee.getCoreRowModel()});return e.length===0?n(a.Box,{sx:{height:"5em"}}):n(Ae,{children:p(a.Table,{sx:Vy,children:[n("thead",{children:r.getHeaderGroups().map(i=>n("tr",{children:i.headers.map(s=>p("th",{style:{width:s.getSize()},children:[s.isPlaceholder?null:Ee.flexRender(s.column.columnDef.header,s.getContext()),n(a.ActionIcon,{onMouseDown:s.getResizeHandler(),onTouchStart:s.getResizeHandler(),className:`resizer ${s.column.getIsResizing()?"isResizing":""}`,children:n(D.ArrowBarToRight,{})})]},s.id))},i.id))}),n("tbody",{children:r.getRowModel().rows.map(i=>n("tr",{children:i.getVisibleCells().map(s=>n("td",{children:n(Ae,{children:Ee.flexRender(s.column.columnDef.cell,s.getContext())})},s.id))},i.id))})]})})}const ws=T.observer(function({id:t}){const r=B(),{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]),c=!Array.isArray(i)||i.length===0;return p(a.Stack,{sx:{border:"1px solid #eee"},children:[p(a.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[p(a.Group,{position:"left",children:[n(a.Text,{weight:500,children:"Preview Data"}),i.length>10&&p(a.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",i.length]})]}),p(a.Group,{pr:15,children:[n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:o,onClick:u,children:n(D.Refresh,{size:15})}),n(a.ActionIcon,{variant:"subtle",color:"blue",disabled:o||c,onClick:l,children:n(D.Download,{size:15})})]})]}),p(a.Box,{sx:{position:"relative",overflow:"auto"},children:[n(a.LoadingOverlay,{visible:o}),n(Oy,{queryID:t}),n(Cs,{data:d})]})]})}),By=T.observer(function(){const t=B(),{panel:{queryID:r,setQueryID:i}}=xe(),s=()=>{t.editor.setPath(["_QUERIES_",r])};return p(a.Stack,{children:[p(a.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[n(a.Text,{children:"Use query"}),n(a.Select,{data:t.queries.options,value:r,onChange:i,allowDeselect:!1,clearable:!1,sx:{flexGrow:"1 !important"},maxDropdownHeight:300,rightSection:r&&n(a.Tooltip,{label:"Open this query",children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:s,children:n(V.IconArrowCurveRight,{size:16})})})})]}),n(ws,{id:r})]})}),Ny=T.observer(({height:e})=>{const t=B(),{data:r,loading:i,error:s,panel:{viz:o,queryID:u}}=xe(),l=t.queries.findByID(u);return n(La,{viz:o,data:r,loading:i,error:s,query:l,height:e})}),Gy=T.observer(()=>{const{panel:{title:e,style:{border:t}}}=xe();return n(Ae,{children:n(a.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:p(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:[p(a.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[n(a.Group,{children:n(Ei,{})}),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(Ny,{height:"410px"})})]})})})}),gr={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 qy{constructor(t){P(this,"panel");P(this,"selected");this.panel=t,ae.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const t=this.panel.variables.filter(r=>r.name.startsWith(gr.name)).length;this.panel.addVariable(y.cloneDeep({...gr,name:`${gr.name}${t||""}`})),this.selected=y.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&&!y.isEmpty(this.panel.variables)){const i=Math.min(this.panel.variables.length-1,r);this.selected=this.panel.variables[i]}}}function Fy(){const{panel:e}=xe();return Z.useCreation(()=>new qy(e),[e])}const Wy=m.forwardRef(function({value:t,onChange:r,data:i,withStyle:s=!0},o){const u=(l,d)=>{const c=y.cloneDeep(t);y.set(c,l,d),r(c)};return p(a.Box,{px:"sm",py:"md",ref:o,children:[p(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(U,{label:"Data Field",required:!0,data:i,value:t.data_field,onChange:l=>u("data_field",l)})]}),n(Ft,{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(Ki,{value:t,onChange:r})]})}),_s=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}})),jy=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))})},Ry=T.observer(jy),Yy=({variable:e,data:t})=>n(a.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:n(a.Paper,{withBorder:!0,p:"md",children:Ji(e,t)})}),Qy=T.observer(Yy),Uy=e=>{const t=Z.useCreation(()=>Pv(e.variable),[e.variable]),{classes:r}=_s(),{data:i}=xe();return p(a.Group,{style:{height:"100%"},align:"start",children:[p(a.Stack,{"data-testid":"variable-editor",align:"stretch",className:r.config,children:[p(a.Group,{position:"right",children:[n(a.ActionIcon,{variant:"filled",disabled:!t.changed,color:"primary",onClick:t.commit,children:n(V.IconDeviceFloppy,{size:18})}),n(a.ActionIcon,{color:"red",onClick:()=>e.uiModel.remove(e.variable),children:n(V.IconTrash,{size:18})})]}),n(Wy,{value:v.getSnapshot(t.copy),onChange:t.update,data:i})]}),n(Qy,{variable:v.getSnapshot(t.copy),data:i})]})},Xy=T.observer(Uy),Zy=()=>{const e=Fy(),{classes:t}=_s();return p(a.Group,{className:t.root,noWrap:!0,align:"start",children:[n(a.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:p(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(Ry,{uiModel:e})]})}),e.selected?n(O,{children:n(Xy,{uiModel:e,variable:e.selected})}):n("span",{children:"Select or create a new variable on right side"})]})},Ky=T.observer(Zy);function Jy(){const{vizManager:e}=m.useContext(Ne);return m.useMemo(()=>{const t=e.availableVizList.map(r=>({value:r.name,label:r.displayName??r.name,group:r.displayGroup??""}));return y.orderBy(t,[r=>r.group,r=>r.label],["asc","asc"])},[e])}const Hy=T.observer(({value:e,submit:t})=>{const[r,i]=ve.useInputState(e);m.useEffect(()=>{i(e)},[e]);const s=Jy(),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(D.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),Ss=[];function ex(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function tx(){const{data:e,panel:{variables:t,viz:r,title:i,queryID:s,description:o,setDescription:u,setTitle:l,setQueryID:d,id:c}}=xe(),{vizManager:f}=m.useContext(Ne),g={title:i,description:o,viz:r,queryID:s,id:c},h={setDescription:u,setQueryID:d,setTitle:l},b=za(g);try{return f.resolveComponent(g.viz.type),n(Bt,{configure:b,children:n(bb,{variables:t,setVizConf:r.setConf,panel:g,panelInfoEditor:h,vizManager:f,data:e})})}catch(w){return console.info(y.get(w,"message")),null}}const nx=T.observer(()=>{const{data:e,panel:{viz:t}}=xe(),{vizManager:r}=m.useContext(Ne),i=m.useCallback(c=>{if(c===t.type)return;const f=ex(r,c);t.setType(c),t.setConf(f||{})},[t.type]),s=c=>{try{t.setConf(JSON.parse(c))}catch(f){console.error(f)}},o=m.useMemo(()=>{var c;return(c=Ss.find(f=>f.value===t.type))==null?void 0:c.Panel},[t.type,Ss]),u=tx(),l=o?m.createElement(o,{data:e,conf:t.conf,setConf:t.setConf}):null,d=u||l;return p(a.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[n(Hy,{submit:i,value:t.type}),n(a.Stack,{pb:50,sx:{flexGrow:1,maxHeight:"calc(100% - 80px)",overflow:"auto"},children:d}),!d&&n(a.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:s})]})}),rx=T.observer(({panel:e,sourceViewID:t})=>{const r=B(),[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 p(O,{children:[n(a.Button,{size:"xs",variant:"subtle",color:"blue",onClick:u,leftIcon:n(V.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:p(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(c=>n(a.Radio,{value:c.value,label:c.label},c.value))})}),p(a.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[n(a.Button,{size:"xs",color:"red",leftIcon:n(V.IconX,{size:14}),onClick:l,children:"Cancel"}),n(a.Button,{size:"xs",color:"blue",leftIcon:n(V.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:"Confirm"})]})]})})]})}),ix={root:{flexGrow:1,width:"100%",height:"100%"},panel:{width:"100%",height:"100%",padding:10}},Ts=({children:e})=>p(a.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"calc(100% - 36px)"},children:[n(a.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),n(Gy,{})]});function ax(e){return!["richText","button"].includes(e)}const sx=T.observer(({panel:e})=>{const t=Pe.useModals(),r=B(),[i,s]=m.useState("Data"),{data:o,state:u,error:l}=r.getDataStuffByID(e.queryID),d=r.queries.findByID(e.queryID),f=ax(e.viz.type)&&u==="loading",g=f||l||!d||!!d.stateMessage,h=r.editor.path[1];m.useEffect(()=>{s(C=>g&&C==="Visualization"?"Data":C)},[e.id,g]);const b=()=>{r.editor.setPath(["_VIEWS_",h])},w=()=>t.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.removePanelByID(e.id,h),b()},confirmProps:{color:"red"},zIndex:320});return p(vn,{value:{panel:e,data:o,loading:f,error:l},children:[p(a.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[p(a.Text,{pt:9,pb:8,children:[e.title?e.title:e.viz.type," "]}),p(a.Group,{position:"right",noWrap:!0,children:[n(rx,{panel:e,sourceViewID:h}),n(a.Button,{size:"xs",variant:"subtle",color:"red",onClick:w,leftIcon:n(V.IconTrash,{size:14}),children:"Delete This Panel"})]})]}),p(a.Tabs,{value:i,onTabChange:s,keepMounted:!1,styles:ix,children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"Data",disabled:f,children:"Data"}),n(a.Tabs.Tab,{value:"Panel",children:"Panel"}),n(a.Tabs.Tab,{value:"Variables",disabled:g,children:n(a.Tooltip,{label:"Requires data",disabled:!g,withinPortal:!0,zIndex:310,children:n(a.Text,{children:"Variables"})})}),n(a.Tabs.Tab,{value:"Visualization",disabled:g,children:n(a.Tooltip,{label:"Requires data",disabled:!g,withinPortal:!0,zIndex:310,children:n(a.Text,{children:"Visualization"})})}),n(a.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),p(a.Tabs.Panel,{value:"Data",children:[n(a.LoadingOverlay,{visible:f,exitTransitionDuration:0}),n(By,{})]}),n(a.Tabs.Panel,{value:"Panel",children:n(Ts,{children:n(Py,{})})}),n(a.Tabs.Panel,{value:"Variables",children:n(Ky,{})}),n(a.Tabs.Panel,{value:"Visualization",children:n(Ae,{children:n(Ts,{children:n(nx,{})})})}),n(a.Tabs.Panel,{value:"Interactions",children:n(Ae,{children:n(gb,{})})})]})]})}),ox=T.observer(({viewID:e,panelID:t})=>{const r=B();if(!r.views.findByID(e))return p(a.Text,{size:14,children:["View by ID[",e,"] is not found"]});const s=r.panels.findByID(t);return s?n(sx,{panel:s}):p(a.Text,{size:14,children:["Panel by ID[",t,"] is not found"]})}),Ds=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:r,count:i,spacing:s=16,pl:o=0})=>p(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"})]}),kt=({value:e})=>e===null||e===""?null:n(a.Tooltip,{label:e,disabled:!e,multiline:!0,children:n(a.ActionIcon,{children:n(V.IconInfoCircle,{size:14})})}),lx=({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},ux=T.observer(({dataSource:e})=>{const{columns:t}=e;return t.loading?n(Ds,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:p(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("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:p("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=>p("tr",{children:[n("td",{children:r.ordinal_position}),n("td",{children:r.column_name}),n("td",{children:n(kt,{value:r.column_comment})}),n("td",{children:n(lx,{column:r})}),n("td",{children:r.column_type}),n("td",{children:r.is_nullable}),n("td",{children:n(kt,{value:r.column_default})})]},r.column_name))})]})}),dx=T.observer(({dataSource:e})=>{const{indexes:t}=e,r=t.data;return p(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("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:p("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=>p("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))})]})}),cx=T.observer(({dataSource:e})=>{const{indexes:t}=e,r=t.data;return p(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[p("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:p("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=>p("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(kt,{value:i.index_definition})}),n("td",{children:n(kt,{value:i.condition})}),n("td",{children:n(kt,{value:i.comment})})]},i.index_name))})]})}),px=T.observer(({dataSource:e})=>{const{indexes:t}=e;return t.loading||t.empty?null:e.type===ce.MySQL?n(dx,{dataSource:e}):e.type===ce.Postgresql?n(cx,{dataSource:e}):null}),hx=T.observer(({dataSource:e})=>p(a.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[n(Ae,{children:n(ux,{dataSource:e})}),n(Ae,{children:n(px,{dataSource:e})})]}));function fx({table_type:e}){return e==="VIEW"?n(V.IconEye,{size:14}):e==="BASE TABLE"?n(V.IconTable,{size:14}):null}const gx=T.observer(({dataSource:e})=>{const{tables:t}=e;return t.loading?n(Ds,{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(V.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(fx,{table_type:s.table_type}),onClick:()=>{e.setKeywords(r,s.table_name)},active:e.table_name===s.table_name},s.table_name))},r))})}),mx=({visible:e})=>n(a.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:n(a.LoadingOverlay,{visible:e})}),bx=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],vx={icon:{width:"50px",textAlign:"center"},input:{"&.mantine-Input-withIcon":{paddingLeft:"50px"}}},yx=T.observer(({dataSource:e})=>{const{tableData:t}=e;return p(a.Group,{pt:10,px:10,position:"apart",children:[p(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:vx,data:bx,value:String(t.limit),onChange:r=>t.setLimit(Number(r))})]}),n(a.Group,{position:"right",children:p(a.Text,{color:"dimmed",my:0,size:14,children:["Total ",t.total," rows"]})})]})}),xx=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(mx,{visible:!0}):p(Ae,{children:[n(yx,{dataSource:e}),p(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(Cs,{data:t.data})]})]})}),Cx={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},wx=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}):p(a.Flex,{sx:{height:"100%"},children:[n(a.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:n(Ae,{children:n(gx,{dataSource:e})})}),p(a.Tabs,{defaultValue:"structure",styles:Cx,children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"structure",icon:n(V.IconColumns,{size:14}),children:"Structure"}),n(a.Tabs.Tab,{value:"data",icon:n(V.IconDatabase,{size:14}),children:"Data"})]}),n(a.Tabs.Panel,{value:"structure",children:n(hx,{dataSource:e})}),n(a.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:n(xx,{dataSource:e})})]})]}))),_x={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"}},ks=T.observer(({dataSource:e,triggerButtonProps:t={}})=>{const[r,i]=m.useState(!1);return p(O,{children:[n(a.Modal,{opened:r,onClose:()=>i(!1),title:p(a.Group,{position:"apart",sx:{flexGrow:1},children:[n(a.Text,{fw:500,children:"Explorer Data Source"}),p(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:_x,children:n(a.Box,{sx:{height:"calc(100vh - 220px)"},children:n(wx,{dataSource:e})})}),n(a.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:"See Table Structure"})]})}),Sx=m.forwardRef(({label:e,type:t,...r},i)=>p(a.Group,{position:"apart",ref:i,...r,children:[n(a.Text,{children:e}),n(a.Text,{children:t})]})),Tx=T.observer(({value:e,onChange:t})=>{const r=B(),{data:i=[],loading:s}=Z.useRequest(sr,{refreshDeps:[]},[]),o=m.useMemo(()=>i.map(c=>({label:c.key,value:c.key,type:c.type})),[i]),u=m.useMemo(()=>o.reduce((c,f)=>(c[f.value]=f.type,c),{}),[o]),l=c=>{c!==null&&t({key:c,type:u[c]})},d=m.useMemo(()=>r.datasources.find(e),[r,e]);return n(a.Select,{data:o,label:p(a.Group,{position:"apart",children:[n(a.Box,{children:"Data Source"}),d&&n(ks,{dataSource:d,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:Sx,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",".mantine-Text-root":{userSelect:"none"}}},disabled:s,value:e.key,onChange:l})}),Dx=e=>{const{queryModel:t}=e,r=B(),s=r.findQueryUsage(t.id).length>0,o=Pe.useModals(),u=()=>{o.openConfirmModal({title:"Delete this query?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.queries.removeQuery(t.id),r.editor.setPath(["_QUERIES_",""])},zIndex:320})};return s?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(V.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})}):n(a.Button,{color:"red",size:"xs",onClick:u,leftIcon:n(V.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})},kx=T.observer(Dx),Ix=T.observer(({queryModel:e})=>n(a.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:p(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(Tx,{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",data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy}),n(a.Divider,{mt:20,mb:10,variant:"dashed"}),n(kx,{queryModel:e})]})}));function Mx(){const[e,{open:t,close:r}]=ve.useDisclosure(!1);return p(O,{children:[n(a.Modal,{opened:e,onClose:r,title:"About FunctionUtils",zIndex:320,children:n(Nt,{value:ov,styles:{root:{border:"none"},content:{padding:0}}})}),n(a.Button,{variant:"light",color:"violet",size:"xs",onClick:t,leftIcon:n(V.IconInfoCircle,{size:16}),children:"About parameter 'utils'"})]})}const Ax=({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}}})})},on=m.forwardRef(({value:e,onChange:t,label:r,defaultValue:i},s)=>{const[o,u]=m.useState(e),l=()=>{t(o)},d=()=>{u(e)},c=()=>{u(i)};m.useEffect(()=>{u(e)},[e]);const f=o!==e;return p(a.Stack,{spacing:4,sx:{height:"100%"},children:[p(a.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[n(a.Group,{position:"left",children:n(Mx,{})}),p(a.Group,{position:"right",children:[n(a.Button,{onClick:c,size:"xs",variant:"default",leftIcon:n(V.IconPlayerSkipBack,{size:16}),children:"Reset to default"}),n(a.Button,{onClick:d,color:"red",size:"xs",disabled:!f,leftIcon:n(V.IconRecycle,{size:16}),children:"Revert Changes"}),n(a.Button,{size:"xs",onClick:l,disabled:!f,leftIcon:n(V.IconDeviceFloppy,{size:16}),children:"Confirm Changes"})]})]}),n(a.Text,{size:14,children:r}),n(Ax,{value:o,onChange:u})]})}),zx=`
375
375
  -- You may reference global variables in SQL or VizConfig.
376
376
  SELECT *
377
377
  FROM commit
@@ -387,4 +387,4 @@ WHERE
387
387
  `),post:["function process_result(res, utils) {"," // your code goes here"," return data","}"].join(`
388
388
  `)},$x=T.observer(({queryModel:e})=>e.typedAsHTTP?p(a.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"pre_process",children:"Build Request"}),n(a.Tabs.Tab,{value:"post_process",children:"Process Result"}),n(mr,{})]}),n(a.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:n(on,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:Ms.pre})}),n(a.Tabs.Panel,{value:"post_process",p:"sm",children:n(on,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:Ms.post})})]}):null),br=({value:e,onChange:t,height:r="200px",defaultLanguage:i="sql"})=>{const s=u=>{console.log("changing"),t==null||t(u??"")},o=!t;return n(_e,{className:"minimal-monaco-editor",height:r,defaultLanguage:i,value:e,onChange:o?void 0:s,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:o||!t}})},Ex=({value:e,height:t="200px",defaultLanguage:r="sql"})=>n(_e,{className:"preview-sql-in-monaco-editor",height:t,defaultLanguage:r,value:e,onChange:void 0,theme:"vs-light",options:{lineNumbers:"on",folding:!0,lineDecorationsWidth:20,wordWrap:"on",minimap:{enabled:!1},readOnly:!0}}),Lx=T.observer(({value:e})=>{const t=B(),r=t.context.current,i=m.useMemo(()=>es(e,r,t.mock_context.current,t.sqlSnippets.current,t.filters.values),[e,r,t.mock_context.current,t.sqlSnippets.current,t.filters.values]);return n(Ex,{height:"100%",value:i})}),As={pre:["function process_request({ context, filters, sql }, utils) {"," // modify and return sql"," return sql","}"].join(`
389
389
  `),post:["function process_result(data, utils) {"," // process data and return the result"," return data","}"].join(`
390
- `)},Px=T.observer(({queryModel:e})=>{const[t,r]=m.useState(e.sql);m.useEffect(()=>{r(o=>o!==e.sql?e.sql:o)},[e.sql]);const i=t!==e.sql,s=()=>{e.setSQL(t)};return e.typedAsSQL?p(a.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"Edit",children:p(a.Group,{spacing:14,position:"apart",children:["Edit SQL",n(a.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!i,onClick:s,children:n(D.DeviceFloppy,{size:20})})]})}),n(a.Tabs.Tab,{value:"Preview",children:"Preview SQL"}),n(a.Tabs.Tab,{value:"pre_process",children:"Process Request"}),n(a.Tabs.Tab,{value:"post_process",children:"Process Result"}),n(mr,{}),e.datasource&&n(ks,{dataSource:e.datasource})]}),n(a.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:n(br,{height:"100%",value:t,onChange:r})}),n(a.Tabs.Panel,{value:"Preview",p:0,pl:4,children:n(Lx,{value:e.sql})}),n(a.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:n(on,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:As.pre})}),n(a.Tabs.Panel,{value:"post_process",p:"sm",children:n(on,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:As.post})})]}):null}),Ox=T.observer(({queryID:e,usage:t})=>{const r=B().editor,i=o=>{if(o.type==="filter"){r.setPath(["_FILTERS_",o.id]);return}if(o.type==="panel"){const u=o.views[0].id;r.setPath(["_VIEWS_",u,"_PANELS_",o.id]);return}},s=o=>{r.setPath(["_VIEWS_",o])};return n(a.Stack,{py:"sm",px:"md",children:p(a.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n("thead",{children:p("tr",{children:[n("th",{style:{width:100},children:"Type"}),n("th",{style:{width:"calc(50% - 50px)"},children:"Name"}),n("th",{children:"In View(s)"})]})}),n("tbody",{children:t.map(o=>p("tr",{children:[n("td",{children:y.capitalize(o.type)}),n("td",{children:n(a.Anchor,{component:"button",type:"button",onClick:()=>i(o),children:o.label})}),n("td",{children:p(a.Stack,{align:"flex-start",justify:"flex-start",spacing:2,children:[o.views.map(u=>n(a.Anchor,{component:"button",type:"button",onClick:()=>s(u.id),children:n(a.Box,{children:u.label})})),o.views.length===0&&n(a.Box,{children:"--"})]})})]},o.id))})]})})}),ln={height:"calc(100% - 44px)",padding:0},Vx=T.observer(({queryModel:e})=>{const t=B(),r=m.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),i=t.findQueryUsage(e.id),s=i.length===0;return n(a.Stack,{sx:{flexGrow:1},my:0,p:0,children:p(a.Tabs,{defaultValue:r,orientation:"horizontal",keepMounted:!1,sx:{flexGrow:1},children:[p(a.Tabs.List,{grow:!0,children:[n(a.Tabs.Tab,{value:"Configurations",children:"Configurations"}),e.typedAsSQL&&n(a.Tabs.Tab,{value:"SQL",children:"Request"}),e.typedAsHTTP&&n(a.Tabs.Tab,{value:"HTTP",children:"Request"}),n(a.Tabs.Tab,{value:"Data",disabled:!e.datasource,children:n(a.Tooltip,{label:"Need to pick a Data Source first",disabled:e.datasource,withinPortal:!0,children:n(a.Text,{children:"Data"})})}),n(a.Tabs.Tab,{value:"Usage",disabled:s,children:n(a.Tooltip,{label:"This query is not used for any filter or panel",disabled:!s,withinPortal:!0,children:n(a.Text,{children:"Usage"})})})]}),n(a.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:n(Ix,{queryModel:e})}),e.typedAsSQL&&n(a.Tabs.Panel,{value:"SQL",sx:ln,children:n(a.Stack,{sx:{height:"100%"},children:n(Px,{queryModel:e})})}),e.typedAsHTTP&&n(a.Tabs.Panel,{value:"HTTP",sx:ln,children:n(a.Stack,{sx:{height:"100%"},children:n($x,{queryModel:e})})}),n(a.Tabs.Panel,{value:"Data",sx:{...ln,overflow:"hidden"},children:n(ws,{id:e.id})}),n(a.Tabs.Panel,{value:"Usage",sx:{...ln,overflow:"hidden"},children:n(Ox,{queryID:e.id,usage:i})})]})})}),Bx=T.observer(({id:e})=>{const r=B().queries.findByID(e);return e===""?null:r?n(a.Stack,{sx:{height:"100%"},spacing:"sm",children:n(Vx,{queryModel:r})}):n(a.Text,{size:14,color:"red",children:"Invalid Query ID"})}),Nx=T.observer(({value:e})=>{const t=B(),r=t.context.current,i=fv(e,r,t.mock_context.current,t.filters.values);return n(br,{height:"100%",value:i})}),Gx=T.observer(({item:e,remove:t,onKeyChanged:r})=>{const[i,s]=m.useState("SQL"),[o,u]=m.useState(e.key),l=()=>{e.setKey(o),r(o)},d=o!==e.key,c=e.isADuplicatedKey(o),[f,g]=m.useState(e.value),h=()=>{e.setValue(f)};m.useEffect(()=>{u(e.key),g(e.value)},[e]);const b=f!==e.value,w=Pe.useModals(),C=()=>{w.openConfirmModal({title:"Delete this SQL snippet?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:t,zIndex:320})};return p(a.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[p(a.Group,{sx:{alignItems:"end"},spacing:40,children:[n(a.TextInput,{label:c?"This key is occupied by another snippet":"Key",value:o,onChange:S=>{u(S.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:n(a.ActionIcon,{color:"blue",variant:"subtle",onClick:l,disabled:!d||c,children:n(D.DeviceFloppy,{size:16})}),error:c}),n(a.Button,{leftIcon:n(D.Trash,{size:16}),color:"red",variant:"light",onClick:C,children:"Delete this SQL Snippet"})]}),p(a.Tabs,{value:i,onTabChange:s,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[p(a.Tabs.List,{sx:{position:"relative"},children:[n(a.Tabs.Tab,{value:"SQL",children:"SQL"}),n(a.Tabs.Tab,{value:"Preview",children:"Preview"}),n(mr,{}),n(a.ActionIcon,{color:"blue",variant:"filled",onClick:h,disabled:!b,sx:{position:"absolute",top:0,right:10},children:n(D.DeviceFloppy,{size:18})})]}),n(a.Tabs.Panel,{value:"SQL",pt:"sm",children:n(br,{height:"100%",value:f,onChange:g})}),n(a.Tabs.Panel,{value:"Preview",pt:"sm",children:n(Nx,{value:f})})]})]})}),qx=T.observer(({id:e})=>{const t=B(),r=m.useMemo(()=>t.sqlSnippets.findByKey(e),[e]);return r?n(Gx,{item:r,remove:()=>t.sqlSnippets.removeByKey(e),onKeyChanged:o=>{t.editor.setPath(["_SQL_SNIPPETS_",o])}}):p(a.Text,{size:14,children:["SQL Snippet by key[",e,"] is not found"]})}),Fx=T.observer(({view:e})=>!e||e.type!==K.Division?null:p(a.Stack,{children:[n(a.Divider,{mt:8,mb:0,label:"Division settings",labelPosition:"center"}),n(a.Text,{align:"center",size:"xs",color:"dimmed",children:"Under construction"})]})),Wx=[{value:"default",label:"Default"},{value:"outline",label:"Outline"},{value:"pills",label:"Pills"}],jx=[{value:"horizontal",label:"Horizontal"},{value:"vertical",label:"Vertical"}],Rx=T.observer(({view:e})=>{if(!e||e.type!==K.Tabs)return null;const t=e.config;return p(a.Stack,{children:[n(a.Divider,{mt:8,mb:0,label:"Tabs settings",labelPosition:"center"}),n(a.Select,{label:"Variant",value:t.variant,onChange:t.setVariant,data:Wx}),n(a.Select,{label:"Orientation",value:t.orientation,onChange:t.setOrientation,data:jx}),n(a.Switch,{label:"Grow Tabs",checked:t.grow,onChange:r=>t.setGrow(r.currentTarget.checked)})]})}),Yx=({disabled:e,value:t,onChange:r})=>{const i=s=>{s&&r(s)};return p(a.Box,{sx:{position:"relative"},children:[e&&n(a.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),n(_e,{height:"500px",defaultLanguage:"javascript",value:t,onChange:i,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},Qx=({value:e,onChange:t})=>{const[r,{setTrue:i,setFalse:s}]=Z.useBoolean(),[o,u]=m.useState(e??or),l=h=>{u({...o,enabled:h})},d=()=>{s();const{enabled:h,func_content:b}=o,w={enabled:h,func_content:b};u(w),t(w)},c=()=>{s(),u(e)},f=h=>{u(b=>({...b,func_content:h}))},g=()=>{f(or.func_content)};return p(O,{children:[n(a.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:i,sx:{flexGrow:0},children:n(D.Settings,{size:14})}),n(a.Modal,{size:800,title:"Customize modal title",opened:r,onClose:s,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&p(a.Stack,{children:[n(a.Checkbox,{mt:10,label:"Enabled",checked:o.enabled,onChange:h=>l(h.currentTarget.checked)}),n(Yx,{value:o.func_content,onChange:f,disabled:!o.enabled}),p(a.Group,{position:"apart",children:[n(a.Button,{onClick:g,color:"red",leftIcon:n(D.Recycle,{size:20}),children:"Rest"}),p(a.Group,{position:"right",children:[n(a.Button,{onClick:c,variant:"subtle",children:"Cancel"}),n(a.Button,{onClick:d,children:"OK"})]})]})]})})]})},Ux=T.observer(({view:e})=>{if(!e||e.type!==K.Modal)return null;const t=e.config,r=t.custom_modal_title.value;return p(a.Stack,{children:[n(a.Divider,{mt:8,label:"Modal settings",labelPosition:"center"}),p(a.Flex,{gap:10,children:[n(a.TextInput,{label:"Modal Title",value:r,onChange:y.noop,disabled:!0,sx:{flexGrow:1}}),n(Qx,{value:t.custom_modal_title,onChange:t.custom_modal_title.replace})]}),p(a.Group,{grow:!0,children:[n(a.TextInput,{label:"Width",value:t.width,onChange:i=>t.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),n(a.TextInput,{label:"Height",value:t.height,onChange:i=>t.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),Xx=T.observer(({view:e})=>p(O,{children:[n(Fx,{view:e}),n(Ux,{view:e}),n(Rx,{view:e})]})),Zx=[{label:"Division",value:K.Division},{label:"Modal",value:K.Modal},{label:"Tabs",value:K.Tabs}],Kx=T.observer(({view:e})=>e?p(a.Stack,{sx:{position:"relative"},children:[n(a.TextInput,{label:"Name",value:e.name,onChange:t=>{e.setName(t.currentTarget.value)}}),n(a.Select,{label:"Type",withinPortal:!0,value:e.type,onChange:e.setType,data:Zx}),n(Xx,{view:e})]}):null),Jx=T.observer(({id:e})=>{const t=Pe.useModals(),r=B(),i=r.views.findByID(e);if(!i)return p(a.Text,{size:14,children:["View by ID[",e,"] is not found"]});const s=()=>{t.openConfirmModal({title:"Delete this view?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>r.views.removeByID(e),zIndex:320})};return p(a.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[n(a.Group,{position:"right",pt:10,children:n(a.Button,{size:"xs",color:"red",leftIcon:n(D.Trash,{size:16}),onClick:s,children:"Delete this view"})}),n(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n(Kx,{view:i})})]})});function Hx(e){return e.length===1&&e[0]==="_GLOBAL_VARS_"}function eC(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function tC(e){return e.length===2&&e[0]==="_FILTERS_"}function nC(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function rC(e){return e.length===2&&e[0]==="_QUERIES_"}function iC(e){return e.length===2&&e[0]==="_VIEWS_"}function aC(e){return e.length===4&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}const sC=T.observer(()=>n(a.Stack,{sx:{height:"100%"},p:"sm",children:n(Is,{})})),oC=T.observer(()=>{const e=B().editor,t=e.path;return Hx(t)?n(sC,{}):eC(t)?n(zy,{}):tC(t)?n(a.Box,{p:"xs",pl:20,children:n(Ay,{id:t[1]})}):nC(t)?n(qx,{id:t[1]}):rC(t)?n(Bx,{id:t[1]}):iC(t)?n(a.Box,{p:"xs",pl:20,children:n(Jx,{id:t[1]})}):aC(t)?n(ox,{viewID:t[1],panelID:t[3]}):n(a.Box,{children:e.path})}),lC=T.observer(()=>(B().editor,n(oC,{}))),uC=T.observer(()=>{const e=B(),t=()=>{const r=new Date().getTime().toString(),i={id:r,key:r,label:r,order:e.filters.current.length+1,type:tr.TextInput,config:Qa(),visibleInViewsIDs:["Main"],auto_submit:!1};e.filters.append(i)};return n(a.Button,{variant:"subtle",leftIcon:n(V.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Filter"})}),dC=T.observer(({parentID:e})=>{const t=B();if(!e)return null;const r=t.views.findByID(e);return r?n(a.Button,{variant:"subtle",leftIcon:n(V.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>t.addANewPanel(r.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Panel"}):null}),cC=T.observer(()=>{const e=B(),t=()=>{const r=new Date().getTime().toString(),i={id:r,name:r,type:ce.Postgresql,key:"",sql:""};e.queries.append(i)};return n(a.Button,{variant:"subtle",leftIcon:n(V.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Query"})}),pC=T.observer(()=>{const e=B(),t=()=>{const i={key:new Date().getTime().toString(),value:""};e.sqlSnippets.append(i)};return n(a.Button,{variant:"subtle",leftIcon:n(V.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a SQL Snippet"})}),hC=T.observer(()=>{const e=B();return n(a.Button,{variant:"subtle",leftIcon:n(V.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a View"})}),fC=T.observer(({action_type:e,parentID:t})=>(B(),e==="_Add_A_Filter_"?n(uC,{}):e==="_Add_A_SQL_SNIPPET_"?n(pC,{}):e==="_Add_A_QUERY_"?n(cC,{}):e==="_Add_A_VIEW_"?n(hC,{}):e==="_Add_A_PANEL_"?n(dC,{parentID:t}):null)),zs=T.observer(({option:e})=>{var c;const t=B().editor,r=t.isOptionActive,i=r(t.path,e),s=t.isOptionOpened,o=t.navigate,u=s(e),[l,d]=m.useState(u);return m.useEffect(()=>{d(u)},[u]),n(a.NavLink,{active:i,defaultOpened:u,opened:l,onChange:d,label:e.label,onClick:()=>o(e),icon:e.Icon?n(e.Icon,{size:18}):null,children:(c=e.children)==null?void 0:c.map(f=>f._type==="ACTION"?n(fC,{action_type:f._action_type,parentID:f.parentID},`_ADD_${f.value}_`):n(zs,{option:f},f.value))},e.label)}),gC=T.observer(()=>{const e=B();return n(a.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>n(zs,{option:t},t.value))})}),mC=T.observer(()=>{const e=B();return p(a.Navbar,{p:0,width:{base:200,xs:200,sm:220,md:240,lg:280,xl:300},sx:{height:"100vh - 60px - 60px"},children:[n(a.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n(a.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Settings"})}),n(a.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:n(gC,{})}),n(a.Navbar.Section,{children:n(a.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n(a.Button,{size:"xs",color:"red",leftIcon:n(V.IconX,{size:18}),onClick:()=>e.editor.close(),children:"Close"})})})]})}),bC={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},vC=T.observer(()=>{const e=B().editor;return n(a.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionDuration:0,withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{modal:{padding:"0 !important"}},children:n(a.AppShell,{padding:0,navbar:n(mC,{}),styles:bC,children:n(lC,{})})})}),yC=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function xC(e){m.useEffect(()=>{if(_e.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const r=yC(e);_e.loader.config({paths:{vs:r}}),_e.loader.init().then(i=>console.log("monaco instance:",i))},[])}const $s={grid:{axis:"#97999D",scope:"rgba(47,140,192,0.1)",boundary:"#789AB4",reference:"#CFCFD8"},graphics:{compared:{blueDark:"#3E7CAB",blue:"#6398C7",blueLight:"#7CB0DF",blue10:"#6398C71a",redDark:"#AF5F6B",red:"#CD7C88",redLight:"#E794A0",red10:"#CD7C881a"},gradient:{distributed:"linear-gradient(90deg, #1babe6 0%, #2fc8c8 28.63%, #98d44b 48.86%, #ffd057 67.53%, #f5ae53 80.6%, #e76441 91.18%, #b90000 100%)",protrude:"linear-gradient(180deg, #ec73734d 0%, #ec737300 100%)"},level:{lv0:"#6398C7",lv1:"#61B5BF",lv2:"#54D4BB",lv3:"#F5D277",lv4:"#E8BB7F",lv5:"#DB9E84",lv6:"#CB8089"},depth:{dp0:"#FFF7F8",dp1:"#FFE1E1",dp2:"#FDBCBC",dp3:"#F39494",dp4:"#FA4242",dp5:"#E21212"},multiple:{c1:"#66B4DB",c2:"#E46464",c3:"#EEBA00",c4:"#33A678",c5:"#9D88CB",c6:"#939943",c7:"#E49792",c8:"#09A2B8",c9:"#AF5F6B",c10:"#6CA157",c11:"#3E7CAB",c12:"#6398C7",c13:"#E692BA",c14:"#97B566",c15:"#8CACE2",c16:"#CA79AC",c17:"#6DBC80",c18:"#B08F4B",c19:"#39BFA2",c20:"#826BAF"}}};function CC(){oe.registerTheme("merico-light",{color:Object.values($s.graphics.multiple),visualMap:{color:Object.values($s.graphics.depth).reverse()}})}function Es(){CC()}Es();const wC={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60,height:"100vh"}},_C=T.observer(m.forwardRef(function({context:t,dashboard:r,update:i,className:s="dashboard",config:o,onChange:u,headerSlot:l},d){xC(o.monacoPath),Na(o);const{data:c=[]}=Z.useRequest(sr),[f,g]=m.useState(!1),h=m.useMemo(()=>ur(r,c,t),[r]);m.useImperativeHandle(d,()=>h,[h]),Si(h,!0),m.useEffect(()=>{h.context.replace(t)},[t]),m.useEffect(()=>{h.datasources.replace(c)},[c]),m.useEffect(()=>ae.reaction(()=>ae.toJS(h.json),S=>{u==null||u(S)}),[h]);const b=async()=>{await i(h.json)},w=Z.useCreation(Hn,[]),C=dr(w);return n(Pe.ModalsProvider,{children:n(mn,{value:h,children:n(Xe.Provider,{value:{layoutFrozen:f,freezeLayout:g,inEditMode:!0},children:n(Ne.Provider,{value:w,children:p(Bt,{configure:C,children:[n(a.AppShell,{padding:0,header:n(Wv,{saveDashboardChanges:b,headerSlot:l}),navbar:n(gy,{}),styles:wC,children:n(a.Box,{className:`${s} dashboard-root`,sx:{position:"relative"},children:h.views.visibleViews.map(S=>n(Ba,{view:S},S.id))})}),n(vC,{})]})})})})})})),yw="";Es();const SC=T.observer(({context:e,dashboard:t,className:r="dashboard",config:i,fullScreenPanelID:s,setFullScreenPanelID:o})=>{Na(i);const{data:u=[]}=Z.useRequest(sr),l=m.useMemo(()=>ur(t,u,e),[t]);Si(l,!1),m.useEffect(()=>{l.context.replace(e)},[e]),m.useEffect(()=>{l.datasources.replace(u)},[u]);const d=Z.useCreation(Hn,[]),c=dr(d);return n(Pe.ModalsProvider,{children:n(mn,{value:l,children:n(yn.Provider,{value:{fullScreenPanelID:s,setFullScreenPanelID:o},children:n(Xe.Provider,{value:{layoutFrozen:!0,freezeLayout:y.noop,inEditMode:!1},children:n(a.Box,{className:`${r} dashboard-root`,children:n(Ne.Provider,{value:d,children:n(Bt,{configure:c,children:l.views.visibleViews.map(f=>n(en,{view:f},f.id))})})})})})})})});var vr={},TC={get exports(){return vr},set exports(e){vr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){var o=i.prototype,u=o.format;s.en.ordinal=function(l){var d=["th","st","nd","rd"],c=l%100;return"["+l+(d[(c-20)%10]||d[c]||d[0])+"]"},o.format=function(l){var d=this,c=this.$locale();if(!this.isValid())return u.bind(this)(l);var f=this.$utils(),g=(l||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(h){switch(h){case"Q":return Math.ceil((d.$M+1)/3);case"Do":return c.ordinal(d.$D);case"gggg":return d.weekYear();case"GGGG":return d.isoWeekYear();case"wo":return c.ordinal(d.week(),"W");case"w":case"ww":return f.s(d.week(),h==="w"?1:2,"0");case"W":case"WW":return f.s(d.isoWeek(),h==="W"?1:2,"0");case"k":case"kk":return f.s(String(d.$H===0?24:d.$H),h==="k"?1:2,"0");case"X":return Math.floor(d.$d.getTime()/1e3);case"x":return d.$d.getTime();case"z":return"["+d.offsetName()+"]";case"zzz":return"["+d.offsetName("long")+"]";default:return h}});return u.bind(this)(g)}}})})(TC);const DC=vr;var yr={},kC={get exports(){return yr},set exports(e){yr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){var o=i.prototype,u=function(d){var c=d.date,f=d.utc;return Array.isArray(c)?f?c.length?new Date(Date.UTC.apply(null,c)):new Date:c.length===1?s(String(c[0])).toDate():new(Function.prototype.bind.apply(Date,[null].concat(c))):c},l=o.parse;o.parse=function(d){d.date=u.bind(this)(d),l.bind(this)(d)}}})})(kC);const IC=yr;var xr={},MC={get exports(){return xr},set exports(e){xr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){var s=i.prototype;s.$g=function(h,b,w){return this.$utils().u(h)?this[b]:this.$set(w,h)},s.set=function(h,b){return this.$set(h,b)};var o=s.startOf;s.startOf=function(h,b){return this.$d=o.bind(this)(h,b).toDate(),this.init(),this};var u=s.add;s.add=function(h,b){return this.$d=u.bind(this)(h,b).toDate(),this.init(),this};var l=s.locale;s.locale=function(h,b){return h?(this.$L=l.bind(this)(h,b).$L,this):this.$L};var d=s.daysInMonth;s.daysInMonth=function(){return d.bind(this.clone())()};var c=s.isSame;s.isSame=function(h,b){return c.bind(this.clone())(h,b)};var f=s.isBefore;s.isBefore=function(h,b){return f.bind(this.clone())(h,b)};var g=s.isAfter;s.isAfter=function(h,b){return g.bind(this.clone())(h,b)}}})})(MC);const AC=xr;var Cr={},zC={get exports(){return Cr},set exports(e){Cr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){var s=i.prototype,o=s.format;s.format=function(u){var l=this,d=(u||"YYYY-MM-DDTHH:mm:ssZ").replace(/(\[[^\]]+])|BBBB|BB/g,function(c,f){var g,h=String(l.$y+543),b=c==="BB"?[h.slice(-2),2]:[h,4];return f||(g=l.$utils()).s.apply(g,b.concat(["0"]))});return o.bind(this)(d)}}})})(zC);const $C=Cr;var wr={},EC={get exports(){return wr},set exports(e){wr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){var o="h:mm A",u={lastDay:"[Yesterday at] "+o,sameDay:"[Today at] "+o,nextDay:"[Tomorrow at] "+o,nextWeek:"dddd [at] "+o,lastWeek:"[Last] dddd [at] "+o,sameElse:"MM/DD/YYYY"};i.prototype.calendar=function(l,d){var c=d||this.$locale().calendar||u,f=s(l||void 0).startOf("d"),g=this.diff(f,"d",!0),h="sameElse",b=g<-6?h:g<-1?"lastWeek":g<0?"lastDay":g<1?"sameDay":g<2?"nextDay":g<7?"nextWeek":h,w=c[b]||u[b];return typeof w=="function"?w.call(this,s()):this.format(w)}}})})(EC);const LC=wr;var _r={},PC={get exports(){return _r},set exports(e){_r=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},i=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,s=/\d\d/,o=/\d\d?/,u=/\d*[^-_:/,()\s\d]+/,l={},d=function(C){return(C=+C)+(C>68?1900:2e3)},c=function(C){return function(S){this[C]=+S}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(C){(this.zone||(this.zone={})).offset=function(S){if(!S||S==="Z")return 0;var A=S.match(/([+-]|\d\d)/g),z=60*A[1]+(+A[2]||0);return z===0?0:A[0]==="+"?-z:z}(C)}],g=function(C){var S=l[C];return S&&(S.indexOf?S:S.s.concat(S.f))},h=function(C,S){var A,z=l.meridiem;if(z){for(var G=1;G<=24;G+=1)if(C.indexOf(z(G,0,S))>-1){A=G>12;break}}else A=C===(S?"pm":"PM");return A},b={A:[u,function(C){this.afternoon=h(C,!1)}],a:[u,function(C){this.afternoon=h(C,!0)}],S:[/\d/,function(C){this.milliseconds=100*+C}],SS:[s,function(C){this.milliseconds=10*+C}],SSS:[/\d{3}/,function(C){this.milliseconds=+C}],s:[o,c("seconds")],ss:[o,c("seconds")],m:[o,c("minutes")],mm:[o,c("minutes")],H:[o,c("hours")],h:[o,c("hours")],HH:[o,c("hours")],hh:[o,c("hours")],D:[o,c("day")],DD:[s,c("day")],Do:[u,function(C){var S=l.ordinal,A=C.match(/\d+/);if(this.day=A[0],S)for(var z=1;z<=31;z+=1)S(z).replace(/\[|\]/g,"")===C&&(this.day=z)}],M:[o,c("month")],MM:[s,c("month")],MMM:[u,function(C){var S=g("months"),A=(g("monthsShort")||S.map(function(z){return z.slice(0,3)})).indexOf(C)+1;if(A<1)throw new Error;this.month=A%12||A}],MMMM:[u,function(C){var S=g("months").indexOf(C)+1;if(S<1)throw new Error;this.month=S%12||S}],Y:[/[+-]?\d+/,c("year")],YY:[s,function(C){this.year=d(C)}],YYYY:[/\d{4}/,c("year")],Z:f,ZZ:f};function w(C){var S,A;S=C,A=l&&l.formats;for(var z=(C=S.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(Q,Y,te){var re=te&&te.toUpperCase();return Y||A[te]||r[te]||A[re].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(se,ne,pe){return ne||pe.slice(1)})})).match(i),G=z.length,F=0;F<G;F+=1){var L=z[F],$=b[L],M=$&&$[0],N=$&&$[1];z[F]=N?{regex:M,parser:N}:L.replace(/^\[|\]$/g,"")}return function(Q){for(var Y={},te=0,re=0;te<G;te+=1){var se=z[te];if(typeof se=="string")re+=se.length;else{var ne=se.regex,pe=se.parser,he=Q.slice(re),we=ne.exec(he)[0];pe.call(Y,we),Q=Q.replace(we,"")}}return function(qe){var ke=qe.afternoon;if(ke!==void 0){var Re=qe.hours;ke?Re<12&&(qe.hours+=12):Re===12&&(qe.hours=0),delete qe.afternoon}}(Y),Y}}return function(C,S,A){A.p.customParseFormat=!0,C&&C.parseTwoDigitYear&&(d=C.parseTwoDigitYear);var z=S.prototype,G=z.parse;z.parse=function(F){var L=F.date,$=F.utc,M=F.args;this.$u=$;var N=M[1];if(typeof N=="string"){var Q=M[2]===!0,Y=M[3]===!0,te=Q||Y,re=M[2];Y&&(re=M[2]),l=this.$locale(),!Q&&re&&(l=A.Ls[re]),this.$d=function(he,we,qe){try{if(["x","X"].indexOf(we)>-1)return new Date((we==="X"?1e3:1)*he);var ke=w(we)(he),Re=ke.year,rt=ke.month,un=ke.day,dn=ke.hours,Jr=ke.minutes,Hr=ke.seconds,It=ke.milliseconds,pt=ke.zone,He=new Date,it=un||(Re||rt?1:He.getDate()),et=Re||He.getFullYear(),ht=0;Re&&!rt||(ht=rt>0?rt-1:He.getMonth());var ft=dn||0,Mt=Jr||0,At=Hr||0,tt=It||0;return pt?new Date(Date.UTC(et,ht,it,ft,Mt,At,tt+60*pt.offset*1e3)):qe?new Date(Date.UTC(et,ht,it,ft,Mt,At,tt)):new Date(et,ht,it,ft,Mt,At,tt)}catch{return new Date("")}}(L,N,$),this.init(),re&&re!==!0&&(this.$L=this.locale(re).$L),te&&L!=this.format(N)&&(this.$d=new Date("")),l={}}else if(N instanceof Array)for(var se=N.length,ne=1;ne<=se;ne+=1){M[1]=N[ne-1];var pe=A.apply(this,M);if(pe.isValid()){this.$d=pe.$d,this.$L=pe.$L,this.init();break}ne===se&&(this.$d=new Date(""))}else G.call(this,F)}}})})(PC);const OC=_r;var Sr={},VC={get exports(){return Sr},set exports(e){Sr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){i.prototype.dayOfYear=function(o){var u=Math.round((s(this).startOf("day")-s(this).startOf("year"))/864e5)+1;return o==null?u:this.add(o-u,"day")}}})})(VC);const BC=Sr;var Tr={},NC={get exports(){return Tr},set exports(e){Tr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r,i,s=1e3,o=6e4,u=36e5,l=864e5,d=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,c=31536e6,f=2592e6,g=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,h={years:c,months:f,days:l,hours:u,minutes:o,seconds:s,milliseconds:1,weeks:6048e5},b=function(L){return L instanceof F},w=function(L,$,M){return new F(L,M,$.$l)},C=function(L){return i.p(L)+"s"},S=function(L){return L<0},A=function(L){return S(L)?Math.ceil(L):Math.floor(L)},z=function(L){return Math.abs(L)},G=function(L,$){return L?S(L)?{negative:!0,format:""+z(L)+$}:{negative:!1,format:""+L+$}:{negative:!1,format:""}},F=function(){function L(M,N,Q){var Y=this;if(this.$d={},this.$l=Q,M===void 0&&(this.$ms=0,this.parseFromMilliseconds()),N)return w(M*h[C(N)],this);if(typeof M=="number")return this.$ms=M,this.parseFromMilliseconds(),this;if(typeof M=="object")return Object.keys(M).forEach(function(se){Y.$d[C(se)]=M[se]}),this.calMilliseconds(),this;if(typeof M=="string"){var te=M.match(g);if(te){var re=te.slice(2).map(function(se){return se!=null?Number(se):0});return this.$d.years=re[0],this.$d.months=re[1],this.$d.weeks=re[2],this.$d.days=re[3],this.$d.hours=re[4],this.$d.minutes=re[5],this.$d.seconds=re[6],this.calMilliseconds(),this}}return this}var $=L.prototype;return $.calMilliseconds=function(){var M=this;this.$ms=Object.keys(this.$d).reduce(function(N,Q){return N+(M.$d[Q]||0)*h[Q]},0)},$.parseFromMilliseconds=function(){var M=this.$ms;this.$d.years=A(M/c),M%=c,this.$d.months=A(M/f),M%=f,this.$d.days=A(M/l),M%=l,this.$d.hours=A(M/u),M%=u,this.$d.minutes=A(M/o),M%=o,this.$d.seconds=A(M/s),M%=s,this.$d.milliseconds=M},$.toISOString=function(){var M=G(this.$d.years,"Y"),N=G(this.$d.months,"M"),Q=+this.$d.days||0;this.$d.weeks&&(Q+=7*this.$d.weeks);var Y=G(Q,"D"),te=G(this.$d.hours,"H"),re=G(this.$d.minutes,"M"),se=this.$d.seconds||0;this.$d.milliseconds&&(se+=this.$d.milliseconds/1e3);var ne=G(se,"S"),pe=M.negative||N.negative||Y.negative||te.negative||re.negative||ne.negative,he=te.format||re.format||ne.format?"T":"",we=(pe?"-":"")+"P"+M.format+N.format+Y.format+he+te.format+re.format+ne.format;return we==="P"||we==="-P"?"P0D":we},$.toJSON=function(){return this.toISOString()},$.format=function(M){var N=M||"YYYY-MM-DDTHH:mm:ss",Q={Y:this.$d.years,YY:i.s(this.$d.years,2,"0"),YYYY:i.s(this.$d.years,4,"0"),M:this.$d.months,MM:i.s(this.$d.months,2,"0"),D:this.$d.days,DD:i.s(this.$d.days,2,"0"),H:this.$d.hours,HH:i.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:i.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:i.s(this.$d.seconds,2,"0"),SSS:i.s(this.$d.milliseconds,3,"0")};return N.replace(d,function(Y,te){return te||String(Q[Y])})},$.as=function(M){return this.$ms/h[C(M)]},$.get=function(M){var N=this.$ms,Q=C(M);return Q==="milliseconds"?N%=1e3:N=Q==="weeks"?A(N/h[Q]):this.$d[Q],N===0?0:N},$.add=function(M,N,Q){var Y;return Y=N?M*h[C(N)]:b(M)?M.$ms:w(M,this).$ms,w(this.$ms+Y*(Q?-1:1),this)},$.subtract=function(M,N){return this.add(M,N,!0)},$.locale=function(M){var N=this.clone();return N.$l=M,N},$.clone=function(){return w(this.$ms,this)},$.humanize=function(M){return r().add(this.$ms,"ms").locale(this.$l).fromNow(!M)},$.milliseconds=function(){return this.get("milliseconds")},$.asMilliseconds=function(){return this.as("milliseconds")},$.seconds=function(){return this.get("seconds")},$.asSeconds=function(){return this.as("seconds")},$.minutes=function(){return this.get("minutes")},$.asMinutes=function(){return this.as("minutes")},$.hours=function(){return this.get("hours")},$.asHours=function(){return this.as("hours")},$.days=function(){return this.get("days")},$.asDays=function(){return this.as("days")},$.weeks=function(){return this.get("weeks")},$.asWeeks=function(){return this.as("weeks")},$.months=function(){return this.get("months")},$.asMonths=function(){return this.as("months")},$.years=function(){return this.get("years")},$.asYears=function(){return this.as("years")},L}();return function(L,$,M){r=M,i=M().$utils(),M.duration=function(Y,te){var re=M.locale();return w(Y,{$l:re},te)},M.isDuration=b;var N=$.prototype.add,Q=$.prototype.subtract;$.prototype.add=function(Y,te){return b(Y)&&(Y=Y.asMilliseconds()),N.bind(this)(Y,te)},$.prototype.subtract=function(Y,te){return b(Y)&&(Y=Y.asMilliseconds()),Q.bind(this)(Y,te)}}})})(NC);const GC=Tr;var Dr={},qC={get exports(){return Dr},set exports(e){Dr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){i.prototype.isBetween=function(o,u,l,d){var c=s(o),f=s(u),g=(d=d||"()")[0]==="(",h=d[1]===")";return(g?this.isAfter(c,l):!this.isBefore(c,l))&&(h?this.isBefore(f,l):!this.isAfter(f,l))||(g?this.isBefore(c,l):!this.isAfter(c,l))&&(h?this.isAfter(f,l):!this.isBefore(f,l))}}})})(qC);const FC=Dr;var kr={},WC={get exports(){return kr},set exports(e){kr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}})})(WC);const jC=kr;var Ir={},RC={get exports(){return Ir},set exports(e){Ir=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){s.isMoment=function(o){return s.isDayjs(o)}}})})(RC);const YC=Ir;var Mr={},QC={get exports(){return Mr},set exports(e){Mr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r="day";return function(i,s,o){var u=function(c){return c.add(4-c.isoWeekday(),r)},l=s.prototype;l.isoWeekYear=function(){return u(this).year()},l.isoWeek=function(c){if(!this.$utils().u(c))return this.add(7*(c-this.isoWeek()),r);var f,g,h,b,w=u(this),C=(f=this.isoWeekYear(),g=this.$u,h=(g?o.utc:o)().year(f).startOf("year"),b=4-h.isoWeekday(),h.isoWeekday()>4&&(b+=7),h.add(b,r));return w.diff(C,"week")+1},l.isoWeekday=function(c){return this.$utils().u(c)?this.day()||7:this.day(this.day()%7?c:c-7)};var d=l.startOf;l.startOf=function(c,f){var g=this.$utils(),h=!!g.u(f)||f;return g.p(c)==="isoweek"?h?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):d.bind(this)(c,f)}}})})(QC);const UC=Mr;var Ar={},XC={get exports(){return Ar},set exports(e){Ar=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.isoWeeksInYear=function(){var s=this.isLeapYear(),o=this.endOf("y").day();return o===4||s&&o===5?53:52}}})})(XC);const ZC=Ar;var zr={},KC={get exports(){return zr},set exports(e){zr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.isSameOrAfter=function(s,o){return this.isSame(s,o)||this.isAfter(s,o)}}})})(KC);const JC=zr;var $r={},HC={get exports(){return $r},set exports(e){$r=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.isSameOrBefore=function(s,o){return this.isSame(s,o)||this.isBefore(s,o)}}})})(HC);const e0=$r;var Er={},t0={get exports(){return Er},set exports(e){Er=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){i.prototype.isToday=function(){var o="YYYY-MM-DD",u=s();return this.format(o)===u.format(o)}}})})(t0);const n0=Er;var Lr={},r0={get exports(){return Lr},set exports(e){Lr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){i.prototype.isTomorrow=function(){var o="YYYY-MM-DD",u=s().add(1,"day");return this.format(o)===u.format(o)}}})})(r0);const i0=Lr;var Pr={},a0={get exports(){return Pr},set exports(e){Pr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){i.prototype.isYesterday=function(){var o="YYYY-MM-DD",u=s().subtract(1,"day");return this.format(o)===u.format(o)}}})})(a0);const s0=Pr;var Or={},o0={get exports(){return Or},set exports(e){Or=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){var o=i.prototype,u=function(g){return g&&(g.indexOf?g:g.s)},l=function(g,h,b,w,C){var S=g.name?g:g.$locale(),A=u(S[h]),z=u(S[b]),G=A||z.map(function(L){return L.slice(0,w)});if(!C)return G;var F=S.weekStart;return G.map(function(L,$){return G[($+(F||0))%7]})},d=function(){return s.Ls[s.locale()]},c=function(g,h){return g.formats[h]||function(b){return b.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(w,C,S){return C||S.slice(1)})}(g.formats[h.toUpperCase()])},f=function(){var g=this;return{months:function(h){return h?h.format("MMMM"):l(g,"months")},monthsShort:function(h){return h?h.format("MMM"):l(g,"monthsShort","months",3)},firstDayOfWeek:function(){return g.$locale().weekStart||0},weekdays:function(h){return h?h.format("dddd"):l(g,"weekdays")},weekdaysMin:function(h){return h?h.format("dd"):l(g,"weekdaysMin","weekdays",2)},weekdaysShort:function(h){return h?h.format("ddd"):l(g,"weekdaysShort","weekdays",3)},longDateFormat:function(h){return c(g.$locale(),h)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};o.localeData=function(){return f.bind(this)()},s.localeData=function(){var g=d();return{firstDayOfWeek:function(){return g.weekStart||0},weekdays:function(){return s.weekdays()},weekdaysShort:function(){return s.weekdaysShort()},weekdaysMin:function(){return s.weekdaysMin()},months:function(){return s.months()},monthsShort:function(){return s.monthsShort()},longDateFormat:function(h){return c(g,h)},meridiem:g.meridiem,ordinal:g.ordinal}},s.months=function(){return l(d(),"months")},s.monthsShort=function(){return l(d(),"monthsShort","months",3)},s.weekdays=function(g){return l(d(),"weekdays",null,null,g)},s.weekdaysShort=function(g){return l(d(),"weekdaysShort","weekdays",3,g)},s.weekdaysMin=function(g){return l(d(),"weekdaysMin","weekdays",2,g)}}})})(o0);const l0=Or;var Vr={},u0={get exports(){return Vr},set exports(e){Vr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(i,s,o){var u=s.prototype,l=u.format;o.en.formats=r,u.format=function(d){d===void 0&&(d="YYYY-MM-DDTHH:mm:ssZ");var c=this.$locale().formats,f=function(g,h){return g.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(b,w,C){var S=C&&C.toUpperCase();return w||h[C]||r[C]||h[S].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(A,z,G){return z||G.slice(1)})})}(d,c===void 0?{}:c);return l.call(this,f)}}})})(u0);const d0=Vr;var Br={},c0={get exports(){return Br},set exports(e){Br=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){var o=function(u,l){if(!l||!l.length||!l[0]||l.length===1&&!l[0].length)return null;var d;l.length===1&&l[0].length>0&&(l=l[0]),d=l[0];for(var c=1;c<l.length;c+=1)l[c].isValid()&&!l[c][u](d)||(d=l[c]);return d};s.max=function(){var u=[].slice.call(arguments,0);return o("isAfter",u)},s.min=function(){var u=[].slice.call(arguments,0);return o("isBefore",u)}}})})(c0);const p0=Br;var Nr={},h0={get exports(){return Nr},set exports(e){Nr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){var o=i.prototype,u=function(g){var h,b=g.date,w=g.utc,C={};if(!((h=b)instanceof Date)&&!(h instanceof Array)&&h instanceof Object){if(!Object.keys(b).length)return new Date;var S=w?s.utc():s();Object.keys(b).forEach(function(N){var Q,Y;C[Q=N,Y=o.$utils().p(Q),Y==="date"?"day":Y]=b[N]});var A=C.day||(C.year||C.month>=0?1:S.date()),z=C.year||S.year(),G=C.month>=0?C.month:C.year||C.day?0:S.month(),F=C.hour||0,L=C.minute||0,$=C.second||0,M=C.millisecond||0;return w?new Date(Date.UTC(z,G,A,F,L,$,M)):new Date(z,G,A,F,L,$,M)}return b},l=o.parse;o.parse=function(g){g.date=u.bind(this)(g),l.bind(this)(g)};var d=o.set,c=o.add,f=function(g,h,b,w){if(w===void 0&&(w=1),h instanceof Object){var C=Object.keys(h),S=this;return C.forEach(function(A){S=g.bind(S)(h[A]*w,A)}),S}return g.bind(this)(h*w,b)};o.set=function(g,h){return h=h===void 0?g:h,f.bind(this)(function(b,w){return d.bind(this)(w,b)},h,g)},o.add=function(g,h){return f.bind(this)(c,g,h)},o.subtract=function(g,h){return f.bind(this)(c,g,h,-1)}}})})(h0);const f0=Nr;var Gr={},g0={get exports(){return Gr},set exports(e){Gr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){var s=i.prototype;["milliseconds","seconds","minutes","hours","days","weeks","isoWeeks","months","quarters","years","dates"].forEach(function(o){s[o]=s[o.replace(/s$/,"")]})}})})(g0);const m0=Gr;var qr={},b0={get exports(){return qr},set exports(e){qr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){var s=i.prototype.parse;i.prototype.parse=function(l){if(typeof l.date=="string"){var d=this.$locale();l.date=d&&d.preparse?d.preparse(l.date):l.date}return s.bind(this)(l)};var o=i.prototype.format;i.prototype.format=function(){for(var l=arguments.length,d=new Array(l),c=0;c<l;c++)d[c]=arguments[c];var f=o.call.apply(o,[this].concat(d)),g=this.$locale();return g&&g.postformat?g.postformat(f):f};var u=i.prototype.fromToBase;u&&(i.prototype.fromToBase=function(l,d,c,f){var g=this.$locale()||c.$locale();return u.call(this,l,d,c,f,g&&g.postformat)})}})})(b0);const v0=qr;var Fr={},y0={get exports(){return Fr},set exports(e){Fr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r="month",i="quarter";return function(s,o){var u=o.prototype;u.quarter=function(c){return this.$utils().u(c)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(c-1))};var l=u.add;u.add=function(c,f){return c=Number(c),this.$utils().p(f)===i?this.add(3*c,r):l.bind(this)(c,f)};var d=u.startOf;u.startOf=function(c,f){var g=this.$utils(),h=!!g.u(f)||f;if(g.p(c)===i){var b=this.quarter()-1;return h?this.month(3*b).startOf(r).startOf("day"):this.month(3*b+2).endOf(r).endOf("day")}return d.bind(this)(c,f)}}})})(y0);const x0=Fr;var Wr={},C0={get exports(){return Wr},set exports(e){Wr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){r=r||{};var o=i.prototype,u={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function l(c,f,g,h){return o.fromToBase(c,f,g,h)}s.en.relativeTime=u,o.fromToBase=function(c,f,g,h,b){for(var w,C,S,A=g.$locale().relativeTime||u,z=r.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],G=z.length,F=0;F<G;F+=1){var L=z[F];L.d&&(w=h?s(c).diff(g,L.d,!0):g.diff(c,L.d,!0));var $=(r.rounding||Math.round)(Math.abs(w));if(S=w>0,$<=L.r||!L.r){$<=1&&F>0&&(L=z[F-1]);var M=A[L.l];b&&($=b(""+$)),C=typeof M=="string"?M.replace("%d",$):M($,f,L.l,S);break}}if(f)return C;var N=S?A.future:A.past;return typeof N=="function"?N(C):N.replace("%s",C)},o.to=function(c,f){return l(c,f,this,!0)},o.from=function(c,f){return l(c,f,this)};var d=function(c){return c.$u?s.utc():s()};o.toNow=function(c){return this.to(d(this),c)},o.fromNow=function(c){return this.from(d(this),c)}}})})(C0);const w0=Wr;var jr={},_0={get exports(){return jr},set exports(e){jr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r={year:0,month:1,day:2,hour:3,minute:4,second:5},i={};return function(s,o,u){var l,d=function(h,b,w){w===void 0&&(w={});var C=new Date(h),S=function(A,z){z===void 0&&(z={});var G=z.timeZoneName||"short",F=A+"|"+G,L=i[F];return L||(L=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:A,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:G}),i[F]=L),L}(b,w);return S.formatToParts(C)},c=function(h,b){for(var w=d(h,b),C=[],S=0;S<w.length;S+=1){var A=w[S],z=A.type,G=A.value,F=r[z];F>=0&&(C[F]=parseInt(G,10))}var L=C[3],$=L===24?0:L,M=C[0]+"-"+C[1]+"-"+C[2]+" "+$+":"+C[4]+":"+C[5]+":000",N=+h;return(u.utc(M).valueOf()-(N-=N%1e3))/6e4},f=o.prototype;f.tz=function(h,b){h===void 0&&(h=l);var w=this.utcOffset(),C=this.toDate(),S=C.toLocaleString("en-US",{timeZone:h}),A=Math.round((C-new Date(S))/1e3/60),z=u(S).$set("millisecond",this.$ms).utcOffset(15*-Math.round(C.getTimezoneOffset()/15)-A,!0);if(b){var G=z.utcOffset();z=z.add(w-G,"minute")}return z.$x.$timezone=h,z},f.offsetName=function(h){var b=this.$x.$timezone||u.tz.guess(),w=d(this.valueOf(),b,{timeZoneName:h}).find(function(C){return C.type.toLowerCase()==="timezonename"});return w&&w.value};var g=f.startOf;f.startOf=function(h,b){if(!this.$x||!this.$x.$timezone)return g.call(this,h,b);var w=u(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return g.call(w,h,b).tz(this.$x.$timezone,!0)},u.tz=function(h,b,w){var C=w&&b,S=w||b||l,A=c(+u(),S);if(typeof h!="string")return u(h).tz(S);var z=function($,M,N){var Q=$-60*M*1e3,Y=c(Q,N);if(M===Y)return[Q,M];var te=c(Q-=60*(Y-M)*1e3,N);return Y===te?[Q,Y]:[$-60*Math.min(Y,te)*1e3,Math.max(Y,te)]}(u.utc(h,C).valueOf(),A,S),G=z[0],F=z[1],L=u(G).utcOffset(F);return L.$x.$timezone=S,L},u.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},u.tz.setDefault=function(h){l=h}}})})(_0);const S0=jr;var Rr={},T0={get exports(){return Rr},set exports(e){Rr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.toArray=function(){return[this.$y,this.$M,this.$D,this.$H,this.$m,this.$s,this.$ms]}}})})(T0);const D0=Rr;var Yr={},k0={get exports(){return Yr},set exports(e){Yr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.toObject=function(){return{years:this.$y,months:this.$M,date:this.$D,hours:this.$H,minutes:this.$m,seconds:this.$s,milliseconds:this.$ms}}}})})(k0);const I0=Yr;var Qr={},M0={get exports(){return Qr},set exports(e){Qr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){s.updateLocale=function(o,u){var l=s.Ls[o];if(l)return(u?Object.keys(u):[]).forEach(function(d){l[d]=u[d]}),l}}})})(M0);const A0=Qr;var Ur={},z0={get exports(){return Ur},set exports(e){Ur=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r="minute",i=/[+-]\d\d(?::?\d\d)?/g,s=/([+-]|\d\d)/g;return function(o,u,l){var d=u.prototype;l.utc=function(C){var S={date:C,utc:!0,args:arguments};return new u(S)},d.utc=function(C){var S=l(this.toDate(),{locale:this.$L,utc:!0});return C?S.add(this.utcOffset(),r):S},d.local=function(){return l(this.toDate(),{locale:this.$L,utc:!1})};var c=d.parse;d.parse=function(C){C.utc&&(this.$u=!0),this.$utils().u(C.$offset)||(this.$offset=C.$offset),c.call(this,C)};var f=d.init;d.init=function(){if(this.$u){var C=this.$d;this.$y=C.getUTCFullYear(),this.$M=C.getUTCMonth(),this.$D=C.getUTCDate(),this.$W=C.getUTCDay(),this.$H=C.getUTCHours(),this.$m=C.getUTCMinutes(),this.$s=C.getUTCSeconds(),this.$ms=C.getUTCMilliseconds()}else f.call(this)};var g=d.utcOffset;d.utcOffset=function(C,S){var A=this.$utils().u;if(A(C))return this.$u?0:A(this.$offset)?g.call(this):this.$offset;if(typeof C=="string"&&(C=function(L){L===void 0&&(L="");var $=L.match(i);if(!$)return null;var M=(""+$[0]).match(s)||["-",0,0],N=M[0],Q=60*+M[1]+ +M[2];return Q===0?0:N==="+"?Q:-Q}(C),C===null))return this;var z=Math.abs(C)<=16?60*C:C,G=this;if(S)return G.$offset=z,G.$u=C===0,G;if(C!==0){var F=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(G=this.local().add(z+F,r)).$offset=z,G.$x.$localOffset=F}else G=this.utc();return G};var h=d.format;d.format=function(C){var S=C||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,S)},d.valueOf=function(){var C=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*C},d.isUTC=function(){return!!this.$u},d.toISOString=function(){return this.toDate().toISOString()},d.toString=function(){return this.toDate().toUTCString()};var b=d.toDate;d.toDate=function(C){return C==="s"&&this.$offset?l(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():b.call(this)};var w=d.diff;d.diff=function(C,S,A){if(C&&this.$u===C.$u)return w.call(this,C,S,A);var z=this.local(),G=l(C).local();return w.call(z,G,S,A)}}})})(z0);const $0=Ur;var Xr={},E0={get exports(){return Xr},set exports(e){Xr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.weekday=function(s){var o=this.$locale().weekStart||0,u=this.$W,l=(u<o?u+7:u)-o;return this.$utils().u(s)?l:this.subtract(l,"day").add(s,"day")}}})})(E0);const L0=Xr;var Zr={},P0={get exports(){return Zr},set exports(e){Zr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r="week",i="year";return function(s,o,u){var l=o.prototype;l.week=function(d){if(d===void 0&&(d=null),d!==null)return this.add(7*(d-this.week()),"day");var c=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var f=u(this).startOf(i).add(1,i).date(c),g=u(this).endOf(r);if(f.isBefore(g))return 1}var h=u(this).startOf(i).date(c).startOf(r).subtract(1,"millisecond"),b=this.diff(h,r,!0);return b<0?u(this).startOf("week").week():Math.ceil(b)},l.weeks=function(d){return d===void 0&&(d=null),this.week(d)}}})})(P0);const O0=Zr;var Kr={},V0={get exports(){return Kr},set exports(e){Kr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.weekYear=function(){var s=this.month(),o=this.week(),u=this.year();return o===1&&s===11?u+1:s===0&&o>=52?u-1:u}}})})(V0);const B0=Kr;W.extend(DC),W.extend(IC),W.extend(AC),W.extend($C),W.extend(LC),W.extend(OC),W.extend(BC),W.extend(GC),W.extend(FC),W.extend(jC),W.extend(YC),W.extend(JC),W.extend(e0),W.extend(n0),W.extend(i0),W.extend(s0),W.extend(UC),W.extend(ZC),W.extend(l0),W.extend(d0),W.extend(p0),W.extend(f0),W.extend(m0),W.extend(v0),W.extend(x0),W.extend(w0),W.extend(S0),W.extend(D0),W.extend(I0),W.extend(A0),W.extend($0),W.extend(O0),W.extend(B0),W.extend(L0),W.tz.setDefault("UTC");const N0=()=>Promise.resolve().then(()=>No).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));k.ContextModel=as,k.Dashboard=_C,k.DashboardFilterType=tr,k.DashboardMode=Oa,k.DashboardModel=rn,k.DashboardViewEditor=Ba,k.DashboardViewRender=en,k.EViewComponentType=K,k.FilterModel=rr,k.FiltersModel=Za,k.FullScreenPanelContext=yn,k.LayoutStateContext=Xe,k.ModelContextProvider=mn,k.Panel=Ht,k.PanelContextProvider=vn,k.PanelModel=ss,k.PanelsModel=ls,k.QueriesModel=ns,k.QueryModel=ts,k.ReadOnlyDashboard=SC,k.SQLSnippetModel=rs,k.SQLSnippetsModel=is,k.ViewComponentTypeBackground=Va,k.ViewComponentTypeColor=zb,k.ViewComponentTypeName=Ab,k.ViewModel=ps,k.ViewsModel=hs,k.applyPartialDashboard=Fv,k.createDashboardModel=ur,k.createDashboardViewsModel=lr,k.getInitialFiltersPayload=Ka,k.getNewPanel=os,k.getVersion=N0,k.useFullScreenPanelContext=Mi,k.useModelContext=B,k.usePanelContext=xe,k.useTopLevelServices=dr,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
390
+ `)},Px=T.observer(({queryModel:e})=>{const[t,r]=m.useState(e.sql);m.useEffect(()=>{r(o=>o!==e.sql?e.sql:o)},[e.sql]);const i=t!==e.sql,s=()=>{e.setSQL(t)};return e.typedAsSQL?p(a.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"Edit",children:p(a.Group,{spacing:14,position:"apart",children:["Edit SQL",n(a.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!i,onClick:s,children:n(D.DeviceFloppy,{size:20})})]})}),n(a.Tabs.Tab,{value:"Preview",children:"Preview SQL"}),n(a.Tabs.Tab,{value:"pre_process",children:"Process Request"}),n(a.Tabs.Tab,{value:"post_process",children:"Process Result"}),n(mr,{}),e.datasource&&n(ks,{dataSource:e.datasource})]}),n(a.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:n(br,{height:"100%",value:t,onChange:r})}),n(a.Tabs.Panel,{value:"Preview",p:0,pl:4,children:n(Lx,{value:e.sql})}),n(a.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:n(on,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:As.pre})}),n(a.Tabs.Panel,{value:"post_process",p:"sm",children:n(on,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:As.post})})]}):null}),Ox=T.observer(({queryID:e,usage:t})=>{const r=B().editor,i=o=>{if(o.type==="filter"){r.setPath(["_FILTERS_",o.id]);return}if(o.type==="panel"){const u=o.views[0].id;r.setPath(["_VIEWS_",u,"_PANELS_",o.id]);return}},s=o=>{r.setPath(["_VIEWS_",o])};return n(a.Stack,{py:"sm",px:"md",children:p(a.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n("thead",{children:p("tr",{children:[n("th",{style:{width:100},children:"Type"}),n("th",{style:{width:"calc(50% - 50px)"},children:"Name"}),n("th",{children:"In View(s)"})]})}),n("tbody",{children:t.map(o=>p("tr",{children:[n("td",{children:y.capitalize(o.type)}),n("td",{children:n(a.Anchor,{component:"button",type:"button",onClick:()=>i(o),children:o.label})}),n("td",{children:p(a.Stack,{align:"flex-start",justify:"flex-start",spacing:2,children:[o.views.map(u=>n(a.Anchor,{component:"button",type:"button",onClick:()=>s(u.id),children:n(a.Box,{children:u.label})})),o.views.length===0&&n(a.Box,{children:"--"})]})})]},o.id))})]})})}),ln={height:"calc(100% - 44px)",padding:0},Vx=T.observer(({queryModel:e})=>{const t=B(),r=m.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),i=t.findQueryUsage(e.id),s=i.length===0;return n(a.Stack,{sx:{flexGrow:1},my:0,p:0,children:p(a.Tabs,{defaultValue:r,orientation:"horizontal",keepMounted:!1,sx:{flexGrow:1},children:[p(a.Tabs.List,{grow:!0,children:[n(a.Tabs.Tab,{value:"Configurations",children:"Configurations"}),e.typedAsSQL&&n(a.Tabs.Tab,{value:"SQL",children:"Request"}),e.typedAsHTTP&&n(a.Tabs.Tab,{value:"HTTP",children:"Request"}),n(a.Tabs.Tab,{value:"Data",disabled:!e.datasource,children:n(a.Tooltip,{label:"Need to pick a Data Source first",disabled:e.datasource,withinPortal:!0,children:n(a.Text,{children:"Data"})})}),n(a.Tabs.Tab,{value:"Usage",disabled:s,children:n(a.Tooltip,{label:"This query is not used for any filter or panel",disabled:!s,withinPortal:!0,children:n(a.Text,{children:"Usage"})})})]}),n(a.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:n(Ix,{queryModel:e})}),e.typedAsSQL&&n(a.Tabs.Panel,{value:"SQL",sx:ln,children:n(a.Stack,{sx:{height:"100%"},children:n(Px,{queryModel:e})})}),e.typedAsHTTP&&n(a.Tabs.Panel,{value:"HTTP",sx:ln,children:n(a.Stack,{sx:{height:"100%"},children:n($x,{queryModel:e})})}),n(a.Tabs.Panel,{value:"Data",sx:{...ln,overflow:"hidden"},children:n(ws,{id:e.id})}),n(a.Tabs.Panel,{value:"Usage",sx:{...ln,overflow:"hidden"},children:n(Ox,{queryID:e.id,usage:i})})]})})}),Bx=T.observer(({id:e})=>{const r=B().queries.findByID(e);return e===""?null:r?n(a.Stack,{sx:{height:"100%"},spacing:"sm",children:n(Vx,{queryModel:r})}):n(a.Text,{size:14,color:"red",children:"Invalid Query ID"})}),Nx=T.observer(({value:e})=>{const t=B(),r=t.context.current,i=fv(e,r,t.mock_context.current,t.filters.values);return n(br,{height:"100%",value:i})}),Gx=T.observer(({item:e,remove:t,onKeyChanged:r})=>{const[i,s]=m.useState("SQL"),[o,u]=m.useState(e.key),l=()=>{e.setKey(o),r(o)},d=o!==e.key,c=e.isADuplicatedKey(o),[f,g]=m.useState(e.value),h=()=>{e.setValue(f)};m.useEffect(()=>{u(e.key),g(e.value)},[e]);const b=f!==e.value,w=Pe.useModals(),C=()=>{w.openConfirmModal({title:"Delete this SQL snippet?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:t,zIndex:320})};return p(a.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[p(a.Group,{sx:{alignItems:"end"},spacing:40,children:[n(a.TextInput,{label:c?"This key is occupied by another snippet":"Key",value:o,onChange:S=>{u(S.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:n(a.ActionIcon,{color:"blue",variant:"subtle",onClick:l,disabled:!d||c,children:n(D.DeviceFloppy,{size:16})}),error:c}),n(a.Button,{leftIcon:n(D.Trash,{size:16}),color:"red",variant:"light",onClick:C,children:"Delete this SQL Snippet"})]}),p(a.Tabs,{value:i,onTabChange:s,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[p(a.Tabs.List,{sx:{position:"relative"},children:[n(a.Tabs.Tab,{value:"SQL",children:"SQL"}),n(a.Tabs.Tab,{value:"Preview",children:"Preview"}),n(mr,{}),n(a.ActionIcon,{color:"blue",variant:"filled",onClick:h,disabled:!b,sx:{position:"absolute",top:0,right:10},children:n(D.DeviceFloppy,{size:18})})]}),n(a.Tabs.Panel,{value:"SQL",pt:"sm",children:n(br,{height:"100%",value:f,onChange:g})}),n(a.Tabs.Panel,{value:"Preview",pt:"sm",children:n(Nx,{value:f})})]})]})}),qx=T.observer(({id:e})=>{const t=B(),r=m.useMemo(()=>t.sqlSnippets.findByKey(e),[e]);if(!e)return null;if(!r)return p(a.Text,{size:14,children:["SQL Snippet by key[",e,"] is not found"]});const i=()=>{t.editor.setPath(["_SQL_SNIPPETS_",""])};return n(Gx,{item:r,remove:()=>{t.sqlSnippets.removeByKey(e),i()},onKeyChanged:u=>{t.editor.setPath(["_SQL_SNIPPETS_",u])}})}),Fx=T.observer(({view:e})=>!e||e.type!==K.Division?null:p(a.Stack,{children:[n(a.Divider,{mt:8,mb:0,label:"Division settings",labelPosition:"center"}),n(a.Text,{align:"center",size:"xs",color:"dimmed",children:"Under construction"})]})),Wx=[{value:"default",label:"Default"},{value:"outline",label:"Outline"},{value:"pills",label:"Pills"}],jx=[{value:"horizontal",label:"Horizontal"},{value:"vertical",label:"Vertical"}],Rx=T.observer(({view:e})=>{if(!e||e.type!==K.Tabs)return null;const t=e.config;return p(a.Stack,{children:[n(a.Divider,{mt:8,mb:0,label:"Tabs settings",labelPosition:"center"}),n(a.Select,{label:"Variant",value:t.variant,onChange:t.setVariant,data:Wx}),n(a.Select,{label:"Orientation",value:t.orientation,onChange:t.setOrientation,data:jx}),n(a.Switch,{label:"Grow Tabs",checked:t.grow,onChange:r=>t.setGrow(r.currentTarget.checked)})]})}),Yx=({disabled:e,value:t,onChange:r})=>{const i=s=>{s&&r(s)};return p(a.Box,{sx:{position:"relative"},children:[e&&n(a.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),n(_e,{height:"500px",defaultLanguage:"javascript",value:t,onChange:i,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},Qx=({value:e,onChange:t})=>{const[r,{setTrue:i,setFalse:s}]=Z.useBoolean(),[o,u]=m.useState(e??or),l=h=>{u({...o,enabled:h})},d=()=>{s();const{enabled:h,func_content:b}=o,w={enabled:h,func_content:b};u(w),t(w)},c=()=>{s(),u(e)},f=h=>{u(b=>({...b,func_content:h}))},g=()=>{f(or.func_content)};return p(O,{children:[n(a.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:i,sx:{flexGrow:0},children:n(D.Settings,{size:14})}),n(a.Modal,{size:800,title:"Customize modal title",opened:r,onClose:s,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&p(a.Stack,{children:[n(a.Checkbox,{mt:10,label:"Enabled",checked:o.enabled,onChange:h=>l(h.currentTarget.checked)}),n(Yx,{value:o.func_content,onChange:f,disabled:!o.enabled}),p(a.Group,{position:"apart",children:[n(a.Button,{onClick:g,color:"red",leftIcon:n(D.Recycle,{size:20}),children:"Rest"}),p(a.Group,{position:"right",children:[n(a.Button,{onClick:c,variant:"subtle",children:"Cancel"}),n(a.Button,{onClick:d,children:"OK"})]})]})]})})]})},Ux=T.observer(({view:e})=>{if(!e||e.type!==K.Modal)return null;const t=e.config,r=t.custom_modal_title.value;return p(a.Stack,{children:[n(a.Divider,{mt:8,label:"Modal settings",labelPosition:"center"}),p(a.Flex,{gap:10,children:[n(a.TextInput,{label:"Modal Title",value:r,onChange:y.noop,disabled:!0,sx:{flexGrow:1}}),n(Qx,{value:t.custom_modal_title,onChange:t.custom_modal_title.replace})]}),p(a.Group,{grow:!0,children:[n(a.TextInput,{label:"Width",value:t.width,onChange:i=>t.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),n(a.TextInput,{label:"Height",value:t.height,onChange:i=>t.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),Xx=T.observer(({view:e})=>p(O,{children:[n(Fx,{view:e}),n(Ux,{view:e}),n(Rx,{view:e})]})),Zx=[{label:"Division",value:K.Division},{label:"Modal",value:K.Modal},{label:"Tabs",value:K.Tabs}],Kx=T.observer(({view:e})=>e?p(a.Stack,{sx:{position:"relative"},children:[n(a.TextInput,{label:"Name",value:e.name,onChange:t=>{e.setName(t.currentTarget.value)}}),n(a.Select,{label:"Type",withinPortal:!0,value:e.type,onChange:e.setType,data:Zx}),n(Xx,{view:e})]}):null),Jx=T.observer(({id:e})=>{const t=Pe.useModals(),r=B();if(e==="")return null;const i=r.views.findByID(e);if(!i)return p(a.Text,{size:14,children:["View by ID[",e,"] is not found"]});const s=()=>{r.editor.setPath(["_VIEWS_",""])},o=()=>{t.openConfirmModal({title:"Delete this view?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.views.removeByID(e),s()},zIndex:320})};return p(a.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[n(a.Group,{position:"right",pt:10,children:n(a.Button,{size:"xs",color:"red",leftIcon:n(D.Trash,{size:16}),onClick:o,children:"Delete this view"})}),n(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n(Kx,{view:i})})]})});function Hx(e){return e.length===1&&e[0]==="_GLOBAL_VARS_"}function eC(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function tC(e){return e.length===2&&e[0]==="_FILTERS_"}function nC(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function rC(e){return e.length===2&&e[0]==="_QUERIES_"}function iC(e){return e.length===2&&e[0]==="_VIEWS_"}function aC(e){return e.length===4&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}const sC=T.observer(()=>n(a.Stack,{sx:{height:"100%"},p:"sm",children:n(Is,{})})),oC=T.observer(()=>{const e=B().editor,t=e.path;return Hx(t)?n(sC,{}):eC(t)?n(zy,{}):tC(t)?n(a.Box,{p:"xs",pl:20,children:n(Ay,{id:t[1]})}):nC(t)?n(qx,{id:t[1]}):rC(t)?n(Bx,{id:t[1]}):iC(t)?n(a.Box,{p:"xs",pl:20,children:n(Jx,{id:t[1]})}):aC(t)?n(ox,{viewID:t[1],panelID:t[3]}):n(a.Box,{children:e.path})}),lC=T.observer(()=>(B().editor,n(oC,{}))),uC=T.observer(()=>{const e=B(),t=()=>{const r=new Date().getTime().toString(),i={id:r,key:r,label:r,order:e.filters.current.length+1,type:tr.TextInput,config:Qa(),visibleInViewsIDs:["Main"],auto_submit:!1};e.filters.append(i)};return n(a.Button,{variant:"subtle",leftIcon:n(V.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Filter"})}),dC=T.observer(({parentID:e})=>{const t=B();if(!e)return null;const r=t.views.findByID(e);return r?n(a.Button,{variant:"subtle",leftIcon:n(V.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>t.addANewPanel(r.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Panel"}):null}),cC=T.observer(()=>{const e=B(),t=()=>{const r=new Date().getTime().toString(),i={id:r,name:r,type:ce.Postgresql,key:"",sql:""};e.queries.append(i)};return n(a.Button,{variant:"subtle",leftIcon:n(V.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Query"})}),pC=T.observer(()=>{const e=B(),t=()=>{const i={key:new Date().getTime().toString(),value:""};e.sqlSnippets.append(i)};return n(a.Button,{variant:"subtle",leftIcon:n(V.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a SQL Snippet"})}),hC=T.observer(()=>{const e=B();return n(a.Button,{variant:"subtle",leftIcon:n(V.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a View"})}),fC=T.observer(({action_type:e,parentID:t})=>(B(),e==="_Add_A_Filter_"?n(uC,{}):e==="_Add_A_SQL_SNIPPET_"?n(pC,{}):e==="_Add_A_QUERY_"?n(cC,{}):e==="_Add_A_VIEW_"?n(hC,{}):e==="_Add_A_PANEL_"?n(dC,{parentID:t}):null)),zs=T.observer(({option:e})=>{var c;const t=B().editor,r=t.isOptionActive,i=r(t.path,e),s=t.isOptionOpened,o=t.navigate,u=s(e),[l,d]=m.useState(u);return m.useEffect(()=>{d(u)},[u]),n(a.NavLink,{active:i,defaultOpened:u,opened:l,onChange:d,label:e.label,onClick:()=>o(e),icon:e.Icon?n(e.Icon,{size:18}):null,children:(c=e.children)==null?void 0:c.map(f=>f._type==="ACTION"?n(fC,{action_type:f._action_type,parentID:f.parentID},`_ADD_${f.value}_`):n(zs,{option:f},f.value))},e.label)}),gC=T.observer(()=>{const e=B();return n(a.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>n(zs,{option:t},t.value))})}),mC=T.observer(()=>{const e=B();return p(a.Navbar,{p:0,width:{base:200,xs:200,sm:220,md:240,lg:280,xl:300},sx:{height:"100vh - 60px - 60px"},children:[n(a.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n(a.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Settings"})}),n(a.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:n(gC,{})}),n(a.Navbar.Section,{children:n(a.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n(a.Button,{size:"xs",color:"red",leftIcon:n(V.IconX,{size:18}),onClick:()=>e.editor.close(),children:"Close"})})})]})}),bC={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},vC=T.observer(()=>{const e=B().editor;return n(a.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionDuration:0,withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{modal:{padding:"0 !important"}},children:n(a.AppShell,{padding:0,navbar:n(mC,{}),styles:bC,children:n(lC,{})})})}),yC=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function xC(e){m.useEffect(()=>{if(_e.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const r=yC(e);_e.loader.config({paths:{vs:r}}),_e.loader.init().then(i=>console.log("monaco instance:",i))},[])}const $s={grid:{axis:"#97999D",scope:"rgba(47,140,192,0.1)",boundary:"#789AB4",reference:"#CFCFD8"},graphics:{compared:{blueDark:"#3E7CAB",blue:"#6398C7",blueLight:"#7CB0DF",blue10:"#6398C71a",redDark:"#AF5F6B",red:"#CD7C88",redLight:"#E794A0",red10:"#CD7C881a"},gradient:{distributed:"linear-gradient(90deg, #1babe6 0%, #2fc8c8 28.63%, #98d44b 48.86%, #ffd057 67.53%, #f5ae53 80.6%, #e76441 91.18%, #b90000 100%)",protrude:"linear-gradient(180deg, #ec73734d 0%, #ec737300 100%)"},level:{lv0:"#6398C7",lv1:"#61B5BF",lv2:"#54D4BB",lv3:"#F5D277",lv4:"#E8BB7F",lv5:"#DB9E84",lv6:"#CB8089"},depth:{dp0:"#FFF7F8",dp1:"#FFE1E1",dp2:"#FDBCBC",dp3:"#F39494",dp4:"#FA4242",dp5:"#E21212"},multiple:{c1:"#66B4DB",c2:"#E46464",c3:"#EEBA00",c4:"#33A678",c5:"#9D88CB",c6:"#939943",c7:"#E49792",c8:"#09A2B8",c9:"#AF5F6B",c10:"#6CA157",c11:"#3E7CAB",c12:"#6398C7",c13:"#E692BA",c14:"#97B566",c15:"#8CACE2",c16:"#CA79AC",c17:"#6DBC80",c18:"#B08F4B",c19:"#39BFA2",c20:"#826BAF"}}};function CC(){oe.registerTheme("merico-light",{color:Object.values($s.graphics.multiple),visualMap:{color:Object.values($s.graphics.depth).reverse()}})}function Es(){CC()}Es();const wC={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60,height:"100vh"}},_C=T.observer(m.forwardRef(function({context:t,dashboard:r,update:i,className:s="dashboard",config:o,onChange:u,headerSlot:l},d){xC(o.monacoPath),Na(o);const{data:c=[]}=Z.useRequest(sr),[f,g]=m.useState(!1),h=m.useMemo(()=>ur(r,c,t),[r]);m.useImperativeHandle(d,()=>h,[h]),Si(h,!0),m.useEffect(()=>{h.context.replace(t)},[t]),m.useEffect(()=>{h.datasources.replace(c)},[c]),m.useEffect(()=>ae.reaction(()=>ae.toJS(h.json),S=>{u==null||u(S)}),[h]);const b=async()=>{await i(h.json)},w=Z.useCreation(Hn,[]),C=dr(w);return n(Pe.ModalsProvider,{children:n(mn,{value:h,children:n(Xe.Provider,{value:{layoutFrozen:f,freezeLayout:g,inEditMode:!0},children:n(Ne.Provider,{value:w,children:p(Bt,{configure:C,children:[n(a.AppShell,{padding:0,header:n(Wv,{saveDashboardChanges:b,headerSlot:l}),navbar:n(gy,{}),styles:wC,children:n(a.Box,{className:`${s} dashboard-root`,sx:{position:"relative"},children:h.views.visibleViews.map(S=>n(Ba,{view:S},S.id))})}),n(vC,{})]})})})})})})),yw="";Es();const SC=T.observer(({context:e,dashboard:t,className:r="dashboard",config:i,fullScreenPanelID:s,setFullScreenPanelID:o})=>{Na(i);const{data:u=[]}=Z.useRequest(sr),l=m.useMemo(()=>ur(t,u,e),[t]);Si(l,!1),m.useEffect(()=>{l.context.replace(e)},[e]),m.useEffect(()=>{l.datasources.replace(u)},[u]);const d=Z.useCreation(Hn,[]),c=dr(d);return n(Pe.ModalsProvider,{children:n(mn,{value:l,children:n(yn.Provider,{value:{fullScreenPanelID:s,setFullScreenPanelID:o},children:n(Xe.Provider,{value:{layoutFrozen:!0,freezeLayout:y.noop,inEditMode:!1},children:n(a.Box,{className:`${r} dashboard-root`,children:n(Ne.Provider,{value:d,children:n(Bt,{configure:c,children:l.views.visibleViews.map(f=>n(en,{view:f},f.id))})})})})})})})});var vr={},TC={get exports(){return vr},set exports(e){vr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){var o=i.prototype,u=o.format;s.en.ordinal=function(l){var d=["th","st","nd","rd"],c=l%100;return"["+l+(d[(c-20)%10]||d[c]||d[0])+"]"},o.format=function(l){var d=this,c=this.$locale();if(!this.isValid())return u.bind(this)(l);var f=this.$utils(),g=(l||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(h){switch(h){case"Q":return Math.ceil((d.$M+1)/3);case"Do":return c.ordinal(d.$D);case"gggg":return d.weekYear();case"GGGG":return d.isoWeekYear();case"wo":return c.ordinal(d.week(),"W");case"w":case"ww":return f.s(d.week(),h==="w"?1:2,"0");case"W":case"WW":return f.s(d.isoWeek(),h==="W"?1:2,"0");case"k":case"kk":return f.s(String(d.$H===0?24:d.$H),h==="k"?1:2,"0");case"X":return Math.floor(d.$d.getTime()/1e3);case"x":return d.$d.getTime();case"z":return"["+d.offsetName()+"]";case"zzz":return"["+d.offsetName("long")+"]";default:return h}});return u.bind(this)(g)}}})})(TC);const DC=vr;var yr={},kC={get exports(){return yr},set exports(e){yr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){var o=i.prototype,u=function(d){var c=d.date,f=d.utc;return Array.isArray(c)?f?c.length?new Date(Date.UTC.apply(null,c)):new Date:c.length===1?s(String(c[0])).toDate():new(Function.prototype.bind.apply(Date,[null].concat(c))):c},l=o.parse;o.parse=function(d){d.date=u.bind(this)(d),l.bind(this)(d)}}})})(kC);const IC=yr;var xr={},MC={get exports(){return xr},set exports(e){xr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){var s=i.prototype;s.$g=function(h,b,w){return this.$utils().u(h)?this[b]:this.$set(w,h)},s.set=function(h,b){return this.$set(h,b)};var o=s.startOf;s.startOf=function(h,b){return this.$d=o.bind(this)(h,b).toDate(),this.init(),this};var u=s.add;s.add=function(h,b){return this.$d=u.bind(this)(h,b).toDate(),this.init(),this};var l=s.locale;s.locale=function(h,b){return h?(this.$L=l.bind(this)(h,b).$L,this):this.$L};var d=s.daysInMonth;s.daysInMonth=function(){return d.bind(this.clone())()};var c=s.isSame;s.isSame=function(h,b){return c.bind(this.clone())(h,b)};var f=s.isBefore;s.isBefore=function(h,b){return f.bind(this.clone())(h,b)};var g=s.isAfter;s.isAfter=function(h,b){return g.bind(this.clone())(h,b)}}})})(MC);const AC=xr;var Cr={},zC={get exports(){return Cr},set exports(e){Cr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){var s=i.prototype,o=s.format;s.format=function(u){var l=this,d=(u||"YYYY-MM-DDTHH:mm:ssZ").replace(/(\[[^\]]+])|BBBB|BB/g,function(c,f){var g,h=String(l.$y+543),b=c==="BB"?[h.slice(-2),2]:[h,4];return f||(g=l.$utils()).s.apply(g,b.concat(["0"]))});return o.bind(this)(d)}}})})(zC);const $C=Cr;var wr={},EC={get exports(){return wr},set exports(e){wr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){var o="h:mm A",u={lastDay:"[Yesterday at] "+o,sameDay:"[Today at] "+o,nextDay:"[Tomorrow at] "+o,nextWeek:"dddd [at] "+o,lastWeek:"[Last] dddd [at] "+o,sameElse:"MM/DD/YYYY"};i.prototype.calendar=function(l,d){var c=d||this.$locale().calendar||u,f=s(l||void 0).startOf("d"),g=this.diff(f,"d",!0),h="sameElse",b=g<-6?h:g<-1?"lastWeek":g<0?"lastDay":g<1?"sameDay":g<2?"nextDay":g<7?"nextWeek":h,w=c[b]||u[b];return typeof w=="function"?w.call(this,s()):this.format(w)}}})})(EC);const LC=wr;var _r={},PC={get exports(){return _r},set exports(e){_r=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},i=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,s=/\d\d/,o=/\d\d?/,u=/\d*[^-_:/,()\s\d]+/,l={},d=function(C){return(C=+C)+(C>68?1900:2e3)},c=function(C){return function(S){this[C]=+S}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(C){(this.zone||(this.zone={})).offset=function(S){if(!S||S==="Z")return 0;var A=S.match(/([+-]|\d\d)/g),z=60*A[1]+(+A[2]||0);return z===0?0:A[0]==="+"?-z:z}(C)}],g=function(C){var S=l[C];return S&&(S.indexOf?S:S.s.concat(S.f))},h=function(C,S){var A,z=l.meridiem;if(z){for(var G=1;G<=24;G+=1)if(C.indexOf(z(G,0,S))>-1){A=G>12;break}}else A=C===(S?"pm":"PM");return A},b={A:[u,function(C){this.afternoon=h(C,!1)}],a:[u,function(C){this.afternoon=h(C,!0)}],S:[/\d/,function(C){this.milliseconds=100*+C}],SS:[s,function(C){this.milliseconds=10*+C}],SSS:[/\d{3}/,function(C){this.milliseconds=+C}],s:[o,c("seconds")],ss:[o,c("seconds")],m:[o,c("minutes")],mm:[o,c("minutes")],H:[o,c("hours")],h:[o,c("hours")],HH:[o,c("hours")],hh:[o,c("hours")],D:[o,c("day")],DD:[s,c("day")],Do:[u,function(C){var S=l.ordinal,A=C.match(/\d+/);if(this.day=A[0],S)for(var z=1;z<=31;z+=1)S(z).replace(/\[|\]/g,"")===C&&(this.day=z)}],M:[o,c("month")],MM:[s,c("month")],MMM:[u,function(C){var S=g("months"),A=(g("monthsShort")||S.map(function(z){return z.slice(0,3)})).indexOf(C)+1;if(A<1)throw new Error;this.month=A%12||A}],MMMM:[u,function(C){var S=g("months").indexOf(C)+1;if(S<1)throw new Error;this.month=S%12||S}],Y:[/[+-]?\d+/,c("year")],YY:[s,function(C){this.year=d(C)}],YYYY:[/\d{4}/,c("year")],Z:f,ZZ:f};function w(C){var S,A;S=C,A=l&&l.formats;for(var z=(C=S.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(Q,Y,te){var re=te&&te.toUpperCase();return Y||A[te]||r[te]||A[re].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(se,ne,pe){return ne||pe.slice(1)})})).match(i),G=z.length,F=0;F<G;F+=1){var L=z[F],$=b[L],M=$&&$[0],N=$&&$[1];z[F]=N?{regex:M,parser:N}:L.replace(/^\[|\]$/g,"")}return function(Q){for(var Y={},te=0,re=0;te<G;te+=1){var se=z[te];if(typeof se=="string")re+=se.length;else{var ne=se.regex,pe=se.parser,he=Q.slice(re),we=ne.exec(he)[0];pe.call(Y,we),Q=Q.replace(we,"")}}return function(qe){var ke=qe.afternoon;if(ke!==void 0){var Re=qe.hours;ke?Re<12&&(qe.hours+=12):Re===12&&(qe.hours=0),delete qe.afternoon}}(Y),Y}}return function(C,S,A){A.p.customParseFormat=!0,C&&C.parseTwoDigitYear&&(d=C.parseTwoDigitYear);var z=S.prototype,G=z.parse;z.parse=function(F){var L=F.date,$=F.utc,M=F.args;this.$u=$;var N=M[1];if(typeof N=="string"){var Q=M[2]===!0,Y=M[3]===!0,te=Q||Y,re=M[2];Y&&(re=M[2]),l=this.$locale(),!Q&&re&&(l=A.Ls[re]),this.$d=function(he,we,qe){try{if(["x","X"].indexOf(we)>-1)return new Date((we==="X"?1e3:1)*he);var ke=w(we)(he),Re=ke.year,rt=ke.month,un=ke.day,dn=ke.hours,Jr=ke.minutes,Hr=ke.seconds,It=ke.milliseconds,pt=ke.zone,He=new Date,it=un||(Re||rt?1:He.getDate()),et=Re||He.getFullYear(),ht=0;Re&&!rt||(ht=rt>0?rt-1:He.getMonth());var ft=dn||0,Mt=Jr||0,At=Hr||0,tt=It||0;return pt?new Date(Date.UTC(et,ht,it,ft,Mt,At,tt+60*pt.offset*1e3)):qe?new Date(Date.UTC(et,ht,it,ft,Mt,At,tt)):new Date(et,ht,it,ft,Mt,At,tt)}catch{return new Date("")}}(L,N,$),this.init(),re&&re!==!0&&(this.$L=this.locale(re).$L),te&&L!=this.format(N)&&(this.$d=new Date("")),l={}}else if(N instanceof Array)for(var se=N.length,ne=1;ne<=se;ne+=1){M[1]=N[ne-1];var pe=A.apply(this,M);if(pe.isValid()){this.$d=pe.$d,this.$L=pe.$L,this.init();break}ne===se&&(this.$d=new Date(""))}else G.call(this,F)}}})})(PC);const OC=_r;var Sr={},VC={get exports(){return Sr},set exports(e){Sr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){i.prototype.dayOfYear=function(o){var u=Math.round((s(this).startOf("day")-s(this).startOf("year"))/864e5)+1;return o==null?u:this.add(o-u,"day")}}})})(VC);const BC=Sr;var Tr={},NC={get exports(){return Tr},set exports(e){Tr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r,i,s=1e3,o=6e4,u=36e5,l=864e5,d=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,c=31536e6,f=2592e6,g=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,h={years:c,months:f,days:l,hours:u,minutes:o,seconds:s,milliseconds:1,weeks:6048e5},b=function(L){return L instanceof F},w=function(L,$,M){return new F(L,M,$.$l)},C=function(L){return i.p(L)+"s"},S=function(L){return L<0},A=function(L){return S(L)?Math.ceil(L):Math.floor(L)},z=function(L){return Math.abs(L)},G=function(L,$){return L?S(L)?{negative:!0,format:""+z(L)+$}:{negative:!1,format:""+L+$}:{negative:!1,format:""}},F=function(){function L(M,N,Q){var Y=this;if(this.$d={},this.$l=Q,M===void 0&&(this.$ms=0,this.parseFromMilliseconds()),N)return w(M*h[C(N)],this);if(typeof M=="number")return this.$ms=M,this.parseFromMilliseconds(),this;if(typeof M=="object")return Object.keys(M).forEach(function(se){Y.$d[C(se)]=M[se]}),this.calMilliseconds(),this;if(typeof M=="string"){var te=M.match(g);if(te){var re=te.slice(2).map(function(se){return se!=null?Number(se):0});return this.$d.years=re[0],this.$d.months=re[1],this.$d.weeks=re[2],this.$d.days=re[3],this.$d.hours=re[4],this.$d.minutes=re[5],this.$d.seconds=re[6],this.calMilliseconds(),this}}return this}var $=L.prototype;return $.calMilliseconds=function(){var M=this;this.$ms=Object.keys(this.$d).reduce(function(N,Q){return N+(M.$d[Q]||0)*h[Q]},0)},$.parseFromMilliseconds=function(){var M=this.$ms;this.$d.years=A(M/c),M%=c,this.$d.months=A(M/f),M%=f,this.$d.days=A(M/l),M%=l,this.$d.hours=A(M/u),M%=u,this.$d.minutes=A(M/o),M%=o,this.$d.seconds=A(M/s),M%=s,this.$d.milliseconds=M},$.toISOString=function(){var M=G(this.$d.years,"Y"),N=G(this.$d.months,"M"),Q=+this.$d.days||0;this.$d.weeks&&(Q+=7*this.$d.weeks);var Y=G(Q,"D"),te=G(this.$d.hours,"H"),re=G(this.$d.minutes,"M"),se=this.$d.seconds||0;this.$d.milliseconds&&(se+=this.$d.milliseconds/1e3);var ne=G(se,"S"),pe=M.negative||N.negative||Y.negative||te.negative||re.negative||ne.negative,he=te.format||re.format||ne.format?"T":"",we=(pe?"-":"")+"P"+M.format+N.format+Y.format+he+te.format+re.format+ne.format;return we==="P"||we==="-P"?"P0D":we},$.toJSON=function(){return this.toISOString()},$.format=function(M){var N=M||"YYYY-MM-DDTHH:mm:ss",Q={Y:this.$d.years,YY:i.s(this.$d.years,2,"0"),YYYY:i.s(this.$d.years,4,"0"),M:this.$d.months,MM:i.s(this.$d.months,2,"0"),D:this.$d.days,DD:i.s(this.$d.days,2,"0"),H:this.$d.hours,HH:i.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:i.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:i.s(this.$d.seconds,2,"0"),SSS:i.s(this.$d.milliseconds,3,"0")};return N.replace(d,function(Y,te){return te||String(Q[Y])})},$.as=function(M){return this.$ms/h[C(M)]},$.get=function(M){var N=this.$ms,Q=C(M);return Q==="milliseconds"?N%=1e3:N=Q==="weeks"?A(N/h[Q]):this.$d[Q],N===0?0:N},$.add=function(M,N,Q){var Y;return Y=N?M*h[C(N)]:b(M)?M.$ms:w(M,this).$ms,w(this.$ms+Y*(Q?-1:1),this)},$.subtract=function(M,N){return this.add(M,N,!0)},$.locale=function(M){var N=this.clone();return N.$l=M,N},$.clone=function(){return w(this.$ms,this)},$.humanize=function(M){return r().add(this.$ms,"ms").locale(this.$l).fromNow(!M)},$.milliseconds=function(){return this.get("milliseconds")},$.asMilliseconds=function(){return this.as("milliseconds")},$.seconds=function(){return this.get("seconds")},$.asSeconds=function(){return this.as("seconds")},$.minutes=function(){return this.get("minutes")},$.asMinutes=function(){return this.as("minutes")},$.hours=function(){return this.get("hours")},$.asHours=function(){return this.as("hours")},$.days=function(){return this.get("days")},$.asDays=function(){return this.as("days")},$.weeks=function(){return this.get("weeks")},$.asWeeks=function(){return this.as("weeks")},$.months=function(){return this.get("months")},$.asMonths=function(){return this.as("months")},$.years=function(){return this.get("years")},$.asYears=function(){return this.as("years")},L}();return function(L,$,M){r=M,i=M().$utils(),M.duration=function(Y,te){var re=M.locale();return w(Y,{$l:re},te)},M.isDuration=b;var N=$.prototype.add,Q=$.prototype.subtract;$.prototype.add=function(Y,te){return b(Y)&&(Y=Y.asMilliseconds()),N.bind(this)(Y,te)},$.prototype.subtract=function(Y,te){return b(Y)&&(Y=Y.asMilliseconds()),Q.bind(this)(Y,te)}}})})(NC);const GC=Tr;var Dr={},qC={get exports(){return Dr},set exports(e){Dr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){i.prototype.isBetween=function(o,u,l,d){var c=s(o),f=s(u),g=(d=d||"()")[0]==="(",h=d[1]===")";return(g?this.isAfter(c,l):!this.isBefore(c,l))&&(h?this.isBefore(f,l):!this.isAfter(f,l))||(g?this.isBefore(c,l):!this.isAfter(c,l))&&(h?this.isAfter(f,l):!this.isBefore(f,l))}}})})(qC);const FC=Dr;var kr={},WC={get exports(){return kr},set exports(e){kr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}})})(WC);const jC=kr;var Ir={},RC={get exports(){return Ir},set exports(e){Ir=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){s.isMoment=function(o){return s.isDayjs(o)}}})})(RC);const YC=Ir;var Mr={},QC={get exports(){return Mr},set exports(e){Mr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r="day";return function(i,s,o){var u=function(c){return c.add(4-c.isoWeekday(),r)},l=s.prototype;l.isoWeekYear=function(){return u(this).year()},l.isoWeek=function(c){if(!this.$utils().u(c))return this.add(7*(c-this.isoWeek()),r);var f,g,h,b,w=u(this),C=(f=this.isoWeekYear(),g=this.$u,h=(g?o.utc:o)().year(f).startOf("year"),b=4-h.isoWeekday(),h.isoWeekday()>4&&(b+=7),h.add(b,r));return w.diff(C,"week")+1},l.isoWeekday=function(c){return this.$utils().u(c)?this.day()||7:this.day(this.day()%7?c:c-7)};var d=l.startOf;l.startOf=function(c,f){var g=this.$utils(),h=!!g.u(f)||f;return g.p(c)==="isoweek"?h?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):d.bind(this)(c,f)}}})})(QC);const UC=Mr;var Ar={},XC={get exports(){return Ar},set exports(e){Ar=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.isoWeeksInYear=function(){var s=this.isLeapYear(),o=this.endOf("y").day();return o===4||s&&o===5?53:52}}})})(XC);const ZC=Ar;var zr={},KC={get exports(){return zr},set exports(e){zr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.isSameOrAfter=function(s,o){return this.isSame(s,o)||this.isAfter(s,o)}}})})(KC);const JC=zr;var $r={},HC={get exports(){return $r},set exports(e){$r=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.isSameOrBefore=function(s,o){return this.isSame(s,o)||this.isBefore(s,o)}}})})(HC);const e0=$r;var Er={},t0={get exports(){return Er},set exports(e){Er=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){i.prototype.isToday=function(){var o="YYYY-MM-DD",u=s();return this.format(o)===u.format(o)}}})})(t0);const n0=Er;var Lr={},r0={get exports(){return Lr},set exports(e){Lr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){i.prototype.isTomorrow=function(){var o="YYYY-MM-DD",u=s().add(1,"day");return this.format(o)===u.format(o)}}})})(r0);const i0=Lr;var Pr={},a0={get exports(){return Pr},set exports(e){Pr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){i.prototype.isYesterday=function(){var o="YYYY-MM-DD",u=s().subtract(1,"day");return this.format(o)===u.format(o)}}})})(a0);const s0=Pr;var Or={},o0={get exports(){return Or},set exports(e){Or=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){var o=i.prototype,u=function(g){return g&&(g.indexOf?g:g.s)},l=function(g,h,b,w,C){var S=g.name?g:g.$locale(),A=u(S[h]),z=u(S[b]),G=A||z.map(function(L){return L.slice(0,w)});if(!C)return G;var F=S.weekStart;return G.map(function(L,$){return G[($+(F||0))%7]})},d=function(){return s.Ls[s.locale()]},c=function(g,h){return g.formats[h]||function(b){return b.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(w,C,S){return C||S.slice(1)})}(g.formats[h.toUpperCase()])},f=function(){var g=this;return{months:function(h){return h?h.format("MMMM"):l(g,"months")},monthsShort:function(h){return h?h.format("MMM"):l(g,"monthsShort","months",3)},firstDayOfWeek:function(){return g.$locale().weekStart||0},weekdays:function(h){return h?h.format("dddd"):l(g,"weekdays")},weekdaysMin:function(h){return h?h.format("dd"):l(g,"weekdaysMin","weekdays",2)},weekdaysShort:function(h){return h?h.format("ddd"):l(g,"weekdaysShort","weekdays",3)},longDateFormat:function(h){return c(g.$locale(),h)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};o.localeData=function(){return f.bind(this)()},s.localeData=function(){var g=d();return{firstDayOfWeek:function(){return g.weekStart||0},weekdays:function(){return s.weekdays()},weekdaysShort:function(){return s.weekdaysShort()},weekdaysMin:function(){return s.weekdaysMin()},months:function(){return s.months()},monthsShort:function(){return s.monthsShort()},longDateFormat:function(h){return c(g,h)},meridiem:g.meridiem,ordinal:g.ordinal}},s.months=function(){return l(d(),"months")},s.monthsShort=function(){return l(d(),"monthsShort","months",3)},s.weekdays=function(g){return l(d(),"weekdays",null,null,g)},s.weekdaysShort=function(g){return l(d(),"weekdaysShort","weekdays",3,g)},s.weekdaysMin=function(g){return l(d(),"weekdaysMin","weekdays",2,g)}}})})(o0);const l0=Or;var Vr={},u0={get exports(){return Vr},set exports(e){Vr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(i,s,o){var u=s.prototype,l=u.format;o.en.formats=r,u.format=function(d){d===void 0&&(d="YYYY-MM-DDTHH:mm:ssZ");var c=this.$locale().formats,f=function(g,h){return g.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(b,w,C){var S=C&&C.toUpperCase();return w||h[C]||r[C]||h[S].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(A,z,G){return z||G.slice(1)})})}(d,c===void 0?{}:c);return l.call(this,f)}}})})(u0);const d0=Vr;var Br={},c0={get exports(){return Br},set exports(e){Br=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){var o=function(u,l){if(!l||!l.length||!l[0]||l.length===1&&!l[0].length)return null;var d;l.length===1&&l[0].length>0&&(l=l[0]),d=l[0];for(var c=1;c<l.length;c+=1)l[c].isValid()&&!l[c][u](d)||(d=l[c]);return d};s.max=function(){var u=[].slice.call(arguments,0);return o("isAfter",u)},s.min=function(){var u=[].slice.call(arguments,0);return o("isBefore",u)}}})})(c0);const p0=Br;var Nr={},h0={get exports(){return Nr},set exports(e){Nr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){var o=i.prototype,u=function(g){var h,b=g.date,w=g.utc,C={};if(!((h=b)instanceof Date)&&!(h instanceof Array)&&h instanceof Object){if(!Object.keys(b).length)return new Date;var S=w?s.utc():s();Object.keys(b).forEach(function(N){var Q,Y;C[Q=N,Y=o.$utils().p(Q),Y==="date"?"day":Y]=b[N]});var A=C.day||(C.year||C.month>=0?1:S.date()),z=C.year||S.year(),G=C.month>=0?C.month:C.year||C.day?0:S.month(),F=C.hour||0,L=C.minute||0,$=C.second||0,M=C.millisecond||0;return w?new Date(Date.UTC(z,G,A,F,L,$,M)):new Date(z,G,A,F,L,$,M)}return b},l=o.parse;o.parse=function(g){g.date=u.bind(this)(g),l.bind(this)(g)};var d=o.set,c=o.add,f=function(g,h,b,w){if(w===void 0&&(w=1),h instanceof Object){var C=Object.keys(h),S=this;return C.forEach(function(A){S=g.bind(S)(h[A]*w,A)}),S}return g.bind(this)(h*w,b)};o.set=function(g,h){return h=h===void 0?g:h,f.bind(this)(function(b,w){return d.bind(this)(w,b)},h,g)},o.add=function(g,h){return f.bind(this)(c,g,h)},o.subtract=function(g,h){return f.bind(this)(c,g,h,-1)}}})})(h0);const f0=Nr;var Gr={},g0={get exports(){return Gr},set exports(e){Gr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){var s=i.prototype;["milliseconds","seconds","minutes","hours","days","weeks","isoWeeks","months","quarters","years","dates"].forEach(function(o){s[o]=s[o.replace(/s$/,"")]})}})})(g0);const m0=Gr;var qr={},b0={get exports(){return qr},set exports(e){qr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){var s=i.prototype.parse;i.prototype.parse=function(l){if(typeof l.date=="string"){var d=this.$locale();l.date=d&&d.preparse?d.preparse(l.date):l.date}return s.bind(this)(l)};var o=i.prototype.format;i.prototype.format=function(){for(var l=arguments.length,d=new Array(l),c=0;c<l;c++)d[c]=arguments[c];var f=o.call.apply(o,[this].concat(d)),g=this.$locale();return g&&g.postformat?g.postformat(f):f};var u=i.prototype.fromToBase;u&&(i.prototype.fromToBase=function(l,d,c,f){var g=this.$locale()||c.$locale();return u.call(this,l,d,c,f,g&&g.postformat)})}})})(b0);const v0=qr;var Fr={},y0={get exports(){return Fr},set exports(e){Fr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r="month",i="quarter";return function(s,o){var u=o.prototype;u.quarter=function(c){return this.$utils().u(c)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(c-1))};var l=u.add;u.add=function(c,f){return c=Number(c),this.$utils().p(f)===i?this.add(3*c,r):l.bind(this)(c,f)};var d=u.startOf;u.startOf=function(c,f){var g=this.$utils(),h=!!g.u(f)||f;if(g.p(c)===i){var b=this.quarter()-1;return h?this.month(3*b).startOf(r).startOf("day"):this.month(3*b+2).endOf(r).endOf("day")}return d.bind(this)(c,f)}}})})(y0);const x0=Fr;var Wr={},C0={get exports(){return Wr},set exports(e){Wr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){r=r||{};var o=i.prototype,u={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function l(c,f,g,h){return o.fromToBase(c,f,g,h)}s.en.relativeTime=u,o.fromToBase=function(c,f,g,h,b){for(var w,C,S,A=g.$locale().relativeTime||u,z=r.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],G=z.length,F=0;F<G;F+=1){var L=z[F];L.d&&(w=h?s(c).diff(g,L.d,!0):g.diff(c,L.d,!0));var $=(r.rounding||Math.round)(Math.abs(w));if(S=w>0,$<=L.r||!L.r){$<=1&&F>0&&(L=z[F-1]);var M=A[L.l];b&&($=b(""+$)),C=typeof M=="string"?M.replace("%d",$):M($,f,L.l,S);break}}if(f)return C;var N=S?A.future:A.past;return typeof N=="function"?N(C):N.replace("%s",C)},o.to=function(c,f){return l(c,f,this,!0)},o.from=function(c,f){return l(c,f,this)};var d=function(c){return c.$u?s.utc():s()};o.toNow=function(c){return this.to(d(this),c)},o.fromNow=function(c){return this.from(d(this),c)}}})})(C0);const w0=Wr;var jr={},_0={get exports(){return jr},set exports(e){jr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r={year:0,month:1,day:2,hour:3,minute:4,second:5},i={};return function(s,o,u){var l,d=function(h,b,w){w===void 0&&(w={});var C=new Date(h),S=function(A,z){z===void 0&&(z={});var G=z.timeZoneName||"short",F=A+"|"+G,L=i[F];return L||(L=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:A,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:G}),i[F]=L),L}(b,w);return S.formatToParts(C)},c=function(h,b){for(var w=d(h,b),C=[],S=0;S<w.length;S+=1){var A=w[S],z=A.type,G=A.value,F=r[z];F>=0&&(C[F]=parseInt(G,10))}var L=C[3],$=L===24?0:L,M=C[0]+"-"+C[1]+"-"+C[2]+" "+$+":"+C[4]+":"+C[5]+":000",N=+h;return(u.utc(M).valueOf()-(N-=N%1e3))/6e4},f=o.prototype;f.tz=function(h,b){h===void 0&&(h=l);var w=this.utcOffset(),C=this.toDate(),S=C.toLocaleString("en-US",{timeZone:h}),A=Math.round((C-new Date(S))/1e3/60),z=u(S).$set("millisecond",this.$ms).utcOffset(15*-Math.round(C.getTimezoneOffset()/15)-A,!0);if(b){var G=z.utcOffset();z=z.add(w-G,"minute")}return z.$x.$timezone=h,z},f.offsetName=function(h){var b=this.$x.$timezone||u.tz.guess(),w=d(this.valueOf(),b,{timeZoneName:h}).find(function(C){return C.type.toLowerCase()==="timezonename"});return w&&w.value};var g=f.startOf;f.startOf=function(h,b){if(!this.$x||!this.$x.$timezone)return g.call(this,h,b);var w=u(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return g.call(w,h,b).tz(this.$x.$timezone,!0)},u.tz=function(h,b,w){var C=w&&b,S=w||b||l,A=c(+u(),S);if(typeof h!="string")return u(h).tz(S);var z=function($,M,N){var Q=$-60*M*1e3,Y=c(Q,N);if(M===Y)return[Q,M];var te=c(Q-=60*(Y-M)*1e3,N);return Y===te?[Q,Y]:[$-60*Math.min(Y,te)*1e3,Math.max(Y,te)]}(u.utc(h,C).valueOf(),A,S),G=z[0],F=z[1],L=u(G).utcOffset(F);return L.$x.$timezone=S,L},u.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},u.tz.setDefault=function(h){l=h}}})})(_0);const S0=jr;var Rr={},T0={get exports(){return Rr},set exports(e){Rr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.toArray=function(){return[this.$y,this.$M,this.$D,this.$H,this.$m,this.$s,this.$ms]}}})})(T0);const D0=Rr;var Yr={},k0={get exports(){return Yr},set exports(e){Yr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.toObject=function(){return{years:this.$y,months:this.$M,date:this.$D,hours:this.$H,minutes:this.$m,seconds:this.$s,milliseconds:this.$ms}}}})})(k0);const I0=Yr;var Qr={},M0={get exports(){return Qr},set exports(e){Qr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i,s){s.updateLocale=function(o,u){var l=s.Ls[o];if(l)return(u?Object.keys(u):[]).forEach(function(d){l[d]=u[d]}),l}}})})(M0);const A0=Qr;var Ur={},z0={get exports(){return Ur},set exports(e){Ur=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r="minute",i=/[+-]\d\d(?::?\d\d)?/g,s=/([+-]|\d\d)/g;return function(o,u,l){var d=u.prototype;l.utc=function(C){var S={date:C,utc:!0,args:arguments};return new u(S)},d.utc=function(C){var S=l(this.toDate(),{locale:this.$L,utc:!0});return C?S.add(this.utcOffset(),r):S},d.local=function(){return l(this.toDate(),{locale:this.$L,utc:!1})};var c=d.parse;d.parse=function(C){C.utc&&(this.$u=!0),this.$utils().u(C.$offset)||(this.$offset=C.$offset),c.call(this,C)};var f=d.init;d.init=function(){if(this.$u){var C=this.$d;this.$y=C.getUTCFullYear(),this.$M=C.getUTCMonth(),this.$D=C.getUTCDate(),this.$W=C.getUTCDay(),this.$H=C.getUTCHours(),this.$m=C.getUTCMinutes(),this.$s=C.getUTCSeconds(),this.$ms=C.getUTCMilliseconds()}else f.call(this)};var g=d.utcOffset;d.utcOffset=function(C,S){var A=this.$utils().u;if(A(C))return this.$u?0:A(this.$offset)?g.call(this):this.$offset;if(typeof C=="string"&&(C=function(L){L===void 0&&(L="");var $=L.match(i);if(!$)return null;var M=(""+$[0]).match(s)||["-",0,0],N=M[0],Q=60*+M[1]+ +M[2];return Q===0?0:N==="+"?Q:-Q}(C),C===null))return this;var z=Math.abs(C)<=16?60*C:C,G=this;if(S)return G.$offset=z,G.$u=C===0,G;if(C!==0){var F=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(G=this.local().add(z+F,r)).$offset=z,G.$x.$localOffset=F}else G=this.utc();return G};var h=d.format;d.format=function(C){var S=C||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,S)},d.valueOf=function(){var C=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*C},d.isUTC=function(){return!!this.$u},d.toISOString=function(){return this.toDate().toISOString()},d.toString=function(){return this.toDate().toUTCString()};var b=d.toDate;d.toDate=function(C){return C==="s"&&this.$offset?l(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():b.call(this)};var w=d.diff;d.diff=function(C,S,A){if(C&&this.$u===C.$u)return w.call(this,C,S,A);var z=this.local(),G=l(C).local();return w.call(z,G,S,A)}}})})(z0);const $0=Ur;var Xr={},E0={get exports(){return Xr},set exports(e){Xr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.weekday=function(s){var o=this.$locale().weekStart||0,u=this.$W,l=(u<o?u+7:u)-o;return this.$utils().u(s)?l:this.subtract(l,"day").add(s,"day")}}})})(E0);const L0=Xr;var Zr={},P0={get exports(){return Zr},set exports(e){Zr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){var r="week",i="year";return function(s,o,u){var l=o.prototype;l.week=function(d){if(d===void 0&&(d=null),d!==null)return this.add(7*(d-this.week()),"day");var c=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var f=u(this).startOf(i).add(1,i).date(c),g=u(this).endOf(r);if(f.isBefore(g))return 1}var h=u(this).startOf(i).date(c).startOf(r).subtract(1,"millisecond"),b=this.diff(h,r,!0);return b<0?u(this).startOf("week").week():Math.ceil(b)},l.weeks=function(d){return d===void 0&&(d=null),this.week(d)}}})})(P0);const O0=Zr;var Kr={},V0={get exports(){return Kr},set exports(e){Kr=e}};(function(e,t){(function(r,i){e.exports=i()})(H,function(){return function(r,i){i.prototype.weekYear=function(){var s=this.month(),o=this.week(),u=this.year();return o===1&&s===11?u+1:s===0&&o>=52?u-1:u}}})})(V0);const B0=Kr;W.extend(DC),W.extend(IC),W.extend(AC),W.extend($C),W.extend(LC),W.extend(OC),W.extend(BC),W.extend(GC),W.extend(FC),W.extend(jC),W.extend(YC),W.extend(JC),W.extend(e0),W.extend(n0),W.extend(i0),W.extend(s0),W.extend(UC),W.extend(ZC),W.extend(l0),W.extend(d0),W.extend(p0),W.extend(f0),W.extend(m0),W.extend(v0),W.extend(x0),W.extend(w0),W.extend(S0),W.extend(D0),W.extend(I0),W.extend(A0),W.extend($0),W.extend(O0),W.extend(B0),W.extend(L0),W.tz.setDefault("UTC");const N0=()=>Promise.resolve().then(()=>No).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));k.ContextModel=as,k.Dashboard=_C,k.DashboardFilterType=tr,k.DashboardMode=Oa,k.DashboardModel=rn,k.DashboardViewEditor=Ba,k.DashboardViewRender=en,k.EViewComponentType=K,k.FilterModel=rr,k.FiltersModel=Za,k.FullScreenPanelContext=yn,k.LayoutStateContext=Xe,k.ModelContextProvider=mn,k.Panel=Ht,k.PanelContextProvider=vn,k.PanelModel=ss,k.PanelsModel=ls,k.QueriesModel=ns,k.QueryModel=ts,k.ReadOnlyDashboard=SC,k.SQLSnippetModel=rs,k.SQLSnippetsModel=is,k.ViewComponentTypeBackground=Va,k.ViewComponentTypeColor=zb,k.ViewComponentTypeName=Ab,k.ViewModel=ps,k.ViewsModel=hs,k.applyPartialDashboard=Fv,k.createDashboardModel=ur,k.createDashboardViewsModel=lr,k.getInitialFiltersPayload=Ka,k.getNewPanel=os,k.getVersion=N0,k.useFullScreenPanelContext=Mi,k.useModelContext=B,k.usePanelContext=xe,k.useTopLevelServices=dr,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})});
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export declare const EditSQLSnippet: (({ id }: {
3
3
  id: string;
4
- }) => JSX.Element) & {
4
+ }) => JSX.Element | null) & {
5
5
  displayName: string;
6
6
  };
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  export declare const EditView: (({ id }: {
3
3
  id: string;
4
- }) => JSX.Element) & {
4
+ }) => JSX.Element | null) & {
5
5
  displayName: string;
6
6
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtable/dashboard",
3
- "version": "8.59.6",
3
+ "version": "8.60.1",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -34,7 +34,7 @@
34
34
  "@monaco-editor/react": "4.4.6",
35
35
  "@types/chroma-js": "^2.1.4",
36
36
  "file-saver": "2.0.5",
37
- "mathjs": "11.7.0",
37
+ "mathjs": "11.8.0",
38
38
  "monaco-editor": "0.36.0",
39
39
  "performant-array-to-tree": "1.11.0",
40
40
  "popmotion": "^11.0.3",
@@ -83,7 +83,7 @@
83
83
  "@types/react-dom": "^18.0.0",
84
84
  "@types/react-grid-layout": "^1.3.2",
85
85
  "ahooks": "^3.3.11",
86
- "ajv": "8.11.0",
86
+ "ajv": "8.12.0",
87
87
  "axios": "^0.27.2",
88
88
  "crypto-js": "^4.1.1",
89
89
  "cypress": "^12.9.0",
@@ -143,7 +143,7 @@
143
143
  "chroma-js": "^2.4.2",
144
144
  "crypto-js": "^4.1.1",
145
145
  "d3-array": "3.2.3",
146
- "d3-regression": "1.2.8",
146
+ "d3-regression": "1.3.10",
147
147
  "dayjs": "1.11.7",
148
148
  "echarts": "^5.3.2",
149
149
  "echarts-for-react": "^3.0.2",