@devtable/dashboard 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/dashboard.es.js +8251 -14258
  2. package/dist/dashboard.umd.js +38 -19
  3. package/package.json +18 -4
  4. package/dist/api-caller/index.d.ts +0 -20
  5. package/dist/api-caller/request.d.ts +0 -5
  6. package/dist/api-caller/types.d.ts +0 -11
  7. package/dist/contexts/context-info-context.d.ts +0 -5
  8. package/dist/contexts/dashboard-action-context.d.ts +0 -9
  9. package/dist/contexts/definition-context.d.ts +0 -7
  10. package/dist/contexts/filter-values-context.d.ts +0 -4
  11. package/dist/contexts/index.d.ts +0 -5
  12. package/dist/contexts/layout-state-context.d.ts +0 -11
  13. package/dist/contexts/panel-context.d.ts +0 -17
  14. package/dist/definition-editor/data-editor-modal.d.ts +0 -7
  15. package/dist/definition-editor/global-variables-guide.d.ts +0 -8
  16. package/dist/definition-editor/index.d.ts +0 -1
  17. package/dist/definition-editor/query-editor/data-preview.d.ts +0 -4
  18. package/dist/definition-editor/query-editor/editor.d.ts +0 -7
  19. package/dist/definition-editor/query-editor/form.d.ts +0 -8
  20. package/dist/definition-editor/query-editor/index.d.ts +0 -5
  21. package/dist/definition-editor/query-editor/preview-sql.d.ts +0 -6
  22. package/dist/definition-editor/query-editor/select-or-add-query.d.ts +0 -7
  23. package/dist/definition-editor/sql-snippet-editor/editor.d.ts +0 -5
  24. package/dist/definition-editor/sql-snippet-editor/index.d.ts +0 -5
  25. package/dist/definition-editor/sql-snippet-editor/preview-snippet.d.ts +0 -6
  26. package/dist/filter/filter-checkbox/editor.d.ts +0 -8
  27. package/dist/filter/filter-checkbox/render.d.ts +0 -10
  28. package/dist/filter/filter-date-range/editor.d.ts +0 -7
  29. package/dist/filter/filter-date-range/render.d.ts +0 -10
  30. package/dist/filter/filter-multi-select/editor.d.ts +0 -7
  31. package/dist/filter/filter-multi-select/render.d.ts +0 -10
  32. package/dist/filter/filter-query-field/index.d.ts +0 -8
  33. package/dist/filter/filter-query-field/select-data-source.d.ts +0 -8
  34. package/dist/filter/filter-query-field/test-query.d.ts +0 -7
  35. package/dist/filter/filter-select/editor.d.ts +0 -7
  36. package/dist/filter/filter-select/render.d.ts +0 -10
  37. package/dist/filter/filter-settings/filter-setting.d.ts +0 -8
  38. package/dist/filter/filter-settings/filter-settings.d.ts +0 -7
  39. package/dist/filter/filter-settings/index.d.ts +0 -9
  40. package/dist/filter/filter-settings/preview-filter.d.ts +0 -7
  41. package/dist/filter/filter-text-input/editor.d.ts +0 -7
  42. package/dist/filter/filter-text-input/render.d.ts +0 -10
  43. package/dist/filter/filter.d.ts +0 -9
  44. package/dist/filter/index.d.ts +0 -9
  45. package/dist/index.d.ts +0 -5
  46. package/dist/layout/index.d.ts +0 -12
  47. package/dist/layout/read-only.d.ts +0 -9
  48. package/dist/main/actions.d.ts +0 -14
  49. package/dist/main/full-screen-panel.d.ts +0 -6
  50. package/dist/main/index.d.ts +0 -2
  51. package/dist/main/main.d.ts +0 -12
  52. package/dist/main/read-only.d.ts +0 -11
  53. package/dist/main/toggle-mode.d.ts +0 -8
  54. package/dist/main/use-filters.d.ts +0 -2128
  55. package/dist/main/use-panel-full-screen.d.ts +0 -7
  56. package/dist/main/view-schema-modal.d.ts +0 -8
  57. package/dist/model/dashboard.d.ts +0 -8103
  58. package/dist/model/filter/checkbox.d.ts +0 -16
  59. package/dist/model/filter/common.d.ts +0 -14
  60. package/dist/model/filter/date-range.d.ts +0 -28
  61. package/dist/model/filter/index.d.ts +0 -172
  62. package/dist/model/filter/multi-select.d.ts +0 -81
  63. package/dist/model/filter/select.d.ts +0 -95
  64. package/dist/model/filter/text-input.d.ts +0 -22
  65. package/dist/model/index.d.ts +0 -2
  66. package/dist/panel/error-boundary.d.ts +0 -13
  67. package/dist/panel/index.d.ts +0 -7
  68. package/dist/panel/panel-description.d.ts +0 -5
  69. package/dist/panel/settings/common/aggregation-selector.d.ts +0 -9
  70. package/dist/panel/settings/common/color-array-input.d.ts +0 -8
  71. package/dist/panel/settings/common/data-field-selector.d.ts +0 -12
  72. package/dist/panel/settings/common/mantine-color.d.ts +0 -7
  73. package/dist/panel/settings/common/mantine-font-weight.d.ts +0 -8
  74. package/dist/panel/settings/common/numbro-format-selector.d.ts +0 -13
  75. package/dist/panel/settings/common/text-array-input.d.ts +0 -8
  76. package/dist/panel/settings/index.d.ts +0 -7
  77. package/dist/panel/settings/panel-config/description.d.ts +0 -2
  78. package/dist/panel/settings/panel-config/index.d.ts +0 -5
  79. package/dist/panel/settings/panel-config/preview-panel.d.ts +0 -2
  80. package/dist/panel/settings/panel-config/title.d.ts +0 -2
  81. package/dist/panel/settings/pick-query/index.d.ts +0 -5
  82. package/dist/panel/settings/viz-config/index.d.ts +0 -5
  83. package/dist/panel/settings/viz-config/preview-viz.d.ts +0 -5
  84. package/dist/panel/settings/viz-config/viz-conf.d.ts +0 -2
  85. package/dist/panel/title-bar.d.ts +0 -5
  86. package/dist/panel/viz/bar-3d/index.d.ts +0 -9
  87. package/dist/panel/viz/bar-3d/panel.d.ts +0 -3
  88. package/dist/panel/viz/cartesian/index.d.ts +0 -10
  89. package/dist/panel/viz/cartesian/option/regression.d.ts +0 -20
  90. package/dist/panel/viz/cartesian/panel/index.d.ts +0 -3
  91. package/dist/panel/viz/cartesian/panel/regressions/index.d.ts +0 -11
  92. package/dist/panel/viz/cartesian/panel/regressions/regression-item.d.ts +0 -16
  93. package/dist/panel/viz/cartesian/panel/series/fields.bar.d.ts +0 -9
  94. package/dist/panel/viz/cartesian/panel/series/fields.line.d.ts +0 -9
  95. package/dist/panel/viz/cartesian/panel/series/fields.scatter.d.ts +0 -9
  96. package/dist/panel/viz/cartesian/panel/series/index.d.ts +0 -11
  97. package/dist/panel/viz/cartesian/panel/series/series-item.d.ts +0 -16
  98. package/dist/panel/viz/cartesian/panel/stats/index.d.ts +0 -10
  99. package/dist/panel/viz/cartesian/panel/stats/variable.d.ts +0 -11
  100. package/dist/panel/viz/cartesian/panel/y-axes.d.ts +0 -9
  101. package/dist/panel/viz/cartesian/type.d.ts +0 -58
  102. package/dist/panel/viz/index.d.ts +0 -9
  103. package/dist/panel/viz/pie/index.d.ts +0 -9
  104. package/dist/panel/viz/pie/panel.d.ts +0 -3
  105. package/dist/panel/viz/rich-text/index.d.ts +0 -10
  106. package/dist/panel/viz/rich-text/panel.d.ts +0 -3
  107. package/dist/panel/viz/rich-text/type.d.ts +0 -8
  108. package/dist/panel/viz/stats/index.d.ts +0 -10
  109. package/dist/panel/viz/stats/panel/index.d.ts +0 -10
  110. package/dist/panel/viz/stats/panel/variable.d.ts +0 -11
  111. package/dist/panel/viz/stats/panel/variables.d.ts +0 -10
  112. package/dist/panel/viz/stats/types.d.ts +0 -6
  113. package/dist/panel/viz/stats/update/index.d.ts +0 -15
  114. package/dist/panel/viz/sunburst/index.d.ts +0 -9
  115. package/dist/panel/viz/sunburst/panel.d.ts +0 -3
  116. package/dist/panel/viz/table/index.d.ts +0 -10
  117. package/dist/panel/viz/table/panel.d.ts +0 -3
  118. package/dist/panel/viz/table/type.d.ts +0 -21
  119. package/dist/panel/viz/table/value-type-selector.d.ts +0 -10
  120. package/dist/panel/viz/table/value.d.ts +0 -8
  121. package/dist/types/dashboard.d.ts +0 -49
  122. package/dist/types/filter.d.ts +0 -7
  123. package/dist/types/index.d.ts +0 -3
  124. package/dist/types/viz-panel.d.ts +0 -6
  125. package/dist/utils/aggregation.d.ts +0 -2
  126. package/dist/utils/color-mapping.d.ts +0 -9
  127. package/dist/utils/sql.d.ts +0 -8
  128. package/dist/utils/template/editor.d.ts +0 -16
  129. package/dist/utils/template/render.d.ts +0 -3
  130. package/dist/utils/template/types.d.ts +0 -21
  131. package/dist/vite-env.d.ts +0 -1
@@ -1,4 +1,4 @@
1
- (function(w,z){typeof exports=="object"&&typeof module!="undefined"?z(exports,require("react"),require("lodash"),require("react-grid-layout"),require("@mantine/core"),require("ahooks"),require("axios"),require("@mantine/modals"),require("tabler-icons-react"),require("@mantine/rte"),require("@mantine/hooks"),require("echarts-for-react/lib/core"),require("echarts/core"),require("echarts/charts"),require("echarts/renderers"),require("echarts-stat"),require("echarts/components"),require("numbro"),require("echarts-gl"),require("react-hook-form"),require("@mantine/form"),require("@mantine/prism"),require("react-dom"),require("@mantine/dates")):typeof define=="function"&&define.amd?define(["exports","react","lodash","react-grid-layout","@mantine/core","ahooks","axios","@mantine/modals","tabler-icons-react","@mantine/rte","@mantine/hooks","echarts-for-react/lib/core","echarts/core","echarts/charts","echarts/renderers","echarts-stat","echarts/components","numbro","echarts-gl","react-hook-form","@mantine/form","@mantine/prism","react-dom","@mantine/dates"],z):(w=typeof globalThis!="undefined"?globalThis:w||self,z(w.dashboard={},w.React,w._,w["react-grid-layout"],w["@mantine/core"],w.ahooks,w.axios,w["@mantine/modals"],w["tabler-icons-react"],w["@mantine/rte"],w["@mantine/hooks"],w["echarts-for-react/lib/core"],w["echarts/core"],w["echarts/charts"],w["echarts/renderers"],w["echarts-stat"],w["echarts/components"],w.numbro,w["echarts-gl"],w["react-hook-form"],w["@mantine/form"],w["@mantine/prism"],w.ReactDOM,w["@mantine/dates"]))})(this,function(w,z,qe,Rr,s,Be,Fo,Vr,_,En,W,qo,Bo,wt,Yt,Go,Ge,$o,Lp,O,St,$e,Uo,Wo){"use strict";var zp=Object.defineProperty;var Np=(w,z,qe)=>z in w?zp(w,z,{enumerable:!0,configurable:!0,writable:!0,value:qe}):w[z]=qe;var Lo=(w,z,qe)=>(Np(w,typeof z!="symbol"?z+"":z,qe),qe);function Ue(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}function Yo(e){if(e&&e.__esModule)return e;var r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});return e&&Object.keys(e).forEach(function(t){if(t!=="default"){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}}),r.default=e,Object.freeze(r)}var h=Ue(z),C=Ue(qe),In=Ue(Rr),Qo=Ue(Fo),kr=Ue(En),Qt=Ue(qo),Oe=Yo(Bo),Kt=Ue($o),le=(e=>(e.Use="use",e.Layout="layout",e.Edit="edit",e))(le||{});const Ko={layoutFrozen:!1,freezeLayout:()=>{},mode:le.Edit,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},be=h.default.createContext(Ko);function Ho(e,r){const t=Object.keys(r),n=Object.values(r);try{return new Function(...t,`return \`${e}\`;`)(...n)}catch(i){return console.error(i),i.message}}function zr(e,r){const t=Object.keys(r),n=Object.values(r);try{return new Function(...t,`return \`${e}\`;`)(...n)}catch(i){throw t.length===0&&e.includes("$")?new Error("[formatSQL] insufficient params"):i}}function Dn(e,r,t){const n=r.sqlSnippets.reduce((i,a)=>(i[a.key]=zr(a.value,e),i),{});return C.default.merge({},n,e,{filters:t})}function Jo(e,r,t,n){try{const i=Dn(r,t,n);return zr(e,i)}catch(i){return console.error(i),i.message}}const We={baseURL:"http://localhost:31200",getRequest(e){return(r,t,n={})=>{const i={"X-Requested-With":"XMLHttpRequest","Content-Type":n.string?"application/x-www-form-urlencoded":"application/json",...n.headers},a={baseURL:this.baseURL,method:e,url:r,params:e==="GET"?t:n.params,headers:i};return e==="POST"&&(a.data=n.string?JSON.stringify(t):t),Qo.default(a).then(o=>o.data).catch(o=>Promise.reject(o))}}},Nr=({type:e,key:r,sql:t})=>async()=>{if(!e||!r||!t)return[];try{return await We.getRequest("POST")("/query",{type:e,key:r,query:t})}catch(n){return console.error(n),[]}},Mn=({context:e,definitions:r,title:t,query:n,filterValues:i})=>async()=>{if(!n||!n.sql)return[];const{type:a,key:o,sql:u}=n,c=u.includes("$");try{const d=Dn(e,r,i),f=zr(u,d);return c&&(console.groupCollapsed(`Final SQL for: ${t}`),console.log(f),console.groupEnd()),await We.getRequest("POST")("/query",{type:a,key:o,query:f})}catch(d){return console.error(d),[]}};async function Rn(){try{return(await We.getRequest("POST")("/datasource/list",{filter:{},sort:{field:"create_time",order:"ASC"},pagination:{page:1,pagesize:100}})).data}catch(e){return console.error(e),[]}}const Vn={},Xo=Vn,Ie=h.default.createContext(Vn),Zo={id:"",data:[],loading:!1,title:"",setTitle:()=>{},description:"",setDescription:()=>{},queryID:"",setQueryID:()=>{},viz:{type:"",conf:{}},setViz:()=>{},refreshData:()=>{}},se=h.default.createContext(Zo),eu={addPanel:C.default.noop,duplidatePanel:C.default.noop,removePanelByID:C.default.noop,viewPanelInFullScreen:C.default.noop,inFullScreen:!1},Ht=h.default.createContext(eu),tu={sqlSnippets:[],setSQLSnippets:()=>{},queries:[],setQueries:()=>{}},ce=h.default.createContext(tu),kn={},ru=kn,Ye=h.default.createContext(kn);var Jt={exports:{}},Xt={};/**
1
+ (function(ge,Re){typeof exports=="object"&&typeof module<"u"?Re(exports,require("react"),require("lodash"),require("react-grid-layout"),require("@mantine/core"),require("@mantine/modals"),require("mobx-react-lite"),require("tabler-icons-react"),require("@mantine/rte"),require("@mantine/hooks"),require("echarts-for-react/lib/core"),require("echarts/core"),require("echarts/charts"),require("echarts/renderers"),require("echarts-stat"),require("echarts/components"),require("numbro"),require("echarts-gl"),require("react-hook-form"),require("@mantine/form"),require("@mantine/prism"),require("ahooks"),require("axios"),require("mobx-state-tree"),require("@mantine/dates"),require("mobx")):typeof define=="function"&&define.amd?define(["exports","react","lodash","react-grid-layout","@mantine/core","@mantine/modals","mobx-react-lite","tabler-icons-react","@mantine/rte","@mantine/hooks","echarts-for-react/lib/core","echarts/core","echarts/charts","echarts/renderers","echarts-stat","echarts/components","numbro","echarts-gl","react-hook-form","@mantine/form","@mantine/prism","ahooks","axios","mobx-state-tree","@mantine/dates","mobx"],Re):(ge=typeof globalThis<"u"?globalThis:ge||self,Re(ge.dashboard={},ge.React,ge._,ge["react-grid-layout"],ge["@mantine/core"],ge["@mantine/modals"],ge["mobx-react-lite"],ge["tabler-icons-react"],ge["@mantine/rte"],ge["@mantine/hooks"],ge["echarts-for-react/lib/core"],ge["echarts/core"],ge["echarts/charts"],ge["echarts/renderers"],ge["echarts-stat"],ge["echarts/components"],ge.numbro,ge["echarts-gl"],ge["react-hook-form"],ge["@mantine/form"],ge["@mantine/prism"],ge.ahooks,ge.axios,ge["mobx-state-tree"],ge["@mantine/dates"],ge.mobx))})(this,function(ge,Re,$e,Lt,c,Bt,Ce,he,ir,Be,yn,_n,ft,xt,wn,nt,xn,Ns,be,Mt,it,ut,kn,se,Sn,Cn){"use strict";var js=Object.defineProperty;var qs=(ge,Re,$e)=>Re in ge?js(ge,Re,{enumerable:!0,configurable:!0,writable:!0,value:$e}):ge[Re]=$e;var rt=(ge,Re,$e)=>(qs(ge,typeof Re!="symbol"?Re+"":Re,$e),$e);const at=t=>t&&typeof t=="object"&&"default"in t?t:{default:t};function En(t){if(t&&t.__esModule)return t;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,o.get?o:{enumerable:!0,get:()=>t[r]})}}return e.default=t,Object.freeze(e)}const V=at(Re),ye=at($e),ar=at(Lt),jt=at(ir),kt=at(yn),Ze=En(_n),St=at(xn),Tn=at(kn);var Ge=(t=>(t.Use="use",t.Layout="layout",t.Edit="edit",t))(Ge||{});const An={layoutFrozen:!1,freezeLayout:()=>{},mode:Ge.Edit,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},Ve=V.default.createContext(An),zn={id:"",data:[],loading:!1,title:"",setTitle:()=>{},description:"",setDescription:()=>{},queryID:"",setQueryID:()=>{},viz:{type:"",conf:{}},setViz:()=>{}},Ue=V.default.createContext(zn),sr=V.default.createContext(null),qt=sr.Provider;function Fe(){const t=V.default.useContext(sr);if(!t)throw new Error("Please use ModelContextProvider");return t}const On={addPanel:ye.default.noop,duplidatePanel:ye.default.noop,removePanelByID:ye.default.noop,viewPanelInFullScreen:ye.default.noop,inFullScreen:!1},Ct=V.default.createContext(On);var Qe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Et={exports:{}},ht={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,9 +6,27 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var nu=h.default,iu=Symbol.for("react.element"),au=Symbol.for("react.fragment"),ou=Object.prototype.hasOwnProperty,uu=nu.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,lu={key:!0,ref:!0,__self:!0,__source:!0};function zn(e,r,t){var n,i={},a=null,o=null;t!==void 0&&(a=""+t),r.key!==void 0&&(a=""+r.key),r.ref!==void 0&&(o=r.ref);for(n in r)ou.call(r,n)&&!lu.hasOwnProperty(n)&&(i[n]=r[n]);if(e&&e.defaultProps)for(n in r=e.defaultProps,r)i[n]===void 0&&(i[n]=r[n]);return{$$typeof:iu,type:e,key:a,ref:o,props:i,_owner:uu.current}}Xt.Fragment=au,Xt.jsx=zn,Xt.jsxs=zn,Jt.exports=Xt;const l=Jt.exports.jsx,b=Jt.exports.jsxs,Y=Jt.exports.Fragment;function Nn({}){const{freezeLayout:e}=h.default.useContext(be),[r,t]=h.default.useState(!1),{title:n,description:i}=h.default.useContext(se);return h.default.useEffect(()=>{e(r)},[r]),!i||i==="<p><br></p>"?null:b(Y,{children:[l(s.Modal,{opened:r,onClose:()=>t(!1),title:n,withCloseButton:!1,children:l(kr.default,{readOnly:!0,value:i,onChange:C.default.noop,sx:{border:"none"}})}),l(s.Tooltip,{label:"Click to see description",position:"top-start",children:l(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>t(a=>!a),sx:{verticalAlign:"baseline",cursor:"pointer"},children:l(_.InfoCircle,{size:20})})})]})}function su(){const{description:e,setDescription:r}=h.default.useContext(se),[t,n]=h.default.useState(e),i=e!==t,a=h.default.useCallback(()=>{!i||r(t)},[i,t]);return b(s.Stack,{sx:{flexGrow:1},children:[b(s.Group,{align:"end",children:[l(s.Text,{children:"Description"}),l(s.ActionIcon,{variant:"subtle",color:"blue",disabled:!i,onClick:a,children:l(_.DeviceFloppy,{size:20})})]}),l(En.RichTextEditor,{value:t,onChange:n,sx:{flexGrow:1},sticky:!0,p:"0"})]})}class Zt extends h.default.Component{constructor(r){super(r),this.state={error:null}}componentDidCatch(r){this.setState({error:r})}render(){var r;if(this.state.error){const t=()=>{this.setState({error:null})};return b(s.Box,{children:[l(s.Text,{size:"xs",children:(r=this.state.error)==null?void 0:r.message}),l(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:t,children:"Retry"})]})}return this.props.children}}function cu(){const{title:e}=h.default.useContext(se);return l(Zt,{children:b(s.Stack,{mx:"auto",mt:"xl",p:"5px",spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",boxShadow:"0px 0px 10px 0px rgba(0,0,0,.2)"},children:[b(s.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[l(s.Group,{children:l(Nn,{})}),l(s.Group,{grow:!0,position:"center",children:l(s.Text,{lineClamp:1,weight:"bold",children:e})}),l(s.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),l(s.Group,{sx:{background:"#eee",flexGrow:1}})]})})}function fu(){const{title:e,setTitle:r}=h.default.useContext(se),[t,n]=W.useInputState(e),i=e!==t,a=h.default.useCallback(()=>{!i||r(t)},[i,t]);return l(s.TextInput,{value:t,onChange:n,label:b(s.Group,{align:"end",children:[l(s.Text,{children:"Panel Title"}),l(s.ActionIcon,{variant:"subtle",color:"blue",disabled:!i,onClick:a,children:l(_.DeviceFloppy,{size:20})})]})})}function du({}){return b(s.Group,{grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[b(s.Stack,{sx:{width:"40%",flexShrink:0,flexGrow:0,height:"100%"},children:[l(fu,{}),l(su,{})]}),l(s.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:l(cu,{})})]})}function Ln({id:e}){const r=h.default.useContext(ce),t=h.default.useContext(Ye),n=h.default.useContext(Ie),i=h.default.useMemo(()=>r.queries.find(c=>c.id===e),[r.queries,e]),{data:a=[],loading:o,refresh:u}=Be.useRequest(Mn({context:n,definitions:r,filterValues:t,title:e,query:i}),{refreshDeps:[n,r,i,t]});return o?l(s.LoadingOverlay,{visible:o,exitTransitionDuration:0}):a.length===0?l(s.Table,{}):b(s.Stack,{my:"xl",sx:{border:"1px solid #eee"},children:[b(s.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[b(s.Group,{position:"left",children:[l(s.Text,{weight:500,children:"Preview Data"}),a.length>10&&b(s.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",a.length]})]}),l(s.ActionIcon,{mr:15,variant:"subtle",color:"blue",disabled:o,onClick:u,children:l(_.Refresh,{size:15})})]}),b(s.Table,{children:[l("thead",{children:l("tr",{children:Object.keys(a==null?void 0:a[0]).map(c=>l("th",{children:l(s.Text,{weight:700,color:"#000",children:c})},c))})}),l("tbody",{children:a.slice(0,10).map((c,d)=>l("tr",{children:Object.values(c).map((f,p)=>l("td",{children:l(s.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:l(s.Text,{children:f})})},`${f}--${p}`))},`row-${d}`))})]})]})}function pu({}){const{queries:e}=h.default.useContext(ce),{queryID:r,setQueryID:t,data:n,loading:i}=h.default.useContext(se),a=h.default.useMemo(()=>e.map(o=>({value:o.id,label:o.id})),[e]);return b(s.Stack,{children:[b(s.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[l(s.Text,{children:"Select a Query"}),l(s.Select,{data:a,value:r,onChange:t,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}})]}),l(Ln,{id:r})]})}Oe.use([wt.SunburstChart,Yt.CanvasRenderer]);const hu={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function bu({conf:e,data:r,width:t,height:n}){const{label_field:i="name",value_field:a="value",...o}=e,u=h.default.useMemo(()=>r.map(p=>({name:p[i],value:Number(p[a])})),[r,i,a]),c=h.default.useMemo(()=>{var p,v;return(v=(p=C.default.maxBy(u,y=>y.value))==null?void 0:p.value)!=null?v:1},[u]),d=h.default.useMemo(()=>({series:{label:{formatter:({name:p,value:v})=>v/c<.2?" ":p}}}),[c]),f=C.default.merge({},hu,d,o,{series:{data:u}});return l(Qt.default,{echarts:Oe,option:f,style:{width:t,height:n}})}function vu({regressions:e=[]},r){const t=[],n=[],i=[];return r.length===0?{regressionDataSets:t,regressionSeries:n,regressionXAxes:i}:(e.forEach(({transform:a,plot:o,name:u,y_axis_data_key:c})=>{const d=`x-axis-for-${u}`,f=`dataset-for-${u}--raw`,p=`dataset-for-${u}--transformed`;t.push({id:f,source:r.map((v,y)=>[y,v[c]])}),t.push({transform:a,id:p,fromDatasetId:f}),n.push({...o,name:u,datasetId:p,xAxisId:d,showSymbol:!1,tooltip:{show:!1}}),i.push({type:"category",id:d,datasetId:p,show:!1})}),{regressionDataSets:t,regressionSeries:n,regressionXAxes:i})}const mu={legend:{show:!0,bottom:0,left:0},tooltip:{trigger:"axis"},xAxis:{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"}},grid:{top:0,left:15,right:15,bottom:30,containLabel:!0}};function yu(e,r){var d;const t=e.y_axes.reduce((f,{label_formatter:p},v)=>(f[v]=function(P){const j=typeof P=="object"?P.value:P;if(!p)return j;try{return Kt.default(j).format(p)}catch(I){return console.error(I),j}},f),{default:({value:f})=>f}),n=e.series.reduce((f,{yAxisIndex:p,name:v})=>(f[v]=p,f),{}),i=e.series.map(({y_axis_data_key:f,yAxisIndex:p,label_position:v,name:y,...P})=>({data:r.map(I=>I[f]),label:{show:!!v,position:v,formatter:t[p!=null?p:"default"]},name:y,xAxisId:"main-x-axis",yAxisIndex:p,...P})),{regressionDataSets:a,regressionSeries:o,regressionXAxes:u}=vu(e,r),c={xAxis:[{data:r.map(f=>f[e.x_axis_data_key]),name:(d=e.x_axis_name)!=null?d:"",id:"main-x-axis"},...u],yAxis:e.y_axes.map(({label_formatter:f,...p},v)=>{var y;return{...p,axisLabel:{show:!0,formatter:(y=t[v])!=null?y:t.default}}}),dataset:[...a],series:[...i,...o],tooltip:{formatter:function(f){const p=Array.isArray(f)?f:[f];if(p.length===0)return"";const v=p.map(({seriesName:y,value:P})=>{var $;if(!y)return P;const j=n[y],I=($=t[j])!=null?$:t.default;return`${y}: ${I({value:P})}`});return v.unshift(`<strong>${p[0].name}</strong>`),v.join("<br />")}}};return C.default.merge({},mu,c)}function gu(e){const r=Array.from(e).sort((n,i)=>n-i),t=Math.floor(r.length/2);return r.length%2===0?(r[t-1]+r[t])/2:r[t]}function _u(e,r,t){var i,a,o;const n=e.map(u=>u[r]);switch(t){case"sum":return C.default.sum(n);case"mean":return C.default.mean(n);case"median":return gu(n);case"max":return(i=C.default.max(n))!=null?i:0;case"min":return(a=C.default.min(n))!=null?a:0;default:return(o=e[0])==null?void 0:o[r]}}var Fn=function(){};const wu=(e,r,t)=>Math.min(Math.max(t,e),r),qn=(e,r,t)=>{const n=r-e;return n===0?1:(t-e)/n},Lr=(e,r,t)=>-t*e+t*r+e,Bn=(e,r)=>t=>Math.max(Math.min(t,r),e),Ot=e=>e%1?Number(e.toFixed(5)):e,er=/(-)?([\d]*\.?[\d])+/g,Fr=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,Su=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function xt(e){return typeof e=="string"}const tr={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Gn=Object.assign(Object.assign({},tr),{transform:Bn(0,1)});Object.assign(Object.assign({},tr),{default:1});const Pt=(e=>({test:r=>xt(r)&&r.endsWith(e)&&r.split(" ").length===1,parse:parseFloat,transform:r=>`${r}${e}`}))("%");Object.assign(Object.assign({},Pt),{parse:e=>Pt.parse(e)/100,transform:e=>Pt.transform(e*100)});const qr=(e,r)=>t=>Boolean(xt(t)&&Su.test(t)&&t.startsWith(e)||r&&Object.prototype.hasOwnProperty.call(t,r)),$n=(e,r,t)=>n=>{if(!xt(n))return n;const[i,a,o,u]=n.match(er);return{[e]:parseFloat(i),[r]:parseFloat(a),[t]:parseFloat(o),alpha:u!==void 0?parseFloat(u):1}},Qe={test:qr("hsl","hue"),parse:$n("hue","saturation","lightness"),transform:({hue:e,saturation:r,lightness:t,alpha:n=1})=>"hsla("+Math.round(e)+", "+Pt.transform(Ot(r))+", "+Pt.transform(Ot(t))+", "+Ot(Gn.transform(n))+")"},Ou=Bn(0,255),Br=Object.assign(Object.assign({},tr),{transform:e=>Math.round(Ou(e))}),De={test:qr("rgb","red"),parse:$n("red","green","blue"),transform:({red:e,green:r,blue:t,alpha:n=1})=>"rgba("+Br.transform(e)+", "+Br.transform(r)+", "+Br.transform(t)+", "+Ot(Gn.transform(n))+")"};function xu(e){let r="",t="",n="",i="";return e.length>5?(r=e.substr(1,2),t=e.substr(3,2),n=e.substr(5,2),i=e.substr(7,2)):(r=e.substr(1,1),t=e.substr(2,1),n=e.substr(3,1),i=e.substr(4,1),r+=r,t+=t,n+=n,i+=i),{red:parseInt(r,16),green:parseInt(t,16),blue:parseInt(n,16),alpha:i?parseInt(i,16)/255:1}}const Gr={test:qr("#"),parse:xu,transform:De.transform},rr={test:e=>De.test(e)||Gr.test(e)||Qe.test(e),parse:e=>De.test(e)?De.parse(e):Qe.test(e)?Qe.parse(e):Gr.parse(e),transform:e=>xt(e)?e:e.hasOwnProperty("red")?De.transform(e):Qe.transform(e)},Un="${c}",Wn="${n}";function Pu(e){var r,t,n,i;return isNaN(e)&&xt(e)&&((t=(r=e.match(er))===null||r===void 0?void 0:r.length)!==null&&t!==void 0?t:0)+((i=(n=e.match(Fr))===null||n===void 0?void 0:n.length)!==null&&i!==void 0?i:0)>0}function Yn(e){typeof e=="number"&&(e=`${e}`);const r=[];let t=0;const n=e.match(Fr);n&&(t=n.length,e=e.replace(Fr,Un),r.push(...n.map(rr.parse)));const i=e.match(er);return i&&(e=e.replace(er,Wn),r.push(...i.map(tr.parse))),{values:r,numColors:t,tokenised:e}}function Qn(e){return Yn(e).values}function Kn(e){const{values:r,numColors:t,tokenised:n}=Yn(e),i=r.length;return a=>{let o=n;for(let u=0;u<i;u++)o=o.replace(u<t?Un:Wn,u<t?rr.transform(a[u]):Ot(a[u]));return o}}const Cu=e=>typeof e=="number"?0:e;function Au(e){const r=Qn(e);return Kn(e)(r.map(Cu))}const Hn={test:Pu,parse:Qn,createTransformer:Kn,getAnimatableNone:Au};function $r(e,r,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?e+(r-e)*6*t:t<1/2?r:t<2/3?e+(r-e)*(2/3-t)*6:e}function Jn({hue:e,saturation:r,lightness:t,alpha:n}){e/=360,r/=100,t/=100;let i=0,a=0,o=0;if(!r)i=a=o=t;else{const u=t<.5?t*(1+r):t+r-t*r,c=2*t-u;i=$r(c,u,e+1/3),a=$r(c,u,e),o=$r(c,u,e-1/3)}return{red:Math.round(i*255),green:Math.round(a*255),blue:Math.round(o*255),alpha:n}}const ju=(e,r,t)=>{const n=e*e,i=r*r;return Math.sqrt(Math.max(0,t*(i-n)+n))},Tu=[Gr,De,Qe],Xn=e=>Tu.find(r=>r.test(e)),Zn=(e,r)=>{let t=Xn(e),n=Xn(r),i=t.parse(e),a=n.parse(r);t===Qe&&(i=Jn(i),t=De),n===Qe&&(a=Jn(a),n=De);const o=Object.assign({},i);return u=>{for(const c in o)c!=="alpha"&&(o[c]=ju(i[c],a[c],u));return o.alpha=Lr(i.alpha,a.alpha,u),t.transform(o)}},Eu=e=>typeof e=="number",Iu=(e,r)=>t=>r(e(t)),ei=(...e)=>e.reduce(Iu);function ti(e,r){return Eu(e)?t=>Lr(e,r,t):rr.test(e)?Zn(e,r):ii(e,r)}const ri=(e,r)=>{const t=[...e],n=t.length,i=e.map((a,o)=>ti(a,r[o]));return a=>{for(let o=0;o<n;o++)t[o]=i[o](a);return t}},Du=(e,r)=>{const t=Object.assign(Object.assign({},e),r),n={};for(const i in t)e[i]!==void 0&&r[i]!==void 0&&(n[i]=ti(e[i],r[i]));return i=>{for(const a in n)t[a]=n[a](i);return t}};function ni(e){const r=Hn.parse(e),t=r.length;let n=0,i=0,a=0;for(let o=0;o<t;o++)n||typeof r[o]=="number"?n++:r[o].hue!==void 0?a++:i++;return{parsed:r,numNumbers:n,numRGB:i,numHSL:a}}const ii=(e,r)=>{const t=Hn.createTransformer(r),n=ni(e),i=ni(r);return n.numHSL===i.numHSL&&n.numRGB===i.numRGB&&n.numNumbers>=i.numNumbers?ei(ri(n.parsed,i.parsed),t):o=>`${o>0?r:e}`},Mu=(e,r)=>t=>Lr(e,r,t);function Ru(e){if(typeof e=="number")return Mu;if(typeof e=="string")return rr.test(e)?Zn:ii;if(Array.isArray(e))return ri;if(typeof e=="object")return Du}function Vu(e,r,t){const n=[],i=t||Ru(e[0]),a=e.length-1;for(let o=0;o<a;o++){let u=i(e[o],e[o+1]);if(r){const c=Array.isArray(r)?r[o]:r;u=ei(c,u)}n.push(u)}return n}function ku([e,r],[t]){return n=>t(qn(e,r,n))}function zu(e,r){const t=e.length,n=t-1;return i=>{let a=0,o=!1;if(i<=e[0]?o=!0:i>=e[n]&&(a=n-1,o=!0),!o){let c=1;for(;c<t&&!(e[c]>i||c===n);c++);a=c-1}const u=qn(e[a],e[a+1],i);return r[a](u)}}function Nu(e,r,{clamp:t=!0,ease:n,mixer:i}={}){const a=e.length;Fn(a===r.length),Fn(!n||!Array.isArray(n)||n.length===a-1),e[0]>e[a-1]&&(e=[].concat(e),r=[].concat(r),e.reverse(),r.reverse());const o=Vu(r,n,i),u=a===2?ku(e,o):zu(e,o);return t?c=>u(wu(e[0],e[a-1],c)):u}class Lu{constructor({valueRange:r,colorRange:t}){Lo(this,"mapper");this.mapper=Nu(r,t)}getColor(r){return this.mapper(r)}}function Fu(e,r){return e.type==="static"?e.staticColor:e.type==="continuous"?new Lu(e).getColor(r):"black"}function qu(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Bu(e,r){const t={};return e.forEach(({name:n,color:i,data_field:a,aggregation:o,size:u,weight:c,formatter:d})=>{const f=_u(r,a,o);let p="";["string","number"].includes(typeof f)?p=Kt.default(f).format(d):p=qu(f),t[n]=l(s.Text,{sx:{fontSize:u,display:"inline"},color:Fu(i,f),weight:c,children:p})}),t}function Gu(e){return e.split(" ").map(r=>b(Y,{children:[r,"\xA0"]}))}function $u(e){const t=e.replaceAll("<br />","<br/>").replaceAll(`
10
- `,"<br/>").split("<br/>");return t.map((i,a)=>{const o=[Gu(i)];return a!==t.length-1&&o.push(l("br",{})),o}).flat().filter(i=>i!==void 0)}function Ur(e){return $u(e)}function Wr(e,r,t){const n=Bu(r,t),i=/^\{(.+)\}(.*)$/;return e.split("$").map(a=>{var d;const o=i.exec(a);if(!o)return Ur(a);const u=n[o[1]];if(!u)return Ur(a);const c=(d=o[2])!=null?d:"";return b(Y,{children:[u,Ur(c)]})})}Oe.use([wt.BarChart,wt.LineChart,wt.ScatterChart,Ge.GridComponent,Ge.LegendComponent,Ge.TooltipComponent,Yt.CanvasRenderer]),Oe.registerTransform(Go.transform.regression);function ai(e){return e.trim().length>0}function Uu({conf:e,data:r,width:t,height:n}){const i=h.default.useMemo(()=>yu(e,r),[e,r]);return!t||!n?null:l(Qt.default,{echarts:Oe,option:i,style:{width:t,height:n}})}function Wu({conf:e,data:r,width:t,height:n}){const{ref:i,height:a}=W.useElementSize(),{ref:o,height:u}=W.useElementSize(),c=h.default.useMemo(()=>{const{stats:{templates:f,variables:p}}=e;return{top:Wr(f.top,p,r),bottom:Wr(f.bottom,p,r)}},[e,r]),d=Math.max(0,n-a-u);return b(s.Box,{children:[ai(e.stats.templates.top)&&l(s.Text,{ref:i,align:"left",size:"xs",pl:"sm",children:Object.values(c.top).map(f=>f)}),l(Uu,{width:t,height:d,data:r,conf:e}),ai(e.stats.templates.bottom)&&l(s.Text,{ref:o,align:"left",size:"xs",pl:"sm",children:Object.values(c.bottom).map(f=>f)})]})}var Me=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e))(Me||{});function Yu({value:e}){return l(s.Text,{component:"span",children:e})}function Qu({value:e}){return l(s.Text,{component:"span",children:e})}function Ku({value:e}){const r=Kt.default(e).format({thousandSeparated:!0});return l(s.Text,{component:"span",children:r})}function Hu({value:e}){const r=Kt.default(e).format({output:"percent",mantissa:3});return l(s.Text,{component:"span",children:r})}function Ju({value:e,type:r}){switch(r){case Me.string:return l(Yu,{value:e});case Me.eloc:return l(Qu,{value:e});case Me.number:return l(Ku,{value:e});case Me.percentage:return l(Hu,{value:e})}}function Xu({conf:e,data:r=[],width:t,height:n}){const{id_field:i,use_raw_columns:a,columns:o,...u}=e,c=h.default.useMemo(()=>a?Object.keys(r==null?void 0:r[0]):o.map(f=>f.label),[a,o,r]),d=h.default.useMemo(()=>a?Object.keys(r==null?void 0:r[0]).map(f=>({label:f,value_field:f,value_type:Me.string})):o,[a,o,r]);return b(s.Table,{sx:{maxHeight:n},...u,children:[l("thead",{children:l("tr",{children:c.map(f=>l("th",{children:f},f))})}),l("tbody",{children:r.slice(0,30).map((f,p)=>l("tr",{children:d.map(({value_field:v,value_type:y})=>l("td",{children:l(s.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace",fontSize:u.fontSize}},children:l(Ju,{value:f[v],type:y})})},`${v}--${f[v]}`))},i?f[i]:`row-${p}`))}),r.length>100&&l("tfoot",{children:l("tr",{children:l("td",{colSpan:c.length,children:l(s.Text,{color:"red",size:"sm",children:"Showing only the first 30 rows to avoid causing slow performance"})})})})]})}Oe.use([Ge.GridComponent,Ge.VisualMapComponent,Ge.LegendComponent,Ge.TooltipComponent,Yt.CanvasRenderer]);function Zu({conf:e,data:r,width:t,height:n}){const{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:o,...u}=e,c=h.default.useMemo(()=>C.default.minBy(r,p=>p[o])[o],[r,o]),d=h.default.useMemo(()=>C.default.maxBy(r,p=>p[o])[o],[r,o]),f={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:c,max:d,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:{type:"value"},yAxis3D:{type:"value"},zAxis3D:{type:"value"},grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},...u,series:[{type:"bar3D",wireframe:{},data:r.map(p=>[p[i],p[a],p[o]])}]};return l(Qt.default,{echarts:Oe,option:f,style:{width:t,height:n}})}var qp="";Oe.use([wt.PieChart,Yt.CanvasRenderer]);const el={tooltip:{show:!0},series:{type:"pie",radius:["50%","80%"],label:{position:"outer",alignTo:"edge",formatter:`{name|{b}}
11
- {percentage|{d}%}`,minMargin:5,edgeDistance:10,lineHeight:15,rich:{percentage:{color:"#999"}},margin:20},labelLine:{length:15,length2:0,maxSurfaceAngle:80,showAbove:!0},top:10,bottom:10,left:10,right:10}};function tl({conf:e,data:r,width:t,height:n}){const{label_field:i="name",value_field:a="value",...o}=e,u=h.default.useMemo(()=>r.map(f=>({name:f[i],value:Number(f[a])})),[r,i,a]),c=h.default.useMemo(()=>({series:{labelLayout:function(f){const p=f.labelRect.x<t/2,v=f.labelLinePoints;return v[2][0]=p?f.labelRect.x:f.labelRect.x+f.labelRect.width,{labelLinePoints:v}}}}),[t]),d=C.default.merge({},el,c,o,{series:{data:u}});return l(Qt.default,{echarts:Oe,option:d,style:{width:t,height:n}})}function rl({conf:{template:e,variables:r,align:t},data:n}){const i=h.default.useMemo(()=>Wr(e,r,n),[e,r,n]);return l(s.Text,{align:t,children:Object.values(i).map(a=>a)})}function nl({conf:e,width:r,height:t}){return!r||!t?null:l(kr.default,{readOnly:!0,value:e.content,onChange:C.default.noop,sx:{border:"none"}})}function oi(e,r,t,n){const i={width:e,height:r,data:t,conf:n.conf};switch(n.type){case"sunburst":return l(bu,{...i});case"cartesian":return l(Wu,{...i});case"table":return l(Xu,{...i});case"stats":return l(rl,{...i});case"rich-text":return l(nl,{...i});case"bar-3d":return l(Zu,{...i});case"pie":return l(tl,{...i});default:return null}}const il=["rich-text"];function ui({viz:e,data:r,loading:t}){const{ref:n,width:i,height:a}=W.useElementSize(),o=h.default.useMemo(()=>!Array.isArray(r)||r.length===0,[r]);return il.includes(e.type)?l("div",{className:"viz-root",ref:n,children:l(Zt,{children:oi(i,a,r,e)})}):t?l("div",{className:"viz-root",ref:n,children:l(s.LoadingOverlay,{visible:t,exitTransitionDuration:0})}):b("div",{className:"viz-root",ref:n,children:[o&&l(s.Text,{color:"gray",align:"center",children:"nothing to show"}),!o&&l(Zt,{children:oi(i,a,r,e)})]})}function al({}){const{data:e,loading:r,viz:t}=h.default.useContext(se);return l(ui,{viz:t,data:e,loading:r})}function ol({label:e,required:r,value:t,onChange:n,data:i,sx:a},o){const u=h.default.useMemo(()=>!Array.isArray(i)||i.length===0?[]:Object.keys(i[0]).map(d=>({label:d,value:d})),[i]);return l(s.Select,{ref:o,label:e,data:u,value:t,onChange:n,required:r,sx:a})}const Q=h.default.forwardRef(ol);function ul({conf:e,setConf:r,data:t}){const n=C.default.assign({},{x_axis_data_key:"x",y_axis_data_key:"y",z_axis_data_key:"z",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}},e),{control:i,handleSubmit:a,formState:o}=O.useForm({defaultValues:n});return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:a(r),children:[l(s.Text,{children:"X Axis"}),b(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(O.Controller,{name:"x_axis_data_key",control:i,render:({field:u})=>l(Q,{label:"Data Field",required:!0,data:t,...u})}),l(O.Controller,{name:"xAxis3D.name",control:i,render:({field:u})=>l(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(s.Text,{mt:"lg",children:"Y Axis"}),b(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(O.Controller,{name:"y_axis_data_key",control:i,render:({field:u})=>l(Q,{label:"Data Field",required:!0,data:t,...u})}),l(O.Controller,{name:"yAxis3D.name",control:i,render:({field:u})=>l(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(s.Text,{mt:"lg",children:"Z Axis"}),b(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(O.Controller,{name:"z_axis_data_key",control:i,render:({field:u})=>l(Q,{label:"Data Field",required:!0,data:t,...u})}),l(O.Controller,{name:"zAxis3D.name",control:i,render:({field:u})=>l(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:b(s.Button,{color:"blue",type:"submit",children:[l(_.DeviceFloppy,{size:20}),l(s.Text,{ml:"md",children:"Save"})]})})]})})}function ll({value:e,onChange:r},t){const n=s.useMantineTheme(),i=h.default.useMemo(()=>Object.entries(n.colors).map(([o,u])=>({label:o,value:u[6]})),[n]),a=h.default.useMemo(()=>i.some(o=>o.value===e),[e,i]);return b(s.Group,{position:"apart",spacing:4,children:[l(s.TextInput,{placeholder:"Set any color",value:a?"":e,onChange:o=>r(o.currentTarget.value),rightSection:l(s.ColorSwatch,{color:a?"transparent":e,radius:4}),variant:a?"filled":"default",sx:{maxWidth:"46%",flexGrow:1}}),l(s.Text,{sx:{flexGrow:0},children:"or"}),l(s.Select,{data:i,value:e,onChange:r,variant:a?"default":"filled",placeholder:"Pick a theme color",icon:l(s.ColorSwatch,{color:a?e:"transparent",radius:4}),sx:{maxWidth:"46%",flexGrow:1}})]})}const Yr=h.default.forwardRef(ll);function sl({control:e,index:r}){return b(s.Group,{grow:!0,align:"top",children:[l(O.Controller,{name:`series.${r}.stack`,control:e,render:({field:t})=>l(s.TextInput,{label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1},...t})}),l(O.Controller,{name:`series.${r}.barWidth`,control:e,render:({field:t})=>l(s.TextInput,{label:"Bar Width",sx:{flexGrow:1},...t})})]})}const cl=[{label:"off",value:"false"},{label:"start",value:"start"},{label:"middle",value:"middle"},{label:"end",value:"end"}];function fl({control:e,index:r}){return b(s.Group,{grow:!0,align:"center",children:[l(O.Controller,{name:`series.${r}.step`,control:e,render:({field:t})=>l(s.Select,{label:"Step",data:cl,sx:{flexGrow:1,maxWidth:"48%"},...t,value:String(t.value),onChange:n=>{const i=n==="false"?!1:n;t.onChange(i)}})}),l(O.Controller,{name:`series.${r}.smooth`,control:e,render:({field:t})=>l(s.Box,{sx:{flexGrow:1},children:l(s.Switch,{label:"Smooth Line",checked:t.value,onChange:n=>t.onChange(n.currentTarget.checked)})})})]})}const dl=Array.from(new Array(9),(e,r)=>({label:String(r+1),value:r+1}));function pl({control:e,index:r}){return l(s.Group,{grow:!0,align:"center",children:l(O.Controller,{name:`series.${r}.symbolSize`,control:e,render:({field:t})=>b(s.Stack,{sx:{flexGrow:1},pb:16,spacing:4,children:[l(s.Text,{size:"sm",children:"Size"}),l(s.Slider,{min:1,max:10,marks:dl,...t,sx:{width:"100%"}})]})})})}const hl=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function bl({control:e,index:r,remove:t,seriesItem:n,yAxisOptions:i,data:a}){const o=n.type;return b(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[l(s.Stack,{children:l(O.Controller,{name:`series.${r}.type`,control:e,render:({field:u})=>l(s.SegmentedControl,{data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter"},{label:"Boxplot",value:"boxplot",disabled:!0}],...u})})}),l(O.Controller,{name:`series.${r}.name`,control:e,render:({field:u})=>l(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...u})}),b(s.Group,{grow:!0,noWrap:!0,children:[l(O.Controller,{name:`series.${r}.y_axis_data_key`,control:e,render:({field:u})=>l(Q,{label:"Value Field",required:!0,data:a,sx:{flex:1},...u})}),l(O.Controller,{name:`series.${r}.yAxisIndex`,control:e,render:({field:{value:u,onChange:c,...d}})=>{var f;return l(s.Select,{label:"Y Axis",data:i,disabled:i.length===0,...d,value:(f=u==null?void 0:u.toString())!=null?f:"",onChange:p=>{if(!p){c(0);return}c(Number(p))},sx:{flex:1}})}})]}),o==="line"&&l(fl,{index:r,control:e}),o==="bar"&&l(sl,{index:r,control:e}),o==="scatter"&&l(pl,{index:r,control:e}),l(O.Controller,{name:`series.${r}.label_position`,control:e,render:({field:u})=>l(s.Select,{label:"Label Position",data:hl,...u})}),b(s.Stack,{spacing:4,children:[l(s.Text,{size:"sm",children:"Color"}),l(O.Controller,{name:`series.${r}.color`,control:e,render:({field:u})=>l(Yr,{...u})})]}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t(r),sx:{position:"absolute",top:15,right:5},children:l(_.Trash,{size:16})})]},r)}function vl({control:e,watch:r,getValues:t,data:n}){const{fields:i,append:a,remove:o}=O.useFieldArray({control:e,name:"series"}),u=r("series"),c=i.map((p,v)=>({...p,...u[v]})),d=()=>a({type:"bar",name:W.randomId(),showSymbol:!1,symbolSize:5,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",stack:"",color:"#000",step:!1,smooth:!1}),f=h.default.useMemo(()=>t().y_axes.map(({name:p},v)=>({label:p,value:v.toString()})),[t]);return b(s.Stack,{children:[c.map((p,v)=>l(bl,{control:e,index:v,remove:o,seriesItem:p,yAxisOptions:f,data:n})),l(s.Group,{position:"center",mt:"xs",children:l(s.Button,{onClick:d,children:"Add a Series"})})]})}const li={mantissa:0,output:"number"};function ml({value:e,onChange:r},t){const n=o=>{r({...e,output:o})},i=o=>{const u=o===0?!1:e.trimMantissa;r({...e,mantissa:o,trimMantissa:u})},a=o=>{r({...e,trimMantissa:o.currentTarget.checked})};return l(s.Stack,{ref:t,children:b(s.Group,{grow:!0,children:[l(s.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:n}),l(s.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:i}),l(s.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:a,disabled:e.mantissa===0})]})})}const si=h.default.forwardRef(ml);function yl({control:e,index:r,remove:t}){return b(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[l(s.Group,{grow:!0,noWrap:!0,children:l(O.Controller,{name:`y_axes.${r}.name`,control:e,render:({field:n})=>l(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...n})})}),l(s.Stack,{children:l(O.Controller,{name:`y_axes.${r}.label_formatter`,control:e,render:({field:n})=>l(si,{...n})})}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t(r),sx:{position:"absolute",top:15,right:5},disabled:r===0,children:l(_.Trash,{size:16})})]},r)}function gl({control:e,watch:r}){const{fields:t,append:n,remove:i}=O.useFieldArray({control:e,name:"y_axes"}),a=r("y_axes"),o=t.map((c,d)=>({...c,...a[d]})),u=()=>n({name:"",label_formatter:li});return b(s.Stack,{children:[o.map((c,d)=>l(yl,{control:e,index:d,remove:i})),l(s.Group,{position:"center",mt:"xs",children:l(s.Button,{onClick:u,children:"Add a Y Axis"})})]})}const _l=[{label:"Linear",value:"linear"},{label:"Exponential",value:"exponential"},{label:"Logarithmic",value:"logarithmic"},{label:"Polynomial",value:"polynomial"}];function wl({control:e,regressionItem:r,index:t,remove:n,yAxisOptions:i,data:a}){const o=r.transform.config.method;return b(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[l(O.Controller,{name:`regressions.${t}.name`,control:e,render:({field:u})=>l(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...u})}),b(s.Group,{grow:!0,noWrap:!0,children:[l(O.Controller,{name:`regressions.${t}.y_axis_data_key`,control:e,render:({field:u})=>l(Q,{label:"Value Field",required:!0,data:a,sx:{flex:1},...u})}),l(O.Controller,{name:`regressions.${t}.plot.yAxisIndex`,control:e,render:({field:{value:u,onChange:c,...d}})=>{var f;return l(s.Select,{label:"Y Axis",data:i,disabled:i.length===0,...d,value:(f=u==null?void 0:u.toString())!=null?f:"",onChange:p=>{if(!p){c(0);return}c(Number(p))},sx:{flex:1}})}})]}),b(s.Group,{grow:!0,noWrap:!0,children:[l(O.Controller,{name:`regressions.${t}.transform.config.method`,control:e,render:({field:u})=>l(s.Select,{label:"Method",data:_l,sx:{flex:1},...u})}),o==="polynomial"&&l(O.Controller,{name:`regressions.${t}.transform.config.order`,control:e,render:({field:u})=>l(s.NumberInput,{label:"Order",sx:{flex:1},...u})})]}),b(s.Stack,{spacing:4,children:[l(s.Text,{size:"sm",children:"Color"}),l(O.Controller,{name:`regressions.${t}.plot.color`,control:e,render:({field:u})=>l(Yr,{...u})})]}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>n(t),sx:{position:"absolute",top:15,right:5},children:l(_.Trash,{size:16})})]},t)}function Sl({control:e,watch:r,getValues:t,data:n}){const{fields:i,append:a,remove:o}=O.useFieldArray({control:e,name:"regressions"}),u=r("regressions"),c=i.map((p,v)=>({...p,...u[v]})),d=h.default.useMemo(()=>t().y_axes.map(({name:p},v)=>({label:p,value:v.toString()})),[t]),f=()=>a({transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},name:"",y_axis_data_key:"",plot:{type:"line",yAxisIndex:0,color:"#666666"}});return b(s.Stack,{children:[c.map((p,v)=>l(wl,{regressionItem:p,control:e,index:v,remove:o,yAxisOptions:d,data:n})),l(s.Group,{position:"center",mt:"xs",children:l(s.Button,{onClick:f,children:"Add a Regression Line"})})]})}const Ol=[{label:"None",value:"none"},{label:"Sum",value:"sum"},{label:"Mean",value:"mean"},{label:"Median",value:"median"},{label:"Max",value:"max"},{label:"Min",value:"min"}];function xl({label:e,value:r,onChange:t},n){return l(s.Select,{ref:n,label:e,data:Ol,value:r,onChange:t})}const Pl=h.default.forwardRef(xl);function Cl({label:e,value:r,onChange:t},n){const[i,a]=h.default.useState(Array.isArray(r)?[...r]:[]),o=h.default.useCallback(()=>{a(v=>[...v,""])},[a]),u=h.default.useCallback(v=>{a(y=>(y.splice(v,1),[...y]))},[a]),c=h.default.useMemo(()=>!C.default.isEqual(i,r),[i,r]),d=()=>{t(i.map(v=>v.toString()))},f=s.useMantineTheme(),p=h.default.useMemo(()=>Object.entries(f.colors).map(([v,y])=>y[6]),[f]);return b(Y,{children:[b(s.Group,{position:"left",ref:n,children:[l(s.Text,{children:e}),l(s.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!c,onClick:d,children:l(_.DeviceFloppy,{size:20})})]}),b(s.Group,{children:[i.map((v,y)=>l(s.ColorInput,{value:v,onChange:P=>{a(j=>(j.splice(y,1,P),[...j]))},swatches:p,rightSection:l(s.ActionIcon,{onClick:()=>u(y),color:"red",children:l(_.Trash,{size:14})}),sx:{width:"45%"}})),l(s.ActionIcon,{onClick:o,color:"blue",variant:"outline",children:l(_.PlaylistAdd,{size:20})})]})]})}const Al=h.default.forwardRef(Cl),nr=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function jl({label:e,value:r,onChange:t},n){var o,u;const[i,a]=h.default.useState((u=(o=nr.find(c=>c.label===r))==null?void 0:o.value)!=null?u:nr[0].value);return h.default.useEffect(()=>{const c=nr.find(d=>d.value===i);c&&t(c.label)},[i]),b(s.Stack,{spacing:0,mt:"sm",mb:"lg",children:[l(s.Text,{size:"sm",children:e}),l(s.Slider,{label:null,marks:nr,value:i,onChange:a,step:25,placeholder:"Pick a font size",ref:n})]})}const Tl=h.default.forwardRef(jl);function El({label:e,value:r,onChange:t},n){const[i,a]=h.default.useState(Array.isArray(r)?[...r]:[]),o=h.default.useCallback(()=>{a(f=>[...f,""])},[a]),u=h.default.useCallback(f=>{a(p=>(p.splice(f,1),[...p]))},[a]),c=h.default.useMemo(()=>!C.default.isEqual(i,r),[i,r]),d=()=>{t(i.map(f=>f.toString()))};return b(Y,{children:[b(s.Group,{position:"left",ref:n,children:[l(s.Text,{children:e}),l(s.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!c,onClick:d,children:l(_.DeviceFloppy,{size:20})})]}),b(s.Group,{children:[i.map((f,p)=>l(s.TextInput,{value:f,onChange:v=>{const y=v.currentTarget.value;a(P=>(P.splice(p,1,y),[...P]))},rightSection:l(s.ActionIcon,{onClick:()=>u(p),color:"red",children:l(_.Trash,{size:14})}),sx:{width:"45%"}})),l(s.ActionIcon,{onClick:o,color:"blue",variant:"outline",children:l(_.PlaylistAdd,{size:20})})]})]})}const Il=h.default.forwardRef(El);function ci(){return{name:W.randomId(),size:"20px",weight:"bold",color:{type:"static",staticColor:"blue"},data_field:"",aggregation:"none",formatter:{output:"number",mantissa:0}}}const Qr=h.default.forwardRef(function({value:r,onChange:t,...n},i){return l(s.TextInput,{ref:i,value:r,onChange:t,...n})}),fi=h.default.forwardRef(function({value:r,onChange:t,data:n},i){const a=r.color.type,o=(u,c)=>{const d=C.default.cloneDeep(r);C.default.set(d,u,c),t(d)};return b(s.Box,{px:"sm",py:"md",children:[l(s.Text,{weight:"bold",pb:0,children:r.name}),l(s.Divider,{my:"xs",label:"Data",labelPosition:"center"}),b(s.Group,{grow:!0,noWrap:!0,children:[l(s.TextInput,{label:"Name",required:!0,value:r.name,onChange:u=>o("name",u.currentTarget.value)}),l(Q,{label:"Data Field",required:!0,data:n,value:r.data_field,onChange:u=>o("data_field",u)}),l(Pl,{label:"Aggregation",value:r.aggregation,onChange:u=>o("aggregation",u)})]}),l(si,{value:r.formatter,onChange:u=>o("formatter",u)}),l(s.Divider,{my:"xs",label:"Typography",labelPosition:"center"}),l(s.Stack,{children:l(s.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},value:r.size,onChange:u=>o("size",u.currentTarget.value)})}),l(s.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:l(Tl,{label:"Font Weight",value:r.weight,onChange:u=>o("weight",u)})}),l(s.Divider,{my:"xs",label:"Style",labelPosition:"center"}),b(s.Stack,{children:[l(s.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:r.color.type,onChange:u=>o("color.type",u)}),a==="static"&&l(Yr,{value:r.color.staticColor,onChange:u=>o("color.staticColor",u)}),a==="continuous"&&b(Y,{children:[l(Il,{label:"Value Range",value:r.color.valueRange,onChange:u=>o("color.valueRange",u)}),l(Al,{label:"Color Range",value:r.color.colorRange,onChange:u=>o("color.colorRange",u)})]})]})]})});function Dl({control:e,index:r,remove:t,data:n}){return b(s.Stack,{my:"sm",p:0,sx:{border:"1px solid #eee",borderTopColor:"#333",borderTopWidth:2,position:"relative"},children:[l(O.Controller,{name:`stats.variables.${r}`,control:e,render:({field:i})=>l(fi,{data:n,...i})}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t(r),sx:{position:"absolute",top:15,right:5},children:l(_.Trash,{size:16})})]},r)}function Ml({control:e,watch:r,data:t}){const{fields:n,append:i,remove:a}=O.useFieldArray({control:e,name:"stats.variables"});r("stats.templates");const o=r("stats.variables"),u=n.map((d,f)=>({...d,...o[f]})),c=()=>i(ci());return b(s.Stack,{children:[b(s.Stack,{spacing:0,children:[l(O.Controller,{name:"stats.templates.top",control:e,render:({field:d})=>l(Qr,{label:"Template for stats above the chart",py:"md",sx:{flexGrow:1},...d})}),l(O.Controller,{name:"stats.templates.bottom",control:e,render:({field:d})=>l(Qr,{label:"Template for stats under the chart",py:"md",sx:{flexGrow:1},...d})})]}),u.map((d,f)=>l(Dl,{control:e,index:f,remove:a,data:t})),l(s.Group,{position:"center",mt:"xs",children:l(s.Button,{onClick:c,children:"Add a Variable"})})]})}function Rl(e){function r({type:t,name:n,showSymbol:i,symbolSize:a=5,y_axis_data_key:o="value",yAxisIndex:u=0,label_position:c="top",stack:d="1",color:f="black",barWidth:p="30",smooth:v=!1,step:y=!1}){return{type:t,name:n,showSymbol:i,symbolSize:a,y_axis_data_key:o,yAxisIndex:u,label_position:c,stack:d,color:f,barWidth:p,smooth:v,step:y}}return e.map(r)}function Vl(e){return e||{templates:{top:"",bottom:""},variables:[]}}function kl({conf:e,setConf:r,data:t}){const{series:n,y_axes:i,...a}=e,o=h.default.useMemo(()=>{const{x_axis_name:y="",stats:P,...j}=a;return{series:Rl(n!=null?n:[]),x_axis_name:y,y_axes:i!=null?i:[{name:"Y Axis",label_formatter:li}],stats:Vl(P),...j}},[n,a]);h.default.useEffect(()=>{!C.default.isEqual(e,o)&&r(o)},[e,o]);const{control:u,handleSubmit:c,watch:d,getValues:f}=O.useForm({defaultValues:o});d(["x_axis_data_key","x_axis_name"]);const p=f(),v=h.default.useMemo(()=>!C.default.isEqual(p,e),[p,e]);return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:c(r),children:[b(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(s.Text,{children:"Chart Config"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!v,children:l(_.DeviceFloppy,{size:20})})]}),b(s.Accordion,{multiple:!0,value:["X Axis","Y Axes"],children:[l(s.Accordion.Item,{value:"X Axis",children:b(s.Group,{grow:!0,noWrap:!0,children:[l(O.Controller,{name:"x_axis_data_key",control:u,render:({field:y})=>l(Q,{label:"X Axis Data Field",required:!0,data:t,sx:{flex:1},...y})}),l(O.Controller,{name:"x_axis_name",control:u,render:({field:y})=>l(s.TextInput,{label:"X Axis Name",sx:{flex:1},...y})})]})}),l(s.Accordion.Item,{value:"Y Axes",children:l(gl,{control:u,watch:d})}),l(s.Accordion.Item,{value:"Series",children:l(vl,{control:u,watch:d,getValues:f,data:t})}),l(s.Accordion.Item,{value:"Regression Lines",children:l(Sl,{control:u,watch:d,getValues:f,data:t})}),l(s.Accordion.Item,{value:"Stats",children:l(Ml,{control:u,watch:d,data:t})})]})]})})}function zl({conf:{label_field:e,value_field:r},setConf:t,data:n}){const i=St.useForm({initialValues:{label_field:e,value_field:r}});return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:i.onSubmit(t),children:[b(s.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[l(s.Text,{children:"Pie Config"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:l(_.DeviceFloppy,{size:20})})]}),b(s.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[l(Q,{label:"Label Field",required:!0,data:n,...i.getInputProps("label_field")}),l(Q,{label:"Value Field",required:!0,data:n,...i.getInputProps("value_field")})]})]})})}function Nl({conf:e,setConf:r}){const t=h.default.useMemo(()=>{const{content:d=""}=e;return{content:d}},[e]);h.default.useEffect(()=>{!C.default.isEqual(e,t)&&r(t)},[e,t]);const{control:n,handleSubmit:i,watch:a,getValues:o}=O.useForm({defaultValues:t});a("content");const u=o(),c=h.default.useMemo(()=>!C.default.isEqual(u,e),[u,e]);return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:i(r),children:[b(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(s.Text,{children:"Content"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!c,children:l(_.DeviceFloppy,{size:20})})]}),l(O.Controller,{name:"content",control:n,render:({field:d})=>l(kr.default,{sx:{flex:1},...d})})]})})}function Ll(e){if("variables"in e)return e;const{align:r,size:t,weight:n,color:i,content:{prefix:a="",data_field:o="value",formatter:u={output:"number",mantissa:0},postfix:c=""}={}}=e;return{align:r,template:`${a} \${value} ${c}`,variables:[{name:"value",data_field:o,aggregation:"none",formatter:u,color:i,weight:n,size:t}]}}function Fl({control:e,index:r,remove:t,data:n}){return b(s.Stack,{my:"sm",p:0,sx:{border:"1px solid #eee",borderTopColor:"#333",borderTopWidth:2,position:"relative"},children:[l(O.Controller,{name:`variables.${r}`,control:e,render:({field:i})=>l(fi,{data:n,...i})}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>t(r),sx:{position:"absolute",top:15,right:5},children:l(_.Trash,{size:16})})]},r)}function ql({control:e,watch:r,data:t}){const{fields:n,append:i,remove:a}=O.useFieldArray({control:e,name:"variables"}),o=r("variables"),u=n.map((d,f)=>({...d,...o[f]})),c=()=>i(ci());return b(s.Stack,{children:[u.map((d,f)=>l(Fl,{control:e,index:f,remove:a,data:t})),l(s.Group,{position:"center",mt:"xs",children:l(s.Button,{onClick:c,children:"Add a Variable"})})]})}function Bl(){return{align:"center",template:"The variable ${value} is defined in Variables section",variables:[{name:"value",size:"20px",weight:"bold",color:{type:"static",staticColor:"blue"},data_field:"",aggregation:"none",formatter:{output:"number",mantissa:0}}]}}function Gl({conf:e,setConf:r,data:t}){const n=h.default.useMemo(()=>{const{align:f,template:p="",variables:v=[]}=Ll(e);return f?{variables:v,template:p,align:f}:Bl()},[e]);h.default.useEffect(()=>{!C.default.isEqual(e,n)&&r(n)},[e,n]);const{control:i,handleSubmit:a,watch:o,getValues:u}=O.useForm({defaultValues:n});o(["variables","template"]);const c=u(),d=h.default.useMemo(()=>!C.default.isEqual(c,e),[c,e]);return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:a(r),children:[b(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(s.Text,{weight:500,children:"Stats Configurations"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!d,children:l(_.DeviceFloppy,{size:20})})]}),l(O.Controller,{name:"template",control:i,render:({field:f})=>l(Qr,{label:"Template",py:"md",sx:{flexGrow:1},...f})}),l(s.Text,{pb:"sm",pt:"md",size:"sm",children:"Variables"}),l(ql,{control:i,watch:o,data:t})]})})}function $l({conf:{label_field:e,value_field:r},setConf:t,data:n}){const i=St.useForm({initialValues:{label_field:e,value_field:r}});return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:i.onSubmit(t),children:[b(s.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[l(s.Text,{children:"Sunburst Config"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:l(_.DeviceFloppy,{size:20})})]}),b(s.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[l(Q,{label:"Label Field",required:!0,data:n,...i.getInputProps("label_field")}),l(Q,{label:"Value Field",required:!0,data:n,...i.getInputProps("value_field")})]})]})})}const Ul=Object.values(Me).map(e=>({label:e,value:e}));function Wl({label:e,value:r,onChange:t,sx:n}){return l(s.Select,{label:e,data:Ul,value:r,onChange:t,sx:n})}function Yl({conf:{columns:e,...r},setConf:t,data:n}){const i=St.useForm({initialValues:{id_field:"id",use_raw_columns:!0,columns:e!=null?e:[],fontSize:"sm",horizontalSpacing:"sm",verticalSpacing:"sm",striped:!1,highlightOnHover:!1,...r}}),a=()=>i.insertListItem("columns",{label:W.randomId(),value_field:"value",value_type:Me.string});return l(s.Stack,{mt:"md",spacing:"xs",children:b("form",{onSubmit:i.onSubmit(t),children:[b(s.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[l(s.Text,{children:"Table Config"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:l(_.DeviceFloppy,{size:20})})]}),b(s.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[l(Q,{label:"ID Field",required:!0,data:n,...i.getInputProps("id_field")}),b(s.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[l(s.TextInput,{label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...i.getInputProps("horizontalSpacing")}),l(s.TextInput,{label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...i.getInputProps("verticalSpacing")})]}),l(s.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:l(s.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...i.getInputProps("fontSize")})}),b(s.Stack,{children:[l(s.Text,{children:"Other"}),b(s.Group,{position:"apart",grow:!0,children:[l(s.Switch,{label:"Striped",...i.getInputProps("striped",{type:"checkbox"})}),l(s.Switch,{label:"Highlight on hover",...i.getInputProps("highlightOnHover",{type:"checkbox"})})]})]})]}),b(s.Stack,{mt:"xs",spacing:"xs",p:"md",mb:"xl",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[l(s.Switch,{label:"Use Original Data Columns",...i.getInputProps("use_raw_columns",{type:"checkbox"})}),!i.values.use_raw_columns&&b(s.Stack,{children:[l(s.Text,{mt:"xl",mb:0,children:"Custom Columns"}),i.values.columns.map((o,u)=>b(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[b(s.Group,{position:"apart",grow:!0,children:[l(s.TextInput,{label:"Label",required:!0,sx:{flex:1},...i.getInputProps(`columns.${u}.label`)}),l(Q,{label:"Value Field",required:!0,data:n,...i.getInputProps(`columns.${u}.value_field`)}),l(Wl,{label:"Value Type",sx:{flex:1},...i.getInputProps(`columns.${u}.value_type`)})]}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>i.removeListItem("columns",u),sx:{position:"absolute",top:15,right:5},children:l(_.Trash,{size:16})})]},u)),l(s.Group,{position:"center",mt:"xs",children:l(s.Button,{onClick:a,children:"Add a Column"})})]})]}),l(s.Text,{weight:500,mb:"md",children:"Current Configuration:"}),l($e.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(i.values,null,2)})]})})}const Kr=[{value:"stats",label:"Stats",Panel:Gl},{value:"rich-text",label:"Rich Text",Panel:Nl},{value:"table",label:"Table",Panel:Yl},{value:"sunburst",label:"Sunburst",Panel:$l},{value:"bar-3d",label:"Bar Chart (3D)",Panel:ul},{value:"cartesian",label:"Cartesian Chart",Panel:kl},{value:"pie",label:"Pie Chart",Panel:zl}];function Ql(){const{data:e,viz:r,setViz:t}=h.default.useContext(se),[n,i]=W.useInputState(r.type),a=r.type!==n,o=h.default.useCallback(()=>{!a||t(f=>({...f,type:n}))},[a,n]),u=f=>{t(p=>({...p,conf:f}))},c=f=>{try{u(JSON.parse(f))}catch(p){console.error(p)}},d=h.default.useMemo(()=>{var f;return(f=Kr.find(p=>p.value===n))==null?void 0:f.Panel},[n,Kr]);return b(Y,{children:[l(s.Select,{label:"Visualization",value:n,onChange:i,data:Kr,rightSection:l(s.ActionIcon,{disabled:!a,onClick:o,children:l(_.DeviceFloppy,{size:20})})}),d&&l(d,{conf:r.conf,setConf:u,data:e}),!d&&l(s.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(r.conf,null,2),onChange:c})]})}function Kl({}){return b(s.Group,{grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[l(s.Stack,{sx:{width:"40%",flexShrink:0,flexGrow:0},children:l(Ql,{})}),l(s.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:l(al,{})})]})}function Hl({opened:e,close:r}){const{freezeLayout:t}=h.default.useContext(be),{data:n,loading:i,viz:a,title:o}=h.default.useContext(se);return h.default.useEffect(()=>{t(e)},[e]),l(s.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:o,trapFocus:!0,onDragStart:u=>{u.stopPropagation()},children:l(s.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:"16px"}},padding:"md",children:b(s.Tabs,{defaultValue:"Visualization",children:[b(s.Tabs.List,{children:[l(s.Tabs.Tab,{value:"Data",children:"Data"}),l(s.Tabs.Tab,{value:"Panel",children:"Panel"}),l(s.Tabs.Tab,{value:"Visualization",children:"Visualization"})]}),b(s.Tabs.Panel,{value:"Data",pt:"sm",children:[l(s.LoadingOverlay,{visible:i,exitTransitionDuration:0}),l(pu,{})]}),l(s.Tabs.Panel,{value:"Panel",pt:"sm",children:l(du,{})}),l(s.Tabs.Panel,{value:"Visualization",pt:"sm",children:l(Kl,{})})]})})})}var Bp="";function Jl({}){const e=Vr.useModals(),[r,t]=h.default.useState(!1),n=()=>t(!0),i=()=>t(!1),{id:a,title:o,refreshData:u}=h.default.useContext(se),{inEditMode:c}=h.default.useContext(be),{duplidatePanel:d,removePanelByID:f,viewPanelInFullScreen:p,inFullScreen:v}=h.default.useContext(Ht),y=h.default.useCallback(()=>{d(a)},[d,a]),P=()=>e.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>f(a)}),j=h.default.useCallback(()=>{p(a)},[a,p]);return b(s.Box,{sx:{position:"relative"},children:[l(s.Box,{sx:{position:"absolute",left:0,top:0,height:28},children:l(Nn,{})}),l(s.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:b(s.Menu,{children:[l(s.Menu.Target,{children:l(s.Text,{lineClamp:1,weight:"bold",children:o})}),b(s.Menu.Dropdown,{children:[l(s.Menu.Item,{onClick:u,icon:l(_.Refresh,{size:14}),children:"Refresh"}),!v&&l(s.Menu.Item,{onClick:j,icon:l(_.ArrowsMaximize,{size:14}),children:"Full Screen"}),c&&b(Y,{children:[l(s.Divider,{label:"Edit",labelPosition:"center"}),l(s.Menu.Item,{onClick:n,icon:l(_.Settings,{size:14}),children:"Settings"}),l(s.Menu.Item,{onClick:y,icon:l(_.Copy,{size:14}),children:"Duplicate"}),l(s.Menu.Item,{color:"red",onClick:P,icon:l(_.Trash,{size:14}),children:"Delete"})]})]})]})}),c&&l(Hl,{opened:r,close:i})]})}var Gp="";function ir({viz:e,queryID:r,title:t,description:n,update:i,layout:a,id:o}){const u=h.default.useContext(Ie),c=h.default.useContext(Ye),d=h.default.useContext(ce),[f,p]=h.default.useState(t),[v,y]=h.default.useState(n),[P,j]=h.default.useState(r),[I,$]=h.default.useState(e),he=h.default.useMemo(()=>{if(!!P)return d.queries.find(_t=>_t.id===P)},[P,d.queries]);h.default.useEffect(()=>{i==null||i({id:o,layout:a,title:f,description:v,queryID:P,viz:I})},[f,v,he,I,o,a,P]);const{data:Z=[],loading:k,refresh:U}=Be.useRequest(Mn({context:u,definitions:d,filterValues:c,title:f,query:he}),{refreshDeps:[u,d,he,c]}),ee=U;return l(se.Provider,{value:{id:o,data:Z,loading:k,title:f,setTitle:p,description:v,setDescription:y,queryID:P,setQueryID:j,viz:I,setViz:$,refreshData:ee},children:b(s.Container,{className:"panel-root",children:[l(Jl,{}),l(ui,{viz:I,data:Z,loading:k})]})})}var $p="";const Xl=Rr.WidthProvider(In.default);function di({panels:e,setPanels:r,className:t="layout",rowHeight:n=10,isDraggable:i,isResizable:a}){const o=h.default.useCallback(u=>{const c=new Map;u.forEach(({i:f,...p})=>{c.set(f,p)});const d=e.map(f=>({...f,layout:c.get(f.id)}));r(d)},[e,r]);return l(Xl,{onLayoutChange:o,className:`dashboard-layout ${t}`,rowHeight:n,isDraggable:i,isResizable:a,children:e.map(({id:u,...c},d)=>l("div",{"data-grid":c.layout,children:l(ir,{id:u,...c,update:f=>{r(p=>(p.splice(d,1,f),[...p]))}})},u))})}function Hr(e,r){return b(s.Text,{size:"xs",sx:{svg:{verticalAlign:"bottom"}},children:[e," ",r]})}function Zl({mode:e,setMode:r}){return l(s.SegmentedControl,{size:"xs",value:e,onChange:r,data:[{label:Hr(l(_.PlayerPlay,{size:20}),"Use"),value:le.Use},{label:Hr(l(_.Resize,{size:20}),"Edit Layout"),value:le.Layout},{label:Hr(l(_.Paint,{size:20}),"Edit Content"),value:le.Edit}]})}const es=`
9
+ */var or;function Dn(){if(or)return ht;or=1;var t=V.default,e=Symbol.for("react.element"),r=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,a=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function s(i,d,v){var h,p={},b=null,m=null;v!==void 0&&(b=""+v),d.key!==void 0&&(b=""+d.key),d.ref!==void 0&&(m=d.ref);for(h in d)o.call(d,h)&&!l.hasOwnProperty(h)&&(p[h]=d[h]);if(i&&i.defaultProps)for(h in d=i.defaultProps,d)p[h]===void 0&&(p[h]=d[h]);return{$$typeof:e,type:i,key:b,ref:m,props:p,_owner:a.current}}return ht.Fragment=r,ht.jsx=s,ht.jsxs=s,ht}var pt={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Facebook, Inc. and its affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var lr;function In(){return lr||(lr=1,process.env.NODE_ENV!=="production"&&function(){var t=V.default,e=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),s=Symbol.for("react.provider"),i=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),p=Symbol.for("react.memo"),b=Symbol.for("react.lazy"),m=Symbol.for("react.offscreen"),E=Symbol.iterator,g="@@iterator";function C(O){if(O===null||typeof O!="object")return null;var te=E&&O[E]||O[g];return typeof te=="function"?te:null}var _=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function T(O){{for(var te=arguments.length,oe=new Array(te>1?te-1:0),ve=1;ve<te;ve++)oe[ve-1]=arguments[ve];I("error",O,oe)}}function I(O,te,oe){{var ve=_.ReactDebugCurrentFrame,Ee=ve.getStackAddendum();Ee!==""&&(te+="%s",oe=oe.concat([Ee]));var Ae=oe.map(function(ke){return String(ke)});Ae.unshift("Warning: "+te),Function.prototype.apply.call(console[O],console,Ae)}}var L=!1,R=!1,Y=!1,$=!1,ee=!1,N;N=Symbol.for("react.module.reference");function ne(O){return!!(typeof O=="string"||typeof O=="function"||O===o||O===l||ee||O===a||O===v||O===h||$||O===m||L||R||Y||typeof O=="object"&&O!==null&&(O.$$typeof===b||O.$$typeof===p||O.$$typeof===s||O.$$typeof===i||O.$$typeof===d||O.$$typeof===N||O.getModuleId!==void 0))}function ue(O,te,oe){var ve=O.displayName;if(ve)return ve;var Ee=te.displayName||te.name||"";return Ee!==""?oe+"("+Ee+")":oe}function z(O){return O.displayName||"Context"}function U(O){if(O==null)return null;if(typeof O.tag=="number"&&T("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof O=="function")return O.displayName||O.name||null;if(typeof O=="string")return O;switch(O){case o:return"Fragment";case r:return"Portal";case l:return"Profiler";case a:return"StrictMode";case v:return"Suspense";case h:return"SuspenseList"}if(typeof O=="object")switch(O.$$typeof){case i:var te=O;return z(te)+".Consumer";case s:var oe=O;return z(oe._context)+".Provider";case d:return ue(O,O.render,"ForwardRef");case p:var ve=O.displayName||null;return ve!==null?ve:U(O.type)||"Memo";case b:{var Ee=O,Ae=Ee._payload,ke=Ee._init;try{return U(ke(Ae))}catch{return null}}}return null}var f=Object.assign,j=0,me,H,y,w,D,x,S;function F(){}F.__reactDisabledLog=!0;function B(){{if(j===0){me=console.log,H=console.info,y=console.warn,w=console.error,D=console.group,x=console.groupCollapsed,S=console.groupEnd;var O={configurable:!0,enumerable:!0,value:F,writable:!0};Object.defineProperties(console,{info:O,log:O,warn:O,error:O,group:O,groupCollapsed:O,groupEnd:O})}j++}}function M(){{if(j--,j===0){var O={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:f({},O,{value:me}),info:f({},O,{value:H}),warn:f({},O,{value:y}),error:f({},O,{value:w}),group:f({},O,{value:D}),groupCollapsed:f({},O,{value:x}),groupEnd:f({},O,{value:S})})}j<0&&T("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Q=_.ReactCurrentDispatcher,K;function re(O,te,oe){{if(K===void 0)try{throw Error()}catch(Ee){var ve=Ee.stack.trim().match(/\n( *(at )?)/);K=ve&&ve[1]||""}return`
18
+ `+K+O}}var pe=!1,de;{var fe=typeof WeakMap=="function"?WeakMap:Map;de=new fe}function _e(O,te){if(!O||pe)return"";{var oe=de.get(O);if(oe!==void 0)return oe}var ve;pe=!0;var Ee=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ae;Ae=Q.current,Q.current=null,B();try{if(te){var ke=function(){throw Error()};if(Object.defineProperty(ke.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ke,[])}catch(Xe){ve=Xe}Reflect.construct(O,[],ke)}else{try{ke.call()}catch(Xe){ve=Xe}O.call(ke.prototype)}}else{try{throw Error()}catch(Xe){ve=Xe}O()}}catch(Xe){if(Xe&&ve&&typeof Xe.stack=="string"){for(var xe=Xe.stack.split(`
19
+ `),Pe=ve.stack.split(`
20
+ `),Oe=xe.length-1,De=Pe.length-1;Oe>=1&&De>=0&&xe[Oe]!==Pe[De];)De--;for(;Oe>=1&&De>=0;Oe--,De--)if(xe[Oe]!==Pe[De]){if(Oe!==1||De!==1)do if(Oe--,De--,De<0||xe[Oe]!==Pe[De]){var Ne=`
21
+ `+xe[Oe].replace(" at new "," at ");return O.displayName&&Ne.includes("<anonymous>")&&(Ne=Ne.replace("<anonymous>",O.displayName)),typeof O=="function"&&de.set(O,Ne),Ne}while(Oe>=1&&De>=0);break}}}finally{pe=!1,Q.current=Ae,M(),Error.prepareStackTrace=Ee}var dt=O?O.displayName||O.name:"",bn=dt?re(dt):"";return typeof O=="function"&&de.set(O,bn),bn}function Te(O,te,oe){return _e(O,!1)}function u(O){var te=O.prototype;return!!(te&&te.isReactComponent)}function Z(O,te,oe){if(O==null)return"";if(typeof O=="function")return _e(O,u(O));if(typeof O=="string")return re(O);switch(O){case v:return re("Suspense");case h:return re("SuspenseList")}if(typeof O=="object")switch(O.$$typeof){case d:return Te(O.render);case p:return Z(O.type,te,oe);case b:{var ve=O,Ee=ve._payload,Ae=ve._init;try{return Z(Ae(Ee),te,oe)}catch{}}}return""}var W=Object.prototype.hasOwnProperty,A={},k=_.ReactDebugCurrentFrame;function P(O){if(O){var te=O._owner,oe=Z(O.type,O._source,te?te.type:null);k.setExtraStackFrame(oe)}else k.setExtraStackFrame(null)}function X(O,te,oe,ve,Ee){{var Ae=Function.call.bind(W);for(var ke in O)if(Ae(O,ke)){var xe=void 0;try{if(typeof O[ke]!="function"){var Pe=Error((ve||"React class")+": "+oe+" type `"+ke+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof O[ke]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Pe.name="Invariant Violation",Pe}xe=O[ke](te,ke,ve,oe,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Oe){xe=Oe}xe&&!(xe instanceof Error)&&(P(Ee),T("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",ve||"React class",oe,ke,typeof xe),P(null)),xe instanceof Error&&!(xe.message in A)&&(A[xe.message]=!0,P(Ee),T("Failed %s type: %s",oe,xe.message),P(null))}}}var J=Array.isArray;function q(O){return J(O)}function ie(O){{var te=typeof Symbol=="function"&&Symbol.toStringTag,oe=te&&O[Symbol.toStringTag]||O.constructor.name||"Object";return oe}}function le(O){try{return ae(O),!1}catch{return!0}}function ae(O){return""+O}function ce(O){if(le(O))return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ie(O)),ae(O)}var Se=_.ReactCurrentOwner,we={key:!0,ref:!0,__self:!0,__source:!0},Ie,et,Le;Le={};function lt(O){if(W.call(O,"ref")){var te=Object.getOwnPropertyDescriptor(O,"ref").get;if(te&&te.isReactWarning)return!1}return O.ref!==void 0}function ze(O){if(W.call(O,"key")){var te=Object.getOwnPropertyDescriptor(O,"key").get;if(te&&te.isReactWarning)return!1}return O.key!==void 0}function ct(O,te){if(typeof O.ref=="string"&&Se.current&&te&&Se.current.stateNode!==te){var oe=U(Se.current.type);Le[oe]||(T('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',U(Se.current.type),O.ref),Le[oe]=!0)}}function _t(O,te){{var oe=function(){Ie||(Ie=!0,T("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",te))};oe.isReactWarning=!0,Object.defineProperty(O,"key",{get:oe,configurable:!0})}}function We(O,te){{var oe=function(){et||(et=!0,T("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",te))};oe.isReactWarning=!0,Object.defineProperty(O,"ref",{get:oe,configurable:!0})}}var Rt=function(O,te,oe,ve,Ee,Ae,ke){var xe={$$typeof:e,type:O,key:te,ref:oe,props:ke,_owner:Ae};return xe._store={},Object.defineProperty(xe._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(xe,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ve}),Object.defineProperty(xe,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Ee}),Object.freeze&&(Object.freeze(xe.props),Object.freeze(xe)),xe};function nr(O,te,oe,ve,Ee){{var Ae,ke={},xe=null,Pe=null;oe!==void 0&&(ce(oe),xe=""+oe),ze(te)&&(ce(te.key),xe=""+te.key),lt(te)&&(Pe=te.ref,ct(te,Ee));for(Ae in te)W.call(te,Ae)&&!we.hasOwnProperty(Ae)&&(ke[Ae]=te[Ae]);if(O&&O.defaultProps){var Oe=O.defaultProps;for(Ae in Oe)ke[Ae]===void 0&&(ke[Ae]=Oe[Ae])}if(xe||Pe){var De=typeof O=="function"?O.displayName||O.name||"Unknown":O;xe&&_t(ke,De),Pe&&We(ke,De)}return Rt(O,xe,Pe,Ee,ve,Se.current,ke)}}var wt=_.ReactCurrentOwner,Ft=_.ReactDebugCurrentFrame;function Ye(O){if(O){var te=O._owner,oe=Z(O.type,O._source,te?te.type:null);Ft.setExtraStackFrame(oe)}else Ft.setExtraStackFrame(null)}var Ke;Ke=!1;function tt(O){return typeof O=="object"&&O!==null&&O.$$typeof===e}function hn(){{if(wt.current){var O=U(wt.current.type);if(O)return`
22
+
23
+ Check the render method of \``+O+"`."}return""}}function Ds(O){{if(O!==void 0){var te=O.fileName.replace(/^.*[\\\/]/,""),oe=O.lineNumber;return`
24
+
25
+ Check your code at `+te+":"+oe+"."}return""}}var pn={};function Is(O){{var te=hn();if(!te){var oe=typeof O=="string"?O:O.displayName||O.name;oe&&(te=`
26
+
27
+ Check the top-level render call using <`+oe+">.")}return te}}function mn(O,te){{if(!O._store||O._store.validated||O.key!=null)return;O._store.validated=!0;var oe=Is(te);if(pn[oe])return;pn[oe]=!0;var ve="";O&&O._owner&&O._owner!==wt.current&&(ve=" It was passed a child from "+U(O._owner.type)+"."),Ye(O),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',oe,ve),Ye(null)}}function gn(O,te){{if(typeof O!="object")return;if(q(O))for(var oe=0;oe<O.length;oe++){var ve=O[oe];tt(ve)&&mn(ve,te)}else if(tt(O))O._store&&(O._store.validated=!0);else if(O){var Ee=C(O);if(typeof Ee=="function"&&Ee!==O.entries)for(var Ae=Ee.call(O),ke;!(ke=Ae.next()).done;)tt(ke.value)&&mn(ke.value,te)}}}function Ps(O){{var te=O.type;if(te==null||typeof te=="string")return;var oe;if(typeof te=="function")oe=te.propTypes;else if(typeof te=="object"&&(te.$$typeof===d||te.$$typeof===p))oe=te.propTypes;else return;if(oe){var ve=U(te);X(oe,O.props,"prop",ve,O)}else if(te.PropTypes!==void 0&&!Ke){Ke=!0;var Ee=U(te);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Ee||"Unknown")}typeof te.getDefaultProps=="function"&&!te.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Rs(O){{for(var te=Object.keys(O.props),oe=0;oe<te.length;oe++){var ve=te[oe];if(ve!=="children"&&ve!=="key"){Ye(O),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ve),Ye(null);break}}O.ref!==null&&(Ye(O),T("Invalid attribute `ref` supplied to `React.Fragment`."),Ye(null))}}function vn(O,te,oe,ve,Ee,Ae){{var ke=ne(O);if(!ke){var xe="";(O===void 0||typeof O=="object"&&O!==null&&Object.keys(O).length===0)&&(xe+=" 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 Pe=Ds(Ee);Pe?xe+=Pe:xe+=hn();var Oe;O===null?Oe="null":q(O)?Oe="array":O!==void 0&&O.$$typeof===e?(Oe="<"+(U(O.type)||"Unknown")+" />",xe=" Did you accidentally export a JSX literal instead of a component?"):Oe=typeof O,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Oe,xe)}var De=nr(O,te,oe,Ee,Ae);if(De==null)return De;if(ke){var Ne=te.children;if(Ne!==void 0)if(ve)if(q(Ne)){for(var dt=0;dt<Ne.length;dt++)gn(Ne[dt],O);Object.freeze&&Object.freeze(Ne)}else T("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 gn(Ne,O)}return O===o?Rs(De):Ps(De),De}}function Fs(O,te,oe){return vn(O,te,oe,!0)}function Ls(O,te,oe){return vn(O,te,oe,!1)}var Bs=Ls,Ms=Fs;pt.Fragment=o,pt.jsx=Bs,pt.jsxs=Ms}()),pt}(function(t){process.env.NODE_ENV==="production"?t.exports=Dn():t.exports=In()})(Et);const n=Et.exports.jsx,G=Et.exports.jsxs,Me=Et.exports.Fragment;function ur({}){const{freezeLayout:t}=V.default.useContext(Ve),[e,r]=V.default.useState(!1),{title:o,description:a}=V.default.useContext(Ue);return V.default.useEffect(()=>{t(e)},[e]),!a||a==="<p><br></p>"?null:G(Me,{children:[n(c.Modal,{opened:e,onClose:()=>r(!1),title:o,withCloseButton:!1,children:n(jt.default,{readOnly:!0,value:a,onChange:ye.default.noop,sx:{border:"none"}})}),n(c.Tooltip,{label:"Click to see description",position:"top-start",children:n(c.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(l=>!l),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n(he.InfoCircle,{size:20})})})]})}function Pn(){const{description:t,setDescription:e}=V.default.useContext(Ue),[r,o]=V.default.useState(t),a=t!==r,l=V.default.useCallback(()=>{!a||e(r)},[a,r]);return G(c.Stack,{sx:{flexGrow:1},children:[G(c.Group,{align:"end",children:[n(c.Text,{children:"Description"}),n(c.ActionIcon,{variant:"subtle",color:"blue",disabled:!a,onClick:l,children:n(he.DeviceFloppy,{size:20})})]}),n(ir.RichTextEditor,{value:r,onChange:o,sx:{flexGrow:1},sticky:!0,p:"0"})]})}class Tt extends V.default.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){var e;if(this.state.error){const r=()=>{this.setState({error:null})};return G(c.Box,{children:[n(c.Text,{size:"xs",children:(e=this.state.error)==null?void 0:e.message}),n(c.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:r,children:"Retry"})]})}return this.props.children}}function Rn(){const{title:t}=V.default.useContext(Ue);return n(Tt,{children:G(c.Stack,{mx:"auto",mt:"xl",p:"5px",spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",boxShadow:"0px 0px 10px 0px rgba(0,0,0,.2)"},children:[G(c.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[n(c.Group,{children:n(ur,{})}),n(c.Group,{grow:!0,position:"center",children:n(c.Text,{lineClamp:1,weight:"bold",children:t})}),n(c.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),n(c.Group,{sx:{background:"#eee",flexGrow:1}})]})})}function Fn(){const{title:t,setTitle:e}=V.default.useContext(Ue),[r,o]=Be.useInputState(t),a=t!==r,l=V.default.useCallback(()=>{!a||e(r)},[a,r]);return n(c.TextInput,{value:r,onChange:o,label:G(c.Group,{align:"end",children:[n(c.Text,{children:"Panel Title"}),n(c.ActionIcon,{variant:"subtle",color:"blue",disabled:!a,onClick:l,children:n(he.DeviceFloppy,{size:20})})]})})}function Ln({}){return G(c.Group,{grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[G(c.Stack,{sx:{width:"40%",flexShrink:0,flexGrow:0,height:"100%"},children:[n(Fn,{}),n(Pn,{})]}),n(c.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:n(Rn,{})})]})}function Bn({data:t}){return t.length===0?n(c.Box,{sx:{height:"5em"}}):G(c.Table,{children:[n("thead",{children:n("tr",{children:Object.keys(t==null?void 0:t[0]).map(e=>n("th",{children:n(c.Text,{weight:700,color:"#000",children:e})},e))})}),n("tbody",{children:t.slice(0,10).map((e,r)=>n("tr",{children:Object.values(e).map((o,a)=>n("td",{children:n(c.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:n(c.Text,{children:o})})},`${o}--${a}`))},`row-${r}`))})]})}const cr=Ce.observer(function({id:e}){const r=Fe(),{data:o,state:a,error:l}=r.getDataStuffByID(e),s=a==="loading",i=()=>{r.queries.refetchDataByQueryID(e)};return G(c.Stack,{my:"xl",sx:{border:"1px solid #eee"},children:[G(c.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[G(c.Group,{position:"left",children:[n(c.Text,{weight:500,children:"Preview Data"}),o.length>10&&G(c.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",o.length]})]}),n(c.ActionIcon,{mr:15,variant:"subtle",color:"blue",disabled:s,onClick:i,children:n(he.Refresh,{size:15})})]}),G(c.Box,{sx:{position:"relative"},children:[n(c.LoadingOverlay,{visible:s}),n(Bn,{data:o})]})]})}),Mn=Ce.observer(function({}){const e=Fe(),{queryID:r,setQueryID:o}=V.default.useContext(Ue),a=V.default.useMemo(()=>e.queries.current.map(l=>({value:l.id,label:l.id})),[e.queries.current]);return G(c.Stack,{children:[G(c.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[n(c.Text,{children:"Select a Query"}),n(c.Select,{data:a,value:r,onChange:o,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}})]}),n(cr,{id:r})]})});Ze.use([ft.SunburstChart,xt.CanvasRenderer]);const jn={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function qn({conf:t,data:e,width:r,height:o}){const{label_field:a="name",value_field:l="value",...s}=t,i=V.default.useMemo(()=>e.map(p=>({name:p[a],value:Number(p[l])})),[e,a,l]),d=V.default.useMemo(()=>{var p,b;return(b=(p=ye.default.maxBy(i,m=>m.value))==null?void 0:p.value)!=null?b:1},[i]),v=V.default.useMemo(()=>({series:{label:{formatter:({name:p,value:b})=>b/d<.2?" ":p}}}),[d]),h=ye.default.merge({},jn,v,s,{series:{data:i}});return n(kt.default,{echarts:Ze,option:h,style:{width:r,height:o}})}function Nn({regressions:t=[]},e){const r=[],o=[],a=[];return e.length===0?{regressionDataSets:r,regressionSeries:o,regressionXAxes:a}:(t.forEach(({transform:l,plot:s,name:i,y_axis_data_key:d})=>{const v=`x-axis-for-${i}`,h=`dataset-for-${i}--raw`,p=`dataset-for-${i}--transformed`;r.push({id:h,source:e.map((b,m)=>[m,b[d]])}),r.push({transform:l,id:p,fromDatasetId:h}),o.push({...s,name:i,datasetId:p,xAxisId:v,showSymbol:!1,tooltip:{show:!1}}),a.push({type:"category",id:v,datasetId:p,show:!1})}),{regressionDataSets:r,regressionSeries:o,regressionXAxes:a})}const Gn={legend:{show:!0,bottom:0,left:0},tooltip:{trigger:"axis"},xAxis:{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"}},grid:{top:0,left:15,right:15,bottom:30,containLabel:!0}};function Un(t,e){var v;const r=t.y_axes.reduce((h,{label_formatter:p},b)=>(h[b]=function(E){const g=typeof E=="object"?E.value:E;if(!p)return g;try{return St.default(g).format(p)}catch(C){return console.error(C),g}},h),{default:({value:h})=>h}),o=t.series.reduce((h,{yAxisIndex:p,name:b})=>(h[b]=p,h),{}),a=t.series.map(({y_axis_data_key:h,yAxisIndex:p,label_position:b,name:m,...E})=>({data:e.map(C=>C[h]),label:{show:!!b,position:b,formatter:r[p!=null?p:"default"]},name:m,xAxisId:"main-x-axis",yAxisIndex:p,...E})),{regressionDataSets:l,regressionSeries:s,regressionXAxes:i}=Nn(t,e),d={xAxis:[{data:e.map(h=>h[t.x_axis_data_key]),name:(v=t.x_axis_name)!=null?v:"",id:"main-x-axis"},...i],yAxis:t.y_axes.map(({label_formatter:h,...p},b)=>{var m;return{...p,axisLabel:{show:!0,formatter:(m=r[b])!=null?m:r.default}}}),dataset:[...l],series:[...a,...s],tooltip:{formatter:function(h){const p=Array.isArray(h)?h:[h];if(p.length===0)return"";const b=p.map(({seriesName:m,value:E})=>{var _;if(!m)return E;const g=o[m],C=(_=r[g])!=null?_:r.default;return`${m}: ${C({value:E})}`});return b.unshift(`<strong>${p[0].name}</strong>`),b.join("<br />")}}};return ye.default.merge({},Gn,d)}function Wn(t){const e=Array.from(t).sort((o,a)=>o-a),r=Math.floor(e.length/2);return e.length%2===0?(e[r-1]+e[r])/2:e[r]}function Vn(t,e,r){var a,l,s;const o=t.map(i=>i[e]);switch(r){case"sum":return ye.default.sum(o);case"mean":return ye.default.mean(o);case"median":return Wn(o);case"max":return(a=ye.default.max(o))!=null?a:0;case"min":return(l=ye.default.min(o))!=null?l:0;default:return(s=t[0])==null?void 0:s[e]}}var dr=function(){},mt=function(){};process.env.NODE_ENV!=="production"&&(dr=function(t,e){!t&&typeof console<"u"&&console.warn(e)},mt=function(t,e){if(!t)throw new Error(e)});const $n=(t,e,r)=>Math.min(Math.max(r,t),e),fr=(t,e,r)=>{const o=e-t;return o===0?1:(r-t)/o},Nt=(t,e,r)=>-r*t+r*e+t,hr=(t,e)=>r=>Math.max(Math.min(r,e),t),gt=t=>t%1?Number(t.toFixed(5)):t,At=/(-)?([\d]*\.?[\d])+/g,Gt=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,Zn=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function vt(t){return typeof t=="string"}const zt={test:t=>typeof t=="number",parse:parseFloat,transform:t=>t},pr=Object.assign(Object.assign({},zt),{transform:hr(0,1)});Object.assign(Object.assign({},zt),{default:1});const bt=(t=>({test:e=>vt(e)&&e.endsWith(t)&&e.split(" ").length===1,parse:parseFloat,transform:e=>`${e}${t}`}))("%");Object.assign(Object.assign({},bt),{parse:t=>bt.parse(t)/100,transform:t=>bt.transform(t*100)});const Ut=(t,e)=>r=>Boolean(vt(r)&&Zn.test(r)&&r.startsWith(t)||e&&Object.prototype.hasOwnProperty.call(r,e)),mr=(t,e,r)=>o=>{if(!vt(o))return o;const[a,l,s,i]=o.match(At);return{[t]:parseFloat(a),[e]:parseFloat(l),[r]:parseFloat(s),alpha:i!==void 0?parseFloat(i):1}},st={test:Ut("hsl","hue"),parse:mr("hue","saturation","lightness"),transform:({hue:t,saturation:e,lightness:r,alpha:o=1})=>"hsla("+Math.round(t)+", "+bt.transform(gt(e))+", "+bt.transform(gt(r))+", "+gt(pr.transform(o))+")"},Qn=hr(0,255),Wt=Object.assign(Object.assign({},zt),{transform:t=>Math.round(Qn(t))}),Je={test:Ut("rgb","red"),parse:mr("red","green","blue"),transform:({red:t,green:e,blue:r,alpha:o=1})=>"rgba("+Wt.transform(t)+", "+Wt.transform(e)+", "+Wt.transform(r)+", "+gt(pr.transform(o))+")"};function Yn(t){let e="",r="",o="",a="";return t.length>5?(e=t.substr(1,2),r=t.substr(3,2),o=t.substr(5,2),a=t.substr(7,2)):(e=t.substr(1,1),r=t.substr(2,1),o=t.substr(3,1),a=t.substr(4,1),e+=e,r+=r,o+=o,a+=a),{red:parseInt(e,16),green:parseInt(r,16),blue:parseInt(o,16),alpha:a?parseInt(a,16)/255:1}}const Vt={test:Ut("#"),parse:Yn,transform:Je.transform},Ot={test:t=>Je.test(t)||Vt.test(t)||st.test(t),parse:t=>Je.test(t)?Je.parse(t):st.test(t)?st.parse(t):Vt.parse(t),transform:t=>vt(t)?t:t.hasOwnProperty("red")?Je.transform(t):st.transform(t)},gr="${c}",vr="${n}";function Kn(t){var e,r,o,a;return isNaN(t)&&vt(t)&&((r=(e=t.match(At))===null||e===void 0?void 0:e.length)!==null&&r!==void 0?r:0)+((a=(o=t.match(Gt))===null||o===void 0?void 0:o.length)!==null&&a!==void 0?a:0)>0}function br(t){typeof t=="number"&&(t=`${t}`);const e=[];let r=0;const o=t.match(Gt);o&&(r=o.length,t=t.replace(Gt,gr),e.push(...o.map(Ot.parse)));const a=t.match(At);return a&&(t=t.replace(At,vr),e.push(...a.map(zt.parse))),{values:e,numColors:r,tokenised:t}}function yr(t){return br(t).values}function _r(t){const{values:e,numColors:r,tokenised:o}=br(t),a=e.length;return l=>{let s=o;for(let i=0;i<a;i++)s=s.replace(i<r?gr:vr,i<r?Ot.transform(l[i]):gt(l[i]));return s}}const Xn=t=>typeof t=="number"?0:t;function Jn(t){const e=yr(t);return _r(t)(e.map(Xn))}const wr={test:Kn,parse:yr,createTransformer:_r,getAnimatableNone:Jn};function $t(t,e,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?t+(e-t)*6*r:r<1/2?e:r<2/3?t+(e-t)*(2/3-r)*6:t}function xr({hue:t,saturation:e,lightness:r,alpha:o}){t/=360,e/=100,r/=100;let a=0,l=0,s=0;if(!e)a=l=s=r;else{const i=r<.5?r*(1+e):r+e-r*e,d=2*r-i;a=$t(d,i,t+1/3),l=$t(d,i,t),s=$t(d,i,t-1/3)}return{red:Math.round(a*255),green:Math.round(l*255),blue:Math.round(s*255),alpha:o}}const Hn=(t,e,r)=>{const o=t*t,a=e*e;return Math.sqrt(Math.max(0,r*(a-o)+o))},ei=[Vt,Je,st],kr=t=>ei.find(e=>e.test(t)),Sr=t=>`'${t}' is not an animatable color. Use the equivalent color code instead.`,Cr=(t,e)=>{let r=kr(t),o=kr(e);mt(!!r,Sr(t)),mt(!!o,Sr(e));let a=r.parse(t),l=o.parse(e);r===st&&(a=xr(a),r=Je),o===st&&(l=xr(l),o=Je);const s=Object.assign({},a);return i=>{for(const d in s)d!=="alpha"&&(s[d]=Hn(a[d],l[d],i));return s.alpha=Nt(a.alpha,l.alpha,i),r.transform(s)}},ti=t=>typeof t=="number",ri=(t,e)=>r=>e(t(r)),Er=(...t)=>t.reduce(ri);function Tr(t,e){return ti(t)?r=>Nt(t,e,r):Ot.test(t)?Cr(t,e):Or(t,e)}const Ar=(t,e)=>{const r=[...t],o=r.length,a=t.map((l,s)=>Tr(l,e[s]));return l=>{for(let s=0;s<o;s++)r[s]=a[s](l);return r}},ni=(t,e)=>{const r=Object.assign(Object.assign({},t),e),o={};for(const a in r)t[a]!==void 0&&e[a]!==void 0&&(o[a]=Tr(t[a],e[a]));return a=>{for(const l in o)r[l]=o[l](a);return r}};function zr(t){const e=wr.parse(t),r=e.length;let o=0,a=0,l=0;for(let s=0;s<r;s++)o||typeof e[s]=="number"?o++:e[s].hue!==void 0?l++:a++;return{parsed:e,numNumbers:o,numRGB:a,numHSL:l}}const Or=(t,e)=>{const r=wr.createTransformer(e),o=zr(t),a=zr(e);return o.numHSL===a.numHSL&&o.numRGB===a.numRGB&&o.numNumbers>=a.numNumbers?Er(Ar(o.parsed,a.parsed),r):(dr(!0,`Complex values '${t}' and '${e}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),s=>`${s>0?e:t}`)},ii=(t,e)=>r=>Nt(t,e,r);function ai(t){if(typeof t=="number")return ii;if(typeof t=="string")return Ot.test(t)?Cr:Or;if(Array.isArray(t))return Ar;if(typeof t=="object")return ni}function si(t,e,r){const o=[],a=r||ai(t[0]),l=t.length-1;for(let s=0;s<l;s++){let i=a(t[s],t[s+1]);if(e){const d=Array.isArray(e)?e[s]:e;i=Er(d,i)}o.push(i)}return o}function oi([t,e],[r]){return o=>r(fr(t,e,o))}function li(t,e){const r=t.length,o=r-1;return a=>{let l=0,s=!1;if(a<=t[0]?s=!0:a>=t[o]&&(l=o-1,s=!0),!s){let d=1;for(;d<r&&!(t[d]>a||d===o);d++);l=d-1}const i=fr(t[l],t[l+1],a);return e[l](i)}}function ui(t,e,{clamp:r=!0,ease:o,mixer:a}={}){const l=t.length;mt(l===e.length,"Both input and output ranges must be the same length"),mt(!o||!Array.isArray(o)||o.length===l-1,"Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values."),t[0]>t[l-1]&&(t=[].concat(t),e=[].concat(e),t.reverse(),e.reverse());const s=si(e,o,a),i=l===2?oi(t,s):li(t,s);return r?d=>i($n(t[0],t[l-1],d)):i}class ci{constructor({valueRange:e,colorRange:r}){rt(this,"mapper");this.mapper=ui(e,r)}getColor(e){return this.mapper(e)}}function di(t,e){return t.type==="static"?t.staticColor:t.type==="continuous"?new ci(t).getColor(e):"black"}function fi(t){return t===null?"null":t===void 0?"undefined":Array.isArray(t)?`Array(${t.length})`:t.toString()}function hi(t,e){const r={};return t.forEach(({name:o,color:a,data_field:l,aggregation:s,size:i,weight:d,formatter:v})=>{const h=Vn(e,l,s);let p="";["string","number"].includes(typeof h)?p=St.default(h).format(v):p=fi(h),r[o]=n(c.Text,{sx:{fontSize:i,display:"inline"},color:di(a,h),weight:d,children:p})}),r}function pi(t){return t.split(" ").map(e=>G(Me,{children:[e,"\xA0"]}))}function mi(t){const r=t.replaceAll("<br />","<br/>").replaceAll(`
28
+ `,"<br/>").split("<br/>");return r.map((a,l)=>{const s=[pi(a)];return l!==r.length-1&&s.push(n("br",{})),s}).flat().filter(a=>a!==void 0)}function Zt(t){return mi(t)}function Qt(t,e,r){const o=hi(e,r),a=/^\{(.+)\}(.*)$/;return t.split("$").map(l=>{var v;const s=a.exec(l);if(!s)return Zt(l);const i=o[s[1]];if(!i)return Zt(l);const d=(v=s[2])!=null?v:"";return G(Me,{children:[i,Zt(d)]})})}Ze.use([ft.BarChart,ft.LineChart,ft.ScatterChart,nt.GridComponent,nt.LegendComponent,nt.TooltipComponent,xt.CanvasRenderer]),Ze.registerTransform(wn.transform.regression);function Dr(t){return t.trim().length>0}function gi({conf:t,data:e,width:r,height:o}){const a=V.default.useMemo(()=>Un(t,e),[t,e]);return!r||!o?null:n(kt.default,{echarts:Ze,option:a,style:{width:r,height:o}})}function vi({conf:t,data:e,width:r,height:o}){const{ref:a,height:l}=Be.useElementSize(),{ref:s,height:i}=Be.useElementSize(),d=V.default.useMemo(()=>{const{stats:{templates:h,variables:p}}=t;return{top:Qt(h.top,p,e),bottom:Qt(h.bottom,p,e)}},[t,e]),v=Math.max(0,o-l-i);return G(c.Box,{children:[Dr(t.stats.templates.top)&&n(c.Text,{ref:a,align:"left",size:"xs",pl:"sm",children:Object.values(d.top).map(h=>h)}),n(gi,{width:r,height:v,data:e,conf:t}),Dr(t.stats.templates.bottom)&&n(c.Text,{ref:s,align:"left",size:"xs",pl:"sm",children:Object.values(d.bottom).map(h=>h)})]})}var He=(t=>(t.string="string",t.number="number",t.eloc="eloc",t.percentage="percentage",t))(He||{});function bi({value:t}){return n(c.Text,{component:"span",children:t})}function yi({value:t}){return n(c.Text,{component:"span",children:t})}function _i({value:t}){const e=St.default(t).format({thousandSeparated:!0});return n(c.Text,{component:"span",children:e})}function wi({value:t}){const e=St.default(t).format({output:"percent",mantissa:3});return n(c.Text,{component:"span",children:e})}function xi({value:t,type:e}){switch(e){case He.string:return n(bi,{value:t});case He.eloc:return n(yi,{value:t});case He.number:return n(_i,{value:t});case He.percentage:return n(wi,{value:t})}}function ki({conf:t,data:e=[],width:r,height:o}){const{id_field:a,use_raw_columns:l,columns:s,...i}=t,d=V.default.useMemo(()=>l?Object.keys(e==null?void 0:e[0]):s.map(h=>h.label),[l,s,e]),v=V.default.useMemo(()=>l?Object.keys(e==null?void 0:e[0]).map(h=>({label:h,value_field:h,value_type:He.string})):s,[l,s,e]);return G(c.Table,{sx:{maxHeight:o},...i,children:[n("thead",{children:n("tr",{children:d.map(h=>n("th",{children:h},h))})}),n("tbody",{children:e.slice(0,30).map((h,p)=>n("tr",{children:v.map(({value_field:b,value_type:m})=>n("td",{children:n(c.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace",fontSize:i.fontSize}},children:n(xi,{value:h[b],type:m})})},`${b}--${h[b]}`))},a?h[a]:`row-${p}`))}),e.length>100&&n("tfoot",{children:n("tr",{children:n("td",{colSpan:d.length,children:n(c.Text,{color:"red",size:"sm",children:"Showing only the first 30 rows to avoid causing slow performance"})})})})]})}Ze.use([nt.GridComponent,nt.VisualMapComponent,nt.LegendComponent,nt.TooltipComponent,xt.CanvasRenderer]);function Si({conf:t,data:e,width:r,height:o}){const{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:s,...i}=t,d=V.default.useMemo(()=>ye.default.minBy(e,p=>p[s])[s],[e,s]),v=V.default.useMemo(()=>ye.default.maxBy(e,p=>p[s])[s],[e,s]),h={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:d,max:v,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:{type:"value"},yAxis3D:{type:"value"},zAxis3D:{type:"value"},grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},...i,series:[{type:"bar3D",wireframe:{},data:e.map(p=>[p[a],p[l],p[s]])}]};return n(kt.default,{echarts:Ze,option:h,style:{width:r,height:o}})}const Us="";Ze.use([ft.PieChart,xt.CanvasRenderer]);const Ci={tooltip:{show:!0},series:{type:"pie",radius:["50%","80%"],label:{position:"outer",alignTo:"edge",formatter:`{name|{b}}
29
+ {percentage|{d}%}`,minMargin:5,edgeDistance:10,lineHeight:15,rich:{percentage:{color:"#999"}},margin:20},labelLine:{length:15,length2:0,maxSurfaceAngle:80,showAbove:!0},top:10,bottom:10,left:10,right:10}};function Ei({conf:t,data:e,width:r,height:o}){const{label_field:a="name",value_field:l="value",...s}=t,i=V.default.useMemo(()=>e.map(h=>({name:h[a],value:Number(h[l])})),[e,a,l]),d=V.default.useMemo(()=>({series:{labelLayout:function(h){const p=h.labelRect.x<r/2,b=h.labelLinePoints;return b[2][0]=p?h.labelRect.x:h.labelRect.x+h.labelRect.width,{labelLinePoints:b}}}}),[r]),v=ye.default.merge({},Ci,d,s,{series:{data:i}});return n(kt.default,{echarts:Ze,option:v,style:{width:r,height:o}})}function Ti({conf:{template:t,variables:e,align:r},data:o}){const a=V.default.useMemo(()=>Qt(t,e,o),[t,e,o]);return n(c.Text,{align:r,children:Object.values(a).map(l=>l)})}function Ai({conf:t,width:e,height:r}){return!e||!r?null:n(jt.default,{readOnly:!0,value:t.content,onChange:ye.default.noop,sx:{border:"none"}})}function Ir(t,e,r,o){const a={width:t,height:e,data:r,conf:o.conf};switch(o.type){case"sunburst":return n(qn,{...a});case"cartesian":return n(vi,{...a});case"table":return n(ki,{...a});case"stats":return n(Ti,{...a});case"rich-text":return n(Ai,{...a});case"bar-3d":return n(Si,{...a});case"pie":return n(Ei,{...a});default:return null}}const zi=["rich-text"],Pr=Ce.observer(function({viz:e,data:r,loading:o}){const{ref:a,width:l,height:s}=Be.useElementSize(),i=V.default.useMemo(()=>!Array.isArray(r)||r.length===0,[r]);return zi.includes(e.type)?n("div",{className:"viz-root",ref:a,children:n(Tt,{children:Ir(l,s,r,e)})}):o?n("div",{className:"viz-root",ref:a,children:n(c.LoadingOverlay,{visible:o,exitTransitionDuration:0})}):G("div",{className:"viz-root",ref:a,children:[i&&n(c.Text,{color:"gray",align:"center",children:"nothing to show"}),!i&&n(Tt,{children:Ir(l,s,r,e)})]})});function Oi({}){const{data:t,loading:e,viz:r}=V.default.useContext(Ue);return n(Pr,{viz:r,data:t,loading:e})}function Di({label:t,required:e,value:r,onChange:o,data:a,sx:l},s){const i=V.default.useMemo(()=>!Array.isArray(a)||a.length===0?[]:Object.keys(a[0]).map(v=>({label:v,value:v})),[a]);return n(c.Select,{ref:s,label:t,data:i,value:r,onChange:o,required:e,sx:l})}const je=V.default.forwardRef(Di);function Ii({conf:t,setConf:e,data:r}){const o=ye.default.assign({},{x_axis_data_key:"x",y_axis_data_key:"y",z_axis_data_key:"z",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}},t),{control:a,handleSubmit:l,formState:s}=be.useForm({defaultValues:o});return n(c.Stack,{mt:"md",spacing:"xs",children:G("form",{onSubmit:l(e),children:[n(c.Text,{children:"X Axis"}),G(c.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(be.Controller,{name:"x_axis_data_key",control:a,render:({field:i})=>n(je,{label:"Data Field",required:!0,data:r,...i})}),n(be.Controller,{name:"xAxis3D.name",control:a,render:({field:i})=>n(c.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...i})})]}),n(c.Text,{mt:"lg",children:"Y Axis"}),G(c.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(be.Controller,{name:"y_axis_data_key",control:a,render:({field:i})=>n(je,{label:"Data Field",required:!0,data:r,...i})}),n(be.Controller,{name:"yAxis3D.name",control:a,render:({field:i})=>n(c.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...i})})]}),n(c.Text,{mt:"lg",children:"Z Axis"}),G(c.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(be.Controller,{name:"z_axis_data_key",control:a,render:({field:i})=>n(je,{label:"Data Field",required:!0,data:r,...i})}),n(be.Controller,{name:"zAxis3D.name",control:a,render:({field:i})=>n(c.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...i})})]}),n(c.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:G(c.Button,{color:"blue",type:"submit",children:[n(he.DeviceFloppy,{size:20}),n(c.Text,{ml:"md",children:"Save"})]})})]})})}function Pi({value:t,onChange:e},r){const o=c.useMantineTheme(),a=V.default.useMemo(()=>Object.entries(o.colors).map(([s,i])=>({label:s,value:i[6]})),[o]),l=V.default.useMemo(()=>a.some(s=>s.value===t),[t,a]);return G(c.Group,{position:"apart",spacing:4,children:[n(c.TextInput,{placeholder:"Set any color",value:l?"":t,onChange:s=>e(s.currentTarget.value),rightSection:n(c.ColorSwatch,{color:l?"transparent":t,radius:4}),variant:l?"filled":"default",sx:{maxWidth:"46%",flexGrow:1}}),n(c.Text,{sx:{flexGrow:0},children:"or"}),n(c.Select,{data:a,value:t,onChange:e,variant:l?"default":"filled",placeholder:"Pick a theme color",icon:n(c.ColorSwatch,{color:l?t:"transparent",radius:4}),sx:{maxWidth:"46%",flexGrow:1}})]})}const Yt=V.default.forwardRef(Pi);function Ri({control:t,index:e}){return G(c.Group,{grow:!0,align:"top",children:[n(be.Controller,{name:`series.${e}.stack`,control:t,render:({field:r})=>n(c.TextInput,{label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1},...r})}),n(be.Controller,{name:`series.${e}.barWidth`,control:t,render:({field:r})=>n(c.TextInput,{label:"Bar Width",sx:{flexGrow:1},...r})})]})}const Fi=[{label:"off",value:"false"},{label:"start",value:"start"},{label:"middle",value:"middle"},{label:"end",value:"end"}];function Li({control:t,index:e}){return G(c.Group,{grow:!0,align:"center",children:[n(be.Controller,{name:`series.${e}.step`,control:t,render:({field:r})=>n(c.Select,{label:"Step",data:Fi,sx:{flexGrow:1,maxWidth:"48%"},...r,value:String(r.value),onChange:o=>{const a=o==="false"?!1:o;r.onChange(a)}})}),n(be.Controller,{name:`series.${e}.smooth`,control:t,render:({field:r})=>n(c.Box,{sx:{flexGrow:1},children:n(c.Switch,{label:"Smooth Line",checked:r.value,onChange:o=>r.onChange(o.currentTarget.checked)})})})]})}const Bi=Array.from(new Array(9),(t,e)=>({label:String(e+1),value:e+1}));function Mi({control:t,index:e}){return n(c.Group,{grow:!0,align:"center",children:n(be.Controller,{name:`series.${e}.symbolSize`,control:t,render:({field:r})=>G(c.Stack,{sx:{flexGrow:1},pb:16,spacing:4,children:[n(c.Text,{size:"sm",children:"Size"}),n(c.Slider,{min:1,max:10,marks:Bi,...r,sx:{width:"100%"}})]})})})}const ji=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function qi({control:t,index:e,remove:r,seriesItem:o,yAxisOptions:a,data:l}){const s=o.type;return G(c.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[n(c.Stack,{children:n(be.Controller,{name:`series.${e}.type`,control:t,render:({field:i})=>n(c.SegmentedControl,{data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter"},{label:"Boxplot",value:"boxplot",disabled:!0}],...i})})}),n(be.Controller,{name:`series.${e}.name`,control:t,render:({field:i})=>n(c.TextInput,{label:"Name",required:!0,sx:{flex:1},...i})}),G(c.Group,{grow:!0,noWrap:!0,children:[n(be.Controller,{name:`series.${e}.y_axis_data_key`,control:t,render:({field:i})=>n(je,{label:"Value Field",required:!0,data:l,sx:{flex:1},...i})}),n(be.Controller,{name:`series.${e}.yAxisIndex`,control:t,render:({field:{value:i,onChange:d,...v}})=>{var h;return n(c.Select,{label:"Y Axis",data:a,disabled:a.length===0,...v,value:(h=i==null?void 0:i.toString())!=null?h:"",onChange:p=>{if(!p){d(0);return}d(Number(p))},sx:{flex:1}})}})]}),s==="line"&&n(Li,{index:e,control:t}),s==="bar"&&n(Ri,{index:e,control:t}),s==="scatter"&&n(Mi,{index:e,control:t}),n(be.Controller,{name:`series.${e}.label_position`,control:t,render:({field:i})=>n(c.Select,{label:"Label Position",data:ji,...i})}),G(c.Stack,{spacing:4,children:[n(c.Text,{size:"sm",children:"Color"}),n(be.Controller,{name:`series.${e}.color`,control:t,render:({field:i})=>n(Yt,{...i})})]}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r(e),sx:{position:"absolute",top:15,right:5},children:n(he.Trash,{size:16})})]},e)}function Ni({control:t,watch:e,getValues:r,data:o}){const{fields:a,append:l,remove:s}=be.useFieldArray({control:t,name:"series"}),i=e("series"),d=a.map((p,b)=>({...p,...i[b]})),v=()=>l({type:"bar",name:Be.randomId(),showSymbol:!1,symbolSize:5,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",stack:"",color:"#000",step:!1,smooth:!1}),h=V.default.useMemo(()=>r().y_axes.map(({name:p},b)=>({label:p,value:b.toString()})),[r]);return G(c.Stack,{children:[d.map((p,b)=>n(qi,{control:t,index:b,remove:s,seriesItem:p,yAxisOptions:h,data:o})),n(c.Group,{position:"center",mt:"xs",children:n(c.Button,{onClick:v,children:"Add a Series"})})]})}const Rr={mantissa:0,output:"number"};function Gi({value:t,onChange:e},r){const o=s=>{e({...t,output:s})},a=s=>{const i=s===0?!1:t.trimMantissa;e({...t,mantissa:s,trimMantissa:i})},l=s=>{e({...t,trimMantissa:s.currentTarget.checked})};return n(c.Stack,{ref:r,children:G(c.Group,{grow:!0,children:[n(c.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:t.output,onChange:o}),n(c.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:t.mantissa,onChange:a}),n(c.Switch,{label:"Trim mantissa",checked:t.trimMantissa,onChange:l,disabled:t.mantissa===0})]})})}const Fr=V.default.forwardRef(Gi);function Ui({control:t,index:e,remove:r}){return G(c.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[n(c.Group,{grow:!0,noWrap:!0,children:n(be.Controller,{name:`y_axes.${e}.name`,control:t,render:({field:o})=>n(c.TextInput,{label:"Name",required:!0,sx:{flex:1},...o})})}),n(c.Stack,{children:n(be.Controller,{name:`y_axes.${e}.label_formatter`,control:t,render:({field:o})=>n(Fr,{...o})})}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r(e),sx:{position:"absolute",top:15,right:5},disabled:e===0,children:n(he.Trash,{size:16})})]},e)}function Wi({control:t,watch:e}){const{fields:r,append:o,remove:a}=be.useFieldArray({control:t,name:"y_axes"}),l=e("y_axes"),s=r.map((d,v)=>({...d,...l[v]})),i=()=>o({name:"",label_formatter:Rr});return G(c.Stack,{children:[s.map((d,v)=>n(Ui,{control:t,index:v,remove:a})),n(c.Group,{position:"center",mt:"xs",children:n(c.Button,{onClick:i,children:"Add a Y Axis"})})]})}const Vi=[{label:"Linear",value:"linear"},{label:"Exponential",value:"exponential"},{label:"Logarithmic",value:"logarithmic"},{label:"Polynomial",value:"polynomial"}];function $i({control:t,regressionItem:e,index:r,remove:o,yAxisOptions:a,data:l}){const s=e.transform.config.method;return G(c.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[n(be.Controller,{name:`regressions.${r}.name`,control:t,render:({field:i})=>n(c.TextInput,{label:"Name",required:!0,sx:{flex:1},...i})}),G(c.Group,{grow:!0,noWrap:!0,children:[n(be.Controller,{name:`regressions.${r}.y_axis_data_key`,control:t,render:({field:i})=>n(je,{label:"Value Field",required:!0,data:l,sx:{flex:1},...i})}),n(be.Controller,{name:`regressions.${r}.plot.yAxisIndex`,control:t,render:({field:{value:i,onChange:d,...v}})=>{var h;return n(c.Select,{label:"Y Axis",data:a,disabled:a.length===0,...v,value:(h=i==null?void 0:i.toString())!=null?h:"",onChange:p=>{if(!p){d(0);return}d(Number(p))},sx:{flex:1}})}})]}),G(c.Group,{grow:!0,noWrap:!0,children:[n(be.Controller,{name:`regressions.${r}.transform.config.method`,control:t,render:({field:i})=>n(c.Select,{label:"Method",data:Vi,sx:{flex:1},...i})}),s==="polynomial"&&n(be.Controller,{name:`regressions.${r}.transform.config.order`,control:t,render:({field:i})=>n(c.NumberInput,{label:"Order",sx:{flex:1},...i})})]}),G(c.Stack,{spacing:4,children:[n(c.Text,{size:"sm",children:"Color"}),n(be.Controller,{name:`regressions.${r}.plot.color`,control:t,render:({field:i})=>n(Yt,{...i})})]}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>o(r),sx:{position:"absolute",top:15,right:5},children:n(he.Trash,{size:16})})]},r)}function Zi({control:t,watch:e,getValues:r,data:o}){const{fields:a,append:l,remove:s}=be.useFieldArray({control:t,name:"regressions"}),i=e("regressions"),d=a.map((p,b)=>({...p,...i[b]})),v=V.default.useMemo(()=>r().y_axes.map(({name:p},b)=>({label:p,value:b.toString()})),[r]),h=()=>l({transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},name:"",y_axis_data_key:"",plot:{type:"line",yAxisIndex:0,color:"#666666"}});return G(c.Stack,{children:[d.map((p,b)=>n($i,{regressionItem:p,control:t,index:b,remove:s,yAxisOptions:v,data:o})),n(c.Group,{position:"center",mt:"xs",children:n(c.Button,{onClick:h,children:"Add a Regression Line"})})]})}const Qi=[{label:"None",value:"none"},{label:"Sum",value:"sum"},{label:"Mean",value:"mean"},{label:"Median",value:"median"},{label:"Max",value:"max"},{label:"Min",value:"min"}];function Yi({label:t,value:e,onChange:r},o){return n(c.Select,{ref:o,label:t,data:Qi,value:e,onChange:r})}const Ki=V.default.forwardRef(Yi);function Xi({label:t,value:e,onChange:r},o){const[a,l]=V.default.useState(Array.isArray(e)?[...e]:[]),s=V.default.useCallback(()=>{l(b=>[...b,""])},[l]),i=V.default.useCallback(b=>{l(m=>(m.splice(b,1),[...m]))},[l]),d=V.default.useMemo(()=>!ye.default.isEqual(a,e),[a,e]),v=()=>{r(a.map(b=>b.toString()))},h=c.useMantineTheme(),p=V.default.useMemo(()=>Object.entries(h.colors).map(([b,m])=>m[6]),[h]);return G(Me,{children:[G(c.Group,{position:"left",ref:o,children:[n(c.Text,{children:t}),n(c.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:v,children:n(he.DeviceFloppy,{size:20})})]}),G(c.Group,{children:[a.map((b,m)=>n(c.ColorInput,{value:b,onChange:E=>{l(g=>(g.splice(m,1,E),[...g]))},swatches:p,rightSection:n(c.ActionIcon,{onClick:()=>i(m),color:"red",children:n(he.Trash,{size:14})}),sx:{width:"45%"}})),n(c.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:n(he.PlaylistAdd,{size:20})})]})]})}const Ji=V.default.forwardRef(Xi),Dt=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function Hi({label:t,value:e,onChange:r},o){var s,i;const[a,l]=V.default.useState((i=(s=Dt.find(d=>d.label===e))==null?void 0:s.value)!=null?i:Dt[0].value);return V.default.useEffect(()=>{const d=Dt.find(v=>v.value===a);d&&r(d.label)},[a]),G(c.Stack,{spacing:0,mt:"sm",mb:"lg",children:[n(c.Text,{size:"sm",children:t}),n(c.Slider,{label:null,marks:Dt,value:a,onChange:l,step:25,placeholder:"Pick a font size",ref:o})]})}const ea=V.default.forwardRef(Hi);function ta({label:t,value:e,onChange:r},o){const[a,l]=V.default.useState(Array.isArray(e)?[...e]:[]),s=V.default.useCallback(()=>{l(h=>[...h,""])},[l]),i=V.default.useCallback(h=>{l(p=>(p.splice(h,1),[...p]))},[l]),d=V.default.useMemo(()=>!ye.default.isEqual(a,e),[a,e]),v=()=>{r(a.map(h=>h.toString()))};return G(Me,{children:[G(c.Group,{position:"left",ref:o,children:[n(c.Text,{children:t}),n(c.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:v,children:n(he.DeviceFloppy,{size:20})})]}),G(c.Group,{children:[a.map((h,p)=>n(c.TextInput,{value:h,onChange:b=>{const m=b.currentTarget.value;l(E=>(E.splice(p,1,m),[...E]))},rightSection:n(c.ActionIcon,{onClick:()=>i(p),color:"red",children:n(he.Trash,{size:14})}),sx:{width:"45%"}})),n(c.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:n(he.PlaylistAdd,{size:20})})]})]})}const ra=V.default.forwardRef(ta);function Lr(){return{name:Be.randomId(),size:"20px",weight:"bold",color:{type:"static",staticColor:"blue"},data_field:"",aggregation:"none",formatter:{output:"number",mantissa:0}}}const Kt=V.default.forwardRef(function({value:e,onChange:r,...o},a){return n(c.TextInput,{ref:a,value:e,onChange:r,...o})}),Br=V.default.forwardRef(function({value:e,onChange:r,data:o},a){const l=e.color.type,s=(i,d)=>{const v=ye.default.cloneDeep(e);ye.default.set(v,i,d),r(v)};return G(c.Box,{px:"sm",py:"md",children:[n(c.Text,{weight:"bold",pb:0,children:e.name}),n(c.Divider,{my:"xs",label:"Data",labelPosition:"center"}),G(c.Group,{grow:!0,noWrap:!0,children:[n(c.TextInput,{label:"Name",required:!0,value:e.name,onChange:i=>s("name",i.currentTarget.value)}),n(je,{label:"Data Field",required:!0,data:o,value:e.data_field,onChange:i=>s("data_field",i)}),n(Ki,{label:"Aggregation",value:e.aggregation,onChange:i=>s("aggregation",i)})]}),n(Fr,{value:e.formatter,onChange:i=>s("formatter",i)}),n(c.Divider,{my:"xs",label:"Typography",labelPosition:"center"}),n(c.Stack,{children:n(c.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},value:e.size,onChange:i=>s("size",i.currentTarget.value)})}),n(c.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:n(ea,{label:"Font Weight",value:e.weight,onChange:i=>s("weight",i)})}),n(c.Divider,{my:"xs",label:"Style",labelPosition:"center"}),G(c.Stack,{children:[n(c.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:e.color.type,onChange:i=>s("color.type",i)}),l==="static"&&n(Yt,{value:e.color.staticColor,onChange:i=>s("color.staticColor",i)}),l==="continuous"&&G(Me,{children:[n(ra,{label:"Value Range",value:e.color.valueRange,onChange:i=>s("color.valueRange",i)}),n(Ji,{label:"Color Range",value:e.color.colorRange,onChange:i=>s("color.colorRange",i)})]})]})]})});function na({control:t,index:e,remove:r,data:o}){return G(c.Stack,{my:"sm",p:0,sx:{border:"1px solid #eee",borderTopColor:"#333",borderTopWidth:2,position:"relative"},children:[n(be.Controller,{name:`stats.variables.${e}`,control:t,render:({field:a})=>n(Br,{data:o,...a})}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r(e),sx:{position:"absolute",top:15,right:5},children:n(he.Trash,{size:16})})]},e)}function ia({control:t,watch:e,data:r}){const{fields:o,append:a,remove:l}=be.useFieldArray({control:t,name:"stats.variables"});e("stats.templates");const s=e("stats.variables"),i=o.map((v,h)=>({...v,...s[h]})),d=()=>a(Lr());return G(c.Stack,{children:[G(c.Stack,{spacing:0,children:[n(be.Controller,{name:"stats.templates.top",control:t,render:({field:v})=>n(Kt,{label:"Template for stats above the chart",py:"md",sx:{flexGrow:1},...v})}),n(be.Controller,{name:"stats.templates.bottom",control:t,render:({field:v})=>n(Kt,{label:"Template for stats under the chart",py:"md",sx:{flexGrow:1},...v})})]}),i.map((v,h)=>n(na,{control:t,index:h,remove:l,data:r})),n(c.Group,{position:"center",mt:"xs",children:n(c.Button,{onClick:d,children:"Add a Variable"})})]})}function aa(t){function e({type:r,name:o,showSymbol:a,symbolSize:l=5,y_axis_data_key:s="value",yAxisIndex:i=0,label_position:d="top",stack:v="1",color:h="black",barWidth:p="30",smooth:b=!1,step:m=!1}){return{type:r,name:o,showSymbol:a,symbolSize:l,y_axis_data_key:s,yAxisIndex:i,label_position:d,stack:v,color:h,barWidth:p,smooth:b,step:m}}return t.map(e)}function sa(t){return t||{templates:{top:"",bottom:""},variables:[]}}function oa({conf:t,setConf:e,data:r}){const{series:o,y_axes:a,...l}=t,s=V.default.useMemo(()=>{const{x_axis_name:m="",stats:E,...g}=l;return{series:aa(o!=null?o:[]),x_axis_name:m,y_axes:a!=null?a:[{name:"Y Axis",label_formatter:Rr}],stats:sa(E),...g}},[o,l]);V.default.useEffect(()=>{!ye.default.isEqual(t,s)&&e(s)},[t,s]);const{control:i,handleSubmit:d,watch:v,getValues:h}=be.useForm({defaultValues:s});v(["x_axis_data_key","x_axis_name"]);const p=h(),b=V.default.useMemo(()=>!ye.default.isEqual(p,t),[p,t]);return n(c.Stack,{mt:"md",spacing:"xs",children:G("form",{onSubmit:d(e),children:[G(c.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n(c.Text,{children:"Chart Config"}),n(c.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!b,children:n(he.DeviceFloppy,{size:20})})]}),G(c.Accordion,{multiple:!0,value:["X Axis","Y Axes"],children:[n(c.Accordion.Item,{value:"X Axis",children:G(c.Group,{grow:!0,noWrap:!0,children:[n(be.Controller,{name:"x_axis_data_key",control:i,render:({field:m})=>n(je,{label:"X Axis Data Field",required:!0,data:r,sx:{flex:1},...m})}),n(be.Controller,{name:"x_axis_name",control:i,render:({field:m})=>n(c.TextInput,{label:"X Axis Name",sx:{flex:1},...m})})]})}),n(c.Accordion.Item,{value:"Y Axes",children:n(Wi,{control:i,watch:v})}),n(c.Accordion.Item,{value:"Series",children:n(Ni,{control:i,watch:v,getValues:h,data:r})}),n(c.Accordion.Item,{value:"Regression Lines",children:n(Zi,{control:i,watch:v,getValues:h,data:r})}),n(c.Accordion.Item,{value:"Stats",children:n(ia,{control:i,watch:v,data:r})})]})]})})}function la({conf:{label_field:t,value_field:e},setConf:r,data:o}){const a=Mt.useForm({initialValues:{label_field:t,value_field:e}});return n(c.Stack,{mt:"md",spacing:"xs",children:G("form",{onSubmit:a.onSubmit(r),children:[G(c.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[n(c.Text,{children:"Pie Config"}),n(c.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:n(he.DeviceFloppy,{size:20})})]}),G(c.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[n(je,{label:"Label Field",required:!0,data:o,...a.getInputProps("label_field")}),n(je,{label:"Value Field",required:!0,data:o,...a.getInputProps("value_field")})]})]})})}function ua({conf:t,setConf:e}){const r=V.default.useMemo(()=>{const{content:v=""}=t;return{content:v}},[t]);V.default.useEffect(()=>{!ye.default.isEqual(t,r)&&e(r)},[t,r]);const{control:o,handleSubmit:a,watch:l,getValues:s}=be.useForm({defaultValues:r});l("content");const i=s(),d=V.default.useMemo(()=>!ye.default.isEqual(i,t),[i,t]);return n(c.Stack,{mt:"md",spacing:"xs",children:G("form",{onSubmit:a(e),children:[G(c.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n(c.Text,{children:"Content"}),n(c.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!d,children:n(he.DeviceFloppy,{size:20})})]}),n(be.Controller,{name:"content",control:o,render:({field:v})=>n(jt.default,{sx:{flex:1},...v})})]})})}function ca(t){if("variables"in t)return t;const{align:e,size:r,weight:o,color:a,content:{prefix:l="",data_field:s="value",formatter:i={output:"number",mantissa:0},postfix:d=""}={}}=t;return{align:e,template:`${l} \${value} ${d}`,variables:[{name:"value",data_field:s,aggregation:"none",formatter:i,color:a,weight:o,size:r}]}}function da({control:t,index:e,remove:r,data:o}){return G(c.Stack,{my:"sm",p:0,sx:{border:"1px solid #eee",borderTopColor:"#333",borderTopWidth:2,position:"relative"},children:[n(be.Controller,{name:`variables.${e}`,control:t,render:({field:a})=>n(Br,{data:o,...a})}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r(e),sx:{position:"absolute",top:15,right:5},children:n(he.Trash,{size:16})})]},e)}function fa({control:t,watch:e,data:r}){const{fields:o,append:a,remove:l}=be.useFieldArray({control:t,name:"variables"}),s=e("variables"),i=o.map((v,h)=>({...v,...s[h]})),d=()=>a(Lr());return G(c.Stack,{children:[i.map((v,h)=>n(da,{control:t,index:h,remove:l,data:r})),n(c.Group,{position:"center",mt:"xs",children:n(c.Button,{onClick:d,children:"Add a Variable"})})]})}function ha(){return{align:"center",template:"The variable ${value} is defined in Variables section",variables:[{name:"value",size:"20px",weight:"bold",color:{type:"static",staticColor:"blue"},data_field:"",aggregation:"none",formatter:{output:"number",mantissa:0}}]}}function pa({conf:t,setConf:e,data:r}){const o=V.default.useMemo(()=>{const{align:h,template:p="",variables:b=[]}=ca(t);return h?{variables:b,template:p,align:h}:ha()},[t]);V.default.useEffect(()=>{!ye.default.isEqual(t,o)&&e(o)},[t,o]);const{control:a,handleSubmit:l,watch:s,getValues:i}=be.useForm({defaultValues:o});s(["variables","template"]);const d=i(),v=V.default.useMemo(()=>!ye.default.isEqual(d,t),[d,t]);return n(c.Stack,{mt:"md",spacing:"xs",children:G("form",{onSubmit:l(e),children:[G(c.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n(c.Text,{weight:500,children:"Stats Configurations"}),n(c.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!v,children:n(he.DeviceFloppy,{size:20})})]}),n(be.Controller,{name:"template",control:a,render:({field:h})=>n(Kt,{label:"Template",py:"md",sx:{flexGrow:1},...h})}),n(c.Text,{pb:"sm",pt:"md",size:"sm",children:"Variables"}),n(fa,{control:a,watch:s,data:r})]})})}function ma({conf:{label_field:t,value_field:e},setConf:r,data:o}){const a=Mt.useForm({initialValues:{label_field:t,value_field:e}});return n(c.Stack,{mt:"md",spacing:"xs",children:G("form",{onSubmit:a.onSubmit(r),children:[G(c.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[n(c.Text,{children:"Sunburst Config"}),n(c.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:n(he.DeviceFloppy,{size:20})})]}),G(c.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[n(je,{label:"Label Field",required:!0,data:o,...a.getInputProps("label_field")}),n(je,{label:"Value Field",required:!0,data:o,...a.getInputProps("value_field")})]})]})})}const ga=Object.values(He).map(t=>({label:t,value:t}));function va({label:t,value:e,onChange:r,sx:o}){return n(c.Select,{label:t,data:ga,value:e,onChange:r,sx:o})}function ba({conf:{columns:t,...e},setConf:r,data:o}){const a=Mt.useForm({initialValues:{id_field:"id",use_raw_columns:!0,columns:t!=null?t:[],fontSize:"sm",horizontalSpacing:"sm",verticalSpacing:"sm",striped:!1,highlightOnHover:!1,...e}}),l=()=>a.insertListItem("columns",{label:Be.randomId(),value_field:"value",value_type:He.string});return n(c.Stack,{mt:"md",spacing:"xs",children:G("form",{onSubmit:a.onSubmit(r),children:[G(c.Group,{position:"apart",mb:"lg",sx:{position:"relative"},children:[n(c.Text,{children:"Table Config"}),n(c.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",children:n(he.DeviceFloppy,{size:20})})]}),G(c.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[n(je,{label:"ID Field",required:!0,data:o,...a.getInputProps("id_field")}),G(c.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[n(c.TextInput,{label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...a.getInputProps("horizontalSpacing")}),n(c.TextInput,{label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...a.getInputProps("verticalSpacing")})]}),n(c.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:n(c.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...a.getInputProps("fontSize")})}),G(c.Stack,{children:[n(c.Text,{children:"Other"}),G(c.Group,{position:"apart",grow:!0,children:[n(c.Switch,{label:"Striped",...a.getInputProps("striped",{type:"checkbox"})}),n(c.Switch,{label:"Highlight on hover",...a.getInputProps("highlightOnHover",{type:"checkbox"})})]})]})]}),G(c.Stack,{mt:"xs",spacing:"xs",p:"md",mb:"xl",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[n(c.Switch,{label:"Use Original Data Columns",...a.getInputProps("use_raw_columns",{type:"checkbox"})}),!a.values.use_raw_columns&&G(c.Stack,{children:[n(c.Text,{mt:"xl",mb:0,children:"Custom Columns"}),a.values.columns.map((s,i)=>G(c.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[G(c.Group,{position:"apart",grow:!0,children:[n(c.TextInput,{label:"Label",required:!0,sx:{flex:1},...a.getInputProps(`columns.${i}.label`)}),n(je,{label:"Value Field",required:!0,data:o,...a.getInputProps(`columns.${i}.value_field`)}),n(va,{label:"Value Type",sx:{flex:1},...a.getInputProps(`columns.${i}.value_type`)})]}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>a.removeListItem("columns",i),sx:{position:"absolute",top:15,right:5},children:n(he.Trash,{size:16})})]},i)),n(c.Group,{position:"center",mt:"xs",children:n(c.Button,{onClick:l,children:"Add a Column"})})]})]}),n(c.Text,{weight:500,mb:"md",children:"Current Configuration:"}),n(it.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(a.values,null,2)})]})})}const Xt=[{value:"stats",label:"Stats",Panel:pa},{value:"rich-text",label:"Rich Text",Panel:ua},{value:"table",label:"Table",Panel:ba},{value:"sunburst",label:"Sunburst",Panel:ma},{value:"bar-3d",label:"Bar Chart (3D)",Panel:Ii},{value:"cartesian",label:"Cartesian Chart",Panel:oa},{value:"pie",label:"Pie Chart",Panel:la}];function ya(){const{data:t,viz:e,setViz:r}=V.default.useContext(Ue),[o,a]=Be.useInputState(e.type),l=e.type!==o,s=V.default.useCallback(()=>{!l||r(h=>({...h,type:o}))},[l,o]),i=h=>{r(p=>({...p,conf:h}))},d=h=>{try{i(JSON.parse(h))}catch(p){console.error(p)}},v=V.default.useMemo(()=>{var h;return(h=Xt.find(p=>p.value===o))==null?void 0:h.Panel},[o,Xt]);return G(Me,{children:[n(c.Select,{label:"Visualization",value:o,onChange:a,data:Xt,rightSection:n(c.ActionIcon,{disabled:!l,onClick:s,children:n(he.DeviceFloppy,{size:20})})}),v&&n(v,{conf:e.conf,setConf:i,data:t}),!v&&n(c.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(e.conf,null,2),onChange:d})]})}function _a({}){return G(c.Group,{grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[n(c.Stack,{sx:{width:"40%",flexShrink:0,flexGrow:0},children:n(ya,{})}),n(c.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:n(Oi,{})})]})}const wa=Ce.observer(function({opened:e,close:r}){const{freezeLayout:o}=V.default.useContext(Ve),{data:a,loading:l,viz:s,title:i}=V.default.useContext(Ue);return V.default.useEffect(()=>{o(e)},[e]),n(c.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:i,trapFocus:!0,onDragStart:d=>{d.stopPropagation()},children:n(c.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:"16px"}},padding:"md",children:G(c.Tabs,{defaultValue:"Visualization",children:[G(c.Tabs.List,{children:[n(c.Tabs.Tab,{value:"Data",children:"Data"}),n(c.Tabs.Tab,{value:"Panel",children:"Panel"}),n(c.Tabs.Tab,{value:"Visualization",children:"Visualization"})]}),G(c.Tabs.Panel,{value:"Data",pt:"sm",children:[n(c.LoadingOverlay,{visible:l,exitTransitionDuration:0}),n(Mn,{})]}),n(c.Tabs.Panel,{value:"Panel",pt:"sm",children:n(Ln,{})}),n(c.Tabs.Panel,{value:"Visualization",pt:"sm",children:n(_a,{})})]})})})}),Ws="",xa=Ce.observer(function({}){const e=Fe(),r=Bt.useModals(),[o,a]=V.default.useState(!1),l=()=>a(!0),s=()=>a(!1),{id:i,title:d,queryID:v}=V.default.useContext(Ue),{inEditMode:h}=V.default.useContext(Ve),p=()=>e.queries.refetchDataByQueryID(v),{duplidatePanel:b,removePanelByID:m,viewPanelInFullScreen:E,inFullScreen:g}=V.default.useContext(Ct),C=V.default.useCallback(()=>{b(i)},[b,i]),_=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>m(i)}),T=V.default.useCallback(()=>{E(i)},[i,E]);return G(c.Box,{sx:{position:"relative"},children:[n(c.Box,{sx:{position:"absolute",left:0,top:0,height:28},children:n(ur,{})}),n(c.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:G(c.Menu,{children:[n(c.Menu.Target,{children:n(c.Text,{lineClamp:1,weight:"bold",children:d})}),G(c.Menu.Dropdown,{children:[n(c.Menu.Item,{onClick:p,icon:n(he.Refresh,{size:14}),children:"Refresh"}),n(c.Menu.Item,{onClick:()=>e.queries.downloadDataByQueryID(v),icon:n(he.Download,{size:14}),children:"Download Data"}),!g&&n(c.Menu.Item,{onClick:T,icon:n(he.ArrowsMaximize,{size:14}),children:"Full Screen"}),h&&G(Me,{children:[n(c.Divider,{label:"Edit",labelPosition:"center"}),n(c.Menu.Item,{onClick:l,icon:n(he.Settings,{size:14}),children:"Settings"}),n(c.Menu.Item,{onClick:C,icon:n(he.Copy,{size:14}),children:"Duplicate"}),n(c.Menu.Item,{color:"red",onClick:_,icon:n(he.Trash,{size:14}),children:"Delete"})]})]})]})}),h&&n(wa,{opened:o,close:s})]})}),Vs="",It=Ce.observer(function({viz:e,queryID:r,title:o,description:a,update:l,layout:s,id:i}){const d=Fe(),[v,h]=V.default.useState(o),[p,b]=V.default.useState(a),[m,E]=V.default.useState(r),[g,C]=V.default.useState(e);V.default.useEffect(()=>{l==null||l({id:i,layout:s,title:v,description:p,queryID:m,viz:g})},[v,p,g,i,s,m]);const{data:_,state:T,error:I}=d.getDataStuffByID(m),L=T==="loading";return n(Ue.Provider,{value:{id:i,data:_,loading:L,title:v,setTitle:h,description:p,setDescription:b,queryID:m,setQueryID:E,viz:g,setViz:C},children:G(c.Container,{className:"panel-root",children:[n(xa,{}),n(Pr,{viz:g,data:_,loading:L})]})})}),$s="",ka=Lt.WidthProvider(ar.default),Mr=Ce.observer(function({panels:e,setPanels:r,className:o="layout",rowHeight:a=10,isDraggable:l,isResizable:s}){const i=V.default.useCallback(d=>{const v=new Map;d.forEach(({i:p,...b})=>{v.set(p,b)});const h=e.map(p=>({...p,layout:v.get(p.id)}));r(h)},[e,r]);return n(ka,{onLayoutChange:i,className:`dashboard-layout ${o}`,rowHeight:a,isDraggable:l,isResizable:s,children:e.map(({id:d,...v},h)=>n("div",{"data-grid":v.layout,children:n(It,{id:d,...v,update:p=>{r(b=>(b.splice(h,1,p),[...b]))}})},d))})});function Jt(t,e){return G(c.Text,{size:"xs",sx:{svg:{verticalAlign:"bottom"}},children:[t," ",e]})}function Sa({mode:t,setMode:e}){return n(c.SegmentedControl,{size:"xs",value:t,onChange:e,data:[{label:Jt(n(he.PlayerPlay,{size:20}),"Use"),value:Ge.Use},{label:Jt(n(he.Resize,{size:20}),"Edit Layout"),value:Ge.Layout},{label:Jt(n(he.Paint,{size:20}),"Edit Content"),value:Ge.Edit}]})}const Ca=`
12
30
  -- You may reference global variables in SQL or VizConfig.
13
31
  SELECT *
14
32
  FROM commit
@@ -20,21 +38,22 @@ WHERE
20
38
  -- SQL snippets
21
39
  AND \${sql_snippets.author_email_condition}
22
40
  \${sql_snippets.order_by_clause}
23
- `;function pi({showSQLSnippets:e=!0,sx:r={}}){const t=h.default.useContext(Ie),n=h.default.useContext(Ye),{sqlSnippets:i}=h.default.useContext(ce),a=h.default.useMemo(()=>{const o={context:t,filters:n};if(e){const u=i.reduce((c,d)=>(c[d.key]=d.value,c),{});o.sql_snippets=u}return JSON.stringify(o,null,2)},[t,i,n,e]);return b(s.Stack,{sx:{border:"1px solid #eee",maxWidth:"40%",overflow:"hidden",...r},children:[l(s.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:l(s.Text,{weight:500,children:"Global Variables"})}),b(s.Stack,{px:"md",pb:"md",sx:{width:"100%"},children:[l($e.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:es}),l(s.Text,{weight:500,sx:{flexGrow:0},children:"Current Values"}),l($e.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:a})]})]})}function hi({value:e}){const r=h.default.useContext(Ie),t=h.default.useContext(Ye),n=h.default.useContext(ce),i=h.default.useMemo(()=>Jo(e,r,n,t),[e,r,n,t]);return l($e.Prism,{language:"sql",colorScheme:"light",children:i})}function ts({value:e,onChange:r}){const t=St.useForm({initialValues:e}),n=h.default.useCallback(d=>{r(d)},[r]),i=h.default.useMemo(()=>!C.default.isEqual(e,t.values),[e,t.values]);h.default.useEffect(()=>{t.reset()},[e]);const{data:a=[],loading:o}=Be.useRequest(Rn,{refreshDeps:[]},[]),u=h.default.useMemo(()=>Array.from(new Set(a.map(({type:f})=>f))).map(f=>({label:f,value:f})),[a]),c=h.default.useMemo(()=>{const d=a.filter(({type:f})=>f===t.values.type);return d?d.map(({key:f})=>({label:f,value:f})):[]},[a,t.values.type]);return l(s.Stack,{sx:{border:"1px solid #eee",flexGrow:1},children:b("form",{onSubmit:t.onSubmit(n),children:[b(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(s.Text,{weight:500,children:"Edit Query"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!i||o,children:l(_.DeviceFloppy,{size:20})})]}),b(s.Stack,{my:0,p:"md",pr:40,children:[b(s.Group,{grow:!0,children:[l(s.TextInput,{placeholder:"An ID unique in this dashboard",label:"ID",required:!0,sx:{flex:1},disabled:o,...t.getInputProps("id")}),l(s.Select,{label:"Data Source Type",data:u,sx:{flex:1},disabled:o,...t.getInputProps("type")}),l(s.Select,{label:"Data Source Key",data:c,sx:{flex:1},disabled:o,...t.getInputProps("key")})]}),b(s.Tabs,{defaultValue:"SQL",children:[b(s.Tabs.List,{children:[l(s.Tabs.Tab,{value:"SQL",children:"SQL"}),l(s.Tabs.Tab,{value:"Preview",children:"Preview"})]}),l(s.Tabs.Panel,{value:"SQL",pt:"sm",children:l(s.Textarea,{autosize:!0,minRows:12,maxRows:24,...t.getInputProps("sql"),className:"code-textarea"})}),l(s.Tabs.Panel,{value:"Preview",pt:"sm",children:l(hi,{value:t.values.sql})})]})]})]})})}function rs({id:e,setID:r}){const{queries:t,setQueries:n}=h.default.useContext(ce),i=h.default.useMemo(()=>t.find(o=>o.id===e),[t,e]),a=h.default.useCallback(o=>{if(t.findIndex(c=>c.id===e)===-1){console.error(new Error("Invalid data source id when updating by id"));return}n(c=>{const d=c.findIndex(f=>f.id===e);return c.splice(d,1,o),[...c]}),r(o.id)},[e,t,n,r]);return e?i?l(ts,{value:i,onChange:a}):l("span",{children:"Invalid Data Source ID"}):null}function ns({id:e,setID:r}){const{queries:t,setQueries:n}=h.default.useContext(ce),i=h.default.useCallback(()=>{var u,c;r((c=(u=t[0])==null?void 0:u.id)!=null?c:"")},[r,t]);h.default.useEffect(()=>{if(!e){i();return}t.findIndex(c=>c.id===e)===-1&&i()},[e,t,i]);const a=h.default.useMemo(()=>t.map(u=>({value:u.id,label:u.id})),[t]),o=h.default.useCallback(()=>{const u={id:W.randomId(),type:"postgresql",key:"",sql:""};n(c=>[...c,u]),r(u.id)},[n,r]);return l(s.Group,{pb:"xl",children:b(s.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[l(s.Text,{children:"Select a Query"}),l(s.Select,{data:a,value:e,onChange:r,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}}),l(s.Text,{children:"or"}),l(s.Group,{position:"center",mt:"md",children:l(s.Button,{onClick:o,children:"Add a Query"})})]})})}function is({}){const[e,r]=h.default.useState("");return b(s.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:[b(s.Group,{position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[b(s.Stack,{sx:{flexGrow:1,maxWidth:"calc(60% - 16px)"},children:[l(ns,{id:e,setID:r}),l(rs,{id:e,setID:r})]}),l(pi,{})]}),l(Ln,{id:e})]})}function as({value:e}){const r=h.default.useContext(Ie),t=h.default.useMemo(()=>Ho(e,r),[e,r]);return b(s.Stack,{children:[l(s.Text,{children:"Preview"}),l($e.Prism,{language:"sql",noCopy:!0,colorScheme:"dark",children:t})]})}function os({}){const{sqlSnippets:e,setSQLSnippets:r}=h.default.useContext(ce),t=h.default.useMemo(()=>({snippets:e!=null?e:[]}),[e]),n=St.useForm({initialValues:t}),i=()=>n.insertListItem("snippets",{key:W.randomId(),value:""}),a=h.default.useMemo(()=>!C.default.isEqual(n.values,t),[n.values,t]),o=({snippets:u})=>{r(u)};return l(s.Stack,{sx:{border:"1px solid #eee",flexGrow:1},children:b("form",{onSubmit:n.onSubmit(o),children:[b(s.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:[l(s.Text,{weight:500,children:"SQL Snippets"}),l(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!a,children:l(_.DeviceFloppy,{size:20})})]}),l(s.Group,{px:"md",pb:"md",pt:"md",children:b(s.Stack,{sx:{width:"100%",position:"relative"},children:[n.values.snippets.map((u,c)=>b(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[l(s.TextInput,{label:"Key",required:!0,...n.getInputProps(`snippets.${c}.key`)}),l(s.Textarea,{minRows:3,label:"Value",required:!0,...n.getInputProps(`snippets.${c}.value`),className:"code-textarea"}),l(as,{value:n.values.snippets[c].value}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>n.removeListItem("snippets",c),sx:{position:"absolute",top:15,right:5},children:l(_.Trash,{size:16})})]},c)),l(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:l(s.Button,{variant:"default",onClick:i,children:"Add a snippet"})})]})})]})})}function us({}){return l(s.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:b(s.Group,{position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[l(os,{}),l(pi,{showSQLSnippets:!1})]})})}function ls({opened:e,close:r}){const{freezeLayout:t}=h.default.useContext(be);return h.default.useEffect(()=>{t(e)},[e]),l(s.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:"Data Settings",trapFocus:!0,onDragStart:n=>{n.stopPropagation()},children:b(s.Tabs,{defaultValue:"Queries",children:[b(s.Tabs.List,{children:[l(s.Tabs.Tab,{value:"SQL Snippet",children:"SQL Snippet"}),l(s.Tabs.Tab,{value:"Queries",children:"Queries"})]}),l(s.Tabs.Panel,{value:"SQL Snippet",pt:"sm",children:l(us,{})}),l(s.Tabs.Panel,{value:"Queries",pt:"sm",children:l(is,{})})]})})}function ss({opened:e,close:r,getCurrentSchema:t}){const{freezeLayout:n}=h.default.useContext(be);h.default.useEffect(()=>{n(e)},[e]);const i=h.default.useMemo(()=>JSON.stringify(t(),null,2),[e]);return l(s.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:"This dashboard is described by this schema",trapFocus:!0,onDragStart:a=>{a.stopPropagation()},children:l($e.Prism,{language:"json",sx:{width:"100%"},colorScheme:"dark",children:i})})}function A(e){for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];throw new Error(typeof e=="number"?"[MobX] minified error nr: "+e+(t.length?" "+t.map(String).join(","):"")+". Find the full error at: https://github.com/mobxjs/mobx/blob/main/packages/mobx/src/errors.ts":"[MobX] "+e)}var cs={};function Jr(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:cs}var fs=Object.assign,ar=Object.getOwnPropertyDescriptor,xe=Object.defineProperty,or=Object.prototype,Xr=[];Object.freeze(Xr);var Zr={};Object.freeze(Zr);var ds=typeof Proxy!="undefined",ps=Object.toString();function bi(){ds||A("Proxy not available")}function vi(e){var r=!1;return function(){if(!r)return r=!0,e.apply(this,arguments)}}var nt=function(){};function K(e){return typeof e=="function"}function Ke(e){var r=typeof e;switch(r){case"string":case"symbol":case"number":return!0}return!1}function ur(e){return e!==null&&typeof e=="object"}function Re(e){if(!ur(e))return!1;var r=Object.getPrototypeOf(e);if(r==null)return!0;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return typeof t=="function"&&t.toString()===ps}function mi(e){var r=e==null?void 0:e.constructor;return r?r.name==="GeneratorFunction"||r.displayName==="GeneratorFunction":!1}function lr(e,r,t){xe(e,r,{enumerable:!1,writable:!0,configurable:!0,value:t})}function yi(e,r,t){xe(e,r,{enumerable:!1,writable:!1,configurable:!0,value:t})}function Ve(e,r){var t="isMobX"+e;return r.prototype[t]=!0,function(n){return ur(n)&&n[t]===!0}}function it(e){return e instanceof Map}function Ct(e){return e instanceof Set}var gi=typeof Object.getOwnPropertySymbols!="undefined";function hs(e){var r=Object.keys(e);if(!gi)return r;var t=Object.getOwnPropertySymbols(e);return t.length?[].concat(r,t.filter(function(n){return or.propertyIsEnumerable.call(e,n)})):r}var sr=typeof Reflect!="undefined"&&Reflect.ownKeys?Reflect.ownKeys:gi?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames;function _i(e){return e===null?null:typeof e=="object"?""+e:e}function Pe(e,r){return or.hasOwnProperty.call(e,r)}var bs=Object.getOwnPropertyDescriptors||function(r){var t={};return sr(r).forEach(function(n){t[n]=ar(r,n)}),t};function wi(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function en(e,r,t){return r&&wi(e.prototype,r),t&&wi(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function at(){return at=Object.assign||function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},at.apply(this,arguments)}function Si(e,r){e.prototype=Object.create(r.prototype),e.prototype.constructor=e,tn(e,r)}function tn(e,r){return tn=Object.setPrototypeOf||function(n,i){return n.__proto__=i,n},tn(e,r)}function Oi(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function vs(e,r){if(!!e){if(typeof e=="string")return xi(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if(t==="Object"&&e.constructor&&(t=e.constructor.name),t==="Map"||t==="Set")return Array.from(e);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return xi(e,r)}}function xi(e,r){(r==null||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function ot(e,r){var t=typeof Symbol!="undefined"&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=vs(e))||r&&e&&typeof e.length=="number"){t&&(e=t);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
24
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var ve=Symbol("mobx-stored-annotations");function me(e){function r(t,n){At(t,n,e)}return Object.assign(r,e)}function At(e,r,t){Pe(e,ve)||lr(e,ve,at({},e[ve])),Ps(t)||(e[ve][r]=t)}function ms(e){return Pe(e,ve)||lr(e,ve,at({},e[ve])),e[ve]}var S=Symbol("mobx administration"),jt=function(){function e(t){t===void 0&&(t="Atom"),this.name_=void 0,this.isPendingUnobservation_=!1,this.isBeingObserved_=!1,this.observers_=new Set,this.diffValue_=0,this.lastAccessedBy_=0,this.lowestObserverState_=T.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=t}var r=e.prototype;return r.onBO=function(){this.onBOL&&this.onBOL.forEach(function(n){return n()})},r.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(n){return n()})},r.reportObserved=function(){return Qi(this)},r.reportChanged=function(){B(),Ki(this),G()},r.toString=function(){return this.name_},e}(),rn=Ve("Atom",jt);function cr(e,r,t){r===void 0&&(r=nt),t===void 0&&(t=nt);var n=new jt(e);return r!==nt&&Pc(n,r),t!==nt&&aa(n,t),n}function ys(e,r){return e===r}function gs(e,r){return mn(e,r)}function _s(e,r){return mn(e,r,1)}function ws(e,r){return Object.is?Object.is(e,r):e===r?e!==0||1/e===1/r:e!==e&&r!==r}var ut={identity:ys,structural:gs,default:ws,shallow:_s};function lt(e,r,t){return da(e)?e:Array.isArray(e)?R.array(e,{name:t}):Re(e)?R.object(e,void 0,{name:t}):it(e)?R.map(e,{name:t}):Ct(e)?R.set(e,{name:t}):typeof e=="function"&&!sn(e)&&!Or(e)?mi(e)?kt(e):Vt(t,e):e}function Ss(e,r,t){if(e==null||ie(e)||ge(e)||ne(e)||pe(e))return e;if(Array.isArray(e))return R.array(e,{name:t,deep:!1});if(Re(e))return R.object(e,void 0,{name:t,deep:!1});if(it(e))return R.map(e,{name:t,deep:!1});if(Ct(e))return R.set(e,{name:t,deep:!1})}function fr(e){return e}function Os(e,r){return mn(e,r)?r:e}var xs="override";function Ps(e){return e.annotationType_===xs}function Tt(e,r){return{annotationType_:e,options_:r,make_:Cs,extend_:As}}function Cs(e,r,t,n){var i;if((i=this.options_)!=null&&i.bound)return this.extend_(e,r,t,!1)===null?0:1;if(n===e.target_)return this.extend_(e,r,t,!1)===null?0:2;if(sn(t.value))return 1;var a=Pi(e,this,r,t,!1);return xe(n,r,a),2}function As(e,r,t,n){var i=Pi(e,this,r,t);return e.defineProperty_(r,i,n)}function js(e,r,t,n){r.annotationType_,n.value}function Pi(e,r,t,n,i){var a,o,u,c,d,f,p;i===void 0&&(i=m.safeDescriptors),js(e,r,t,n);var v=n.value;if((a=r.options_)!=null&&a.bound){var y;v=v.bind((y=e.proxy_)!=null?y:e.target_)}return{value:ct((o=(u=r.options_)==null?void 0:u.name)!=null?o:t.toString(),v,(c=(d=r.options_)==null?void 0:d.autoAction)!=null?c:!1,(f=r.options_)!=null&&f.bound?(p=e.proxy_)!=null?p:e.target_:void 0),configurable:i?e.isPlainObject_:!0,enumerable:!1,writable:!i}}function Ci(e,r){return{annotationType_:e,options_:r,make_:Ts,extend_:Es}}function Ts(e,r,t,n){var i;if(n===e.target_)return this.extend_(e,r,t,!1)===null?0:2;if((i=this.options_)!=null&&i.bound&&(!Pe(e.target_,r)||!Or(e.target_[r]))&&this.extend_(e,r,t,!1)===null)return 0;if(Or(t.value))return 1;var a=Ai(e,this,r,t,!1,!1);return xe(n,r,a),2}function Es(e,r,t,n){var i,a=Ai(e,this,r,t,(i=this.options_)==null?void 0:i.bound);return e.defineProperty_(r,a,n)}function Is(e,r,t,n){r.annotationType_,n.value}function Ai(e,r,t,n,i,a){a===void 0&&(a=m.safeDescriptors),Is(e,r,t,n);var o=n.value;if(Or(o)||(o=kt(o)),i){var u;o=o.bind((u=e.proxy_)!=null?u:e.target_),o.isMobXFlow=!0}return{value:o,configurable:a?e.isPlainObject_:!0,enumerable:!1,writable:!a}}function nn(e,r){return{annotationType_:e,options_:r,make_:Ds,extend_:Ms}}function Ds(e,r,t){return this.extend_(e,r,t,!1)===null?0:1}function Ms(e,r,t,n){return Rs(e,this,r,t),e.defineComputedProperty_(r,at({},this.options_,{get:t.get,set:t.set}),n)}function Rs(e,r,t,n){r.annotationType_,n.get}function dr(e,r){return{annotationType_:e,options_:r,make_:Vs,extend_:ks}}function Vs(e,r,t){return this.extend_(e,r,t,!1)===null?0:1}function ks(e,r,t,n){var i,a;return zs(e,this),e.defineObservableProperty_(r,t.value,(i=(a=this.options_)==null?void 0:a.enhancer)!=null?i:lt,n)}function zs(e,r,t,n){r.annotationType_}var Ns="true",Ls=ji();function ji(e){return{annotationType_:Ns,options_:e,make_:Fs,extend_:qs}}function Fs(e,r,t,n){var i,a;if(t.get)return st.make_(e,r,t,n);if(t.set){var o=ct(r.toString(),t.set);return n===e.target_?e.defineProperty_(r,{configurable:m.safeDescriptors?e.isPlainObject_:!0,set:o})===null?0:2:(xe(n,r,{configurable:!0,set:o}),2)}if(n!==e.target_&&typeof t.value=="function"){var u;if(mi(t.value)){var c,d=(c=this.options_)!=null&&c.autoBind?kt.bound:kt;return d.make_(e,r,t,n)}var f=(u=this.options_)!=null&&u.autoBind?Vt.bound:Vt;return f.make_(e,r,t,n)}var p=((i=this.options_)==null?void 0:i.deep)===!1?R.ref:R;if(typeof t.value=="function"&&(a=this.options_)!=null&&a.autoBind){var v;t.value=t.value.bind((v=e.proxy_)!=null?v:e.target_)}return p.make_(e,r,t,n)}function qs(e,r,t,n){var i,a;if(t.get)return st.extend_(e,r,t,n);if(t.set)return e.defineProperty_(r,{configurable:m.safeDescriptors?e.isPlainObject_:!0,set:ct(r.toString(),t.set)},n);if(typeof t.value=="function"&&(i=this.options_)!=null&&i.autoBind){var o;t.value=t.value.bind((o=e.proxy_)!=null?o:e.target_)}var u=((a=this.options_)==null?void 0:a.deep)===!1?R.ref:R;return u.extend_(e,r,t,n)}var Bs="observable",Gs="observable.ref",$s="observable.shallow",Us="observable.struct",Ti={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};Object.freeze(Ti);function pr(e){return e||Ti}var Ei=dr(Bs),Ws=dr(Gs,{enhancer:fr}),Ys=dr($s,{enhancer:Ss}),Qs=dr(Us,{enhancer:Os}),Ii=me(Ei);function hr(e){return e.deep===!0?lt:e.deep===!1?fr:Hs(e.defaultDecorator)}function Ks(e){var r;return e?(r=e.defaultDecorator)!=null?r:ji(e):void 0}function Hs(e){var r,t;return e&&(r=(t=e.options_)==null?void 0:t.enhancer)!=null?r:lt}function Di(e,r,t){if(Ke(r)){At(e,r,Ei);return}return da(e)?e:Re(e)?R.object(e,r,t):Array.isArray(e)?R.array(e,r):it(e)?R.map(e,r):Ct(e)?R.set(e,r):typeof e=="object"&&e!==null?e:R.box(e,r)}Object.assign(Di,Ii);var Js={box:function(r,t){var n=pr(t);return new He(r,hr(n),n.name,!0,n.equals)},array:function(r,t){var n=pr(t);return(m.useProxies===!1||n.proxy===!1?tf:Wc)(r,hr(n),n.name)},map:function(r,t){var n=pr(t);return new pn(r,hr(n),n.name)},set:function(r,t){var n=pr(t);return new Oa(r,hr(n),n.name)},object:function(r,t,n){return Tc(m.useProxies===!1||(n==null?void 0:n.proxy)===!1?Ar({},n):Gc({},n),r,t)},ref:me(Ws),shallow:me(Ys),deep:Ii,struct:me(Qs)},R=fs(Di,Js),Mi="computed",Xs="computed.struct",Ri=nn(Mi),Zs=nn(Xs,{equals:ut.structural}),st=function(r,t){if(Ke(t))return At(r,t,Ri);if(Re(r))return me(nn(Mi,r));var n=Re(t)?t:{};return n.get=r,n.name||(n.name=r.name||""),new Dt(n)};Object.assign(st,Ri),st.struct=me(Zs);var Vi,ki,br=0,ec=1,tc=(Vi=(ki=ar(function(){},"name"))==null?void 0:ki.configurable)!=null?Vi:!1,zi={value:"action",configurable:!0,writable:!1,enumerable:!1};function ct(e,r,t,n){t===void 0&&(t=!1);function i(){return Ni(e,t,r,n||this,arguments)}return i.isMobxAction=!0,tc&&(zi.value=e,Object.defineProperty(i,"name",zi)),i}function Ni(e,r,t,n,i){var a=rc(e,r);try{return t.apply(n,i)}catch(o){throw a.error_=o,o}finally{nc(a)}}function rc(e,r,t,n){var i=!1,a=0,o=m.trackingDerivation,u=!r||!o;B();var c=m.allowStateChanges;u&&(ft(),c=Et(!0));var d=un(!0),f={runAsAction_:u,prevDerivation_:o,prevAllowStateChanges_:c,prevAllowStateReads_:d,notifySpy_:i,startTime_:a,actionId_:ec++,parentActionId_:br};return br=f.actionId_,f}function nc(e){br!==e.actionId_&&A(30),br=e.parentActionId_,e.error_!==void 0&&(m.suppressReactionErrors=!0),It(e.prevAllowStateChanges_),Mt(e.prevAllowStateReads_),G(),e.runAsAction_&&ke(e.prevDerivation_),m.suppressReactionErrors=!1}function Li(e,r){var t=Et(e);try{return r()}finally{It(t)}}function Et(e){var r=m.allowStateChanges;return m.allowStateChanges=e,r}function It(e){m.allowStateChanges=e}var Fi;Fi=Symbol.toPrimitive;var He=function(e){Si(r,e);function r(n,i,a,o,u){var c;return a===void 0&&(a="ObservableValue"),u===void 0&&(u=ut.default),c=e.call(this,a)||this,c.enhancer=void 0,c.name_=void 0,c.equals=void 0,c.hasUnreportedChange_=!1,c.interceptors_=void 0,c.changeListeners_=void 0,c.value_=void 0,c.dehancer=void 0,c.enhancer=i,c.name_=a,c.equals=u,c.value_=i(n,void 0,a),c}var t=r.prototype;return t.dehanceValue=function(i){return this.dehancer!==void 0?this.dehancer(i):i},t.set=function(i){this.value_,i=this.prepareNewValue_(i),i!==m.UNCHANGED&&this.setNewValue_(i)},t.prepareNewValue_=function(i){if(te(this)){var a=re(this,{object:this,type:ye,newValue:i});if(!a)return m.UNCHANGED;i=a.newValue}return i=this.enhancer(i,this.value_,this.name_),this.equals(this.value_,i)?m.UNCHANGED:i},t.setNewValue_=function(i){var a=this.value_;this.value_=i,this.reportChanged(),fe(this)&&de(this,{type:ye,object:this,newValue:i,oldValue:a})},t.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},t.intercept_=function(i){return zt(this,i)},t.observe_=function(i,a){return a&&i({observableKind:"value",debugObjectName:this.name_,object:this,type:ye,newValue:this.value_,oldValue:void 0}),Nt(this,i)},t.raw=function(){return this.value_},t.toJSON=function(){return this.get()},t.toString=function(){return this.name_+"["+this.value_+"]"},t.valueOf=function(){return _i(this.get())},t[Fi]=function(){return this.valueOf()},r}(jt),ic=Ve("ObservableValue",He),qi;qi=Symbol.toPrimitive;var Dt=function(){function e(t){this.dependenciesState_=T.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.isBeingObserved_=!1,this.isPendingUnobservation_=!1,this.observers_=new Set,this.diffValue_=0,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=T.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new mr(null),this.name_=void 0,this.triggeredBy_=void 0,this.isComputing_=!1,this.isRunningSetter_=!1,this.derivation=void 0,this.setter_=void 0,this.isTracing_=Je.NONE,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,t.get||A(31),this.derivation=t.get,this.name_=t.name||"ComputedValue",t.set&&(this.setter_=ct("ComputedValue-setter",t.set)),this.equals_=t.equals||(t.compareStructural||t.struct?ut.structural:ut.default),this.scope_=t.context,this.requiresReaction_=t.requiresReaction,this.keepAlive_=!!t.keepAlive}var r=e.prototype;return r.onBecomeStale_=function(){cc(this)},r.onBO=function(){this.onBOL&&this.onBOL.forEach(function(n){return n()})},r.onBUO=function(){this.onBUOL&&this.onBUOL.forEach(function(n){return n()})},r.get=function(){if(this.isComputing_&&A(32,this.name_,this.derivation),m.inBatch===0&&this.observers_.size===0&&!this.keepAlive_)an(this)&&(this.warnAboutUntrackedRead_(),B(),this.value_=this.computeValue_(!1),G());else if(Qi(this),an(this)){var n=m.trackingContext;this.keepAlive_&&!n&&(m.trackingContext=this),this.trackAndCompute()&&sc(this),m.trackingContext=n}var i=this.value_;if(yr(i))throw i.cause;return i},r.set=function(n){if(this.setter_){this.isRunningSetter_&&A(33,this.name_),this.isRunningSetter_=!0;try{this.setter_.call(this.scope_,n)}finally{this.isRunningSetter_=!1}}else A(34,this.name_)},r.trackAndCompute=function(){var n=this.value_,i=this.dependenciesState_===T.NOT_TRACKING_,a=this.computeValue_(!0),o=i||yr(n)||yr(a)||!this.equals_(n,a);return o&&(this.value_=a),o},r.computeValue_=function(n){this.isComputing_=!0;var i=Et(!1),a;if(n)a=Bi(this,this.derivation,this.scope_);else if(m.disableErrorBoundaries===!0)a=this.derivation.call(this.scope_);else try{a=this.derivation.call(this.scope_)}catch(o){a=new mr(o)}return It(i),this.isComputing_=!1,a},r.suspend_=function(){this.keepAlive_||(on(this),this.value_=void 0)},r.observe_=function(n,i){var a=this,o=!0,u=void 0;return gc(function(){var c=a.get();if(!o||i){var d=ft();n({observableKind:"computed",debugObjectName:a.name_,type:ye,object:a,newValue:c,oldValue:u}),ke(d)}o=!1,u=c})},r.warnAboutUntrackedRead_=function(){},r.toString=function(){return this.name_+"["+this.derivation.toString()+"]"},r.valueOf=function(){return _i(this.get())},r[qi]=function(){return this.valueOf()},e}(),vr=Ve("ComputedValue",Dt),T;(function(e){e[e.NOT_TRACKING_=-1]="NOT_TRACKING_",e[e.UP_TO_DATE_=0]="UP_TO_DATE_",e[e.POSSIBLY_STALE_=1]="POSSIBLY_STALE_",e[e.STALE_=2]="STALE_"})(T||(T={}));var Je;(function(e){e[e.NONE=0]="NONE",e[e.LOG=1]="LOG",e[e.BREAK=2]="BREAK"})(Je||(Je={}));var mr=function(r){this.cause=void 0,this.cause=r};function yr(e){return e instanceof mr}function an(e){switch(e.dependenciesState_){case T.UP_TO_DATE_:return!1;case T.NOT_TRACKING_:case T.STALE_:return!0;case T.POSSIBLY_STALE_:{for(var r=un(!0),t=ft(),n=e.observing_,i=n.length,a=0;a<i;a++){var o=n[a];if(vr(o)){if(m.disableErrorBoundaries)o.get();else try{o.get()}catch{return ke(t),Mt(r),!0}if(e.dependenciesState_===T.STALE_)return ke(t),Mt(r),!0}}return $i(e),ke(t),Mt(r),!1}}}function Up(e){}function Bi(e,r,t){var n=un(!0);$i(e),e.newObserving_=new Array(e.observing_.length+100),e.unboundDepsCount_=0,e.runId_=++m.runId;var i=m.trackingDerivation;m.trackingDerivation=e,m.inBatch++;var a;if(m.disableErrorBoundaries===!0)a=r.call(t);else try{a=r.call(t)}catch(o){a=new mr(o)}return m.inBatch--,m.trackingDerivation=i,ac(e),Mt(n),a}function ac(e){for(var r=e.observing_,t=e.observing_=e.newObserving_,n=T.UP_TO_DATE_,i=0,a=e.unboundDepsCount_,o=0;o<a;o++){var u=t[o];u.diffValue_===0&&(u.diffValue_=1,i!==o&&(t[i]=u),i++),u.dependenciesState_>n&&(n=u.dependenciesState_)}for(t.length=i,e.newObserving_=null,a=r.length;a--;){var c=r[a];c.diffValue_===0&&Wi(c,e),c.diffValue_=0}for(;i--;){var d=t[i];d.diffValue_===1&&(d.diffValue_=0,lc(d,e))}n!==T.UP_TO_DATE_&&(e.dependenciesState_=n,e.onBecomeStale_())}function on(e){var r=e.observing_;e.observing_=[];for(var t=r.length;t--;)Wi(r[t],e);e.dependenciesState_=T.NOT_TRACKING_}function Gi(e){var r=ft();try{return e()}finally{ke(r)}}function ft(){var e=m.trackingDerivation;return m.trackingDerivation=null,e}function ke(e){m.trackingDerivation=e}function un(e){var r=m.allowStateReads;return m.allowStateReads=e,r}function Mt(e){m.allowStateReads=e}function $i(e){if(e.dependenciesState_!==T.UP_TO_DATE_){e.dependenciesState_=T.UP_TO_DATE_;for(var r=e.observing_,t=r.length;t--;)r[t].lowestObserverState_=T.UP_TO_DATE_}}var gr=function(){this.version=6,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},_r=!0,Ui=!1,m=function(){var e=Jr();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(_r=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==new gr().version&&(_r=!1),_r?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new gr):(setTimeout(function(){Ui||A(35)},1),new gr)}();function oc(){if((m.pendingReactions.length||m.inBatch||m.isRunningReactions)&&A(36),Ui=!0,_r){var e=Jr();--e.__mobxInstanceCount===0&&(e.__mobxGlobals=void 0),m=new gr}}function uc(){return m}function lc(e,r){e.observers_.add(r),e.lowestObserverState_>r.dependenciesState_&&(e.lowestObserverState_=r.dependenciesState_)}function Wi(e,r){e.observers_.delete(r),e.observers_.size===0&&Yi(e)}function Yi(e){e.isPendingUnobservation_===!1&&(e.isPendingUnobservation_=!0,m.pendingUnobservations.push(e))}function B(){m.inBatch++}function G(){if(--m.inBatch===0){Hi();for(var e=m.pendingUnobservations,r=0;r<e.length;r++){var t=e[r];t.isPendingUnobservation_=!1,t.observers_.size===0&&(t.isBeingObserved_&&(t.isBeingObserved_=!1,t.onBUO()),t instanceof Dt&&t.suspend_())}m.pendingUnobservations=[]}}function Qi(e){var r=m.trackingDerivation;return r!==null?(r.runId_!==e.lastAccessedBy_&&(e.lastAccessedBy_=r.runId_,r.newObserving_[r.unboundDepsCount_++]=e,!e.isBeingObserved_&&m.trackingContext&&(e.isBeingObserved_=!0,e.onBO())),!0):(e.observers_.size===0&&m.inBatch>0&&Yi(e),!1)}function Ki(e){e.lowestObserverState_!==T.STALE_&&(e.lowestObserverState_=T.STALE_,e.observers_.forEach(function(r){r.dependenciesState_===T.UP_TO_DATE_&&r.onBecomeStale_(),r.dependenciesState_=T.STALE_}))}function sc(e){e.lowestObserverState_!==T.STALE_&&(e.lowestObserverState_=T.STALE_,e.observers_.forEach(function(r){r.dependenciesState_===T.POSSIBLY_STALE_?r.dependenciesState_=T.STALE_:r.dependenciesState_===T.UP_TO_DATE_&&(e.lowestObserverState_=T.UP_TO_DATE_)}))}function cc(e){e.lowestObserverState_===T.UP_TO_DATE_&&(e.lowestObserverState_=T.POSSIBLY_STALE_,e.observers_.forEach(function(r){r.dependenciesState_===T.UP_TO_DATE_&&(r.dependenciesState_=T.POSSIBLY_STALE_,r.onBecomeStale_())}))}var dt=function(){function e(t,n,i,a){t===void 0&&(t="Reaction"),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=T.NOT_TRACKING_,this.diffValue_=0,this.runId_=0,this.unboundDepsCount_=0,this.isDisposed_=!1,this.isScheduled_=!1,this.isTrackPending_=!1,this.isRunning_=!1,this.isTracing_=Je.NONE,this.name_=t,this.onInvalidate_=n,this.errorHandler_=i,this.requiresObservable_=a}var r=e.prototype;return r.onBecomeStale_=function(){this.schedule_()},r.schedule_=function(){this.isScheduled_||(this.isScheduled_=!0,m.pendingReactions.push(this),Hi())},r.isScheduled=function(){return this.isScheduled_},r.runReaction_=function(){if(!this.isDisposed_){B(),this.isScheduled_=!1;var n=m.trackingContext;if(m.trackingContext=this,an(this)){this.isTrackPending_=!0;try{this.onInvalidate_()}catch(i){this.reportExceptionInDerivation_(i)}}m.trackingContext=n,G()}},r.track=function(n){if(!this.isDisposed_){B(),this.isRunning_=!0;var i=m.trackingContext;m.trackingContext=this;var a=Bi(this,n,void 0);m.trackingContext=i,this.isRunning_=!1,this.isTrackPending_=!1,this.isDisposed_&&on(this),yr(a)&&this.reportExceptionInDerivation_(a.cause),G()}},r.reportExceptionInDerivation_=function(n){var i=this;if(this.errorHandler_){this.errorHandler_(n,this);return}if(m.disableErrorBoundaries)throw n;var a="[mobx] uncaught error in '"+this+"'";m.suppressReactionErrors||console.error(a,n),m.globalReactionErrorHandlers.forEach(function(o){return o(n,i)})},r.dispose=function(){this.isDisposed_||(this.isDisposed_=!0,this.isRunning_||(B(),on(this),G()))},r.getDisposer_=function(){var n=this.dispose.bind(this);return n[S]=this,n},r.toString=function(){return"Reaction["+this.name_+"]"},r.trace=function(n){n===void 0&&(n=!1),Fc(this,n)},e}(),fc=100,ln=function(r){return r()};function Hi(){m.inBatch>0||m.isRunningReactions||ln(dc)}function dc(){m.isRunningReactions=!0;for(var e=m.pendingReactions,r=0;e.length>0;){++r===fc&&(console.error("[mobx] cycle in reaction: "+e[0]),e.splice(0));for(var t=e.splice(0),n=0,i=t.length;n<i;n++)t[n].runReaction_()}m.isRunningReactions=!1}var wr=Ve("Reaction",dt);function pc(e){var r=ln;ln=function(n){return e(function(){return r(n)})}}function Rt(){return!1}function Wp(e){}function Yp(e){}function Qp(e){}function hc(e){return console.warn("[mobx.spy] Is a no-op in production builds"),function(){}}var Ji="action",bc="action.bound",Xi="autoAction",vc="autoAction.bound",Zi="<unnamed action>",ea=Tt(Ji),mc=Tt(bc,{bound:!0}),ta=Tt(Xi,{autoAction:!0}),yc=Tt(vc,{autoAction:!0,bound:!0});function ra(e){var r=function(n,i){if(K(n))return ct(n.name||Zi,n,e);if(K(i))return ct(n,i,e);if(Ke(i))return At(n,i,e?ta:ea);if(Ke(n))return me(Tt(e?Xi:Ji,{name:n,autoAction:e}))};return r}var L=ra(!1);Object.assign(L,ea);var Vt=ra(!0);Object.assign(Vt,ta),L.bound=me(mc),Vt.bound=me(yc);function na(e){return Ni(e.name||Zi,!1,e,this,void 0)}function sn(e){return K(e)&&e.isMobxAction===!0}function gc(e,r){var t,n;r===void 0&&(r=Zr);var i=(t=(n=r)==null?void 0:n.name)!=null?t:"Autorun",a=!r.scheduler&&!r.delay,o;if(a)o=new dt(i,function(){this.track(d)},r.onError,r.requiresObservable);else{var u=ia(r),c=!1;o=new dt(i,function(){c||(c=!0,u(function(){c=!1,o.isDisposed_||o.track(d)}))},r.onError,r.requiresObservable)}function d(){e(o)}return o.schedule_(),o.getDisposer_()}var _c=function(r){return r()};function ia(e){return e.scheduler?e.scheduler:e.delay?function(r){return setTimeout(r,e.delay)}:_c}function wc(e,r,t){var n;t===void 0&&(t=Zr);var i=(n=t.name)!=null?n:"Reaction",a=L(i,t.onError?Sc(t.onError,r):r),o=!t.scheduler&&!t.delay,u=ia(t),c=!0,d=!1,f,p,v=t.compareStructural?ut.structural:t.equals||ut.default,y=new dt(i,function(){c||o?P():d||(d=!0,u(P))},t.onError,t.requiresObservable);function P(){if(d=!1,!y.isDisposed_){var j=!1;y.track(function(){var I=Li(!1,function(){return e(y)});j=c||!v(f,I),p=f,f=I}),(c&&t.fireImmediately||!c&&j)&&a(f,p,y),c=!1}}return y.schedule_(),y.getDisposer_()}function Sc(e,r){return function(){try{return r.apply(this,arguments)}catch(t){e.call(this,t)}}}var Oc="onBO",xc="onBUO";function Pc(e,r,t){return oa(Oc,e,r,t)}function aa(e,r,t){return oa(xc,e,r,t)}function oa(e,r,t,n){var i=typeof n=="function"?je(r,t):je(r),a=K(n)?n:t,o=e+"L";return i[o]?i[o].add(a):i[o]=new Set([a]),function(){var u=i[o];u&&(u.delete(a),u.size===0&&delete i[o])}}var Cc="never",Sr="always",Ac="observed";function jc(e){e.isolateGlobalState===!0&&oc();var r=e.useProxies,t=e.enforceActions;if(r!==void 0&&(m.useProxies=r===Sr?!0:r===Cc?!1:typeof Proxy!="undefined"),r==="ifavailable"&&(m.verifyProxies=!0),t!==void 0){var n=t===Sr?Sr:t===Ac;m.enforceActions=n,m.allowStateChanges=!(n===!0||n===Sr)}["computedRequiresReaction","reactionRequiresObservable","observableRequiresReaction","disableErrorBoundaries","safeDescriptors"].forEach(function(i){i in e&&(m[i]=!!e[i])}),m.allowStateReads=!m.observableRequiresReaction,e.reactionScheduler&&pc(e.reactionScheduler)}function Tc(e,r,t,n){var i=bs(r),a=Ar(e,n)[S];B();try{sr(i).forEach(function(o){a.extend_(o,i[o],t&&o in t?t[o]:!0)})}finally{G()}return e}function Ec(e,r){return ua(je(e,r))}function ua(e){var r={name:e.name_};return e.observing_&&e.observing_.length>0&&(r.dependencies=Ic(e.observing_).map(ua)),r}function Ic(e){return Array.from(new Set(e))}var Dc=0;function la(){this.message="FLOW_CANCELLED"}la.prototype=Object.create(Error.prototype);var sa=Ci("flow"),Mc=Ci("flow.bound",{bound:!0}),kt=Object.assign(function(r,t){if(Ke(t))return At(r,t,sa);var n=r,i=n.name||"<unnamed flow>",a=function(){var u=this,c=arguments,d=++Dc,f=L(i+" - runid: "+d+" - init",n).apply(u,c),p,v=void 0,y=new Promise(function(P,j){var I=0;p=j;function $(k){v=void 0;var U;try{U=L(i+" - runid: "+d+" - yield "+I++,f.next).call(f,k)}catch(ee){return j(ee)}Z(U)}function he(k){v=void 0;var U;try{U=L(i+" - runid: "+d+" - yield "+I++,f.throw).call(f,k)}catch(ee){return j(ee)}Z(U)}function Z(k){if(K(k==null?void 0:k.then)){k.then(Z,j);return}return k.done?P(k.value):(v=Promise.resolve(k.value),v.then($,he))}$(void 0)});return y.cancel=L(i+" - runid: "+d+" - cancel",function(){try{v&&ca(v);var P=f.return(void 0),j=Promise.resolve(P.value);j.then(nt,nt),ca(j),p(new la)}catch(I){p(I)}}),y};return a.isMobXFlow=!0,a},sa);kt.bound=me(Mc);function ca(e){K(e.cancel)&&e.cancel()}function Or(e){return(e==null?void 0:e.isMobXFlow)===!0}function fa(e,r,t){var n;return ne(e)||ge(e)||ic(e)?n=_e(e):ie(e)&&(n=_e(e,r)),n.dehancer=typeof r=="function"?r:t,function(){n.dehancer=void 0}}function cn(e,r,t){return K(t)?Vc(e,r,t):Rc(e,r)}function Rc(e,r){return _e(e).intercept_(r)}function Vc(e,r,t){return _e(e,r).intercept_(t)}function kc(e,r){return e?r!==void 0?ie(e)?e[S].values_.has(r):!1:ie(e)||!!e[S]||rn(e)||wr(e)||vr(e):!1}function da(e){return kc(e)}function xr(e){if(ie(e))return e[S].keys_();if(ne(e)||pe(e))return Array.from(e.keys());if(ge(e))return e.map(function(r,t){return t});A(5)}function pa(e){if(ie(e))return xr(e).map(function(r){return e[r]});if(ne(e))return xr(e).map(function(r){return e.get(r)});if(pe(e))return Array.from(e.values());if(ge(e))return e.slice();A(6)}function zc(e){if(ie(e))return xr(e).map(function(r){return[r,e[r]]});if(ne(e))return xr(e).map(function(r){return[r,e.get(r)]});if(pe(e))return Array.from(e.entries());if(ge(e))return e.map(function(r,t){return[t,r]});A(7)}function ha(e,r,t){if(arguments.length===2&&!pe(e)){B();var n=r;try{for(var i in n)ha(e,i,n[i])}finally{G()}return}ie(e)?e[S].set_(r,t):ne(e)?e.set(r,t):pe(e)?e.add(r):ge(e)?(typeof r!="number"&&(r=parseInt(r,10)),r<0&&A("Invalid index: '"+r+"'"),B(),r>=e.length&&(e.length=r+1),e[r]=t,G()):A(8)}function ba(e,r,t){if(ie(e))return e[S].defineProperty_(r,t);A(39)}function fn(e,r,t,n){return K(t)?Lc(e,r,t,n):Nc(e,r,t)}function Nc(e,r,t){return _e(e).observe_(r,t)}function Lc(e,r,t,n){return _e(e,r).observe_(t,n)}function Fc(){A("trace() is not available in production builds");for(var e=!1,r=arguments.length,t=new Array(r),n=0;n<r;n++)t[n]=arguments[n];typeof t[t.length-1]=="boolean"&&(e=t.pop());var i=qc(t);if(!i)return A("'trace(break?)' can only be used inside a tracked computed value or a Reaction. Consider passing in the computed value or reaction explicitly");i.isTracing_===Je.NONE&&console.log("[mobx.trace] '"+i.name_+"' tracing enabled"),i.isTracing_=e?Je.BREAK:Je.LOG}function qc(e){switch(e.length){case 0:return m.trackingDerivation;case 1:return je(e[0]);case 2:return je(e[0],e[1])}}function Ce(e,r){r===void 0&&(r=void 0),B();try{return e.apply(r)}finally{G()}}function pt(e){return e[S]}var Bc={has:function(r,t){return pt(r).has_(t)},get:function(r,t){return pt(r).get_(t)},set:function(r,t,n){var i;return Ke(t)?(i=pt(r).set_(t,n,!0))!=null?i:!0:!1},deleteProperty:function(r,t){var n;return Ke(t)?(n=pt(r).delete_(t,!0))!=null?n:!0:!1},defineProperty:function(r,t,n){var i;return(i=pt(r).defineProperty_(t,n))!=null?i:!0},ownKeys:function(r){return pt(r).ownKeys_()},preventExtensions:function(r){A(13)}};function Gc(e,r){var t,n;return bi(),e=Ar(e,r),(n=(t=e[S]).proxy_)!=null?n:t.proxy_=new Proxy(e,Bc)}function te(e){return e.interceptors_!==void 0&&e.interceptors_.length>0}function zt(e,r){var t=e.interceptors_||(e.interceptors_=[]);return t.push(r),vi(function(){var n=t.indexOf(r);n!==-1&&t.splice(n,1)})}function re(e,r){var t=ft();try{for(var n=[].concat(e.interceptors_||[]),i=0,a=n.length;i<a&&(r=n[i](r),r&&!r.type&&A(14),!!r);i++);return r}finally{ke(t)}}function fe(e){return e.changeListeners_!==void 0&&e.changeListeners_.length>0}function Nt(e,r){var t=e.changeListeners_||(e.changeListeners_=[]);return t.push(r),vi(function(){var n=t.indexOf(r);n!==-1&&t.splice(n,1)})}function de(e,r){var t=ft(),n=e.changeListeners_;if(!!n){n=n.slice();for(var i=0,a=n.length;i<a;i++)n[i](r);ke(t)}}function va(e,r,t){var n=Ar(e,t)[S];B();try{var i;(i=r)!=null||(r=ms(e)),sr(r).forEach(function(a){return n.make_(a,r[a])})}finally{G()}return e}var ma="splice",ye="update",$c=1e4,Uc={get:function(r,t){var n=r[S];return t===S?n:t==="length"?n.getArrayLength_():typeof t=="string"&&!isNaN(t)?n.get_(parseInt(t)):Pe(Pr,t)?Pr[t]:r[t]},set:function(r,t,n){var i=r[S];return t==="length"&&i.setArrayLength_(n),typeof t=="symbol"||isNaN(t)?r[t]=n:i.set_(parseInt(t),n),!0},preventExtensions:function(){A(15)}},dn=function(){function e(t,n,i,a){t===void 0&&(t="ObservableArray"),this.owned_=void 0,this.legacyMode_=void 0,this.atom_=void 0,this.values_=[],this.interceptors_=void 0,this.changeListeners_=void 0,this.enhancer_=void 0,this.dehancer=void 0,this.proxy_=void 0,this.lastKnownLength_=0,this.owned_=i,this.legacyMode_=a,this.atom_=new jt(t),this.enhancer_=function(o,u){return n(o,u,"ObservableArray[..]")}}var r=e.prototype;return r.dehanceValue_=function(n){return this.dehancer!==void 0?this.dehancer(n):n},r.dehanceValues_=function(n){return this.dehancer!==void 0&&n.length>0?n.map(this.dehancer):n},r.intercept_=function(n){return zt(this,n)},r.observe_=function(n,i){return i===void 0&&(i=!1),i&&n({observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:"splice",index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),Nt(this,n)},r.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},r.setArrayLength_=function(n){(typeof n!="number"||isNaN(n)||n<0)&&A("Out of range: "+n);var i=this.values_.length;if(n!==i)if(n>i){for(var a=new Array(n-i),o=0;o<n-i;o++)a[o]=void 0;this.spliceWithArray_(i,0,a)}else this.spliceWithArray_(n,i-n)},r.updateArrayLength_=function(n,i){n!==this.lastKnownLength_&&A(16),this.lastKnownLength_+=i,this.legacyMode_&&i>0&&Ea(n+i+1)},r.spliceWithArray_=function(n,i,a){var o=this;this.atom_;var u=this.values_.length;if(n===void 0?n=0:n>u?n=u:n<0&&(n=Math.max(0,u+n)),arguments.length===1?i=u-n:i==null?i=0:i=Math.max(0,Math.min(i,u-n)),a===void 0&&(a=Xr),te(this)){var c=re(this,{object:this.proxy_,type:ma,index:n,removedCount:i,added:a});if(!c)return Xr;i=c.removedCount,a=c.added}if(a=a.length===0?a:a.map(function(p){return o.enhancer_(p,void 0)}),this.legacyMode_){var d=a.length-i;this.updateArrayLength_(u,d)}var f=this.spliceItemsIntoValues_(n,i,a);return(i!==0||a.length!==0)&&this.notifyArraySplice_(n,a,f),this.dehanceValues_(f)},r.spliceItemsIntoValues_=function(n,i,a){if(a.length<$c){var o;return(o=this.values_).splice.apply(o,[n,i].concat(a))}else{var u=this.values_.slice(n,n+i),c=this.values_.slice(n+i);this.values_.length+=a.length-i;for(var d=0;d<a.length;d++)this.values_[n+d]=a[d];for(var f=0;f<c.length;f++)this.values_[n+a.length+f]=c[f];return u}},r.notifyArrayChildUpdate_=function(n,i,a){var o=!this.owned_&&Rt(),u=fe(this),c=u||o?{observableKind:"array",object:this.proxy_,type:ye,debugObjectName:this.atom_.name_,index:n,newValue:i,oldValue:a}:null;this.atom_.reportChanged(),u&&de(this,c)},r.notifyArraySplice_=function(n,i,a){var o=!this.owned_&&Rt(),u=fe(this),c=u||o?{observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:ma,index:n,removed:a,added:i,removedCount:a.length,addedCount:i.length}:null;this.atom_.reportChanged(),u&&de(this,c)},r.get_=function(n){if(n<this.values_.length)return this.atom_.reportObserved(),this.dehanceValue_(this.values_[n]);console.warn("[mobx.array] Attempt to read an array index ("+n+") that is out of bounds ("+this.values_.length+"). Please check length first. Out of bound indices will not be tracked by MobX")},r.set_=function(n,i){var a=this.values_;if(n<a.length){this.atom_;var o=a[n];if(te(this)){var u=re(this,{type:ye,object:this.proxy_,index:n,newValue:i});if(!u)return;i=u.newValue}i=this.enhancer_(i,o);var c=i!==o;c&&(a[n]=i,this.notifyArrayChildUpdate_(n,i,o))}else n===a.length?this.spliceWithArray_(n,0,[i]):A(17,n,a.length)},e}();function Wc(e,r,t,n){t===void 0&&(t="ObservableArray"),n===void 0&&(n=!1),bi();var i=new dn(t,r,n,!1);yi(i.values_,S,i);var a=new Proxy(i.values_,Uc);if(i.proxy_=a,e&&e.length){var o=Et(!0);i.spliceWithArray_(0,0,e),It(o)}return a}var Pr={clear:function(){return this.splice(0)},replace:function(r){var t=this[S];return t.spliceWithArray_(0,t.values_.length,r)},toJSON:function(){return this.slice()},splice:function(r,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),a=2;a<n;a++)i[a-2]=arguments[a];var o=this[S];switch(arguments.length){case 0:return[];case 1:return o.spliceWithArray_(r);case 2:return o.spliceWithArray_(r,t)}return o.spliceWithArray_(r,t,i)},spliceWithArray:function(r,t,n){return this[S].spliceWithArray_(r,t,n)},push:function(){for(var r=this[S],t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return r.spliceWithArray_(r.values_.length,0,n),r.values_.length},pop:function(){return this.splice(Math.max(this[S].values_.length-1,0),1)[0]},shift:function(){return this.splice(0,1)[0]},unshift:function(){for(var r=this[S],t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];return r.spliceWithArray_(0,0,n),r.values_.length},reverse:function(){return m.trackingDerivation&&A(37,"reverse"),this.replace(this.slice().reverse()),this},sort:function(){m.trackingDerivation&&A(37,"sort");var r=this.slice();return r.sort.apply(r,arguments),this.replace(r),this},remove:function(r){var t=this[S],n=t.dehanceValues_(t.values_).indexOf(r);return n>-1?(this.splice(n,1),!0):!1}};N("concat",Ae),N("flat",Ae),N("includes",Ae),N("indexOf",Ae),N("join",Ae),N("lastIndexOf",Ae),N("slice",Ae),N("toString",Ae),N("toLocaleString",Ae),N("every",ze),N("filter",ze),N("find",ze),N("findIndex",ze),N("flatMap",ze),N("forEach",ze),N("map",ze),N("some",ze),N("reduce",ya),N("reduceRight",ya);function N(e,r){typeof Array.prototype[e]=="function"&&(Pr[e]=r(e))}function Ae(e){return function(){var r=this[S];r.atom_.reportObserved();var t=r.dehanceValues_(r.values_);return t[e].apply(t,arguments)}}function ze(e){return function(r,t){var n=this,i=this[S];i.atom_.reportObserved();var a=i.dehanceValues_(i.values_);return a[e](function(o,u){return r.call(t,o,u,n)})}}function ya(e){return function(){var r=this,t=this[S];t.atom_.reportObserved();var n=t.dehanceValues_(t.values_),i=arguments[0];return arguments[0]=function(a,o,u){return i(a,o,u,r)},n[e].apply(n,arguments)}}var Yc=Ve("ObservableArrayAdministration",dn);function ge(e){return ur(e)&&Yc(e[S])}var ga,_a,Qc={},Ne="add",Cr="delete";ga=Symbol.iterator,_a=Symbol.toStringTag;var pn=function(){function e(t,n,i){var a=this;n===void 0&&(n=lt),i===void 0&&(i="ObservableMap"),this.enhancer_=void 0,this.name_=void 0,this[S]=Qc,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=n,this.name_=i,K(Map)||A(18),this.keysAtom_=cr("ObservableMap.keys()"),this.data_=new Map,this.hasMap_=new Map,Li(!0,function(){a.merge(t)})}var r=e.prototype;return r.has_=function(n){return this.data_.has(n)},r.has=function(n){var i=this;if(!m.trackingDerivation)return this.has_(n);var a=this.hasMap_.get(n);if(!a){var o=a=new He(this.has_(n),fr,"ObservableMap.key?",!1);this.hasMap_.set(n,o),aa(o,function(){return i.hasMap_.delete(n)})}return a.get()},r.set=function(n,i){var a=this.has_(n);if(te(this)){var o=re(this,{type:a?ye:Ne,object:this,newValue:i,name:n});if(!o)return this;i=o.newValue}return a?this.updateValue_(n,i):this.addValue_(n,i),this},r.delete=function(n){var i=this;if(this.keysAtom_,te(this)){var a=re(this,{type:Cr,object:this,name:n});if(!a)return!1}if(this.has_(n)){var o=Rt(),u=fe(this),c=u||o?{observableKind:"map",debugObjectName:this.name_,type:Cr,object:this,oldValue:this.data_.get(n).value_,name:n}:null;return Ce(function(){var d;i.keysAtom_.reportChanged(),(d=i.hasMap_.get(n))==null||d.setNewValue_(!1);var f=i.data_.get(n);f.setNewValue_(void 0),i.data_.delete(n)}),u&&de(this,c),!0}return!1},r.updateValue_=function(n,i){var a=this.data_.get(n);if(i=a.prepareNewValue_(i),i!==m.UNCHANGED){var o=Rt(),u=fe(this),c=u||o?{observableKind:"map",debugObjectName:this.name_,type:ye,object:this,oldValue:a.value_,name:n,newValue:i}:null;a.setNewValue_(i),u&&de(this,c)}},r.addValue_=function(n,i){var a=this;this.keysAtom_,Ce(function(){var d,f=new He(i,a.enhancer_,"ObservableMap.key",!1);a.data_.set(n,f),i=f.value_,(d=a.hasMap_.get(n))==null||d.setNewValue_(!0),a.keysAtom_.reportChanged()});var o=Rt(),u=fe(this),c=u||o?{observableKind:"map",debugObjectName:this.name_,type:Ne,object:this,name:n,newValue:i}:null;u&&de(this,c)},r.get=function(n){return this.has(n)?this.dehanceValue_(this.data_.get(n).get()):this.dehanceValue_(void 0)},r.dehanceValue_=function(n){return this.dehancer!==void 0?this.dehancer(n):n},r.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},r.values=function(){var n=this,i=this.keys();return Lt({next:function(){var o=i.next(),u=o.done,c=o.value;return{done:u,value:u?void 0:n.get(c)}}})},r.entries=function(){var n=this,i=this.keys();return Lt({next:function(){var o=i.next(),u=o.done,c=o.value;return{done:u,value:u?void 0:[c,n.get(c)]}}})},r[ga]=function(){return this.entries()},r.forEach=function(n,i){for(var a=ot(this),o;!(o=a()).done;){var u=o.value,c=u[0],d=u[1];n.call(i,d,c,this)}},r.merge=function(n){var i=this;return ne(n)&&(n=new Map(n)),Ce(function(){Re(n)?hs(n).forEach(function(a){return i.set(a,n[a])}):Array.isArray(n)?n.forEach(function(a){var o=a[0],u=a[1];return i.set(o,u)}):it(n)?(n.constructor!==Map&&A(19,n),n.forEach(function(a,o){return i.set(o,a)})):n!=null&&A(20,n)}),this},r.clear=function(){var n=this;Ce(function(){Gi(function(){for(var i=ot(n.keys()),a;!(a=i()).done;){var o=a.value;n.delete(o)}})})},r.replace=function(n){var i=this;return Ce(function(){for(var a=Kc(n),o=new Map,u=!1,c=ot(i.data_.keys()),d;!(d=c()).done;){var f=d.value;if(!a.has(f)){var p=i.delete(f);if(p)u=!0;else{var v=i.data_.get(f);o.set(f,v)}}}for(var y=ot(a.entries()),P;!(P=y()).done;){var j=P.value,I=j[0],$=j[1],he=i.data_.has(I);if(i.set(I,$),i.data_.has(I)){var Z=i.data_.get(I);o.set(I,Z),he||(u=!0)}}if(!u)if(i.data_.size!==o.size)i.keysAtom_.reportChanged();else for(var k=i.data_.keys(),U=o.keys(),ee=k.next(),_t=U.next();!ee.done;){if(ee.value!==_t.value){i.keysAtom_.reportChanged();break}ee=k.next(),_t=U.next()}i.data_=o}),this},r.toString=function(){return"[object ObservableMap]"},r.toJSON=function(){return Array.from(this)},r.observe_=function(n,i){return Nt(this,n)},r.intercept_=function(n){return zt(this,n)},en(e,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:_a,get:function(){return"Map"}}]),e}(),ne=Ve("ObservableMap",pn);function Kc(e){if(it(e)||ne(e))return e;if(Array.isArray(e))return new Map(e);if(Re(e)){var r=new Map;for(var t in e)r.set(t,e[t]);return r}else return A(21,e)}var wa,Sa,Hc={};wa=Symbol.iterator,Sa=Symbol.toStringTag;var Oa=function(){function e(t,n,i){n===void 0&&(n=lt),i===void 0&&(i="ObservableSet"),this.name_=void 0,this[S]=Hc,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=i,K(Set)||A(22),this.atom_=cr(this.name_),this.enhancer_=function(a,o){return n(a,o,i)},t&&this.replace(t)}var r=e.prototype;return r.dehanceValue_=function(n){return this.dehancer!==void 0?this.dehancer(n):n},r.clear=function(){var n=this;Ce(function(){Gi(function(){for(var i=ot(n.data_.values()),a;!(a=i()).done;){var o=a.value;n.delete(o)}})})},r.forEach=function(n,i){for(var a=ot(this),o;!(o=a()).done;){var u=o.value;n.call(i,u,u,this)}},r.add=function(n){var i=this;if(this.atom_,te(this)){var a=re(this,{type:Ne,object:this,newValue:n});if(!a)return this}if(!this.has(n)){Ce(function(){i.data_.add(i.enhancer_(n,void 0)),i.atom_.reportChanged()});var o=!1,u=fe(this),c=u||o?{observableKind:"set",debugObjectName:this.name_,type:Ne,object:this,newValue:n}:null;u&&de(this,c)}return this},r.delete=function(n){var i=this;if(te(this)){var a=re(this,{type:Cr,object:this,oldValue:n});if(!a)return!1}if(this.has(n)){var o=!1,u=fe(this),c=u||o?{observableKind:"set",debugObjectName:this.name_,type:Cr,object:this,oldValue:n}:null;return Ce(function(){i.atom_.reportChanged(),i.data_.delete(n)}),u&&de(this,c),!0}return!1},r.has=function(n){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(n))},r.entries=function(){var n=0,i=Array.from(this.keys()),a=Array.from(this.values());return Lt({next:function(){var u=n;return n+=1,u<a.length?{value:[i[u],a[u]],done:!1}:{done:!0}}})},r.keys=function(){return this.values()},r.values=function(){this.atom_.reportObserved();var n=this,i=0,a=Array.from(this.data_.values());return Lt({next:function(){return i<a.length?{value:n.dehanceValue_(a[i++]),done:!1}:{done:!0}}})},r.replace=function(n){var i=this;return pe(n)&&(n=new Set(n)),Ce(function(){Array.isArray(n)?(i.clear(),n.forEach(function(a){return i.add(a)})):Ct(n)?(i.clear(),n.forEach(function(a){return i.add(a)})):n!=null&&A("Cannot initialize set from "+n)}),this},r.observe_=function(n,i){return Nt(this,n)},r.intercept_=function(n){return zt(this,n)},r.toJSON=function(){return Array.from(this)},r.toString=function(){return"[object ObservableSet]"},r[wa]=function(){return this.values()},en(e,[{key:"size",get:function(){return this.atom_.reportObserved(),this.data_.size}},{key:Sa,get:function(){return"Set"}}]),e}(),pe=Ve("ObservableSet",Oa),xa=Object.create(null),Pa="remove",Ca=function(){function e(t,n,i,a){n===void 0&&(n=new Map),a===void 0&&(a=Ls),this.target_=void 0,this.values_=void 0,this.name_=void 0,this.defaultAnnotation_=void 0,this.keysAtom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.proxy_=void 0,this.isPlainObject_=void 0,this.appliedAnnotations_=void 0,this.pendingKeys_=void 0,this.target_=t,this.values_=n,this.name_=i,this.defaultAnnotation_=a,this.keysAtom_=new jt("ObservableObject.keys"),this.isPlainObject_=Re(this.target_)}var r=e.prototype;return r.getObservablePropValue_=function(n){return this.values_.get(n).get()},r.setObservablePropValue_=function(n,i){var a=this.values_.get(n);if(a instanceof Dt)return a.set(i),!0;if(te(this)){var o=re(this,{type:ye,object:this.proxy_||this.target_,name:n,newValue:i});if(!o)return null;i=o.newValue}if(i=a.prepareNewValue_(i),i!==m.UNCHANGED){var u=fe(this),c=!1,d=u||c?{type:ye,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,oldValue:a.value_,name:n,newValue:i}:null;a.setNewValue_(i),u&&de(this,d)}return!0},r.get_=function(n){return m.trackingDerivation&&!Pe(this.target_,n)&&this.has_(n),this.target_[n]},r.set_=function(n,i,a){return a===void 0&&(a=!1),Pe(this.target_,n)?this.values_.has(n)?this.setObservablePropValue_(n,i):a?Reflect.set(this.target_,n,i):(this.target_[n]=i,!0):this.extend_(n,{value:i,enumerable:!0,writable:!0,configurable:!0},this.defaultAnnotation_,a)},r.has_=function(n){if(!m.trackingDerivation)return n in this.target_;this.pendingKeys_||(this.pendingKeys_=new Map);var i=this.pendingKeys_.get(n);return i||(i=new He(n in this.target_,fr,"ObservableObject.key?",!1),this.pendingKeys_.set(n,i)),i.get()},r.make_=function(n,i){if(i===!0&&(i=this.defaultAnnotation_),i!==!1){if(!(n in this.target_)){var a;if((a=this.target_[ve])!=null&&a[n])return;A(1,i.annotationType_,this.name_+"."+n.toString())}for(var o=this.target_;o&&o!==or;){var u=ar(o,n);if(u){var c=i.make_(this,n,u,o);if(c===0)return;if(c===1)break}o=Object.getPrototypeOf(o)}ja(this,i,n)}},r.extend_=function(n,i,a,o){if(o===void 0&&(o=!1),a===!0&&(a=this.defaultAnnotation_),a===!1)return this.defineProperty_(n,i,o);var u=a.extend_(this,n,i,o);return u&&ja(this,a,n),u},r.defineProperty_=function(n,i,a){a===void 0&&(a=!1);try{B();var o=this.delete_(n);if(!o)return o;if(te(this)){var u=re(this,{object:this.proxy_||this.target_,name:n,type:Ne,newValue:i.value});if(!u)return null;var c=u.newValue;i.value!==c&&(i=at({},i,{value:c}))}if(a){if(!Reflect.defineProperty(this.target_,n,i))return!1}else xe(this.target_,n,i);this.notifyPropertyAddition_(n,i.value)}finally{G()}return!0},r.defineObservableProperty_=function(n,i,a,o){o===void 0&&(o=!1);try{B();var u=this.delete_(n);if(!u)return u;if(te(this)){var c=re(this,{object:this.proxy_||this.target_,name:n,type:Ne,newValue:i});if(!c)return null;i=c.newValue}var d=Aa(n),f={configurable:m.safeDescriptors?this.isPlainObject_:!0,enumerable:!0,get:d.get,set:d.set};if(o){if(!Reflect.defineProperty(this.target_,n,f))return!1}else xe(this.target_,n,f);var p=new He(i,a,"ObservableObject.key",!1);this.values_.set(n,p),this.notifyPropertyAddition_(n,p.value_)}finally{G()}return!0},r.defineComputedProperty_=function(n,i,a){a===void 0&&(a=!1);try{B();var o=this.delete_(n);if(!o)return o;if(te(this)){var u=re(this,{object:this.proxy_||this.target_,name:n,type:Ne,newValue:void 0});if(!u)return null}i.name||(i.name="ObservableObject.key"),i.context=this.proxy_||this.target_;var c=Aa(n),d={configurable:m.safeDescriptors?this.isPlainObject_:!0,enumerable:!1,get:c.get,set:c.set};if(a){if(!Reflect.defineProperty(this.target_,n,d))return!1}else xe(this.target_,n,d);this.values_.set(n,new Dt(i)),this.notifyPropertyAddition_(n,void 0)}finally{G()}return!0},r.delete_=function(n,i){if(i===void 0&&(i=!1),!Pe(this.target_,n))return!0;if(te(this)){var a=re(this,{object:this.proxy_||this.target_,name:n,type:Pa});if(!a)return null}try{var o,u;B();var c=fe(this),d=!1,f=this.values_.get(n),p=void 0;if(!f&&(c||d)){var v;p=(v=ar(this.target_,n))==null?void 0:v.value}if(i){if(!Reflect.deleteProperty(this.target_,n))return!1}else delete this.target_[n];if(f&&(this.values_.delete(n),f instanceof He&&(p=f.value_),Ki(f)),this.keysAtom_.reportChanged(),(o=this.pendingKeys_)==null||(u=o.get(n))==null||u.set(n in this.target_),c||d){var y={type:Pa,observableKind:"object",object:this.proxy_||this.target_,debugObjectName:this.name_,oldValue:p,name:n};c&&de(this,y)}}finally{G()}return!0},r.observe_=function(n,i){return Nt(this,n)},r.intercept_=function(n){return zt(this,n)},r.notifyPropertyAddition_=function(n,i){var a,o,u=fe(this),c=!1;if(u||c){var d=u||c?{type:Ne,observableKind:"object",debugObjectName:this.name_,object:this.proxy_||this.target_,name:n,newValue:i}:null;u&&de(this,d)}(a=this.pendingKeys_)==null||(o=a.get(n))==null||o.set(!0),this.keysAtom_.reportChanged()},r.ownKeys_=function(){return this.keysAtom_.reportObserved(),sr(this.target_)},r.keys_=function(){return this.keysAtom_.reportObserved(),Object.keys(this.target_)},e}();function Ar(e,r){var t;if(Pe(e,S))return e;var n=(t=r==null?void 0:r.name)!=null?t:"ObservableObject",i=new Ca(e,new Map,String(n),Ks(r));return lr(e,S,i),e}var Jc=Ve("ObservableObjectAdministration",Ca);function Aa(e){return xa[e]||(xa[e]={get:function(){return this[S].getObservablePropValue_(e)},set:function(t){return this[S].setObservablePropValue_(e,t)}})}function ie(e){return ur(e)?Jc(e[S]):!1}function ja(e,r,t){var n;(n=e.target_[ve])==null||delete n[t]}var hn=0,Ta=function(){};function Xc(e,r){Object.setPrototypeOf?Object.setPrototypeOf(e.prototype,r):e.prototype.__proto__!==void 0?e.prototype.__proto__=r:e.prototype=r}Xc(Ta,Array.prototype);var bn=function(e,r,t){Si(n,e);function n(a,o,u,c){var d;u===void 0&&(u="ObservableArray"),c===void 0&&(c=!1),d=e.call(this)||this;var f=new dn(u,o,c,!0);if(f.proxy_=Oi(d),yi(Oi(d),S,f),a&&a.length){var p=Et(!0);d.spliceWithArray(0,0,a),It(p)}return d}var i=n.prototype;return i.concat=function(){this[S].atom_.reportObserved();for(var o=arguments.length,u=new Array(o),c=0;c<o;c++)u[c]=arguments[c];return Array.prototype.concat.apply(this.slice(),u.map(function(d){return ge(d)?d.slice():d}))},i[t]=function(){var a=this,o=0;return Lt({next:function(){return o<a.length?{value:a[o++],done:!1}:{done:!0,value:void 0}}})},en(n,[{key:"length",get:function(){return this[S].getArrayLength_()},set:function(o){this[S].setArrayLength_(o)}},{key:r,get:function(){return"Array"}}]),n}(Ta,Symbol.toStringTag,Symbol.iterator);Object.entries(Pr).forEach(function(e){var r=e[0],t=e[1];r!=="concat"&&lr(bn.prototype,r,t)});function Zc(e){return{enumerable:!1,configurable:!0,get:function(){return this[S].get_(e)},set:function(t){this[S].set_(e,t)}}}function ef(e){xe(bn.prototype,""+e,Zc(e))}function Ea(e){if(e>hn){for(var r=hn;r<e+100;r++)ef(r);hn=e}}Ea(1e3);function tf(e,r,t){return new bn(e,r,t)}function je(e,r){if(typeof e=="object"&&e!==null){if(ge(e))return r!==void 0&&A(23),e[S].atom_;if(pe(e))return e[S];if(ne(e)){if(r===void 0)return e.keysAtom_;var t=e.data_.get(r)||e.hasMap_.get(r);return t||A(25,r,vn(e)),t}if(ie(e)){if(!r)return A(26);var n=e[S].values_.get(r);return n||A(27,r,vn(e)),n}if(rn(e)||vr(e)||wr(e))return e}else if(K(e)&&wr(e[S]))return e[S];A(28)}function _e(e,r){if(e||A(29),r!==void 0)return _e(je(e,r));if(rn(e)||vr(e)||wr(e)||ne(e)||pe(e))return e;if(e[S])return e[S];A(24,e)}function vn(e,r){var t;if(r!==void 0)t=je(e,r);else{if(sn(e))return e.name;ie(e)||ne(e)||pe(e)?t=_e(e):t=je(e)}return t.name_}var Ia=or.toString;function mn(e,r,t){return t===void 0&&(t=-1),yn(e,r,t)}function yn(e,r,t,n,i){if(e===r)return e!==0||1/e===1/r;if(e==null||r==null)return!1;if(e!==e)return r!==r;var a=typeof e;if(a!=="function"&&a!=="object"&&typeof r!="object")return!1;var o=Ia.call(e);if(o!==Ia.call(r))return!1;switch(o){case"[object RegExp]":case"[object String]":return""+e==""+r;case"[object Number]":return+e!=+e?+r!=+r:+e==0?1/+e===1/r:+e==+r;case"[object Date]":case"[object Boolean]":return+e==+r;case"[object Symbol]":return typeof Symbol!="undefined"&&Symbol.valueOf.call(e)===Symbol.valueOf.call(r);case"[object Map]":case"[object Set]":t>=0&&t++;break}e=Da(e),r=Da(r);var u=o==="[object Array]";if(!u){if(typeof e!="object"||typeof r!="object")return!1;var c=e.constructor,d=r.constructor;if(c!==d&&!(K(c)&&c instanceof c&&K(d)&&d instanceof d)&&"constructor"in e&&"constructor"in r)return!1}if(t===0)return!1;t<0&&(t=-1),n=n||[],i=i||[];for(var f=n.length;f--;)if(n[f]===e)return i[f]===r;if(n.push(e),i.push(r),u){if(f=e.length,f!==r.length)return!1;for(;f--;)if(!yn(e[f],r[f],t-1,n,i))return!1}else{var p=Object.keys(e),v;if(f=p.length,Object.keys(r).length!==f)return!1;for(;f--;)if(v=p[f],!(Pe(r,v)&&yn(e[v],r[v],t-1,n,i)))return!1}return n.pop(),i.pop(),!0}function Da(e){return ge(e)?e.slice():it(e)||ne(e)||Ct(e)||pe(e)?Array.from(e.entries()):e}function Lt(e){return e[Symbol.iterator]=rf,e}function rf(){return this}if(["Symbol","Map","Set"].forEach(function(e){var r=Jr();typeof r[e]=="undefined"&&A("MobX requires global '"+e+"' to be available or polyfilled")}),typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__=="object"&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:hc,extras:{getDebugName:vn},$mobx:S}),!z.useState)throw new Error("mobx-react-lite requires React with Hooks support");if(!va)throw new Error("mobx-react-lite@3 requires mobx at least version 6 to be available");function nf(e){e()}function af(e){e||(e=nf),jc({reactionScheduler:e})}function of(e){return Ec(e)}var Ma=typeof FinalizationRegistry=="undefined"?void 0:FinalizationRegistry;function Ra(e){var r={reaction:e,mounted:!1,changedBeforeMount:!1,cleanAt:Date.now()+uf};return r}var uf=1e4,lf=1e4;function sf(e){var r=new Map,t=1,n=new e(function(a){var o=r.get(a);o&&(o.reaction.dispose(),r.delete(a))});return{addReactionToTrack:function(i,a,o){var u=t++;return n.register(o,u,i),i.current=Ra(a),i.current.finalizationRegistryCleanupToken=u,r.set(u,i.current),i.current},recordReactionAsCommitted:function(i){n.unregister(i),i.current&&i.current.finalizationRegistryCleanupToken&&r.delete(i.current.finalizationRegistryCleanupToken)},forceCleanupTimerToRunNowForTests:function(){},resetCleanupScheduleForTests:function(){}}}var cf=globalThis&&globalThis.__values||function(e){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")};function ff(){var e=new Set,r;function t(){r&&(clearTimeout(r),u())}function n(){var c,d;if(e.size>0){try{for(var f=cf(e),p=f.next();!p.done;p=f.next()){var v=p.value,y=v.current;y&&(y.reaction.dispose(),v.current=null)}}catch(P){c={error:P}}finally{try{p&&!p.done&&(d=f.return)&&d.call(f)}finally{if(c)throw c.error}}e.clear()}r&&(clearTimeout(r),r=void 0)}function i(){r===void 0&&(r=setTimeout(u,lf))}function a(c){e.add(c),i()}function o(c){e.delete(c)}function u(){r=void 0;var c=Date.now();e.forEach(function(d){var f=d.current;f&&c>=f.cleanAt&&(f.reaction.dispose(),d.current=null,e.delete(d))}),e.size>0&&i()}return{addReactionToTrack:function(c,d,f){return c.current=Ra(d),a(c),c.current},recordReactionAsCommitted:o,forceCleanupTimerToRunNowForTests:t,resetCleanupScheduleForTests:n}}var Va=Ma?sf(Ma):ff(),df=Va.addReactionToTrack,pf=Va.recordReactionAsCommitted,ka=globalThis&&globalThis.__read||function(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),i,a=[],o;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(u){o={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a};function za(e){return"observer".concat(e)}var hf=function(){function e(){}return e}();function bf(){return new hf}function vf(e,r){r===void 0&&(r="observed");var t=ka(h.default.useState(bf),1),n=t[0],i=ka(h.default.useState(),2),a=i[1],o=function(){return a([])},u=h.default.useRef(null);if(!u.current)var c=new dt(za(r),function(){d.mounted?o():d.changedBeforeMount=!0}),d=df(u,c,n);var f=u.current.reaction;h.default.useDebugValue(f,of),h.default.useEffect(function(){return pf(u),u.current?(u.current.mounted=!0,u.current.changedBeforeMount&&(u.current.changedBeforeMount=!1,o())):(u.current={reaction:new dt(za(r),function(){o()}),mounted:!0,changedBeforeMount:!1,cleanAt:1/0},o()),function(){u.current.reaction.dispose(),u.current=null}},[]);var p,v;if(f.track(function(){try{p=e()}catch(y){v=y}}),v)throw v;return p}var Na=typeof Symbol=="function"&&Symbol.for,La=Na?Symbol.for("react.forward_ref"):typeof z.forwardRef=="function"&&z.forwardRef(function(e){return null}).$$typeof,Fa=Na?Symbol.for("react.memo"):typeof z.memo=="function"&&z.memo(function(e){return null}).$$typeof;function ae(e,r){var t;if(Fa&&e.$$typeof===Fa)throw new Error("[mobx-react-lite] You are trying to use `observer` on a function component wrapped in either another `observer` or `React.memo`. The observer already applies 'React.memo' for you.");var n=(t=r==null?void 0:r.forwardRef)!==null&&t!==void 0?t:!1,i=e,a=e.displayName||e.name;if(La&&e.$$typeof===La&&(n=!0,i=e.render,typeof i!="function"))throw new Error("[mobx-react-lite] `render` property of ForwardRef was not a function");var o=function(u,c){return vf(function(){return i(u,c)},a)};return a!==""&&(o.displayName=a),e.contextTypes&&(o.contextTypes=e.contextTypes),n&&(o=z.forwardRef(o)),o=z.memo(o),yf(e,o),o}var mf={$$typeof:!0,render:!0,compare:!0,type:!0,displayName:!0};function yf(e,r){Object.keys(e).forEach(function(t){mf[t]||Object.defineProperty(r,t,Object.getOwnPropertyDescriptor(e,t))})}globalThis&&globalThis.__read,af(Uo.unstable_batchedUpdates);var gf="warn";function _f(){return gf}var F;(function(e){e.afterCreate="afterCreate",e.afterAttach="afterAttach",e.afterCreationFinalization="afterCreationFinalization",e.beforeDetach="beforeDetach",e.beforeDestroy="beforeDestroy"})(F||(F={}));/*! *****************************************************************************
25
- Copyright (c) Microsoft Corporation.
41
+ `,jr=Ce.observer(function({showSQLSnippets:e=!0,sx:r={}}){const o=Fe(),a=o.context.current,l=V.default.useMemo(()=>{const s={context:a,filters:o.filters.values};if(e){const i=o.sqlSnippets.current.reduce((d,v)=>(d[v.key]=v.value,d),{});s.sql_snippets=i}return JSON.stringify(s,null,2)},[a,o.sqlSnippets.current,o.filters.values,e]);return G(c.Stack,{sx:{border:"1px solid #eee",maxWidth:"40%",overflow:"hidden",...r},children:[n(c.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:n(c.Text,{weight:500,children:"Global Variables"})}),G(c.Stack,{px:"md",pb:"md",sx:{width:"100%"},children:[n(it.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:Ca}),n(c.Text,{weight:500,sx:{flexGrow:0},children:"Current Values"}),n(it.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:l})]})]})});function Ea(t,e){const r=Object.keys(e),o=Object.values(e);try{return new Function(...r,`return \`${t}\`;`)(...o)}catch(a){return console.error(a),a.message}}function Ht(t,e){const r=Object.keys(e),o=Object.values(e);try{return new Function(...r,`return \`${t}\`;`)(...o)}catch(a){throw r.length===0&&t.includes("$")?new Error("[formatSQL] insufficient params"):a}}function qr(t,e,r){const o=e.reduce((a,l)=>(a[l.key]=Ht(l.value,t),a),{});return ye.default.merge({},o,t,{filters:r})}function Ta(t,e,r,o){try{const a=qr(e,r,o);return Ht(t,a)}catch(a){return console.error(a),a.message}}const ot={baseURL:"http://localhost:31200",getRequest(t){return(e,r,o={})=>{const a={"X-Requested-With":"XMLHttpRequest","Content-Type":o.string?"application/x-www-form-urlencoded":"application/json",...o.headers},l={baseURL:this.baseURL,method:t,url:e,params:t==="GET"?r:o.params,headers:a};return t==="POST"&&(l.data=o.string?JSON.stringify(r):r),Tn.default(l).then(s=>s.data).catch(s=>Promise.reject(s))}}},er=({type:t,key:e,sql:r})=>async()=>{if(!t||!e||!r)return[];try{return await ot.getRequest("POST")("/query",{type:t,key:e,query:r})}catch(o){return console.error(o),[]}};async function Aa({context:t,sqlSnippets:e,title:r,query:o,filterValues:a}){if(!o.sql)return[];const{type:l,key:s,sql:i}=o,d=i.includes("$");try{const v=qr(t,e,a),h=Ht(i,v);return d&&(console.groupCollapsed(`Final SQL for: ${r}`),console.log(h),console.groupEnd()),await ot.getRequest("POST")("/query",{type:l,key:s,query:h})}catch(v){return console.error(v),[]}}async function Nr(){try{return(await ot.getRequest("POST")("/datasource/list",{filter:{},sort:{field:"create_time",order:"ASC"},pagination:{page:1,pagesize:100}})).data}catch(t){return console.error(t),[]}}function Gr({value:t}){const e=Fe(),r=e.context.current,o=V.default.useMemo(()=>Ta(t,r,e.sqlSnippets.current,e.filters.values),[t,r,e.sqlSnippets.current,e.filters.values]);return n(it.Prism,{language:"sql",colorScheme:"light",children:o})}const za=Ce.observer(function({queryModel:e}){const{data:r=[],loading:o}=ut.useRequest(Nr,{refreshDeps:[]},[]),a=V.default.useMemo(()=>Array.from(new Set(r.map(({type:p})=>p))).map(p=>({label:p,value:p})),[r]),l=V.default.useMemo(()=>{const h=r.filter(({type:p})=>p===e.type);return h?h.map(({key:p})=>({label:p,value:p})):[]},[r,e.type]),[s,i]=V.default.useState(e.sql);V.default.useEffect(()=>{i(h=>h!==e.sql?e.sql:h)},[e.sql]);const d=s!==e.sql,v=()=>{e.setSQL(s)};return G(c.Stack,{sx:{border:"1px solid #eee",flexGrow:1},children:[n(c.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:n(c.Text,{weight:500,children:"Edit Query"})}),G(c.Stack,{my:0,p:"md",pr:40,children:[G(c.Group,{grow:!0,children:[n(c.TextInput,{placeholder:"An ID unique in this dashboard",label:"ID",required:!0,sx:{flex:1},disabled:o,value:e.id,onChange:h=>{e.setID(h.currentTarget.value)}}),n(c.Select,{label:"Data Source Type",data:a,sx:{flex:1},disabled:o,value:e.type,onChange:e.setType}),n(c.Select,{label:"Data Source Key",data:l,sx:{flex:1},disabled:o,value:e.key,onChange:e.setKey})]}),G(c.Tabs,{defaultValue:"SQL",children:[G(c.Tabs.List,{children:[n(c.Tabs.Tab,{value:"SQL",children:"SQL"}),n(c.Tabs.Tab,{value:"Preview",children:"Preview"})]}),n(c.Tabs.Panel,{value:"SQL",pt:"sm",children:G(c.Box,{sx:{position:"relative"},children:[n(c.Textarea,{autosize:!0,minRows:12,maxRows:24,className:"code-textarea",value:s,onChange:h=>{i(h.currentTarget.value)}}),n(c.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:10,top:10},disabled:!d,onClick:v,children:n(he.DeviceFloppy,{size:20})})]})}),n(c.Tabs.Panel,{value:"Preview",pt:"sm",children:n(Gr,{value:e.sql})})]})]})]})}),Oa=Ce.observer(function({id:e,setID:r}){const o=Fe(),a=V.default.useMemo(()=>o.queries.findByID(e),[o.queries,e]);return e?a?n(za,{queryModel:a}):n("span",{children:"Invalid Query ID"}):null});var yt=(t=>(t.Postgresql="postgresql",t.MySQL="mysql",t.HTTP="http",t))(yt||{});const Da=Ce.observer(function({id:e,setID:r}){const o=Fe(),a=()=>{var s;r((s=o.queries.firstID)!=null?s:"")};V.default.useEffect(()=>{if(!e){a();return}o.queries.current.findIndex(i=>i.id===e)===-1&&a()},[e,o.queries.current,a]);const l=()=>{const s=Be.randomId();o.queries.append(se.cast({id:s,type:yt.Postgresql,key:"",sql:""})),r(s)};return n(c.Group,{pb:"xl",children:G(c.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[n(c.Text,{children:"Select a Query"}),n(c.Select,{data:o.queries.options,value:e,onChange:r,allowDeselect:!1,clearable:!1,sx:{flexGrow:1}}),n(c.Text,{children:"or"}),n(c.Group,{position:"center",mt:"md",children:n(c.Button,{onClick:l,children:"Add a Query"})})]})})}),Ia=Ce.observer(function({}){const[e,r]=V.default.useState("");return G(c.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:[G(c.Group,{position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[G(c.Stack,{sx:{flexGrow:1,maxWidth:"calc(60% - 16px)"},children:[n(Da,{id:e,setID:r}),n(Oa,{id:e,setID:r})]}),n(jr,{})]}),n(cr,{id:e})]})});function Pa({value:t}){const r=Fe().context.current,o=V.default.useMemo(()=>Ea(t,r),[t,r]);return G(c.Stack,{children:[n(c.Text,{children:"Preview"}),n(it.Prism,{language:"sql",noCopy:!0,colorScheme:"dark",children:o})]})}const Ra=Ce.observer(function({}){const e=Fe(),r=()=>e.sqlSnippets.append(se.cast({key:Be.randomId(),value:""}));return G(c.Stack,{sx:{border:"1px solid #eee",flexGrow:1},children:[n(c.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:n(c.Text,{weight:500,children:"SQL Snippets"})}),n(c.Group,{px:"md",pb:"md",pt:"md",children:G(c.Stack,{sx:{width:"100%",position:"relative"},children:[e.sqlSnippets.current.map((o,a)=>G(c.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[n(c.TextInput,{label:"Key",required:!0,value:o.key,onChange:l=>{o.setKey(l.currentTarget.value)}}),n(c.Textarea,{minRows:3,label:"Value",required:!0,value:o.value,onChange:l=>{o.setValue(l.currentTarget.value)},className:"code-textarea"}),n(Pa,{value:o.value}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.sqlSnippets.remove(a),sx:{position:"absolute",top:15,right:5},children:n(he.Trash,{size:16})})]},a)),n(c.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"40%"},mx:"auto",children:n(c.Button,{variant:"default",onClick:r,children:"Add a snippet"})})]})})]})});function Fa({}){return n(c.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 225px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",width:"100%",padding:0,margin:0}},padding:"md",children:G(c.Group,{position:"apart",grow:!0,align:"stretch",noWrap:!0,children:[n(Ra,{}),n(jr,{showSQLSnippets:!1})]})})}const La=Ce.observer(function({opened:e,close:r}){const{freezeLayout:o}=V.default.useContext(Ve);return V.default.useEffect(()=>{o(e)},[e]),n(c.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:"Data Settings",trapFocus:!0,onDragStart:a=>{a.stopPropagation()},children:G(c.Tabs,{defaultValue:"Queries",children:[G(c.Tabs.List,{children:[n(c.Tabs.Tab,{value:"SQL Snippet",children:"SQL Snippet"}),n(c.Tabs.Tab,{value:"Queries",children:"Queries"})]}),n(c.Tabs.Panel,{value:"SQL Snippet",pt:"sm",children:n(Fa,{})}),n(c.Tabs.Panel,{value:"Queries",pt:"sm",children:n(Ia,{})})]})})});function Ba({opened:t,close:e,getCurrentSchema:r}){const{freezeLayout:o}=V.default.useContext(Ve);V.default.useEffect(()=>{o(t)},[t]);const a=V.default.useMemo(()=>JSON.stringify(r(),null,2),[t]);return n(c.Modal,{size:"96vw",overflow:"inside",opened:t,onClose:e,title:"This dashboard is described by this schema",trapFocus:!0,onDragStart:l=>{l.stopPropagation()},children:n(it.Prism,{language:"json",sx:{width:"100%"},colorScheme:"dark",children:a})})}var qe=(t=>(t.Select="select",t.MultiSelect="multi-select",t.TextInput="text-input",t.Checkbox="checkbox",t.DateRange="date-range",t))(qe||{});const Ur=se.types.model({type:se.types.enumeration("DataSourceType",["postgresql"]),key:se.types.string,sql:se.types.string}),Wr=se.types.model("FilterConfigModel_TextInput",{required:se.types.boolean,default_value:se.types.string}).actions(t=>({setRequired(e){t.required=e},setDefaultValue(e){t.default_value=e}})),Vr=()=>Wr.create({required:!1,default_value:""}),Ma=Ce.observer(function({config:e}){return n(Me,{children:n(c.Checkbox,{checked:e.default_value,onChange:r=>e.setDefaultValue(r.currentTarget.checked),label:"Default Checked"})})}),ja=[{label:"2022",value:"YYYY"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],qa=Ce.observer(function({config:e}){return G(Me,{children:[G(c.Group,{children:[n(c.Checkbox,{checked:e.required,onChange:r=>e.setRequired(r.currentTarget.checked),label:"Required"}),n(c.Checkbox,{checked:e.clearable,onChange:r=>e.setClearable(r.currentTarget.checked),label:"Clearable"})]}),n(c.Select,{data:ja,label:"Display Format",value:e.inputFormat,onChange:e.setInputFormat})]})}),Na=Ce.observer(function({value:e,onChange:r}){const{data:o=[],loading:a}=ut.useRequest(Nr,{refreshDeps:[]},[]),l=V.default.useMemo(()=>Array.from(new Set(o.map(({type:d})=>d))).map(d=>({label:d,value:d})),[o]),s=V.default.useMemo(()=>{const i=o.filter(({type:d})=>d===e.type);return i?i.map(({key:d})=>({label:d,value:d})):[]},[o,e.type]);return G(c.Group,{grow:!0,children:[n(c.Select,{label:"Data Source Type",data:l,sx:{flex:1},disabled:a,value:e.type,onChange:i=>{r({...e,type:i})}}),n(c.Select,{label:"Data Source Key",data:s,sx:{flex:1},disabled:a,value:e.key,onChange:i=>{r({...e,key:i})}})]})});function Ga({data:t}){return t.length===0?n(c.Box,{sx:{height:"5em"}}):G(c.Table,{children:[n("thead",{children:n("tr",{children:Object.keys(t==null?void 0:t[0]).map(e=>n("th",{children:n(c.Text,{weight:700,color:"#000",children:e})},e))})}),n("tbody",{children:t.slice(0,3).map((e,r)=>n("tr",{children:Object.values(e).map((o,a)=>n("td",{children:n(c.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:n(c.Text,{children:o})})},`${o}--${a}`))},`row-${r}`))}),t.length>3&&n("tfoot",{children:n("tr",{children:n("td",{colSpan:Object.keys(t==null?void 0:t[0]).length,children:G(c.Text,{color:"gray",size:"sm",children:[t.length-3," more row(s) hidden"]})})})})]})}const Ua=Ce.observer(function({query:e}){const{data:r=[],loading:o,refresh:a}=ut.useRequest(er(e),{refreshDeps:[e]});return G(c.Stack,{my:0,children:[G(c.Group,{position:"apart",children:[n(c.Text,{size:"md",pl:"sm",children:"Fetched Data"}),n(c.Button,{size:"xs",onClick:a,disabled:!e.sql||!e.key,children:"Retry"})]}),G(c.Box,{sx:{position:"relative"},children:[n(c.LoadingOverlay,{visible:o,exitTransitionDuration:0}),n(Ga,{data:r})]})]})}),$r=Ce.observer(function({value:e,onChange:r}){return G(c.Stack,{my:0,children:[n(Na,{value:e,onChange:r}),G(c.Tabs,{defaultValue:"SQL",children:[G(c.Tabs.List,{children:[n(c.Tabs.Tab,{value:"SQL",children:"SQL"}),n(c.Tabs.Tab,{value:"Preview",children:"Preview"}),n(c.Tabs.Tab,{value:"Data",children:"Data"})]}),n(c.Tabs.Panel,{value:"SQL",pt:"sm",children:n(c.Textarea,{autosize:!0,minRows:12,maxRows:24,className:"code-textarea",value:e.sql,onChange:o=>{r({...e,sql:o.currentTarget.value})},placeholder:"SELECT name AS label, id AS value"})}),n(c.Tabs.Panel,{value:"Preview",pt:"sm",children:n(Gr,{value:e.sql})}),n(c.Tabs.Panel,{value:"Data",pt:"sm",children:n(Ua,{query:e})})]})]})}),Wa=Ce.observer(function({config:e}){const r=()=>{e.addStaticOption({label:"",value:""})},o=e.static_options,a=[...o];return G(Me,{children:[n(c.Divider,{label:"Configure options",labelPosition:"center"}),o.length>0&&n(c.MultiSelect,{label:"Default Selection",data:a,value:e.default_value,onChange:e.setDefaultValue}),o.map((l,s)=>G(c.Group,{sx:{position:"relative"},pr:"40px",children:[n(c.TextInput,{label:"Label",required:!0,value:e.static_options[s].label,onChange:i=>{e.static_options[s].setLabel(i.currentTarget.value)},sx:{flexGrow:1}}),n(c.TextInput,{label:"Value",required:!0,value:e.static_options[s].value,onChange:i=>{e.static_options[s].setValue(i.currentTarget.value)},sx:{flexGrow:1}}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.removeStaticOption(s),sx:{position:"absolute",top:28,right:5},children:n(he.Trash,{size:16})})]})),n(c.Button,{size:"xs",color:"blue",leftIcon:n(he.PlaylistAdd,{size:20}),onClick:r,sx:{width:"50%"},mx:"auto",children:"Add an Option"}),n(c.Divider,{label:"Or fetch options from database",labelPosition:"center"}),n($r,{value:e.options_query,onChange:e.setOptionsQuery})]})}),Va=Ce.observer(function({config:e}){const r=()=>{e.addStaticOption({label:"",value:""})},o=e.static_options,a=[{label:"No default selection",value:""},...o];return G(Me,{children:[n(c.Checkbox,{checked:e.required,onChange:l=>e.setRequired(l.currentTarget.checked),label:"Required"}),n(c.Divider,{label:"Configure options",labelPosition:"center"}),o.length>0&&n(c.Select,{label:"Default Selection",data:a,value:e.default_value,onChange:e.setDefaultValue}),o.map((l,s)=>G(c.Group,{sx:{position:"relative"},pr:"40px",children:[n(c.TextInput,{label:"Label",required:!0,value:e.static_options[s].label,onChange:i=>{e.static_options[s].setLabel(i.currentTarget.value)},sx:{flexGrow:1}}),n(c.TextInput,{label:"Value",required:!0,value:e.static_options[s].value,onChange:i=>{e.static_options[s].setValue(i.currentTarget.value)},sx:{flexGrow:1}}),n(c.ActionIcon,{color:"red",variant:"subtle",onClick:()=>e.removeStaticOption(s),sx:{position:"absolute",top:28,right:5},children:n(he.Trash,{size:16})})]})),n(c.Button,{size:"xs",color:"blue",leftIcon:n(he.PlaylistAdd,{size:20}),onClick:r,sx:{width:"50%"},mx:"auto",children:"Add an Option"}),n(c.Divider,{label:"Or fetch options from database",labelPosition:"center"}),n($r,{value:e.options_query,onChange:e.setOptionsQuery})]})}),$a=Ce.observer(function({config:e}){return G(Me,{children:[n(c.TextInput,{label:"Default Value",value:e.default_value,onChange:r=>{e.setDefaultValue(r.currentTarget.value)}}),n(c.Checkbox,{checked:e.required,onChange:r=>e.setRequired(r.currentTarget.checked),label:"Required"})]})});function Za({label:t,config:{default_value:e,...r},value:o,onChange:a}){return G(c.Box,{children:[n(c.Text,{children:"\xA0"}),n(c.Checkbox,{label:t,checked:o,onChange:l=>a(l.currentTarget.checked),...r})]})}function Qa({label:t,config:e,value:r,onChange:o}){return n(Sn.DateRangePicker,{label:t,value:r,onChange:o,icon:n(he.Calendar,{size:16}),sx:{minWidth:"14em"},...e})}function Ya({label:t,config:e,value:r,onChange:o}){const a=!!e.options_query.sql,{data:l=[],loading:s}=ut.useRequest(er(e.options_query),{refreshDeps:[e.options_query,a]});return n(c.MultiSelect,{label:t,data:a?l:e.static_options,disabled:a?s:!1,value:r,onChange:o,sx:{minWidth:"14em"}})}function Ka({label:t,config:e,value:r,onChange:o}){const a=!!e.options_query.sql,{data:l=[],loading:s}=ut.useRequest(er(e.options_query),{refreshDeps:[e.options_query,a]});return n(c.Select,{label:t,data:a?l:e.static_options,disabled:a?s:!1,value:r,onChange:o})}function Xa({label:t,config:e,value:r,onChange:o}){return n(c.TextInput,{label:t,value:r,onChange:o,...e})}function Ja({type:t,config:e,key:r,...o},a){switch(t){case"select":return n(Ka,{...o,...a,config:e});case"multi-select":return n(Ya,{...o,...a,config:e});case"text-input":return n(Xa,{...o,...a,config:e});case"date-range":return n(Qa,{...o,...a,config:e});case"checkbox":return n(Za,{...o,...a,config:e});default:return null}}const Zr=V.default.forwardRef(function({filter:e,...r},o){return n("div",{className:"filter-root",ref:o,children:n(Tt,{children:Ja(e,r)})})}),Ha=Ce.observer(function({filter:e}){const r=e.config.default_value,[o,a]=V.default.useState(r);return V.default.useEffect(()=>{a(r)},[r]),G(c.Box,{sx:{maxWidth:"30em"},children:[n(c.Text,{pb:"md",color:"gray",children:"Preview"}),n(Zr,{filter:e,value:o,onChange:a}),n(c.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),n(it.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(e,null,4)})]})}),es={select:Va,"multi-select":Wa,"text-input":$a,checkbox:Ma,"date-range":qa},ts=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],rs=Ce.observer(function({filter:e,index:r}){const o=V.default.useMemo(()=>es[e.type],[e.type]);return G(c.SimpleGrid,{cols:2,children:[G(c.Box,{pl:"md",children:[n(c.Text,{pb:"md",color:"gray",children:"Edit"}),G(c.Stack,{sx:{maxWidth:"30em"},children:[n(c.NumberInput,{label:"Placement Order",required:!0,value:e.order,onChange:e.setOrder,hideControls:!0}),n(c.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:e.key,onChange:a=>{e.setKey(a.currentTarget.value)}}),n(c.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:e.label,onChange:a=>{e.setLabel(a.currentTarget.value)}}),n(c.Select,{label:"Widget",data:ts,required:!0,value:e.type,onChange:e.setType}),n(o,{config:e.config,index:r})]})]}),n(Ha,{filter:e})]})}),ns=Ce.observer(function({}){const e=Fe(),r=e.filters.current,o=()=>{const a=Be.randomId(),l={id:a,key:a,label:a,order:r.length+1,type:qe.TextInput,config:Vr()};e.filters.append(l)};return G(c.Group,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)"},p:0,children:[n(c.Group,{sx:{position:"absolute",top:"16px",right:"16px"},children:n(c.Button,{size:"xs",color:"red",leftIcon:n(he.Recycle,{size:20}),disabled:!e.filters.changed,onClick:e.filters.reset,children:"Revert Changes"})}),n(c.Tabs,{orientation:"vertical",defaultValue:e.filters.firstID,children:G(c.Group,{sx:{height:"100%"},children:[G(c.Stack,{sx:{height:"100%"},children:[n(c.Tabs.List,{position:"left",sx:{flexGrow:1,width:"200px"},children:e.filters.current.map((a,l)=>n(c.Tabs.Tab,{value:a.id,children:a.label},a.id))}),n(c.Button,{size:"xs",color:"blue",leftIcon:n(he.PlaylistAdd,{size:20}),onClick:o,children:"Add a Filter"})]}),n(c.Box,{sx:{flexGrow:1,height:"100%"},children:e.filters.current.map((a,l)=>n(c.Tabs.Panel,{value:a.id,sx:{height:"100%"},children:G(c.Stack,{sx:{height:"100%"},spacing:"sm",children:[n(c.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"scroll"},children:n(rs,{filter:a,index:l})}),n(c.Group,{position:"right",pt:10,children:n(c.Button,{size:"xs",color:"red",leftIcon:n(he.Trash,{size:20}),onClick:()=>e.filters.remove(l),children:"Delete this filter"})})]})},a.id))})]})})]})}),is=Ce.observer(function({opened:e,close:r}){const{freezeLayout:o}=V.default.useContext(Ve);return V.default.useEffect(()=>{o(e)},[e]),n(c.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:"Filters",trapFocus:!0,onDragStart:a=>{a.stopPropagation()},withCloseButton:!1,children:n(ns,{})})}),as=Ce.observer(function({mode:e,setMode:r,hasChanges:o,saveChanges:a,revertChanges:l,getCurrentSchema:s}){const i=Fe(),{addPanel:d}=V.default.useContext(Ct),{inLayoutMode:v,inEditMode:h,inUseMode:p}=V.default.useContext(Ve),[b,m]=V.default.useState(!1),E=()=>m(!0),g=()=>m(!1),[C,_]=V.default.useState(!1),T=()=>_(!0),I=()=>_(!1),[L,R]=V.default.useState(!1),Y=()=>R(!0),$=()=>R(!1);return G(c.Group,{position:"apart",pt:0,pb:"xs",children:[n(c.Group,{position:"left",children:n(Sa,{mode:e,setMode:r})}),G(c.Group,{position:"right",children:[!p&&n(c.Button,{variant:"default",size:"xs",onClick:d,leftIcon:n(he.PlaylistAdd,{size:20}),children:"Add a Panel"}),h&&n(c.Button,{variant:"default",size:"xs",onClick:T,leftIcon:n(he.Filter,{size:20}),children:"Filters"}),h&&n(c.Button,{variant:"default",size:"xs",onClick:E,leftIcon:n(he.Database,{size:20}),children:"Data Settings"}),!p&&n(c.Button,{variant:"default",size:"xs",onClick:a,disabled:!o,leftIcon:n(he.DeviceFloppy,{size:20}),children:"Save Changes"}),!p&&n(c.Button,{color:"red",size:"xs",disabled:!o,onClick:l,leftIcon:n(he.Recycle,{size:20}),children:"Revert Changes"}),G(c.Menu,{width:180,children:[n(c.Menu.Target,{children:n(c.Button,{variant:"default",size:"xs",leftIcon:n(he.Share,{size:20}),children:"Export"})}),G(c.Menu.Dropdown,{children:[n(c.Menu.Item,{icon:n(he.Download,{size:14}),onClick:i.queries.downloadAllData,children:"Download Data"}),n(c.Menu.Item,{icon:n(he.Code,{size:14}),onClick:Y,children:"View Schema"})]})]})]}),n(is,{opened:C,close:I}),n(La,{opened:b,close:g}),n(Ba,{opened:L,close:$,getCurrentSchema:s})]})}),Qr=Ce.observer(function({panel:e,exitFullScreen:r}){return G(c.Stack,{sx:{flexGrow:1,justifyContent:"flex-start"},children:[n(c.Group,{sx:{flexGrow:0},children:n(c.Button,{variant:"default",size:"sm",onClick:r,leftIcon:n(he.ArrowLeft,{size:20}),children:"Exit fullscreen"})}),n(c.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:n(It,{...e})})]})});function Yr(t){const[e,r]=V.default.useState(null),o=V.default.useCallback(i=>{r(i)},[]),a=V.default.useCallback(()=>{r(null)},[]),l=V.default.useMemo(()=>t.find(i=>i.id===e),[e,t]);return{viewPanelInFullScreen:o,exitFullScreen:a,inFullScreen:!!l,fullScreenPanel:l}}const Kr=Ce.observer(function({}){const e=Fe(),{control:r,handleSubmit:o}=be.useForm({defaultValues:e.filters.values});return e.filters.empty?null:n("form",{onSubmit:o(e.filters.setValues),children:G(c.Group,{className:"dashboard-filters",position:"apart",p:"md",mb:"md",noWrap:!0,sx:{boxShadow:"0px 0px 10px 0px rgba(0,0,0,.2)"},children:[n(c.Group,{align:"flex-start",children:e.filters.inOrder.map(a=>n(be.Controller,{name:a.key,control:r,render:({field:l})=>n(Zr,{filter:a,...l})},a.id))}),n(c.Group,{sx:{alignSelf:"flex-end"},children:n(c.Button,{color:"blue",size:"sm",type:"submit",children:"Submit"})})]})})}),ss=se.types.model("ContextModel",{current:se.types.optional(se.types.frozen(),{})}).views(t=>({get keys(){return Object.keys(t.current)},get entries(){return Object.entries(t.current)}})).actions(t=>({replace(e){t.current=e},get(e){return t.current[e]},set(e,r){t.current[e]=r}})),Xr=se.types.model({label:se.types.string,value:se.types.string}).actions(t=>({setLabel(e){t.label=e},setValue(e){t.value=e}})),Jr=se.types.model("FilterConfigModel_Select",{required:se.types.boolean,default_value:se.types.string,static_options:se.types.optional(se.types.array(Xr),[]),options_query:Ur}).actions(t=>({addStaticOption(e){t.static_options.push(e)},removeStaticOption(e){t.static_options.splice(e,1)},setRequired(e){t.required=e},setDefaultValue(e){t.default_value=e},setOptionsQuery(e){t.options_query=e}})),os=()=>Jr.create({required:!1,default_value:"",static_options:[],options_query:{type:"postgresql",key:"",sql:""}}),Hr=se.types.model("FilterConfigModel_MultiSelect",{default_value:se.types.optional(se.types.array(se.types.string),[]),static_options:se.types.optional(se.types.array(Xr),[]),options_query:Ur}).actions(t=>({addStaticOption(e){t.static_options.push(e)},removeStaticOption(e){t.static_options.splice(e,1)},setDefaultValue(e){t.default_value=se.cast(e)},setOptionsQuery(e){t.options_query=e}})),ls=()=>Hr.create({default_value:[],static_options:[],options_query:{type:"postgresql",key:"",sql:""}}),en=se.types.model("FilterConfigModel_Checkbox",{default_value:se.types.boolean}).actions(t=>({setDefaultValue(e){t.default_value=e}})),us=()=>en.create({default_value:!1}),tn=se.types.model("FilterConfigModel_DateRange",{required:se.types.boolean,inputFormat:se.types.enumeration("DateRangeInputFormat",["YYYY","YYYY-MM","YYYY-MM-DD"]),clearable:se.types.boolean}).actions(t=>({setRequired(e){t.required=e},setClearable(e){t.clearable=e},setInputFormat(e){t.inputFormat=e}})),cs=()=>tn.create({required:!1,inputFormat:"YYYY-MM-DD",clearable:!1}),rn=se.types.model("FilterModel",{id:se.types.identifier,key:se.types.string,label:se.types.string,order:se.types.number,type:se.types.enumeration("DashboardFilterType",[qe.Select,qe.MultiSelect,qe.TextInput,qe.Checkbox,qe.DateRange]),config:se.types.union(Jr,Hr,Wr,en,tn)}).actions(t=>({setKey(e){t.key=e},setLabel(e){t.label=e},setOrder(e){t.order=e},setType(e){switch(e){case qe.Select:t.config=os();break;case qe.MultiSelect:t.config=ls();break;case qe.TextInput:t.config=Vr();break;case qe.Checkbox:t.config=us();break;case qe.DateRange:t.config=cs();break}t.type=e}})),ds=se.types.model("FiltersModel",{original:se.types.optional(se.types.array(rn),[]),current:se.types.optional(se.types.array(rn),[]),values:se.types.optional(se.types.frozen(),{})}).views(t=>({get changed(){return!ye.default.isEqual(t.original,t.current)},get firstID(){if(t.current.length!==0)return t.current[0].id},get inOrder(){return ye.default.sortBy(t.current,"order")},get empty(){return t.current.length===0}})).actions(t=>({reset(){t.current=ye.default.cloneDeep(t.original)},replace(e){t.current=se.cast(e)},append(e){t.current.push(e)},remove(e){t.current.splice(e,1)},setValues(e){t.values=e},setValueByKey(e,r){t.values[e]=r},getValueByKey(e){return t.values[e]}}));function fs(t){const e=t.reduce((r,o)=>{var a;return r[o.key]=(a=o.config.default_value)!=null?a:"",r},{});return{original:t,current:t,values:e}}function Pt(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var nn={exports:{}};/*!
26
42
 
27
- Permission to use, copy, modify, and/or distribute this software for any
28
- purpose with or without fee is hereby granted.
43
+ JSZip v3.10.1 - A JavaScript class for generating and reading zip files
44
+ <http://stuartk.com/jszip>
29
45
 
30
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
31
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
32
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
33
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
34
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
35
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
36
- PERFORMANCE OF THIS SOFTWARE.
37
- ***************************************************************************** */var gn=function(e,r){return gn=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,n){t.__proto__=n}||function(t,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])},gn(e,r)};function M(e,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");gn(e,r);function t(){this.constructor=e}e.prototype=r===null?Object.create(r):(t.prototype=r.prototype,new t)}var Ft=function(){return Ft=Object.assign||function(r){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=t[a])}return r},Ft.apply(this,arguments)};function wf(e,r){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&r.indexOf(n)<0&&(t[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)r.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(t[n[i]]=e[n[i]]);return t}function jr(e){var r=typeof Symbol=="function"&&Symbol.iterator,t=r&&e[r],n=0;if(t)return t.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function _n(e,r){var t=typeof Symbol=="function"&&e[Symbol.iterator];if(!t)return e;var n=t.call(e),i,a=[],o;try{for(;(r===void 0||r-- >0)&&!(i=n.next()).done;)a.push(i.value)}catch(u){o={error:u}}finally{try{i&&!i.done&&(t=n.return)&&t.call(n)}finally{if(o)throw o.error}}return a}function ht(){for(var e=[],r=0;r<arguments.length;r++)e=e.concat(_n(arguments[r]));return e}function qa(e){return D(e).type}function Ba(e,r){D(e).applyPatches(Ja(r))}function Ga(e,r){r===void 0&&(r=!0);var t=D(e);return r?t.snapshot:t.type.getSnapshot(t,!1)}function Sf(e){return D(e).root.storedValue}function Of(e){return D(e).path}function xf(e){return D(e).identifier}function Kp(e){return e}var $a=function(){function e(r,t,n,i){Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"environment",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(this,"_escapedSubpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_subpathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_pathUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"storedValue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"aliveAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_state",{enumerable:!0,configurable:!0,writable:!0,value:q.INITIALIZING}),Object.defineProperty(this,"_hookSubscribers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"_parent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pathAtom",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.environment=i,this.baseSetParent(t,n)}return Object.defineProperty(e.prototype,"subpath",{get:function(){return this._subpath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subpathUponDeath",{get:function(){return this._subpathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pathUponDeath",{get:function(){return this._pathUponDeath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this.type.getValue(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"state",{get:function(){return this._state},set:function(r){var t=this.isAlive;this._state=r;var n=this.isAlive;this.aliveAtom&&t!==n&&this.aliveAtom.reportChanged()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fireInternalHook",{enumerable:!1,configurable:!0,writable:!0,value:function(r){this._hookSubscribers&&this._hookSubscribers.emit(r,this,r)}}),Object.defineProperty(e.prototype,"registerHook",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){return this._hookSubscribers||(this._hookSubscribers=new Za),this._hookSubscribers.register(r,t)}}),Object.defineProperty(e.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getReconciliationType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type}}),Object.defineProperty(e.prototype,"baseSetParent",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){this._parent=r,this._subpath=t,this._escapedSubpath=void 0,this.pathAtom&&this.pathAtom.reportChanged()}}),Object.defineProperty(e.prototype,"path",{get:function(){return this.getEscapedPath(!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getEscapedPath",{enumerable:!1,configurable:!0,writable:!0,value:function(r){return r&&(this.pathAtom||(this.pathAtom=cr("path")),this.pathAtom.reportObserved()),this.parent?(this._escapedSubpath===void 0&&(this._escapedSubpath=this._subpath?et(this._subpath):""),this.parent.getEscapedPath(r)+"/"+this._escapedSubpath):""}}),Object.defineProperty(e.prototype,"isRoot",{get:function(){return this.parent===null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAlive",{get:function(){return this.state!==q.DEAD},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDetaching",{get:function(){return this.state===q.DETACHING},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"observableIsAlive",{get:function(){return this.aliveAtom||(this.aliveAtom=cr("alive")),this.aliveAtom.reportObserved(),this.isAlive},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseFinalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(r){if(this.state===q.CREATED){if(this.parent){if(this.parent.state!==q.FINALIZED)return;this.fireHook(F.afterAttach)}this.state=q.FINALIZED,r&&r()}}}),Object.defineProperty(e.prototype,"baseFinalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._hookSubscribers&&this._hookSubscribers.clearAll(),this._subpathUponDeath=this._subpath,this._pathUponDeath=this.getEscapedPath(!1),this.baseSetParent(null,""),this.state=q.DEAD}}),Object.defineProperty(e.prototype,"baseAboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.fireHook(F.beforeDestroy)}}),e}(),qt=function(e){M(r,e);function r(t,n,i,a,o){var u=e.call(this,t,n,i,a)||this;try{u.storedValue=t.createNewInstance(o)}catch(c){throw u.state=q.DEAD,c}return u.state=q.CREATED,u.finalizeCreation(),u}return Object.defineProperty(r.prototype,"root",{get:function(){if(!this.parent)throw g("This scalar node is not part of a tree");return this.parent.root},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this.parent!==t,a=this.subpath!==n;!i&&!a||(this.environment=void 0,this.baseSetParent(this.parent,n))}}),Object.defineProperty(r.prototype,"snapshot",{get:function(){return this.getSnapshot()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(r.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>";return this.type.name+"@"+t+(this.isAlive?"":" [dead]")}}),Object.defineProperty(r.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){!this.isAlive||this.state===q.DETACHING||(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(r.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeCreation()}}),Object.defineProperty(r.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseAboutToDie()}}),Object.defineProperty(r.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.baseFinalizeDeath()}}),Object.defineProperty(r.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.fireInternalHook(t)}}),r}($a);qt.prototype.die=L(qt.prototype.die);var Pf=1,Cf={onError:function(e){throw e}},H=function(e){M(r,e);function r(t,n,i,a,o){var u=e.call(this,t,n,i,a)||this;if(Object.defineProperty(u,"nodeId",{enumerable:!0,configurable:!0,writable:!0,value:++Pf}),Object.defineProperty(u,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"unnormalizedIdentifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"identifierCache",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"isProtectionEnabled",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applyPatches",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_applySnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_autoUnbox",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(u,"_isRunningAction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_hasSnapshotReaction",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_observableInstanceState",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(u,"_childNodes",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_initialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_cachedInitialSnapshotCreated",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(u,"_snapshotComputed",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_snapshotUponDeath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(u,"_internalEvents",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),u._snapshotComputed=st(function(){return u.getSnapshot()}),u.unbox=u.unbox.bind(u),u._initialSnapshot=o,u.identifierAttribute=t.identifierAttribute,n||(u.identifierCache=new qf),u._childNodes=t.initializeChildNodes(u,u._initialSnapshot),u.identifier=null,u.unnormalizedIdentifier=null,u.identifierAttribute&&u._initialSnapshot){var c=u._initialSnapshot[u.identifierAttribute];if(c===void 0){var d=u._childNodes[u.identifierAttribute];d&&(c=d.value)}if(typeof c!="string"&&typeof c!="number")throw g("Instance identifier '"+u.identifierAttribute+"' for type '"+u.type.name+"' must be a string or a number");u.identifier=Wt(c),u.unnormalizedIdentifier=c}return n?n.root.identifierCache.addNodeToCache(u):u.identifierCache.addNodeToCache(u),u}return Object.defineProperty(r.prototype,"applyPatches",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.createObservableInstanceIfNeeded(),this._applyPatches(t)}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.createObservableInstanceIfNeeded(),this._applySnapshot(t)}}),Object.defineProperty(r.prototype,"createObservableInstanceIfNeeded",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._observableInstanceState===0&&this.createObservableInstance()}}),Object.defineProperty(r.prototype,"createObservableInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t,n;this._observableInstanceState=1;for(var i=[],a=this.parent;a&&a._observableInstanceState===0;)i.unshift(a),a=a.parent;try{for(var o=jr(i),u=o.next();!u.done;u=o.next()){var c=u.value;c.createObservableInstanceIfNeeded()}}catch(f){t={error:f}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}var d=this.type;try{this.storedValue=d.createNewInstance(this._childNodes),this.preboot(),this._isRunningAction=!0,d.finalizeNewInstance(this,this.storedValue)}catch(f){throw this.state=q.DEAD,f}finally{this._isRunningAction=!1}this._observableInstanceState=2,this._snapshotComputed.trackAndCompute(),this.isRoot&&this._addSnapshotReaction(),this._childNodes=yt,this.state=q.CREATED,this.fireHook(F.afterCreate),this.finalizeCreation()}}),Object.defineProperty(r.prototype,"root",{get:function(){var t=this.parent;return t?t.root:this},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"clearParent",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!!this.parent){this.fireHook(F.beforeDetach);var t=this.state;this.state=q.DETACHING;var n=this.root,i=n.environment,a=n.identifierCache.splitCache(this);try{this.parent.removeChild(this.subpath),this.baseSetParent(null,""),this.environment=i,this.identifierCache=a}finally{this.state=t}}}}),Object.defineProperty(r.prototype,"setParent",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=t!==this.parent,a=n!==this.subpath;!i&&!a||(i?(this.environment=void 0,t.root.identifierCache.mergeCache(this),this.baseSetParent(t,n),this.fireHook(F.afterAttach)):a&&this.baseSetParent(this.parent,n))}}),Object.defineProperty(r.prototype,"fireHook",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;this.fireInternalHook(t);var i=this.storedValue&&typeof this.storedValue=="object"&&this.storedValue[t];typeof i=="function"&&(na?na(function(){i.apply(n.storedValue)}):i.apply(this.storedValue))}}),Object.defineProperty(r.prototype,"snapshot",{get:function(){return this._snapshotComputed.get()},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.isAlive?this._observableInstanceState===2?this._getActualSnapshot():this._getCachedInitialSnapshot():this._snapshotUponDeath}}),Object.defineProperty(r.prototype,"_getActualSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.type.getSnapshot(this)}}),Object.defineProperty(r.prototype,"_getCachedInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this._cachedInitialSnapshotCreated){var t=this.type,n=this._childNodes,i=this._initialSnapshot;this._cachedInitialSnapshot=t.processInitialSnapshot(n,i),this._cachedInitialSnapshotCreated=!0}return this._cachedInitialSnapshot}}),Object.defineProperty(r.prototype,"isRunningAction",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._isRunningAction?!0:this.isRoot?!1:this.parent.isRunningAction()}}),Object.defineProperty(r.prototype,"assertAlive",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=_f();if(!this.isAlive&&n!=="ignore"){var i=this._getAssertAliveError(t);switch(n){case"error":throw g(i);case"warn":Zf(i)}}}}),Object.defineProperty(r.prototype,"_getAssertAliveError",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.getEscapedPath(!1)||this.pathUponDeath||"",i=t.subpath&&et(t.subpath)||"",a=t.actionContext||Tf();a&&a.type!=="action"&&a.parentActionEvent&&(a=a.parentActionEvent);var o="";if(a&&a.name!=null){var u=a&&a.context&&Of(a.context)||n;o=u+"."+a.name+"()"}return"You are trying to read or write to an object that is no longer part of a state tree. (Object type: '"+this.type.name+"', Path upon death: '"+n+"', Subpath: '"+i+"', Action: '"+o+"'). Either detach nodes first, or don't use objects after removing / replacing them in the tree."}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.assertAlive({subpath:t}),this._autoUnbox=!1;try{return this._observableInstanceState===2?this.type.getChildNode(this,t):this._childNodes[t]}finally{this._autoUnbox=!0}}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.assertAlive(yt),this._autoUnbox=!1;try{return this._observableInstanceState===2?this.type.getChildren(this):Ka(this._childNodes)}finally{this._autoUnbox=!0}}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.type.getChildType(t)}}),Object.defineProperty(r.prototype,"isProtected",{get:function(){return this.root.isProtectionEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"assertWritable",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(this.assertAlive(t),!this.isRunningAction()&&this.isProtected)throw g("Cannot modify '"+this+"', the object is protected and can only be modified by using an action.")}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this.type.removeChild(this,t)}}),Object.defineProperty(r.prototype,"unbox",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t&&(this.assertAlive({subpath:t.subpath||t.subpathUponDeath}),this._autoUnbox?t.value:t)}}),Object.defineProperty(r.prototype,"toString",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=(this.isAlive?this.path:this.pathUponDeath)||"<root>",n=this.identifier?"(id: "+this.identifier+")":"";return this.type.name+"@"+t+n+(this.isAlive?"":" [dead]")}}),Object.defineProperty(r.prototype,"finalizeCreation",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;this.baseFinalizeCreation(function(){var n,i;try{for(var a=jr(t.getChildren()),o=a.next();!o.done;o=a.next()){var u=o.value;u.finalizeCreation()}}catch(c){n={error:c}}finally{try{o&&!o.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}t.fireInternalHook(F.afterCreationFinalization)})}}),Object.defineProperty(r.prototype,"detach",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(!this.isAlive)throw g("Error while detaching, node is not alive.");this.clearParent()}}),Object.defineProperty(r.prototype,"preboot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;this._applyPatches=Gt(this.storedValue,"@APPLY_PATCHES",function(n){n.forEach(function(i){if(!i.path){t.type.applySnapshot(t,i.value);return}var a=od(i.path),o=$f(t,a.slice(0,-1));o.applyPatchLocally(a[a.length-1],i)})}),this._applySnapshot=Gt(this.storedValue,"@APPLY_SNAPSHOT",function(n){if(n!==t.snapshot)return t.type.applySnapshot(t,n)}),Ze(this.storedValue,"$treenode",this),Ze(this.storedValue,"toJSON",Gf)}}),Object.defineProperty(r.prototype,"die",{enumerable:!1,configurable:!0,writable:!0,value:function(){!this.isAlive||this.state===q.DETACHING||(this.aboutToDie(),this.finalizeDeath())}}),Object.defineProperty(r.prototype,"aboutToDie",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._observableInstanceState!==0&&(this.getChildren().forEach(function(t){t.aboutToDie()}),this.baseAboutToDie(),this._internalEventsEmit("dispose"),this._internalEventsClear("dispose"))}}),Object.defineProperty(r.prototype,"finalizeDeath",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.getChildren().forEach(function(n){n.finalizeDeath()}),this.root.identifierCache.notifyDied(this);var t=this.snapshot;this._snapshotUponDeath=t,this._internalEventsClearAll(),this.baseFinalizeDeath()}}),Object.defineProperty(r.prototype,"onSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._addSnapshotReaction(),this._internalEventsRegister("snapshot",t)}}),Object.defineProperty(r.prototype,"emitSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this._internalEventsEmit("snapshot",t)}}),Object.defineProperty(r.prototype,"onPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._internalEventsRegister("patch",t)}}),Object.defineProperty(r.prototype,"emitPatch",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(this._internalEventsHasSubscribers("patch")){var i=Qf({},t,{path:n.path.substr(this.path.length)+"/"+t.path}),a=_n(td(i),2),o=a[0],u=a[1];this._internalEventsEmit("patch",o,u)}this.parent&&this.parent.emitPatch(t,n)}}),Object.defineProperty(r.prototype,"hasDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._internalEventsHas("dispose",t)}}),Object.defineProperty(r.prototype,"addDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(!this.hasDisposer(t)){this._internalEventsRegister("dispose",t,!0);return}throw g("cannot add a disposer when it is already registered for execution")}}),Object.defineProperty(r.prototype,"removeDisposer",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(!this._internalEventsHas("dispose",t))throw g("cannot remove a disposer which was never registered for execution");this._internalEventsUnregister("dispose",t)}}),Object.defineProperty(r.prototype,"removeMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(this.middlewares){var n=this.middlewares.indexOf(t);n>=0&&this.middlewares.splice(n,1)}}}),Object.defineProperty(r.prototype,"addMiddleWare",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this;n===void 0&&(n=!0);var a={handler:t,includeHooks:n};return this.middlewares?this.middlewares.push(a):this.middlewares=[a],function(){i.removeMiddleware(a)}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){this.assertWritable({subpath:t}),this.createObservableInstanceIfNeeded(),this.type.applyPatchLocally(this,t,n)}}),Object.defineProperty(r.prototype,"_addSnapshotReaction",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;if(!this._hasSnapshotReaction){var n=wc(function(){return t.snapshot},function(i){return t.emitSnapshot(i)},Cf);this.addDisposer(n),this._hasSnapshotReaction=!0}}}),Object.defineProperty(r.prototype,"_internalEventsHasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return!!this._internalEvents&&this._internalEvents.hasSubscribers(t)}}),Object.defineProperty(r.prototype,"_internalEventsRegister",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i){return i===void 0&&(i=!1),this._internalEvents||(this._internalEvents=new Za),this._internalEvents.register(t,n,i)}}),Object.defineProperty(r.prototype,"_internalEventsHas",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return!!this._internalEvents&&this._internalEvents.has(t,n)}}),Object.defineProperty(r.prototype,"_internalEventsUnregister",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){this._internalEvents&&this._internalEvents.unregister(t,n)}}),Object.defineProperty(r.prototype,"_internalEventsEmit",{enumerable:!1,configurable:!0,writable:!0,value:function(t){for(var n,i=[],a=1;a<arguments.length;a++)i[a-1]=arguments[a];this._internalEvents&&(n=this._internalEvents).emit.apply(n,ht([t],i))}}),Object.defineProperty(r.prototype,"_internalEventsClear",{enumerable:!1,configurable:!0,writable:!0,value:function(t){this._internalEvents&&this._internalEvents.clear(t)}}),Object.defineProperty(r.prototype,"_internalEventsClearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this._internalEvents&&this._internalEvents.clearAll()}}),r}($a);H.prototype.createObservableInstance=L(H.prototype.createObservableInstance),H.prototype.detach=L(H.prototype.detach),H.prototype.die=L(H.prototype.die);var Ua,E;(function(e){e[e.String=1]="String",e[e.Number=2]="Number",e[e.Boolean=4]="Boolean",e[e.Date=8]="Date",e[e.Literal=16]="Literal",e[e.Array=32]="Array",e[e.Map=64]="Map",e[e.Object=128]="Object",e[e.Frozen=256]="Frozen",e[e.Optional=512]="Optional",e[e.Reference=1024]="Reference",e[e.Identifier=2048]="Identifier",e[e.Late=4096]="Late",e[e.Refinement=8192]="Refinement",e[e.Union=16384]="Union",e[e.Null=32768]="Null",e[e.Undefined=65536]="Undefined",e[e.Integer=131072]="Integer",e[e.Custom=262144]="Custom",e[e.SnapshotProcessor=524288]="SnapshotProcessor"})(E||(E={}));var Wa="cannotDetermine",Af=Symbol("$type"),Te=function(){function e(r){Object.defineProperty(this,Ua,{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"C",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"S",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"T",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"N",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"isType",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r}return Object.defineProperty(e.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){return Ee(this,r),this.instantiate(null,"",t,r).value}}),Object.defineProperty(e.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){throw g("unimplemented method")}}),Object.defineProperty(e.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(r){return r===this}}),Object.defineProperty(e.prototype,"validate",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){var n=Qa(r);if(n){var i=qa(r);return this.isAssignableFrom(i)?J():X(t,r)}return this.isValidSnapshot(r,t)}}),Object.defineProperty(e.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(r){return this.validate(r,[{path:"",type:this}]).length===0}}),Object.defineProperty(e.prototype,"Type",{get:function(){throw g("Factory.Type should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.Type`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"TypeWithoutSTN",{get:function(){throw g("Factory.TypeWithoutSTN should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.TypeWithoutSTN`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"SnapshotType",{get:function(){throw g("Factory.SnapshotType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.SnapshotType`")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"CreationType",{get:function(){throw g("Factory.CreationType should not be actually called. It is just a Type signature that can be used at compile time with Typescript, by using `typeof type.CreationType`")},enumerable:!1,configurable:!0}),e}();Ua=Af,Te.prototype.create=L(Te.prototype.create);var bt=function(e){M(r,e);function r(t){var n=e.call(this,t)||this;return Object.defineProperty(n,"identifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),n}return Object.defineProperty(r.prototype,"create",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return t===void 0&&(t=this.getDefaultSnapshot()),e.prototype.create.call(this,t,n)}}),Object.defineProperty(r.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.createObservableInstanceIfNeeded(),t.storedValue}}),Object.defineProperty(r.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return!t.identifierAttribute||t.identifier===Wt(n[t.identifierAttribute])}}),Object.defineProperty(r.prototype,"tryToReconcileNode",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return t.isDetaching?!1:t.snapshot===n||V(n)&&D(n)===t?!0:t.type===this&&Xa(n)&&!V(n)&&this.isMatchingSnapshotId(t,n)?(t.applySnapshot(n),!0):!1}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=this.tryToReconcileNode(t,n);if(o)return t.setParent(i,a),t;if(t.die(),V(n)&&this.isAssignableFrom(qa(n))){var u=D(n);return u.setParent(i,a),u}return this.instantiate(i,a,void 0,n)}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),r}(Te);bt.prototype.create=L(bt.prototype.create);var vt=function(e){M(r,e);function r(){return e!==null&&e.apply(this,arguments)||this}return Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t}}),Object.defineProperty(r.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.storedValue}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.storedValue}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){if(!t.isDetaching&&t.type===this&&t.storedValue===n)return t;var o=this.instantiate(i,a,void 0,n);return t.die(),o}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return null}}),r}(Te);function Le(e){return typeof e=="object"&&e&&e.isType===!0}var jf=1,Bt;function Tf(){return Bt}function Ef(){return jf++}function If(e,r){var t=D(e.context);e.type==="action"&&t.assertAlive({actionContext:e});var n=t._isRunningAction;t._isRunningAction=!0;var i=Bt;Bt=e;try{return Rf(t,e,r)}finally{Bt=i,t._isRunningAction=n}}function Df(e){if(!!e)return e.type==="action"?e:e.parentActionEvent}function Gt(e,r,t){var n=function(){var i=Ef(),a=Bt,o=Df(a);return If({type:"action",name:r,id:i,args:Xf(arguments),context:e,tree:Sf(e),rootId:a?a.rootId:i,parentId:a?a.id:0,allParentIds:a?ht(a.allParentIds,[a.id]):[],parentEvent:a,parentActionEvent:o},t)};return n._isMSTAction=!0,n}var Mf=function(){function e(r,t){Object.defineProperty(this,"arrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"inArrayIndex",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"middlewares",{enumerable:!0,configurable:!0,writable:!0,value:[]}),t.$mst_middleware&&this.middlewares.push(t.$mst_middleware);for(var n=r;n;)n.middlewares&&this.middlewares.push(n.middlewares),n=n.parent}return Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.middlewares.length<=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"getNextMiddleware",{enumerable:!1,configurable:!0,writable:!0,value:function(){var r=this.middlewares[this.arrayIndex];if(!!r){var t=r[this.inArrayIndex++];return t||(this.arrayIndex++,this.inArrayIndex=0,this.getNextMiddleware())}}}),e}();function Rf(e,r,t){var n=new Mf(e,t);if(n.isEmpty)return L(t).apply(null,r.args);var i=null;function a(o){var u=n.getNextMiddleware(),c=u&&u.handler;if(!c)return L(t).apply(null,o.args);if(!u.includeHooks&&F[o.name])return a(o);function d(p,v){i=a(p),v&&(i=v(i))}function f(p){i=p}return c(o,d,f),i}return a(r)}function Vf(e){try{return JSON.stringify(e)}catch(r){return"<Unserializable: "+r+">"}}function Ya(e){return typeof e=="function"?"<function"+(e.name?" "+e.name:"")+">":V(e)?"<"+e+">":"`"+Vf(e)+"`"}function kf(e){return e.length<280?e:e.substring(0,272)+"......"+e.substring(e.length-8)}function zf(e){var r=e.value,t=e.context[e.context.length-1].type,n=e.context.map(function(u){var c=u.path;return c}).filter(function(u){return u.length>0}).join("/"),i=n.length>0?'at path "/'+n+'" ':"",a=V(r)?"value of type "+D(r).type.name+":":$t(r)?"value":"snapshot",o=t&&V(r)&&t.is(D(r).snapshot);return""+i+a+" "+Ya(r)+" is not assignable "+(t?"to type: `"+t.name+"`":"")+(e.message?" ("+e.message+")":"")+(t?_d(t)||$t(r)?".":", expected an instance of `"+t.name+"` or a snapshot like `"+t.describe()+"` instead."+(o?" (Note that a snapshot of the provided value is compatible with the targeted type)":""):".")}function wn(e,r,t){return e.concat([{path:r,type:t}])}function J(){return mt}function X(e,r,t){return[{context:e,value:r,message:t}]}function Tr(e){return e.reduce(function(r,t){return r.concat(t)},[])}function Ee(e,r){ed()&&Nf(e,r)}function Nf(e,r){var t=e.validate(r,[{path:"",type:e}]);if(t.length>0)throw g(Lf(e,r,t))}function Lf(e,r,t){if(t.length!==0)return"Error while converting "+kf(Ya(r))+" to `"+e.name+`\`:
46
+ (c) 2009-2016 Stuart Knightley <stuart [at] stuartk.com>
47
+ Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/main/LICENSE.markdown.
38
48
 
39
- `+t.map(zf).join(`
40
- `)}var Ff=0,qf=function(){function e(){Object.defineProperty(this,"cacheId",{enumerable:!0,configurable:!0,writable:!0,value:Ff++}),Object.defineProperty(this,"cache",{enumerable:!0,configurable:!0,writable:!0,value:R.map()}),Object.defineProperty(this,"lastCacheModificationPerId",{enumerable:!0,configurable:!0,writable:!0,value:R.map()})}return Object.defineProperty(e.prototype,"updateLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=this.lastCacheModificationPerId.get(r);this.lastCacheModificationPerId.set(r,t===void 0?1:t+1)}}),Object.defineProperty(e.prototype,"getLastCacheModificationPerId",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=this.lastCacheModificationPerId.get(r)||0;return this.cacheId+"-"+t}}),Object.defineProperty(e.prototype,"addNodeToCache",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){if(t===void 0&&(t=!0),r.identifierAttribute){var n=r.identifier;this.cache.has(n)||this.cache.set(n,R.array([],Er));var i=this.cache.get(n);if(i.indexOf(r)!==-1)throw g("Already registered");i.push(r),t&&this.updateLastCacheModificationPerId(n)}}}),Object.defineProperty(e.prototype,"mergeCache",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=this;pa(r.identifierCache.cache).forEach(function(n){return n.forEach(function(i){t.addNodeToCache(i)})})}}),Object.defineProperty(e.prototype,"notifyDied",{enumerable:!1,configurable:!0,writable:!0,value:function(r){if(r.identifierAttribute){var t=r.identifier,n=this.cache.get(t);n&&(n.remove(r),n.length||this.cache.delete(t),this.updateLastCacheModificationPerId(r.identifier))}}}),Object.defineProperty(e.prototype,"splitCache",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=this,n=new e,i=r.path;return zc(this.cache).forEach(function(a){for(var o=_n(a,2),u=o[0],c=o[1],d=!1,f=c.length-1;f>=0;f--)c[f].path.indexOf(i)===0&&(n.addNodeToCache(c[f],!1),c.splice(f,1),d=!0);d&&t.updateLastCacheModificationPerId(u)}),n}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){var n=this.cache.get(t);return n?n.some(function(i){return r.isAssignableFrom(i.type)}):!1}}),Object.defineProperty(e.prototype,"resolve",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){var n=this.cache.get(t);if(!n)return null;var i=n.filter(function(a){return r.isAssignableFrom(a.type)});switch(i.length){case 0:return null;case 1:return i[0];default:throw g("Cannot resolve a reference to type '"+r.name+"' with id: '"+t+"' unambigously, there are multiple candidates: "+i.map(function(a){return a.path}).join(", "))}}}),e}();function Sn(e,r,t,n,i){var a=Qa(i);if(a){if(a.parent)throw g("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+(r?r.path:"")+"/"+t+"', but it lives already at '"+a.path+"'");return r&&a.setParent(r,t),a}return new H(e,r,t,n,i)}function Xe(e,r,t,n,i){return new qt(e,r,t,n,i)}function Bf(e){return e instanceof qt||e instanceof H}var q;(function(e){e[e.INITIALIZING=0]="INITIALIZING",e[e.CREATED=1]="CREATED",e[e.FINALIZED=2]="FINALIZED",e[e.DETACHING=3]="DETACHING",e[e.DEAD=4]="DEAD"})(q||(q={}));function V(e){return!!(e&&e.$treenode)}function D(e){if(!V(e))throw g("Value "+e+" is no MST Node");return e.$treenode}function Qa(e){return e&&e.$treenode||null}function Gf(){return D(this).snapshot}function $f(e,r,t){t===void 0&&(t=!0);for(var n=e,i=0;i<r.length;i++){var a=r[i];if(a===".."){if(n=n.parent,n)continue}else{if(a===".")continue;if(n){if(n instanceof qt)try{var o=n.value;V(o)&&(n=D(o))}catch(c){if(!t)return;throw c}if(n instanceof H){var u=n.getChildType(a);if(u&&(n=n.getChildNode(a),n))continue}}}if(t)throw g("Could not resolve '"+a+"' in path '"+(eo(r.slice(0,i))||"/")+"' while resolving '"+eo(r)+"'");return}return n}function Ka(e){if(!e)return mt;var r=Object.keys(e);if(!r.length)return mt;var t=new Array(r.length);return r.forEach(function(n,i){t[i]=e[n]}),t}var Uf=Object.toString(),mt=Object.freeze([]),yt=Object.freeze({}),Er=uc().useProxies?{deep:!1}:{deep:!1,proxy:!1};Object.freeze(Er);function g(e){return e===void 0&&(e="Illegal state"),new Error("[mobx-state-tree] "+e)}function Wf(e){return e}var Yf=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e};function Ha(e){return Array.isArray(e)||ge(e)}function Ja(e){return e?Ha(e)?e:[e]:mt}function Qf(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];for(var n=0;n<r.length;n++){var i=r[n];for(var a in i)e[a]=i[a]}return e}function gt(e){var r;if(e===null||typeof e!="object")return!1;var t=Object.getPrototypeOf(e);return t==null?!0:((r=t.constructor)===null||r===void 0?void 0:r.toString())===Uf}function Xa(e){return e!==null&&typeof e=="object"&&!(e instanceof Date)&&!(e instanceof RegExp)}function $t(e,r){return r===void 0&&(r=!0),e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"||r&&e instanceof Date}function Hp(e){return e}function Jp(e){return e}function Kf(e){return typeof e!="function"}function Hf(e,r,t){ie(e)?ba(e,r,t):Object.defineProperty(e,r,t)}function Ze(e,r,t){Hf(e,r,{enumerable:!1,writable:!1,configurable:!0,value:t})}var Jf=function(){function e(){Object.defineProperty(this,"handlers",{enumerable:!0,configurable:!0,writable:!0,value:[]})}return Object.defineProperty(e.prototype,"hasSubscribers",{get:function(){return this.handlers.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){var n=this;return t===void 0&&(t=!1),t?this.handlers.unshift(r):this.handlers.push(r),function(){n.unregister(r)}}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(r){return this.handlers.indexOf(r)>=0}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=this.handlers.indexOf(r);t>=0&&this.handlers.splice(t,1)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.handlers.length=0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(){for(var r=[],t=0;t<arguments.length;t++)r[t]=arguments[t];var n=this.handlers.slice();n.forEach(function(i){return i.apply(void 0,ht(r))})}}),e}(),Za=function(){function e(){Object.defineProperty(this,"eventHandlers",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}return Object.defineProperty(e.prototype,"hasSubscribers",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=this.eventHandlers&&this.eventHandlers[r];return!!t&&t.hasSubscribers}}),Object.defineProperty(e.prototype,"register",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t,n){n===void 0&&(n=!1),this.eventHandlers||(this.eventHandlers={});var i=this.eventHandlers[r];return i||(i=this.eventHandlers[r]=new Jf),i.register(t,n)}}),Object.defineProperty(e.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){var n=this.eventHandlers&&this.eventHandlers[r];return!!n&&n.has(t)}}),Object.defineProperty(e.prototype,"unregister",{enumerable:!1,configurable:!0,writable:!0,value:function(r,t){var n=this.eventHandlers&&this.eventHandlers[r];n&&n.unregister(t)}}),Object.defineProperty(e.prototype,"clear",{enumerable:!1,configurable:!0,writable:!0,value:function(r){this.eventHandlers&&delete this.eventHandlers[r]}}),Object.defineProperty(e.prototype,"clearAll",{enumerable:!1,configurable:!0,writable:!0,value:function(){this.eventHandlers=void 0}}),Object.defineProperty(e.prototype,"emit",{enumerable:!1,configurable:!0,writable:!0,value:function(r){for(var t,n=[],i=1;i<arguments.length;i++)n[i-1]=arguments[i];var a=this.eventHandlers&&this.eventHandlers[r];a&&(t=a).emit.apply(t,ht(n))}}),e}();function Xf(e){for(var r=new Array(e.length),t=0;t<e.length;t++)r[t]=e[t];return r}function On(e,r){return e.indexOf(r)===0}function Zf(e){console.warn(new Error("[mobx-state-tree] "+e))}function ed(){return typeof process!="undefined"&&process.env&&{}.ENABLE_TYPE_CHECK==="true"}function td(e){if(!("oldValue"in e))throw g("Patches without `oldValue` field cannot be inversed");return[rd(e),nd(e)]}function rd(e){switch(e.op){case"add":return{op:"add",path:e.path,value:e.value};case"remove":return{op:"remove",path:e.path};case"replace":return{op:"replace",path:e.path,value:e.value}}}function nd(e){switch(e.op){case"add":return{op:"remove",path:e.path};case"remove":return{op:"add",path:e.path,value:e.oldValue};case"replace":return{op:"replace",path:e.path,value:e.oldValue}}}function id(e){return typeof e=="number"}function et(e){return id(e)===!0?""+e:e.indexOf("/")===-1&&e.indexOf("~")===-1?e:e.replace(/~/g,"~0").replace(/\//g,"~1")}function ad(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function eo(e){if(e.length===0)return"";var r=function(t){return t.map(et).join("/")};return e[0]==="."||e[0]===".."?r(e):"/"+r(e)}function od(e){var r=e.split("/").map(ad),t=e===""||e==="."||e===".."||On(e,"/")||On(e,"./")||On(e,"../");if(!t)throw g("a json path must be either rooted, empty or relative, but got '"+e+"'");return r[0]===""&&r.shift(),r}var xn=Symbol("$preProcessorFailed"),ud=function(e){M(r,e);function r(t,n,i){var a=e.call(this,i||t.name)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"_processors",{enumerable:!0,configurable:!0,writable:!0,value:n}),a}return Object.defineProperty(r.prototype,"flags",{get:function(){return this._subtype.flags|E.SnapshotProcessor},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"snapshotProcessor("+this._subtype.describe()+")"}}),Object.defineProperty(r.prototype,"preProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._processors.preProcessor?this._processors.preProcessor.call(null,t):t}}),Object.defineProperty(r.prototype,"preProcessSnapshotSafe",{enumerable:!1,configurable:!0,writable:!0,value:function(t){try{return this.preProcessSnapshot(t)}catch{return xn}}}),Object.defineProperty(r.prototype,"postProcessSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._processors.postProcessor?this._processors.postProcessor.call(null,t):t}}),Object.defineProperty(r.prototype,"_fixNode",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;ld(t.type,this,"create");var i=t.getSnapshot;t.getSnapshot=function(){return n.postProcessSnapshot(i.call(t))},Cd(this._subtype)||(t.getReconciliationType=function(){return n})}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=V(a)?a:this.preProcessSnapshot(a),u=this._subtype.instantiate(t,n,i,o);return this._fixNode(u),u}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=this._subtype.reconcile(t,V(n)?n:this.preProcessSnapshot(n),i,a);return o!==t&&this._fixNode(o),o}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){n===void 0&&(n=!0);var i=this._subtype.getSnapshot(t);return n?this.postProcessSnapshot(i):i}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this.preProcessSnapshotSafe(t);return i===xn?X(n,t,"Failed to preprocess value"):this._subtype.validate(i,n)}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),Object.defineProperty(r.prototype,"is",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=Le(t)?this._subtype:V(t)?Ga(t,!1):this.preProcessSnapshotSafe(t);return n===xn?!1:this._subtype.validate(n,[{path:"",type:this._subtype}]).length===0}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._subtype.isAssignableFrom(t)}}),Object.defineProperty(r.prototype,"isMatchingSnapshotId",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(!(this._subtype instanceof bt))return!1;var i=this.preProcessSnapshot(n);return this._subtype.isMatchingSnapshotId(t,i)}}),r}(Te);function ld(e,r){for(var t,n,i=[],a=2;a<arguments.length;a++)i[a-2]=arguments[a];try{for(var o=jr(i),u=o.next();!u.done;u=o.next()){var c=u.value;e[c]=r[c].bind(r)}}catch(d){t={error:d}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}}function sd(e,r,t){return new ud(e,r,t)}var to="Map.put can only be used to store complex values that have an identifier type attribute";function ro(e,r){var t,n,i=e.getSubTypes();if(i===Wa)return!1;if(i){var a=Ja(i);try{for(var o=jr(a),u=o.next();!u.done;u=o.next()){var c=u.value;if(!ro(c,r))return!1}}catch(d){t={error:d}}finally{try{u&&!u.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}}return e instanceof Ut&&r.push(e),!0}var Fe;(function(e){e[e.UNKNOWN=0]="UNKNOWN",e[e.YES=1]="YES",e[e.NO=2]="NO"})(Fe||(Fe={}));var cd=function(e){M(r,e);function r(t){return e.call(this,t,R.ref.enhancer)||this}return Object.defineProperty(r.prototype,"get",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.get.call(this,""+t)}}),Object.defineProperty(r.prototype,"has",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.has.call(this,""+t)}}),Object.defineProperty(r.prototype,"delete",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return e.prototype.delete.call(this,""+t)}}),Object.defineProperty(r.prototype,"set",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return e.prototype.set.call(this,""+t,n)}}),Object.defineProperty(r.prototype,"put",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(!t)throw g("Map.put cannot be used to set empty values");if(V(t)){var n=D(t);if(n.identifier===null)throw g(to);return this.set(n.identifier,t),t}else if(Xa(t)){var i=D(this),a=i.type;if(a.identifierMode!==Fe.YES)throw g(to);var o=a.mapIdentifierAttribute,u=t[o];if(!Cn(u)){var c=this.put(a.getChildType().create(t,i.environment));return this.put(Ga(c))}var d=Wt(u);return this.set(d,t),this.get(d)}else throw g("Map.put can only be used to store complex values")}}),r}(pn),Ir=function(e){M(r,e);function r(t,n,i){i===void 0&&(i=[]);var a=e.call(this,t)||this;return Object.defineProperty(a,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"identifierMode",{enumerable:!0,configurable:!0,writable:!0,value:Fe.UNKNOWN}),Object.defineProperty(a,"mapIdentifierAttribute",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Map}),Object.defineProperty(a,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),a._determineIdentifierMode(),a.hookInitializers=i,a}return Object.defineProperty(r.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.hookInitializers.length>0?this.hookInitializers.concat(t):[t];return new r(this.name,this._subType,n)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return this._determineIdentifierMode(),Sn(this,t,n,i,a)}}),Object.defineProperty(r.prototype,"_determineIdentifierMode",{enumerable:!1,configurable:!0,writable:!0,value:function(){if(this.identifierMode===Fe.UNKNOWN){var t=[];if(ro(this._subType,t)){var n=t.reduce(function(i,a){if(!a.identifierAttribute)return i;if(i&&i!==a.identifierAttribute)throw g("The objects in a map should all have the same identifier attribute, expected '"+i+"', but child of type '"+a.name+"' declared attribute '"+a.identifierAttribute+"' as identifier");return a.identifierAttribute},void 0);n?(this.identifierMode=Fe.YES,this.mapIdentifierAttribute=n):this.identifierMode=Fe.NO}}}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){n===void 0&&(n={});var i=t.type._subType,a={};return Object.keys(n).forEach(function(o){a[o]=i.instantiate(t,o,void 0,n[o])}),a}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return new cd(t)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){fa(n,t.unbox);var i=t.type;i.hookInitializers.forEach(function(a){var o=a(n);Object.keys(o).forEach(function(u){var c=o[u],d=Gt(n,u,c);Ze(n,u,d)})}),cn(n,this.willChange),fn(n,this.didChange)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"Map<string, "+this._subType.describe()+">"}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return pa(t.storedValue)}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=t.storedValue.get(""+n);if(!i)throw g("Not a child "+n);return i}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=D(t.object),i=t.name;n.assertWritable({subpath:i});var a=n.type,o=a._subType;switch(t.type){case"update":{var u=t.newValue,c=t.object.get(i);if(u===c)return null;Ee(o,u),t.newValue=o.reconcile(n.getChildNode(i),t.newValue,n,i),a.processIdentifier(i,t.newValue)}break;case"add":Ee(o,t.newValue),t.newValue=o.instantiate(n,i,void 0,t.newValue),a.processIdentifier(i,t.newValue);break}return t}}),Object.defineProperty(r.prototype,"processIdentifier",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(this.identifierMode===Fe.YES&&n instanceof H){var i=n.identifier;if(i!==t)throw g("A map of objects containing an identifier should always store the object under their own identifier. Trying to store key '"+i+"', but expected: '"+t+"'")}}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n={};return t.getChildren().forEach(function(i){n[i.subpath]=i.snapshot}),n}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n={};return Object.keys(t).forEach(function(i){n[i]=t[i].getSnapshot()}),n}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=D(t.object);switch(t.type){case"update":return void n.emitPatch({op:"replace",path:et(t.name),value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},n);case"add":return void n.emitPatch({op:"add",path:et(t.name),value:t.newValue.snapshot,oldValue:void 0},n);case"delete":var i=t.oldValue.snapshot;return t.oldValue.die(),void n.emitPatch({op:"remove",path:et(t.name),oldValue:i},n)}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i){var a=t.storedValue;switch(i.op){case"add":case"replace":a.set(n,i.value);break;case"remove":a.delete(n);break}}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){Ee(this,n);var i=t.storedValue,a={};if(Array.from(i.keys()).forEach(function(u){a[u]=!1}),n)for(var o in n)i.set(o,n[o]),a[""+o]=!0;Object.keys(a).forEach(function(u){a[u]===!1&&i.delete(u)})}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this;return gt(t)?Tr(Object.keys(t).map(function(a){return i._subType.validate(t[a],wn(n,a,i._subType))})):X(n,t,"Value is not a plain object")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return yt}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){t.storedValue.delete(n)}}),r}(bt);Ir.prototype.applySnapshot=L(Ir.prototype.applySnapshot);function fd(e){return new Ir("map<string, "+e.name+">",e)}var Dr=function(e){M(r,e);function r(t,n,i){i===void 0&&(i=[]);var a=e.call(this,t)||this;return Object.defineProperty(a,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Array}),Object.defineProperty(a,"hookInitializers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),a.hookInitializers=i,a}return Object.defineProperty(r.prototype,"hooks",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.hookInitializers.length>0?this.hookInitializers.concat(t):[t];return new r(this.name,this._subType,n)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return Sn(this,t,n,i,a)}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){n===void 0&&(n=[]);var i=t.type._subType,a={};return n.forEach(function(o,u){var c=""+u;a[c]=i.instantiate(t,c,void 0,o)}),a}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return R.array(Ka(t),Er)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){_e(n).dehancer=t.unbox;var i=t.type;i.hookInitializers.forEach(function(a){var o=a(n);Object.keys(o).forEach(function(u){var c=o[u],d=Gt(n,u,c);Ze(n,u,d)})}),cn(n,this.willChange),fn(n,this.didChange)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType.describe()+"[]"}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.storedValue.slice()}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=Number(n);if(i<t.storedValue.length)return t.storedValue[i];throw g("Not a child: "+n)}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=D(t.object);n.assertWritable({subpath:""+t.index});var i=n.type._subType,a=n.getChildren();switch(t.type){case"update":{if(t.newValue===t.object[t.index])return null;var o=no(n,i,[a[t.index]],[t.newValue],[t.index]);if(!o)return null;t.newValue=o[0]}break;case"splice":{var u=t.index,c=t.removedCount,d=t.added,f=no(n,i,a.slice(u,u+c),d,d.map(function(v,y){return u+y}));if(!f)return null;t.added=f;for(var p=u+c;p<a.length;p++)a[p].setParent(n,""+(p+d.length-c))}break}return t}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.getChildren().map(function(n){return n.snapshot})}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=[];return Object.keys(t).forEach(function(i){n.push(t[i].getSnapshot())}),n}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=D(t.object);switch(t.type){case"update":return void n.emitPatch({op:"replace",path:""+t.index,value:t.newValue.snapshot,oldValue:t.oldValue?t.oldValue.snapshot:void 0},n);case"splice":for(var i=t.removedCount-1;i>=0;i--)n.emitPatch({op:"remove",path:""+(t.index+i),oldValue:t.removed[i].snapshot},n);for(var i=0;i<t.addedCount;i++)n.emitPatch({op:"add",path:""+(t.index+i),value:n.getChildNode(""+(t.index+i)).snapshot,oldValue:void 0},n);return}}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i){var a=t.storedValue,o=n==="-"?a.length:Number(n);switch(i.op){case"replace":a[o]=i.value;break;case"add":a.splice(o,0,i.value);break;case"remove":a.splice(o,1);break}}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){Ee(this,n);var i=t.storedValue;i.replace(n)}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subType}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this;return Ha(t)?Tr(t.map(function(a,o){return i._subType.validate(a,wn(n,""+o,i._subType))})):X(n,t,"Value is not an array")}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return mt}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){t.storedValue.splice(Number(n),1)}}),r}(bt);Dr.prototype.applySnapshot=L(Dr.prototype.applySnapshot);function dd(e){return new Dr(e.name+"[]",e)}function no(e,r,t,n,i){for(var a=!0,o=0;;o++){var u=o<=n.length-1,c=t[o],d=u?n[o]:void 0,f=""+i[o];if(Bf(d)&&(d=d.storedValue),!c&&!u)break;if(!u)a=!1,t.splice(o,1),c instanceof H&&c.createObservableInstanceIfNeeded(),c.die(),o--;else if(c)if(io(c,d))t[o]=Pn(r,e,f,d,c);else{for(var v=void 0,y=o;y<t.length;y++)if(io(t[y],d)){v=t.splice(y,1)[0];break}a=!1;var p=Pn(r,e,f,d,v);t.splice(o,0,p)}else{if(V(d)&&D(d).parent===e)throw g("Cannot add an object to a state tree if it is already part of the same or another state tree. Tried to assign an object to '"+e.path+"/"+f+"', but it lives already at '"+D(d).path+"'");a=!1;var p=Pn(r,e,f,d);t.splice(o,0,p)}}return a?null:t}function Pn(e,r,t,n,i){Ee(e,n);function a(){if(V(n)){var u=D(n);if(u.assertAlive(yt),u.parent!==null&&u.parent===r)return u.setParent(r,t),u}return i?e.reconcile(i,n,r,t):e.instantiate(r,t,void 0,n)}var o=a();return i&&i!==o&&(i instanceof H&&i.createObservableInstanceIfNeeded(),i.die()),o}function io(e,r){if(!e.isAlive)return!1;if(V(r)){var t=D(r);return t.isAlive&&t===e}if(e.snapshot===r)return!0;if(!(e instanceof H))return!1;var n=e.getReconciliationType();return e.identifier!==null&&e.identifierAttribute&&gt(r)&&n.is(r)&&n.isMatchingSnapshotId(e,r)}var ao="preProcessSnapshot",oo="postProcessSnapshot";function pd(){return D(this).toString()}var uo={name:"AnonymousModel",properties:{},initializers:mt};function hd(e){return Object.keys(e).reduce(function(r,t){var n,i,a;if(t in F)throw g("Hook '"+t+"' was defined as property. Hooks should be defined as part of the actions");var o=Object.getOwnPropertyDescriptor(r,t);if("get"in o)throw g("Getters are not supported as properties. Please use views instead");var u=o.value;if(u==null)throw g("The default value of an attribute cannot be null or undefined as the type cannot be inferred. Did you mean `types.maybe(someType)`?");if($t(u))return Object.assign({},r,(n={},n[t]=rt(gd(u),u),n));if(u instanceof Ir)return Object.assign({},r,(i={},i[t]=rt(u,{}),i));if(u instanceof Dr)return Object.assign({},r,(a={},a[t]=rt(u,[]),a));if(Le(u))return r;throw g("Invalid type definition for property '"+t+"', cannot infer a type from a value like '"+u+"' ("+typeof u+")")},e)}var Ut=function(e){M(r,e);function r(t){var n=e.call(this,t.name||uo.name)||this;return Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Object}),Object.defineProperty(n,"initializers",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"properties",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"preProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"postProcessor",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"propertyNames",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"named",{enumerable:!0,configurable:!0,writable:!0,value:function(i){return n.cloneAndEnhance({name:i})}}),Object.defineProperty(n,"props",{enumerable:!0,configurable:!0,writable:!0,value:function(i){return n.cloneAndEnhance({properties:i})}}),Object.defineProperty(n,"preProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(i){var a=n.preProcessor;return a?n.cloneAndEnhance({preProcessor:function(o){return a(i(o))}}):n.cloneAndEnhance({preProcessor:i})}}),Object.defineProperty(n,"postProcessSnapshot",{enumerable:!0,configurable:!0,writable:!0,value:function(i){var a=n.postProcessor;return a?n.cloneAndEnhance({postProcessor:function(o){return i(a(o))}}):n.cloneAndEnhance({postProcessor:i})}}),Object.assign(n,uo,t),n.properties=hd(n.properties),n.properties,n.propertyNames=Object.keys(n.properties),n.identifierAttribute=n._getIdentifierAttribute(),n}return Object.defineProperty(r.prototype,"_getIdentifierAttribute",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=void 0;return this.forAllProps(function(n,i){if(i.flags&E.Identifier){if(t)throw g("Cannot define property '"+n+"' as object identifier, property '"+t+"' is already defined as identifier property");t=n}}),t}}),Object.defineProperty(r.prototype,"cloneAndEnhance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return new r({name:t.name||this.name,properties:Object.assign({},this.properties,t.properties),initializers:this.initializers.concat(t.initializers||[]),preProcessor:t.preProcessor||this.preProcessor,postProcessor:t.postProcessor||this.postProcessor})}}),Object.defineProperty(r.prototype,"actions",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,i=function(a){return n.instantiateActions(a,t(a)),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(r.prototype,"instantiateActions",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(!gt(n))throw g("actions initializer should return a plain object containing actions");Object.keys(n).forEach(function(i){if(i===ao)throw g("Cannot define action '"+ao+"', it should be defined using 'type.preProcessSnapshot(fn)' instead");if(i===oo)throw g("Cannot define action '"+oo+"', it should be defined using 'type.postProcessSnapshot(fn)' instead");var a=n[i],o=t[i];if(i in F&&o){var u=a;a=function(){o.apply(null,arguments),u.apply(null,arguments)}}var c=a.$mst_middleware,d=a.bind(n);d.$mst_middleware=c;var f=Gt(t,i,d);n[i]=f,Ze(t,i,f)})}}),Object.defineProperty(r.prototype,"volatile",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;if(typeof t!="function")throw g("You passed an "+typeof t+" to volatile state as an argument, when function is expected");var i=function(a){return n.instantiateVolatileState(a,t(a)),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(r.prototype,"instantiateVolatileState",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(!gt(n))throw g("volatile state initializer should return a plain object containing state");ha(t,n)}}),Object.defineProperty(r.prototype,"extend",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,i=function(a){var o=t(a),u=o.actions,c=o.views,d=o.state,f=wf(o,["actions","views","state"]);for(var p in f)throw g("The `extend` function should return an object with a subset of the fields 'actions', 'views' and 'state'. Found invalid key '"+p+"'");return d&&n.instantiateVolatileState(a,d),c&&n.instantiateViews(a,c),u&&n.instantiateActions(a,u),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(r.prototype,"views",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,i=function(a){return n.instantiateViews(a,t(a)),a};return this.cloneAndEnhance({initializers:[i]})}}),Object.defineProperty(r.prototype,"instantiateViews",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(!gt(n))throw g("views initializer should return a plain object containing views");Object.getOwnPropertyNames(n).forEach(function(i){var a,o=Object.getOwnPropertyDescriptor(n,i);if("get"in o)ba(t,i,o),va(t,(a={},a[i]=st,a));else if(typeof o.value=="function")Ze(t,i,o.value);else throw g("A view member should either be a function or getter based property")})}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=V(a)?a:this.applySnapshotPreProcessor(a);return Sn(this,t,n,i,o)}}),Object.defineProperty(r.prototype,"initializeChildNodes",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){n===void 0&&(n={});var i=t.type,a={};return i.forAllProps(function(o,u){a[o]=u.instantiate(t,o,void 0,n[o])}),a}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return R.object(t,yt,Er)}}),Object.defineProperty(r.prototype,"finalizeNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){Ze(n,"toString",pd),this.forAllProps(function(i){fa(n,i,t.unbox)}),this.initializers.reduce(function(i,a){return a(i)},n),cn(n,this.willChange),fn(n,this.didChange)}}),Object.defineProperty(r.prototype,"willChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t,i=D(n.object),a=n.name;i.assertWritable({subpath:a});var o=i.type.properties[a];return o&&(Ee(o,n.newValue),n.newValue=o.reconcile(i.getChildNode(a),n.newValue,i,a)),n}}),Object.defineProperty(r.prototype,"didChange",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t,i=D(n.object),a=i.type.properties[n.name];if(!!a){var o=n.oldValue?n.oldValue.snapshot:void 0;i.emitPatch({op:"replace",path:et(n.name),value:n.newValue.snapshot,oldValue:o},i)}}}),Object.defineProperty(r.prototype,"getChildren",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this,i=[];return this.forAllProps(function(a){i.push(n.getChildNode(t,a))}),i}}),Object.defineProperty(r.prototype,"getChildNode",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(!(n in this.properties))throw g("Not a value property: "+n);var i=_e(t.storedValue,n),a=i.raw();if(!a)throw g("Node not available for property "+n);return a}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this;n===void 0&&(n=!0);var a={};return this.forAllProps(function(o,u){je(t.storedValue,o).reportObserved(),a[o]=i.getChildNode(t,o).snapshot}),n?this.applySnapshotPostProcessor(a):a}}),Object.defineProperty(r.prototype,"processInitialSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n={};return Object.keys(t).forEach(function(i){n[i]=t[i].getSnapshot()}),this.applySnapshotPostProcessor(n)}}),Object.defineProperty(r.prototype,"applyPatchLocally",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i){if(!(i.op==="replace"||i.op==="add"))throw g("object does not support operation "+i.op);t.storedValue[n]=i.value}}),Object.defineProperty(r.prototype,"applySnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this.applySnapshotPreProcessor(n);Ee(this,i),this.forAllProps(function(a){t.storedValue[a]=i[a]})}}),Object.defineProperty(r.prototype,"applySnapshotPreProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.preProcessor;return n?n.call(null,t):t}}),Object.defineProperty(r.prototype,"applySnapshotPostProcessor",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.postProcessor;return n?n.call(null,t):t}}),Object.defineProperty(r.prototype,"getChildType",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.properties[t]}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this,a=this.applySnapshotPreProcessor(t);return gt(a)?Tr(this.propertyNames.map(function(o){return i.properties[o].validate(a[o],wn(n,o,i.properties[o]))})):X(n,a,"Value is not a plain object")}}),Object.defineProperty(r.prototype,"forAllProps",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this;this.propertyNames.forEach(function(i){return t(i,n.properties[i])})}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this;return"{ "+this.propertyNames.map(function(n){return n+": "+t.properties[n].describe()}).join("; ")+" }"}}),Object.defineProperty(r.prototype,"getDefaultSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){return yt}}),Object.defineProperty(r.prototype,"removeChild",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){t.storedValue[n]=void 0}}),r}(bt);Ut.prototype.applySnapshot=L(Ut.prototype.applySnapshot);function bd(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=typeof e[0]=="string"?e.shift():"AnonymousModel",n=e.shift()||{};return new Ut({name:t,properties:n})}function vd(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=typeof e[0]=="string",n=t?e[0]:"AnonymousModel";return t&&e.shift(),e.reduce(function(i,a){return i.cloneAndEnhance({name:i.name+"_"+a.name,properties:a.properties,initializers:a.initializers,preProcessor:function(o){return a.applySnapshotPreProcessor(i.applySnapshotPreProcessor(o))},postProcessor:function(o){return a.applySnapshotPostProcessor(i.applySnapshotPostProcessor(o))}})}).named(n)}function md(e){return Le(e)&&(e.flags&E.Object)>0}var tt=function(e){M(r,e);function r(t,n,i,a){a===void 0&&(a=Wf);var o=e.call(this,t)||this;return Object.defineProperty(o,"flags",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(o,"checker",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(o,"initializer",{enumerable:!0,configurable:!0,writable:!0,value:a}),o.flags=n,o}return Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return Xe(this,t,n,i,a)}}),Object.defineProperty(r.prototype,"createNewInstance",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.initializer(t)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if($t(t)&&this.checker(t))return J();var i=this.name==="Date"?"Date or a unix milliseconds timestamp":this.name;return X(n,t,"Value is not a "+i)}}),r}(vt),lo=new tt("string",E.String,function(e){return typeof e=="string"}),so=new tt("number",E.Number,function(e){return typeof e=="number"}),yd=new tt("integer",E.Integer,function(e){return Yf(e)}),co=new tt("boolean",E.Boolean,function(e){return typeof e=="boolean"}),fo=new tt("null",E.Null,function(e){return e===null}),po=new tt("undefined",E.Undefined,function(e){return e===void 0}),ho=new tt("Date",E.Date,function(e){return typeof e=="number"||e instanceof Date},function(e){return e instanceof Date?e:new Date(e)});ho.getSnapshot=function(e){return e.storedValue.getTime()};var bo=ho;function gd(e){switch(typeof e){case"string":return lo;case"number":return so;case"boolean":return co;case"object":if(e instanceof Date)return bo}throw g("Cannot determine primitive type from value "+e)}function _d(e){return Le(e)&&(e.flags&(E.String|E.Number|E.Integer|E.Boolean|E.Date))>0}var wd=function(e){M(r,e);function r(t){var n=e.call(this,JSON.stringify(t))||this;return Object.defineProperty(n,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Literal}),n.value=t,n}return Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return Xe(this,t,n,i,a)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return JSON.stringify(this.value)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return $t(t)&&t===this.value?J():X(n,t,"Value is not a literal "+JSON.stringify(this.value))}}),r}(vt);function vo(e){return new wd(e)}var Sd=function(e){M(r,e);function r(t,n,i,a){var o=e.call(this,t)||this;return Object.defineProperty(o,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(o,"_predicate",{enumerable:!0,configurable:!0,writable:!0,value:i}),Object.defineProperty(o,"_message",{enumerable:!0,configurable:!0,writable:!0,value:a}),o}return Object.defineProperty(r.prototype,"flags",{get:function(){return this._subtype.flags|E.Refinement},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return this._subtype.instantiate(t,n,i,a)}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._subtype.isAssignableFrom(t)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this._subtype.validate(t,n);if(i.length>0)return i;var a=V(t)?D(t).snapshot:t;return this._predicate(a)?J():X(n,t,this._message(t))}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return this._subtype.reconcile(t,n,i,a)}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),r}(Te);function Od(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var t=typeof e[0]=="string"?e.shift():Le(e[0])?e[0].name:null,n=e[0],i=e[1],a=e[2]?e[2]:function(o){return"Value does not respect the refinement predicate"};return new Sd(t,n,i,a)}function xd(e,r){var t=typeof e=="string"?r:e,n=Mr.apply(void 0,ht(t.map(function(i){return vo(""+i)})));return typeof e=="string"&&(n.name=e),n}var Pd=function(e){M(r,e);function r(t,n,i){var a=e.call(this,t)||this;return Object.defineProperty(a,"_types",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"_dispatcher",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(a,"_eager",{enumerable:!0,configurable:!0,writable:!0,value:!0}),i=Ft({eager:!0,dispatcher:void 0},i),a._dispatcher=i.dispatcher,i.eager||(a._eager=!1),a}return Object.defineProperty(r.prototype,"flags",{get:function(){var t=E.Union;return this._types.forEach(function(n){t|=n.flags}),t},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._types.some(function(n){return n.isAssignableFrom(t)})}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"("+this._types.map(function(t){return t.describe()}).join(" | ")+")"}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=this.determineType(a,void 0);if(!o)throw g("No matching type for union "+this.describe());return o.instantiate(t,n,i,a)}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=this.determineType(n,t.getReconciliationType());if(!o)throw g("No matching type for union "+this.describe());return o.reconcile(t,n,i,a)}}),Object.defineProperty(r.prototype,"determineType",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return this._dispatcher?this._dispatcher(t):n?n.is(t)?n:this._types.filter(function(i){return i!==n}).find(function(i){return i.is(t)}):this._types.find(function(i){return i.is(t)})}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(this._dispatcher)return this._dispatcher(t).validate(t,n);for(var i=[],a=0,o=0;o<this._types.length;o++){var u=this._types[o],c=u.validate(t,n);if(c.length===0){if(this._eager)return J();a++}else i.push(c)}return a===1?J():X(n,t,"No type is applicable for the union").concat(Tr(i))}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._types}}),r}(Te);function Mr(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];var n=Le(e)?void 0:e,i=Le(e)?ht([e],r):r,a="("+i.map(function(o){return o.name}).join(" | ")+")";return new Pd(a,i,n)}function Cd(e){return(e.flags&E.Union)>0}var Ad=function(e){M(r,e);function r(t,n,i){var a=e.call(this,t.name)||this;return Object.defineProperty(a,"_subtype",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(a,"_defaultValue",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(a,"optionalValues",{enumerable:!0,configurable:!0,writable:!0,value:i}),a}return Object.defineProperty(r.prototype,"flags",{get:function(){return this._subtype.flags|E.Optional},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype.describe()+"?"}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){if(this.optionalValues.indexOf(a)>=0){var o=this.getDefaultInstanceOrSnapshot();return this._subtype.instantiate(t,n,i,o)}return this._subtype.instantiate(t,n,i,a)}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return this._subtype.reconcile(t,this.optionalValues.indexOf(n)<0&&this._subtype.is(n)?n:this.getDefaultInstanceOrSnapshot(),i,a)}}),Object.defineProperty(r.prototype,"getDefaultInstanceOrSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=typeof this._defaultValue=="function"?this._defaultValue():this._defaultValue;return typeof this._defaultValue=="function"&&Ee(this,t),t}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return this.optionalValues.indexOf(t)>=0?J():this._subtype.validate(t,n)}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this._subtype.isAssignableFrom(t)}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this._subtype}}),r}(Te);function jd(e,r){if(typeof r!="function"&&V(r))throw g("default value cannot be an instance, pass a snapshot or a function that creates an instance/snapshot instead")}function rt(e,r,t){return jd(e,r),new Ad(e,r,t||Td)}var Td=[void 0],Ed=rt(po,void 0),Id=rt(fo,null);function mo(e){return Mr(e,Ed)}function Dd(e){return Mr(e,Id)}var Md=function(e){M(r,e);function r(t,n){var i=e.call(this,t)||this;return Object.defineProperty(i,"_definition",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"_subType",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),i}return Object.defineProperty(r.prototype,"flags",{get:function(){return(this._subType?this._subType.flags:0)|E.Late},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"getSubType",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(!this._subType){var n=void 0;try{n=this._definition()}catch(i){if(i instanceof ReferenceError)n=void 0;else throw i}if(t&&n===void 0)throw g("Late type seems to be used too early, the definition (still) returns undefined");n&&(this._subType=n)}return this._subType}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return this.getSubType(!0).instantiate(t,n,i,a)}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return this.getSubType(!0).reconcile(t,n,i,a)}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this.getSubType(!1);return t?t.name:"<uknown late type>"}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this.getSubType(!1);return i?i.validate(t,n):J()}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=this.getSubType(!1);return n?n.isAssignableFrom(t):!1}}),Object.defineProperty(r.prototype,"getSubTypes",{enumerable:!1,configurable:!0,writable:!0,value:function(){var t=this.getSubType(!1);return t||Wa}}),r}(Te);function Rd(e,r){var t=typeof e=="string"?e:"late("+e.toString()+")",n=typeof e=="string"?r:e;return new Md(t,n)}var yo=function(e){M(r,e);function r(t){var n=e.call(this,t?"frozen("+t.name+")":"frozen")||this;return Object.defineProperty(n,"subType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Frozen}),n}return Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"<any immutable value>"}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){return Xe(this,t,n,i,a)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return Kf(t)?this.subType?this.subType.validate(t,n):J():X(n,t,"Value is not serializable and cannot be frozen")}}),r}(vt),go=new yo;function Vd(e){return arguments.length===0?go:Le(e)?new yo(e):rt(go,e)}function kd(e){switch(e){case F.beforeDestroy:return"destroy";case F.beforeDetach:return"detach";default:return}}var zd=function(){function e(r,t){if(Object.defineProperty(this,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"identifier",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"node",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"resolvedReference",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Cn(r))this.identifier=r;else if(V(r)){var n=D(r);if(!n.identifierAttribute)throw g("Can only store references with a defined identifier attribute.");var i=n.unnormalizedIdentifier;if(i==null)throw g("Can only store references to tree nodes with a defined identifier.");this.identifier=i}else throw g("Can only store references to tree nodes or identifiers, got: '"+r+"'")}return Object.defineProperty(e.prototype,"updateResolvedReference",{enumerable:!1,configurable:!0,writable:!0,value:function(r){var t=Wt(this.identifier),n=r.root,i=n.identifierCache.getLastCacheModificationPerId(t);if(!this.resolvedReference||this.resolvedReference.lastCacheModification!==i){var a=this.targetType,o=n.identifierCache.resolve(a,t);if(!o)throw new Nd("[mobx-state-tree] Failed to resolve reference '"+this.identifier+"' to type '"+this.targetType.name+"' (from node: "+r.path+")");this.resolvedReference={node:o,lastCacheModification:i}}}}),Object.defineProperty(e.prototype,"resolvedValue",{get:function(){return this.updateResolvedReference(this.node),this.resolvedReference.node.value},enumerable:!1,configurable:!0}),e}(),Nd=function(e){M(r,e);function r(t){var n=e.call(this,t)||this;return Object.setPrototypeOf(n,r.prototype),n}return r}(Error),_o=function(e){M(r,e);function r(t,n){var i=e.call(this,"reference("+t.name+")")||this;return Object.defineProperty(i,"targetType",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(i,"onInvalidated",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Reference}),i}return Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"isAssignableFrom",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.targetType.isAssignableFrom(t)}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return Cn(t)?J():X(n,t,"Value is not a valid identifier, which is a string or a number")}}),Object.defineProperty(r.prototype,"fireInvalidated",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=n.parent;if(!(!o||!o.isAlive)){var u=o.storedValue;!u||this.onInvalidated({cause:t,parent:u,invalidTarget:a?a.storedValue:void 0,invalidId:i,replaceRef:function(c){Ba(n.root.storedValue,{op:"replace",value:c,path:n.path})},removeRef:function(){md(o.type)?this.replaceRef(void 0):Ba(n.root.storedValue,{op:"remove",path:n.path})}})}}}),Object.defineProperty(r.prototype,"addTargetNodeWatcher",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){var i=this,a=this.getValue(t);if(!!a){var o=D(a),u=function(f,p){var v=kd(p);!v||i.fireInvalidated(v,t,n,o)},c=o.registerHook(F.beforeDetach,u),d=o.registerHook(F.beforeDestroy,u);return function(){c(),d()}}}}),Object.defineProperty(r.prototype,"watchTargetNodeForInvalidations",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i){var a=this;if(!!this.onInvalidated){var o;t.registerHook(F.beforeDestroy,function(){o&&o()});var u=function(c){o&&o();var d=t.parent,f=d&&d.storedValue;if(d&&d.isAlive&&f){var p=void 0;i?p=!!i.get(n,f):p=t.root.identifierCache.has(a.targetType,Wt(n)),p?o=a.addTargetNodeWatcher(t,n):c||a.fireInvalidated("invalidSnapshotReference",t,n,null)}};t.state===q.FINALIZED?u(!0):(t.isRoot||t.root.registerHook(F.afterCreationFinalization,function(){t.parent&&t.parent.createObservableInstanceIfNeeded()}),t.registerHook(F.afterAttach,function(){u(!1)}))}}}),r}(vt),Ld=function(e){M(r,e);function r(t,n){return e.call(this,t,n)||this}return Object.defineProperty(r.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(!!t.isAlive){var n=t.storedValue;return n.resolvedValue}}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){var n=t.storedValue;return n.identifier}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=V(a)?xf(a):a,u=new zd(a,this.targetType),c=Xe(this,t,n,i,u);return u.node=c,this.watchTargetNodeForInvalidations(c,o,void 0),c}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){if(!t.isDetaching&&t.type===this){var o=V(n),u=t.storedValue;if(!o&&u.identifier===n||o&&u.resolvedValue===n)return t.setParent(i,a),t}var c=this.instantiate(i,a,void 0,n);return t.die(),c}}),r}(_o),Fd=function(e){M(r,e);function r(t,n,i){var a=e.call(this,t,i)||this;return Object.defineProperty(a,"options",{enumerable:!0,configurable:!0,writable:!0,value:n}),a}return Object.defineProperty(r.prototype,"getValue",{enumerable:!1,configurable:!0,writable:!0,value:function(t){if(!!t.isAlive){var n=this.options.get(t.storedValue,t.parent?t.parent.storedValue:null);return n}}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.storedValue}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=V(a)?this.options.set(a,t?t.storedValue:null):a,u=Xe(this,t,n,i,o);return this.watchTargetNodeForInvalidations(u,o,this.options),u}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=V(n)?this.options.set(n,t?t.storedValue:null):n;if(!t.isDetaching&&t.type===this&&t.storedValue===o)return t.setParent(i,a),t;var u=this.instantiate(i,a,void 0,o);return t.die(),u}}),r}(_o);function wo(e,r){var t=r||void 0,n=r?r.onInvalidated:void 0;return t&&(t.get||t.set)?new Fd(e,{get:t.get,set:t.set},n):new Ld(e,n)}function qd(e,r){var t=wo(e,Ft(Ft({},r),{onInvalidated:function(n){r&&r.onInvalidated&&r.onInvalidated(n),n.removeRef()}}));return r&&r.acceptsUndefined===!1?t:mo(t)}var So=function(e){M(r,e);function r(t,n){var i=e.call(this,t)||this;return Object.defineProperty(i,"validType",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(i,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Identifier}),i}return Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){if(!t||!(t.type instanceof Ut))throw g("Identifier types can only be instantiated as direct child of a model type");return Xe(this,t,n,i,a)}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){if(t.storedValue!==n)throw g("Tried to change identifier from '"+t.storedValue+"' to '"+n+"'. Changing identifiers is not allowed.");return t.setParent(i,a),t}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){return typeof t!==this.validType?X(n,t,"Value is not a valid "+this.describe()+", expected a "+this.validType):J()}}),r}(vt),Bd=function(e){M(r,e);function r(){var t=e.call(this,"identifier","string")||this;return Object.defineProperty(t,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Identifier}),t}return Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifier"}}),r}(So),Gd=function(e){M(r,e);function r(){return e.call(this,"identifierNumber","number")||this}return Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return t.storedValue}}),Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return"identifierNumber"}}),r}(So),$d=new Bd,Ud=new Gd;function Wt(e){return""+e}function Cn(e){return typeof e=="string"||typeof e=="number"}function Wd(e){return new Yd(e)}var Yd=function(e){M(r,e);function r(t){var n=e.call(this,t.name)||this;return Object.defineProperty(n,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(n,"flags",{enumerable:!0,configurable:!0,writable:!0,value:E.Custom}),n}return Object.defineProperty(r.prototype,"describe",{enumerable:!1,configurable:!0,writable:!0,value:function(){return this.name}}),Object.defineProperty(r.prototype,"isValidSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n){if(this.options.isTargetType(t))return J();var i=this.options.getValidationMessage(t);return i?X(n,t,"Invalid value for type '"+this.name+"': "+i):J()}}),Object.defineProperty(r.prototype,"getSnapshot",{enumerable:!1,configurable:!0,writable:!0,value:function(t){return this.options.toSnapshot(t.storedValue)}}),Object.defineProperty(r.prototype,"instantiate",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=this.options.isTargetType(a)?a:this.options.fromSnapshot(a,t&&t.root.environment);return Xe(this,t,n,i,o)}}),Object.defineProperty(r.prototype,"reconcile",{enumerable:!1,configurable:!0,writable:!0,value:function(t,n,i,a){var o=!this.options.isTargetType(n);if(!t.isDetaching){var u=t.type===this&&(o?n===t.snapshot:n===t.storedValue);if(u)return t.setParent(i,a),t}var c=o?this.options.fromSnapshot(n,i.root.environment):n,d=this.instantiate(i,a,void 0,c);return t.die(),d}}),r}(vt),x={enumeration:xd,model:bd,compose:vd,custom:Wd,reference:wo,safeReference:qd,union:Mr,optional:rt,literal:vo,maybe:mo,maybeNull:Dd,refinement:Od,string:lo,boolean:co,number:so,integer:yd,Date:bo,map:fd,array:dd,frozen:Vd,identifier:$d,identifierNumber:Ud,late:Rd,undefined:po,null:fo,snapshotProcessor:sd},oe=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(oe||{});const Oo=x.model({type:x.enumeration("DataSourceType",["postgresql"]),key:x.string,sql:x.string}),xo=x.model("FilterConfigModel_TextInput",{required:x.boolean,default_value:x.string}).actions(e=>({setRequired(r){e.required=r},setDefaultValue(r){e.default_value=r}})),Po=()=>xo.create({required:!1,default_value:""}),Qd=ae(function({config:r}){return l(Y,{children:l(s.Checkbox,{checked:r.default_value,onChange:t=>r.setDefaultValue(t.currentTarget.checked),label:"Default Checked"})})}),Kd=[{label:"2022",value:"YYYY"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],Hd=ae(function({config:r}){return b(Y,{children:[b(s.Group,{children:[l(s.Checkbox,{checked:r.required,onChange:t=>r.setRequired(t.currentTarget.checked),label:"Required"}),l(s.Checkbox,{checked:r.clearable,onChange:t=>r.setClearable(t.currentTarget.checked),label:"Clearable"})]}),l(s.Select,{data:Kd,label:"Display Format",value:r.inputFormat,onChange:r.setInputFormat})]})}),Jd=ae(function({value:r,onChange:t}){const{data:n=[],loading:i}=Be.useRequest(Rn,{refreshDeps:[]},[]),a=h.default.useMemo(()=>Array.from(new Set(n.map(({type:c})=>c))).map(c=>({label:c,value:c})),[n]),o=h.default.useMemo(()=>{const u=n.filter(({type:c})=>c===r.type);return u?u.map(({key:c})=>({label:c,value:c})):[]},[n,r.type]);return b(s.Group,{grow:!0,children:[l(s.Select,{label:"Data Source Type",data:a,sx:{flex:1},disabled:i,value:r.type,onChange:u=>{t({...r,type:u})}}),l(s.Select,{label:"Data Source Key",data:o,sx:{flex:1},disabled:i,value:r.key,onChange:u=>{t({...r,key:u})}})]})});function Xd({data:e}){return e.length===0?l(s.Table,{}):b(s.Table,{children:[l("thead",{children:l("tr",{children:Object.keys(e==null?void 0:e[0]).map(r=>l("th",{children:l(s.Text,{weight:700,color:"#000",children:r})},r))})}),l("tbody",{children:e.slice(0,3).map((r,t)=>l("tr",{children:Object.values(r).map((n,i)=>l("td",{children:l(s.Group,{sx:{"&, .mantine-Text-root":{fontFamily:"monospace"}},children:l(s.Text,{children:n})})},`${n}--${i}`))},`row-${t}`))}),e.length>3&&l("tfoot",{children:l("tr",{children:l("td",{colSpan:Object.keys(e==null?void 0:e[0]).length,children:b(s.Text,{color:"gray",size:"sm",children:[e.length-3," more row(s) hidden"]})})})})]})}const Zd=ae(function({query:r}){const{data:t=[],loading:n,refresh:i}=Be.useRequest(Nr(r),{refreshDeps:[r]});return b(s.Stack,{my:0,children:[b(s.Group,{position:"apart",children:[l(s.Text,{size:"md",pl:"sm",children:"Fetched Data"}),l(s.Button,{size:"xs",onClick:i,disabled:!r.sql||!r.key,children:"Retry"})]}),b(s.Box,{sx:{position:"relative"},children:[l(s.LoadingOverlay,{visible:n,exitTransitionDuration:0}),l(Xd,{data:t})]})]})}),Co=ae(function({value:r,onChange:t}){return b(s.Stack,{my:0,children:[l(Jd,{value:r,onChange:t}),b(s.Tabs,{defaultValue:"SQL",children:[b(s.Tabs.List,{children:[l(s.Tabs.Tab,{value:"SQL",children:"SQL"}),l(s.Tabs.Tab,{value:"Preview",children:"Preview"}),l(s.Tabs.Tab,{value:"Data",children:"Data"})]}),l(s.Tabs.Panel,{value:"SQL",pt:"sm",children:l(s.Textarea,{autosize:!0,minRows:12,maxRows:24,className:"code-textarea",value:r.sql,onChange:n=>{t({...r,sql:n.currentTarget.value})},placeholder:"SELECT name AS label, id AS value"})}),l(s.Tabs.Panel,{value:"Preview",pt:"sm",children:l(hi,{value:r.sql})}),l(s.Tabs.Panel,{value:"Data",pt:"sm",children:l(Zd,{query:r})})]})]})}),ep=ae(function({config:r}){const t=()=>{r.addStaticOption({label:"",value:""})},n=r.static_options,i=[...n];return b(Y,{children:[l(s.Divider,{label:"Configure options",labelPosition:"center"}),n.length>0&&l(s.MultiSelect,{label:"Default Selection",data:i,value:r.default_value,onChange:r.setDefaultValue}),n.map((a,o)=>b(s.Group,{sx:{position:"relative"},pr:"40px",children:[l(s.TextInput,{label:"Label",required:!0,value:r.static_options[o].label,onChange:u=>{r.static_options[o].setLabel(u.currentTarget.value)},sx:{flexGrow:1}}),l(s.TextInput,{label:"Value",required:!0,value:r.static_options[o].value,onChange:u=>{r.static_options[o].setValue(u.currentTarget.value)},sx:{flexGrow:1}}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r.removeStaticOption(o),sx:{position:"absolute",top:28,right:5},children:l(_.Trash,{size:16})})]})),l(s.Button,{size:"xs",color:"blue",leftIcon:l(_.PlaylistAdd,{size:20}),onClick:t,sx:{width:"50%"},mx:"auto",children:"Add an Option"}),l(s.Divider,{label:"Or fetch options from database",labelPosition:"center"}),l(Co,{value:r.options_query,onChange:r.setOptionsQuery})]})}),tp=ae(function({config:r}){const t=()=>{r.addStaticOption({label:"",value:""})},n=r.static_options,i=[{label:"No default selection",value:""},...n];return b(Y,{children:[l(s.Checkbox,{checked:r.required,onChange:a=>r.setRequired(a.currentTarget.checked),label:"Required"}),l(s.Divider,{label:"Configure options",labelPosition:"center"}),n.length>0&&l(s.Select,{label:"Default Selection",data:i,value:r.default_value,onChange:r.setDefaultValue}),n.map((a,o)=>b(s.Group,{sx:{position:"relative"},pr:"40px",children:[l(s.TextInput,{label:"Label",required:!0,value:r.static_options[o].label,onChange:u=>{r.static_options[o].setLabel(u.currentTarget.value)},sx:{flexGrow:1}}),l(s.TextInput,{label:"Value",required:!0,value:r.static_options[o].value,onChange:u=>{r.static_options[o].setValue(u.currentTarget.value)},sx:{flexGrow:1}}),l(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r.removeStaticOption(o),sx:{position:"absolute",top:28,right:5},children:l(_.Trash,{size:16})})]})),l(s.Button,{size:"xs",color:"blue",leftIcon:l(_.PlaylistAdd,{size:20}),onClick:t,sx:{width:"50%"},mx:"auto",children:"Add an Option"}),l(s.Divider,{label:"Or fetch options from database",labelPosition:"center"}),l(Co,{value:r.options_query,onChange:r.setOptionsQuery})]})}),rp=ae(function({config:r}){return b(Y,{children:[l(s.TextInput,{label:"Default Value",value:r.default_value,onChange:t=>{r.setDefaultValue(t.currentTarget.value)}}),l(s.Checkbox,{checked:r.required,onChange:t=>r.setRequired(t.currentTarget.checked),label:"Required"})]})});function np({label:e,config:{default_value:r,...t},value:n,onChange:i}){return b(s.Box,{children:[l(s.Text,{children:"\xA0"}),l(s.Checkbox,{label:e,checked:n,onChange:a=>i(a.currentTarget.checked),...t})]})}function ip({label:e,config:r,value:t,onChange:n}){return l(Wo.DateRangePicker,{label:e,value:t,onChange:n,icon:l(_.Calendar,{size:16}),sx:{minWidth:"14em"},...r})}function ap({label:e,config:r,value:t,onChange:n}){const i=!!r.options_query.sql,{data:a=[],loading:o}=Be.useRequest(Nr(r.options_query),{refreshDeps:[r.options_query,i]});return l(s.MultiSelect,{label:e,data:i?a:r.static_options,disabled:i?o:!1,value:t,onChange:n,sx:{minWidth:"14em"}})}function op({label:e,config:r,value:t,onChange:n}){const i=!!r.options_query.sql,{data:a=[],loading:o}=Be.useRequest(Nr(r.options_query),{refreshDeps:[r.options_query,i]});return l(s.Select,{label:e,data:i?a:r.static_options,disabled:i?o:!1,value:t,onChange:n})}function up({label:e,config:r,value:t,onChange:n}){return l(s.TextInput,{label:e,value:t,onChange:n,...r})}function lp({type:e,config:r,key:t,...n},i){switch(e){case"select":return l(op,{...n,...i,config:r});case"multi-select":return l(ap,{...n,...i,config:r});case"text-input":return l(up,{...n,...i,config:r});case"date-range":return l(ip,{...n,...i,config:r});case"checkbox":return l(np,{...n,...i,config:r});default:return null}}const Ao=h.default.forwardRef(function({filter:r,...t},n){return l("div",{className:"filter-root",ref:n,children:l(Zt,{children:lp(r,t)})})}),sp=ae(function({filter:r}){const t=r.config.default_value,[n,i]=h.default.useState(t);return h.default.useEffect(()=>{i(t)},[t]),b(s.Box,{sx:{maxWidth:"30em"},children:[l(s.Text,{pb:"md",color:"gray",children:"Preview"}),l(Ao,{filter:r,value:n,onChange:i}),l(s.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),l($e.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(r,null,4)})]})}),cp={select:tp,"multi-select":ep,"text-input":rp,checkbox:Qd,"date-range":Hd},fp=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],dp=ae(function({filter:r,index:t}){const n=h.default.useMemo(()=>cp[r.type],[r.type]);return b(s.SimpleGrid,{cols:2,children:[b(s.Box,{pl:"md",children:[l(s.Text,{pb:"md",color:"gray",children:"Edit"}),b(s.Stack,{sx:{maxWidth:"30em"},children:[l(s.NumberInput,{label:"Placement Order",required:!0,value:r.order,onChange:r.setOrder,hideControls:!0}),l(s.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:r.key,onChange:i=>{r.setKey(i.currentTarget.value)}}),l(s.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:r.label,onChange:i=>{r.setLabel(i.currentTarget.value)}}),l(s.Select,{label:"Widget",data:fp,required:!0,value:r.type,onChange:r.setType}),l(n,{config:r.config,index:t})]})]}),l(sp,{filter:r})]})}),pp=ae(function({model:r}){const t=r.filters.current,n=()=>{const i=W.randomId(),a={id:i,key:i,label:i,order:t.length+1,type:oe.TextInput,config:Po()};r.filters.append(a)};return b(s.Group,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)"},p:0,children:[l(s.Group,{sx:{position:"absolute",top:"16px",right:"16px"},children:l(s.Button,{size:"xs",color:"red",leftIcon:l(_.Recycle,{size:20}),disabled:!r.filters.changed,onClick:r.filters.reset,children:"Revert Changes"})}),l(s.Tabs,{orientation:"vertical",defaultValue:r.filters.firstID,children:b(s.Group,{sx:{height:"100%"},children:[b(s.Stack,{sx:{height:"100%"},children:[l(s.Tabs.List,{position:"left",sx:{flexGrow:1,width:"200px"},children:r.filters.current.map((i,a)=>l(s.Tabs.Tab,{value:i.id,children:i.label},i.id))}),l(s.Button,{size:"xs",color:"blue",leftIcon:l(_.PlaylistAdd,{size:20}),onClick:n,children:"Add a Filter"})]}),l(s.Box,{sx:{flexGrow:1,height:"100%"},children:r.filters.current.map((i,a)=>l(s.Tabs.Panel,{value:i.id,sx:{height:"100%"},children:b(s.Stack,{sx:{height:"100%"},spacing:"sm",children:[l(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"scroll"},children:l(dp,{filter:i,index:a})}),l(s.Group,{position:"right",pt:10,children:l(s.Button,{size:"xs",color:"red",leftIcon:l(_.Trash,{size:20}),onClick:()=>r.filters.remove(a),children:"Delete this filter"})})]})},i.id))})]})})]})});function hp({opened:e,close:r,model:t}){const{freezeLayout:n}=h.default.useContext(be);return h.default.useEffect(()=>{n(e)},[e]),l(s.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:r,title:"Filters",trapFocus:!0,onDragStart:i=>{i.stopPropagation()},withCloseButton:!1,children:l(pp,{model:t})})}function bp({mode:e,setMode:r,hasChanges:t,saveChanges:n,revertChanges:i,getCurrentSchema:a,model:o}){const{addPanel:u}=h.default.useContext(Ht),{inLayoutMode:c,inEditMode:d,inUseMode:f}=h.default.useContext(be),[p,v]=h.default.useState(!1),y=()=>v(!0),P=()=>v(!1),[j,I]=h.default.useState(!1),$=()=>I(!0),he=()=>I(!1),[Z,k]=h.default.useState(!1),U=()=>k(!0),ee=()=>k(!1);return b(s.Group,{position:"apart",pt:0,pb:"xs",children:[l(s.Group,{position:"left",children:l(Zl,{mode:e,setMode:r})}),b(s.Group,{position:"right",children:[!f&&l(s.Button,{variant:"default",size:"xs",onClick:u,leftIcon:l(_.PlaylistAdd,{size:20}),children:"Add a Panel"}),d&&l(s.Button,{variant:"default",size:"xs",onClick:$,leftIcon:l(_.Filter,{size:20}),children:"Filters"}),d&&l(s.Button,{variant:"default",size:"xs",onClick:y,leftIcon:l(_.Database,{size:20}),children:"Data Settings"}),!f&&l(s.Button,{variant:"default",size:"xs",onClick:n,disabled:!t,leftIcon:l(_.DeviceFloppy,{size:20}),children:"Save Changes"}),!f&&l(s.Button,{color:"red",size:"xs",disabled:!t,onClick:i,leftIcon:l(_.Recycle,{size:20}),children:"Revert Changes"}),b(s.Menu,{children:[l(s.Menu.Target,{children:l(s.Button,{variant:"default",size:"xs",leftIcon:l(_.Share,{size:20}),children:"Export"})}),b(s.Menu.Dropdown,{children:[l(s.Menu.Item,{disabled:!0,children:"Download Data"}),l(s.Menu.Item,{onClick:U,children:"View Schema"})]})]})]}),l(hp,{opened:j,close:he,model:o}),l(ls,{opened:p,close:P}),l(ss,{opened:Z,close:ee,getCurrentSchema:a})]})}function jo({panel:e,exitFullScreen:r}){return b(s.Stack,{sx:{flexGrow:1,justifyContent:"flex-start"},children:[l(s.Group,{sx:{flexGrow:0},children:l(s.Button,{variant:"default",size:"sm",onClick:r,leftIcon:l(_.ArrowLeft,{size:20}),children:"Exit fullscreen"})}),l(s.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:l(ir,{...e})})]})}function To(e){const[r,t]=h.default.useState(null),n=h.default.useCallback(u=>{t(u)},[]),i=h.default.useCallback(()=>{t(null)},[]),a=h.default.useMemo(()=>e.find(u=>u.id===r),[r,e]);return{viewPanelInFullScreen:n,exitFullScreen:i,inFullScreen:!!a,fullScreenPanel:a}}function Eo({filters:e,filterValues:r,setFilterValues:t}){const{control:n,handleSubmit:i}=O.useForm({defaultValues:r}),a=h.default.useMemo(()=>C.default.sortBy(e,"order"),[e]);return e.length===0?null:l("form",{onSubmit:i(t),children:b(s.Group,{className:"dashboard-filters",position:"apart",p:"md",mb:"md",noWrap:!0,sx:{boxShadow:"0px 0px 10px 0px rgba(0,0,0,.2)"},children:[l(s.Group,{align:"flex-start",children:a.map(o=>l(O.Controller,{name:o.key,control:n,render:({field:u})=>l(Ao,{filter:o,...u})},o.id))}),l(s.Group,{sx:{alignSelf:"flex-end"},children:l(s.Button,{color:"blue",size:"sm",type:"submit",children:"Submit"})})]})})}function Io(e){const[r,t]=h.default.useState(e.filters),[n,i]=h.default.useState(()=>e.filters.reduce((o,u)=>{var c;return o[u.key]=(c=u.config.default_value)!=null?c:"",o},{}));return{filters:r,setFilters:t,filterValues:n,setFilterValues:i}}const Do=x.model({label:x.string,value:x.string}).actions(e=>({setLabel(r){e.label=r},setValue(r){e.value=r}})),Mo=x.model("FilterConfigModel_Select",{required:x.boolean,default_value:x.string,static_options:x.optional(x.array(Do),[]),options_query:Oo}).actions(e=>({addStaticOption(r){e.static_options.push(r)},removeStaticOption(r){e.static_options.splice(r,1)},setRequired(r){e.required=r},setDefaultValue(r){e.default_value=r},setOptionsQuery(r){e.options_query=r}})),vp=()=>Mo.create({required:!1,default_value:"",static_options:[],options_query:{type:"postgresql",key:"",sql:""}}),Ro=x.model("FilterConfigModel_MultiSelect",{default_value:x.optional(x.array(x.string),[]),static_options:x.optional(x.array(Do),[]),options_query:Oo}).actions(e=>({addStaticOption(r){e.static_options.push(r)},removeStaticOption(r){e.static_options.splice(r,1)},setDefaultValue(r){e.default_value=r},setOptionsQuery(r){e.options_query=r}})),mp=()=>Ro.create({default_value:[],static_options:[],options_query:{type:"postgresql",key:"",sql:""}}),Vo=x.model("FilterConfigModel_Checkbox",{default_value:x.boolean}).actions(e=>({setDefaultValue(r){e.default_value=r}})),yp=()=>Vo.create({default_value:!1}),ko=x.model("FilterConfigModel_DateRange",{required:x.boolean,inputFormat:x.enumeration("DateRangeInputFormat",["YYYY","YYYY-MM","YYYY-MM-DD"]),clearable:x.boolean}).actions(e=>({setRequired(r){e.required=r},setClearable(r){e.clearable=r},setInputFormat(r){e.inputFormat=r}})),gp=()=>ko.create({required:!1,inputFormat:"YYYY-MM-DD",clearable:!1}),zo=x.model("FilterModel",{id:x.identifier,key:x.string,label:x.string,order:x.number,type:x.enumeration("DashboardFilterType",[oe.Select,oe.MultiSelect,oe.TextInput,oe.Checkbox,oe.DateRange]),config:x.union(Mo,Ro,xo,Vo,ko)}).actions(e=>({setKey(r){e.key=r},setLabel(r){e.label=r},setOrder(r){e.order=r},setType(r){switch(r){case oe.Select:e.config=vp();break;case oe.MultiSelect:e.config=mp();break;case oe.TextInput:e.config=Po();break;case oe.Checkbox:e.config=yp();break;case oe.DateRange:e.config=gp();break}e.type=r}})),_p=x.model("FiltersModel",{original:x.optional(x.array(zo),[]),current:x.optional(x.array(zo),[])}).views(e=>({get changed(){return!C.default.isEqual(e.original,e.current)},get firstID(){if(e.current.length!==0)return e.current[0].id}})).actions(e=>({reset(){e.current=C.default.cloneDeep(e.original)},replace(r){e.current=r},append(r){e.current.push(r)},remove(r){e.current.splice(r,1)}})),wp=x.model({id:x.identifier,name:x.string,filters:_p});function Sp({id:e,name:r,filters:t}){return wp.create({id:e,name:r,filters:{original:t,current:t}})}const Op=ae(function({context:r,dashboard:t,update:n,className:i="dashboard",config:a}){We.baseURL!==a.apiBaseURL&&(We.baseURL=a.apiBaseURL);const[o,u]=h.default.useState(!1),[c,d]=h.default.useState(le.Edit),[f,p]=h.default.useState(t.panels),v=h.default.useMemo(()=>Sp(t),[t]),[y,P]=h.default.useState(t.definition.sqlSnippets),[j,I]=h.default.useState(t.definition.queries),{filters:$,setFilters:he,filterValues:Z,setFilterValues:k}=Io(t),U=h.default.useMemo(()=>{if(v.filters.changed)return!0;const ue=Se=>JSON.parse(JSON.stringify(Se));return!C.default.isEqual(ue(f),ue(t.panels))||!C.default.isEqual(y,t.definition.sqlSnippets)?!0:!C.default.isEqual(j,t.definition.queries)},[t,$,f,y,j,v.filters.changed]),ee=async()=>{const ue={...t,filters:[...v.filters.current],panels:f,definition:{sqlSnippets:y,queries:j}};await n(ue)},_t=()=>{he(t.filters),p(t.panels),P(t.definition.sqlSnippets),I(t.definition.queries)},Ap=()=>{const ue=W.randomId(),we={id:ue,layout:{x:0,y:1/0,w:3,h:15},title:`Panel - ${ue}`,description:"<p><br></p>",queryID:"",viz:{type:"table",conf:{}}};p(Se=>[...Se,we])},jp=ue=>{try{const we=f.find(Tn=>Tn.id===ue);if(!we)throw new Error(`[duplicate panel] Can't find a panel by id[${ue}]`);const Se={...we,id:W.randomId(),layout:{...we.layout,x:0,y:1/0}};p(Tn=>[...Tn,Se])}catch(we){console.error(we)}},Tp=ue=>{const we=f.findIndex(Se=>Se.id===ue);p(Se=>(Se.splice(we,1),[...Se]))},Ep=c===le.Edit,An=c===le.Layout,Ip=c===le.Use,Dp=h.default.useMemo(()=>({sqlSnippets:y,setSQLSnippets:P,queries:j,setQueries:I}),[y,P,j,I]),Mp=h.default.useCallback(()=>({panels:f,definition:{sqlSnippets:y,queries:j}}),[y,j,f]),{viewPanelInFullScreen:Rp,exitFullScreen:Vp,inFullScreen:jn,fullScreenPanel:kp}=To(f);return l(Vr.ModalsProvider,{children:l(Ie.Provider,{value:r,children:l(Ye.Provider,{value:Z,children:l(Ht.Provider,{value:{addPanel:Ap,duplidatePanel:jp,removePanelByID:Tp,viewPanelInFullScreen:Rp,inFullScreen:jn},children:l(ce.Provider,{value:Dp,children:b(be.Provider,{value:{layoutFrozen:o,freezeLayout:u,mode:c,inEditMode:Ep,inLayoutMode:An,inUseMode:Ip},children:[jn&&l(jo,{panel:kp,exitFullScreen:Vp}),b(s.Box,{className:i,sx:{position:"relative",display:jn?"none":"block"},children:[l(bp,{mode:c,setMode:d,hasChanges:U,saveChanges:ee,revertChanges:_t,getCurrentSchema:Mp,model:v}),l(Eo,{filters:$,filterValues:Z,setFilterValues:k}),l(di,{panels:f,setPanels:p,isDraggable:An,isResizable:An})]})]})})})})})})}),xp=Rr.WidthProvider(In.default);function Pp({panels:e,className:r="layout",rowHeight:t=10}){return l(xp,{className:`dashboard-layout ${r}`,rowHeight:t,isDraggable:!1,isResizable:!1,children:e.map(({id:n,...i})=>l("div",{"data-grid":i.layout,children:l(ir,{id:n,...i})},n))})}function Cp({context:e,dashboard:r,className:t="dashboard",config:n}){We.baseURL!==n.apiBaseURL&&(We.baseURL=n.apiBaseURL);const{filters:i,filterValues:a,setFilterValues:o}=Io(r),u=h.default.useMemo(()=>({...r.definition,setSQLSnippets:()=>{},setQueries:()=>{}}),[r]),{viewPanelInFullScreen:c,exitFullScreen:d,inFullScreen:f,fullScreenPanel:p}=To(r.panels);return l(Vr.ModalsProvider,{children:l(Ie.Provider,{value:e,children:l(Ye.Provider,{value:a,children:l(Ht.Provider,{value:{addPanel:C.default.noop,duplidatePanel:C.default.noop,removePanelByID:C.default.noop,viewPanelInFullScreen:c,inFullScreen:f},children:l(ce.Provider,{value:u,children:b(be.Provider,{value:{layoutFrozen:!0,freezeLayout:()=>{},mode:le.Use,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},children:[f&&l(jo,{panel:p,exitFullScreen:d}),b(s.Box,{className:t,sx:{display:f?"none":"block"},children:[l(Eo,{filters:i,filterValues:a,setFilterValues:o}),l(Pp,{panels:r.panels})]})]})})})})})})}var No=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(No||{});w.ContextInfoContext=Ie,w.Dashboard=Op,w.DashboardFilterType=No,w.DashboardLayout=di,w.DashboardMode=le,w.DefinitionContext=ce,w.FilterValuesContext=Ye,w.LayoutStateContext=be,w.Panel=ir,w.PanelContext=se,w.ReadOnlyDashboard=Cp,w.initialContextInfoContext=Xo,w.initialFilterValuesContext=ru,Object.defineProperties(w,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
49
+ JSZip uses the library pako released under the MIT license :
50
+ https://github.com/nodeca/pako/blob/main/LICENSE
51
+ */(function(t,e){(function(r){t.exports=r()})(function(){return function r(o,a,l){function s(v,h){if(!a[v]){if(!o[v]){var p=typeof Pt=="function"&&Pt;if(!h&&p)return p(v,!0);if(i)return i(v,!0);var b=new Error("Cannot find module '"+v+"'");throw b.code="MODULE_NOT_FOUND",b}var m=a[v]={exports:{}};o[v][0].call(m.exports,function(E){var g=o[v][1][E];return s(g||E)},m,m.exports,r,o,a,l)}return a[v].exports}for(var i=typeof Pt=="function"&&Pt,d=0;d<l.length;d++)s(l[d]);return s}({1:[function(r,o,a){var l=r("./utils"),s=r("./support"),i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";a.encode=function(d){for(var v,h,p,b,m,E,g,C=[],_=0,T=d.length,I=T,L=l.getTypeOf(d)!=="string";_<d.length;)I=T-_,p=L?(v=d[_++],h=_<T?d[_++]:0,_<T?d[_++]:0):(v=d.charCodeAt(_++),h=_<T?d.charCodeAt(_++):0,_<T?d.charCodeAt(_++):0),b=v>>2,m=(3&v)<<4|h>>4,E=1<I?(15&h)<<2|p>>6:64,g=2<I?63&p:64,C.push(i.charAt(b)+i.charAt(m)+i.charAt(E)+i.charAt(g));return C.join("")},a.decode=function(d){var v,h,p,b,m,E,g=0,C=0,_="data:";if(d.substr(0,_.length)===_)throw new Error("Invalid base64 input, it looks like a data url.");var T,I=3*(d=d.replace(/[^A-Za-z0-9+/=]/g,"")).length/4;if(d.charAt(d.length-1)===i.charAt(64)&&I--,d.charAt(d.length-2)===i.charAt(64)&&I--,I%1!=0)throw new Error("Invalid base64 input, bad content length.");for(T=s.uint8array?new Uint8Array(0|I):new Array(0|I);g<d.length;)v=i.indexOf(d.charAt(g++))<<2|(b=i.indexOf(d.charAt(g++)))>>4,h=(15&b)<<4|(m=i.indexOf(d.charAt(g++)))>>2,p=(3&m)<<6|(E=i.indexOf(d.charAt(g++))),T[C++]=v,m!==64&&(T[C++]=h),E!==64&&(T[C++]=p);return T}},{"./support":30,"./utils":32}],2:[function(r,o,a){var l=r("./external"),s=r("./stream/DataWorker"),i=r("./stream/Crc32Probe"),d=r("./stream/DataLengthProbe");function v(h,p,b,m,E){this.compressedSize=h,this.uncompressedSize=p,this.crc32=b,this.compression=m,this.compressedContent=E}v.prototype={getContentWorker:function(){var h=new s(l.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new d("data_length")),p=this;return h.on("end",function(){if(this.streamInfo.data_length!==p.uncompressedSize)throw new Error("Bug : uncompressed data size mismatch")}),h},getCompressedWorker:function(){return new s(l.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize",this.compressedSize).withStreamInfo("uncompressedSize",this.uncompressedSize).withStreamInfo("crc32",this.crc32).withStreamInfo("compression",this.compression)}},v.createWorkerFrom=function(h,p,b){return h.pipe(new i).pipe(new d("uncompressedSize")).pipe(p.compressWorker(b)).pipe(new d("compressedSize")).withStreamInfo("compression",p)},o.exports=v},{"./external":6,"./stream/Crc32Probe":25,"./stream/DataLengthProbe":26,"./stream/DataWorker":27}],3:[function(r,o,a){var l=r("./stream/GenericWorker");a.STORE={magic:"\0\0",compressWorker:function(){return new l("STORE compression")},uncompressWorker:function(){return new l("STORE decompression")}},a.DEFLATE=r("./flate")},{"./flate":7,"./stream/GenericWorker":28}],4:[function(r,o,a){var l=r("./utils"),s=function(){for(var i,d=[],v=0;v<256;v++){i=v;for(var h=0;h<8;h++)i=1&i?3988292384^i>>>1:i>>>1;d[v]=i}return d}();o.exports=function(i,d){return i!==void 0&&i.length?l.getTypeOf(i)!=="string"?function(v,h,p,b){var m=s,E=b+p;v^=-1;for(var g=b;g<E;g++)v=v>>>8^m[255&(v^h[g])];return-1^v}(0|d,i,i.length,0):function(v,h,p,b){var m=s,E=b+p;v^=-1;for(var g=b;g<E;g++)v=v>>>8^m[255&(v^h.charCodeAt(g))];return-1^v}(0|d,i,i.length,0):0}},{"./utils":32}],5:[function(r,o,a){a.base64=!1,a.binary=!1,a.dir=!1,a.createFolders=!0,a.date=null,a.compression=null,a.compressionOptions=null,a.comment=null,a.unixPermissions=null,a.dosPermissions=null},{}],6:[function(r,o,a){var l=null;l=typeof Promise<"u"?Promise:r("lie"),o.exports={Promise:l}},{lie:37}],7:[function(r,o,a){var l=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Uint32Array<"u",s=r("pako"),i=r("./utils"),d=r("./stream/GenericWorker"),v=l?"uint8array":"array";function h(p,b){d.call(this,"FlateWorker/"+p),this._pako=null,this._pakoAction=p,this._pakoOptions=b,this.meta={}}a.magic="\b\0",i.inherits(h,d),h.prototype.processChunk=function(p){this.meta=p.meta,this._pako===null&&this._createPako(),this._pako.push(i.transformTo(v,p.data),!1)},h.prototype.flush=function(){d.prototype.flush.call(this),this._pako===null&&this._createPako(),this._pako.push([],!0)},h.prototype.cleanUp=function(){d.prototype.cleanUp.call(this),this._pako=null},h.prototype._createPako=function(){this._pako=new s[this._pakoAction]({raw:!0,level:this._pakoOptions.level||-1});var p=this;this._pako.onData=function(b){p.push({data:b,meta:p.meta})}},a.compressWorker=function(p){return new h("Deflate",p)},a.uncompressWorker=function(){return new h("Inflate",{})}},{"./stream/GenericWorker":28,"./utils":32,pako:38}],8:[function(r,o,a){function l(m,E){var g,C="";for(g=0;g<E;g++)C+=String.fromCharCode(255&m),m>>>=8;return C}function s(m,E,g,C,_,T){var I,L,R=m.file,Y=m.compression,$=T!==v.utf8encode,ee=i.transformTo("string",T(R.name)),N=i.transformTo("string",v.utf8encode(R.name)),ne=R.comment,ue=i.transformTo("string",T(ne)),z=i.transformTo("string",v.utf8encode(ne)),U=N.length!==R.name.length,f=z.length!==ne.length,j="",me="",H="",y=R.dir,w=R.date,D={crc32:0,compressedSize:0,uncompressedSize:0};E&&!g||(D.crc32=m.crc32,D.compressedSize=m.compressedSize,D.uncompressedSize=m.uncompressedSize);var x=0;E&&(x|=8),$||!U&&!f||(x|=2048);var S=0,F=0;y&&(S|=16),_==="UNIX"?(F=798,S|=function(M,Q){var K=M;return M||(K=Q?16893:33204),(65535&K)<<16}(R.unixPermissions,y)):(F=20,S|=function(M){return 63&(M||0)}(R.dosPermissions)),I=w.getUTCHours(),I<<=6,I|=w.getUTCMinutes(),I<<=5,I|=w.getUTCSeconds()/2,L=w.getUTCFullYear()-1980,L<<=4,L|=w.getUTCMonth()+1,L<<=5,L|=w.getUTCDate(),U&&(me=l(1,1)+l(h(ee),4)+N,j+="up"+l(me.length,2)+me),f&&(H=l(1,1)+l(h(ue),4)+z,j+="uc"+l(H.length,2)+H);var B="";return B+=`
52
+ \0`,B+=l(x,2),B+=Y.magic,B+=l(I,2),B+=l(L,2),B+=l(D.crc32,4),B+=l(D.compressedSize,4),B+=l(D.uncompressedSize,4),B+=l(ee.length,2),B+=l(j.length,2),{fileRecord:p.LOCAL_FILE_HEADER+B+ee+j,dirRecord:p.CENTRAL_FILE_HEADER+l(F,2)+B+l(ue.length,2)+"\0\0\0\0"+l(S,4)+l(C,4)+ee+j+ue}}var i=r("../utils"),d=r("../stream/GenericWorker"),v=r("../utf8"),h=r("../crc32"),p=r("../signature");function b(m,E,g,C){d.call(this,"ZipFileWorker"),this.bytesWritten=0,this.zipComment=E,this.zipPlatform=g,this.encodeFileName=C,this.streamFiles=m,this.accumulate=!1,this.contentBuffer=[],this.dirRecords=[],this.currentSourceOffset=0,this.entriesCount=0,this.currentFile=null,this._sources=[]}i.inherits(b,d),b.prototype.push=function(m){var E=m.meta.percent||0,g=this.entriesCount,C=this._sources.length;this.accumulate?this.contentBuffer.push(m):(this.bytesWritten+=m.data.length,d.prototype.push.call(this,{data:m.data,meta:{currentFile:this.currentFile,percent:g?(E+100*(g-C-1))/g:100}}))},b.prototype.openedSource=function(m){this.currentSourceOffset=this.bytesWritten,this.currentFile=m.file.name;var E=this.streamFiles&&!m.file.dir;if(E){var g=s(m,E,!1,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);this.push({data:g.fileRecord,meta:{percent:0}})}else this.accumulate=!0},b.prototype.closedSource=function(m){this.accumulate=!1;var E=this.streamFiles&&!m.file.dir,g=s(m,E,!0,this.currentSourceOffset,this.zipPlatform,this.encodeFileName);if(this.dirRecords.push(g.dirRecord),E)this.push({data:function(C){return p.DATA_DESCRIPTOR+l(C.crc32,4)+l(C.compressedSize,4)+l(C.uncompressedSize,4)}(m),meta:{percent:100}});else for(this.push({data:g.fileRecord,meta:{percent:0}});this.contentBuffer.length;)this.push(this.contentBuffer.shift());this.currentFile=null},b.prototype.flush=function(){for(var m=this.bytesWritten,E=0;E<this.dirRecords.length;E++)this.push({data:this.dirRecords[E],meta:{percent:100}});var g=this.bytesWritten-m,C=function(_,T,I,L,R){var Y=i.transformTo("string",R(L));return p.CENTRAL_DIRECTORY_END+"\0\0\0\0"+l(_,2)+l(_,2)+l(T,4)+l(I,4)+l(Y.length,2)+Y}(this.dirRecords.length,g,m,this.zipComment,this.encodeFileName);this.push({data:C,meta:{percent:100}})},b.prototype.prepareNextSource=function(){this.previous=this._sources.shift(),this.openedSource(this.previous.streamInfo),this.isPaused?this.previous.pause():this.previous.resume()},b.prototype.registerPrevious=function(m){this._sources.push(m);var E=this;return m.on("data",function(g){E.processChunk(g)}),m.on("end",function(){E.closedSource(E.previous.streamInfo),E._sources.length?E.prepareNextSource():E.end()}),m.on("error",function(g){E.error(g)}),this},b.prototype.resume=function(){return!!d.prototype.resume.call(this)&&(!this.previous&&this._sources.length?(this.prepareNextSource(),!0):this.previous||this._sources.length||this.generatedError?void 0:(this.end(),!0))},b.prototype.error=function(m){var E=this._sources;if(!d.prototype.error.call(this,m))return!1;for(var g=0;g<E.length;g++)try{E[g].error(m)}catch{}return!0},b.prototype.lock=function(){d.prototype.lock.call(this);for(var m=this._sources,E=0;E<m.length;E++)m[E].lock()},o.exports=b},{"../crc32":4,"../signature":23,"../stream/GenericWorker":28,"../utf8":31,"../utils":32}],9:[function(r,o,a){var l=r("../compressions"),s=r("./ZipFileWorker");a.generateWorker=function(i,d,v){var h=new s(d.streamFiles,v,d.platform,d.encodeFileName),p=0;try{i.forEach(function(b,m){p++;var E=function(T,I){var L=T||I,R=l[L];if(!R)throw new Error(L+" is not a valid compression method !");return R}(m.options.compression,d.compression),g=m.options.compressionOptions||d.compressionOptions||{},C=m.dir,_=m.date;m._compressWorker(E,g).withStreamInfo("file",{name:b,dir:C,date:_,comment:m.comment||"",unixPermissions:m.unixPermissions,dosPermissions:m.dosPermissions}).pipe(h)}),h.entriesCount=p}catch(b){h.error(b)}return h}},{"../compressions":3,"./ZipFileWorker":8}],10:[function(r,o,a){function l(){if(!(this instanceof l))return new l;if(arguments.length)throw new Error("The constructor with parameters has been removed in JSZip 3.0, please check the upgrade guide.");this.files=Object.create(null),this.comment=null,this.root="",this.clone=function(){var s=new l;for(var i in this)typeof this[i]!="function"&&(s[i]=this[i]);return s}}(l.prototype=r("./object")).loadAsync=r("./load"),l.support=r("./support"),l.defaults=r("./defaults"),l.version="3.10.1",l.loadAsync=function(s,i){return new l().loadAsync(s,i)},l.external=r("./external"),o.exports=l},{"./defaults":5,"./external":6,"./load":11,"./object":15,"./support":30}],11:[function(r,o,a){var l=r("./utils"),s=r("./external"),i=r("./utf8"),d=r("./zipEntries"),v=r("./stream/Crc32Probe"),h=r("./nodejsUtils");function p(b){return new s.Promise(function(m,E){var g=b.decompressed.getContentWorker().pipe(new v);g.on("error",function(C){E(C)}).on("end",function(){g.streamInfo.crc32!==b.decompressed.crc32?E(new Error("Corrupted zip : CRC32 mismatch")):m()}).resume()})}o.exports=function(b,m){var E=this;return m=l.extend(m||{},{base64:!1,checkCRC32:!1,optimizedBinaryString:!1,createFolders:!1,decodeFileName:i.utf8decode}),h.isNode&&h.isStream(b)?s.Promise.reject(new Error("JSZip can't accept a stream when loading a zip file.")):l.prepareContent("the loaded zip file",b,!0,m.optimizedBinaryString,m.base64).then(function(g){var C=new d(m);return C.load(g),C}).then(function(g){var C=[s.Promise.resolve(g)],_=g.files;if(m.checkCRC32)for(var T=0;T<_.length;T++)C.push(p(_[T]));return s.Promise.all(C)}).then(function(g){for(var C=g.shift(),_=C.files,T=0;T<_.length;T++){var I=_[T],L=I.fileNameStr,R=l.resolve(I.fileNameStr);E.file(R,I.decompressed,{binary:!0,optimizedBinaryString:!0,date:I.date,dir:I.dir,comment:I.fileCommentStr.length?I.fileCommentStr:null,unixPermissions:I.unixPermissions,dosPermissions:I.dosPermissions,createFolders:m.createFolders}),I.dir||(E.file(R).unsafeOriginalName=L)}return C.zipComment.length&&(E.comment=C.zipComment),E})}},{"./external":6,"./nodejsUtils":14,"./stream/Crc32Probe":25,"./utf8":31,"./utils":32,"./zipEntries":33}],12:[function(r,o,a){var l=r("../utils"),s=r("../stream/GenericWorker");function i(d,v){s.call(this,"Nodejs stream input adapter for "+d),this._upstreamEnded=!1,this._bindStream(v)}l.inherits(i,s),i.prototype._bindStream=function(d){var v=this;(this._stream=d).pause(),d.on("data",function(h){v.push({data:h,meta:{percent:0}})}).on("error",function(h){v.isPaused?this.generatedError=h:v.error(h)}).on("end",function(){v.isPaused?v._upstreamEnded=!0:v.end()})},i.prototype.pause=function(){return!!s.prototype.pause.call(this)&&(this._stream.pause(),!0)},i.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(this._upstreamEnded?this.end():this._stream.resume(),!0)},o.exports=i},{"../stream/GenericWorker":28,"../utils":32}],13:[function(r,o,a){var l=r("readable-stream").Readable;function s(i,d,v){l.call(this,d),this._helper=i;var h=this;i.on("data",function(p,b){h.push(p)||h._helper.pause(),v&&v(b)}).on("error",function(p){h.emit("error",p)}).on("end",function(){h.push(null)})}r("../utils").inherits(s,l),s.prototype._read=function(){this._helper.resume()},o.exports=s},{"../utils":32,"readable-stream":16}],14:[function(r,o,a){o.exports={isNode:typeof Buffer<"u",newBufferFrom:function(l,s){if(Buffer.from&&Buffer.from!==Uint8Array.from)return Buffer.from(l,s);if(typeof l=="number")throw new Error('The "data" argument must not be a number');return new Buffer(l,s)},allocBuffer:function(l){if(Buffer.alloc)return Buffer.alloc(l);var s=new Buffer(l);return s.fill(0),s},isBuffer:function(l){return Buffer.isBuffer(l)},isStream:function(l){return l&&typeof l.on=="function"&&typeof l.pause=="function"&&typeof l.resume=="function"}}},{}],15:[function(r,o,a){function l(R,Y,$){var ee,N=i.getTypeOf(Y),ne=i.extend($||{},h);ne.date=ne.date||new Date,ne.compression!==null&&(ne.compression=ne.compression.toUpperCase()),typeof ne.unixPermissions=="string"&&(ne.unixPermissions=parseInt(ne.unixPermissions,8)),ne.unixPermissions&&16384&ne.unixPermissions&&(ne.dir=!0),ne.dosPermissions&&16&ne.dosPermissions&&(ne.dir=!0),ne.dir&&(R=_(R)),ne.createFolders&&(ee=C(R))&&T.call(this,ee,!0);var ue=N==="string"&&ne.binary===!1&&ne.base64===!1;$&&$.binary!==void 0||(ne.binary=!ue),(Y instanceof p&&Y.uncompressedSize===0||ne.dir||!Y||Y.length===0)&&(ne.base64=!1,ne.binary=!0,Y="",ne.compression="STORE",N="string");var z=null;z=Y instanceof p||Y instanceof d?Y:E.isNode&&E.isStream(Y)?new g(R,Y):i.prepareContent(R,Y,ne.binary,ne.optimizedBinaryString,ne.base64);var U=new b(R,z,ne);this.files[R]=U}var s=r("./utf8"),i=r("./utils"),d=r("./stream/GenericWorker"),v=r("./stream/StreamHelper"),h=r("./defaults"),p=r("./compressedObject"),b=r("./zipObject"),m=r("./generate"),E=r("./nodejsUtils"),g=r("./nodejs/NodejsStreamInputAdapter"),C=function(R){R.slice(-1)==="/"&&(R=R.substring(0,R.length-1));var Y=R.lastIndexOf("/");return 0<Y?R.substring(0,Y):""},_=function(R){return R.slice(-1)!=="/"&&(R+="/"),R},T=function(R,Y){return Y=Y!==void 0?Y:h.createFolders,R=_(R),this.files[R]||l.call(this,R,null,{dir:!0,createFolders:Y}),this.files[R]};function I(R){return Object.prototype.toString.call(R)==="[object RegExp]"}var L={load:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},forEach:function(R){var Y,$,ee;for(Y in this.files)ee=this.files[Y],($=Y.slice(this.root.length,Y.length))&&Y.slice(0,this.root.length)===this.root&&R($,ee)},filter:function(R){var Y=[];return this.forEach(function($,ee){R($,ee)&&Y.push(ee)}),Y},file:function(R,Y,$){if(arguments.length!==1)return R=this.root+R,l.call(this,R,Y,$),this;if(I(R)){var ee=R;return this.filter(function(ne,ue){return!ue.dir&&ee.test(ne)})}var N=this.files[this.root+R];return N&&!N.dir?N:null},folder:function(R){if(!R)return this;if(I(R))return this.filter(function(N,ne){return ne.dir&&R.test(N)});var Y=this.root+R,$=T.call(this,Y),ee=this.clone();return ee.root=$.name,ee},remove:function(R){R=this.root+R;var Y=this.files[R];if(Y||(R.slice(-1)!=="/"&&(R+="/"),Y=this.files[R]),Y&&!Y.dir)delete this.files[R];else for(var $=this.filter(function(N,ne){return ne.name.slice(0,R.length)===R}),ee=0;ee<$.length;ee++)delete this.files[$[ee].name];return this},generate:function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},generateInternalStream:function(R){var Y,$={};try{if(($=i.extend(R||{},{streamFiles:!1,compression:"STORE",compressionOptions:null,type:"",platform:"DOS",comment:null,mimeType:"application/zip",encodeFileName:s.utf8encode})).type=$.type.toLowerCase(),$.compression=$.compression.toUpperCase(),$.type==="binarystring"&&($.type="string"),!$.type)throw new Error("No output type specified.");i.checkSupport($.type),$.platform!=="darwin"&&$.platform!=="freebsd"&&$.platform!=="linux"&&$.platform!=="sunos"||($.platform="UNIX"),$.platform==="win32"&&($.platform="DOS");var ee=$.comment||this.comment||"";Y=m.generateWorker(this,$,ee)}catch(N){(Y=new d("error")).error(N)}return new v(Y,$.type||"string",$.mimeType)},generateAsync:function(R,Y){return this.generateInternalStream(R).accumulate(Y)},generateNodeStream:function(R,Y){return(R=R||{}).type||(R.type="nodebuffer"),this.generateInternalStream(R).toNodejsStream(Y)}};o.exports=L},{"./compressedObject":2,"./defaults":5,"./generate":9,"./nodejs/NodejsStreamInputAdapter":12,"./nodejsUtils":14,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31,"./utils":32,"./zipObject":35}],16:[function(r,o,a){o.exports=r("stream")},{stream:void 0}],17:[function(r,o,a){var l=r("./DataReader");function s(i){l.call(this,i);for(var d=0;d<this.data.length;d++)i[d]=255&i[d]}r("../utils").inherits(s,l),s.prototype.byteAt=function(i){return this.data[this.zero+i]},s.prototype.lastIndexOfSignature=function(i){for(var d=i.charCodeAt(0),v=i.charCodeAt(1),h=i.charCodeAt(2),p=i.charCodeAt(3),b=this.length-4;0<=b;--b)if(this.data[b]===d&&this.data[b+1]===v&&this.data[b+2]===h&&this.data[b+3]===p)return b-this.zero;return-1},s.prototype.readAndCheckSignature=function(i){var d=i.charCodeAt(0),v=i.charCodeAt(1),h=i.charCodeAt(2),p=i.charCodeAt(3),b=this.readData(4);return d===b[0]&&v===b[1]&&h===b[2]&&p===b[3]},s.prototype.readData=function(i){if(this.checkOffset(i),i===0)return[];var d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},o.exports=s},{"../utils":32,"./DataReader":18}],18:[function(r,o,a){var l=r("../utils");function s(i){this.data=i,this.length=i.length,this.index=0,this.zero=0}s.prototype={checkOffset:function(i){this.checkIndex(this.index+i)},checkIndex:function(i){if(this.length<this.zero+i||i<0)throw new Error("End of data reached (data length = "+this.length+", asked index = "+i+"). Corrupted zip ?")},setIndex:function(i){this.checkIndex(i),this.index=i},skip:function(i){this.setIndex(this.index+i)},byteAt:function(){},readInt:function(i){var d,v=0;for(this.checkOffset(i),d=this.index+i-1;d>=this.index;d--)v=(v<<8)+this.byteAt(d);return this.index+=i,v},readString:function(i){return l.transformTo("string",this.readData(i))},readData:function(){},lastIndexOfSignature:function(){},readAndCheckSignature:function(){},readDate:function(){var i=this.readInt(4);return new Date(Date.UTC(1980+(i>>25&127),(i>>21&15)-1,i>>16&31,i>>11&31,i>>5&63,(31&i)<<1))}},o.exports=s},{"../utils":32}],19:[function(r,o,a){var l=r("./Uint8ArrayReader");function s(i){l.call(this,i)}r("../utils").inherits(s,l),s.prototype.readData=function(i){this.checkOffset(i);var d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},o.exports=s},{"../utils":32,"./Uint8ArrayReader":21}],20:[function(r,o,a){var l=r("./DataReader");function s(i){l.call(this,i)}r("../utils").inherits(s,l),s.prototype.byteAt=function(i){return this.data.charCodeAt(this.zero+i)},s.prototype.lastIndexOfSignature=function(i){return this.data.lastIndexOf(i)-this.zero},s.prototype.readAndCheckSignature=function(i){return i===this.readData(4)},s.prototype.readData=function(i){this.checkOffset(i);var d=this.data.slice(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},o.exports=s},{"../utils":32,"./DataReader":18}],21:[function(r,o,a){var l=r("./ArrayReader");function s(i){l.call(this,i)}r("../utils").inherits(s,l),s.prototype.readData=function(i){if(this.checkOffset(i),i===0)return new Uint8Array(0);var d=this.data.subarray(this.zero+this.index,this.zero+this.index+i);return this.index+=i,d},o.exports=s},{"../utils":32,"./ArrayReader":17}],22:[function(r,o,a){var l=r("../utils"),s=r("../support"),i=r("./ArrayReader"),d=r("./StringReader"),v=r("./NodeBufferReader"),h=r("./Uint8ArrayReader");o.exports=function(p){var b=l.getTypeOf(p);return l.checkSupport(b),b!=="string"||s.uint8array?b==="nodebuffer"?new v(p):s.uint8array?new h(l.transformTo("uint8array",p)):new i(l.transformTo("array",p)):new d(p)}},{"../support":30,"../utils":32,"./ArrayReader":17,"./NodeBufferReader":19,"./StringReader":20,"./Uint8ArrayReader":21}],23:[function(r,o,a){a.LOCAL_FILE_HEADER="PK",a.CENTRAL_FILE_HEADER="PK",a.CENTRAL_DIRECTORY_END="PK",a.ZIP64_CENTRAL_DIRECTORY_LOCATOR="PK\x07",a.ZIP64_CENTRAL_DIRECTORY_END="PK",a.DATA_DESCRIPTOR="PK\x07\b"},{}],24:[function(r,o,a){var l=r("./GenericWorker"),s=r("../utils");function i(d){l.call(this,"ConvertWorker to "+d),this.destType=d}s.inherits(i,l),i.prototype.processChunk=function(d){this.push({data:s.transformTo(this.destType,d.data),meta:d.meta})},o.exports=i},{"../utils":32,"./GenericWorker":28}],25:[function(r,o,a){var l=r("./GenericWorker"),s=r("../crc32");function i(){l.call(this,"Crc32Probe"),this.withStreamInfo("crc32",0)}r("../utils").inherits(i,l),i.prototype.processChunk=function(d){this.streamInfo.crc32=s(d.data,this.streamInfo.crc32||0),this.push(d)},o.exports=i},{"../crc32":4,"../utils":32,"./GenericWorker":28}],26:[function(r,o,a){var l=r("../utils"),s=r("./GenericWorker");function i(d){s.call(this,"DataLengthProbe for "+d),this.propName=d,this.withStreamInfo(d,0)}l.inherits(i,s),i.prototype.processChunk=function(d){if(d){var v=this.streamInfo[this.propName]||0;this.streamInfo[this.propName]=v+d.data.length}s.prototype.processChunk.call(this,d)},o.exports=i},{"../utils":32,"./GenericWorker":28}],27:[function(r,o,a){var l=r("../utils"),s=r("./GenericWorker");function i(d){s.call(this,"DataWorker");var v=this;this.dataIsReady=!1,this.index=0,this.max=0,this.data=null,this.type="",this._tickScheduled=!1,d.then(function(h){v.dataIsReady=!0,v.data=h,v.max=h&&h.length||0,v.type=l.getTypeOf(h),v.isPaused||v._tickAndRepeat()},function(h){v.error(h)})}l.inherits(i,s),i.prototype.cleanUp=function(){s.prototype.cleanUp.call(this),this.data=null},i.prototype.resume=function(){return!!s.prototype.resume.call(this)&&(!this._tickScheduled&&this.dataIsReady&&(this._tickScheduled=!0,l.delay(this._tickAndRepeat,[],this)),!0)},i.prototype._tickAndRepeat=function(){this._tickScheduled=!1,this.isPaused||this.isFinished||(this._tick(),this.isFinished||(l.delay(this._tickAndRepeat,[],this),this._tickScheduled=!0))},i.prototype._tick=function(){if(this.isPaused||this.isFinished)return!1;var d=null,v=Math.min(this.max,this.index+16384);if(this.index>=this.max)return this.end();switch(this.type){case"string":d=this.data.substring(this.index,v);break;case"uint8array":d=this.data.subarray(this.index,v);break;case"array":case"nodebuffer":d=this.data.slice(this.index,v)}return this.index=v,this.push({data:d,meta:{percent:this.max?this.index/this.max*100:0}})},o.exports=i},{"../utils":32,"./GenericWorker":28}],28:[function(r,o,a){function l(s){this.name=s||"default",this.streamInfo={},this.generatedError=null,this.extraStreamInfo={},this.isPaused=!0,this.isFinished=!1,this.isLocked=!1,this._listeners={data:[],end:[],error:[]},this.previous=null}l.prototype={push:function(s){this.emit("data",s)},end:function(){if(this.isFinished)return!1;this.flush();try{this.emit("end"),this.cleanUp(),this.isFinished=!0}catch(s){this.emit("error",s)}return!0},error:function(s){return!this.isFinished&&(this.isPaused?this.generatedError=s:(this.isFinished=!0,this.emit("error",s),this.previous&&this.previous.error(s),this.cleanUp()),!0)},on:function(s,i){return this._listeners[s].push(i),this},cleanUp:function(){this.streamInfo=this.generatedError=this.extraStreamInfo=null,this._listeners=[]},emit:function(s,i){if(this._listeners[s])for(var d=0;d<this._listeners[s].length;d++)this._listeners[s][d].call(this,i)},pipe:function(s){return s.registerPrevious(this)},registerPrevious:function(s){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.streamInfo=s.streamInfo,this.mergeStreamInfo(),this.previous=s;var i=this;return s.on("data",function(d){i.processChunk(d)}),s.on("end",function(){i.end()}),s.on("error",function(d){i.error(d)}),this},pause:function(){return!this.isPaused&&!this.isFinished&&(this.isPaused=!0,this.previous&&this.previous.pause(),!0)},resume:function(){if(!this.isPaused||this.isFinished)return!1;var s=this.isPaused=!1;return this.generatedError&&(this.error(this.generatedError),s=!0),this.previous&&this.previous.resume(),!s},flush:function(){},processChunk:function(s){this.push(s)},withStreamInfo:function(s,i){return this.extraStreamInfo[s]=i,this.mergeStreamInfo(),this},mergeStreamInfo:function(){for(var s in this.extraStreamInfo)Object.prototype.hasOwnProperty.call(this.extraStreamInfo,s)&&(this.streamInfo[s]=this.extraStreamInfo[s])},lock:function(){if(this.isLocked)throw new Error("The stream '"+this+"' has already been used.");this.isLocked=!0,this.previous&&this.previous.lock()},toString:function(){var s="Worker "+this.name;return this.previous?this.previous+" -> "+s:s}},o.exports=l},{}],29:[function(r,o,a){var l=r("../utils"),s=r("./ConvertWorker"),i=r("./GenericWorker"),d=r("../base64"),v=r("../support"),h=r("../external"),p=null;if(v.nodestream)try{p=r("../nodejs/NodejsStreamOutputAdapter")}catch{}function b(E,g){return new h.Promise(function(C,_){var T=[],I=E._internalType,L=E._outputType,R=E._mimeType;E.on("data",function(Y,$){T.push(Y),g&&g($)}).on("error",function(Y){T=[],_(Y)}).on("end",function(){try{var Y=function($,ee,N){switch($){case"blob":return l.newBlob(l.transformTo("arraybuffer",ee),N);case"base64":return d.encode(ee);default:return l.transformTo($,ee)}}(L,function($,ee){var N,ne=0,ue=null,z=0;for(N=0;N<ee.length;N++)z+=ee[N].length;switch($){case"string":return ee.join("");case"array":return Array.prototype.concat.apply([],ee);case"uint8array":for(ue=new Uint8Array(z),N=0;N<ee.length;N++)ue.set(ee[N],ne),ne+=ee[N].length;return ue;case"nodebuffer":return Buffer.concat(ee);default:throw new Error("concat : unsupported type '"+$+"'")}}(I,T),R);C(Y)}catch($){_($)}T=[]}).resume()})}function m(E,g,C){var _=g;switch(g){case"blob":case"arraybuffer":_="uint8array";break;case"base64":_="string"}try{this._internalType=_,this._outputType=g,this._mimeType=C,l.checkSupport(_),this._worker=E.pipe(new s(_)),E.lock()}catch(T){this._worker=new i("error"),this._worker.error(T)}}m.prototype={accumulate:function(E){return b(this,E)},on:function(E,g){var C=this;return E==="data"?this._worker.on(E,function(_){g.call(C,_.data,_.meta)}):this._worker.on(E,function(){l.delay(g,arguments,C)}),this},resume:function(){return l.delay(this._worker.resume,[],this._worker),this},pause:function(){return this._worker.pause(),this},toNodejsStream:function(E){if(l.checkSupport("nodestream"),this._outputType!=="nodebuffer")throw new Error(this._outputType+" is not supported by this method");return new p(this,{objectMode:this._outputType!=="nodebuffer"},E)}},o.exports=m},{"../base64":1,"../external":6,"../nodejs/NodejsStreamOutputAdapter":13,"../support":30,"../utils":32,"./ConvertWorker":24,"./GenericWorker":28}],30:[function(r,o,a){if(a.base64=!0,a.array=!0,a.string=!0,a.arraybuffer=typeof ArrayBuffer<"u"&&typeof Uint8Array<"u",a.nodebuffer=typeof Buffer<"u",a.uint8array=typeof Uint8Array<"u",typeof ArrayBuffer>"u")a.blob=!1;else{var l=new ArrayBuffer(0);try{a.blob=new Blob([l],{type:"application/zip"}).size===0}catch{try{var s=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);s.append(l),a.blob=s.getBlob("application/zip").size===0}catch{a.blob=!1}}}try{a.nodestream=!!r("readable-stream").Readable}catch{a.nodestream=!1}},{"readable-stream":16}],31:[function(r,o,a){for(var l=r("./utils"),s=r("./support"),i=r("./nodejsUtils"),d=r("./stream/GenericWorker"),v=new Array(256),h=0;h<256;h++)v[h]=252<=h?6:248<=h?5:240<=h?4:224<=h?3:192<=h?2:1;v[254]=v[254]=1;function p(){d.call(this,"utf-8 decode"),this.leftOver=null}function b(){d.call(this,"utf-8 encode")}a.utf8encode=function(m){return s.nodebuffer?i.newBufferFrom(m,"utf-8"):function(E){var g,C,_,T,I,L=E.length,R=0;for(T=0;T<L;T++)(64512&(C=E.charCodeAt(T)))==55296&&T+1<L&&(64512&(_=E.charCodeAt(T+1)))==56320&&(C=65536+(C-55296<<10)+(_-56320),T++),R+=C<128?1:C<2048?2:C<65536?3:4;for(g=s.uint8array?new Uint8Array(R):new Array(R),T=I=0;I<R;T++)(64512&(C=E.charCodeAt(T)))==55296&&T+1<L&&(64512&(_=E.charCodeAt(T+1)))==56320&&(C=65536+(C-55296<<10)+(_-56320),T++),C<128?g[I++]=C:(C<2048?g[I++]=192|C>>>6:(C<65536?g[I++]=224|C>>>12:(g[I++]=240|C>>>18,g[I++]=128|C>>>12&63),g[I++]=128|C>>>6&63),g[I++]=128|63&C);return g}(m)},a.utf8decode=function(m){return s.nodebuffer?l.transformTo("nodebuffer",m).toString("utf-8"):function(E){var g,C,_,T,I=E.length,L=new Array(2*I);for(g=C=0;g<I;)if((_=E[g++])<128)L[C++]=_;else if(4<(T=v[_]))L[C++]=65533,g+=T-1;else{for(_&=T===2?31:T===3?15:7;1<T&&g<I;)_=_<<6|63&E[g++],T--;1<T?L[C++]=65533:_<65536?L[C++]=_:(_-=65536,L[C++]=55296|_>>10&1023,L[C++]=56320|1023&_)}return L.length!==C&&(L.subarray?L=L.subarray(0,C):L.length=C),l.applyFromCharCode(L)}(m=l.transformTo(s.uint8array?"uint8array":"array",m))},l.inherits(p,d),p.prototype.processChunk=function(m){var E=l.transformTo(s.uint8array?"uint8array":"array",m.data);if(this.leftOver&&this.leftOver.length){if(s.uint8array){var g=E;(E=new Uint8Array(g.length+this.leftOver.length)).set(this.leftOver,0),E.set(g,this.leftOver.length)}else E=this.leftOver.concat(E);this.leftOver=null}var C=function(T,I){var L;for((I=I||T.length)>T.length&&(I=T.length),L=I-1;0<=L&&(192&T[L])==128;)L--;return L<0||L===0?I:L+v[T[L]]>I?L:I}(E),_=E;C!==E.length&&(s.uint8array?(_=E.subarray(0,C),this.leftOver=E.subarray(C,E.length)):(_=E.slice(0,C),this.leftOver=E.slice(C,E.length))),this.push({data:a.utf8decode(_),meta:m.meta})},p.prototype.flush=function(){this.leftOver&&this.leftOver.length&&(this.push({data:a.utf8decode(this.leftOver),meta:{}}),this.leftOver=null)},a.Utf8DecodeWorker=p,l.inherits(b,d),b.prototype.processChunk=function(m){this.push({data:a.utf8encode(m.data),meta:m.meta})},a.Utf8EncodeWorker=b},{"./nodejsUtils":14,"./stream/GenericWorker":28,"./support":30,"./utils":32}],32:[function(r,o,a){var l=r("./support"),s=r("./base64"),i=r("./nodejsUtils"),d=r("./external");function v(g){return g}function h(g,C){for(var _=0;_<g.length;++_)C[_]=255&g.charCodeAt(_);return C}r("setimmediate"),a.newBlob=function(g,C){a.checkSupport("blob");try{return new Blob([g],{type:C})}catch{try{var _=new(self.BlobBuilder||self.WebKitBlobBuilder||self.MozBlobBuilder||self.MSBlobBuilder);return _.append(g),_.getBlob(C)}catch{throw new Error("Bug : can't construct the Blob.")}}};var p={stringifyByChunk:function(g,C,_){var T=[],I=0,L=g.length;if(L<=_)return String.fromCharCode.apply(null,g);for(;I<L;)C==="array"||C==="nodebuffer"?T.push(String.fromCharCode.apply(null,g.slice(I,Math.min(I+_,L)))):T.push(String.fromCharCode.apply(null,g.subarray(I,Math.min(I+_,L)))),I+=_;return T.join("")},stringifyByChar:function(g){for(var C="",_=0;_<g.length;_++)C+=String.fromCharCode(g[_]);return C},applyCanBeUsed:{uint8array:function(){try{return l.uint8array&&String.fromCharCode.apply(null,new Uint8Array(1)).length===1}catch{return!1}}(),nodebuffer:function(){try{return l.nodebuffer&&String.fromCharCode.apply(null,i.allocBuffer(1)).length===1}catch{return!1}}()}};function b(g){var C=65536,_=a.getTypeOf(g),T=!0;if(_==="uint8array"?T=p.applyCanBeUsed.uint8array:_==="nodebuffer"&&(T=p.applyCanBeUsed.nodebuffer),T)for(;1<C;)try{return p.stringifyByChunk(g,_,C)}catch{C=Math.floor(C/2)}return p.stringifyByChar(g)}function m(g,C){for(var _=0;_<g.length;_++)C[_]=g[_];return C}a.applyFromCharCode=b;var E={};E.string={string:v,array:function(g){return h(g,new Array(g.length))},arraybuffer:function(g){return E.string.uint8array(g).buffer},uint8array:function(g){return h(g,new Uint8Array(g.length))},nodebuffer:function(g){return h(g,i.allocBuffer(g.length))}},E.array={string:b,array:v,arraybuffer:function(g){return new Uint8Array(g).buffer},uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return i.newBufferFrom(g)}},E.arraybuffer={string:function(g){return b(new Uint8Array(g))},array:function(g){return m(new Uint8Array(g),new Array(g.byteLength))},arraybuffer:v,uint8array:function(g){return new Uint8Array(g)},nodebuffer:function(g){return i.newBufferFrom(new Uint8Array(g))}},E.uint8array={string:b,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return g.buffer},uint8array:v,nodebuffer:function(g){return i.newBufferFrom(g)}},E.nodebuffer={string:b,array:function(g){return m(g,new Array(g.length))},arraybuffer:function(g){return E.nodebuffer.uint8array(g).buffer},uint8array:function(g){return m(g,new Uint8Array(g.length))},nodebuffer:v},a.transformTo=function(g,C){if(C=C||"",!g)return C;a.checkSupport(g);var _=a.getTypeOf(C);return E[_][g](C)},a.resolve=function(g){for(var C=g.split("/"),_=[],T=0;T<C.length;T++){var I=C[T];I==="."||I===""&&T!==0&&T!==C.length-1||(I===".."?_.pop():_.push(I))}return _.join("/")},a.getTypeOf=function(g){return typeof g=="string"?"string":Object.prototype.toString.call(g)==="[object Array]"?"array":l.nodebuffer&&i.isBuffer(g)?"nodebuffer":l.uint8array&&g instanceof Uint8Array?"uint8array":l.arraybuffer&&g instanceof ArrayBuffer?"arraybuffer":void 0},a.checkSupport=function(g){if(!l[g.toLowerCase()])throw new Error(g+" is not supported by this platform")},a.MAX_VALUE_16BITS=65535,a.MAX_VALUE_32BITS=-1,a.pretty=function(g){var C,_,T="";for(_=0;_<(g||"").length;_++)T+="\\x"+((C=g.charCodeAt(_))<16?"0":"")+C.toString(16).toUpperCase();return T},a.delay=function(g,C,_){setImmediate(function(){g.apply(_||null,C||[])})},a.inherits=function(g,C){function _(){}_.prototype=C.prototype,g.prototype=new _},a.extend=function(){var g,C,_={};for(g=0;g<arguments.length;g++)for(C in arguments[g])Object.prototype.hasOwnProperty.call(arguments[g],C)&&_[C]===void 0&&(_[C]=arguments[g][C]);return _},a.prepareContent=function(g,C,_,T,I){return d.Promise.resolve(C).then(function(L){return l.blob&&(L instanceof Blob||["[object File]","[object Blob]"].indexOf(Object.prototype.toString.call(L))!==-1)&&typeof FileReader<"u"?new d.Promise(function(R,Y){var $=new FileReader;$.onload=function(ee){R(ee.target.result)},$.onerror=function(ee){Y(ee.target.error)},$.readAsArrayBuffer(L)}):L}).then(function(L){var R=a.getTypeOf(L);return R?(R==="arraybuffer"?L=a.transformTo("uint8array",L):R==="string"&&(I?L=s.decode(L):_&&T!==!0&&(L=function(Y){return h(Y,l.uint8array?new Uint8Array(Y.length):new Array(Y.length))}(L))),L):d.Promise.reject(new Error("Can't read the data of '"+g+"'. Is it in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?"))})}},{"./base64":1,"./external":6,"./nodejsUtils":14,"./support":30,setimmediate:54}],33:[function(r,o,a){var l=r("./reader/readerFor"),s=r("./utils"),i=r("./signature"),d=r("./zipEntry"),v=r("./support");function h(p){this.files=[],this.loadOptions=p}h.prototype={checkSignature:function(p){if(!this.reader.readAndCheckSignature(p)){this.reader.index-=4;var b=this.reader.readString(4);throw new Error("Corrupted zip or bug: unexpected signature ("+s.pretty(b)+", expected "+s.pretty(p)+")")}},isSignature:function(p,b){var m=this.reader.index;this.reader.setIndex(p);var E=this.reader.readString(4)===b;return this.reader.setIndex(m),E},readBlockEndOfCentral:function(){this.diskNumber=this.reader.readInt(2),this.diskWithCentralDirStart=this.reader.readInt(2),this.centralDirRecordsOnThisDisk=this.reader.readInt(2),this.centralDirRecords=this.reader.readInt(2),this.centralDirSize=this.reader.readInt(4),this.centralDirOffset=this.reader.readInt(4),this.zipCommentLength=this.reader.readInt(2);var p=this.reader.readData(this.zipCommentLength),b=v.uint8array?"uint8array":"array",m=s.transformTo(b,p);this.zipComment=this.loadOptions.decodeFileName(m)},readBlockZip64EndOfCentral:function(){this.zip64EndOfCentralSize=this.reader.readInt(8),this.reader.skip(4),this.diskNumber=this.reader.readInt(4),this.diskWithCentralDirStart=this.reader.readInt(4),this.centralDirRecordsOnThisDisk=this.reader.readInt(8),this.centralDirRecords=this.reader.readInt(8),this.centralDirSize=this.reader.readInt(8),this.centralDirOffset=this.reader.readInt(8),this.zip64ExtensibleData={};for(var p,b,m,E=this.zip64EndOfCentralSize-44;0<E;)p=this.reader.readInt(2),b=this.reader.readInt(4),m=this.reader.readData(b),this.zip64ExtensibleData[p]={id:p,length:b,value:m}},readBlockZip64EndOfCentralLocator:function(){if(this.diskWithZip64CentralDirStart=this.reader.readInt(4),this.relativeOffsetEndOfZip64CentralDir=this.reader.readInt(8),this.disksCount=this.reader.readInt(4),1<this.disksCount)throw new Error("Multi-volumes zip are not supported")},readLocalFiles:function(){var p,b;for(p=0;p<this.files.length;p++)b=this.files[p],this.reader.setIndex(b.localHeaderOffset),this.checkSignature(i.LOCAL_FILE_HEADER),b.readLocalPart(this.reader),b.handleUTF8(),b.processAttributes()},readCentralDir:function(){var p;for(this.reader.setIndex(this.centralDirOffset);this.reader.readAndCheckSignature(i.CENTRAL_FILE_HEADER);)(p=new d({zip64:this.zip64},this.loadOptions)).readCentralPart(this.reader),this.files.push(p);if(this.centralDirRecords!==this.files.length&&this.centralDirRecords!==0&&this.files.length===0)throw new Error("Corrupted zip or bug: expected "+this.centralDirRecords+" records in central dir, got "+this.files.length)},readEndOfCentral:function(){var p=this.reader.lastIndexOfSignature(i.CENTRAL_DIRECTORY_END);if(p<0)throw this.isSignature(0,i.LOCAL_FILE_HEADER)?new Error("Corrupted zip: can't find end of central directory"):new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");this.reader.setIndex(p);var b=p;if(this.checkSignature(i.CENTRAL_DIRECTORY_END),this.readBlockEndOfCentral(),this.diskNumber===s.MAX_VALUE_16BITS||this.diskWithCentralDirStart===s.MAX_VALUE_16BITS||this.centralDirRecordsOnThisDisk===s.MAX_VALUE_16BITS||this.centralDirRecords===s.MAX_VALUE_16BITS||this.centralDirSize===s.MAX_VALUE_32BITS||this.centralDirOffset===s.MAX_VALUE_32BITS){if(this.zip64=!0,(p=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR))<0)throw new Error("Corrupted zip: can't find the ZIP64 end of central directory locator");if(this.reader.setIndex(p),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_LOCATOR),this.readBlockZip64EndOfCentralLocator(),!this.isSignature(this.relativeOffsetEndOfZip64CentralDir,i.ZIP64_CENTRAL_DIRECTORY_END)&&(this.relativeOffsetEndOfZip64CentralDir=this.reader.lastIndexOfSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.relativeOffsetEndOfZip64CentralDir<0))throw new Error("Corrupted zip: can't find the ZIP64 end of central directory");this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir),this.checkSignature(i.ZIP64_CENTRAL_DIRECTORY_END),this.readBlockZip64EndOfCentral()}var m=this.centralDirOffset+this.centralDirSize;this.zip64&&(m+=20,m+=12+this.zip64EndOfCentralSize);var E=b-m;if(0<E)this.isSignature(b,i.CENTRAL_FILE_HEADER)||(this.reader.zero=E);else if(E<0)throw new Error("Corrupted zip: missing "+Math.abs(E)+" bytes.")},prepareReader:function(p){this.reader=l(p)},load:function(p){this.prepareReader(p),this.readEndOfCentral(),this.readCentralDir(),this.readLocalFiles()}},o.exports=h},{"./reader/readerFor":22,"./signature":23,"./support":30,"./utils":32,"./zipEntry":34}],34:[function(r,o,a){var l=r("./reader/readerFor"),s=r("./utils"),i=r("./compressedObject"),d=r("./crc32"),v=r("./utf8"),h=r("./compressions"),p=r("./support");function b(m,E){this.options=m,this.loadOptions=E}b.prototype={isEncrypted:function(){return(1&this.bitFlag)==1},useUTF8:function(){return(2048&this.bitFlag)==2048},readLocalPart:function(m){var E,g;if(m.skip(22),this.fileNameLength=m.readInt(2),g=m.readInt(2),this.fileName=m.readData(this.fileNameLength),m.skip(g),this.compressedSize===-1||this.uncompressedSize===-1)throw new Error("Bug or corrupted zip : didn't get enough information from the central directory (compressedSize === -1 || uncompressedSize === -1)");if((E=function(C){for(var _ in h)if(Object.prototype.hasOwnProperty.call(h,_)&&h[_].magic===C)return h[_];return null}(this.compressionMethod))===null)throw new Error("Corrupted zip : compression "+s.pretty(this.compressionMethod)+" unknown (inner file : "+s.transformTo("string",this.fileName)+")");this.decompressed=new i(this.compressedSize,this.uncompressedSize,this.crc32,E,m.readData(this.compressedSize))},readCentralPart:function(m){this.versionMadeBy=m.readInt(2),m.skip(2),this.bitFlag=m.readInt(2),this.compressionMethod=m.readString(2),this.date=m.readDate(),this.crc32=m.readInt(4),this.compressedSize=m.readInt(4),this.uncompressedSize=m.readInt(4);var E=m.readInt(2);if(this.extraFieldsLength=m.readInt(2),this.fileCommentLength=m.readInt(2),this.diskNumberStart=m.readInt(2),this.internalFileAttributes=m.readInt(2),this.externalFileAttributes=m.readInt(4),this.localHeaderOffset=m.readInt(4),this.isEncrypted())throw new Error("Encrypted zip are not supported");m.skip(E),this.readExtraFields(m),this.parseZIP64ExtraField(m),this.fileComment=m.readData(this.fileCommentLength)},processAttributes:function(){this.unixPermissions=null,this.dosPermissions=null;var m=this.versionMadeBy>>8;this.dir=!!(16&this.externalFileAttributes),m==0&&(this.dosPermissions=63&this.externalFileAttributes),m==3&&(this.unixPermissions=this.externalFileAttributes>>16&65535),this.dir||this.fileNameStr.slice(-1)!=="/"||(this.dir=!0)},parseZIP64ExtraField:function(){if(this.extraFields[1]){var m=l(this.extraFields[1].value);this.uncompressedSize===s.MAX_VALUE_32BITS&&(this.uncompressedSize=m.readInt(8)),this.compressedSize===s.MAX_VALUE_32BITS&&(this.compressedSize=m.readInt(8)),this.localHeaderOffset===s.MAX_VALUE_32BITS&&(this.localHeaderOffset=m.readInt(8)),this.diskNumberStart===s.MAX_VALUE_32BITS&&(this.diskNumberStart=m.readInt(4))}},readExtraFields:function(m){var E,g,C,_=m.index+this.extraFieldsLength;for(this.extraFields||(this.extraFields={});m.index+4<_;)E=m.readInt(2),g=m.readInt(2),C=m.readData(g),this.extraFields[E]={id:E,length:g,value:C};m.setIndex(_)},handleUTF8:function(){var m=p.uint8array?"uint8array":"array";if(this.useUTF8())this.fileNameStr=v.utf8decode(this.fileName),this.fileCommentStr=v.utf8decode(this.fileComment);else{var E=this.findExtraFieldUnicodePath();if(E!==null)this.fileNameStr=E;else{var g=s.transformTo(m,this.fileName);this.fileNameStr=this.loadOptions.decodeFileName(g)}var C=this.findExtraFieldUnicodeComment();if(C!==null)this.fileCommentStr=C;else{var _=s.transformTo(m,this.fileComment);this.fileCommentStr=this.loadOptions.decodeFileName(_)}}},findExtraFieldUnicodePath:function(){var m=this.extraFields[28789];if(m){var E=l(m.value);return E.readInt(1)!==1||d(this.fileName)!==E.readInt(4)?null:v.utf8decode(E.readData(m.length-5))}return null},findExtraFieldUnicodeComment:function(){var m=this.extraFields[25461];if(m){var E=l(m.value);return E.readInt(1)!==1||d(this.fileComment)!==E.readInt(4)?null:v.utf8decode(E.readData(m.length-5))}return null}},o.exports=b},{"./compressedObject":2,"./compressions":3,"./crc32":4,"./reader/readerFor":22,"./support":30,"./utf8":31,"./utils":32}],35:[function(r,o,a){function l(E,g,C){this.name=E,this.dir=C.dir,this.date=C.date,this.comment=C.comment,this.unixPermissions=C.unixPermissions,this.dosPermissions=C.dosPermissions,this._data=g,this._dataBinary=C.binary,this.options={compression:C.compression,compressionOptions:C.compressionOptions}}var s=r("./stream/StreamHelper"),i=r("./stream/DataWorker"),d=r("./utf8"),v=r("./compressedObject"),h=r("./stream/GenericWorker");l.prototype={internalStream:function(E){var g=null,C="string";try{if(!E)throw new Error("No output type specified.");var _=(C=E.toLowerCase())==="string"||C==="text";C!=="binarystring"&&C!=="text"||(C="string"),g=this._decompressWorker();var T=!this._dataBinary;T&&!_&&(g=g.pipe(new d.Utf8EncodeWorker)),!T&&_&&(g=g.pipe(new d.Utf8DecodeWorker))}catch(I){(g=new h("error")).error(I)}return new s(g,C,"")},async:function(E,g){return this.internalStream(E).accumulate(g)},nodeStream:function(E,g){return this.internalStream(E||"nodebuffer").toNodejsStream(g)},_compressWorker:function(E,g){if(this._data instanceof v&&this._data.compression.magic===E.magic)return this._data.getCompressedWorker();var C=this._decompressWorker();return this._dataBinary||(C=C.pipe(new d.Utf8EncodeWorker)),v.createWorkerFrom(C,E,g)},_decompressWorker:function(){return this._data instanceof v?this._data.getContentWorker():this._data instanceof h?this._data:new i(this._data)}};for(var p=["asText","asBinary","asNodeBuffer","asUint8Array","asArrayBuffer"],b=function(){throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.")},m=0;m<p.length;m++)l.prototype[p[m]]=b;o.exports=l},{"./compressedObject":2,"./stream/DataWorker":27,"./stream/GenericWorker":28,"./stream/StreamHelper":29,"./utf8":31}],36:[function(r,o,a){(function(l){var s,i,d=l.MutationObserver||l.WebKitMutationObserver;if(d){var v=0,h=new d(E),p=l.document.createTextNode("");h.observe(p,{characterData:!0}),s=function(){p.data=v=++v%2}}else if(l.setImmediate||l.MessageChannel===void 0)s="document"in l&&"onreadystatechange"in l.document.createElement("script")?function(){var g=l.document.createElement("script");g.onreadystatechange=function(){E(),g.onreadystatechange=null,g.parentNode.removeChild(g),g=null},l.document.documentElement.appendChild(g)}:function(){setTimeout(E,0)};else{var b=new l.MessageChannel;b.port1.onmessage=E,s=function(){b.port2.postMessage(0)}}var m=[];function E(){var g,C;i=!0;for(var _=m.length;_;){for(C=m,m=[],g=-1;++g<_;)C[g]();_=m.length}i=!1}o.exports=function(g){m.push(g)!==1||i||s()}}).call(this,typeof Qe<"u"?Qe:typeof self<"u"?self:typeof window<"u"?window:{})},{}],37:[function(r,o,a){var l=r("immediate");function s(){}var i={},d=["REJECTED"],v=["FULFILLED"],h=["PENDING"];function p(_){if(typeof _!="function")throw new TypeError("resolver must be a function");this.state=h,this.queue=[],this.outcome=void 0,_!==s&&g(this,_)}function b(_,T,I){this.promise=_,typeof T=="function"&&(this.onFulfilled=T,this.callFulfilled=this.otherCallFulfilled),typeof I=="function"&&(this.onRejected=I,this.callRejected=this.otherCallRejected)}function m(_,T,I){l(function(){var L;try{L=T(I)}catch(R){return i.reject(_,R)}L===_?i.reject(_,new TypeError("Cannot resolve promise with itself")):i.resolve(_,L)})}function E(_){var T=_&&_.then;if(_&&(typeof _=="object"||typeof _=="function")&&typeof T=="function")return function(){T.apply(_,arguments)}}function g(_,T){var I=!1;function L($){I||(I=!0,i.reject(_,$))}function R($){I||(I=!0,i.resolve(_,$))}var Y=C(function(){T(R,L)});Y.status==="error"&&L(Y.value)}function C(_,T){var I={};try{I.value=_(T),I.status="success"}catch(L){I.status="error",I.value=L}return I}(o.exports=p).prototype.finally=function(_){if(typeof _!="function")return this;var T=this.constructor;return this.then(function(I){return T.resolve(_()).then(function(){return I})},function(I){return T.resolve(_()).then(function(){throw I})})},p.prototype.catch=function(_){return this.then(null,_)},p.prototype.then=function(_,T){if(typeof _!="function"&&this.state===v||typeof T!="function"&&this.state===d)return this;var I=new this.constructor(s);return this.state!==h?m(I,this.state===v?_:T,this.outcome):this.queue.push(new b(I,_,T)),I},b.prototype.callFulfilled=function(_){i.resolve(this.promise,_)},b.prototype.otherCallFulfilled=function(_){m(this.promise,this.onFulfilled,_)},b.prototype.callRejected=function(_){i.reject(this.promise,_)},b.prototype.otherCallRejected=function(_){m(this.promise,this.onRejected,_)},i.resolve=function(_,T){var I=C(E,T);if(I.status==="error")return i.reject(_,I.value);var L=I.value;if(L)g(_,L);else{_.state=v,_.outcome=T;for(var R=-1,Y=_.queue.length;++R<Y;)_.queue[R].callFulfilled(T)}return _},i.reject=function(_,T){_.state=d,_.outcome=T;for(var I=-1,L=_.queue.length;++I<L;)_.queue[I].callRejected(T);return _},p.resolve=function(_){return _ instanceof this?_:i.resolve(new this(s),_)},p.reject=function(_){var T=new this(s);return i.reject(T,_)},p.all=function(_){var T=this;if(Object.prototype.toString.call(_)!=="[object Array]")return this.reject(new TypeError("must be an array"));var I=_.length,L=!1;if(!I)return this.resolve([]);for(var R=new Array(I),Y=0,$=-1,ee=new this(s);++$<I;)N(_[$],$);return ee;function N(ne,ue){T.resolve(ne).then(function(z){R[ue]=z,++Y!==I||L||(L=!0,i.resolve(ee,R))},function(z){L||(L=!0,i.reject(ee,z))})}},p.race=function(_){var T=this;if(Object.prototype.toString.call(_)!=="[object Array]")return this.reject(new TypeError("must be an array"));var I=_.length,L=!1;if(!I)return this.resolve([]);for(var R=-1,Y=new this(s);++R<I;)$=_[R],T.resolve($).then(function(ee){L||(L=!0,i.resolve(Y,ee))},function(ee){L||(L=!0,i.reject(Y,ee))});var $;return Y}},{immediate:36}],38:[function(r,o,a){var l={};(0,r("./lib/utils/common").assign)(l,r("./lib/deflate"),r("./lib/inflate"),r("./lib/zlib/constants")),o.exports=l},{"./lib/deflate":39,"./lib/inflate":40,"./lib/utils/common":41,"./lib/zlib/constants":44}],39:[function(r,o,a){var l=r("./zlib/deflate"),s=r("./utils/common"),i=r("./utils/strings"),d=r("./zlib/messages"),v=r("./zlib/zstream"),h=Object.prototype.toString,p=0,b=-1,m=0,E=8;function g(_){if(!(this instanceof g))return new g(_);this.options=s.assign({level:b,method:E,chunkSize:16384,windowBits:15,memLevel:8,strategy:m,to:""},_||{});var T=this.options;T.raw&&0<T.windowBits?T.windowBits=-T.windowBits:T.gzip&&0<T.windowBits&&T.windowBits<16&&(T.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new v,this.strm.avail_out=0;var I=l.deflateInit2(this.strm,T.level,T.method,T.windowBits,T.memLevel,T.strategy);if(I!==p)throw new Error(d[I]);if(T.header&&l.deflateSetHeader(this.strm,T.header),T.dictionary){var L;if(L=typeof T.dictionary=="string"?i.string2buf(T.dictionary):h.call(T.dictionary)==="[object ArrayBuffer]"?new Uint8Array(T.dictionary):T.dictionary,(I=l.deflateSetDictionary(this.strm,L))!==p)throw new Error(d[I]);this._dict_set=!0}}function C(_,T){var I=new g(T);if(I.push(_,!0),I.err)throw I.msg||d[I.err];return I.result}g.prototype.push=function(_,T){var I,L,R=this.strm,Y=this.options.chunkSize;if(this.ended)return!1;L=T===~~T?T:T===!0?4:0,typeof _=="string"?R.input=i.string2buf(_):h.call(_)==="[object ArrayBuffer]"?R.input=new Uint8Array(_):R.input=_,R.next_in=0,R.avail_in=R.input.length;do{if(R.avail_out===0&&(R.output=new s.Buf8(Y),R.next_out=0,R.avail_out=Y),(I=l.deflate(R,L))!==1&&I!==p)return this.onEnd(I),!(this.ended=!0);R.avail_out!==0&&(R.avail_in!==0||L!==4&&L!==2)||(this.options.to==="string"?this.onData(i.buf2binstring(s.shrinkBuf(R.output,R.next_out))):this.onData(s.shrinkBuf(R.output,R.next_out)))}while((0<R.avail_in||R.avail_out===0)&&I!==1);return L===4?(I=l.deflateEnd(this.strm),this.onEnd(I),this.ended=!0,I===p):L!==2||(this.onEnd(p),!(R.avail_out=0))},g.prototype.onData=function(_){this.chunks.push(_)},g.prototype.onEnd=function(_){_===p&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=_,this.msg=this.strm.msg},a.Deflate=g,a.deflate=C,a.deflateRaw=function(_,T){return(T=T||{}).raw=!0,C(_,T)},a.gzip=function(_,T){return(T=T||{}).gzip=!0,C(_,T)}},{"./utils/common":41,"./utils/strings":42,"./zlib/deflate":46,"./zlib/messages":51,"./zlib/zstream":53}],40:[function(r,o,a){var l=r("./zlib/inflate"),s=r("./utils/common"),i=r("./utils/strings"),d=r("./zlib/constants"),v=r("./zlib/messages"),h=r("./zlib/zstream"),p=r("./zlib/gzheader"),b=Object.prototype.toString;function m(g){if(!(this instanceof m))return new m(g);this.options=s.assign({chunkSize:16384,windowBits:0,to:""},g||{});var C=this.options;C.raw&&0<=C.windowBits&&C.windowBits<16&&(C.windowBits=-C.windowBits,C.windowBits===0&&(C.windowBits=-15)),!(0<=C.windowBits&&C.windowBits<16)||g&&g.windowBits||(C.windowBits+=32),15<C.windowBits&&C.windowBits<48&&(15&C.windowBits)==0&&(C.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new h,this.strm.avail_out=0;var _=l.inflateInit2(this.strm,C.windowBits);if(_!==d.Z_OK)throw new Error(v[_]);this.header=new p,l.inflateGetHeader(this.strm,this.header)}function E(g,C){var _=new m(C);if(_.push(g,!0),_.err)throw _.msg||v[_.err];return _.result}m.prototype.push=function(g,C){var _,T,I,L,R,Y,$=this.strm,ee=this.options.chunkSize,N=this.options.dictionary,ne=!1;if(this.ended)return!1;T=C===~~C?C:C===!0?d.Z_FINISH:d.Z_NO_FLUSH,typeof g=="string"?$.input=i.binstring2buf(g):b.call(g)==="[object ArrayBuffer]"?$.input=new Uint8Array(g):$.input=g,$.next_in=0,$.avail_in=$.input.length;do{if($.avail_out===0&&($.output=new s.Buf8(ee),$.next_out=0,$.avail_out=ee),(_=l.inflate($,d.Z_NO_FLUSH))===d.Z_NEED_DICT&&N&&(Y=typeof N=="string"?i.string2buf(N):b.call(N)==="[object ArrayBuffer]"?new Uint8Array(N):N,_=l.inflateSetDictionary(this.strm,Y)),_===d.Z_BUF_ERROR&&ne===!0&&(_=d.Z_OK,ne=!1),_!==d.Z_STREAM_END&&_!==d.Z_OK)return this.onEnd(_),!(this.ended=!0);$.next_out&&($.avail_out!==0&&_!==d.Z_STREAM_END&&($.avail_in!==0||T!==d.Z_FINISH&&T!==d.Z_SYNC_FLUSH)||(this.options.to==="string"?(I=i.utf8border($.output,$.next_out),L=$.next_out-I,R=i.buf2string($.output,I),$.next_out=L,$.avail_out=ee-L,L&&s.arraySet($.output,$.output,I,L,0),this.onData(R)):this.onData(s.shrinkBuf($.output,$.next_out)))),$.avail_in===0&&$.avail_out===0&&(ne=!0)}while((0<$.avail_in||$.avail_out===0)&&_!==d.Z_STREAM_END);return _===d.Z_STREAM_END&&(T=d.Z_FINISH),T===d.Z_FINISH?(_=l.inflateEnd(this.strm),this.onEnd(_),this.ended=!0,_===d.Z_OK):T!==d.Z_SYNC_FLUSH||(this.onEnd(d.Z_OK),!($.avail_out=0))},m.prototype.onData=function(g){this.chunks.push(g)},m.prototype.onEnd=function(g){g===d.Z_OK&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=s.flattenChunks(this.chunks)),this.chunks=[],this.err=g,this.msg=this.strm.msg},a.Inflate=m,a.inflate=E,a.inflateRaw=function(g,C){return(C=C||{}).raw=!0,E(g,C)},a.ungzip=E},{"./utils/common":41,"./utils/strings":42,"./zlib/constants":44,"./zlib/gzheader":47,"./zlib/inflate":49,"./zlib/messages":51,"./zlib/zstream":53}],41:[function(r,o,a){var l=typeof Uint8Array<"u"&&typeof Uint16Array<"u"&&typeof Int32Array<"u";a.assign=function(d){for(var v=Array.prototype.slice.call(arguments,1);v.length;){var h=v.shift();if(h){if(typeof h!="object")throw new TypeError(h+"must be non-object");for(var p in h)h.hasOwnProperty(p)&&(d[p]=h[p])}}return d},a.shrinkBuf=function(d,v){return d.length===v?d:d.subarray?d.subarray(0,v):(d.length=v,d)};var s={arraySet:function(d,v,h,p,b){if(v.subarray&&d.subarray)d.set(v.subarray(h,h+p),b);else for(var m=0;m<p;m++)d[b+m]=v[h+m]},flattenChunks:function(d){var v,h,p,b,m,E;for(v=p=0,h=d.length;v<h;v++)p+=d[v].length;for(E=new Uint8Array(p),v=b=0,h=d.length;v<h;v++)m=d[v],E.set(m,b),b+=m.length;return E}},i={arraySet:function(d,v,h,p,b){for(var m=0;m<p;m++)d[b+m]=v[h+m]},flattenChunks:function(d){return[].concat.apply([],d)}};a.setTyped=function(d){d?(a.Buf8=Uint8Array,a.Buf16=Uint16Array,a.Buf32=Int32Array,a.assign(a,s)):(a.Buf8=Array,a.Buf16=Array,a.Buf32=Array,a.assign(a,i))},a.setTyped(l)},{}],42:[function(r,o,a){var l=r("./common"),s=!0,i=!0;try{String.fromCharCode.apply(null,[0])}catch{s=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch{i=!1}for(var d=new l.Buf8(256),v=0;v<256;v++)d[v]=252<=v?6:248<=v?5:240<=v?4:224<=v?3:192<=v?2:1;function h(p,b){if(b<65537&&(p.subarray&&i||!p.subarray&&s))return String.fromCharCode.apply(null,l.shrinkBuf(p,b));for(var m="",E=0;E<b;E++)m+=String.fromCharCode(p[E]);return m}d[254]=d[254]=1,a.string2buf=function(p){var b,m,E,g,C,_=p.length,T=0;for(g=0;g<_;g++)(64512&(m=p.charCodeAt(g)))==55296&&g+1<_&&(64512&(E=p.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(E-56320),g++),T+=m<128?1:m<2048?2:m<65536?3:4;for(b=new l.Buf8(T),g=C=0;C<T;g++)(64512&(m=p.charCodeAt(g)))==55296&&g+1<_&&(64512&(E=p.charCodeAt(g+1)))==56320&&(m=65536+(m-55296<<10)+(E-56320),g++),m<128?b[C++]=m:(m<2048?b[C++]=192|m>>>6:(m<65536?b[C++]=224|m>>>12:(b[C++]=240|m>>>18,b[C++]=128|m>>>12&63),b[C++]=128|m>>>6&63),b[C++]=128|63&m);return b},a.buf2binstring=function(p){return h(p,p.length)},a.binstring2buf=function(p){for(var b=new l.Buf8(p.length),m=0,E=b.length;m<E;m++)b[m]=p.charCodeAt(m);return b},a.buf2string=function(p,b){var m,E,g,C,_=b||p.length,T=new Array(2*_);for(m=E=0;m<_;)if((g=p[m++])<128)T[E++]=g;else if(4<(C=d[g]))T[E++]=65533,m+=C-1;else{for(g&=C===2?31:C===3?15:7;1<C&&m<_;)g=g<<6|63&p[m++],C--;1<C?T[E++]=65533:g<65536?T[E++]=g:(g-=65536,T[E++]=55296|g>>10&1023,T[E++]=56320|1023&g)}return h(T,E)},a.utf8border=function(p,b){var m;for((b=b||p.length)>p.length&&(b=p.length),m=b-1;0<=m&&(192&p[m])==128;)m--;return m<0||m===0?b:m+d[p[m]]>b?m:b}},{"./common":41}],43:[function(r,o,a){o.exports=function(l,s,i,d){for(var v=65535&l|0,h=l>>>16&65535|0,p=0;i!==0;){for(i-=p=2e3<i?2e3:i;h=h+(v=v+s[d++]|0)|0,--p;);v%=65521,h%=65521}return v|h<<16|0}},{}],44:[function(r,o,a){o.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],45:[function(r,o,a){var l=function(){for(var s,i=[],d=0;d<256;d++){s=d;for(var v=0;v<8;v++)s=1&s?3988292384^s>>>1:s>>>1;i[d]=s}return i}();o.exports=function(s,i,d,v){var h=l,p=v+d;s^=-1;for(var b=v;b<p;b++)s=s>>>8^h[255&(s^i[b])];return-1^s}},{}],46:[function(r,o,a){var l,s=r("../utils/common"),i=r("./trees"),d=r("./adler32"),v=r("./crc32"),h=r("./messages"),p=0,b=4,m=0,E=-2,g=-1,C=4,_=2,T=8,I=9,L=286,R=30,Y=19,$=2*L+1,ee=15,N=3,ne=258,ue=ne+N+1,z=42,U=113,f=1,j=2,me=3,H=4;function y(u,Z){return u.msg=h[Z],Z}function w(u){return(u<<1)-(4<u?9:0)}function D(u){for(var Z=u.length;0<=--Z;)u[Z]=0}function x(u){var Z=u.state,W=Z.pending;W>u.avail_out&&(W=u.avail_out),W!==0&&(s.arraySet(u.output,Z.pending_buf,Z.pending_out,W,u.next_out),u.next_out+=W,Z.pending_out+=W,u.total_out+=W,u.avail_out-=W,Z.pending-=W,Z.pending===0&&(Z.pending_out=0))}function S(u,Z){i._tr_flush_block(u,0<=u.block_start?u.block_start:-1,u.strstart-u.block_start,Z),u.block_start=u.strstart,x(u.strm)}function F(u,Z){u.pending_buf[u.pending++]=Z}function B(u,Z){u.pending_buf[u.pending++]=Z>>>8&255,u.pending_buf[u.pending++]=255&Z}function M(u,Z){var W,A,k=u.max_chain_length,P=u.strstart,X=u.prev_length,J=u.nice_match,q=u.strstart>u.w_size-ue?u.strstart-(u.w_size-ue):0,ie=u.window,le=u.w_mask,ae=u.prev,ce=u.strstart+ne,Se=ie[P+X-1],we=ie[P+X];u.prev_length>=u.good_match&&(k>>=2),J>u.lookahead&&(J=u.lookahead);do if(ie[(W=Z)+X]===we&&ie[W+X-1]===Se&&ie[W]===ie[P]&&ie[++W]===ie[P+1]){P+=2,W++;do;while(ie[++P]===ie[++W]&&ie[++P]===ie[++W]&&ie[++P]===ie[++W]&&ie[++P]===ie[++W]&&ie[++P]===ie[++W]&&ie[++P]===ie[++W]&&ie[++P]===ie[++W]&&ie[++P]===ie[++W]&&P<ce);if(A=ne-(ce-P),P=ce-ne,X<A){if(u.match_start=Z,J<=(X=A))break;Se=ie[P+X-1],we=ie[P+X]}}while((Z=ae[Z&le])>q&&--k!=0);return X<=u.lookahead?X:u.lookahead}function Q(u){var Z,W,A,k,P,X,J,q,ie,le,ae=u.w_size;do{if(k=u.window_size-u.lookahead-u.strstart,u.strstart>=ae+(ae-ue)){for(s.arraySet(u.window,u.window,ae,ae,0),u.match_start-=ae,u.strstart-=ae,u.block_start-=ae,Z=W=u.hash_size;A=u.head[--Z],u.head[Z]=ae<=A?A-ae:0,--W;);for(Z=W=ae;A=u.prev[--Z],u.prev[Z]=ae<=A?A-ae:0,--W;);k+=ae}if(u.strm.avail_in===0)break;if(X=u.strm,J=u.window,q=u.strstart+u.lookahead,ie=k,le=void 0,le=X.avail_in,ie<le&&(le=ie),W=le===0?0:(X.avail_in-=le,s.arraySet(J,X.input,X.next_in,le,q),X.state.wrap===1?X.adler=d(X.adler,J,le,q):X.state.wrap===2&&(X.adler=v(X.adler,J,le,q)),X.next_in+=le,X.total_in+=le,le),u.lookahead+=W,u.lookahead+u.insert>=N)for(P=u.strstart-u.insert,u.ins_h=u.window[P],u.ins_h=(u.ins_h<<u.hash_shift^u.window[P+1])&u.hash_mask;u.insert&&(u.ins_h=(u.ins_h<<u.hash_shift^u.window[P+N-1])&u.hash_mask,u.prev[P&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=P,P++,u.insert--,!(u.lookahead+u.insert<N)););}while(u.lookahead<ue&&u.strm.avail_in!==0)}function K(u,Z){for(var W,A;;){if(u.lookahead<ue){if(Q(u),u.lookahead<ue&&Z===p)return f;if(u.lookahead===0)break}if(W=0,u.lookahead>=N&&(u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+N-1])&u.hash_mask,W=u.prev[u.strstart&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=u.strstart),W!==0&&u.strstart-W<=u.w_size-ue&&(u.match_length=M(u,W)),u.match_length>=N)if(A=i._tr_tally(u,u.strstart-u.match_start,u.match_length-N),u.lookahead-=u.match_length,u.match_length<=u.max_lazy_match&&u.lookahead>=N){for(u.match_length--;u.strstart++,u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+N-1])&u.hash_mask,W=u.prev[u.strstart&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=u.strstart,--u.match_length!=0;);u.strstart++}else u.strstart+=u.match_length,u.match_length=0,u.ins_h=u.window[u.strstart],u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+1])&u.hash_mask;else A=i._tr_tally(u,0,u.window[u.strstart]),u.lookahead--,u.strstart++;if(A&&(S(u,!1),u.strm.avail_out===0))return f}return u.insert=u.strstart<N-1?u.strstart:N-1,Z===b?(S(u,!0),u.strm.avail_out===0?me:H):u.last_lit&&(S(u,!1),u.strm.avail_out===0)?f:j}function re(u,Z){for(var W,A,k;;){if(u.lookahead<ue){if(Q(u),u.lookahead<ue&&Z===p)return f;if(u.lookahead===0)break}if(W=0,u.lookahead>=N&&(u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+N-1])&u.hash_mask,W=u.prev[u.strstart&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=u.strstart),u.prev_length=u.match_length,u.prev_match=u.match_start,u.match_length=N-1,W!==0&&u.prev_length<u.max_lazy_match&&u.strstart-W<=u.w_size-ue&&(u.match_length=M(u,W),u.match_length<=5&&(u.strategy===1||u.match_length===N&&4096<u.strstart-u.match_start)&&(u.match_length=N-1)),u.prev_length>=N&&u.match_length<=u.prev_length){for(k=u.strstart+u.lookahead-N,A=i._tr_tally(u,u.strstart-1-u.prev_match,u.prev_length-N),u.lookahead-=u.prev_length-1,u.prev_length-=2;++u.strstart<=k&&(u.ins_h=(u.ins_h<<u.hash_shift^u.window[u.strstart+N-1])&u.hash_mask,W=u.prev[u.strstart&u.w_mask]=u.head[u.ins_h],u.head[u.ins_h]=u.strstart),--u.prev_length!=0;);if(u.match_available=0,u.match_length=N-1,u.strstart++,A&&(S(u,!1),u.strm.avail_out===0))return f}else if(u.match_available){if((A=i._tr_tally(u,0,u.window[u.strstart-1]))&&S(u,!1),u.strstart++,u.lookahead--,u.strm.avail_out===0)return f}else u.match_available=1,u.strstart++,u.lookahead--}return u.match_available&&(A=i._tr_tally(u,0,u.window[u.strstart-1]),u.match_available=0),u.insert=u.strstart<N-1?u.strstart:N-1,Z===b?(S(u,!0),u.strm.avail_out===0?me:H):u.last_lit&&(S(u,!1),u.strm.avail_out===0)?f:j}function pe(u,Z,W,A,k){this.good_length=u,this.max_lazy=Z,this.nice_length=W,this.max_chain=A,this.func=k}function de(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=T,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new s.Buf16(2*$),this.dyn_dtree=new s.Buf16(2*(2*R+1)),this.bl_tree=new s.Buf16(2*(2*Y+1)),D(this.dyn_ltree),D(this.dyn_dtree),D(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new s.Buf16(ee+1),this.heap=new s.Buf16(2*L+1),D(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new s.Buf16(2*L+1),D(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function fe(u){var Z;return u&&u.state?(u.total_in=u.total_out=0,u.data_type=_,(Z=u.state).pending=0,Z.pending_out=0,Z.wrap<0&&(Z.wrap=-Z.wrap),Z.status=Z.wrap?z:U,u.adler=Z.wrap===2?0:1,Z.last_flush=p,i._tr_init(Z),m):y(u,E)}function _e(u){var Z=fe(u);return Z===m&&function(W){W.window_size=2*W.w_size,D(W.head),W.max_lazy_match=l[W.level].max_lazy,W.good_match=l[W.level].good_length,W.nice_match=l[W.level].nice_length,W.max_chain_length=l[W.level].max_chain,W.strstart=0,W.block_start=0,W.lookahead=0,W.insert=0,W.match_length=W.prev_length=N-1,W.match_available=0,W.ins_h=0}(u.state),Z}function Te(u,Z,W,A,k,P){if(!u)return E;var X=1;if(Z===g&&(Z=6),A<0?(X=0,A=-A):15<A&&(X=2,A-=16),k<1||I<k||W!==T||A<8||15<A||Z<0||9<Z||P<0||C<P)return y(u,E);A===8&&(A=9);var J=new de;return(u.state=J).strm=u,J.wrap=X,J.gzhead=null,J.w_bits=A,J.w_size=1<<J.w_bits,J.w_mask=J.w_size-1,J.hash_bits=k+7,J.hash_size=1<<J.hash_bits,J.hash_mask=J.hash_size-1,J.hash_shift=~~((J.hash_bits+N-1)/N),J.window=new s.Buf8(2*J.w_size),J.head=new s.Buf16(J.hash_size),J.prev=new s.Buf16(J.w_size),J.lit_bufsize=1<<k+6,J.pending_buf_size=4*J.lit_bufsize,J.pending_buf=new s.Buf8(J.pending_buf_size),J.d_buf=1*J.lit_bufsize,J.l_buf=3*J.lit_bufsize,J.level=Z,J.strategy=P,J.method=W,_e(u)}l=[new pe(0,0,0,0,function(u,Z){var W=65535;for(W>u.pending_buf_size-5&&(W=u.pending_buf_size-5);;){if(u.lookahead<=1){if(Q(u),u.lookahead===0&&Z===p)return f;if(u.lookahead===0)break}u.strstart+=u.lookahead,u.lookahead=0;var A=u.block_start+W;if((u.strstart===0||u.strstart>=A)&&(u.lookahead=u.strstart-A,u.strstart=A,S(u,!1),u.strm.avail_out===0)||u.strstart-u.block_start>=u.w_size-ue&&(S(u,!1),u.strm.avail_out===0))return f}return u.insert=0,Z===b?(S(u,!0),u.strm.avail_out===0?me:H):(u.strstart>u.block_start&&(S(u,!1),u.strm.avail_out),f)}),new pe(4,4,8,4,K),new pe(4,5,16,8,K),new pe(4,6,32,32,K),new pe(4,4,16,16,re),new pe(8,16,32,32,re),new pe(8,16,128,128,re),new pe(8,32,128,256,re),new pe(32,128,258,1024,re),new pe(32,258,258,4096,re)],a.deflateInit=function(u,Z){return Te(u,Z,T,15,8,0)},a.deflateInit2=Te,a.deflateReset=_e,a.deflateResetKeep=fe,a.deflateSetHeader=function(u,Z){return u&&u.state?u.state.wrap!==2?E:(u.state.gzhead=Z,m):E},a.deflate=function(u,Z){var W,A,k,P;if(!u||!u.state||5<Z||Z<0)return u?y(u,E):E;if(A=u.state,!u.output||!u.input&&u.avail_in!==0||A.status===666&&Z!==b)return y(u,u.avail_out===0?-5:E);if(A.strm=u,W=A.last_flush,A.last_flush=Z,A.status===z)if(A.wrap===2)u.adler=0,F(A,31),F(A,139),F(A,8),A.gzhead?(F(A,(A.gzhead.text?1:0)+(A.gzhead.hcrc?2:0)+(A.gzhead.extra?4:0)+(A.gzhead.name?8:0)+(A.gzhead.comment?16:0)),F(A,255&A.gzhead.time),F(A,A.gzhead.time>>8&255),F(A,A.gzhead.time>>16&255),F(A,A.gzhead.time>>24&255),F(A,A.level===9?2:2<=A.strategy||A.level<2?4:0),F(A,255&A.gzhead.os),A.gzhead.extra&&A.gzhead.extra.length&&(F(A,255&A.gzhead.extra.length),F(A,A.gzhead.extra.length>>8&255)),A.gzhead.hcrc&&(u.adler=v(u.adler,A.pending_buf,A.pending,0)),A.gzindex=0,A.status=69):(F(A,0),F(A,0),F(A,0),F(A,0),F(A,0),F(A,A.level===9?2:2<=A.strategy||A.level<2?4:0),F(A,3),A.status=U);else{var X=T+(A.w_bits-8<<4)<<8;X|=(2<=A.strategy||A.level<2?0:A.level<6?1:A.level===6?2:3)<<6,A.strstart!==0&&(X|=32),X+=31-X%31,A.status=U,B(A,X),A.strstart!==0&&(B(A,u.adler>>>16),B(A,65535&u.adler)),u.adler=1}if(A.status===69)if(A.gzhead.extra){for(k=A.pending;A.gzindex<(65535&A.gzhead.extra.length)&&(A.pending!==A.pending_buf_size||(A.gzhead.hcrc&&A.pending>k&&(u.adler=v(u.adler,A.pending_buf,A.pending-k,k)),x(u),k=A.pending,A.pending!==A.pending_buf_size));)F(A,255&A.gzhead.extra[A.gzindex]),A.gzindex++;A.gzhead.hcrc&&A.pending>k&&(u.adler=v(u.adler,A.pending_buf,A.pending-k,k)),A.gzindex===A.gzhead.extra.length&&(A.gzindex=0,A.status=73)}else A.status=73;if(A.status===73)if(A.gzhead.name){k=A.pending;do{if(A.pending===A.pending_buf_size&&(A.gzhead.hcrc&&A.pending>k&&(u.adler=v(u.adler,A.pending_buf,A.pending-k,k)),x(u),k=A.pending,A.pending===A.pending_buf_size)){P=1;break}P=A.gzindex<A.gzhead.name.length?255&A.gzhead.name.charCodeAt(A.gzindex++):0,F(A,P)}while(P!==0);A.gzhead.hcrc&&A.pending>k&&(u.adler=v(u.adler,A.pending_buf,A.pending-k,k)),P===0&&(A.gzindex=0,A.status=91)}else A.status=91;if(A.status===91)if(A.gzhead.comment){k=A.pending;do{if(A.pending===A.pending_buf_size&&(A.gzhead.hcrc&&A.pending>k&&(u.adler=v(u.adler,A.pending_buf,A.pending-k,k)),x(u),k=A.pending,A.pending===A.pending_buf_size)){P=1;break}P=A.gzindex<A.gzhead.comment.length?255&A.gzhead.comment.charCodeAt(A.gzindex++):0,F(A,P)}while(P!==0);A.gzhead.hcrc&&A.pending>k&&(u.adler=v(u.adler,A.pending_buf,A.pending-k,k)),P===0&&(A.status=103)}else A.status=103;if(A.status===103&&(A.gzhead.hcrc?(A.pending+2>A.pending_buf_size&&x(u),A.pending+2<=A.pending_buf_size&&(F(A,255&u.adler),F(A,u.adler>>8&255),u.adler=0,A.status=U)):A.status=U),A.pending!==0){if(x(u),u.avail_out===0)return A.last_flush=-1,m}else if(u.avail_in===0&&w(Z)<=w(W)&&Z!==b)return y(u,-5);if(A.status===666&&u.avail_in!==0)return y(u,-5);if(u.avail_in!==0||A.lookahead!==0||Z!==p&&A.status!==666){var J=A.strategy===2?function(q,ie){for(var le;;){if(q.lookahead===0&&(Q(q),q.lookahead===0)){if(ie===p)return f;break}if(q.match_length=0,le=i._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++,le&&(S(q,!1),q.strm.avail_out===0))return f}return q.insert=0,ie===b?(S(q,!0),q.strm.avail_out===0?me:H):q.last_lit&&(S(q,!1),q.strm.avail_out===0)?f:j}(A,Z):A.strategy===3?function(q,ie){for(var le,ae,ce,Se,we=q.window;;){if(q.lookahead<=ne){if(Q(q),q.lookahead<=ne&&ie===p)return f;if(q.lookahead===0)break}if(q.match_length=0,q.lookahead>=N&&0<q.strstart&&(ae=we[ce=q.strstart-1])===we[++ce]&&ae===we[++ce]&&ae===we[++ce]){Se=q.strstart+ne;do;while(ae===we[++ce]&&ae===we[++ce]&&ae===we[++ce]&&ae===we[++ce]&&ae===we[++ce]&&ae===we[++ce]&&ae===we[++ce]&&ae===we[++ce]&&ce<Se);q.match_length=ne-(Se-ce),q.match_length>q.lookahead&&(q.match_length=q.lookahead)}if(q.match_length>=N?(le=i._tr_tally(q,1,q.match_length-N),q.lookahead-=q.match_length,q.strstart+=q.match_length,q.match_length=0):(le=i._tr_tally(q,0,q.window[q.strstart]),q.lookahead--,q.strstart++),le&&(S(q,!1),q.strm.avail_out===0))return f}return q.insert=0,ie===b?(S(q,!0),q.strm.avail_out===0?me:H):q.last_lit&&(S(q,!1),q.strm.avail_out===0)?f:j}(A,Z):l[A.level].func(A,Z);if(J!==me&&J!==H||(A.status=666),J===f||J===me)return u.avail_out===0&&(A.last_flush=-1),m;if(J===j&&(Z===1?i._tr_align(A):Z!==5&&(i._tr_stored_block(A,0,0,!1),Z===3&&(D(A.head),A.lookahead===0&&(A.strstart=0,A.block_start=0,A.insert=0))),x(u),u.avail_out===0))return A.last_flush=-1,m}return Z!==b?m:A.wrap<=0?1:(A.wrap===2?(F(A,255&u.adler),F(A,u.adler>>8&255),F(A,u.adler>>16&255),F(A,u.adler>>24&255),F(A,255&u.total_in),F(A,u.total_in>>8&255),F(A,u.total_in>>16&255),F(A,u.total_in>>24&255)):(B(A,u.adler>>>16),B(A,65535&u.adler)),x(u),0<A.wrap&&(A.wrap=-A.wrap),A.pending!==0?m:1)},a.deflateEnd=function(u){var Z;return u&&u.state?(Z=u.state.status)!==z&&Z!==69&&Z!==73&&Z!==91&&Z!==103&&Z!==U&&Z!==666?y(u,E):(u.state=null,Z===U?y(u,-3):m):E},a.deflateSetDictionary=function(u,Z){var W,A,k,P,X,J,q,ie,le=Z.length;if(!u||!u.state||(P=(W=u.state).wrap)===2||P===1&&W.status!==z||W.lookahead)return E;for(P===1&&(u.adler=d(u.adler,Z,le,0)),W.wrap=0,le>=W.w_size&&(P===0&&(D(W.head),W.strstart=0,W.block_start=0,W.insert=0),ie=new s.Buf8(W.w_size),s.arraySet(ie,Z,le-W.w_size,W.w_size,0),Z=ie,le=W.w_size),X=u.avail_in,J=u.next_in,q=u.input,u.avail_in=le,u.next_in=0,u.input=Z,Q(W);W.lookahead>=N;){for(A=W.strstart,k=W.lookahead-(N-1);W.ins_h=(W.ins_h<<W.hash_shift^W.window[A+N-1])&W.hash_mask,W.prev[A&W.w_mask]=W.head[W.ins_h],W.head[W.ins_h]=A,A++,--k;);W.strstart=A,W.lookahead=N-1,Q(W)}return W.strstart+=W.lookahead,W.block_start=W.strstart,W.insert=W.lookahead,W.lookahead=0,W.match_length=W.prev_length=N-1,W.match_available=0,u.next_in=J,u.input=q,u.avail_in=X,W.wrap=P,m},a.deflateInfo="pako deflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./messages":51,"./trees":52}],47:[function(r,o,a){o.exports=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}},{}],48:[function(r,o,a){o.exports=function(l,s){var i,d,v,h,p,b,m,E,g,C,_,T,I,L,R,Y,$,ee,N,ne,ue,z,U,f,j;i=l.state,d=l.next_in,f=l.input,v=d+(l.avail_in-5),h=l.next_out,j=l.output,p=h-(s-l.avail_out),b=h+(l.avail_out-257),m=i.dmax,E=i.wsize,g=i.whave,C=i.wnext,_=i.window,T=i.hold,I=i.bits,L=i.lencode,R=i.distcode,Y=(1<<i.lenbits)-1,$=(1<<i.distbits)-1;e:do{I<15&&(T+=f[d++]<<I,I+=8,T+=f[d++]<<I,I+=8),ee=L[T&Y];t:for(;;){if(T>>>=N=ee>>>24,I-=N,(N=ee>>>16&255)===0)j[h++]=65535&ee;else{if(!(16&N)){if((64&N)==0){ee=L[(65535&ee)+(T&(1<<N)-1)];continue t}if(32&N){i.mode=12;break e}l.msg="invalid literal/length code",i.mode=30;break e}ne=65535&ee,(N&=15)&&(I<N&&(T+=f[d++]<<I,I+=8),ne+=T&(1<<N)-1,T>>>=N,I-=N),I<15&&(T+=f[d++]<<I,I+=8,T+=f[d++]<<I,I+=8),ee=R[T&$];r:for(;;){if(T>>>=N=ee>>>24,I-=N,!(16&(N=ee>>>16&255))){if((64&N)==0){ee=R[(65535&ee)+(T&(1<<N)-1)];continue r}l.msg="invalid distance code",i.mode=30;break e}if(ue=65535&ee,I<(N&=15)&&(T+=f[d++]<<I,(I+=8)<N&&(T+=f[d++]<<I,I+=8)),m<(ue+=T&(1<<N)-1)){l.msg="invalid distance too far back",i.mode=30;break e}if(T>>>=N,I-=N,(N=h-p)<ue){if(g<(N=ue-N)&&i.sane){l.msg="invalid distance too far back",i.mode=30;break e}if(U=_,(z=0)===C){if(z+=E-N,N<ne){for(ne-=N;j[h++]=_[z++],--N;);z=h-ue,U=j}}else if(C<N){if(z+=E+C-N,(N-=C)<ne){for(ne-=N;j[h++]=_[z++],--N;);if(z=0,C<ne){for(ne-=N=C;j[h++]=_[z++],--N;);z=h-ue,U=j}}}else if(z+=C-N,N<ne){for(ne-=N;j[h++]=_[z++],--N;);z=h-ue,U=j}for(;2<ne;)j[h++]=U[z++],j[h++]=U[z++],j[h++]=U[z++],ne-=3;ne&&(j[h++]=U[z++],1<ne&&(j[h++]=U[z++]))}else{for(z=h-ue;j[h++]=j[z++],j[h++]=j[z++],j[h++]=j[z++],2<(ne-=3););ne&&(j[h++]=j[z++],1<ne&&(j[h++]=j[z++]))}break}}break}}while(d<v&&h<b);d-=ne=I>>3,T&=(1<<(I-=ne<<3))-1,l.next_in=d,l.next_out=h,l.avail_in=d<v?v-d+5:5-(d-v),l.avail_out=h<b?b-h+257:257-(h-b),i.hold=T,i.bits=I}},{}],49:[function(r,o,a){var l=r("../utils/common"),s=r("./adler32"),i=r("./crc32"),d=r("./inffast"),v=r("./inftrees"),h=1,p=2,b=0,m=-2,E=1,g=852,C=592;function _(z){return(z>>>24&255)+(z>>>8&65280)+((65280&z)<<8)+((255&z)<<24)}function T(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new l.Buf16(320),this.work=new l.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function I(z){var U;return z&&z.state?(U=z.state,z.total_in=z.total_out=U.total=0,z.msg="",U.wrap&&(z.adler=1&U.wrap),U.mode=E,U.last=0,U.havedict=0,U.dmax=32768,U.head=null,U.hold=0,U.bits=0,U.lencode=U.lendyn=new l.Buf32(g),U.distcode=U.distdyn=new l.Buf32(C),U.sane=1,U.back=-1,b):m}function L(z){var U;return z&&z.state?((U=z.state).wsize=0,U.whave=0,U.wnext=0,I(z)):m}function R(z,U){var f,j;return z&&z.state?(j=z.state,U<0?(f=0,U=-U):(f=1+(U>>4),U<48&&(U&=15)),U&&(U<8||15<U)?m:(j.window!==null&&j.wbits!==U&&(j.window=null),j.wrap=f,j.wbits=U,L(z))):m}function Y(z,U){var f,j;return z?(j=new T,(z.state=j).window=null,(f=R(z,U))!==b&&(z.state=null),f):m}var $,ee,N=!0;function ne(z){if(N){var U;for($=new l.Buf32(512),ee=new l.Buf32(32),U=0;U<144;)z.lens[U++]=8;for(;U<256;)z.lens[U++]=9;for(;U<280;)z.lens[U++]=7;for(;U<288;)z.lens[U++]=8;for(v(h,z.lens,0,288,$,0,z.work,{bits:9}),U=0;U<32;)z.lens[U++]=5;v(p,z.lens,0,32,ee,0,z.work,{bits:5}),N=!1}z.lencode=$,z.lenbits=9,z.distcode=ee,z.distbits=5}function ue(z,U,f,j){var me,H=z.state;return H.window===null&&(H.wsize=1<<H.wbits,H.wnext=0,H.whave=0,H.window=new l.Buf8(H.wsize)),j>=H.wsize?(l.arraySet(H.window,U,f-H.wsize,H.wsize,0),H.wnext=0,H.whave=H.wsize):(j<(me=H.wsize-H.wnext)&&(me=j),l.arraySet(H.window,U,f-j,me,H.wnext),(j-=me)?(l.arraySet(H.window,U,f-j,j,0),H.wnext=j,H.whave=H.wsize):(H.wnext+=me,H.wnext===H.wsize&&(H.wnext=0),H.whave<H.wsize&&(H.whave+=me))),0}a.inflateReset=L,a.inflateReset2=R,a.inflateResetKeep=I,a.inflateInit=function(z){return Y(z,15)},a.inflateInit2=Y,a.inflate=function(z,U){var f,j,me,H,y,w,D,x,S,F,B,M,Q,K,re,pe,de,fe,_e,Te,u,Z,W,A,k=0,P=new l.Buf8(4),X=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!z||!z.state||!z.output||!z.input&&z.avail_in!==0)return m;(f=z.state).mode===12&&(f.mode=13),y=z.next_out,me=z.output,D=z.avail_out,H=z.next_in,j=z.input,w=z.avail_in,x=f.hold,S=f.bits,F=w,B=D,Z=b;e:for(;;)switch(f.mode){case E:if(f.wrap===0){f.mode=13;break}for(;S<16;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}if(2&f.wrap&&x===35615){P[f.check=0]=255&x,P[1]=x>>>8&255,f.check=i(f.check,P,2,0),S=x=0,f.mode=2;break}if(f.flags=0,f.head&&(f.head.done=!1),!(1&f.wrap)||(((255&x)<<8)+(x>>8))%31){z.msg="incorrect header check",f.mode=30;break}if((15&x)!=8){z.msg="unknown compression method",f.mode=30;break}if(S-=4,u=8+(15&(x>>>=4)),f.wbits===0)f.wbits=u;else if(u>f.wbits){z.msg="invalid window size",f.mode=30;break}f.dmax=1<<u,z.adler=f.check=1,f.mode=512&x?10:12,S=x=0;break;case 2:for(;S<16;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}if(f.flags=x,(255&f.flags)!=8){z.msg="unknown compression method",f.mode=30;break}if(57344&f.flags){z.msg="unknown header flags set",f.mode=30;break}f.head&&(f.head.text=x>>8&1),512&f.flags&&(P[0]=255&x,P[1]=x>>>8&255,f.check=i(f.check,P,2,0)),S=x=0,f.mode=3;case 3:for(;S<32;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}f.head&&(f.head.time=x),512&f.flags&&(P[0]=255&x,P[1]=x>>>8&255,P[2]=x>>>16&255,P[3]=x>>>24&255,f.check=i(f.check,P,4,0)),S=x=0,f.mode=4;case 4:for(;S<16;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}f.head&&(f.head.xflags=255&x,f.head.os=x>>8),512&f.flags&&(P[0]=255&x,P[1]=x>>>8&255,f.check=i(f.check,P,2,0)),S=x=0,f.mode=5;case 5:if(1024&f.flags){for(;S<16;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}f.length=x,f.head&&(f.head.extra_len=x),512&f.flags&&(P[0]=255&x,P[1]=x>>>8&255,f.check=i(f.check,P,2,0)),S=x=0}else f.head&&(f.head.extra=null);f.mode=6;case 6:if(1024&f.flags&&(w<(M=f.length)&&(M=w),M&&(f.head&&(u=f.head.extra_len-f.length,f.head.extra||(f.head.extra=new Array(f.head.extra_len)),l.arraySet(f.head.extra,j,H,M,u)),512&f.flags&&(f.check=i(f.check,j,M,H)),w-=M,H+=M,f.length-=M),f.length))break e;f.length=0,f.mode=7;case 7:if(2048&f.flags){if(w===0)break e;for(M=0;u=j[H+M++],f.head&&u&&f.length<65536&&(f.head.name+=String.fromCharCode(u)),u&&M<w;);if(512&f.flags&&(f.check=i(f.check,j,M,H)),w-=M,H+=M,u)break e}else f.head&&(f.head.name=null);f.length=0,f.mode=8;case 8:if(4096&f.flags){if(w===0)break e;for(M=0;u=j[H+M++],f.head&&u&&f.length<65536&&(f.head.comment+=String.fromCharCode(u)),u&&M<w;);if(512&f.flags&&(f.check=i(f.check,j,M,H)),w-=M,H+=M,u)break e}else f.head&&(f.head.comment=null);f.mode=9;case 9:if(512&f.flags){for(;S<16;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}if(x!==(65535&f.check)){z.msg="header crc mismatch",f.mode=30;break}S=x=0}f.head&&(f.head.hcrc=f.flags>>9&1,f.head.done=!0),z.adler=f.check=0,f.mode=12;break;case 10:for(;S<32;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}z.adler=f.check=_(x),S=x=0,f.mode=11;case 11:if(f.havedict===0)return z.next_out=y,z.avail_out=D,z.next_in=H,z.avail_in=w,f.hold=x,f.bits=S,2;z.adler=f.check=1,f.mode=12;case 12:if(U===5||U===6)break e;case 13:if(f.last){x>>>=7&S,S-=7&S,f.mode=27;break}for(;S<3;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}switch(f.last=1&x,S-=1,3&(x>>>=1)){case 0:f.mode=14;break;case 1:if(ne(f),f.mode=20,U!==6)break;x>>>=2,S-=2;break e;case 2:f.mode=17;break;case 3:z.msg="invalid block type",f.mode=30}x>>>=2,S-=2;break;case 14:for(x>>>=7&S,S-=7&S;S<32;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}if((65535&x)!=(x>>>16^65535)){z.msg="invalid stored block lengths",f.mode=30;break}if(f.length=65535&x,S=x=0,f.mode=15,U===6)break e;case 15:f.mode=16;case 16:if(M=f.length){if(w<M&&(M=w),D<M&&(M=D),M===0)break e;l.arraySet(me,j,H,M,y),w-=M,H+=M,D-=M,y+=M,f.length-=M;break}f.mode=12;break;case 17:for(;S<14;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}if(f.nlen=257+(31&x),x>>>=5,S-=5,f.ndist=1+(31&x),x>>>=5,S-=5,f.ncode=4+(15&x),x>>>=4,S-=4,286<f.nlen||30<f.ndist){z.msg="too many length or distance symbols",f.mode=30;break}f.have=0,f.mode=18;case 18:for(;f.have<f.ncode;){for(;S<3;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}f.lens[X[f.have++]]=7&x,x>>>=3,S-=3}for(;f.have<19;)f.lens[X[f.have++]]=0;if(f.lencode=f.lendyn,f.lenbits=7,W={bits:f.lenbits},Z=v(0,f.lens,0,19,f.lencode,0,f.work,W),f.lenbits=W.bits,Z){z.msg="invalid code lengths set",f.mode=30;break}f.have=0,f.mode=19;case 19:for(;f.have<f.nlen+f.ndist;){for(;pe=(k=f.lencode[x&(1<<f.lenbits)-1])>>>16&255,de=65535&k,!((re=k>>>24)<=S);){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}if(de<16)x>>>=re,S-=re,f.lens[f.have++]=de;else{if(de===16){for(A=re+2;S<A;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}if(x>>>=re,S-=re,f.have===0){z.msg="invalid bit length repeat",f.mode=30;break}u=f.lens[f.have-1],M=3+(3&x),x>>>=2,S-=2}else if(de===17){for(A=re+3;S<A;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}S-=re,u=0,M=3+(7&(x>>>=re)),x>>>=3,S-=3}else{for(A=re+7;S<A;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}S-=re,u=0,M=11+(127&(x>>>=re)),x>>>=7,S-=7}if(f.have+M>f.nlen+f.ndist){z.msg="invalid bit length repeat",f.mode=30;break}for(;M--;)f.lens[f.have++]=u}}if(f.mode===30)break;if(f.lens[256]===0){z.msg="invalid code -- missing end-of-block",f.mode=30;break}if(f.lenbits=9,W={bits:f.lenbits},Z=v(h,f.lens,0,f.nlen,f.lencode,0,f.work,W),f.lenbits=W.bits,Z){z.msg="invalid literal/lengths set",f.mode=30;break}if(f.distbits=6,f.distcode=f.distdyn,W={bits:f.distbits},Z=v(p,f.lens,f.nlen,f.ndist,f.distcode,0,f.work,W),f.distbits=W.bits,Z){z.msg="invalid distances set",f.mode=30;break}if(f.mode=20,U===6)break e;case 20:f.mode=21;case 21:if(6<=w&&258<=D){z.next_out=y,z.avail_out=D,z.next_in=H,z.avail_in=w,f.hold=x,f.bits=S,d(z,B),y=z.next_out,me=z.output,D=z.avail_out,H=z.next_in,j=z.input,w=z.avail_in,x=f.hold,S=f.bits,f.mode===12&&(f.back=-1);break}for(f.back=0;pe=(k=f.lencode[x&(1<<f.lenbits)-1])>>>16&255,de=65535&k,!((re=k>>>24)<=S);){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}if(pe&&(240&pe)==0){for(fe=re,_e=pe,Te=de;pe=(k=f.lencode[Te+((x&(1<<fe+_e)-1)>>fe)])>>>16&255,de=65535&k,!(fe+(re=k>>>24)<=S);){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}x>>>=fe,S-=fe,f.back+=fe}if(x>>>=re,S-=re,f.back+=re,f.length=de,pe===0){f.mode=26;break}if(32&pe){f.back=-1,f.mode=12;break}if(64&pe){z.msg="invalid literal/length code",f.mode=30;break}f.extra=15&pe,f.mode=22;case 22:if(f.extra){for(A=f.extra;S<A;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}f.length+=x&(1<<f.extra)-1,x>>>=f.extra,S-=f.extra,f.back+=f.extra}f.was=f.length,f.mode=23;case 23:for(;pe=(k=f.distcode[x&(1<<f.distbits)-1])>>>16&255,de=65535&k,!((re=k>>>24)<=S);){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}if((240&pe)==0){for(fe=re,_e=pe,Te=de;pe=(k=f.distcode[Te+((x&(1<<fe+_e)-1)>>fe)])>>>16&255,de=65535&k,!(fe+(re=k>>>24)<=S);){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}x>>>=fe,S-=fe,f.back+=fe}if(x>>>=re,S-=re,f.back+=re,64&pe){z.msg="invalid distance code",f.mode=30;break}f.offset=de,f.extra=15&pe,f.mode=24;case 24:if(f.extra){for(A=f.extra;S<A;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}f.offset+=x&(1<<f.extra)-1,x>>>=f.extra,S-=f.extra,f.back+=f.extra}if(f.offset>f.dmax){z.msg="invalid distance too far back",f.mode=30;break}f.mode=25;case 25:if(D===0)break e;if(M=B-D,f.offset>M){if((M=f.offset-M)>f.whave&&f.sane){z.msg="invalid distance too far back",f.mode=30;break}Q=M>f.wnext?(M-=f.wnext,f.wsize-M):f.wnext-M,M>f.length&&(M=f.length),K=f.window}else K=me,Q=y-f.offset,M=f.length;for(D<M&&(M=D),D-=M,f.length-=M;me[y++]=K[Q++],--M;);f.length===0&&(f.mode=21);break;case 26:if(D===0)break e;me[y++]=f.length,D--,f.mode=21;break;case 27:if(f.wrap){for(;S<32;){if(w===0)break e;w--,x|=j[H++]<<S,S+=8}if(B-=D,z.total_out+=B,f.total+=B,B&&(z.adler=f.check=f.flags?i(f.check,me,B,y-B):s(f.check,me,B,y-B)),B=D,(f.flags?x:_(x))!==f.check){z.msg="incorrect data check",f.mode=30;break}S=x=0}f.mode=28;case 28:if(f.wrap&&f.flags){for(;S<32;){if(w===0)break e;w--,x+=j[H++]<<S,S+=8}if(x!==(4294967295&f.total)){z.msg="incorrect length check",f.mode=30;break}S=x=0}f.mode=29;case 29:Z=1;break e;case 30:Z=-3;break e;case 31:return-4;case 32:default:return m}return z.next_out=y,z.avail_out=D,z.next_in=H,z.avail_in=w,f.hold=x,f.bits=S,(f.wsize||B!==z.avail_out&&f.mode<30&&(f.mode<27||U!==4))&&ue(z,z.output,z.next_out,B-z.avail_out)?(f.mode=31,-4):(F-=z.avail_in,B-=z.avail_out,z.total_in+=F,z.total_out+=B,f.total+=B,f.wrap&&B&&(z.adler=f.check=f.flags?i(f.check,me,B,z.next_out-B):s(f.check,me,B,z.next_out-B)),z.data_type=f.bits+(f.last?64:0)+(f.mode===12?128:0)+(f.mode===20||f.mode===15?256:0),(F==0&&B===0||U===4)&&Z===b&&(Z=-5),Z)},a.inflateEnd=function(z){if(!z||!z.state)return m;var U=z.state;return U.window&&(U.window=null),z.state=null,b},a.inflateGetHeader=function(z,U){var f;return z&&z.state?(2&(f=z.state).wrap)==0?m:((f.head=U).done=!1,b):m},a.inflateSetDictionary=function(z,U){var f,j=U.length;return z&&z.state?(f=z.state).wrap!==0&&f.mode!==11?m:f.mode===11&&s(1,U,j,0)!==f.check?-3:ue(z,U,j,j)?(f.mode=31,-4):(f.havedict=1,b):m},a.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":41,"./adler32":43,"./crc32":45,"./inffast":48,"./inftrees":50}],50:[function(r,o,a){var l=r("../utils/common"),s=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],i=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],d=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],v=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];o.exports=function(h,p,b,m,E,g,C,_){var T,I,L,R,Y,$,ee,N,ne,ue=_.bits,z=0,U=0,f=0,j=0,me=0,H=0,y=0,w=0,D=0,x=0,S=null,F=0,B=new l.Buf16(16),M=new l.Buf16(16),Q=null,K=0;for(z=0;z<=15;z++)B[z]=0;for(U=0;U<m;U++)B[p[b+U]]++;for(me=ue,j=15;1<=j&&B[j]===0;j--);if(j<me&&(me=j),j===0)return E[g++]=20971520,E[g++]=20971520,_.bits=1,0;for(f=1;f<j&&B[f]===0;f++);for(me<f&&(me=f),z=w=1;z<=15;z++)if(w<<=1,(w-=B[z])<0)return-1;if(0<w&&(h===0||j!==1))return-1;for(M[1]=0,z=1;z<15;z++)M[z+1]=M[z]+B[z];for(U=0;U<m;U++)p[b+U]!==0&&(C[M[p[b+U]]++]=U);if($=h===0?(S=Q=C,19):h===1?(S=s,F-=257,Q=i,K-=257,256):(S=d,Q=v,-1),z=f,Y=g,y=U=x=0,L=-1,R=(D=1<<(H=me))-1,h===1&&852<D||h===2&&592<D)return 1;for(;;){for(ee=z-y,ne=C[U]<$?(N=0,C[U]):C[U]>$?(N=Q[K+C[U]],S[F+C[U]]):(N=96,0),T=1<<z-y,f=I=1<<H;E[Y+(x>>y)+(I-=T)]=ee<<24|N<<16|ne|0,I!==0;);for(T=1<<z-1;x&T;)T>>=1;if(T!==0?(x&=T-1,x+=T):x=0,U++,--B[z]==0){if(z===j)break;z=p[b+C[U]]}if(me<z&&(x&R)!==L){for(y===0&&(y=me),Y+=f,w=1<<(H=z-y);H+y<j&&!((w-=B[H+y])<=0);)H++,w<<=1;if(D+=1<<H,h===1&&852<D||h===2&&592<D)return 1;E[L=x&R]=me<<24|H<<16|Y-g|0}}return x!==0&&(E[Y+x]=z-y<<24|64<<16|0),_.bits=me,0}},{"../utils/common":41}],51:[function(r,o,a){o.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],52:[function(r,o,a){var l=r("../utils/common"),s=0,i=1;function d(k){for(var P=k.length;0<=--P;)k[P]=0}var v=0,h=29,p=256,b=p+1+h,m=30,E=19,g=2*b+1,C=15,_=16,T=7,I=256,L=16,R=17,Y=18,$=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],ee=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],N=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],ne=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],ue=new Array(2*(b+2));d(ue);var z=new Array(2*m);d(z);var U=new Array(512);d(U);var f=new Array(256);d(f);var j=new Array(h);d(j);var me,H,y,w=new Array(m);function D(k,P,X,J,q){this.static_tree=k,this.extra_bits=P,this.extra_base=X,this.elems=J,this.max_length=q,this.has_stree=k&&k.length}function x(k,P){this.dyn_tree=k,this.max_code=0,this.stat_desc=P}function S(k){return k<256?U[k]:U[256+(k>>>7)]}function F(k,P){k.pending_buf[k.pending++]=255&P,k.pending_buf[k.pending++]=P>>>8&255}function B(k,P,X){k.bi_valid>_-X?(k.bi_buf|=P<<k.bi_valid&65535,F(k,k.bi_buf),k.bi_buf=P>>_-k.bi_valid,k.bi_valid+=X-_):(k.bi_buf|=P<<k.bi_valid&65535,k.bi_valid+=X)}function M(k,P,X){B(k,X[2*P],X[2*P+1])}function Q(k,P){for(var X=0;X|=1&k,k>>>=1,X<<=1,0<--P;);return X>>>1}function K(k,P,X){var J,q,ie=new Array(C+1),le=0;for(J=1;J<=C;J++)ie[J]=le=le+X[J-1]<<1;for(q=0;q<=P;q++){var ae=k[2*q+1];ae!==0&&(k[2*q]=Q(ie[ae]++,ae))}}function re(k){var P;for(P=0;P<b;P++)k.dyn_ltree[2*P]=0;for(P=0;P<m;P++)k.dyn_dtree[2*P]=0;for(P=0;P<E;P++)k.bl_tree[2*P]=0;k.dyn_ltree[2*I]=1,k.opt_len=k.static_len=0,k.last_lit=k.matches=0}function pe(k){8<k.bi_valid?F(k,k.bi_buf):0<k.bi_valid&&(k.pending_buf[k.pending++]=k.bi_buf),k.bi_buf=0,k.bi_valid=0}function de(k,P,X,J){var q=2*P,ie=2*X;return k[q]<k[ie]||k[q]===k[ie]&&J[P]<=J[X]}function fe(k,P,X){for(var J=k.heap[X],q=X<<1;q<=k.heap_len&&(q<k.heap_len&&de(P,k.heap[q+1],k.heap[q],k.depth)&&q++,!de(P,J,k.heap[q],k.depth));)k.heap[X]=k.heap[q],X=q,q<<=1;k.heap[X]=J}function _e(k,P,X){var J,q,ie,le,ae=0;if(k.last_lit!==0)for(;J=k.pending_buf[k.d_buf+2*ae]<<8|k.pending_buf[k.d_buf+2*ae+1],q=k.pending_buf[k.l_buf+ae],ae++,J===0?M(k,q,P):(M(k,(ie=f[q])+p+1,P),(le=$[ie])!==0&&B(k,q-=j[ie],le),M(k,ie=S(--J),X),(le=ee[ie])!==0&&B(k,J-=w[ie],le)),ae<k.last_lit;);M(k,I,P)}function Te(k,P){var X,J,q,ie=P.dyn_tree,le=P.stat_desc.static_tree,ae=P.stat_desc.has_stree,ce=P.stat_desc.elems,Se=-1;for(k.heap_len=0,k.heap_max=g,X=0;X<ce;X++)ie[2*X]!==0?(k.heap[++k.heap_len]=Se=X,k.depth[X]=0):ie[2*X+1]=0;for(;k.heap_len<2;)ie[2*(q=k.heap[++k.heap_len]=Se<2?++Se:0)]=1,k.depth[q]=0,k.opt_len--,ae&&(k.static_len-=le[2*q+1]);for(P.max_code=Se,X=k.heap_len>>1;1<=X;X--)fe(k,ie,X);for(q=ce;X=k.heap[1],k.heap[1]=k.heap[k.heap_len--],fe(k,ie,1),J=k.heap[1],k.heap[--k.heap_max]=X,k.heap[--k.heap_max]=J,ie[2*q]=ie[2*X]+ie[2*J],k.depth[q]=(k.depth[X]>=k.depth[J]?k.depth[X]:k.depth[J])+1,ie[2*X+1]=ie[2*J+1]=q,k.heap[1]=q++,fe(k,ie,1),2<=k.heap_len;);k.heap[--k.heap_max]=k.heap[1],function(we,Ie){var et,Le,lt,ze,ct,_t,We=Ie.dyn_tree,Rt=Ie.max_code,nr=Ie.stat_desc.static_tree,wt=Ie.stat_desc.has_stree,Ft=Ie.stat_desc.extra_bits,Ye=Ie.stat_desc.extra_base,Ke=Ie.stat_desc.max_length,tt=0;for(ze=0;ze<=C;ze++)we.bl_count[ze]=0;for(We[2*we.heap[we.heap_max]+1]=0,et=we.heap_max+1;et<g;et++)Ke<(ze=We[2*We[2*(Le=we.heap[et])+1]+1]+1)&&(ze=Ke,tt++),We[2*Le+1]=ze,Rt<Le||(we.bl_count[ze]++,ct=0,Ye<=Le&&(ct=Ft[Le-Ye]),_t=We[2*Le],we.opt_len+=_t*(ze+ct),wt&&(we.static_len+=_t*(nr[2*Le+1]+ct)));if(tt!==0){do{for(ze=Ke-1;we.bl_count[ze]===0;)ze--;we.bl_count[ze]--,we.bl_count[ze+1]+=2,we.bl_count[Ke]--,tt-=2}while(0<tt);for(ze=Ke;ze!==0;ze--)for(Le=we.bl_count[ze];Le!==0;)Rt<(lt=we.heap[--et])||(We[2*lt+1]!==ze&&(we.opt_len+=(ze-We[2*lt+1])*We[2*lt],We[2*lt+1]=ze),Le--)}}(k,P),K(ie,Se,k.bl_count)}function u(k,P,X){var J,q,ie=-1,le=P[1],ae=0,ce=7,Se=4;for(le===0&&(ce=138,Se=3),P[2*(X+1)+1]=65535,J=0;J<=X;J++)q=le,le=P[2*(J+1)+1],++ae<ce&&q===le||(ae<Se?k.bl_tree[2*q]+=ae:q!==0?(q!==ie&&k.bl_tree[2*q]++,k.bl_tree[2*L]++):ae<=10?k.bl_tree[2*R]++:k.bl_tree[2*Y]++,ie=q,Se=(ae=0)===le?(ce=138,3):q===le?(ce=6,3):(ce=7,4))}function Z(k,P,X){var J,q,ie=-1,le=P[1],ae=0,ce=7,Se=4;for(le===0&&(ce=138,Se=3),J=0;J<=X;J++)if(q=le,le=P[2*(J+1)+1],!(++ae<ce&&q===le)){if(ae<Se)for(;M(k,q,k.bl_tree),--ae!=0;);else q!==0?(q!==ie&&(M(k,q,k.bl_tree),ae--),M(k,L,k.bl_tree),B(k,ae-3,2)):ae<=10?(M(k,R,k.bl_tree),B(k,ae-3,3)):(M(k,Y,k.bl_tree),B(k,ae-11,7));ie=q,Se=(ae=0)===le?(ce=138,3):q===le?(ce=6,3):(ce=7,4)}}d(w);var W=!1;function A(k,P,X,J){B(k,(v<<1)+(J?1:0),3),function(q,ie,le,ae){pe(q),ae&&(F(q,le),F(q,~le)),l.arraySet(q.pending_buf,q.window,ie,le,q.pending),q.pending+=le}(k,P,X,!0)}a._tr_init=function(k){W||(function(){var P,X,J,q,ie,le=new Array(C+1);for(q=J=0;q<h-1;q++)for(j[q]=J,P=0;P<1<<$[q];P++)f[J++]=q;for(f[J-1]=q,q=ie=0;q<16;q++)for(w[q]=ie,P=0;P<1<<ee[q];P++)U[ie++]=q;for(ie>>=7;q<m;q++)for(w[q]=ie<<7,P=0;P<1<<ee[q]-7;P++)U[256+ie++]=q;for(X=0;X<=C;X++)le[X]=0;for(P=0;P<=143;)ue[2*P+1]=8,P++,le[8]++;for(;P<=255;)ue[2*P+1]=9,P++,le[9]++;for(;P<=279;)ue[2*P+1]=7,P++,le[7]++;for(;P<=287;)ue[2*P+1]=8,P++,le[8]++;for(K(ue,b+1,le),P=0;P<m;P++)z[2*P+1]=5,z[2*P]=Q(P,5);me=new D(ue,$,p+1,b,C),H=new D(z,ee,0,m,C),y=new D(new Array(0),N,0,E,T)}(),W=!0),k.l_desc=new x(k.dyn_ltree,me),k.d_desc=new x(k.dyn_dtree,H),k.bl_desc=new x(k.bl_tree,y),k.bi_buf=0,k.bi_valid=0,re(k)},a._tr_stored_block=A,a._tr_flush_block=function(k,P,X,J){var q,ie,le=0;0<k.level?(k.strm.data_type===2&&(k.strm.data_type=function(ae){var ce,Se=4093624447;for(ce=0;ce<=31;ce++,Se>>>=1)if(1&Se&&ae.dyn_ltree[2*ce]!==0)return s;if(ae.dyn_ltree[18]!==0||ae.dyn_ltree[20]!==0||ae.dyn_ltree[26]!==0)return i;for(ce=32;ce<p;ce++)if(ae.dyn_ltree[2*ce]!==0)return i;return s}(k)),Te(k,k.l_desc),Te(k,k.d_desc),le=function(ae){var ce;for(u(ae,ae.dyn_ltree,ae.l_desc.max_code),u(ae,ae.dyn_dtree,ae.d_desc.max_code),Te(ae,ae.bl_desc),ce=E-1;3<=ce&&ae.bl_tree[2*ne[ce]+1]===0;ce--);return ae.opt_len+=3*(ce+1)+5+5+4,ce}(k),q=k.opt_len+3+7>>>3,(ie=k.static_len+3+7>>>3)<=q&&(q=ie)):q=ie=X+5,X+4<=q&&P!==-1?A(k,P,X,J):k.strategy===4||ie===q?(B(k,2+(J?1:0),3),_e(k,ue,z)):(B(k,4+(J?1:0),3),function(ae,ce,Se,we){var Ie;for(B(ae,ce-257,5),B(ae,Se-1,5),B(ae,we-4,4),Ie=0;Ie<we;Ie++)B(ae,ae.bl_tree[2*ne[Ie]+1],3);Z(ae,ae.dyn_ltree,ce-1),Z(ae,ae.dyn_dtree,Se-1)}(k,k.l_desc.max_code+1,k.d_desc.max_code+1,le+1),_e(k,k.dyn_ltree,k.dyn_dtree)),re(k),J&&pe(k)},a._tr_tally=function(k,P,X){return k.pending_buf[k.d_buf+2*k.last_lit]=P>>>8&255,k.pending_buf[k.d_buf+2*k.last_lit+1]=255&P,k.pending_buf[k.l_buf+k.last_lit]=255&X,k.last_lit++,P===0?k.dyn_ltree[2*X]++:(k.matches++,P--,k.dyn_ltree[2*(f[X]+p+1)]++,k.dyn_dtree[2*S(P)]++),k.last_lit===k.lit_bufsize-1},a._tr_align=function(k){B(k,2,3),M(k,I,ue),function(P){P.bi_valid===16?(F(P,P.bi_buf),P.bi_buf=0,P.bi_valid=0):8<=P.bi_valid&&(P.pending_buf[P.pending++]=255&P.bi_buf,P.bi_buf>>=8,P.bi_valid-=8)}(k)}},{"../utils/common":41}],53:[function(r,o,a){o.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(r,o,a){(function(l){(function(s,i){if(!s.setImmediate){var d,v,h,p,b=1,m={},E=!1,g=s.document,C=Object.getPrototypeOf&&Object.getPrototypeOf(s);C=C&&C.setTimeout?C:s,d={}.toString.call(s.process)==="[object process]"?function(L){process.nextTick(function(){T(L)})}:function(){if(s.postMessage&&!s.importScripts){var L=!0,R=s.onmessage;return s.onmessage=function(){L=!1},s.postMessage("","*"),s.onmessage=R,L}}()?(p="setImmediate$"+Math.random()+"$",s.addEventListener?s.addEventListener("message",I,!1):s.attachEvent("onmessage",I),function(L){s.postMessage(p+L,"*")}):s.MessageChannel?((h=new MessageChannel).port1.onmessage=function(L){T(L.data)},function(L){h.port2.postMessage(L)}):g&&"onreadystatechange"in g.createElement("script")?(v=g.documentElement,function(L){var R=g.createElement("script");R.onreadystatechange=function(){T(L),R.onreadystatechange=null,v.removeChild(R),R=null},v.appendChild(R)}):function(L){setTimeout(T,0,L)},C.setImmediate=function(L){typeof L!="function"&&(L=new Function(""+L));for(var R=new Array(arguments.length-1),Y=0;Y<R.length;Y++)R[Y]=arguments[Y+1];var $={callback:L,args:R};return m[b]=$,d(b),b++},C.clearImmediate=_}function _(L){delete m[L]}function T(L){if(E)setTimeout(T,0,L);else{var R=m[L];if(R){E=!0;try{(function(Y){var $=Y.callback,ee=Y.args;switch(ee.length){case 0:$();break;case 1:$(ee[0]);break;case 2:$(ee[0],ee[1]);break;case 3:$(ee[0],ee[1],ee[2]);break;default:$.apply(i,ee)}})(R)}finally{_(L),E=!1}}}}function I(L){L.source===s&&typeof L.data=="string"&&L.data.indexOf(p)===0&&T(+L.data.slice(p.length))}})(typeof self>"u"?l===void 0?this:l:self)}).call(this,typeof Qe<"u"?Qe:typeof self<"u"?self:typeof window<"u"?window:{})},{}]},{},[10])(10)})})(nn);const hs=nn.exports;var tr={exports:{}};(function(t,e){(function(r,o){o()})(Qe,function(){function r(v,h){return typeof h>"u"?h={autoBom:!1}:typeof h!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),h={autoBom:!h}),h.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(v.type)?new Blob(["\uFEFF",v],{type:v.type}):v}function o(v,h,p){var b=new XMLHttpRequest;b.open("GET",v),b.responseType="blob",b.onload=function(){d(b.response,h,p)},b.onerror=function(){console.error("could not download file")},b.send()}function a(v){var h=new XMLHttpRequest;h.open("HEAD",v,!1);try{h.send()}catch{}return 200<=h.status&&299>=h.status}function l(v){try{v.dispatchEvent(new MouseEvent("click"))}catch{var h=document.createEvent("MouseEvents");h.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),v.dispatchEvent(h)}}var s=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof Qe=="object"&&Qe.global===Qe?Qe:void 0,i=s.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),d=s.saveAs||(typeof window!="object"||window!==s?function(){}:"download"in HTMLAnchorElement.prototype&&!i?function(v,h,p){var b=s.URL||s.webkitURL,m=document.createElement("a");h=h||v.name||"download",m.download=h,m.rel="noopener",typeof v=="string"?(m.href=v,m.origin===location.origin?l(m):a(m.href)?o(v,h,p):l(m,m.target="_blank")):(m.href=b.createObjectURL(v),setTimeout(function(){b.revokeObjectURL(m.href)},4e4),setTimeout(function(){l(m)},0))}:"msSaveOrOpenBlob"in navigator?function(v,h,p){if(h=h||v.name||"download",typeof v!="string")navigator.msSaveOrOpenBlob(r(v,p),h);else if(a(v))o(v,h,p);else{var b=document.createElement("a");b.href=v,b.target="_blank",setTimeout(function(){l(b)})}}:function(v,h,p,b){if(b=b||open("","_blank"),b&&(b.document.title=b.document.body.innerText="downloading..."),typeof v=="string")return o(v,h,p);var m=v.type==="application/octet-stream",E=/constructor/i.test(s.HTMLElement)||s.safari,g=/CriOS\/[\d]+/.test(navigator.userAgent);if((g||m&&E||i)&&typeof FileReader<"u"){var C=new FileReader;C.onloadend=function(){var I=C.result;I=g?I:I.replace(/^data:[^;]*;/,"data:attachment/file;"),b?b.location.href=I:location=I,b=null},C.readAsDataURL(v)}else{var _=s.URL||s.webkitURL,T=_.createObjectURL(v);b?b.location=T:location.href=T,b=null,setTimeout(function(){_.revokeObjectURL(T)},4e4)}});s.saveAs=d.saveAs=d,t.exports=d})})(tr);function ps(t,e){const r=new Blob([e],{type:"text/csv"});tr.exports.saveAs(r,`${t}.csv`)}function ms(t){const e=new hs;t.forEach(({id:r,data:o})=>{e.file(`${r}.csv`,an(o))}),e.generateAsync({type:"blob"}).then(r=>{tr.exports.saveAs(r,"dashboard_data.zip")})}function an(t){if(!Array.isArray(t)||t.length===0)return"";const e=[],r=Object.keys(t[0]);return e.push(r.join(",")),t.forEach(o=>{const a=Object.values(o).join(",");e.push(a)}),e.join(`
53
+ `)}const sn=se.types.model("QueryModel",{id:se.types.string,type:se.types.enumeration("DataSourceType",[yt.Postgresql,yt.MySQL,yt.HTTP]),key:se.types.string,sql:se.types.string}).views(t=>({get valid(){return t.id&&t.type&&t.key&&t.sql},get configurations(){const{id:e,type:r,key:o,sql:a}=t;return{id:e,type:r,key:o,sql:a}}})),gs=se.types.compose("QueryModel",sn,se.types.model({state:se.types.optional(se.types.enumeration(["idle","loading","error"]),"idle"),data:se.types.optional(se.types.array(se.types.frozen()),[]),error:se.types.frozen()})).actions(t=>({setID(e){t.id=e},setKey(e){t.key=e},setType(e){t.type=e},setSQL(e){t.sql=e},fetchData:se.flow(function*(){if(!!t.valid){t.state="loading";try{const e=t.id,r=se.getRoot(t);t.data=yield*se.toGenerator(Aa({context:r.context.current,sqlSnippets:r.sqlSnippets.current,title:e,query:{type:t.type,key:t.key,sql:t.sql},filterValues:{}})),t.state="idle"}catch(e){console.error(e),t.error=e,t.state="error"}}})})).actions(t=>({afterCreate(){se.addDisposer(t,Cn.reaction(()=>`${t.id}--${t.key}--${t.type}--${t.sql}`,t.fetchData,{fireImmediately:!0,delay:500}))}})),vs=se.types.model("QueriesModel",{original:se.types.optional(se.types.array(sn),[]),current:se.types.optional(se.types.array(gs),[])}).views(t=>({get changed(){return t.original.length!==t.current.length?!0:t.original.some((e,r)=>!ye.default.isEqual(e.configurations,t.current[r].configurations))},get firstID(){if(t.current.length!==0)return t.current[0].id},findByID(e){return t.current.find(r=>r.id===e)},get options(){return t.current.map(e=>({value:e.id,label:e.id}))}})).actions(t=>({reset(){t.current=se.cast(t.original)},replace(e){t.current=se.cast(e)},append(e){t.current.push(e)},remove(e){t.current.splice(e,1)},replaceByIndex(e,r){t.current.splice(e,1,r)},downloadAllData(){const e=t.current.map(({id:r,data:o})=>({id:r,data:o.toJSON()}));ms(e)},downloadDataByQueryID(e){const r=t.findByID(e);if(!r){console.log(`[downloadDataByQueryID] query by ID[${e}] not found`);return}const{id:o,data:a}=r,l=an(a);ps(o,l)},refetchDataByQueryID(e){const r=t.findByID(e);if(!r){console.error(new Error(`[downloadDataByQueryID] query by ID[${e}] not found`));return}return r.fetchData()}})),on=se.types.model("SQLSnippetModel",{key:se.types.string,value:se.types.string}).actions(t=>({setKey(e){t.key=e},setValue(e){t.value=e}})),bs=se.types.model("SQLSnippetsModel",{original:se.types.optional(se.types.array(on),[]),current:se.types.optional(se.types.array(on),[])}).views(t=>({get changed(){return!ye.default.isEqual(t.original,t.current)}})).actions(t=>({reset(){t.current=ye.default.cloneDeep(t.original)},replace(e){t.current=se.cast(e)},append(e){t.current.push(e)},remove(e){t.current.splice(e,1)},replaceByIndex(e,r){t.current.splice(e,1,r)}})),ys=se.types.model({id:se.types.identifier,name:se.types.string,filters:ds,queries:vs,sqlSnippets:bs,context:ss}).views(t=>({get data(){return t.queries.current.map(({id:r,data:o})=>({id:r,data:o})).reduce((r,o)=>(r[o.id]=o.data,r),{})},getDataStuffByID(e){const r=t.queries.findByID(e);return r?{data:r.data.toJSON(),state:r.state,error:void 0}:{data:[],state:"idle",error:void 0}},getDataStateByID(e){var r,o;return(o=(r=t.queries.findByID(e))==null?void 0:r.state)!=null?o:[]},getDataErrorByID(e){var r,o;return(o=(r=t.queries.findByID(e))==null?void 0:r.error)!=null?o:[]}}));function ln({id:t,name:e,filters:r,definition:{queries:o,sqlSnippets:a}},l){return ys.create({id:t,name:e,filters:fs(r),queries:{original:o,current:o},sqlSnippets:{original:a,current:a},context:l})}const _s="2.5.0";class ws{constructor(){rt(this,"plugins",new Map);rt(this,"vizComponents",new Map);rt(this,"factory",{viz:e=>{const r=this.vizComponents.get(e);if(r)return r;throw new Error(`Viz Component (${e}) not found`)}})}install(e){if(this.plugins.has(e.id))throw new Error(`Plugin (${e.id}) has been installed before`);this.plugins.set(e.id,e);for(const r of e.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 xs{constructor(e){this.root=e}async deleteItem(e){delete this.root[e]}getItem(e){return Promise.resolve($e.get(this.root,[e]))}setItem(e,r){return $e.set(this.root,[e],r),Promise.resolve(this.getItem(e))}}var un={exports:{}};/*!
54
+ * EventEmitter2
55
+ * https://github.com/hij1nx/EventEmitter2
56
+ *
57
+ * Copyright (c) 2013 hij1nx
58
+ * Licensed under the MIT license.
59
+ */(function(t,e){(function(r){var o=Object.hasOwnProperty,a=Array.isArray?Array.isArray:function(w){return Object.prototype.toString.call(w)==="[object Array]"},l=10,s=typeof process=="object"&&typeof process.nextTick=="function",i=typeof Symbol=="function",d=typeof Reflect=="object",v=typeof setImmediate=="function",h=v?setImmediate:setTimeout,p=i?d&&typeof Reflect.ownKeys=="function"?Reflect.ownKeys:function(y){var w=Object.getOwnPropertyNames(y);return w.push.apply(w,Object.getOwnPropertySymbols(y)),w}:Object.keys;function b(){this._events={},this._conf&&m.call(this,this._conf)}function m(y){y&&(this._conf=y,y.delimiter&&(this.delimiter=y.delimiter),y.maxListeners!==r&&(this._maxListeners=y.maxListeners),y.wildcard&&(this.wildcard=y.wildcard),y.newListener&&(this._newListener=y.newListener),y.removeListener&&(this._removeListener=y.removeListener),y.verboseMemoryLeak&&(this.verboseMemoryLeak=y.verboseMemoryLeak),y.ignoreErrors&&(this.ignoreErrors=y.ignoreErrors),this.wildcard&&(this.listenerTree={}))}function E(y,w){var D="(node) warning: possible EventEmitter memory leak detected. "+y+" listeners added. Use emitter.setMaxListeners() to increase limit.";if(this.verboseMemoryLeak&&(D+=" Event name: "+w+"."),typeof process<"u"&&process.emitWarning){var x=new Error(D);x.name="MaxListenersExceededWarning",x.emitter=this,x.count=y,process.emitWarning(x)}else console.error(D),console.trace&&console.trace()}var g=function(y,w,D){var x=arguments.length;switch(x){case 0:return[];case 1:return[y];case 2:return[y,w];case 3:return[y,w,D];default:for(var S=new Array(x);x--;)S[x]=arguments[x];return S}};function C(y,w){for(var D={},x,S=y.length,F=w?w.length:0,B=0;B<S;B++)x=y[B],D[x]=B<F?w[B]:r;return D}function _(y,w,D){this._emitter=y,this._target=w,this._listeners={},this._listenersCount=0;var x,S;if((D.on||D.off)&&(x=D.on,S=D.off),w.addEventListener?(x=w.addEventListener,S=w.removeEventListener):w.addListener?(x=w.addListener,S=w.removeListener):w.on&&(x=w.on,S=w.off),!x&&!S)throw Error("target does not implement any known event API");if(typeof x!="function")throw TypeError("on method must be a function");if(typeof S!="function")throw TypeError("off method must be a function");this._on=x,this._off=S;var F=y._observers;F?F.push(this):y._observers=[this]}Object.assign(_.prototype,{subscribe:function(y,w,D){var x=this,S=this._target,F=this._emitter,B=this._listeners,M=function(){var Q=g.apply(null,arguments),K={data:Q,name:w,original:y};if(D){var re=D.call(S,K);re!==!1&&F.emit.apply(F,[K.name].concat(Q));return}F.emit.apply(F,[w].concat(Q))};if(B[y])throw Error("Event '"+y+"' is already listening");this._listenersCount++,F._newListener&&F._removeListener&&!x._onNewListener?(this._onNewListener=function(Q){Q===w&&B[y]===null&&(B[y]=M,x._on.call(S,y,M))},F.on("newListener",this._onNewListener),this._onRemoveListener=function(Q){Q===w&&!F.hasListeners(Q)&&B[y]&&(B[y]=null,x._off.call(S,y,M))},B[y]=null,F.on("removeListener",this._onRemoveListener)):(B[y]=M,x._on.call(S,y,M))},unsubscribe:function(y){var w=this,D=this._listeners,x=this._emitter,S,F,B=this._off,M=this._target,Q;if(y&&typeof y!="string")throw TypeError("event must be a string");function K(){w._onNewListener&&(x.off("newListener",w._onNewListener),x.off("removeListener",w._onRemoveListener),w._onNewListener=null,w._onRemoveListener=null);var re=ee.call(x,w);x._observers.splice(re,1)}if(y){if(S=D[y],!S)return;B.call(M,y,S),delete D[y],--this._listenersCount||K()}else{for(F=p(D),Q=F.length;Q-- >0;)y=F[Q],B.call(M,y,D[y]);this._listeners={},this._listenersCount=0,K()}}});function T(y,w,D,x){var S=Object.assign({},w);if(!y)return S;if(typeof y!="object")throw TypeError("options must be an object");var F=Object.keys(y),B=F.length,M,Q,K;function re(de){throw Error('Invalid "'+M+'" option value'+(de?". Reason: "+de:""))}for(var pe=0;pe<B;pe++){if(M=F[pe],!x&&!o.call(w,M))throw Error('Unknown "'+M+'" option');Q=y[M],Q!==r&&(K=D[M],S[M]=K?K(Q,re):Q)}return S}function I(y,w){return(typeof y!="function"||!y.hasOwnProperty("prototype"))&&w("value must be a constructor"),y}function L(y){var w="value must be type of "+y.join("|"),D=y.length,x=y[0],S=y[1];return D===1?function(F,B){if(typeof F===x)return F;B(w)}:D===2?function(F,B){var M=typeof F;if(M===x||M===S)return F;B(w)}:function(F,B){for(var M=typeof F,Q=D;Q-- >0;)if(M===y[Q])return F;B(w)}}var R=L(["function"]),Y=L(["object","function"]);function $(y,w,D){var x,S,F=0,B,M=new y(function(Q,K,re){D=T(D,{timeout:0,overload:!1},{timeout:function(_e,Te){return _e*=1,(typeof _e!="number"||_e<0||!Number.isFinite(_e))&&Te("timeout must be a positive number"),_e}}),x=!D.overload&&typeof y.prototype.cancel=="function"&&typeof re=="function";function pe(){S&&(S=null),F&&(clearTimeout(F),F=0)}var de=function(_e){pe(),Q(_e)},fe=function(_e){pe(),K(_e)};x?w(de,fe,re):(S=[function(_e){fe(_e||Error("canceled"))}],w(de,fe,function(_e){if(B)throw Error("Unable to subscribe on cancel event asynchronously");if(typeof _e!="function")throw TypeError("onCancel callback must be a function");S.push(_e)}),B=!0),D.timeout>0&&(F=setTimeout(function(){var _e=Error("timeout");_e.code="ETIMEDOUT",F=0,M.cancel(_e),K(_e)},D.timeout))});return x||(M.cancel=function(Q){if(!!S){for(var K=S.length,re=1;re<K;re++)S[re](Q);S[0](Q),S=null}}),M}function ee(y){var w=this._observers;if(!w)return-1;for(var D=w.length,x=0;x<D;x++)if(w[x]._target===y)return x;return-1}function N(y,w,D,x,S){if(!D)return null;if(x===0){var F=typeof w;if(F==="string"){var B,M,Q=0,K=0,re=this.delimiter,pe=re.length;if((M=w.indexOf(re))!==-1){B=new Array(5);do B[Q++]=w.slice(K,M),K=M+pe;while((M=w.indexOf(re,K))!==-1);B[Q++]=w.slice(K),w=B,S=Q}else w=[w],S=1}else F==="object"?S=w.length:(w=[w],S=1)}var de=null,fe,_e,Te,u,Z,W=w[x],A=w[x+1],k,P;if(x===S)D._listeners&&(typeof D._listeners=="function"?(y&&y.push(D._listeners),de=[D]):(y&&y.push.apply(y,D._listeners),de=[D]));else if(W==="*"){for(k=p(D),M=k.length;M-- >0;)fe=k[M],fe!=="_listeners"&&(P=N(y,w,D[fe],x+1,S),P&&(de?de.push.apply(de,P):de=P));return de}else if(W==="**"){for(Z=x+1===S||x+2===S&&A==="*",Z&&D._listeners&&(de=N(y,w,D,S,S)),k=p(D),M=k.length;M-- >0;)fe=k[M],fe!=="_listeners"&&(fe==="*"||fe==="**"?(D[fe]._listeners&&!Z&&(P=N(y,w,D[fe],S,S),P&&(de?de.push.apply(de,P):de=P)),P=N(y,w,D[fe],x,S)):fe===A?P=N(y,w,D[fe],x+2,S):P=N(y,w,D[fe],x,S),P&&(de?de.push.apply(de,P):de=P));return de}else D[W]&&(de=N(y,w,D[W],x+1,S));if(_e=D["*"],_e&&N(y,w,_e,x+1,S),Te=D["**"],Te)if(x<S)for(Te._listeners&&N(y,w,Te,S,S),k=p(Te),M=k.length;M-- >0;)fe=k[M],fe!=="_listeners"&&(fe===A?N(y,w,Te[fe],x+2,S):fe===W?N(y,w,Te[fe],x+1,S):(u={},u[fe]=Te[fe],N(y,w,{"**":u},x+1,S)));else Te._listeners?N(y,w,Te,S,S):Te["*"]&&Te["*"]._listeners&&N(y,w,Te["*"],S,S);return de}function ne(y,w,D){var x=0,S=0,F,B=this.delimiter,M=B.length,Q;if(typeof y=="string")if((F=y.indexOf(B))!==-1){Q=new Array(5);do Q[x++]=y.slice(S,F),S=F+M;while((F=y.indexOf(B,S))!==-1);Q[x++]=y.slice(S)}else Q=[y],x=1;else Q=y,x=y.length;if(x>1){for(F=0;F+1<x;F++)if(Q[F]==="**"&&Q[F+1]==="**")return}var K=this.listenerTree,re;for(F=0;F<x;F++)if(re=Q[F],K=K[re]||(K[re]={}),F===x-1)return K._listeners?(typeof K._listeners=="function"&&(K._listeners=[K._listeners]),D?K._listeners.unshift(w):K._listeners.push(w),!K._listeners.warned&&this._maxListeners>0&&K._listeners.length>this._maxListeners&&(K._listeners.warned=!0,E.call(this,K._listeners.length,re))):K._listeners=w,!0;return!0}function ue(y,w,D,x){for(var S=p(y),F=S.length,B,M,Q,K=y._listeners,re;F-- >0;)M=S[F],B=y[M],M==="_listeners"?Q=D:Q=D?D.concat(M):[M],re=x||typeof M=="symbol",K&&w.push(re?Q:Q.join(this.delimiter)),typeof B=="object"&&ue.call(this,B,w,Q,re);return w}function z(y){for(var w=p(y),D=w.length,x,S,F;D-- >0;)S=w[D],x=y[S],x&&(F=!0,S!=="_listeners"&&!z(x)&&delete y[S]);return F}function U(y,w,D){this.emitter=y,this.event=w,this.listener=D}U.prototype.off=function(){return this.emitter.off(this.event,this.listener),this};function f(y,w,D){if(D===!0)S=!0;else if(D===!1)x=!0;else{if(!D||typeof D!="object")throw TypeError("options should be an object or true");var x=D.async,S=D.promisify,F=D.nextTick,B=D.objectify}if(x||F||S){var M=w,Q=w._origin||w;if(F&&!s)throw Error("process.nextTick is not supported");S===r&&(S=w.constructor.name==="AsyncFunction"),w=function(){var K=arguments,re=this,pe=this.event;return S?F?Promise.resolve():new Promise(function(de){h(de)}).then(function(){return re.event=pe,M.apply(re,K)}):(F?process.nextTick:h)(function(){re.event=pe,M.apply(re,K)})},w._async=!0,w._origin=Q}return[w,B?new U(this,y,w):this]}function j(y){this._events={},this._newListener=!1,this._removeListener=!1,this.verboseMemoryLeak=!1,m.call(this,y)}j.EventEmitter2=j,j.prototype.listenTo=function(y,w,D){if(typeof y!="object")throw TypeError("target musts be an object");var x=this;D=T(D,{on:r,off:r,reducers:r},{on:R,off:R,reducers:Y});function S(F){if(typeof F!="object")throw TypeError("events must be an object");var B=D.reducers,M=ee.call(x,y),Q;M===-1?Q=new _(x,y,D):Q=x._observers[M];for(var K=p(F),re=K.length,pe,de=typeof B=="function",fe=0;fe<re;fe++)pe=K[fe],Q.subscribe(pe,F[pe]||pe,de?B:B&&B[pe])}return a(w)?S(C(w)):S(typeof w=="string"?C(w.split(/\s+/)):w),this},j.prototype.stopListeningTo=function(y,w){var D=this._observers;if(!D)return!1;var x=D.length,S,F=!1;if(y&&typeof y!="object")throw TypeError("target should be an object");for(;x-- >0;)S=D[x],(!y||S._target===y)&&(S.unsubscribe(w),F=!0);return F},j.prototype.delimiter=".",j.prototype.setMaxListeners=function(y){y!==r&&(this._maxListeners=y,this._conf||(this._conf={}),this._conf.maxListeners=y)},j.prototype.getMaxListeners=function(){return this._maxListeners},j.prototype.event="",j.prototype.once=function(y,w,D){return this._once(y,w,!1,D)},j.prototype.prependOnceListener=function(y,w,D){return this._once(y,w,!0,D)},j.prototype._once=function(y,w,D,x){return this._many(y,1,w,D,x)},j.prototype.many=function(y,w,D,x){return this._many(y,w,D,!1,x)},j.prototype.prependMany=function(y,w,D,x){return this._many(y,w,D,!0,x)},j.prototype._many=function(y,w,D,x,S){var F=this;if(typeof D!="function")throw new Error("many only accepts instances of Function");function B(){return--w===0&&F.off(y,B),D.apply(this,arguments)}return B._origin=D,this._on(y,B,x,S)},j.prototype.emit=function(){if(!this._events&&!this._all)return!1;this._events||b.call(this);var y=arguments[0],w,D=this.wildcard,x,S,F,B,M;if(y==="newListener"&&!this._newListener&&!this._events.newListener)return!1;if(D&&(w=y,y!=="newListener"&&y!=="removeListener"&&typeof y=="object")){if(S=y.length,i){for(F=0;F<S;F++)if(typeof y[F]=="symbol"){M=!0;break}}M||(y=y.join(this.delimiter))}var Q=arguments.length,K;if(this._all&&this._all.length)for(K=this._all.slice(),F=0,S=K.length;F<S;F++)switch(this.event=y,Q){case 1:K[F].call(this,y);break;case 2:K[F].call(this,y,arguments[1]);break;case 3:K[F].call(this,y,arguments[1],arguments[2]);break;default:K[F].apply(this,arguments)}if(D)K=[],N.call(this,K,w,this.listenerTree,0,S);else if(K=this._events[y],typeof K=="function"){switch(this.event=y,Q){case 1:K.call(this);break;case 2:K.call(this,arguments[1]);break;case 3:K.call(this,arguments[1],arguments[2]);break;default:for(x=new Array(Q-1),B=1;B<Q;B++)x[B-1]=arguments[B];K.apply(this,x)}return!0}else K&&(K=K.slice());if(K&&K.length){if(Q>3)for(x=new Array(Q-1),B=1;B<Q;B++)x[B-1]=arguments[B];for(F=0,S=K.length;F<S;F++)switch(this.event=y,Q){case 1:K[F].call(this);break;case 2:K[F].call(this,arguments[1]);break;case 3:K[F].call(this,arguments[1],arguments[2]);break;default:K[F].apply(this,x)}return!0}else if(!this.ignoreErrors&&!this._all&&y==="error")throw arguments[1]instanceof Error?arguments[1]:new Error("Uncaught, unspecified 'error' event.");return!!this._all},j.prototype.emitAsync=function(){if(!this._events&&!this._all)return!1;this._events||b.call(this);var y=arguments[0],w=this.wildcard,D,x,S,F,B,M;if(y==="newListener"&&!this._newListener&&!this._events.newListener)return Promise.resolve([!1]);if(w&&(D=y,y!=="newListener"&&y!=="removeListener"&&typeof y=="object")){if(F=y.length,i){for(B=0;B<F;B++)if(typeof y[B]=="symbol"){x=!0;break}}x||(y=y.join(this.delimiter))}var Q=[],K=arguments.length,re;if(this._all)for(B=0,F=this._all.length;B<F;B++)switch(this.event=y,K){case 1:Q.push(this._all[B].call(this,y));break;case 2:Q.push(this._all[B].call(this,y,arguments[1]));break;case 3:Q.push(this._all[B].call(this,y,arguments[1],arguments[2]));break;default:Q.push(this._all[B].apply(this,arguments))}if(w?(re=[],N.call(this,re,D,this.listenerTree,0)):re=this._events[y],typeof re=="function")switch(this.event=y,K){case 1:Q.push(re.call(this));break;case 2:Q.push(re.call(this,arguments[1]));break;case 3:Q.push(re.call(this,arguments[1],arguments[2]));break;default:for(S=new Array(K-1),M=1;M<K;M++)S[M-1]=arguments[M];Q.push(re.apply(this,S))}else if(re&&re.length){if(re=re.slice(),K>3)for(S=new Array(K-1),M=1;M<K;M++)S[M-1]=arguments[M];for(B=0,F=re.length;B<F;B++)switch(this.event=y,K){case 1:Q.push(re[B].call(this));break;case 2:Q.push(re[B].call(this,arguments[1]));break;case 3:Q.push(re[B].call(this,arguments[1],arguments[2]));break;default:Q.push(re[B].apply(this,S))}}else if(!this.ignoreErrors&&!this._all&&y==="error")return arguments[1]instanceof Error?Promise.reject(arguments[1]):Promise.reject("Uncaught, unspecified 'error' event.");return Promise.all(Q)},j.prototype.on=function(y,w,D){return this._on(y,w,!1,D)},j.prototype.prependListener=function(y,w,D){return this._on(y,w,!0,D)},j.prototype.onAny=function(y){return this._onAny(y,!1)},j.prototype.prependAny=function(y){return this._onAny(y,!0)},j.prototype.addListener=j.prototype.on,j.prototype._onAny=function(y,w){if(typeof y!="function")throw new Error("onAny only accepts instances of Function");return this._all||(this._all=[]),w?this._all.unshift(y):this._all.push(y),this},j.prototype._on=function(y,w,D,x){if(typeof y=="function")return this._onAny(y,w),this;if(typeof w!="function")throw new Error("on only accepts instances of Function");this._events||b.call(this);var S=this,F;return x!==r&&(F=f.call(this,y,w,x),w=F[0],S=F[1]),this._newListener&&this.emit("newListener",y,w),this.wildcard?(ne.call(this,y,w,D),S):(this._events[y]?(typeof this._events[y]=="function"&&(this._events[y]=[this._events[y]]),D?this._events[y].unshift(w):this._events[y].push(w),!this._events[y].warned&&this._maxListeners>0&&this._events[y].length>this._maxListeners&&(this._events[y].warned=!0,E.call(this,this._events[y].length,y))):this._events[y]=w,S)},j.prototype.off=function(y,w){if(typeof w!="function")throw new Error("removeListener only takes instances of Function");var D,x=[];if(this.wildcard){var S=typeof y=="string"?y.split(this.delimiter):y.slice();if(x=N.call(this,null,S,this.listenerTree,0),!x)return this}else{if(!this._events[y])return this;D=this._events[y],x.push({_listeners:D})}for(var F=0;F<x.length;F++){var B=x[F];if(D=B._listeners,a(D)){for(var M=-1,Q=0,K=D.length;Q<K;Q++)if(D[Q]===w||D[Q].listener&&D[Q].listener===w||D[Q]._origin&&D[Q]._origin===w){M=Q;break}if(M<0)continue;return this.wildcard?B._listeners.splice(M,1):this._events[y].splice(M,1),D.length===0&&(this.wildcard?delete B._listeners:delete this._events[y]),this._removeListener&&this.emit("removeListener",y,w),this}else(D===w||D.listener&&D.listener===w||D._origin&&D._origin===w)&&(this.wildcard?delete B._listeners:delete this._events[y],this._removeListener&&this.emit("removeListener",y,w))}return this.listenerTree&&z(this.listenerTree),this},j.prototype.offAny=function(y){var w=0,D=0,x;if(y&&this._all&&this._all.length>0){for(x=this._all,w=0,D=x.length;w<D;w++)if(y===x[w])return x.splice(w,1),this._removeListener&&this.emit("removeListenerAny",y),this}else{if(x=this._all,this._removeListener)for(w=0,D=x.length;w<D;w++)this.emit("removeListenerAny",x[w]);this._all=[]}return this},j.prototype.removeListener=j.prototype.off,j.prototype.removeAllListeners=function(y){if(y===r)return!this._events||b.call(this),this;if(this.wildcard){var w=N.call(this,null,y,this.listenerTree,0),D,x;if(!w)return this;for(x=0;x<w.length;x++)D=w[x],D._listeners=null;this.listenerTree&&z(this.listenerTree)}else this._events&&(this._events[y]=null);return this},j.prototype.listeners=function(y){var w=this._events,D,x,S,F,B;if(y===r){if(this.wildcard)throw Error("event name required for wildcard emitter");if(!w)return[];for(D=p(w),F=D.length,S=[];F-- >0;)x=w[D[F]],typeof x=="function"?S.push(x):S.push.apply(S,x);return S}else{if(this.wildcard){if(B=this.listenerTree,!B)return[];var M=[],Q=typeof y=="string"?y.split(this.delimiter):y.slice();return N.call(this,M,Q,B,0),M}return w?(x=w[y],x?typeof x=="function"?[x]:x:[]):[]}},j.prototype.eventNames=function(y){var w=this._events;return this.wildcard?ue.call(this,this.listenerTree,[],null,y):w?p(w):[]},j.prototype.listenerCount=function(y){return this.listeners(y).length},j.prototype.hasListeners=function(y){if(this.wildcard){var w=[],D=typeof y=="string"?y.split(this.delimiter):y.slice();return N.call(this,w,D,this.listenerTree,0),w.length>0}var x=this._events,S=this._all;return!!(S&&S.length||x&&(y===r?p(x).length:x[y]))},j.prototype.listenersAny=function(){return this._all?this._all:[]},j.prototype.waitFor=function(y,w){var D=this,x=typeof w;return x==="number"?w={timeout:w}:x==="function"&&(w={filter:w}),w=T(w,{timeout:0,filter:r,handleError:!1,Promise,overload:!1},{filter:R,Promise:I}),$(w.Promise,function(S,F,B){function M(){var Q=w.filter;if(!(Q&&!Q.apply(D,arguments)))if(D.off(y,M),w.handleError){var K=arguments[0];K?F(K):S(g.apply(null,arguments).slice(1))}else S(g.apply(null,arguments))}B(function(){D.off(y,M)}),D._on(y,M,!1)},{timeout:w.timeout,overload:w.overload})};function me(y,w,D){D=T(D,{Promise,timeout:0,overload:!1},{Promise:I});var x=D.Promise;return $(x,function(S,F,B){var M;if(typeof y.addEventListener=="function"){M=function(){S(g.apply(null,arguments))},B(function(){y.removeEventListener(w,M)}),y.addEventListener(w,M,{once:!0});return}var Q=function(){K&&y.removeListener("error",K),S(g.apply(null,arguments))},K;w!=="error"&&(K=function(re){y.removeListener(w,Q),F(re)},y.once("error",K)),B(function(){K&&y.removeListener("error",K),y.removeListener(w,Q)}),y.once(w,Q)},{timeout:D.timeout,overload:D.overload})}var H=j.prototype;Object.defineProperties(j,{defaultMaxListeners:{get:function(){return H._maxListeners},set:function(y){if(typeof y!="number"||y<0||Number.isNaN(y))throw TypeError("n must be a non-negative number");H._maxListeners=y},enumerable:!0},once:{value:me,writable:!0,configurable:!0}}),Object.defineProperties(H,{_maxListeners:{value:l,writable:!0,configurable:!0},_observers:{value:null,writable:!0,configurable:!0}}),typeof r=="function"&&r.amd?r(function(){return j}):t.exports=j})()})(un);const cn=un.exports;class ks{constructor(){rt(this,"channels",new Map);rt(this,"globalChannel",new cn)}getChannel(e){const r=this.channels.get(e);if(r)return r;const o=new cn;return this.channels.set(e,o),o}close(e){this.channels.get(e)&&this.channels.set(e,void 0)}}class Ss{constructor(e){rt(this,"instances",new Map);this.pluginManager=e}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(e=>e.manifest.viz)}resolveComponent(e){return this.pluginManager.factory.viz(e)}getOrCreateInstance(e){const r=this.instances.get(e.id);if(r)return r;const o={id:e.id,name:e.viz.type,messageChannels:new ks,instanceData:new xs(e.viz.conf)};return this.instances.set(e.id,o),o}}const Cs={id:"dashboard",version:_s,manifest:{viz:[],color:[]}},rr=new ws,dn=()=>{const t=new Ss(rr);return{pluginManager:rr,vizManager:t}},Es=Re.createContext(dn());rr.install(Cs);const Ts=Ce.observer(function({context:e,dashboard:r,update:o,className:a="dashboard",config:l}){ot.baseURL!==l.apiBaseURL&&(ot.baseURL=l.apiBaseURL);const[s,i]=V.default.useState(!1),[d,v]=V.default.useState(Ge.Edit),[h,p]=V.default.useState(r.panels),b=V.default.useMemo(()=>ln(r,e),[r]);V.default.useEffect(()=>{b.context.replace(e)},[e]);const m=V.default.useMemo(()=>{if(b.filters.changed||b.queries.changed||b.sqlSnippets.changed)return!0;const z=f=>JSON.parse(JSON.stringify(f));return!ye.default.isEqual(z(h),z(r.panels))},[r,h,b.queries.changed,b.filters.changed]),E=async()=>{const z=[...b.queries.current],U=[...b.sqlSnippets.current],f={...r,filters:[...b.filters.current],panels:h,definition:{sqlSnippets:U,queries:z}};await o(f)},g=()=>{b.filters.reset(),p(r.panels),b.sqlSnippets.reset(),b.queries.reset()},C=()=>{const z=Be.randomId(),U={id:z,layout:{x:0,y:1/0,w:3,h:15},title:`Panel - ${z}`,description:"<p><br></p>",queryID:"",viz:{type:"table",conf:{}}};p(f=>[...f,U])},_=z=>{try{const U=h.find(j=>j.id===z);if(!U)throw new Error(`[duplicate panel] Can't find a panel by id[${z}]`);const f={...U,id:Be.randomId(),layout:{...U.layout,x:0,y:1/0}};p(j=>[...j,f])}catch(U){console.error(U)}},T=z=>{const U=h.findIndex(f=>f.id===z);p(f=>(f.splice(U,1),[...f]))},I=d===Ge.Edit,L=d===Ge.Layout,R=d===Ge.Use,Y=V.default.useCallback(()=>{const z=b.queries.current,U=b.sqlSnippets.current;return{filters:b.filters.current,panels:h,definition:{sqlSnippets:U,queries:z}}},[h,b]),{viewPanelInFullScreen:$,exitFullScreen:ee,inFullScreen:N,fullScreenPanel:ne}=Yr(h),ue=ut.useCreation(dn,[]);return n(Bt.ModalsProvider,{children:n(qt,{value:b,children:n(Ct.Provider,{value:{addPanel:C,duplidatePanel:_,removePanelByID:T,viewPanelInFullScreen:$,inFullScreen:N},children:G(Ve.Provider,{value:{layoutFrozen:s,freezeLayout:i,mode:d,inEditMode:I,inLayoutMode:L,inUseMode:R},children:[N&&n(Qr,{panel:ne,exitFullScreen:ee}),G(c.Box,{className:a,sx:{position:"relative",display:N?"none":"block"},children:[n(as,{mode:d,setMode:v,hasChanges:m,saveChanges:E,revertChanges:g,getCurrentSchema:Y}),n(Kr,{}),n(Es.Provider,{value:ue,children:n(Mr,{panels:h,setPanels:p,isDraggable:L,isResizable:L})})]})]})})})})}),As=Lt.WidthProvider(ar.default),zs=Ce.observer(function({panels:e,className:r="layout",rowHeight:o=10}){return n(As,{className:`dashboard-layout ${r}`,rowHeight:o,isDraggable:!1,isResizable:!1,children:e.map(({id:a,...l})=>n("div",{"data-grid":l.layout,children:n(It,{id:a,...l})},a))})});function Os({context:t,dashboard:e,className:r="dashboard",config:o}){ot.baseURL!==o.apiBaseURL&&(ot.baseURL=o.apiBaseURL);const a=V.default.useMemo(()=>ln(e,t),[e]),{viewPanelInFullScreen:l,exitFullScreen:s,inFullScreen:i,fullScreenPanel:d}=Yr(e.panels);return n(Bt.ModalsProvider,{children:n(qt,{value:a,children:n(Ct.Provider,{value:{addPanel:ye.default.noop,duplidatePanel:ye.default.noop,removePanelByID:ye.default.noop,viewPanelInFullScreen:l,inFullScreen:i},children:G(Ve.Provider,{value:{layoutFrozen:!0,freezeLayout:()=>{},mode:Ge.Use,inEditMode:!1,inLayoutMode:!1,inUseMode:!0},children:[i&&n(Qr,{panel:d,exitFullScreen:s}),G(c.Box,{className:r,sx:{display:i?"none":"block"},children:[n(Kr,{}),n(zs,{panels:e.panels})]})]})})})})}var fn=(t=>(t.Select="select",t.MultiSelect="multi-select",t.TextInput="text-input",t.Checkbox="checkbox",t.DateRange="date-range",t))(fn||{});ge.Dashboard=Ts,ge.DashboardFilterType=fn,ge.DashboardLayout=Mr,ge.DashboardMode=Ge,ge.LayoutStateContext=Ve,ge.ModelContextProvider=qt,ge.Panel=It,ge.PanelContext=Ue,ge.ReadOnlyDashboard=Os,ge.useModelContext=Fe,Object.defineProperties(ge,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});