@devtable/dashboard 13.28.0 → 13.28.2

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.
@@ -67,7 +67,7 @@ Check the top-level render call using <`+q+">.")}return A}}function $g(C,A){{if(
67
67
  `));const t=function(y){const _=y.getModel();if(_._isCursorAtCheckPoint){const k=y.getSelections(),S=k.map(function(T){return{lineNumber:T.positionLineNumber,column:T.positionColumn}});_._isCursorAtCheckPoint(S),_._currentCursorPositions=k}},n={},{isInstanceValid:s,isModelValid:i,isRangesValid:a}=Ey.initWith(e),l=function(y){if(s(y)){let _=y.getDomNode();return p._listener=t.bind(f,y),p._editorInstance=y,p._editorInstance._isInDevMode=!1,_.addEventListener("keydown",p._listener,!0),p._onChangeModelDisposable=y.onDidChangeModel(function(){_&&_.removeEventListener("keydown",p._listener,!0);const k=y.getDomNode();k&&k.addEventListener("keydown",p._listener,!0),_=k}),!0}else throw new Error(Cs("ICodeEditor","editorInstance","This type interface can be found in monaco editor documentation"))},c=function(y,_){if(i(y))if(a(_)){const k=Ay(y,_,e);return n[k.uri.toString()]=k,k}else throw new Error(Cs("Array<RangeRestrictionObject>","ranges","Please refer constrained editor documentation for proper structure"));else throw new Error(Cs("ICodeEditor","editorInstance","This type interface can be found in monaco editor documentation"))},u=function(y){if(i(y)){const _=y.uri.toString(),k=n[_];return k?k.disposeRestrictions():(console.warn("Current Model is not a restricted Model"),!1)}else throw new Error(Cs("ICodeEditor","editorInstance","This type interface can be found in monaco editor documentation"))},d=function(){if(p._editorInstance){const _=p._editorInstance.getDomNode();_&&_.removeEventListener("keydown",p._listener),p._onChangeModelDisposable&&p._onChangeModelDisposable.dispose(),delete p._listener,delete p._editorInstance._isInDevMode,delete p._editorInstance._devModeAction,delete p._editorInstance,delete p._onChangeModelDisposable;for(let k in n)delete n[k];return!0}return!1},h=function(){p._editorInstance._isInDevMode?(p._editorInstance._isInDevMode=!1,p._editorInstance._devModeAction.dispose(),delete p._editorInstance._devModeAction):(p._editorInstance._isInDevMode=!0,p._editorInstance._devModeAction=p._editorInstance.addAction({id:"showRange",label:"Show Range in console",contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:function(y){const k=y.getSelections().reduce(function(S,{startLineNumber:T,endLineNumber:I,startColumn:z,endColumn:E}){return S.push("range : "+JSON.stringify([T,z,I,E])),S},[]).join(`
68
68
  `);console.log(`Selected Ranges :
69
69
  `+JSON.stringify(k,null,2))}}))},p={_listener:null,_editorInstance:null,_uriRestrictionMap:n,_injectedResources:e},f=Object.create(p),m={initializeIn:l,addRestrictionsTo:c,removeRestrictionsIn:u,disposeConstrainer:d,toggleDevMode:h};for(let y in m)Object.defineProperty(f,y,{enumerable:!1,writable:!1,configurable:!1,value:m[y]});return Object.freeze(f)}const Kn=g.forwardRef(({value:e,onChange:t,label:n,defaultValue:s,restrictions:i=[]},a)=>{const{t:l}=j.useTranslation(),[c,u]=g.useState(e),d=()=>{t(c)},h=()=>{u(e)},p=()=>{u(s)};g.useEffect(()=>{u(e)},[e]);const f=g.useCallback((_,k)=>{if(i.length===0)return;const S=Py(k),T=_.getModel();if(S.initializeIn(_),S.addRestrictionsTo(T,i),!!T&&!T._hasHighlight){S.toggleDevMode(),T.toggleHighlightOfEditableAreas();const I=T.getCurrentEditableRanges(),z=T.getValueInEditableRanges();console.debug({model:T,currentRanges:I,currentValue:z})}},[i]),m=c!==e,y=typeof c=="string"&&c.length===0;return r.jsxs(o.Stack,{spacing:4,sx:{height:"100%",".editableArea--multi-line":{backgroundColor:"rgba(255,183,78, 0.1)"},".editableArea--single-line":{backgroundColor:"rgba(255,183,78, 0.1)"}},children:[r.jsxs(o.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[r.jsx(o.Group,{position:"left",children:r.jsx(Pp,{})}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:p,size:"xs",variant:"default",leftIcon:r.jsx(M.IconPlayerSkipBack,{size:16}),children:l("common.actions.reset_to_default")}),r.jsx(o.Button,{onClick:h,color:"red",size:"xs",disabled:!m,leftIcon:r.jsx(M.IconRecycle,{size:16}),children:l("common.actions.revert_changes")}),r.jsx(o.Button,{color:"green",size:"xs",onClick:d,disabled:!m,leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),children:l("common.actions.save_changes")})]})]}),r.jsx(o.Text,{size:14,children:n}),r.jsxs(o.Box,{sx:{position:"relative",flexGrow:1},children:[y&&r.jsx(o.Overlay,{center:!0,color:"#fff",opacity:.5,children:r.jsx(o.Button,{color:"blue",radius:"xl",onClick:p,children:l("common.actions.init_with_default")})}),r.jsx(zy,{value:c,onChange:u,onMount:f})]})]})}),Ji=g.forwardRef(({title:e,value:t,onChange:n,label:s,description:i=null,triggerLabel:a="Edit",triggerButtonProps:l={},renderTriggerButton:c,defaultValue:u,zIndex:d=320,restrictions:h},p)=>{const[f,{open:m,close:y}]=Se.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Modal,{opened:f,onClose:y,title:e,withinPortal:!0,zIndex:d,size:"900px",children:[i,r.jsx(o.Box,{h:600,children:r.jsx(Kn,{value:t,onChange:n,defaultValue:u,label:s,restrictions:h})})]}),c==null?void 0:c({onClick:m}),!c&&r.jsx(o.Button,{onClick:m,...l,children:a})]})}),Oy=({onClick:e})=>{const{t}=j.useTranslation();return r.jsx(o.Tooltip,{label:t("rich_text.dynamic_color.label"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"rgb(190, 75, 219)"},onClick:e,children:r.jsx(M.IconMathFunction,{stroke:2,size:16})})})},Ly=({editor:e})=>{const{t}=j.useTranslation(),n=e.getAttributes(hu)[Iy]??"",s=uu(n),i=ky(n);return r.jsxs(r.Fragment,{children:[r.jsx(Ji,{title:t("rich_text.dynamic_color.edit"),label:"",triggerLabel:"",value:s,onChange:a=>{a?e.chain().focus().setDynamicColor(a).run():e.chain().focus().unsetDynamicColor().run()},defaultValue:Sy,renderTriggerButton:Oy,restrictions:i,zIndex:340}),r.jsx(o.Tooltip,{label:t("rich_text.dynamic_color.clear"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"#000"},disabled:!n,onClick:()=>e.chain().focus().unsetDynamicColor().run(),children:r.jsx(M.IconMathFunctionOff,{stroke:1.5,size:16})})})]})},mu=Zt.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize.replace(/['"]+/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}; line-height: 1.2; overflow: auto`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Vy=["8","10","12","14","16","18","20","24","30","36","48","60","72"].map(e=>`${e}px`),By=[{label:"auto",value:""}].concat(Vy.map(e=>({label:e,value:e}))),qy={input:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"}},Ny=({editor:e})=>{const t=e.getAttributes("textStyle").fontSize;return r.jsx(ee.RichTextEditor.ControlsGroup,{children:r.jsx(o.NativeSelect,{size:"xs",icon:r.jsx(M.IconTextSize,{stroke:1.5,size:16}),data:By,styles:qy,value:t||"",onChange:n=>{const s=n.currentTarget.value;s?e.chain().focus().setFontSize(s).run():e.chain().focus().unsetFontSize().run()}})})},Zi="grad_color_",$y=new RegExp(`^(?!${Zi})(.+)$`);function xu(e){return e&&e.replace($y,`${Zi}$1`)}const Fy=e=>{const n="abcdefghijklmnopqrstuvwxyz",i=`1234567890${n}${n.toUpperCase()}`.split(""),a=new Uint8Array(e);crypto.getRandomValues(a);const l=a.reduce((c,u)=>`${c}${i[u&61]}`,"");return`${Zi}${l}`};function Gy(e,t,n){try{if(!Number.isFinite(t)||!Number.isFinite(n))throw new Error(`[getColorMappingFunc] invalid interval with min[${t}] max[${n}]`);if(e.length<2)throw new Error("[getColorMappingFunc] expected at least 2 colors");const s=(n-t)/(e.length-1),i=wc.range(t,n+s,s);return Bm.scaleLinear(i,e)}catch(s){return console.error(s),()=>"inherit"}}function yu(e,t,n,s){const i=Number(e.getAttribute(n)),a=e.getAttribute(s);if(!a)return i;const l=Number(t[a]);return Number.isFinite(l)?l:i}function Wy(e,t){const n={};return e.querySelectorAll("color-mapping").forEach(i=>{const a=i.getAttribute(yt.color),l=yu(i,t,yt.min_val,yt.min_var),c=yu(i,t,yt.max_val,yt.max_var),u=i.getAttribute(yt.variable);if(!a||!Number.isFinite(l)||!Number.isFinite(c)||!u)return;const d=Number(t[u]);if(!Number.isFinite(d))return;const h=a.split(","),p=Gy(h,l,c);n[`#${xu(i.id)}`]={color:p(d)}}),n}function Ry(e){const t=v.get(e,yt.color,[]),n=v.get(e,yt.min_val,""),s=v.get(e,yt.min_var,""),i=v.get(e,yt.max_val,""),a=v.get(e,yt.max_var,""),l=v.get(e,yt.variable,""),c=t.length===0&&[n,s,i,a,l].every(u=>u==="");return{colors:t,min_val:n,min_var:s,max_val:i,max_var:a,variable:l,empty:c}}const qe={color:"data-colors",min_val:"data-min-val",min_var:"data-min-var",max_val:"data-max-val",max_var:"data-max-var",variable:"data-var"},yt=qe,bu="colorMapping",vu=Tr.create({name:bu,addAttributes(){return{id:{default:Fy(6),parseHTML:e=>{const t=e.getAttribute("id");return xu(t)}},[qe.color]:{default:[],parseHTML:e=>{const t=e.getAttribute(qe.color);return t?t.split(","):[]}},[qe.min_val]:{default:0,parseHTML:e=>e.getAttribute(qe.min_val)},[qe.min_var]:{default:"",parseHTML:e=>e.getAttribute(qe.min_var)},[qe.max_val]:{default:100,parseHTML:e=>e.getAttribute(qe.max_val)},[qe.max_var]:{default:"",parseHTML:e=>e.getAttribute(qe.max_var)},[qe.variable]:{default:"",parseHTML:e=>e.getAttribute(qe.variable)}}},parseHTML(){return[{tag:"color-mapping",getAttrs:e=>typeof e=="string"?(console.debug(e),!1):Object.values(yt).map(t=>e.getAttribute(t))}]},renderHTML({HTMLAttributes:e}){return["color-mapping",e,0]},addCommands(){return{setColorMapping:e=>({commands:t})=>{const{colors:n,min_val:s,min_var:i,max_val:a,max_var:l,variable:c}=e;return t.setMark(this.name,{[qe.color]:n,[qe.min_val]:s,[qe.min_var]:i,[qe.max_val]:a,[qe.max_var]:l,[qe.variable]:c})},unsetColorMapping:()=>({commands:e})=>e.unsetMark(this.name)}}}),cn={grid:{axis:"#97999D",scope:"rgba(47,140,192,0.1)",boundary:"#789AB4",reference:"#CFCFD8"},graphics:{compared:{blueDark:"#3E7CAB",blue:"#6398C7",blueLight:"#7CB0DF",blue10:"#6398C71a",redDark:"#AF5F6B",red:"#CD7C88",redLight:"#E794A0",red10:"#CD7C881a"},gradient:{distributed:"linear-gradient(90deg, #1babe6 0%, #2fc8c8 28.63%, #98d44b 48.86%, #ffd057 67.53%, #f5ae53 80.6%, #e76441 91.18%, #b90000 100%)",protrude:"linear-gradient(180deg, #ec73734d 0%, #ec737300 100%)"},level:{lv0:"#6398C7",lv1:"#61B5BF",lv2:"#54D4BB",lv3:"#F5D277",lv4:"#E8BB7F",lv5:"#DB9E84",lv6:"#CB8089"},depth:{dp0:"#FFF7F8",dp1:"#FFE1E1",dp2:"#FDBCBC",dp3:"#F39494",dp4:"#FA4242",dp5:"#E21212"},multiple:{c1:"#66B4DB",c2:"#E46464",c3:"#EEBA00",c4:"#33A678",c5:"#9D88CB",c6:"#939943",c7:"#E49792",c8:"#09A2B8",c9:"#AF5F6B",c10:"#6CA157",c11:"#3E7CAB",c12:"#6398C7",c13:"#E692BA",c14:"#97B566",c15:"#8CACE2",c16:"#CA79AC",c17:"#6DBC80",c18:"#B08F4B",c19:"#39BFA2",c20:"#826BAF"}}};function Qy(){Ye.registerTheme("merico-light",{color:Object.values(cn.graphics.multiple),visualMap:{color:Object.values(cn.graphics.depth).reverse()},axes:[{type:"all",name:"通用坐标轴",axisLineColor:"#97999D",axisTickColor:"#97999D",axisLabelShow:!0,axisLabelColor:"#818388",splitLineShow:!0,splitLineColor:["#E0E6F1"]}]})}function _u(){Qy()}const ju=g.createContext(null),Hi=ju.Provider;function ea(){const e=g.useContext(ju);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const le=()=>ea(),wu=()=>ea(),Cu=g.createContext({searchButtonProps:{}}),ta=Cu.Provider;function Su(){return g.useContext(Cu)}const ku=g.createContext(null),na=ku.Provider;function Tu(){const e=g.useContext(ku);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const re=()=>Tu(),Pe=()=>Tu(),Uy={inEditMode:!1},Ss=g.createContext(Uy),Du=g.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),ra=Du.Provider;function sa(){const e=g.useContext(Du);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const Lt=()=>sa(),Je=()=>sa();function Mu(){try{return sa(),!0}catch{return!1}}const Iu=()=>Mu(),zu=()=>Mu(),Yy={fullScreenPanelID:"",setFullScreenPanelID:v.noop},ia=g.createContext(Yy);function Eu(){const e=g.useContext(ia);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const Ky={en:"en",zh:"zh-cn"};function aa({children:e}){const{i18n:t}=j.useTranslation(),n=g.useMemo(()=>{const s=t.language;return Ky[s]??"en"},[t.language]);return r.jsx(mc.DatesProvider,{settings:{locale:n,firstDayOfWeek:1},children:e})}const Xy=g.forwardRef(({aggValue:e,formattedValue:t,label:n,preview:s,...i},a)=>{const{hovered:l,ref:c}=Se.useHover(),u=s==="aggregated"?e:t,d=s==="aggregated"?t:e;return r.jsx(o.Box,{ref:c,...i,children:r.jsxs(o.Group,{noWrap:!0,position:"apart",ref:a,children:[r.jsx(o.Text,{size:"sm",sx:{flexGrow:1},children:n}),r.jsx(o.Text,{size:"xs",opacity:l?1:.65,sx:{flexShrink:0},children:l?d:u})]})})}),oa=D.observer(g.forwardRef((e,t)=>{const{label:n,value:s,onChange:i,description:a,required:l,clearable:c=!0,sx:u,preview:d="formatted",zIndex:h=340}=e;j.useTranslation();const{panel:p}=Je(),f=g.useMemo(()=>p.variableOptions(s,c),[s,c]);return f.length===0?r.jsx(o.TextInput,{ref:t,label:n,placeholder:s,readOnly:!0,disabled:!0}):r.jsx(o.Select,{ref:t,label:n,description:a,itemComponent:m=>r.jsx(Xy,{preview:d,...m}),data:f,value:s,onChange:i,required:l,sx:u,maxDropdownHeight:500,withinPortal:!0,zIndex:h})}));var Jy=Symbol.for("preact-signals");function ks(){if(jn>1)jn--;else{for(var e,t=!1;Mr!==void 0;){var n=Mr;for(Mr=void 0,la++;n!==void 0;){var s=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Pu(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=s}}if(la=0,jn--,t)throw e}}function un(e){if(jn>0)return e();jn++;try{return e()}finally{ks()}}var ge=void 0;function Xn(e){var t=ge;ge=void 0;try{return e()}finally{ge=t}}var Mr=void 0,jn=0,la=0,Ts=0;function Au(e){if(ge!==void 0){var t=e.n;if(t===void 0||t.t!==ge)return t={i:0,S:e,p:ge.s,n:void 0,t:ge,e:void 0,x:void 0,r:t},ge.s!==void 0&&(ge.s.n=t),ge.s=t,e.n=t,32&ge.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ge.s,t.n=void 0,ge.s.n=t,ge.s=t),t}}function Ze(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}Ze.prototype.brand=Jy,Ze.prototype.h=function(){return!0},Ze.prototype.S=function(e){this.t!==e&&e.e===void 0&&(e.x=this.t,this.t!==void 0&&(this.t.e=e),this.t=e)},Ze.prototype.U=function(e){if(this.t!==void 0){var t=e.e,n=e.x;t!==void 0&&(t.x=n,e.e=void 0),n!==void 0&&(n.e=t,e.x=void 0),e===this.t&&(this.t=n)}},Ze.prototype.subscribe=function(e){var t=this;return at(function(){var n=t.value,s=ge;ge=void 0;try{e(n)}finally{ge=s}})},Ze.prototype.valueOf=function(){return this.value},Ze.prototype.toString=function(){return this.value+""},Ze.prototype.toJSON=function(){return this.value},Ze.prototype.peek=function(){var e=ge;ge=void 0;try{return this.value}finally{ge=e}},Object.defineProperty(Ze.prototype,"value",{get:function(){var e=Au(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(la>100)throw new Error("Cycle detected");this.v=e,this.i++,Ts++,jn++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ks()}}}});function Ds(e){return new Ze(e)}function Pu(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Ou(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Lu(e){for(var t=e.s,n=void 0;t!==void 0;){var s=t.p;t.i===-1?(t.S.U(t),s!==void 0&&(s.n=t.n),t.n!==void 0&&(t.n.p=s)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=s}e.s=n}function Jn(e){Ze.call(this,void 0),this.x=e,this.s=void 0,this.g=Ts-1,this.f=4}(Jn.prototype=new Ze).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Ts))return!0;if(this.g=Ts,this.f|=1,this.i>0&&!Pu(this))return this.f&=-2,!0;var e=ge;try{Ou(this),ge=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return ge=e,Lu(this),this.f&=-2,!0},Jn.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Ze.prototype.S.call(this,e)},Jn.prototype.U=function(e){if(this.t!==void 0&&(Ze.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},Jn.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(Jn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Au(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Vu(e){return new Jn(e)}function Bu(e){var t=e.u;if(e.u=void 0,typeof t=="function"){jn++;var n=ge;ge=void 0;try{t()}catch(s){throw e.f&=-2,e.f|=8,ca(e),s}finally{ge=n,ks()}}}function ca(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Bu(e)}function Zy(e){if(ge!==this)throw new Error("Out-of-order effect");Lu(this),ge=e,this.f&=-2,8&this.f&&ca(this),ks()}function Ir(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}Ir.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}},Ir.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Bu(this),Ou(this),jn++;var e=ge;return ge=this,Zy.bind(this,e)},Ir.prototype.N=function(){2&this.f||(this.f|=2,this.o=Mr,Mr=this)},Ir.prototype.d=function(){this.f|=8,1&this.f||ca(this)};function at(e){var t=new Ir(e);try{t.c()}catch(n){throw t.d(),n}return t.d.bind(t)}function Ms(e,t){if(t){let n;return Vu(()=>{const s=e();return s&&n&&t(n,s)?n:(n=s,s)})}return Vu(e)}function ua(e,t){if(e===t)return!0;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((s,i)=>!ua(s,t[i]));try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function ke({get:e},t){return{init(n){return Ds(n)},get(){return e.call(this).value},set(n){const s=e.call(this);s.peek()!==n&&(s.value=n)}}}function Is(e,t){const n=new WeakMap;return function(){let s=n.get(this);return s||(s=Ms(e.bind(this)),n.set(this,s)),s.value}}function Hy(...e){const t=e.map(at);return()=>t.forEach(n=>n())}var eb=Object.create,da=Object.defineProperty,tb=Object.getOwnPropertyDescriptor,qu=Object.getOwnPropertySymbols,nb=Object.prototype.hasOwnProperty,rb=Object.prototype.propertyIsEnumerable,Nu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Zn=e=>{throw TypeError(e)},$u=Math.pow,pa=(e,t,n)=>t in e?da(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sb=(e,t)=>{for(var n in t||(t={}))nb.call(t,n)&&pa(e,n,t[n]);if(qu)for(var n of qu(t))rb.call(t,n)&&pa(e,n,t[n]);return e},Fu=(e,t)=>da(e,"name",{value:t,configurable:!0}),ib=e=>{var t;return[,,,eb((t=e==null?void 0:e[Nu("metadata")])!=null?t:null)]},Gu=["class","method","getter","setter","accessor","field","value","get","set"],zr=e=>e!==void 0&&typeof e!="function"?Zn("Function expected"):e,ab=(e,t,n,s,i)=>({kind:Gu[e],name:t,metadata:s,addInitializer:a=>n._?Zn("Already initialized"):i.push(zr(a||null))}),Wu=(e,t)=>pa(t,Nu("metadata"),e[3]),qn=(e,t,n,s)=>{for(var i=0,a=e[t>>1],l=a&&a.length;i<l;i++)t&1?a[i].call(n):s=a[i].call(n,s);return s},Er=(e,t,n,s,i,a)=>{var l,c,u,d,h,p=t&7,f=!!(t&8),m=!!(t&16),y=p>3?e.length+1:p?f?1:2:0,_=Gu[p+5],k=p>3&&(e[y-1]=[]),S=e[y]||(e[y]=[]),T=p&&(!m&&!f&&(i=i.prototype),p<5&&(p>3||!m)&&tb(p<4?i:{get[n](){return Ru(this,a)},set[n](z){return Qu(this,a,z)}},n));p?m&&p<4&&Fu(a,(p>2?"set ":p>1?"get ":"")+n):Fu(i,n);for(var I=s.length-1;I>=0;I--)d=ab(p,n,u={},e[3],S),p&&(d.static=f,d.private=m,h=d.access={has:m?z=>ob(i,z):z=>n in z},p^3&&(h.get=m?z=>(p^1?Ru:lb)(z,i,p^4?a:T.get):z=>z[n]),p>2&&(h.set=m?(z,E)=>Qu(z,i,E,p^4?a:T.set):(z,E)=>z[n]=E)),c=(0,s[I])(p?p<4?m?a:T[_]:p>4?void 0:{get:T.get,set:T.set}:i,d),u._=1,p^4||c===void 0?zr(c)&&(p>4?k.unshift(c):p?m?a=c:T[_]=c:i=c):typeof c!="object"||c===null?Zn("Object expected"):(zr(l=c.get)&&(T.get=l),zr(l=c.set)&&(T.set=l),zr(l=c.init)&&k.unshift(l));return p||Wu(e,i),T&&da(i,n,T),m?p^4?a:T:i},ha=(e,t,n)=>t.has(e)||Zn("Cannot "+n),ob=(e,t)=>Object(t)!==t?Zn('Cannot use the "in" operator on this value'):e.has(t),Ru=(e,t,n)=>(ha(e,t,"read from private field"),n?n.call(e):t.get(e)),fa=(e,t,n)=>t.has(e)?Zn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Qu=(e,t,n,s)=>(ha(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),lb=(e,t,n)=>(ha(e,t,"access private method"),n),dn=class Hl{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Hl(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Hl(t,n)}},cb=class Si{constructor(t,n,s,i){this.left=t,this.top=n,this.width=s,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:s,left:i,width:a,height:l,scale:c}=this,u=new Si(i+t,s+n,a,l);return u.scale=sb({},c),u}get boundingRectangle(){const{width:t,height:n,left:s,top:i,right:a,bottom:l}=this;return{width:t,height:n,left:s,top:i,right:a,bottom:l}}get center(){const{left:t,top:n,right:s,bottom:i}=this;return new dn((t+s)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof Si))return!1;const{left:n,top:s,width:i,height:a}=this;return n===t.left&&s===t.top&&i===t.width&&a===t.height}containsPoint(t){const{top:n,left:s,bottom:i,right:a}=this;return n<=t.y&&t.y<=i&&s<=t.x&&t.x<=a}intersectionArea(t){return t instanceof Si?ub(this,t):0}intersectionRatio(t){const{area:n}=this,s=this.intersectionArea(t);return s/(t.area+n-s)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}};function ub(e,t){const n=Math.max(t.top,e.top),s=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),l=i-s,c=a-n;return s<i&&n<a?l*c:0}var Uu=10,Yu,Ku,Xu,Ju,Zu,ot,ga,ma,xa;Zu=[ke],Ju=[ke],Xu=[ke],Ku=[Is],Yu=[Is];var Hn=class{constructor(e){qn(ot,5,this),fa(this,ga,qn(ot,8,this)),qn(ot,11,this),fa(this,ma,qn(ot,12,this)),qn(ot,15,this),fa(this,xa,qn(ot,16,this)),qn(ot,19,this);const t=dn.from(e);this.initial=t,this.current=t,this.previous=t}get delta(){return dn.delta(this.current,this.initial)}get direction(){const e={x:this.current.x-this.previous.x,y:this.current.y-this.previous.y};return!e.x&&!e.y?null:Math.abs(e.x)>Math.abs(e.y)?e.x>0?"right":"left":e.y>0?"down":"up"}reset(e){const t=dn.from(e);un(()=>{this.current=t,this.previous=t,this.initial=t})}update(e){const{current:t}=this,n=dn.from(e);if(dn.equals(t,n))return;const s={x:n.x-t.x,y:n.y-t.y};(Math.abs(s.x)<Uu||Math.abs(s.y)<Uu)&&(this.previous=t),this.current=n}};ot=ib(null),ga=new WeakMap,ma=new WeakMap,xa=new WeakMap,Er(ot,4,"initial",Zu,Hn,ga),Er(ot,4,"previous",Ju,Hn,ma),Er(ot,4,"current",Xu,Hn,xa),Er(ot,2,"delta",Ku,Hn),Er(ot,2,"direction",Yu,Hn),Wu(ot,Hn);function ya({x:e,y:t},n){const s=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt($u(s,2)+$u(i,2))>n:"x"in n&&"y"in n?s>n.x&&i>n.y:"x"in n?s>n.x:"y"in n?i>n.y:!1}var Hu=(e=>(e.Horizontal="x",e.Vertical="y",e))(Hu||{}),ed=Object.values(Hu),db=Object.create,ba=Object.defineProperty,pb=Object.getOwnPropertyDescriptor,td=Object.getOwnPropertySymbols,hb=Object.prototype.hasOwnProperty,fb=Object.prototype.propertyIsEnumerable,nd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),er=e=>{throw TypeError(e)},gb=(e,t,n)=>t in e?ba(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rd=(e,t)=>ba(e,"name",{value:t,configurable:!0}),sd=(e,t)=>{var n={};for(var s in e)hb.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&td)for(var s of td(e))t.indexOf(s)<0&&fb.call(e,s)&&(n[s]=e[s]);return n},zs=e=>{var t;return[,,,db((t=e==null?void 0:e[nd("metadata")])!=null?t:null)]},id=["class","method","getter","setter","accessor","field","value","get","set"],Ar=e=>e!==void 0&&typeof e!="function"?er("Function expected"):e,mb=(e,t,n,s,i)=>({kind:id[e],name:t,metadata:s,addInitializer:a=>n._?er("Already initialized"):i.push(Ar(a||null))}),Pr=(e,t)=>gb(t,nd("metadata"),e[3]),we=(e,t,n,s)=>{for(var i=0,a=e[t>>1],l=a&&a.length;i<l;i++)t&1?a[i].call(n):s=a[i].call(n,s);return s},lt=(e,t,n,s,i,a)=>{var l,c,u,d,h,p=t&7,f=!!(t&8),m=!!(t&16),y=p>3?e.length+1:p?f?1:2:0,_=id[p+5],k=p>3&&(e[y-1]=[]),S=e[y]||(e[y]=[]),T=p&&(!m&&!f&&(i=i.prototype),p<5&&(p>3||!m)&&pb(p<4?i:{get[n](){return Es(this,a)},set[n](z){return _a(this,a,z)}},n));p?m&&p<4&&rd(a,(p>2?"set ":p>1?"get ":"")+n):rd(i,n);for(var I=s.length-1;I>=0;I--)d=mb(p,n,u={},e[3],S),p&&(d.static=f,d.private=m,h=d.access={has:m?z=>xb(i,z):z=>n in z},p^3&&(h.get=m?z=>(p^1?Es:yb)(z,i,p^4?a:T.get):z=>z[n]),p>2&&(h.set=m?(z,E)=>_a(z,i,E,p^4?a:T.set):(z,E)=>z[n]=E)),c=(0,s[I])(p?p<4?m?a:T[_]:p>4?void 0:{get:T.get,set:T.set}:i,d),u._=1,p^4||c===void 0?Ar(c)&&(p>4?k.unshift(c):p?m?a=c:T[_]=c:i=c):typeof c!="object"||c===null?er("Object expected"):(Ar(l=c.get)&&(T.get=l),Ar(l=c.set)&&(T.set=l),Ar(l=c.init)&&k.unshift(l));return p||Pr(e,i),T&&ba(i,n,T),m?p^4?a:T:i},va=(e,t,n)=>t.has(e)||er("Cannot "+n),xb=(e,t)=>Object(t)!==t?er('Cannot use the "in" operator on this value'):e.has(t),Es=(e,t,n)=>(va(e,t,"read from private field"),n?n.call(e):t.get(e)),bt=(e,t,n)=>t.has(e)?er("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),_a=(e,t,n,s)=>(va(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),yb=(e,t,n)=>(va(e,t,"access private method"),n);function ad(e,t){return{plugin:e,options:t}}function bb(e){return t=>ad(e,t)}function od(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var ld,Or,ja;ld=[ke];var St=class{constructor(e,t){this.manager=e,this.options=t,bt(this,ja,we(Or,8,this,!1)),we(Or,11,this)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return Xn(()=>this.disabled)}configure(e){this.options=e}destroy(){}static configure(e){return ad(this,e)}};Or=zs(null),ja=new WeakMap,lt(Or,4,"disabled",ld,St,ja),Pr(Or,St);var vb=class extends St{},Lr=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(Lr||{}),cd,ud,dd,pd,ct,wa,Ca,Sa,ka;pd=[ke],dd=[ke],ud=[ke],cd=[ke];var Nn=class{constructor(e,t){bt(this,wa,we(ct,8,this)),we(ct,11,this),bt(this,Ca,we(ct,12,this)),we(ct,15,this),bt(this,Sa,we(ct,16,this)),we(ct,19,this),bt(this,ka,we(ct,20,this)),we(ct,23,this);const{effects:n,id:s,data:i={},disabled:a=!1}=e;let l=s;this.manager=t,this.id=s,this.data=i,this.disabled=a,this.effects=()=>{var c;return[()=>{const{id:u,manager:d}=this;if(s!==l)return d==null||d.registry.register(this),()=>d==null?void 0:d.registry.unregister(this)},...(c=n==null?void 0:n())!=null?c:[]]},this.destroy=this.destroy.bind(this),t&&queueMicrotask(()=>{var c;(c=this.manager)==null||c.registry.register(this)})}register(){var e;return(e=this.manager)==null?void 0:e.registry.register(this)}unregister(){var e;(e=this.manager)==null||e.registry.unregister(this)}destroy(){var e;(e=this.manager)==null||e.registry.unregister(this)}};ct=zs(null),wa=new WeakMap,Ca=new WeakMap,Sa=new WeakMap,ka=new WeakMap,lt(ct,4,"manager",pd,Nn,wa),lt(ct,4,"id",dd,Nn,Ca),lt(ct,4,"data",ud,Nn,Sa),lt(ct,4,"disabled",cd,Nn,ka),Pr(ct,Nn);var hd,fd,gd,Ta,Vr,Ht,Da,Ma,Br=class extends(Ta=Nn,gd=[ke],fd=[ke],hd=[Is],Ta){constructor(t,n){var s=t,{modifiers:i,type:a,sensors:l}=s,c=sd(s,["modifiers","type","sensors"]);super(c,n),we(Ht,5,this),bt(this,Vr),bt(this,Da,we(Ht,8,this)),we(Ht,11,this),bt(this,Ma,we(Ht,12,this,"idle")),we(Ht,15,this),this.type=a,this.sensors=l,this.modifiers=i}set modifiers(t){var n;const{manager:s}=this;(n=Es(this,Vr))==null||n.forEach(i=>i.destroy()),s&&_a(this,Vr,t==null?void 0:t.map(i=>{const{plugin:a,options:l}=od(i);return new a(s,l)}))}get modifiers(){return Es(this,Vr)}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}destroy(){var t;super.destroy(),(t=this.modifiers)==null||t.forEach(n=>n.destroy())}};Ht=zs(Ta),Vr=new WeakMap,Da=new WeakMap,Ma=new WeakMap,lt(Ht,4,"type",gd,Br,Da),lt(Ht,4,"status",fd,Br,Ma),lt(Ht,2,"isDragSource",hd,Br),Pr(Ht,Br);var md,xd,yd,bd,vd,_d,Ia,Ne,za,Ea,Aa,Pa,Oa,wn=class extends(Ia=Nn,_d=[ke],vd=[ke],bd=[ke],yd=[ke],xd=[ke],md=[Is],Ia){constructor(t,n){var s=t,{accept:i,collisionDetector:a,collisionPriority:l=2,type:c}=s,u=sd(s,["accept","collisionDetector","collisionPriority","type"]);super(u,n),we(Ne,5,this),bt(this,za,we(Ne,8,this)),we(Ne,11,this),bt(this,Ea,we(Ne,12,this)),we(Ne,15,this),bt(this,Aa,we(Ne,16,this)),we(Ne,19,this),bt(this,Pa,we(Ne,20,this)),we(Ne,23,this),bt(this,Oa,we(Ne,24,this)),we(Ne,27,this),this.accept=i,this.collisionDetector=a,this.collisionPriority=l,this.type=c}accepts(t){const{accept:n}=this;return n?t.type?Array.isArray(n)?n.includes(t.type):typeof n=="function"?n(t):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}refreshShape(){}};Ne=zs(Ia),za=new WeakMap,Ea=new WeakMap,Aa=new WeakMap,Pa=new WeakMap,Oa=new WeakMap,lt(Ne,4,"accept",_d,wn,za),lt(Ne,4,"type",vd,wn,Ea),lt(Ne,4,"collisionDetector",bd,wn,Aa),lt(Ne,4,"collisionPriority",yd,wn,Pa),lt(Ne,4,"shape",xd,wn,Oa),lt(Ne,2,"isDropTarget",md,wn),Pr(Ne,wn);var As=class extends St{constructor(e,t){super(e,t),this.manager=e,this.options=t}},_b=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:s}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=dn.distance(t.shape.center,n);return{id:s,value:1/i,priority:Lr.High}}return null},jb=({dragOperation:e,droppable:t})=>{if(!t.shape)return null;const{shape:n}=e;if(n==null?void 0:n.current.intersectionArea(t.shape)){const{position:i}=e,l=1/dn.distance(t.shape.center,i.current);return{id:t.id,value:l,priority:Lr.Normal}}return null},jd=e=>{var t;return(t=_b(e))!=null?t:jb(e)},wb=e=>{var t;const{dragOperation:n,droppable:s}=e,{shape:i,position:a}=n;if(!s.shape)return null;const c=1/dn.distance(s.shape.center,(t=i==null?void 0:i.current.center)!=null?t:a.current);return{id:s.id,value:c,priority:Lr.Low}};function wd(e){const{width:t,height:n,top:s,left:i,bottom:a,right:l}=e.getBoundingClientRect();return{width:t,height:n,top:s,left:i,bottom:a,right:l}}var Cb=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function La(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Cd(e){return"nodeType"in e}function tr(e){var t,n;return e?La(e)?e:Cd(e)&&(n=(t=e.ownerDocument)==null?void 0:t.defaultView)!=null?n:window:window}function Sd(e){const{Document:t}=tr(e);return e instanceof t}function kd(e){return La(e)?!1:e instanceof tr(e).HTMLElement}function qr(e){return e?La(e)?e.document:Cd(e)?Sd(e)?e:kd(e)?e.ownerDocument:document:document:document}function Sb(e){const{documentElement:t}=qr(e),n=t.clientWidth,s=t.clientHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}function kb(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),s=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((a,l)=>{const c=s[l];if(Td(a)&&Td(c)&&(a.type!=="file"&&(a.value=c.value),a.type==="radio"&&a.name&&(a.name=`Cloned__${a.name}`)),a instanceof HTMLCanvasElement&&c instanceof HTMLCanvasElement&&c.width>0&&c.height>0){const u=a.getContext("2d");u==null||u.drawImage(c,0,0)}}),n}function Td(e){return"value"in e}function nr(e){return"style"in e&&e.style instanceof tr(e).CSSStyleDeclaration}function Tb(e,t=!1,n){const s=kb(e);if(nr(s)&&(t||s.style.setProperty("opacity","0")),s.setAttribute("inert","true"),s.setAttribute("tab-index","-1"),s.setAttribute("aria-hidden","true"),n)for(const[i,a]of Object.entries(n))s.setAttribute(i,a);return s}var Dd=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:s,options:i}]=e;t.removeEventListener(n,s,i)}this.entries.clear()}}bind(e,t){const n=Array.isArray(t)?t:[t],s=[];for(const i of n){const{type:a,listener:l,options:c}=i,u=[e,i];e.addEventListener(a,l,c),this.entries.add(u),s.push(u)}return function(){for(const[a,{type:l,listener:c,options:u}]of s)a.removeEventListener(l,c,u)}}};function Va(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function Ba(e){Va(e)&&e.isConnected&&e.hasAttribute("popover")&&e.showPopover()}function Md(e){return!Cb||!e?!1:e===qr(e).scrollingElement}function Id(e){const t=Md(e)?Sb(e):wd(e),n=Md(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-n.width,y:e.scrollHeight-n.height}},i=s.current.y<=0,a=s.current.x<=0,l=s.current.y>=s.max.y,c=s.current.x>=s.max.x;return{rect:t,position:s,isTop:i,isLeft:a,isBottom:l,isRight:c}}function Db(e,t){const{isTop:n,isBottom:s,isLeft:i,isRight:a,position:l}=Id(e),{x:c,y:u}=t??{x:0,y:0},d=!n&&l.current.y+u>0,h=!s&&l.current.y+u<l.max.y,p=!i&&l.current.x+c>0,f=!a&&l.current.x+c<l.max.x;return{top:d,bottom:h,left:p,right:f,x:p||f,y:d||h}}function Mb(e){return e instanceof tr(e).SVGElement}function Cn(e){return tr(e).getComputedStyle(e)}function Ib(e,t=Cn(e)){return t.position==="fixed"||t.position==="sticky"}function zb(e,t=Cn(e)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].find(i=>{const a=t[i];return typeof a=="string"?n.test(a):!1})!=null}var Eb={excludeElement:!0};function Ps(e,t=Eb){const{limit:n,excludeElement:s}=t,i=new Set;function a(l){if(n!=null&&i.size>=n||!l)return i;if(Sd(l)&&l.scrollingElement!=null&&!i.has(l.scrollingElement))return i.add(l.scrollingElement),i;if(!kd(l))return Mb(l)?a(l.parentElement):i;if(i.has(l))return i;const c=Cn(l);if(s&&l===e||zb(l,c)&&i.add(l),Ib(l,c)){const{scrollingElement:u}=l.ownerDocument;return u&&i.add(u),i}return a(l.parentNode)}return e?a(e):i}function Ab(e){const[t]=Ps(e,{limit:1});return t??null}var kt=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(kt||{}),Pb={x:.2,y:.2},Ob={x:10,y:10};function Lb(e,t,n,s=25,i=Pb,a=Ob){const{rect:l,isTop:c,isBottom:u,isLeft:d,isRight:h}=Id(e),p={x:0,y:0},f={x:0,y:0},m={height:l.height*i.y,width:l.width*i.x};return!c&&t.y<=l.top+m.height&&(n==null?void 0:n.y)!==1&&t.x>=l.left-a.x&&t.x<=l.right+a.x?(p.y=-1,f.y=s*Math.abs((l.top+m.height-t.y)/m.height)):!u&&t.y>=l.bottom-m.height&&(n==null?void 0:n.y)!==-1&&t.x>=l.left-a.x&&t.x<=l.right+a.x&&(p.y=1,f.y=s*Math.abs((l.bottom-m.height-t.y)/m.height)),!h&&t.x>=l.right-m.width&&(n==null?void 0:n.x)!==-1&&t.y>=l.top-a.y&&t.y<=l.bottom+a.y?(p.x=1,f.x=s*Math.abs((l.right-m.width-t.x)/m.width)):!d&&t.x<=l.left+m.width&&(n==null?void 0:n.x)!==1&&t.y>=l.top-a.y&&t.y<=l.bottom+a.y&&(p.x=-1,f.x=s*Math.abs((l.left+m.width-t.x)/m.width)),{direction:p,speed:f}}function Vb(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function zd(e,t=!1){if(Vb(e)){e.scrollIntoViewIfNeeded(t);return}if(!(e instanceof HTMLElement))return e.scrollIntoView();var[n]=Ps(e,{limit:1});if(!(n instanceof HTMLElement))return;const s=Cn(n),i=parseInt(s.getPropertyValue("border-top-width")),a=parseInt(s.getPropertyValue("border-left-width")),l=e.offsetTop-n.offsetTop<n.scrollTop,c=e.offsetTop-n.offsetTop+e.clientHeight-i>n.scrollTop+n.clientHeight,u=e.offsetLeft-n.offsetLeft<n.scrollLeft,d=e.offsetLeft-n.offsetLeft+e.clientWidth-a>n.scrollLeft+n.clientWidth,h=l&&!c;(l||c)&&t&&(n.scrollTop=e.offsetTop-n.offsetTop-n.clientHeight/2-i+e.clientHeight/2),(u||d)&&t&&(n.scrollLeft=e.offsetLeft-n.offsetLeft-n.clientWidth/2-a+e.clientWidth/2),(l||c||u||d)&&!t&&e.scrollIntoView(h)}var Bb=class{constructor(){this.tasks=new Set,this.flush=()=>{const e=this.tasks;this.animationFrame=void 0,this.tasks=new Set;for(const t of e)t()}}schedule(e){this.tasks.add(e),this.animationFrame||(this.animationFrame=requestAnimationFrame(this.flush))}},rr=new Bb;function qb(e,t,n){const{scaleX:s,scaleY:i,x:a,y:l}=t,c=e.left-a-(1-s)*parseFloat(n),u=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=s?e.width/s:e.width,h=i?e.height/i:e.height;return{width:d,height:h,top:u,right:c+d,bottom:u+h,left:c}}var Ed=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(nr(n))for(const[s,i]of Object.entries(e)){const a=`${t}${s}`;this.initial.has(a)||this.initial.set(a,n.style.getPropertyValue(a)),n.style.setProperty(a,typeof i=="string"?i:`${i}px`)}}remove(e,t=""){const{element:n}=this;if(nr(n))for(const s of e){const i=`${t}${s}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(nr(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function Ad({element:e,keyframes:t,options:n,onReady:s,onFinish:i}){const a=new Ed(e),{transitionProperty:l}=Cn(e),c=l.split(", ");a.set({"transition-property":c.length?c.filter(u=>!u.includes("transform")&&!u.includes("translate")).join(", "):"none"}),s==null||s(),e.animate(t,n).finished.then(()=>{i==null||i(),a.reset()})}function Pd(e){const t=e.getAnimations();if(t.length>0){const[n]=t,{effect:s}=n,i=s instanceof KeyframeEffect?s.getKeyframes():[];if(i.length>0)return i==null?void 0:i[i.length-1]}return null}function Os(e){if(e==="none")return null;const[t,n,s="0"]=e.split(" "),i={x:parseFloat(t),y:parseFloat(n),z:parseInt(s,10)};return isNaN(i.x)&&isNaN(i.y)?null:{x:isNaN(i.x)?0:i.x,y:isNaN(i.y)?0:i.y,z:isNaN(i.z)?0:i.z}}function Nb(e){const t=Pd(e);if(t){const{translate:s=""}=t;if(typeof s=="string"){const i=Os(s);if(i)return i}}const{translate:n}=Cn(e);if(n){const s=Os(n);if(s)return s}return{x:0,y:0,z:0}}function $b(e){if(e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),s=parseFloat(t[1]);return isNaN(n)&&isNaN(s)?null:{x:isNaN(n)?s:n,y:isNaN(s)?n:s}}function Od(e){var t,n,s,i,a,l,c,u,d;const{scale:h,transform:p,translate:f}=e,m=$b(h),y=Os(f),_=Fb(p);if(!_&&!m&&!y)return null;const k={x:(t=m==null?void 0:m.x)!=null?t:1,y:(n=m==null?void 0:m.y)!=null?n:1},S={x:(s=y==null?void 0:y.x)!=null?s:0,y:(i=y==null?void 0:y.y)!=null?i:0},T={x:(a=_==null?void 0:_.x)!=null?a:0,y:(l=_==null?void 0:_.y)!=null?l:0,scaleX:(c=_==null?void 0:_.scaleX)!=null?c:1,scaleY:(u=_==null?void 0:_.scaleY)!=null?u:1};return{x:S.x+T.x,y:S.y+T.y,z:(d=y==null?void 0:y.z)!=null?d:0,scaleX:k.x*T.scaleX,scaleY:k.y*T.scaleY}}function Fb(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var en=class extends cb{constructor(e,t=!1){var n,s;let{top:i,left:a,right:l,bottom:c,width:u,height:d}=wd(e);const h=Cn(e),p=Od(h),f={x:(n=p==null?void 0:p.scaleX)!=null?n:1,y:(s=p==null?void 0:p.scaleY)!=null?s:1},m=Gb(e);if(p&&(t||m)){const y=qb({top:i,left:a,right:l,bottom:c,width:u,height:d},p,h.transformOrigin);i=y.top,a=y.left,u=y.width,d=y.height}m&&!t&&(i=i+m.y,a=a+m.x,u=u*m.scaleX,d=d*m.scaleY,f.x=m.scaleX,f.y=m.scaleY),super(a,i,u,d),this.scale=f}};function Gb(e){const t=Pd(e);if(t){const{transform:n="",translate:s="",scale:i=""}=t;if(n||s||i)return Od({transform:typeof n=="string"?n:"",translate:typeof s=="string"?s:"",scale:typeof i=="string"?i:""})}return null}function Ls(e){return e instanceof KeyboardEvent}var Wb=Object.create,Ld=Object.defineProperty,Rb=Object.defineProperties,Qb=Object.getOwnPropertyDescriptor,Ub=Object.getOwnPropertyDescriptors,Vs=Object.getOwnPropertySymbols,Vd=Object.prototype.hasOwnProperty,Bd=Object.prototype.propertyIsEnumerable,qd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Nr=e=>{throw TypeError(e)},qa=(e,t,n)=>t in e?Ld(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Nd=(e,t)=>{for(var n in t||(t={}))Vd.call(t,n)&&qa(e,n,t[n]);if(Vs)for(var n of Vs(t))Bd.call(t,n)&&qa(e,n,t[n]);return e},Yb=(e,t)=>Rb(e,Ub(t)),$d=(e,t)=>{var n={};for(var s in e)Vd.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Vs)for(var s of Vs(e))t.indexOf(s)<0&&Bd.call(e,s)&&(n[s]=e[s]);return n},Bs=e=>{var t;return[,,,Wb((t=e==null?void 0:e[qd("metadata")])!=null?t:null)]},Fd=["class","method","getter","setter","accessor","field","value","get","set"],$r=e=>e!==void 0&&typeof e!="function"?Nr("Function expected"):e,Kb=(e,t,n,s,i)=>({kind:Fd[e],name:t,metadata:s,addInitializer:a=>n._?Nr("Already initialized"):i.push($r(a||null))}),qs=(e,t)=>qa(t,qd("metadata"),e[3]),He=(e,t,n,s)=>{for(var i=0,a=e[t>>1],l=a&&a.length;i<l;i++)t&1?a[i].call(n):s=a[i].call(n,s);return s},Sn=(e,t,n,s,i,a)=>{for(var l,c,u,d,h,p=t&7,f=!!(t&8),m=!!(t&16),y=e.length+1,_=Fd[p+5],k=e[y-1]=[],S=e[y]||(e[y]=[]),T=(i=i.prototype,Qb({get[n](){return tn(this,a)},set[n](z){return sr(this,a,z)}},n)),I=s.length-1;I>=0;I--)d=Kb(p,n,u={},e[3],S),d.static=f,d.private=m,h=d.access={has:z=>n in z},h.get=z=>z[n],h.set=(z,E)=>z[n]=E,c=(0,s[I])({get:T.get,set:T.set},d),u._=1,c===void 0?$r(c)&&(T[_]=c):typeof c!="object"||c===null?Nr("Object expected"):($r(l=c.get)&&(T.get=l),$r(l=c.set)&&(T.set=l),$r(l=c.init)&&k.unshift(l));return T&&Ld(i,n,T),i},Gd=(e,t,n)=>t.has(e)||Nr("Cannot "+n),tn=(e,t,n)=>(Gd(e,t,"read from private field"),t.get(e)),Tt=(e,t,n)=>t.has(e)?Nr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),sr=(e,t,n,s)=>(Gd(e,t,"write to private field"),t.set(e,n),n),Wd={role:"button",roleDescription:"draggable",tabIndex:0},Xb="dnd-kit-description",Jb="dnd-kit-announcement",Zb={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},Hb={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(e)return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function ev(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLAnchorElement||e instanceof HTMLButtonElement||e instanceof HTMLAreaElement}var Na={};function Rd(e){const t=Na[e]==null?0:Na[e]+1;return Na[e]=t,`${e}-${t}`}function tv(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.innerText=t,n}function nv(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var rv=class extends St{constructor(e,t){super(e);const{id:n,idPrefix:{description:s=Xb,announcement:i=Jb}={},announcements:a=Hb,screenReaderInstructions:l=Zb}=t??{},c=n?`${s}-${n}`:Rd(s),u=n?`${i}-${n}`:Rd(i);let d,h;const p=Object.entries(a).map(([y,_])=>this.manager.monitor.addEventListener(y,(k,S)=>{const T=_==null?void 0:_(k,S);T&&h&&(h.innerText=T)})),f=()=>{d=tv(c,l.draggable),h=nv(u),document.body.append(d,h)},m=Hy(()=>{for(const y of e.registry.draggables.value){const{element:_,handle:k}=y,S=k??_;S&&((!d||!h)&&f(),!ev(S)&&!S.hasAttribute("tabindex")&&S.setAttribute("tabindex","0"),!S.hasAttribute("role")&&!(S instanceof HTMLButtonElement)&&S.setAttribute("role",Wd.role),S.hasAttribute("role-description")||S.setAttribute("aria-roledescription",Wd.roleDescription),S.hasAttribute("aria-describedby")||S.setAttribute("aria-describedby",c),S.setAttribute("aria-pressed",String(y.isDragSource)),S.setAttribute("aria-disabled",String(y.disabled)))}this.destroy=()=>{d==null||d.remove(),h==null||h.remove(),p.forEach(y=>y()),m()}})}},sv=class extends St{constructor(e,t){super(e,t),this.manager=e,this.destroy=at(()=>{var n;const{dragOperation:s}=this.manager,{cursor:i="grabbing"}=(n=this.options)!=null?n:{};if(s.status.initialized){const a=document.createElement("style");return a.innerText=`* { cursor: ${i} !important; }`,document.head.appendChild(a),()=>{a.remove()}}})}},Qd="data-dnd-",et="--dnd-",kn=`${Qd}dragging`,iv=`[${kn}] {position: fixed !important; pointer-events: none !important; touch-action: none !important; z-index: calc(infinity); will-change: transform;top: var(${et}top, 0px) !important;left: var(${et}left, 0px) !important;width: var(${et}width, auto) !important;height: var(${et}height, auto) !important;}[${kn}] *{pointer-events: none !important;}[${kn}][style*="${et}translate"] {translate: var(${et}translate) !important;}[style*="${et}transition"] {transition: var(${et}transition) !important;}*:where([${kn}][popover]){overflow:visible;background:var(${et}background);border:var(${et}border);margin:unset;padding:unset;color:inherit;}[${kn}]::backdrop {display: none}`,Ud=`${Qd}placeholder`,av=[kn,Ud,"popover"],ov=["view-transition-name"],lv=class extends St{constructor(e){super(e);let t,n,s={x:0,y:0},i,a,l=!1;const c=at(()=>{if(!t&&e.dragOperation.status.initialized)return t=document.createElement("style"),t.innerText=iv,document.head.prepend(t),c}),u=at(()=>{var d;const{dragOperation:h}=e,{position:p,source:f,status:m}=h;if(m.idle){n=void 0,i=void 0,a=void 0,s={x:0,y:0};return}if(!f)return;const{element:y,feedback:_}=f;if(!y||_==="none")return;const k=new en(y,!0),{width:S,height:T,top:I,left:z}=k,E=new Ed(y),{background:R,border:K,transition:ye,translate:xe}=Cn(y),V=e.registry.droppables.get(f.id),B=_==="clone",O=_!=="move"?Tb(y,B,{[Ud]:""}):null,F=Xn(()=>Ls(e.dragOperation.activatorEvent));if(xe!=="none"){const $=Os(xe);$&&(s=$)}if(n||(n={x:z,y:I}),!a){const $=Xn(()=>p.current);a={x:($.x-z)/S,y:($.y-I)/T}}const Y={x:n.x-z,y:n.y-I},X={top:I+Y.y,left:z+Y.x};y.setAttribute(kn,"true"),E.set({width:S,height:T,top:X.top,left:X.left,background:R,border:K,translate:i?`${i.x}px ${i.y}px 0`:""},et),O&&y.insertAdjacentElement("afterend",O),Va(y)&&(y.hasAttribute("popover")||y.setAttribute("popover",""),Ba(y));const ne=new en(y,!0),H={top:X.top-ne.top,left:X.left-ne.left};H.left>.01||H.top>.01?E.set({top:X.top+H.top,left:X.left+H.left},et):(H.left=0,H.top=0);const he=new ResizeObserver(()=>{if(!O)return;const $=new en(O,!0),te=a??{x:1,y:1},de=(S-$.width)*te.x+Y.x,Ie=(T-$.height)*te.y+Y.y;if(E.set({width:$.width,height:$.height,top:I+Ie+H.top,left:z+de+H.left},et),y instanceof HTMLTableRowElement&&O instanceof HTMLTableRowElement){const ft=Array.from(y.cells),ze=Array.from(O.cells);for(const[Gt,an]of ft.entries()){const Wt=ze[Gt];an.style.width=`${Wt.offsetWidth}px`}}e.dragOperation.shape=new en(y)});V&&O&&(V.placeholder=O,Xn(V.refreshShape)),h.shape=new en(y),f.status="dragging";let ce,ue;O&&(he.observe(O),ce=new MutationObserver(()=>{for(const $ of Array.from(y.attributes))if(!($.name.startsWith("aria-")||av.includes($.name))){if($.name==="style"){if(nr(y)&&nr(O)){O.setAttribute("style",B?"":"opacity: 0;"),O.style.setProperty("transition","none");for(const te of Object.values(y.style))te.startsWith(et)||ov.includes(te)||O.style.setProperty(te,y.style.getPropertyValue(te))}continue}O.setAttribute($.name,$.value)}B&&(O.innerHTML=y.innerHTML)}),ce.observe(y,{attributes:!0,subtree:!0}),ue=new MutationObserver($=>{for(const te of $)if(Array.from(te.addedNodes).includes(y)){y.insertAdjacentElement("afterend",O),Ba(y);return}}),ue.observe(y.ownerDocument.body,{childList:!0,subtree:!0}));const Qe=at(function(){var te,de;const{transform:Ie,status:ft}=h;if(!(!Ie.x&&!Ie.y&&!l)&&(l||(l=!0),ft.dragging)){const ze=F?"250ms ease":"0ms linear",Gt=Ie.x+s.x,an=Ie.y+s.y,Wt=new en(y);E.set({transition:`${ye}, translate ${ze}`,translate:`${Gt}px ${an}px 0`},et),h.shape=Wt.translate(Gt-((te=i==null?void 0:i.x)!=null?te:0),an-((de=i==null?void 0:i.y)!=null?de:0)),i={x:Gt,y:an,z:0,scaleX:Wt.scale.x,scaleY:Wt.scale.y}}}),Fe=(d=e.dragOperation.source)==null?void 0:d.id,sn=()=>{var $;if(!F||Fe==null)return;const te=e.registry.draggables.get(Fe),de=($=te==null?void 0:te.handle)!=null?$:te==null?void 0:te.element;de instanceof HTMLElement&&de.focus()};let be=()=>{ce==null||ce.disconnect(),ue==null||ue.disconnect(),he.disconnect(),E.reset(),l&&y.isConnected&&(O==null||O.replaceWith(y)),O==null||O.remove(),y.removeAttribute(kn),Va(y)&&y.removeAttribute("popover"),Qe(),_e(),V&&(V.placeholder=void 0),f.status="idle",l=!1};const _e=at(function(){if(h.status.dropped){const te=be;be=void 0,f.status="dropping";const de=i;if(!de){te==null||te();return}e.renderer.rendering.then(()=>{var Ie;Ba(y);const ft=O??y;E.remove(["translate"],et);const ze=new en(ft),Gt=new en(y,!0).translate(de.x,de.y),an={x:Gt.center.x-ze.center.x,y:Gt.center.y-ze.center.y},Wt={x:de.x-an.x,y:de.y-an.y,z:0};Ad({element:y,keyframes:{translate:[`${de.x}px ${de.y}px ${(Ie=de.z)!=null?Ie:0}`,`${Wt.x}px ${Wt.y}px ${Wt.z}`]},options:{duration:l?250:0,easing:"ease"},onFinish(){requestAnimationFrame(sn),te==null||te()}})})}});return()=>be==null?void 0:be()});this.destroy=()=>{c(),u(),t==null||t.remove()}}},Fr=!0,cv=!1,Yd,Kd,Xd,Jd,Tn,$a,Fa;Jd=(Xd=[ke],kt.Forward),Kd=(Yd=[ke],kt.Reverse);var Gr=class{constructor(){Tt(this,$a,He(Tn,8,this,Fr)),He(Tn,11,this),Tt(this,Fa,He(Tn,12,this,Fr)),He(Tn,15,this)}isLocked(e){return e===kt.Idle?!1:e==null?this[kt.Forward]===Fr&&this[kt.Reverse]===Fr:this[e]===Fr}unlock(e){e!==kt.Idle&&(this[e]=cv)}};Tn=Bs(null),$a=new WeakMap,Fa=new WeakMap,Sn(Tn,4,Jd,Xd,Gr,$a),Sn(Tn,4,Kd,Yd,Gr,Fa),qs(Tn,Gr);var uv=[kt.Forward,kt.Reverse],Zd=class{constructor(){this.x=new Gr,this.y=new Gr}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},dv=class extends St{constructor(e){super(e);const t=Ds(new Zd);let n=null;this.signal=t,at(()=>{const{status:s}=e.dragOperation;if(!s.initialized){n=null,t.value=new Zd;return}const{delta:i}=e.dragOperation.position;if(n){const a={x:Hd(i.x,n.x),y:Hd(i.y,n.y)},l=t.peek();un(()=>{for(const c of ed)for(const u of uv)a[c]===u&&l[c].unlock(u);t.value=l})}n=i})}get current(){return this.signal.peek()}};function Hd(e,t){return Math.sign(e-t)}var ep,Ga,Wr,Wa,Dn,Ra,Ns=class extends(Ga=vb,ep=[ke],Ga){constructor(e){super(e),Tt(this,Wa,He(Wr,8,this,!1)),He(Wr,11,this),Tt(this,Dn),Tt(this,Ra,()=>{if(!tn(this,Dn))return;const{element:a,by:l}=tn(this,Dn);a.scrollBy(l.x,l.y)}),this.scroll=a=>{var l;if(this.disabled)return!1;const c=this.getScrollableElements();if(!c)return sr(this,Dn,void 0),!1;const{position:u}=this.manager.dragOperation,d=u==null?void 0:u.current;if(d){const{by:h}=a??{},p=h?{x:tp(h.x),y:tp(h.y)}:void 0,f=p?void 0:this.scrollIntentTracker.current;if(f!=null&&f.isLocked())return!1;for(const m of c){const y=Db(m,h);if(y.x||y.y){const{speed:_,direction:k}=Lb(m,d,p);if(f)for(const S of ed)f[S].isLocked(k[S])&&(_[S]=0,k[S]=0);if(k.x||k.y){const{x:S,y:T}=h??k,I=S*_.x,z=T*_.y;if(I||z){const E=(l=tn(this,Dn))==null?void 0:l.by;if(this.autoScrolling&&E&&(E.x&&!I||E.y&&!z))continue;return sr(this,Dn,{element:m,by:{x:I,y:z}}),rr.schedule(tn(this,Ra)),!0}}}}}return sr(this,Dn,void 0),!1};let t=null,n=null;const s=Ms(()=>{var a;const{position:l}=e.dragOperation;if(!l)return null;const{x:c,y:u}=l.current,d=document.elementFromPoint(c,u);return d&&(t=d),(a=document.elementFromPoint(c,u))!=null?a:t}),i=Ms(()=>{const a=s.value;if(!a||a===document.documentElement){const{target:l}=e.dragOperation,c=l==null?void 0:l.element;if(c){const u=Ps(c,{excludeElement:!1});return n=u,u}}if(a){const l=Ps(a,{excludeElement:!1});return this.autoScrolling&&n&&l.size<(n==null?void 0:n.size)?n:(n=l,l)}return n=null,null},ua);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new dv(e),this.destroy=e.monitor.addEventListener("dragmove",a=>{this.disabled||a.defaultPrevented||!Ls(e.dragOperation.activatorEvent)||!a.by||this.scroll({by:a.by})&&a.preventDefault()})}};Wr=Bs(Ga),Wa=new WeakMap,Dn=new WeakMap,Ra=new WeakMap,Sn(Wr,4,"autoScrolling",ep,Ns,Wa),qs(Wr,Ns);function tp(e){return e>0?kt.Forward:e<0?kt.Reverse:kt.Idle}var pv=10,np=class extends St{constructor(e,t){super(e);const n=e.registry.plugins.get(Ns);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=at(()=>{if(this.disabled)return;const{position:s,status:i}=e.dragOperation;if(i.dragging)if(n.scroll()){n.autoScrolling=!0;const l=setInterval(n.scroll,pv);return()=>{clearInterval(l)}}else n.autoScrolling=!1})}},hv=class extends St{constructor(e){super(e),this.manager=e,this.destroy=at(()=>{const{dragOperation:t}=this.manager;if(t.status.initialized){const n=document.createElement("style");return n.innerText="* { user-select: none !important;, -webkit-user-select: none !important; }",document.head.appendChild(n),document.addEventListener("selectionchange",rp,{capture:!0}),()=>{document.removeEventListener("selectionchange",rp,{capture:!0}),n.remove()}}})}};function rp(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var sp={start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},$s=10,Rr,fv=class extends As{constructor(e,t){super(e),this.manager=e,this.options=t,Tt(this,Rr,[]),this.listeners=new Dd,this.handleSourceKeyDown=(n,s,i)=>{if(this.disabled||n.defaultPrevented||!(n.target instanceof Element)||s.disabled||!s.element)return;const{keyboardCodes:a=sp}=i??{};a.start.includes(n.code)&&this.manager.dragOperation.status.idle&&this.handleStart(n,s,i)}}bind(e,t=this.options){return at(()=>{var s;const i=(s=e.handle)!=null?s:e.element,a=l=>{l instanceof KeyboardEvent&&this.handleSourceKeyDown(l,e,t)};if(i)return i.addEventListener("keydown",a),()=>{i.removeEventListener("keydown",a)}})}handleStart(e,t,n){const{element:s}=t;if(!s)throw new Error("Source draggable does not have an associated element");e.preventDefault(),e.stopImmediatePropagation(),zd(s);const{center:i}=new en(s);un(()=>{this.manager.actions.setDragSource(t.id),this.manager.actions.start({event:e,coordinates:{x:i.x,y:i.y}})}),this.sideEffects();const a=qr(s),l=tr(a),c=[this.listeners.bind(a,[{type:"keydown",listener:u=>this.handleKeyDown(u,t,n),options:{capture:!0}}]),this.listeners.bind(l,[{type:"resize",listener:()=>this.handleEnd(!0)}])];tn(this,Rr).push(...c)}handleKeyDown(e,t,n){const{keyboardCodes:s=sp}=n??{};if(ir(e,[...s.end,...s.cancel])){e.preventDefault();const i=ir(e,s.cancel);this.handleEnd(i);return}ir(e,s.up)?this.handleMove("up",e):ir(e,s.down)&&this.handleMove("down",e),ir(e,s.left)?this.handleMove("left",e):ir(e,s.right)&&this.handleMove("right",e)}handleEnd(e){this.manager.actions.stop({canceled:e}),this.cleanup()}handleMove(e,t){const{shape:n}=this.manager.dragOperation,s=t.shiftKey?5:1;let i={x:0,y:0};if(n){switch(e){case"up":i={x:0,y:-$s*s};break;case"down":i={x:0,y:$s*s};break;case"left":i={x:-$s*s,y:0};break;case"right":i={x:$s*s,y:0};break}(i!=null&&i.x||i!=null&&i.y)&&(t.preventDefault(),this.manager.actions.move({by:i}))}}sideEffects(){const e=this.manager.registry.plugins.get(np);(e==null?void 0:e.disabled)===!1&&(e.disable(),tn(this,Rr).push(()=>{e.enable()}))}cleanup(){tn(this,Rr).forEach(e=>e())}destroy(){this.cleanup(),this.listeners.clear()}};Rr=new WeakMap;function ir(e,t){return t.includes(e.code)}var ar,Qa=class extends As{constructor(t,n){super(t),this.manager=t,this.options=n,this.listeners=new Dd,this.cleanup=new Set,Tt(this,ar),this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}bind(t,n=this.options){return at(()=>{var i;const a=(i=t.handle)!=null?i:t.element,l=c=>{c instanceof PointerEvent&&this.handlePointerDown(c,t,n)};if(a)return xv(a.ownerDocument.defaultView),a.addEventListener("pointerdown",l),()=>{a.removeEventListener("pointerdown",l)}})}handlePointerDown(t,n,s={}){if(this.disabled||!t.isPrimary||t.button!==0||!(t.target instanceof Element)||n.disabled)return;const{target:i}=t,a=i instanceof HTMLElement&&i.draggable&&i.getAttribute("draggable")==="true";this.initialCoordinates={x:t.clientX,y:t.clientY};const{activationConstraints:l}=s,c=typeof l=="function"?l(t,n):l;if(t.stopImmediatePropagation(),!(c!=null&&c.delay)&&!(c!=null&&c.distance))this.handleStart(n,t);else{const{delay:p}=c;if(p){const f=setTimeout(()=>this.handleStart(n,t),p.value);sr(this,ar,()=>{clearTimeout(f),sr(this,ar,void 0)})}}const u=qr(t.target),d=this.listeners.bind(u,[{type:"pointermove",listener:p=>this.handlePointerMove(p,n,s)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"touchmove",listener:Ua,options:{passive:!1}},{type:"click",listener:Ua},{type:"dragstart",listener:a?this.handleCancel:Ua},{type:"keydown",listener:this.handleKeyDown}]),h=()=>{var p;setTimeout(d),(p=tn(this,ar))==null||p.call(this),this.initialCoordinates=void 0,this.cleanup.delete(h)};this.cleanup.add(h)}handlePointerMove(t,n,s){const i={x:t.clientX,y:t.clientY};if(this.manager.dragOperation.status.dragging){t.preventDefault(),t.stopPropagation(),this.manager.actions.move({to:i});return}if(!this.initialCoordinates)return;const a={x:i.x-this.initialCoordinates.x,y:i.y-this.initialCoordinates.y},{activationConstraints:l}=s,c=typeof l=="function"?l(t,n):l,{distance:u,delay:d}=c??{};if(u){if(u.tolerance!=null&&ya(a,u.tolerance))return this.handleCancel();if(ya(a,u.value))return this.handleStart(n,t)}if(d&&ya(a,d.tolerance))return this.handleCancel()}handlePointerUp(t){t.preventDefault(),t.stopPropagation();const{status:n}=this.manager.dragOperation;if(!n.idle){const s=!n.initialized;this.manager.actions.stop({canceled:s})}this.cleanup.forEach(s=>s())}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel())}handleStart(t,n){var s;const{manager:i,initialCoordinates:a}=this;(s=tn(this,ar))==null||s.call(this),!(!a||i.dragOperation.status.initialized)&&(n.defaultPrevented||(n.preventDefault(),un(()=>{i.actions.setDragSource(t.id),i.actions.start({coordinates:a,event:n})})))}handleCancel(){const{dragOperation:t}=this.manager;t.status.initialized&&this.manager.actions.stop({canceled:!0}),this.cleanup.forEach(n=>n())}destroy(){this.listeners.clear()}};ar=new WeakMap,Qa.configure=bb(Qa);var gv=Qa;function Ua(e){e.preventDefault()}function mv(){}var ip=new WeakSet;function xv(e){!e||ip.has(e)||(e.addEventListener("touchmove",mv,{capture:!1,passive:!1}),ip.add(e))}gv.configure({activationConstraints(e,t){var n;const{pointerType:s,target:i}=e;if(!(s==="mouse"&&i instanceof Element&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return{delay:{value:200,tolerance:10},distance:{value:5}}}});var ap,op,lp,Ya,Vt,Ka,Xa,Ja,Qr=class extends(Ya=Br,lp=[ke],op=[ke],ap=[ke],Ya){constructor(e,t){var n=e,{element:s,effects:i=()=>[],handle:a,feedback:l="default"}=n,c=$d(n,["element","effects","handle","feedback"]);super(Nd({effects:()=>[...i(),()=>{var u,d;const{manager:h}=this;if(!h)return;const f=((d=(u=this.sensors)==null?void 0:u.map(od))!=null?d:[...h.sensors]).map(m=>{const y=m instanceof As?m:h.registry.register(m.plugin),_=m instanceof As?void 0:m.options;return y.bind(this,_)});return function(){f.forEach(y=>y())}}]},c),t),Tt(this,Ka,He(Vt,8,this)),He(Vt,11,this),Tt(this,Xa,He(Vt,12,this)),He(Vt,15,this),Tt(this,Ja,He(Vt,16,this)),He(Vt,19,this),this.element=s,this.handle=a,this.feedback=l}};Vt=Bs(Ya),Ka=new WeakMap,Xa=new WeakMap,Ja=new WeakMap,Sn(Vt,4,"handle",lp,Qr,Ka),Sn(Vt,4,"element",op,Qr,Xa),Sn(Vt,4,"feedback",ap,Qr,Ja),qs(Vt,Qr);var cp,up,Za,Mn,Ha,eo,Fs=class extends(Za=wn,up=[ke],cp=[ke],Za){constructor(e,t){var n=e,{element:s,effects:i=()=>[]}=n,a=$d(n,["element","effects"]),l;const{collisionDetector:c=jd}=a;super(Yb(Nd({},a),{collisionDetector:c,effects:()=>[...i(),()=>{const{element:u,manager:d}=this;if(!d)return;const{dragOperation:h}=d;if(u&&h.status.initialized){const p=Ab(u),f=qr(u),m=p===f.scrollingElement?f:p,y=new IntersectionObserver(S=>{const[T]=S.slice(-1),{width:I,height:z}=T.boundingClientRect;!I&&!z||(this.visible=T.isIntersecting)},{root:m??f,rootMargin:"40%"}),_=new MutationObserver(()=>rr.schedule(this.refreshShape)),k=new ResizeObserver(()=>rr.schedule(this.refreshShape));return u.parentElement&&_.observe(u.parentElement,{childList:!0}),k.observe(u),y.observe(u),()=>{this.shape=void 0,this.visible=void 0,k.disconnect(),_.disconnect(),y.disconnect()}}},()=>{const{manager:u}=this;if(!u)return;const{dragOperation:d}=u,{status:h}=d,p=Xn(()=>d.source);if(h.initialized){if((p==null?void 0:p.type)!=null&&!this.accepts(p))return;rr.schedule(this.refreshShape)}},()=>{var u;if((u=this.manager)!=null&&u.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),Tt(this,Ha,He(Mn,8,this)),He(Mn,11,this),Tt(this,eo,He(Mn,12,this)),He(Mn,15,this),this.internal={element:Ds(s)},this.refreshShape=this.refreshShape.bind(this),(l=this.manager)!=null&&l.dragOperation.status.initialized&&(this.visible=!0)}set element(e){this.internal.element.value=e}get element(){var e,t;return(t=this.placeholder)!=null?t:(e=this.internal)==null?void 0:e.element.value}refreshShape(e){const{element:t,shape:n}=this;if(!t||this.visible===!1){this.shape=void 0;return}const s=new en(t,e);return s&&(n!=null&&n.equals(s))?n:(this.shape=s,s)}};Mn=Bs(Za),Ha=new WeakMap,eo=new WeakMap,Sn(Mn,4,"visible",up,Fs,Ha),Sn(Mn,4,"placeholder",cp,Fs,eo),qs(Mn,Fs);var yv=Object.create,dp=Object.defineProperty,bv=Object.defineProperties,vv=Object.getOwnPropertyDescriptor,_v=Object.getOwnPropertyDescriptors,Gs=Object.getOwnPropertySymbols,pp=Object.prototype.hasOwnProperty,hp=Object.prototype.propertyIsEnumerable,jv=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Ur=e=>{throw TypeError(e)},to=(e,t,n)=>t in e?dp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wv=(e,t)=>{for(var n in t||(t={}))pp.call(t,n)&&to(e,n,t[n]);if(Gs)for(var n of Gs(t))hp.call(t,n)&&to(e,n,t[n]);return e},Cv=(e,t)=>bv(e,_v(t)),Sv=(e,t)=>{var n={};for(var s in e)pp.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Gs)for(var s of Gs(e))t.indexOf(s)<0&&hp.call(e,s)&&(n[s]=e[s]);return n},kv=e=>{var t;return[,,,yv((t=void 0)!=null?t:null)]},fp=["class","method","getter","setter","accessor","field","value","get","set"],Yr=e=>e!==void 0&&typeof e!="function"?Ur("Function expected"):e,Tv=(e,t,n,s,i)=>({kind:fp[e],name:t,metadata:s,addInitializer:a=>n._?Ur("Already initialized"):i.push(Yr(a||null))}),Dv=(e,t)=>to(t,jv("metadata"),e[3]),Ws=(e,t,n,s)=>{for(var i=0,a=e[t>>1],l=a&&a.length;i<l;i++)t&1?a[i].call(n):s=a[i].call(n,s);return s},gp=(e,t,n,s,i,a)=>{for(var l,c,u,d,h,p=t&7,f=!!(t&8),m=!!(t&16),y=e.length+1,_=fp[p+5],k=e[y-1]=[],S=e[y]||(e[y]=[]),T=(i=i.prototype,vv({get[n](){return Mv(this,a)},set[n](z){return Iv(this,a,z)}},n)),I=s.length-1;I>=0;I--)d=Tv(p,n,u={},e[3],S),d.static=f,d.private=m,h=d.access={has:z=>n in z},h.get=z=>z[n],h.set=(z,E)=>z[n]=E,c=(0,s[I])({get:T.get,set:T.set},d),u._=1,c===void 0?Yr(c)&&(T[_]=c):typeof c!="object"||c===null?Ur("Object expected"):(Yr(l=c.get)&&(T.get=l),Yr(l=c.set)&&(T.set=l),Yr(l=c.init)&&k.unshift(l));return T&&dp(i,n,T),i},mp=(e,t,n)=>t.has(e)||Ur("Cannot "+n),Mv=(e,t,n)=>(mp(e,t,"read from private field"),t.get(e)),xp=(e,t,n)=>t.has(e)?Ur("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Iv=(e,t,n,s)=>(mp(e,t,"write to private field"),t.set(e,n),n);function or(e){return e instanceof so||e instanceof jp}var Rs=10,zv=class extends St{constructor(e){super(e);const t=at(()=>{const{dragOperation:s}=e;if(Ls(s.activatorEvent)&&or(s.source)&&s.status.initialized){const i=e.registry.plugins.get(Ns);if(i)return i.disable(),()=>i.enable()}}),n=e.monitor.addEventListener("dragmove",(s,i)=>{queueMicrotask(()=>{if(this.disabled||s.defaultPrevented)return;const{dragOperation:a}=i;if(!Ls(a.activatorEvent)||!or(a.source)||!a.shape)return;const{actions:l,collisionObserver:c,registry:u}=i,{by:d}=s;if(!d)return;const h=Ev(d),{source:p}=a,{center:f}=a.shape.current,m=[];for(const S of u.droppables){const{shape:T,id:I}=S;if(!(!T||I===(p==null?void 0:p.id)&&or(S)||(p==null?void 0:p.type)!=null&&!S.accepts(p)))switch(h){case"down":f.y+Rs<T.center.y&&m.push(S);break;case"up":f.y-Rs>T.center.y&&m.push(S);break;case"left":f.x-Rs>T.center.x&&m.push(S);break;case"right":f.x+Rs<T.center.x&&m.push(S);break}}s.preventDefault(),c.disable();const y=c.computeCollisions(m,wb),[_]=y;if(!_)return;const{id:k}=_;l.setDropTarget(k).then(()=>{const{source:S}=a;if(!S)return;const T=u.droppables.get(S.id);if(!(T!=null&&T.element))return;const{element:I}=T;zd(I),rr.schedule(()=>{const z=T.refreshShape();z&&(l.move({to:{x:z.center.x,y:z.center.y}}),l.setDropTarget(S.id).then(()=>{a.shape=z,c.enable()}))})})})});this.destroy=()=>{n(),t()}}};function Ev(e){const{x:t,y:n}=e;if(t>0)return"right";if(t<0)return"left";if(n>0)return"down";if(n<0)return"up"}function Av(e,t,n){if(t===n)return e;const s=e.slice();return s.splice(n,0,s.splice(t,1)[0]),s}var Pv=class extends St{constructor(e){super(e);const t=s=>{var i;const a=new Map;for(const l of e.registry.droppables)if(l instanceof so){const{sortable:c}=l;if(c.group!==s)continue;if(a.has(c.index))throw new Error(`Duplicate sortable index found for same sortable group: ${c.droppable.id} and ${(i=a.get(c.index))==null?void 0:i.droppable.id} have the same index (${c.index}). Make sure each sortable item has a unique index. Use the \`group\` attribute to separate sortables into different groups.`);a.set(c.index,c)}return a},n=[e.monitor.addEventListener("dragover",(s,i)=>{queueMicrotask(()=>{if(this.disabled||s.defaultPrevented)return;const{dragOperation:a}=i,{source:l,target:c}=a;if(!or(l)||!or(c)||l.sortable===c.sortable||l.sortable.group!==c.sortable.group)return;const u=t(l.sortable.group);i.renderer.rendering.then(()=>{var d;for(const[k,S]of u.entries())if(S.index!==k)return;const h=Array.from(u.values()).sort((k,S)=>k.index-S.index),p=h.indexOf(l.sortable),f=h.indexOf(c.sortable),m=Av(h,p,f),y=(d=l.sortable.droppable.internal.element.peek())!=null?d:l.sortable.droppable.placeholder,_=c.element;!_||!y||(yp(y,p,_,f),un(()=>{for(const[k,S]of m.entries())S.index=k}))})})}),e.monitor.addEventListener("dragend",(s,i)=>{if(!s.canceled)return;const{dragOperation:a}=i,{source:l}=a;or(l)&&l.sortable.initialIndex!==l.sortable.index&&queueMicrotask(()=>{const c=t(l.sortable.group);i.renderer.rendering.then(()=>{var u;for(const[f,m]of c.entries())if(m.index!==f)return;const d=Array.from(c.values()).sort((f,m)=>f.index-m.index),h=l.sortable.droppable.element,p=(u=d[l.sortable.initialIndex])==null?void 0:u.element;!p||!h||(yp(h,l.sortable.index,p,l.sortable.initialIndex),un(()=>{for(const f of d.values())f.index=f.initialIndex}))})})})];this.destroy=()=>{for(const s of n)s()}}};function yp(e,t,n,s){const i=s<t?"beforebegin":"afterend";n.insertAdjacentElement(i,e)}var Ov=[zv,Pv],bp={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1},vp,_p,In,no,ro;_p=[ke],vp=[ke];var Qs=class{constructor(e,t){xp(this,no,Ws(In,8,this)),Ws(In,11,this),xp(this,ro,Ws(In,12,this)),Ws(In,15,this);var n=e,{effects:s=()=>[],group:i,index:a,sensors:l,type:c,transition:u=bp,plugins:d=Ov}=n,h=Sv(n,["effects","group","index","sensors","type","transition","plugins"]);this.droppable=new so(h,t,this),this.draggable=new jp(Cv(wv({},h),{effects:()=>[()=>{var p;return(p=this.manager)==null?void 0:p.monitor.addEventListener("dragstart",()=>{this.initialIndex=this.index,this.previousIndex=this.index})},()=>{const{index:p,previousIndex:f,manager:m}=this;p!==f&&(this.previousIndex=p,this.animate())},()=>{const{target:p}=this,{feedback:f,isDragSource:m}=this.draggable;f=="move"&&m&&(this.droppable.disabled=!p)},()=>{const{manager:p}=this;for(const f of d)p==null||p.registry.register(f)},...s()],type:c,sensors:l}),t,this),this.manager=t,this.index=a,this.previousIndex=a,this.initialIndex=a,this.group=i,this.type=c,this.transition=u,this.destroy=()=>{this.draggable.destroy(),this.droppable.destroy()}}animate(){Xn(()=>{const{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;const{idle:s}=e.dragOperation.status;!n||!t||s&&!t.idle||rr.schedule(()=>{const{element:i}=this.droppable;if(!i)return;const a=this.refreshShape();if(!a)return;const l={x:n.boundingRectangle.left-a.boundingRectangle.left,y:n.boundingRectangle.top-a.boundingRectangle.top},{x:c,y:u,z:d}=Nb(i);(l.x||l.y)&&Ad({element:i,keyframes:{translate:[`${c+l.x}px ${u+l.y}px ${d}`,`${c}px ${u}px ${d}`]},options:t,onFinish:()=>{s&&(this.droppable.shape=void 0)}})})})}get manager(){return this.draggable.manager}set manager(e){this.draggable.manager=e,this.droppable.manager=e}set element(e){this.draggable.element=e,this.droppable.element=e}get element(){var e;return(e=this.droppable.element)!=null?e:this.draggable.element}set target(e){this.droppable.element=e}get target(){return this.droppable.element}set source(e){this.draggable.element=e}get source(){return this.draggable.element}get disabled(){return this.draggable.disabled&&this.droppable.disabled}set feedback(e){this.draggable.feedback=e}set disabled(e){un(()=>{this.draggable.disabled=e,this.droppable.disabled=e})}set data(e){un(()=>{this.draggable.data=e,this.droppable.data=e})}set handle(e){this.draggable.handle=e}set id(e){un(()=>{this.draggable.id=e,this.droppable.id=e})}get id(){return this.droppable.id}set sensors(e){this.draggable.sensors=e}set collisionPriority(e){this.droppable.collisionPriority=e??Lr.Normal}set collisionDetector(e){this.droppable.collisionDetector=e??jd}set type(e){this.draggable.type=e,this.droppable.type=e}get type(){return this.draggable.type}set accept(e){this.droppable.accept=e}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get status(){return this.draggable.status}refreshShape(e=!1){return this.droppable.refreshShape(e)}accepts(e){return this.droppable.accepts(e)}register(){var e,t;return(e=this.manager)==null||e.registry.register(this.draggable),(t=this.manager)==null||t.registry.register(this.droppable),()=>this.unregister()}unregister(){var e,t;(e=this.manager)==null||e.registry.unregister(this.draggable),(t=this.manager)==null||t.registry.unregister(this.droppable)}destroy(){this.draggable.destroy(),this.droppable.destroy()}};In=kv(),no=new WeakMap,ro=new WeakMap,gp(In,4,"index",_p,Qs,no),gp(In,4,"group",vp,Qs,ro),Dv(In,Qs);var jp=class extends Qr{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}},so=class extends Fs{constructor(e,t,n){super(e,t),this.sortable=n}refreshShape(e=!1){return super.refreshShape(e)}get index(){return this.sortable.index}};function wp(e){const t=g.useRef();return t.current||(t.current=e()),t.current}var Lv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Cp=Lv?g.useLayoutEffect:g.useEffect;function Vv(e,t=!1){const n=wp(()=>e instanceof Ze?e:Ds(e));let s=n.peek();const i=g.useState(s)[1];return Cp(()=>at(()=>{s!==(s=n.value)&&(t?Kg.flushSync(()=>i(s)):i(s))}),[t]),n}function io(e,t=!1){return Vv(wp(()=>Ms(e)),t)}function Bv(e,t){e()}function tt(e,t,n=g.useEffect,s=Object.is){const i=g.useRef(e);n(()=>{const a=i.current;s(e,a)||(i.current=e,t(e,a))},[t,e])}function ao(e){var t;if(e!=null)return typeof e=="object"&&"current"in e?(t=e.current)!=null?t:void 0:e}var qv=Object.defineProperty,Nv=Object.defineProperties,$v=Object.getOwnPropertyDescriptors,Sp=Object.getOwnPropertySymbols,Fv=Object.prototype.hasOwnProperty,Gv=Object.prototype.propertyIsEnumerable,kp=(e,t,n)=>t in e?qv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wv=(e,t)=>{for(var n in t||(t={}))Fv.call(t,n)&&kp(e,n,t[n]);if(Sp)for(var n of Sp(t))Gv.call(t,n)&&kp(e,n,t[n]);return e},Rv=(e,t)=>Nv(e,$v(t));function Tp(e){const{accept:t,collisionDetector:n,collisionPriority:s,id:i,data:a,index:l,group:c,disabled:u,feedback:d,sensors:h,transition:p=bp,type:f}=e,m=is.useDragDropManager(),y=ao(e.handle),_=ao(e.element),k=ao(e.target),S=is.useInstance(E=>new Qs(Rv(Wv({},e),{handle:y,element:_,target:k,feedback:d}),E)),T=io(()=>S.isDropTarget),I=io(()=>S.isDragSource),z=io(()=>S.status);return tt(i,()=>S.id=i),tt(l,()=>S.index=l,Cp),tt(f,()=>S.type=f),tt(c,()=>S.group=c),tt(t,()=>S.accept=t,void 0,ua),tt(a,()=>a&&(S.data=a)),tt(l,()=>{m!=null&&m.dragOperation.status.idle&&p&&S.refreshShape()},Bv),tt(y,()=>S.handle=y),tt(_,()=>S.element=_),tt(k,()=>S.target=k),tt(u,()=>S.disabled=u===!0),tt(h,()=>S.sensors=h),tt(n,()=>S.collisionDetector=n),tt(s,()=>S.collisionPriority=s),tt(d,()=>S.feedback=d??"default"),tt(p,()=>S.transition=p),{get isDragSource(){return I.value},get isDropTarget(){return T.value},get status(){return z.value},handleRef:g.useCallback(E=>{S.handle=E??void 0},[S]),ref:g.useCallback(E=>{S.element=E??void 0},[S]),sourceRef:g.useCallback(E=>{S.source=E??void 0},[S]),targetRef:g.useCallback(E=>{S.target=E??void 0},[S])}}const Qv=({value:e,onChange:t})=>{const n=s=>{s&&t(s)};return r.jsx(o.Box,{children:r.jsx(gt,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Dp={static:{type:"static",value:10},dynamic:{type:"dynamic",value:["function getValue({ variables }, { lodash, interpolate }) {"," // your code goes here"," return 100;","}"].join(`
70
- `)}},Uv=({value:e,onChange:t})=>{const{t:n}=j.useTranslation(),[s,{setTrue:i,setFalse:a}]=J.useBoolean(),[l,c]=g.useState(e),u=()=>{a();const{type:f,value:m}=l,y={type:f,value:m};c(y),t(y)},d=()=>{a(),c(e)},h=f=>{c(m=>({...m,value:f}))},p=()=>{h(Dp.dynamic.value)};return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{sx:{width:"50%"},children:r.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:i,sx:{flexGrow:0},children:n("chart.number_or_dynamic_value.dynamic.setup")})}),r.jsx(o.Modal,{size:800,title:n("chart.number_or_dynamic_value.dynamic.setup_title"),opened:s,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mt:10,mb:-10,label:n("chart.number_or_dynamic_value.dynamic.guide"),labelPosition:"center",variant:"dashed"}),r.jsx(Qv,{value:l.value,onChange:h}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:p,color:"red",leftIcon:r.jsx(W.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:u,children:n("common.actions.save")})]})]})]})})]})},Yv=({value:e,onChange:t})=>e.type!=="dynamic"?null:r.jsx(Uv,{value:e,onChange:t}),Kv=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=s=>{t({...e,value:s})};return r.jsx(o.NumberInput,{defaultValue:18,label:" ",hideControls:!0,value:e.value,onChange:n})},Mp=g.forwardRef(({label:e="Value",value:t,onChange:n},s)=>{const{t:i,i18n:a}=j.useTranslation(),l=u=>{n({...Dp[u]})},c=g.useMemo(()=>[{label:i("chart.number_or_dynamic_value.type.static"),value:"static"},{label:i("chart.number_or_dynamic_value.type.dynamic"),value:"dynamic"}],[a.language]);return r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(o.Select,{ref:s,label:e,data:c,value:t.type,onChange:l,sx:{flexGrow:1}}),r.jsx(Kv,{value:t,onChange:n}),r.jsx(Yv,{value:t,onChange:n})]})});function Ip(e,t,n){if(!e.type)return n;if(e.type==="static"){const{value:i}=e;return Number(i)}const{value:s}=e;try{const i=new Function(`return ${s}`)()({variables:t},{lodash:v,interpolate:xn.interpolate});return Number(i)}catch(i){return console.error(`[getNumberOrDynamicValue] failed parsing custom function, error: ${i.message}`),10}}function zp(e){return{type:"continuous",id:"continuous-example",min:{type:"static",value:0},max:{type:"static",value:100},orient:"horizontal",left:"center",top:"top",text:["",""],calculable:!0,itemWidth:15,itemHeight:140,show:!0,inRange:{color:e??Object.values(cn.graphics.depth)},skipRange:{lt_min:"",min:"",max:"",gt_max:""}}}function Xv(){return{type:"piecewise",piecewise_mode:"pieces",id:"piecewise-visualmap",min:{type:"static",value:0},max:{type:"static",value:100},align:"auto",orient:"horizontal",left:"center",top:"top",itemWidth:15,itemHeight:15,show:!0,precision:0,pieces:[Ep()],categories:[]}}function pn(){return zp()}function Jv(){return{compared:Object.values(cn.graphics.compared),level:Object.values(cn.graphics.level),depth:Object.values(cn.graphics.depth),yellow_blue:["#8f531d","#ffd347","#e3efe3","#eefaee","#4ecbbf","#003f94"],blue:["#f9fcff","#48b3e9","#003f94"],darkgreen_pink:["#0c525a","#f21f99"],spectrum:["#ff0000","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#ff0000"]}}function Us(e,t){const{min:n,max:s}=e,i=Ip(n,t),a=Ip(s,t);if(e.type==="continuous"){const{skipRange:p,text:f,...m}=e;return{...m,min:i,max:a,text:[...f]}}const{piecewise_mode:l,pieces:c,categories:u,...d}=e,h={...d};return delete h.min,delete h.max,l==="pieces"?h.pieces=c.map(p=>{const f={};p.label&&(f.label=p.label),p.color&&(f.color=p.color);const m=Number(p.lower.value);p.lower.value===""?f[p.lower.symbol]=i:Number.isFinite(m)&&(f[p.lower.symbol]=m);const y=Number(p.upper.value);return p.upper.value===""?f[p.upper.symbol]=a:Number.isFinite(y)&&(f[p.upper.symbol]=y),f}):l==="categories"&&(h.categories=u),h}const lr=e=>({followVisualMap:!e,color:e});function oo(e,t,n,s){if(s.type!=="continuous")return lr("");const{skipRange:i}=s;return e===t?lr(i.min):e===n?lr(i.max):e<t?lr(i.lt_min):e>n?lr(i.gt_max):lr("")}function Ep(){return{lower:{value:"0",symbol:"gt"},upper:{value:"",symbol:"lt"},label:"",color:""}}const Zv=Jv(),Hv=({colors:e,applyPalette:t,zIndex:n=340})=>{const{t:s}=j.useTranslation(),i=`linear-gradient(to right, ${e.join(", ")})`;return r.jsxs(o.Menu,{shadow:"md",width:300,withinPortal:!0,zIndex:n,children:[r.jsx(o.Menu.Target,{children:r.jsxs(o.UnstyledButton,{children:[r.jsx(o.Text,{style:{display:"inline-block",fontSize:"0.875rem",fontWeight:500,color:"#212529",wordBreak:"break-word",cursor:"default"},children:s("chart.color.color_gradient")}),r.jsxs(o.Group,{style:{padding:"0.4375rem 0.625rem",border:"0.0625rem solid #ced4da",borderRadius:"0.25rem",columnGap:10},children:[r.jsx(o.Box,{style:{height:"20px",flexGrow:1,backgroundImage:i,borderRadius:4}}),r.jsx(M.IconSelector,{size:14,color:"rgb(134, 142, 150)"})]})]})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Label,{children:s("chart.visual_map.built_in_palettes")}),r.jsx(o.Menu.Divider,{}),Object.entries(Zv).map(([a,l])=>r.jsx(o.Tooltip,{label:s("chart.visual_map.use_palette_x",{x:a}),children:r.jsx(o.Menu.Item,{children:r.jsx(o.Box,{style:{height:"20px",width:"100%",backgroundImage:`linear-gradient(to right, ${l.join(", ")})`,borderRadius:4,boxShadow:"0 0 3px 0 #eee",cursor:"pointer"},onClick:()=>{t(l)},title:a})})},a))]})]})},e_=({color:e,index:t,handleChange:n,handleRemove:s})=>{const[i,{setTrue:a,setFalse:l}]=J.useBoolean(!1),{ref:c,handleRef:u}=Tp({id:e.id,index:t});return r.jsxs(o.Flex,{ref:c,gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",onMouseEnter:a,onMouseLeave:l,children:[r.jsx(o.Center,{style:{minWidth:"30px",maxWidth:"30px",flex:0},children:i?r.jsx(o.ActionIcon,{size:"xs",ref:u,children:r.jsx(M.IconGripVertical,{})}):r.jsx(o.Badge,{size:"sm",children:t+1})}),r.jsx("div",{style:{flex:1},children:r.jsx(o.ColorInput,{styles:{root:{flexGrow:1}},withinPortal:!0,dropdownZIndex:340,size:"xs",value:e.value,onChange:n})}),r.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0},children:r.jsx(o.CloseButton,{onClick:s})})]})},Ap=g.forwardRef(({value:e,onChange:t,zIndex:n=340},s)=>{const{t:i}=j.useTranslation(),a=g.useMemo(()=>e.map(y=>({id:on.v4(),value:y})),[e]),l=y=>{t([...e,y])},c=y=>{const _=[...e];_.splice(y,1),t(_)},u=y=>{t([...y])},d=y=>_=>{const k=[...e];k[y]=_,t(k)},[h,p]=g.useState(""),f=()=>{h&&(l(h),p(""))},m=y=>{const{source:_,target:k}=y.operation,S=Yg.move(a,_,k);t(S.map(T=>T.value))};return r.jsxs(o.Stack,{ref:s,children:[r.jsx(Hv,{colors:e,applyPalette:u,zIndex:n}),r.jsx(is.DragDropProvider,{onDragEnd:m,children:a.map((y,_)=>r.jsx(e_,{color:y,handleChange:d(_),handleRemove:()=>c(_),index:_},y.id))}),r.jsxs(o.Flex,{gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",children:[r.jsx("div",{style:{minWidth:"30px",maxWidth:"30px",flex:0}}),r.jsx("div",{style:{flex:1},children:r.jsx(o.ColorInput,{withinPortal:!0,dropdownZIndex:n,placeholder:i("chart.color.click_to_add_a_color"),value:h,onChange:p,onBlur:f,size:"xs"})}),r.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0}})]})]})}),t_=({defaultValues:e,onSubmit:t,unset:n,cancel:s})=>{const{t:i}=j.useTranslation(),a=b.useForm({defaultValues:e}),{control:l,handleSubmit:c,watch:u,getValues:d,reset:h}=a;g.useEffect(()=>{h(e)},[e]);const p=g.useCallback(()=>h(e),[h,e]);return r.jsxs(o.Box,{children:[r.jsx(o.Divider,{color:"rgb(206, 212, 218)",variant:"dotted",my:"1rem"}),r.jsxs(o.Box,{px:"1rem",children:[r.jsx(b.Controller,{control:l,name:"variable",render:({field:f})=>r.jsx(oa,{label:i("rich_text.color_mapping.choose_value_var"),clearable:!1,preview:"aggregated",zIndex:340,...f})}),r.jsxs(o.Group,{grow:!0,position:"apart",children:[r.jsx(b.Controller,{name:"min_var",control:l,render:({field:f})=>r.jsx(oa,{label:i("rich_text.color_mapping.min.var"),clearable:!1,preview:"aggregated",sx:{flexGrow:1,maxWidth:"unset"},...f})}),r.jsx(b.Controller,{name:"min_val",control:l,render:({field:f})=>r.jsx(o.TextInput,{label:i("rich_text.color_mapping.min.val"),...f,sx:{maxWidth:"120px",flexGrow:0}})})]}),r.jsxs(o.Group,{grow:!0,position:"apart",children:[r.jsx(b.Controller,{name:"max_var",control:l,render:({field:f})=>r.jsx(oa,{label:i("rich_text.color_mapping.max.var"),clearable:!1,preview:"aggregated",sx:{flexGrow:1,maxWidth:"unset"},...f})}),r.jsx(b.Controller,{name:"max_val",control:l,render:({field:f})=>r.jsx(o.TextInput,{label:i("rich_text.color_mapping.max.val"),...f,sx:{maxWidth:"120px",flexGrow:0}})})]}),r.jsx(b.Controller,{control:l,name:"colors",render:({field:f})=>r.jsx(Ap,{...f})})]}),r.jsx(o.Divider,{color:"rgb(206, 212, 218)",variant:"dotted",my:"1rem"}),r.jsxs(o.Group,{position:"apart",px:"1rem",pb:"0.75rem",children:[r.jsxs(o.Group,{position:"left",children:[r.jsx(o.Button,{color:"red",size:"xs",onClick:n,leftIcon:r.jsx(M.IconTrash,{size:18}),children:i("common.actions.clear")}),r.jsx(o.Button,{color:"orange",size:"xs",onClick:p,leftIcon:r.jsx(M.IconArrowBackUp,{size:18}),children:i("common.actions.revert")})]}),r.jsx(o.Button,{color:"green",size:"xs",onClick:c(t),leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),children:i("common.actions.save_changes")})]})]})},n_=()=>{const e=o.useMantineTheme();return r.jsx("div",{style:{width:"20px",height:"13px",borderRadius:"2px",background:e.fn.linearGradient(90,...Object.values(cn.graphics.depth))}})},r_=({disabled:e})=>{const t=o.useMantineTheme();return r.jsx(o.Box,{sx:{width:"16px",height:"10px",borderRadius:"2px",background:t.fn.linearGradient(90,...Object.values(cn.graphics.depth)),opacity:e?"0.5":1,position:"relative","&:after":{position:"absolute",content:"''",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"15px",height:"15px",background:`
70
+ `)}},Uv=({value:e,onChange:t})=>{const{t:n}=j.useTranslation(),[s,{setTrue:i,setFalse:a}]=J.useBoolean(),[l,c]=g.useState(e),u=()=>{a();const{type:f,value:m}=l,y={type:f,value:m};c(y),t(y)},d=()=>{a(),c(e)},h=f=>{c(m=>({...m,value:f}))},p=()=>{h(Dp.dynamic.value)};return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{sx:{width:"50%"},children:r.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:i,sx:{flexGrow:0},children:n("chart.number_or_dynamic_value.dynamic.setup")})}),r.jsx(o.Modal,{size:800,title:n("chart.number_or_dynamic_value.dynamic.setup_title"),opened:s,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mt:10,mb:-10,label:n("chart.number_or_dynamic_value.dynamic.guide"),labelPosition:"center",variant:"dashed"}),r.jsx(Qv,{value:l.value,onChange:h}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:p,color:"red",leftIcon:r.jsx(W.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:u,children:n("common.actions.save")})]})]})]})})]})},Yv=({value:e,onChange:t})=>e.type!=="dynamic"?null:r.jsx(Uv,{value:e,onChange:t}),Kv=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=s=>{t({...e,value:s})};return r.jsx(o.NumberInput,{defaultValue:18,label:" ",hideControls:!0,value:e.value,onChange:n})},Mp=g.forwardRef(({label:e="Value",value:t,onChange:n},s)=>{const{t:i,i18n:a}=j.useTranslation(),l=u=>{n({...Dp[u]})},c=g.useMemo(()=>[{label:i("chart.number_or_dynamic_value.type.static"),value:"static"},{label:i("chart.number_or_dynamic_value.type.dynamic"),value:"dynamic"}],[a.language]);return r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(o.Select,{ref:s,label:e,data:c,value:t.type,onChange:l,sx:{flexGrow:1}}),r.jsx(Kv,{value:t,onChange:n}),r.jsx(Yv,{value:t,onChange:n})]})});function Ip(e,t,n){if(!e.type)return n;if(e.type==="static"){const{value:i}=e;return Number(i)}const{value:s}=e;try{const i=new Function(`return ${s}`)()({variables:t},{lodash:v,interpolate:xn.interpolate});return Number(i)}catch(i){return console.error(`[getNumberOrDynamicValue] failed parsing custom function, error: ${i.message}`),10}}function zp(e){return{type:"continuous",id:"continuous-example",min:{type:"static",value:0},max:{type:"static",value:100},orient:"horizontal",left:"center",top:"top",text:["",""],calculable:!0,itemWidth:15,itemHeight:140,show:!0,inRange:{color:e??Object.values(cn.graphics.depth)},skipRange:{lt_min:"",min:"",max:"",gt_max:""}}}function Xv(){return{type:"piecewise",piecewise_mode:"pieces",id:"piecewise-visualmap",min:{type:"static",value:0},max:{type:"static",value:100},align:"auto",orient:"horizontal",left:"center",top:"top",itemWidth:15,itemHeight:15,show:!0,precision:0,pieces:[Ep()],categories:[]}}function pn(){return zp()}function Jv(){return{compared:Object.values(cn.graphics.compared),level:Object.values(cn.graphics.level),depth:Object.values(cn.graphics.depth),yellow_blue:["#8f531d","#ffd347","#e3efe3","#eefaee","#4ecbbf","#003f94"],blue:["#f9fcff","#48b3e9","#003f94"],darkgreen_pink:["#0c525a","#f21f99"],spectrum:["#ff0000","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#ff0000"]}}function Us(e,t){const{min:n,max:s}=e,i=Ip(n,t),a=Ip(s,t);if(e.type==="continuous"){const{skipRange:p,text:f,...m}=e;return{...m,min:i,max:a,text:[...f]}}const{piecewise_mode:l,pieces:c,categories:u,...d}=e,h={...d};return delete h.min,delete h.max,l==="pieces"?h.pieces=c.map(p=>{const f={};p.label&&(f.label=p.label),p.color&&(f.color=p.color);const m=Number(p.lower.value);p.lower.value===""?f[p.lower.symbol]=i:Number.isFinite(m)&&(f[p.lower.symbol]=m);const y=Number(p.upper.value);return p.upper.value===""?f[p.upper.symbol]=a:Number.isFinite(y)&&(f[p.upper.symbol]=y),f}):l==="categories"&&(h.categories=u),h}const lr=e=>({followVisualMap:!e,color:e});function oo(e,t,n,s){if(s.type!=="continuous")return lr("");const{skipRange:i}=s;return e===t?lr(i.min):e===n?lr(i.max):e<t?lr(i.lt_min):e>n?lr(i.gt_max):lr("")}function Ep(){return{lower:{value:"0",symbol:"gt"},upper:{value:"",symbol:"lt"},label:"",color:""}}const Zv=Jv(),Hv=({colors:e,applyPalette:t,zIndex:n=340})=>{const{t:s}=j.useTranslation(),i=`linear-gradient(to right, ${e.join(", ")})`;return r.jsxs(o.Menu,{shadow:"md",width:300,withinPortal:!0,zIndex:n,children:[r.jsx(o.Menu.Target,{children:r.jsxs(o.UnstyledButton,{children:[r.jsx(o.Text,{style:{display:"inline-block",fontSize:"0.875rem",fontWeight:500,color:"#212529",wordBreak:"break-word",cursor:"default"},children:s("chart.color.color_gradient")}),r.jsxs(o.Group,{style:{padding:"0.4375rem 0.625rem",border:"0.0625rem solid #ced4da",borderRadius:"0.25rem",columnGap:10},children:[r.jsx(o.Box,{style:{height:"20px",flexGrow:1,backgroundImage:i,borderRadius:4}}),r.jsx(M.IconSelector,{size:14,color:"rgb(134, 142, 150)"})]})]})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Label,{children:s("chart.visual_map.built_in_palettes")}),r.jsx(o.Menu.Divider,{}),Object.entries(Zv).map(([a,l])=>r.jsx(o.Tooltip,{label:s("chart.visual_map.use_palette_x",{x:a}),children:r.jsx(o.Menu.Item,{children:r.jsx(o.Box,{style:{height:"20px",width:"100%",backgroundImage:`linear-gradient(to right, ${l.join(", ")})`,borderRadius:4,boxShadow:"0 0 3px 0 #eee",cursor:"pointer"},onClick:()=>{t(l)},title:a})})},a))]})]})},e_=({color:e,index:t,handleChange:n,handleRemove:s})=>{const[i,{setTrue:a,setFalse:l}]=J.useBoolean(!1),{ref:c,handleRef:u}=Tp({id:e.id,index:t});return r.jsxs(o.Flex,{ref:c,gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",onMouseEnter:a,onMouseLeave:l,children:[r.jsx(o.Center,{style:{minWidth:"30px",maxWidth:"30px",flex:0},children:i?r.jsx(o.ActionIcon,{size:"xs",ref:u,children:r.jsx(M.IconGripVertical,{})}):r.jsx(o.Badge,{size:"sm",children:t+1})}),r.jsx("div",{style:{flex:1},children:r.jsx(o.ColorInput,{styles:{root:{flexGrow:1}},withinPortal:!0,dropdownZIndex:340,size:"xs",value:e.value,onChange:n})}),r.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0},children:r.jsx(o.CloseButton,{onClick:s})})]})},Ap=g.forwardRef(({value:e,onChange:t,zIndex:n=340},s)=>{const{t:i}=j.useTranslation(),a=g.useMemo(()=>e.map(y=>({id:on.v4(),value:y})),[e]),l=y=>{t([...e,y])},c=y=>{const _=[...e];_.splice(y,1),t(_)},u=y=>{t([...y])},d=y=>_=>{const k=[...e];k[y]=_,t(k)},[h,p]=g.useState(""),f=()=>{h&&(l(h),p(""))},m=y=>{const{source:_,target:k}=y.operation,S=Yg.move(a,_,k);t(S.map(T=>T.value))};return r.jsxs(o.Stack,{ref:s,children:[r.jsx(Hv,{colors:e,applyPalette:u,zIndex:n}),r.jsx(is.DragDropProvider,{onDragEnd:m,children:a.map((y,_)=>r.jsx(e_,{color:y,handleChange:d(_),handleRemove:()=>c(_),index:_},y.id))}),r.jsxs(o.Flex,{gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",children:[r.jsx("div",{style:{minWidth:"30px",maxWidth:"30px",flex:0}}),r.jsx("div",{style:{flex:1},children:r.jsx(o.ColorInput,{withinPortal:!0,dropdownZIndex:n,placeholder:i("chart.color.click_to_add_a_color"),value:h,onChange:p,onBlur:f,size:"xs"})}),r.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0}})]})]})}),t_=({defaultValues:e,onSubmit:t,unset:n})=>{const{t:s}=j.useTranslation(),i=b.useForm({defaultValues:e}),{control:a,handleSubmit:l,reset:c}=i;g.useEffect(()=>{c(e)},[e]);const u=g.useCallback(()=>c(e),[c,e]);return r.jsxs(o.Box,{children:[r.jsx(o.Divider,{color:"rgb(206, 212, 218)",variant:"dotted",my:"1rem"}),r.jsxs(o.Box,{px:"1rem",children:[r.jsx(b.Controller,{control:a,name:"variable",render:({field:d})=>r.jsx(oa,{label:s("rich_text.color_mapping.choose_value_var"),clearable:!1,preview:"aggregated",zIndex:340,...d})}),r.jsxs(o.Group,{grow:!0,position:"apart",children:[r.jsx(b.Controller,{name:"min_var",control:a,render:({field:d})=>r.jsx(oa,{label:s("rich_text.color_mapping.min.var"),preview:"aggregated",sx:{flexGrow:1,maxWidth:"unset"},...d})}),r.jsx(b.Controller,{name:"min_val",control:a,render:({field:d})=>r.jsx(o.TextInput,{label:s("rich_text.color_mapping.min.val"),...d,sx:{maxWidth:"120px",flexGrow:0}})})]}),r.jsxs(o.Group,{grow:!0,position:"apart",children:[r.jsx(b.Controller,{name:"max_var",control:a,render:({field:d})=>r.jsx(oa,{label:s("rich_text.color_mapping.max.var"),preview:"aggregated",sx:{flexGrow:1,maxWidth:"unset"},...d})}),r.jsx(b.Controller,{name:"max_val",control:a,render:({field:d})=>r.jsx(o.TextInput,{label:s("rich_text.color_mapping.max.val"),...d,sx:{maxWidth:"120px",flexGrow:0}})})]}),r.jsx(b.Controller,{control:a,name:"colors",render:({field:d})=>r.jsx(Ap,{...d})})]}),r.jsx(o.Divider,{color:"rgb(206, 212, 218)",variant:"dotted",my:"1rem"}),r.jsxs(o.Group,{position:"apart",px:"1rem",pb:"0.75rem",children:[r.jsxs(o.Group,{position:"left",children:[r.jsx(o.Button,{color:"red",size:"xs",onClick:n,leftIcon:r.jsx(M.IconTrash,{size:18}),children:s("common.actions.clear")}),r.jsx(o.Button,{color:"orange",size:"xs",onClick:u,leftIcon:r.jsx(M.IconArrowBackUp,{size:18}),children:s("common.actions.revert")})]}),r.jsx(o.Button,{color:"green",size:"xs",onClick:l(t),leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),children:s("common.actions.save_changes")})]})]})},n_=()=>{const e=o.useMantineTheme();return r.jsx("div",{style:{width:"20px",height:"13px",borderRadius:"2px",background:e.fn.linearGradient(90,...Object.values(cn.graphics.depth))}})},r_=({disabled:e})=>{const t=o.useMantineTheme();return r.jsx(o.Box,{sx:{width:"16px",height:"10px",borderRadius:"2px",background:t.fn.linearGradient(90,...Object.values(cn.graphics.depth)),opacity:e?"0.5":1,position:"relative","&:after":{position:"absolute",content:"''",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"15px",height:"15px",background:`
71
71
  linear-gradient(to top right,
72
72
  rgba(0,0,0,0) 0%,
73
73
  rgba(0,0,0,0) calc(50% - 1.4px),
@@ -77,7 +77,7 @@ Check the top-level render call using <`+q+">.")}return A}}function $g(C,A){{if(
77
77
  rgba(0,0,0,0) calc(50% + 0.8px),
78
78
  rgba(255,255,255,1) calc(50% + 1.4px),
79
79
  rgba(0,0,0,0) calc(50% + 1.4px),
80
- rgba(0,0,0,0) 100%)`}}})},s_=({editor:e})=>{const{t}=j.useTranslation(),[n,{set:s,setTrue:i,setFalse:a,toggle:l}]=J.useBoolean(),c=e.getAttributes(bu),{empty:u,...d}=g.useMemo(()=>Ry(c),[c]),h=g.useCallback(f=>{e.chain().focus().setColorMapping(f).run(),a()},[e]),p=g.useCallback(()=>{e.chain().focus().unsetColorMapping().run()},[e]);return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{size:500,opened:n,onClose:a,shadow:"md",withinPortal:!0,zIndex:330,closeOnClickOutside:!1,closeOnEscape:!1,title:t("rich_text.color_mapping.edit"),styles:{header:{paddingBottom:0},body:{padding:0}},children:r.jsx(t_,{defaultValues:d,cancel:a,unset:p,onSubmit:h})}),r.jsxs(ee.RichTextEditor.ControlsGroup,{children:[r.jsx(o.Tooltip,{label:t("rich_text.color_mapping.label"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"#000"},onClick:i,children:r.jsx(n_,{})})}),r.jsx(o.Tooltip,{label:t("rich_text.color_mapping.clear"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"},disabled:u,onClick:p,children:r.jsx(r_,{disabled:u})})})]})]})},Kr=({value:e,styles:t={},sx:n={},dashboardState:s=uo(),variableAggValueMap:i={}})=>{const a=Iu(),l=g.useMemo(()=>{const f=[fc,pc,ee.Link,ic,sc,nc,ac.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),cc,lc,oc,uc.configure({types:["heading","paragraph"]}),rc.configure({placeholder:"This is placeholder"}),dc,tc.Color,mu,fu];return a&&f.push(vu),f},[a]),c=hc.useEditor({extensions:l,content:e,editable:!1});g.useEffect(()=>{c==null||c.commands.setContent(e)},[e,c]);const u=g.useMemo(()=>new DOMParser().parseFromString(e,"text/html"),[e]),d=g.useMemo(()=>My(u,s,i),[u,s,i]),h=g.useMemo(()=>Wy(u,i),[u,i]),p=g.useMemo(()=>v.defaultsDeep({},{content:{...Ei,...d,...h}},t),[t,d,h]);return r.jsx(ee.RichTextEditor,{editor:c,styles:p,sx:n,children:r.jsx(ee.RichTextEditor.Content,{})})};function Pp(){const{t:e}=j.useTranslation(),[t,{open:n,close:s}]=Se.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:s,title:e("function_utils.modal_title"),zIndex:330,withinPortal:!0,children:r.jsx(Kr,{value:Gm(e),styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),r.jsx(o.Button,{variant:"light",color:"violet",size:"xs",onClick:n,leftIcon:r.jsx(M.IconInfoCircle,{size:16}),children:e("function_utils.trigger_text")})]})}const Op=g.forwardRef((e,t)=>{const{label:n,description:s,...i}=e;return r.jsx("div",{ref:t,...i,children:r.jsxs(o.Group,{position:"apart",noWrap:!0,children:[r.jsx(o.Text,{children:n}),r.jsx(o.Text,{size:"xs",color:"dimmed",children:s})]})})}),lo=({value:e,onChange:t,height:n="200px",defaultLanguage:s="sql",theme:i="vs-dark"})=>{const a=c=>{t==null||t(c??"")},l=!t;return r.jsx(gt,{className:"minimal-monaco-editor",height:n,defaultLanguage:s,value:e,onChange:l?void 0:a,theme:i,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!t,"semanticHighlighting.enabled":!0}})},i_=["gray","red","grape","blue","cyan","green","yellow"],a_=({editor:e})=>{const{t}=j.useTranslation(),n=o.useMantineTheme(),[s,{set:i,setFalse:a,toggle:l}]=J.useBoolean(),c=e.getAttributes("textStyle").color||n.black,u=g.useMemo(()=>Ut(c).hex(),[c]),d=g.useMemo(()=>{const f=[];return i_.forEach(m=>{const y=n.colors[m];y&&y.forEach(_=>{f.push(_)})}),f},[n.colors]),h=(f,m=!0)=>{e.chain().focus().setColor(f).run(),m&&a()},p=()=>{e.chain().focus().unsetColor().run(),a()};return r.jsxs(o.Popover,{opened:s,onChange:i,shadow:"md",withinPortal:!0,zIndex:340,withArrow:!0,children:[r.jsx(o.Popover.Target,{children:r.jsx(ee.RichTextEditor.Control,{onClick:l,children:r.jsx(o.ColorSwatch,{color:u,size:14})})}),r.jsx(o.Popover.Dropdown,{children:r.jsxs(o.Stack,{spacing:"xs",children:[r.jsxs(o.Group,{position:"right",children:[r.jsx(o.ColorInput,{value:u,onChangeEnd:f=>h(f,!1),size:"xs",withPicker:!1,dropdownZIndex:340,styles:{root:{flexGrow:1},input:{fontFamily:"monospace",letterSpacing:2,textAlign:"center"}}}),r.jsx(o.ActionIcon,{variant:"default",onClick:p,title:t("common.actions.clear"),children:r.jsx(M.IconCircleOff,{stroke:1.5,size:"1rem"})}),r.jsx(o.ActionIcon,{variant:"default",onClick:a,title:t("common.actions.close"),children:r.jsx(M.IconX,{stroke:1.5,size:"1rem"})})]}),r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(o.ColorPicker,{format:"hex",swatches:d,value:u,onChange:f=>h(f,!1),size:"sm",withPicker:!1,styles:{swatches:{marginTop:"0 !important"}}}),r.jsx(o.ColorPicker,{format:"hex",fullWidth:!0,value:u,onChange:f=>h(f,!1)})]})]})})]})},o_={"dynamic-color":{position:"relative"},"dynamic-color:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"1px",border:"double 1px purple"},"color-mapping":{position:"relative"},"color-mapping:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"4px",opacity:.8,background:"linear-gradient(90deg, rgb(255, 225, 225) 0%, rgb(253, 188, 188) 40%, rgb(243, 148, 148) 60%, rgb(250, 66, 66) 80%, rgb(226, 18, 18) 100%)"}};function l_(){const{editor:e}=ee.useRichTextEditorContext();return r.jsx(ee.RichTextEditor.Control,{onClick:()=>e==null?void 0:e.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}),"aria-label":"Insert table",title:"Insert table",children:r.jsx(M.IconBorderAll,{stroke:1.5,size:16})})}const Ys=g.forwardRef(({value:e,onChange:t,styles:n={},label:s,autoSubmit:i,onSubmit:a},l)=>{const c=zu(),u=g.useMemo(()=>{const _=[fc,pc,ee.Link,ic,sc,nc,ac.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),cc,lc,oc,uc.configure({types:["heading","paragraph"]}),rc.configure({placeholder:"This is placeholder"}),dc,tc.Color,mu,fu];return c&&_.push(vu),_},[c]),[d,h]=g.useState(e),p=hc.useEditor({extensions:u,content:d,onUpdate:({editor:_})=>{const k=_.getHTML();h(k)},onCreate:({editor:_})=>{_.view.dom.setAttribute("spellcheck","false"),_.view.dom.setAttribute("autocomplete","off"),_.view.dom.setAttribute("autocapitalize","off")}});g.useEffect(()=>{h(_=>e===_?_:(p==null||p.commands.setContent(e),e))},[e]);const f=()=>{t(d),a==null||a()},m=e!==d;g.useEffect(()=>{i&&f()},[i,m]);const y=g.useMemo(()=>v.defaultsDeep({},{content:{...Ei,...o_}},n),[n]);return p?r.jsxs(o.Stack,{spacing:4,sx:{flexGrow:1,position:"relative"},children:[r.jsxs(o.Group,{align:"center",children:[r.jsx(o.Text,{size:14,fw:500,children:s}),!i&&r.jsx(o.ActionIcon,{color:"green",disabled:!m,onClick:f,children:r.jsx(M.IconDeviceFloppy,{size:18})})]}),r.jsxs(ee.RichTextEditor,{editor:p,styles:y,children:[r.jsxs(ee.RichTextEditor.Toolbar,{sticky:!0,stickyOffset:0,children:[r.jsx(a_,{editor:p}),c&&r.jsx(s_,{editor:p}),r.jsx(ee.RichTextEditor.ControlsGroup,{children:r.jsx(Ly,{editor:p})}),r.jsxs(ee.RichTextEditor.ControlsGroup,{children:[r.jsx(ee.RichTextEditor.Bold,{}),r.jsx(ee.RichTextEditor.Italic,{}),r.jsx(ee.RichTextEditor.Underline,{}),r.jsx(ee.RichTextEditor.ClearFormatting,{}),r.jsx(ee.RichTextEditor.Highlight,{}),r.jsx(ee.RichTextEditor.Code,{})]}),r.jsxs(ee.RichTextEditor.ControlsGroup,{children:[r.jsx(ee.RichTextEditor.H1,{}),r.jsx(ee.RichTextEditor.H2,{}),r.jsx(ee.RichTextEditor.H3,{}),r.jsx(ee.RichTextEditor.H4,{})]}),r.jsxs(ee.RichTextEditor.ControlsGroup,{children:[r.jsx(ee.RichTextEditor.Blockquote,{}),r.jsx(ee.RichTextEditor.Hr,{}),r.jsx(ee.RichTextEditor.BulletList,{}),r.jsx(ee.RichTextEditor.OrderedList,{}),r.jsx(ee.RichTextEditor.Subscript,{}),r.jsx(ee.RichTextEditor.Superscript,{})]}),r.jsxs(ee.RichTextEditor.ControlsGroup,{children:[r.jsx(ee.RichTextEditor.Link,{}),r.jsx(ee.RichTextEditor.Unlink,{})]}),r.jsxs(ee.RichTextEditor.ControlsGroup,{children:[r.jsx(ee.RichTextEditor.AlignLeft,{}),r.jsx(ee.RichTextEditor.AlignCenter,{}),r.jsx(ee.RichTextEditor.AlignJustify,{}),r.jsx(ee.RichTextEditor.AlignRight,{})]}),r.jsx(ee.RichTextEditor.ControlsGroup,{children:r.jsx(l_,{})}),r.jsx(Ny,{editor:p})]}),r.jsx(ee.RichTextEditor.Content,{})]})]}):null}),We={mantissa:0,output:"number",trimMantissa:!1,average:!1,absolute:!1};function se(e,{absolute:t,...n}){if(e===null)return String(e);try{let s=ss(e).value();if(s===void 0||Number.isNaN(s))throw new Error(`[formatNumber]Not a number: ${e}`);return t&&(s=Math.abs(s)),ss(s).format(n)}catch(s){return console.debug(s),String(e)}}function c_(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function nn({data_field:e,aggregation:t},n){return ds(n,e,t)}function vt({formatter:e,aggregation:t},n){if(typeof n!="string"&&typeof n!="number")return c_(n);if(t.type==="custom")return n;try{return se(n,e)}catch(s){return console.error(s),n}}function Lp(e,t){return e.replaceAll(/(\$\{([^{\}]+(?=}))\})/g,(...s)=>{const i=s[2],a=t.variableStyleMap[i];if(!a)return`{{${i}}}`;const{variable:l,...c}=a,u=Object.entries(c).map(([f,m])=>`${f}:${m}`).join(";"),d=l.color;if(d.type!=="continuous")return`<span style="${u}">{{${i}}}</span>`;const h=pu(6),p=`try {
80
+ rgba(0,0,0,0) 100%)`}}})},s_=({editor:e})=>{const{t}=j.useTranslation(),[n,{set:s,setTrue:i,setFalse:a,toggle:l}]=J.useBoolean(),c=e.getAttributes(bu),{empty:u,...d}=g.useMemo(()=>Ry(c),[c]),h=g.useCallback(f=>{e.chain().focus().setColorMapping(f).run(),a()},[e]),p=g.useCallback(()=>{e.chain().focus().unsetColorMapping().run()},[e]);return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{size:500,opened:n,onClose:a,shadow:"md",withinPortal:!0,zIndex:330,closeOnClickOutside:!1,closeOnEscape:!1,title:t("rich_text.color_mapping.edit"),styles:{header:{paddingBottom:0},body:{padding:0}},children:r.jsx(t_,{defaultValues:d,unset:p,onSubmit:h})}),r.jsxs(ee.RichTextEditor.ControlsGroup,{children:[r.jsx(o.Tooltip,{label:t("rich_text.color_mapping.label"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"#000"},onClick:i,children:r.jsx(n_,{})})}),r.jsx(o.Tooltip,{label:t("rich_text.color_mapping.clear"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"},disabled:u,onClick:p,children:r.jsx(r_,{disabled:u})})})]})]})},Kr=({value:e,styles:t={},sx:n={},dashboardState:s=uo(),variableAggValueMap:i={}})=>{const a=Iu(),l=g.useMemo(()=>{const f=[fc,pc,ee.Link,ic,sc,nc,ac.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),cc,lc,oc,uc.configure({types:["heading","paragraph"]}),rc.configure({placeholder:"This is placeholder"}),dc,tc.Color,mu,fu];return a&&f.push(vu),f},[a]),c=hc.useEditor({extensions:l,content:e,editable:!1});g.useEffect(()=>{c==null||c.commands.setContent(e)},[e,c]);const u=g.useMemo(()=>new DOMParser().parseFromString(e,"text/html"),[e]),d=g.useMemo(()=>My(u,s,i),[u,s,i]),h=g.useMemo(()=>Wy(u,i),[u,i]),p=g.useMemo(()=>v.defaultsDeep({},{content:{...Ei,...d,...h}},t),[t,d,h]);return r.jsx(ee.RichTextEditor,{editor:c,styles:p,sx:n,children:r.jsx(ee.RichTextEditor.Content,{})})};function Pp(){const{t:e}=j.useTranslation(),[t,{open:n,close:s}]=Se.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:s,title:e("function_utils.modal_title"),zIndex:330,withinPortal:!0,children:r.jsx(Kr,{value:Gm(e),styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),r.jsx(o.Button,{variant:"light",color:"violet",size:"xs",onClick:n,leftIcon:r.jsx(M.IconInfoCircle,{size:16}),children:e("function_utils.trigger_text")})]})}const Op=g.forwardRef((e,t)=>{const{label:n,description:s,...i}=e;return r.jsx("div",{ref:t,...i,children:r.jsxs(o.Group,{position:"apart",noWrap:!0,children:[r.jsx(o.Text,{children:n}),r.jsx(o.Text,{size:"xs",color:"dimmed",children:s})]})})}),lo=({value:e,onChange:t,height:n="200px",defaultLanguage:s="sql",theme:i="vs-dark"})=>{const a=c=>{t==null||t(c??"")},l=!t;return r.jsx(gt,{className:"minimal-monaco-editor",height:n,defaultLanguage:s,value:e,onChange:l?void 0:a,theme:i,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!t,"semanticHighlighting.enabled":!0}})},i_=["gray","red","grape","blue","cyan","green","yellow"],a_=({editor:e})=>{const{t}=j.useTranslation(),n=o.useMantineTheme(),[s,{set:i,setFalse:a,toggle:l}]=J.useBoolean(),c=e.getAttributes("textStyle").color||n.black,u=g.useMemo(()=>Ut(c).hex(),[c]),d=g.useMemo(()=>{const f=[];return i_.forEach(m=>{const y=n.colors[m];y&&y.forEach(_=>{f.push(_)})}),f},[n.colors]),h=(f,m=!0)=>{e.chain().focus().setColor(f).run(),m&&a()},p=()=>{e.chain().focus().unsetColor().run(),a()};return r.jsxs(o.Popover,{opened:s,onChange:i,shadow:"md",withinPortal:!0,zIndex:340,withArrow:!0,children:[r.jsx(o.Popover.Target,{children:r.jsx(ee.RichTextEditor.Control,{onClick:l,children:r.jsx(o.ColorSwatch,{color:u,size:14})})}),r.jsx(o.Popover.Dropdown,{children:r.jsxs(o.Stack,{spacing:"xs",children:[r.jsxs(o.Group,{position:"right",children:[r.jsx(o.ColorInput,{value:u,onChangeEnd:f=>h(f,!1),size:"xs",withPicker:!1,dropdownZIndex:340,styles:{root:{flexGrow:1},input:{fontFamily:"monospace",letterSpacing:2,textAlign:"center"}}}),r.jsx(o.ActionIcon,{variant:"default",onClick:p,title:t("common.actions.clear"),children:r.jsx(M.IconCircleOff,{stroke:1.5,size:"1rem"})}),r.jsx(o.ActionIcon,{variant:"default",onClick:a,title:t("common.actions.close"),children:r.jsx(M.IconX,{stroke:1.5,size:"1rem"})})]}),r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(o.ColorPicker,{format:"hex",swatches:d,value:u,onChange:f=>h(f,!1),size:"sm",withPicker:!1,styles:{swatches:{marginTop:"0 !important"}}}),r.jsx(o.ColorPicker,{format:"hex",fullWidth:!0,value:u,onChange:f=>h(f,!1)})]})]})})]})},o_={"dynamic-color":{position:"relative"},"dynamic-color:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"1px",border:"double 1px purple"},"color-mapping":{position:"relative"},"color-mapping:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"4px",opacity:.8,background:"linear-gradient(90deg, rgb(255, 225, 225) 0%, rgb(253, 188, 188) 40%, rgb(243, 148, 148) 60%, rgb(250, 66, 66) 80%, rgb(226, 18, 18) 100%)"}};function l_(){const{editor:e}=ee.useRichTextEditorContext();return r.jsx(ee.RichTextEditor.Control,{onClick:()=>e==null?void 0:e.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}),"aria-label":"Insert table",title:"Insert table",children:r.jsx(M.IconBorderAll,{stroke:1.5,size:16})})}const Ys=g.forwardRef(({value:e,onChange:t,styles:n={},label:s,autoSubmit:i,onSubmit:a},l)=>{const c=zu(),u=g.useMemo(()=>{const _=[fc,pc,ee.Link,ic,sc,nc,ac.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),cc,lc,oc,uc.configure({types:["heading","paragraph"]}),rc.configure({placeholder:"This is placeholder"}),dc,tc.Color,mu,fu];return c&&_.push(vu),_},[c]),[d,h]=g.useState(e),p=hc.useEditor({extensions:u,content:d,onUpdate:({editor:_})=>{const k=_.getHTML();h(k)},onCreate:({editor:_})=>{_.view.dom.setAttribute("spellcheck","false"),_.view.dom.setAttribute("autocomplete","off"),_.view.dom.setAttribute("autocapitalize","off")}});g.useEffect(()=>{h(_=>e===_?_:(p==null||p.commands.setContent(e),e))},[e]);const f=()=>{t(d),a==null||a()},m=e!==d;g.useEffect(()=>{i&&f()},[i,m]);const y=g.useMemo(()=>v.defaultsDeep({},{content:{...Ei,...o_}},n),[n]);return p?r.jsxs(o.Stack,{spacing:4,sx:{flexGrow:1,position:"relative"},children:[r.jsxs(o.Group,{align:"center",children:[r.jsx(o.Text,{size:14,fw:500,children:s}),!i&&r.jsx(o.ActionIcon,{color:"green",disabled:!m,onClick:f,children:r.jsx(M.IconDeviceFloppy,{size:18})})]}),r.jsxs(ee.RichTextEditor,{editor:p,styles:y,children:[r.jsxs(ee.RichTextEditor.Toolbar,{sticky:!0,stickyOffset:0,children:[r.jsx(a_,{editor:p}),c&&r.jsx(s_,{editor:p}),r.jsx(ee.RichTextEditor.ControlsGroup,{children:r.jsx(Ly,{editor:p})}),r.jsxs(ee.RichTextEditor.ControlsGroup,{children:[r.jsx(ee.RichTextEditor.Bold,{}),r.jsx(ee.RichTextEditor.Italic,{}),r.jsx(ee.RichTextEditor.Underline,{}),r.jsx(ee.RichTextEditor.ClearFormatting,{}),r.jsx(ee.RichTextEditor.Highlight,{}),r.jsx(ee.RichTextEditor.Code,{})]}),r.jsxs(ee.RichTextEditor.ControlsGroup,{children:[r.jsx(ee.RichTextEditor.H1,{}),r.jsx(ee.RichTextEditor.H2,{}),r.jsx(ee.RichTextEditor.H3,{}),r.jsx(ee.RichTextEditor.H4,{})]}),r.jsxs(ee.RichTextEditor.ControlsGroup,{children:[r.jsx(ee.RichTextEditor.Blockquote,{}),r.jsx(ee.RichTextEditor.Hr,{}),r.jsx(ee.RichTextEditor.BulletList,{}),r.jsx(ee.RichTextEditor.OrderedList,{}),r.jsx(ee.RichTextEditor.Subscript,{}),r.jsx(ee.RichTextEditor.Superscript,{})]}),r.jsxs(ee.RichTextEditor.ControlsGroup,{children:[r.jsx(ee.RichTextEditor.Link,{}),r.jsx(ee.RichTextEditor.Unlink,{})]}),r.jsxs(ee.RichTextEditor.ControlsGroup,{children:[r.jsx(ee.RichTextEditor.AlignLeft,{}),r.jsx(ee.RichTextEditor.AlignCenter,{}),r.jsx(ee.RichTextEditor.AlignJustify,{}),r.jsx(ee.RichTextEditor.AlignRight,{})]}),r.jsx(ee.RichTextEditor.ControlsGroup,{children:r.jsx(l_,{})}),r.jsx(Ny,{editor:p})]}),r.jsx(ee.RichTextEditor.Content,{})]})]}):null}),We={mantissa:0,output:"number",trimMantissa:!1,average:!1,absolute:!1};function se(e,{absolute:t,...n}){if(e===null)return String(e);try{let s=ss(e).value();if(s===void 0||Number.isNaN(s))throw new Error(`[formatNumber]Not a number: ${e}`);return t&&(s=Math.abs(s)),ss(s).format(n)}catch(s){return console.debug(s),String(e)}}function c_(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function nn({data_field:e,aggregation:t},n){return ds(n,e,t)}function vt({formatter:e,aggregation:t},n){if(typeof n!="string"&&typeof n!="number")return c_(n);if(t.type==="custom")return n;try{return se(n,e)}catch(s){return console.error(s),n}}function Lp(e,t){return e.replaceAll(/(\$\{([^{\}]+(?=}))\})/g,(...s)=>{const i=s[2],a=t.variableStyleMap[i];if(!a)return`{{${i}}}`;const{variable:l,...c}=a,u=Object.entries(c).map(([f,m])=>`${f}:${m}`).join(";"),d=l.color;if(d.type!=="continuous")return`<span style="${u}">{{${i}}}</span>`;const h=pu(6),p=`try {
81
81
  return utils.popmotion.interpolate(${JSON.stringify(d.valueRange)}, ${JSON.stringify(d.colorRange)})(variables["${i}"]);
82
82
  } catch (error) {
83
83
  console.error(error);
@@ -89,7 +89,7 @@ Check the top-level render call using <`+q+">.")}return A}}function $g(C,A){{if(
89
89
  ${Object.entries(t).map(([s,i])=>`const ${s} = '${i}';`).join(`
90
90
  `)}
91
91
  return ${e};
92
- `)(n)}catch(s){return console.error(s),console.log(e),e}}function Np(e,t,n,s){const i=w_(t,s);return e.replaceAll(/(\{\{([^{\}]+(?=}))\}\})/g,(...l)=>{const c=l[2];if(!c)return c;const u=i[c];if(u)return u;const d=C_(c);return S_(d,i,n)})}function k_(e,t){const n=xc.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function T_({query:e,name:t,payload:n,additionals:s},i){if(!e.sql)return[];const{type:a,key:l,sql:c,pre_process:u,post_process:d}=e,h=Di(c,n),p=Wm({sql:h,pre_process:u}),f=xc.encode(p);k_(p,f);let m=await Kt.query(i)({type:a,key:l,query:f,...s},{params:{name:t}});return m=Rm(d,m,po(n)),m}async function D_({type:e,key:t,configString:n,name:s,additionals:i},a){try{return await Kt.httpDataSourceQuery(a)({type:e,key:t,query:n,...i},{params:{name:s}})}catch(l){if(Rt.isCancel(l))throw l;return console.error(l),l}}async function ho(){try{return(await Kt.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function $p(){try{return(await Kt.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class Fp{constructor(t){N(this,"rootRef");this.rootRef=ae.observable({current:t})}async deleteItem(t){ae.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?ae.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(v.isObject(n))ae.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else ae.runInAction(()=>{v.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,s){return ae.reaction(()=>this.getValueFromRoot(t),(i,a)=>{n(i,a)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class M_{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new yc)}getChannel(t){const n=this.channels.get(t);if(n)return n;const s=new yc;return this.channels.set(t,s),s}}class I_{constructor(t){N(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new M_,instanceData:new Fp(t.viz.conf)};return this.instances.set(t.id,s),s}}function Gp(e,t,n,s){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new Fp({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const z_=e=>{const{panel:t,measure:n,vizManager:s,data:i,variables:a}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={...Gp(c,i,s,a),viewport:{width:n.w,height:n.h}},d=l.viewRender;return r.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},E_=e=>{const{vizManager:t,panel:n,data:s,variables:i}=e,a=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...Gp(l,s,t,i)},u=a.configRender;return r.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},Wp=(e,t)=>{const n=Ut.bezier(e),s=Ut.bezier(t);return function(i){return i<50?n(i*2/100).hex():s((i-50)*2/100).hex()}},Js=e=>{const t=Ut.bezier(e);return function(n){return t(n/100).hex()}},A_={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:Wp(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},P_={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:Wp(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},O_={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:Js(["#fff7f1","darkred"]),name:"red",category:"sequential"},L_={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:Js(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},V_={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:Js(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},B_={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:Js(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class q_{constructor(t){N(this,"symbol");this.symbol=Symbol(t)}}function hn(e){return new q_(e)}class fo{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const t=new fo;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const s=n(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=v.get(t,"dispose");v.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const Rp="13.28.0",N_=Object.freeze(Object.defineProperty({__proto__:null,version:Rp},Symbol.toStringTag,{value:"Module"}));class $_{constructor(t){N(this,"staticColors",new Map);N(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class F_{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class G_{constructor(){N(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,s){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),a=v.orderBy(i,"version","asc");if(((l=v.last(a))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return a.reduce((c,u)=>u.handler(c,s),n)}}class Me extends G_{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(s,i)=>({version:t,...n(s,i)}))}async migrate({configData:t,panelModel:n}){const s=await t.getItem(null),i=v.get(s,"version",0),a=this.run({from:i,to:this.VERSION},s,{panelModel:n});await t.setItem(null,a)}async needMigration({configData:t}){const n=await t.getItem(null);return v.get(n,"version",0)<this.VERSION}}const Q=(e,t)=>{const[n,{setFalse:s}]=J.useBoolean(!0),[i,a]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{a(c),s()}),e.watchItem(t,c=>{a(c)})));const l=g.useCallback(async c=>{await e.setItem(t,c),a(c)},[e,t]);return{loading:n,value:i,set:l}},ut={top:16,right:16,bottom:16,left:16},Bt=e=>Math.max(0,e-ut.left-ut.right),qt=e=>Math.max(0,e-ut.top-ut.bottom),Jr=(e,t)=>({width:Bt(e),height:qt(t)}),dt=({width:e,height:t,children:n})=>r.jsx(o.Box,{pt:ut.top,pr:ut.right,pb:ut.bottom,pl:ut.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),go={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function W_({context:e}){const{value:t}=Q(e.instanceData,"config"),n=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:h}=v.defaults({},t,go),p=g.useMemo(()=>cs(n,a),[n,a]),{x:f,y:m,z:y}=g.useMemo(()=>({x:L(a),y:L(l),z:L(c)}),[a,l,c]),{min:_,max:k}=g.useMemo(()=>{const T=v.minBy(p,z=>z[y.columnKey]),I=v.maxBy(p,z=>z[y.columnKey]);return{min:v.get(T,y.columnKey),max:v.get(I,y.columnKey)}},[p,y]),S={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:_,max:k,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:h,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:p.map(T=>[T[f.columnKey],T[m.columnKey],T[y.columnKey]])}]};return t?r.jsx(dt,{width:s,height:i,children:r.jsx(Ke,{echarts:Ye,option:S,style:Jr(s,i),notMerge:!0,theme:"merico-light"})}):null}const U=D.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,queryID:a,clearable:l=!1,sx:c,...u},d)=>{const{panel:h}=Je(),p=g.useMemo(()=>h.dataFieldOptions(s,l,a),[s,l,a]);if(p.length===0){const f=h.explainDataKey(s);return r.jsxs(o.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Box,{children:r.jsx(o.TextInput,{label:e,required:t,defaultValue:f.columnKey,readOnly:!0,disabled:!0})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(o.Text,{size:"xs",color:f.queryName?"black":"red",sx:{fontFamily:"monospace"},children:f.queryName??f.queryID}),r.jsx(o.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),r.jsx(o.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:f.columnKey})]})})]})}return r.jsx(o.Select,{ref:d,label:e,description:n,data:p,value:s,onChange:i,required:t,sx:c,maxDropdownHeight:500,...u})}));function R_({context:e}){const{value:t,set:n}=Q(e.instanceData,"config"),s=v.defaults({},t,go),{control:i,handleSubmit:a,reset:l}=b.useForm({defaultValues:s});return g.useEffect(()=>{l(s)},[t]),t?r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(o.Text,{children:"X Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>r.jsx(U,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Y Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>r.jsx(U,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Z Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>r.jsx(U,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:r.jsxs(o.Button,{color:"blue",type:"submit",children:[r.jsx(W.DeviceFloppy,{size:20}),r.jsx(o.Text,{ml:"md",children:"Save"})]})})]})}):null}const Q_=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function U_(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(a),z_axis_data_key:s(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class Y_ extends Me{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:U_(i,s)}})}}const K_={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Y_,name:"bar-3d",viewRender:W_,configRender:R_,createConfig(){return{version:2,config:v.cloneDeep(go)}},translation:Q_},X_=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(o.Box,{sx:{position:"relative"},children:[e&&r.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(gt,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function pt({enabled:e,func_content:t}){return(n,s)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function nt(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
92
+ `)(n)}catch(s){return console.error(s),console.log(e),e}}function Np(e,t,n,s){const i=w_(t,s);return e.replaceAll(/(\{\{([^{\}]+(?=}))\}\})/g,(...l)=>{const c=l[2];if(!c)return c;const u=i[c];if(u)return u;const d=C_(c);return S_(d,i,n)})}function k_(e,t){const n=xc.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function T_({query:e,name:t,payload:n,additionals:s},i){if(!e.sql)return[];const{type:a,key:l,sql:c,pre_process:u,post_process:d}=e,h=Di(c,n),p=Wm({sql:h,pre_process:u}),f=xc.encode(p);k_(p,f);let m=await Kt.query(i)({type:a,key:l,query:f,...s},{params:{name:t}});return m=Rm(d,m,po(n)),m}async function D_({type:e,key:t,configString:n,name:s,additionals:i},a){try{return await Kt.httpDataSourceQuery(a)({type:e,key:t,query:n,...i},{params:{name:s}})}catch(l){if(Rt.isCancel(l))throw l;return console.error(l),l}}async function ho(){try{return(await Kt.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function $p(){try{return(await Kt.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class Fp{constructor(t){N(this,"rootRef");this.rootRef=ae.observable({current:t})}async deleteItem(t){ae.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?ae.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(v.isObject(n))ae.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else ae.runInAction(()=>{v.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,s){return ae.reaction(()=>this.getValueFromRoot(t),(i,a)=>{n(i,a)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class M_{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new yc)}getChannel(t){const n=this.channels.get(t);if(n)return n;const s=new yc;return this.channels.set(t,s),s}}class I_{constructor(t){N(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new M_,instanceData:new Fp(t.viz.conf)};return this.instances.set(t.id,s),s}}function Gp(e,t,n,s){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new Fp({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const z_=e=>{const{panel:t,measure:n,vizManager:s,data:i,variables:a}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={...Gp(c,i,s,a),viewport:{width:n.w,height:n.h}},d=l.viewRender;return r.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},E_=e=>{const{vizManager:t,panel:n,data:s,variables:i}=e,a=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...Gp(l,s,t,i)},u=a.configRender;return r.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},Wp=(e,t)=>{const n=Ut.bezier(e),s=Ut.bezier(t);return function(i){return i<50?n(i*2/100).hex():s((i-50)*2/100).hex()}},Js=e=>{const t=Ut.bezier(e);return function(n){return t(n/100).hex()}},A_={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:Wp(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},P_={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:Wp(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},O_={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:Js(["#fff7f1","darkred"]),name:"red",category:"sequential"},L_={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:Js(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},V_={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:Js(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},B_={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:Js(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class q_{constructor(t){N(this,"symbol");this.symbol=Symbol(t)}}function hn(e){return new q_(e)}class fo{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const t=new fo;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const s=n(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=v.get(t,"dispose");v.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const Rp="13.28.2",N_=Object.freeze(Object.defineProperty({__proto__:null,version:Rp},Symbol.toStringTag,{value:"Module"}));class $_{constructor(t){N(this,"staticColors",new Map);N(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class F_{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class G_{constructor(){N(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,s){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),a=v.orderBy(i,"version","asc");if(((l=v.last(a))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return a.reduce((c,u)=>u.handler(c,s),n)}}class Me extends G_{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(s,i)=>({version:t,...n(s,i)}))}async migrate({configData:t,panelModel:n}){const s=await t.getItem(null),i=v.get(s,"version",0),a=this.run({from:i,to:this.VERSION},s,{panelModel:n});await t.setItem(null,a)}async needMigration({configData:t}){const n=await t.getItem(null);return v.get(n,"version",0)<this.VERSION}}const Q=(e,t)=>{const[n,{setFalse:s}]=J.useBoolean(!0),[i,a]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{a(c),s()}),e.watchItem(t,c=>{a(c)})));const l=g.useCallback(async c=>{await e.setItem(t,c),a(c)},[e,t]);return{loading:n,value:i,set:l}},ut={top:16,right:16,bottom:16,left:16},Bt=e=>Math.max(0,e-ut.left-ut.right),qt=e=>Math.max(0,e-ut.top-ut.bottom),Jr=(e,t)=>({width:Bt(e),height:qt(t)}),dt=({width:e,height:t,children:n})=>r.jsx(o.Box,{pt:ut.top,pr:ut.right,pb:ut.bottom,pl:ut.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),go={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function W_({context:e}){const{value:t}=Q(e.instanceData,"config"),n=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:h}=v.defaults({},t,go),p=g.useMemo(()=>cs(n,a),[n,a]),{x:f,y:m,z:y}=g.useMemo(()=>({x:L(a),y:L(l),z:L(c)}),[a,l,c]),{min:_,max:k}=g.useMemo(()=>{const T=v.minBy(p,z=>z[y.columnKey]),I=v.maxBy(p,z=>z[y.columnKey]);return{min:v.get(T,y.columnKey),max:v.get(I,y.columnKey)}},[p,y]),S={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:_,max:k,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:h,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:p.map(T=>[T[f.columnKey],T[m.columnKey],T[y.columnKey]])}]};return t?r.jsx(dt,{width:s,height:i,children:r.jsx(Ke,{echarts:Ye,option:S,style:Jr(s,i),notMerge:!0,theme:"merico-light"})}):null}const U=D.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,queryID:a,clearable:l=!1,sx:c,...u},d)=>{const{panel:h}=Je(),p=g.useMemo(()=>h.dataFieldOptions(s,l,a),[s,l,a]);if(p.length===0){const f=h.explainDataKey(s);return r.jsxs(o.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Box,{children:r.jsx(o.TextInput,{label:e,required:t,defaultValue:f.columnKey,readOnly:!0,disabled:!0})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(o.Text,{size:"xs",color:f.queryName?"black":"red",sx:{fontFamily:"monospace"},children:f.queryName??f.queryID}),r.jsx(o.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),r.jsx(o.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:f.columnKey})]})})]})}return r.jsx(o.Select,{ref:d,label:e,description:n,data:p,value:s,onChange:i,required:t,sx:c,maxDropdownHeight:500,...u})}));function R_({context:e}){const{value:t,set:n}=Q(e.instanceData,"config"),s=v.defaults({},t,go),{control:i,handleSubmit:a,reset:l}=b.useForm({defaultValues:s});return g.useEffect(()=>{l(s)},[t]),t?r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(o.Text,{children:"X Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>r.jsx(U,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Y Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>r.jsx(U,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Z Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>r.jsx(U,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:r.jsxs(o.Button,{color:"blue",type:"submit",children:[r.jsx(W.DeviceFloppy,{size:20}),r.jsx(o.Text,{ml:"md",children:"Save"})]})})]})}):null}const Q_=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function U_(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(a),z_axis_data_key:s(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class Y_ extends Me{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:U_(i,s)}})}}const K_={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Y_,name:"bar-3d",viewRender:W_,configRender:R_,createConfig(){return{version:2,config:v.cloneDeep(go)}},translation:Q_},X_=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(o.Box,{sx:{position:"relative"},children:[e&&r.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(gt,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function pt({enabled:e,func_content:t}){return(n,s)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function nt(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
93
93
  `)}}const Nt=g.forwardRef(({value:e,onChange:t,triggerButtonText:n},s)=>{const{t:i}=j.useTranslation(),[a,{setTrue:l,setFalse:c}]=J.useBoolean(),[u,d]=g.useState(e);g.useEffect(()=>{d(e)},[e]);const h=k=>{d({...u,enabled:k})},p=()=>{c();const{enabled:k,func_content:S}=u,T={enabled:k,func_content:S};d(T),t(T)},f=()=>{c(),d(e)},m=k=>{d(S=>({...S,func_content:k}))},y=()=>{m(nt().func_content)},_=n??i("chart.axis.customize_label");return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"filled",color:"grape",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:_}),r.jsx(o.Modal,{size:800,title:_,opened:a,onClose:c,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&r.jsxs(o.Stack,{children:[r.jsx(o.Checkbox,{mt:10,label:i("common.enabled"),checked:u.enabled,onChange:k=>h(k.currentTarget.checked)}),r.jsx(X_,{value:u.func_content,onChange:m,disabled:!u.enabled}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:y,color:"red",leftIcon:r.jsx(W.Recycle,{size:20}),children:i("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:f,variant:"subtle",children:i("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:p,children:i("common.actions.save")})]})]})]})})]})}),$n={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1};function Qp(){return v.cloneDeep($n)}const J_=[{lang:"en",resources:{boxplot:{viz_name:"Boxplot Chart",box:"Box",outlier:"Outlier",scatter:"Scatter",click_series:{label:"Click box, scatter or outlier"}}}},{lang:"zh",resources:{boxplot:{viz_name:"箱线图",box:"箱体",outlier:"异常点",scatter:"散点",click_series:{label:"点击箱体、散点或异常点"}}}}],Up={id:"builtin:echarts:click-echart:series",displayName:"viz.boxplot.click_series.label",nameRender:H_,configRender:Z_,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'boxplot'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Record of 'name', 'min', 'q1', 'median', 'q3', 'max'",valueType:"object"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Z_(e){return r.jsx(r.Fragment,{})}function H_(e){const{t}=j.useTranslation();return r.jsx(o.Text,{children:t("viz.boxplot.click_series.label")})}const Zs=g.forwardRef(({sectionTitle:e,value:t,onChange:n},s)=>{const{t:i,i18n:a}=j.useTranslation(),l=u=>d=>{const h=v.cloneDeep(t);v.set(h,u,d),n(h)},c=g.useMemo(()=>[{label:i("chart.axis.overflow.truncate"),value:"truncate"},{label:i("chart.axis.overflow.break_line"),value:"break"},{label:i("chart.axis.overflow.break_word"),value:"breakAll"}],[a.language]);return r.jsxs(o.Stack,{spacing:0,children:[e&&r.jsx(o.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.NumberInput,{label:i("chart.axis.overflow.max_width"),hideControls:!0,value:t.width,onChange:l("width")}),r.jsx(o.Select,{label:i("chart.axis.overflow.label"),data:c,value:t.overflow,onChange:l("overflow")}),r.jsx(o.TextInput,{label:i("chart.axis.overflow.ellipsis"),value:t.ellipsis,disabled:!0})]})]})}),$t=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=j.useTranslation(),i=l=>{t({...e,on_axis:l})},a=l=>{t({...e,in_tooltip:l})};return r.jsxs(o.Stack,{ref:n,spacing:0,children:[r.jsx(Zs,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.on_axis,onChange:i}),r.jsx(Zs,{sectionTitle:s("chart.axis.overflow.section_title.in_tooltip"),value:e.in_tooltip,onChange:a})]})});function ht(){return{on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}}}function Dt({overflow:e,width:t}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],s=e==="truncate"?"nowrap":"initial",i={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
94
94
  max-width: ${t}px;
95
95
  word-break: ${n};
@@ -467,7 +467,7 @@ Check the top-level render call using <`+q+">.")}return A}}function $g(C,A){{if(
467
467
  <tbody>${f.join("")}</tbody>
468
468
  </table>
469
469
  `}})}function Pz(e,t,n){const{overflow:s,rotate:i}=e.x_axis.axisLabel,a=Mt(s.on_axis);return me.getXAxis({id:"main-x-axis",type:"category",data:t,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:i,...a,formatter:n},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:3})}function Oz(e,t){const{nameAlignment:n,data_key:s,...i}=e.y_axis,{overflow:a,rotate:l}=e.y_axis.axisLabel,c=Mt(a.on_axis);return me.getYAxis({...i,type:"category",axisLabel:{rotate:l,...c,formatter:t},axisLine:{show:!0,lineStyle:{width:3}},axisTick:{show:!0,alignWithLabel:!0},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameTextStyle:{fontWeight:"bold",align:n},nameLocation:"end",nameGap:15,z:3})}function Lz(e,t,n){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const s=n.reduce((_,k)=>{const S=nn(k,t);return _[k.name]=vt(k,S),_},{}),i=Tz(e),a=Dz(e),l=Us(e.visualMap,s),{min:c,max:u}=l,d=L(e.x_axis.data_key),h=L(e.y_axis.data_key),p=L(e.heat_block.data_key),f=v.uniq(t[d.queryID].map(_=>_[d.columnKey])),m=t[d.queryID].map(_=>{const k=v.get(_,d.columnKey),S=v.get(_,h.columnKey),T=v.get(_,p.columnKey),I={value:[k,S,T]},{followVisualMap:z,color:E}=oo(T,c,u,e.visualMap);return z||(I.visualMap=!1,I.itemStyle={color:E}),I});return{xAxis:Pz(e,f,i.x_axis),yAxis:Oz(e,i.y_axis),series:Iz(e,m),tooltip:Az(e,t,i,a),grid:Mz(e),visualMap:l}}function Vz({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=g.useMemo(()=>{const p=L(e.x_axis.data_key),f=L(e.y_axis.data_key);return v.keyBy(t[p.queryID],m=>`${m[p.columnKey]}---${m[f.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),c=_t(i.triggerManager,Uh.id),u=g.useCallback(p=>{const[f,m]=p.value,y=v.get(l,`${f}---${m}`,{error:"rowData is not found"});c.forEach(_=>{i.runInteraction(_.id,{...p,rowData:y})})},[l,c,i]),d=g.useMemo(()=>({click:u}),[u]),h=g.useMemo(()=>Lz(e,t,a),[e,t]);return r.jsx(Ke,{echarts:Ye,option:h,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function Bz({context:e,instance:t}){const n=jt({vizManager:e.vizManager,instance:t}),{value:s}=Q(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,Ho),[s]),l=e.data,{width:c,height:u}=e.viewport;return!c||!u?null:r.jsx(dt,{width:c,height:u,children:r.jsx(Vz,{variables:i,width:Bt(c),height:qt(u),data:l,conf:a,interactionManager:n})})}const qz=[{lang:"en",resources:{merico_heatmap:{viz_name:"Merico Heatmap",click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{merico_heatmap:{viz_name:"思码逸热力图",click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function Nz(e){const{visualMap:t=pn(),heat_block:{min:n,max:s,...i},...a}=e;return{...a,heat_block:i,visualMap:{...pn(),min:n,max:s}}}class $z extends Me{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:Nz(n.config)}))}}const Fz={displayName:"viz.merico_heatmap.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new $z,name:"merico-heatmap",viewRender:Bz,configRender:Cz,createConfig:()=>({version:2,config:Ho}),triggers:[Uh],translation:qz},Gz=[{value:"#25262B",name:"Dark"},{value:"#868E96",name:"Gray"},{value:"#FA5252",name:"Red"},{value:"#E64980",name:"Pink"},{value:"#BE4BDB",name:"Grape"},{value:"#7950F2",name:"Violet"},{value:"#4C6EF5",name:"Indigo"},{value:"#228BE6",name:"Blue"},{value:"#15AABF",name:"Cyan"},{value:"#12B886",name:"Teal"},{value:"#40C057",name:"Green"},{value:"#82C91E",name:"Lime"},{value:"#FAB005",name:"Yellow"},{value:"#FD7E14",name:"Orange"}].map(e=>({name:e.name,value:e.value,type:"single",category:"basic"})),Wz=[A_,P_,V_,L_,O_,B_],Yh=[Wo,W1,aM,MT,dD,Ck,kI,K_,Xw,YC,IS,WM,pk,MC,T1,Xk,CT,gM,iz,Fz,xz,o0],Kh=()=>({id:"dashboard",version:Rp,manifest:{viz:Yh,color:[...Gz,...Wz]}}),Hr=new F_,Oe={pluginManager:hn("pluginManager"),vizManager:hn("vizManager"),colorManager:hn("colorManager"),instanceScope:{panelModel:hn("panelModel"),vizInstance:hn("vizInstance"),interactionManager:hn("interactionManager"),migrator:hn("migrator"),operationManager:hn("operationManager"),triggerManager:hn("triggerManager")}},el=()=>{try{Hr.install(Kh())}catch{}const e=new I_(Hr),t=new $_(Hr);return{pluginManager:Hr,vizManager:e,colorManager:t}},rn=g.createContext(el());try{Hr.install(Kh())}catch{}const tl=g.createContext(null);function di(e){const t=g.useContext(tl),n=J.useCreation(()=>e.configure(t||new fo),[e.configure]),s=J.usePrevious(n);return s&&s!==n&&s.dispose(),r.jsx(tl.Provider,{value:n,children:e.children})}function Xh(){return g.useContext(tl)}const Rz=({description:e,isDescriptionEmpty:t})=>t?null:r.jsx(o.Tooltip,{color:"white",label:r.jsx(Kr,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:r.jsx(o.Box,{sx:{height:"16px",alignSelf:"center"},children:r.jsx(M.IconInfoCircle,{size:16,color:"gray"})})}),Qz=D.observer(({label:e,config:{default_value:t,description:n,isDescriptionEmpty:s,...i},value:a,onChange:l})=>r.jsxs(o.Box,{children:[r.jsx(o.Text,{children:" "}),r.jsx(o.Checkbox,{label:r.jsxs(o.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[r.jsx(o.Box,{sx:{flexGrow:1},children:e}),r.jsx(Rz,{description:n,isDescriptionEmpty:s})]}),checked:a||!1,onChange:c=>l(c.currentTarget.checked),...i,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),Uz=({value:e,onChange:t,close:n,max_days:s,allowSingleDateInRange:i})=>{const{i18n:a}=j.useTranslation(),[l,c]=e,u=g.useMemo(()=>l||new Date,[l]),d=g.useMemo(()=>{if(l&&!c)return l},[l,c]),h=g.useMemo(()=>{if(l&&!c&&s>0)return P(l).add(s-1,"days").toDate()},[l,c,s]),p=f=>{const[m,y]=f;t(f),m&&y&&n()};return r.jsx(mc.DatePicker,{defaultDate:u,numberOfColumns:2,type:"range",value:e,onChange:p,onNextMonth:console.log,minDate:d,maxDate:h,allowSingleDateInRange:i,locale:a.language})},Yz=({begin:e,end:t})=>{const{t:n}=j.useTranslation(),s=g.useMemo(()=>P(t).diff(P(e),"days")+1,[e,t]);if(Number.isNaN(s))return r.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const i=s===1?n("filter.widget.date_range.one_day"):n("filter.widget.date_range.x_days",{count:s});return r.jsx(o.Tooltip,{label:i,children:r.jsx(o.Badge,{size:"sm",children:s})})},Kz=({max_days:e})=>{const{t}=j.useTranslation();return e?r.jsxs(r.Fragment,{children:[r.jsx(o.Group,{position:"right",children:r.jsx(o.Badge,{size:"xs",children:t("filter.widget.date_range.x_max_days",{max_days:e})})}),r.jsx(o.Divider,{variant:"dashed",my:10})]}):null},nl=()=>[{key:"d",value:"yesterday",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"w",value:"last week",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"week").startOf("week").toDate(),P(e).subtract(1,"week").endOf("week").toDate()]}},{key:"m",value:"last month",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"month").startOf("month").toDate(),P(e).subtract(1,"month").endOf("month").toDate()]}},{key:"m2",value:"last 2 months",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(2,"month").startOf("month").toDate(),P(e).subtract(1,"month").endOf("month").toDate()]}},{key:"m3",value:"last 3 months",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(3,"month").startOf("month").toDate(),P(e).subtract(1,"month").endOf("month").toDate()]}},{key:"y",value:"last year",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"year").startOf("year").toDate(),P(e).subtract(1,"year").endOf("year").toDate()]}},{key:"d7",value:"recent 7 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(7,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d30",value:"recent 30 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(30,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d60",value:"recent 60 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(60,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d90",value:"recent 90 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(90,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d180",value:"recent 180 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(180,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d365",value:"recent 365 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(365,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d",value:"today",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("day").toDate(),P(e).endOf("day").toDate()]}},{key:"w",value:"this week",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("week").toDate(),P(e).endOf("week").toDate()]}},{key:"m",value:"this month",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("month").toDate(),P(e).endOf("month").toDate()]}},{key:"y",value:"this year",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("year").toDate(),P(e).endOf("year").toDate()]}},{key:"w",value:"this week so far",group:"this_so_far",getRange:()=>{const e=Date.now();return[P(e).startOf("week").toDate(),P(e).toDate()]}},{key:"m",value:"this month so far",group:"this_so_far",getRange:()=>{const e=Date.now();return[P(e).startOf("month").toDate(),P(e).toDate()]}},{key:"y",value:"this year so far",group:"this_so_far",getRange:()=>{const e=Date.now();return[P(e).startOf("year").toDate(),P(e).toDate()]}}];function Jh(e){const n=nl().find(s=>s.value===e);return n?n.getRange():null}const Xz=({onChange:e})=>{const{t,i18n:n}=j.useTranslation(),s=l=>()=>{const c=l();e(c)},i=g.useMemo(()=>v.groupBy(nl(),"group"),[]),a=n.language==="zh";return r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(o.Table,{withBorder:!1,sx:{"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:r.jsx("tbody",{children:Object.entries(i).map(([l,c])=>r.jsxs("tr",{children:[r.jsx("th",{children:r.jsx(o.Text,{size:"xs",color:"#555",children:t(`filter.widget.date_range.shortcut.${l}.label`)})}),c.map(({key:u,value:d,getRange:h})=>r.jsx("td",{children:r.jsx(o.Button,{compact:!0,size:"xs",variant:"subtle",onClick:s(h),children:t(`filter.widget.date_range.shortcut.${l}.${a?"full.":""}${u}`)})},u))]},l))})})]})},Zh=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),Jz=({label:e,required:t,value:n,onChange:s,max_days:i,allowSingleDateInRange:a,inputFormat:l})=>{const{t:c}=j.useTranslation(),[u,{open:d,close:h}]=Se.useDisclosure(!1),[p,f]=n,m=p?P(p).format(l):"",y=f?P(f).format(l):"";return r.jsxs(o.Popover,{opened:u,onClose:h,position:"bottom-start",shadow:"md",children:[r.jsxs(o.Group,{position:"left",grow:!0,noWrap:!0,spacing:0,w:"288px",sx:{marginTop:"3px"},children:[r.jsx(o.Popover.Target,{children:r.jsx(o.TextInput,{label:e,labelProps:{title:e},required:t,icon:r.jsx(M.IconCalendar,{size:16}),placeholder:c("filter.widget.date_range.start_date"),readOnly:!0,value:m,onFocus:d,styles:Zh(u),sx:{".mantine-TextInput-label":{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",width:"calc(240px)",position:"relative",zIndex:1},".mantine-Input-input":{borderRight:"none",borderTopRightRadius:0,borderBottomRightRadius:0}}})}),r.jsx(o.TextInput,{label:r.jsx(o.Group,{position:"right",children:r.jsx(Yz,{begin:p,end:f})}),icon:r.jsx(M.IconMinus,{size:16}),placeholder:c("filter.widget.date_range.end_date"),readOnly:!0,disabled:!p,value:y,onFocus:d,styles:Zh(u),sx:{".mantine-Input-icon":{transform:"translateX(-22px)"},".mantine-Input-input":{borderLeft:"none",borderTopLeftRadius:0,borderBottomLeftRadius:0},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to right, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})]}),r.jsxs(o.Popover.Dropdown,{p:"sm",children:[r.jsx(Kz,{max_days:i}),r.jsx(Uz,{value:n,onChange:s,close:h,allowSingleDateInRange:a,max_days:i}),r.jsx(Xz,{onChange:s})]})]})},Hh=D.observer(({label:e,config:t,value:n=[null,null],onChange:s})=>{const{inputFormat:i,required:a,max_days:l,allowSingleDateInRange:c}=t,u=Array.isArray(n)?n.map(h=>h?P(h).toDate():null):[null,null],d=h=>{s(h.map(p=>p&&P(p).format(i)))};return r.jsx(Jz,{label:e,value:u,onChange:d,inputFormat:i,allowSingleDateInRange:c,max_days:l,required:a})}),Zz=o.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-select.rc-select-open":{borderColor:"#228be6 !important",".rc-select-selection-overflow-item-rest":{display:"none"},".rc-select-selection-overflow-item-suffix":{display:"block"}},".rc-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-select-selection-search-mirror":{display:"none"},".rc-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,backgroundColor:"#fff",border:"1px solid #e9ecef",marginTop:6,padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px","&.rc-select-dropdown-slide-up-leave-active":{display:"none"},".rc-select-item-empty":{padding:"8px 12px"},".rc-select-item-option":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px 8px 2px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},flexDirection:"row-reverse",".rc-select-item-option-state":{flexGrow:0,flexShrink:0,width:"30px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},".rc-select-item-option-content":{width:"calc(100% - 30px)",overflow:"hidden",'div[data-role="label"]':{overflowWrap:"break-word"}}},".rc-virtual-list-holder-inner":{alignItems:"flex-start"}}})),rl=({errorMessage:e})=>{const{t}=j.useTranslation();return e?r.jsx(o.Text,{color:"red",size:12,children:e}):r.jsx(o.Text,{color:"dimmed",size:12,children:t("filter.widget.common.selector_option_empty")})},Hz=({disabled:e,classNames:t,styles:n,unstyled:s,radius:i,style:a,label:l,value:c,onChange:u,options:d,errorMessage:h,required:p})=>{const{t:f}=j.useTranslation(),{classes:m,cx:y}=Zz({radius:i},{name:"MultiSelectWidget",classNames:t,styles:n,unstyled:s}),[_,k]=g.useState(!1),S=R=>{k(R)},T=_&&(c==null?void 0:c.length)>0,[I,z]=g.useState(""),E=g.useMemo(()=>{if(!I)return d;const R=I.toLowerCase(),K=ye=>{var xe;return((xe=ye.description)==null?void 0:xe.toLowerCase().includes(R))||ye.label.toLowerCase().includes(R)};return d.filter(K)},[I,d]);return r.jsxs(o.Stack,{spacing:3,children:[r.jsxs(o.Group,{position:"apart",children:[r.jsxs(o.Text,{className:m.label,children:[l,p&&r.jsx("span",{className:m.required,"aria-hidden":"true",children:"*"})]}),T&&r.jsx(o.Tooltip,{label:f("filter.widget.common.x_selected",{count:c.length}),children:r.jsx(o.Badge,{children:c.length})})]}),r.jsx(bc,{disabled:e,allowClear:!0,className:y(m.root,"check-select"),dropdownClassName:y(m.dropdown,""),onDropdownVisibleChange:S,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:a,clearIcon:()=>r.jsx(o.CloseButton,{}),value:c,onChange:u,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:r.jsx(rl,{errorMessage:h}),maxTagTextLength:10,maxTagPlaceholder:R=>f("filter.widget.common.x_selected",{count:R.length}),searchValue:I,onSearch:z,filterOption:!1,children:E.map(R=>r.jsxs(bc.Option,{title:R.label,children:[r.jsx(o.Text,{size:"sm","data-role":"label",children:R.label}),R.description&&r.jsx(o.Text,{size:"xs",color:"dimmed","data-role":"description",children:R.description})]},R.value))})]})},eE=D.observer(({label:e,config:t,value:n,onChange:s})=>{const i=Pe(),a=!!t.options_query_id,{state:l,error:c}=i.getDataStuffByID(t.options_query_id),u=l==="loading",d=t.min_width?t.min_width:"200px",h=a?u:!1,p=g.useMemo(()=>t.initialSelection(n),[n,t.initialSelection]),f=m=>s(m,!1);return r.jsx(Hz,{label:e,options:t.options,style:{minWidth:"160px",width:d,maxWidth:h?d:"unset",borderColor:"#e9ecef"},disabled:h,value:[...p],onChange:f,errorMessage:c,required:t.required})}),tE=g.forwardRef(({label:e,description:t,...n},s)=>r.jsx("div",{ref:s,...n,children:r.jsx(o.Group,{noWrap:!0,children:r.jsxs("div",{children:[r.jsx(o.Text,{size:"sm","data-role":"label",children:e}),r.jsx(o.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),nE=D.observer(({label:e,config:t,value:n,onChange:s})=>{const i=Pe(),a=!!t.options_query_id,{state:l,error:c}=i.getDataStuffByID(t.options_query_id),u=l==="loading";return r.jsx(o.Select,{label:e,data:t.options,disabled:a?u:!1,value:n,onChange:s,maxDropdownHeight:500,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"},".mantine-Select-nothingFound":{fontSize:"0.75rem",textAlign:"left",padding:"4px 10px"}},itemComponent:tE,searchable:!c,nothingFound:r.jsx(rl,{errorMessage:c}),clearable:t.clearable})});function rE({label:e,config:t,value:n,onChange:s}){return r.jsx(o.TextInput,{label:e,value:n||"",onChange:i=>s(i.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const sE=({rotate:e,onClick:t})=>r.jsx("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:r.jsx("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),iE=({expanded:e,isLeaf:t,value:n,onClick:s,...i})=>(n==="0-0-value"&&console.log(i),t?r.jsx("span",{style:{width:"14px",display:"inline-block"}}):r.jsx(sE,{rotate:e?"0":"-90",onClick:s,...i})),aE=({onClick:e})=>r.jsxs("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),r.jsx("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),r.jsx("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),r.jsx("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),oE=({onClick:e,...t})=>r.jsx(aE,{onClick:e,...t}),lE=o.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),cE=({disabled:e,classNames:t,styles:n,unstyled:s,radius:i,style:a,label:l,value:c,onChange:u,treeData:d,errorMessage:h,required:p,treeCheckStrictly:f})=>{const{t:m}=j.useTranslation(),{classes:y,cx:_}=lE({radius:i},{name:"FilterTreeSelectWidget",classNames:t,styles:n,unstyled:s}),[k,S]=g.useState(!1),T=z=>{S(z)},I=k&&(c==null?void 0:c.length)>0;return r.jsxs(o.Stack,{spacing:3,children:[r.jsxs(o.Group,{position:"apart",children:[r.jsxs(o.Text,{className:y.label,children:[l,p&&r.jsx("span",{className:y.required,"aria-hidden":"true",children:"*"})]}),I&&r.jsx(o.Tooltip,{label:m("filter.widget.common.x_selected",{count:c.length}),children:r.jsx(o.Badge,{children:c.length})})]}),r.jsx(vc,{disabled:e,allowClear:!0,treeCheckStrictly:f,labelInValue:!0,className:_(y.root,"check-select"),dropdownClassName:_(y.dropdown,""),onDropdownVisibleChange:T,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:a,listHeight:510,treeLine:!0,clearIcon:()=>r.jsx(o.CloseButton,{}),switcherIcon:iE,treeIcon:oE,maxTagTextLength:10,value:c,treeData:d,notFoundContent:r.jsx(rl,{errorMessage:h}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:vc.SHOW_PARENT,onChange:u,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:()=>m("filter.widget.common.x_selected",{count:c.length})})]})},uE=D.observer(({label:e,config:t,value:n,onChange:s})=>{const{treeData:i,treeDataLoading:a,errorMessage:l}=t,c=f=>{const m=f.map(y=>y.value);s(m,!1)},u=g.useMemo(()=>t.initialSelection(n),[n,t.initialSelection]),d=t.min_width?t.min_width:"200px",p=!!t.options_query_id?a:!1;return r.jsx(cE,{disabled:p,style:{minWidth:"160px",width:d,maxWidth:p?d:"unset",borderColor:"#e9ecef"},value:[...u],onChange:c,treeData:i,errorMessage:l,label:e,required:t.required,treeCheckStrictly:t.treeCheckStrictly})}),dE=D.observer(({filter:{type:e,config:t,key:n,...s},formFieldProps:i})=>{switch(e){case"select":return r.jsx(nE,{...s,...i,config:t});case"multi-select":return r.jsx(eE,{...s,...i,config:t});case"tree-select":return r.jsx(uE,{...s,...i,config:t});case"text-input":return r.jsx(rE,{...s,...i,config:t});case"date-range":return r.jsx(Hh,{...s,...i,config:t});case"checkbox":return r.jsx(Qz,{...s,...i,config:t});default:return null}}),pE=D.observer(g.forwardRef(({filter:e,...t},n)=>r.jsx("div",{className:"filter-root",ref:n,children:r.jsx(Re,{children:r.jsx(dE,{filter:e,formFieldProps:t})})}))),hE=({disabled:e})=>{const{searchButtonProps:t}=Su(),{children:n="Search",type:s,...i}=t;return r.jsx(o.Button,{color:"blue",size:"sm",type:"submit",...i,disabled:e||i.disabled,children:n})};function fE(e){const t=re();g.useEffect(()=>{var n,s;(s=(n=t.filters).updatePreviewValues)==null||s.call(n,e)},[e])}const gE=({opened:e,toggle:t})=>{const{t:n}=j.useTranslation();return r.jsx(o.Group,{position:"right",ml:-4,mt:-4,mb:e?4:0,children:r.jsx(o.Button,{size:"xs",compact:!0,variant:"subtle",color:e?"gray":"blue",leftIcon:e?r.jsx(M.IconChevronsUp,{size:14}):r.jsx(M.IconChevronsDown,{size:14}),onClick:t,children:n(e?"filter.hide_filters":"filter.show_filters")})})},ef=D.observer(function({view:t}){const[n,{toggle:s}]=Se.useDisclosure(!0),i=Pe(),{control:a,handleSubmit:l,reset:c}=b.useForm({defaultValues:i.filters.values,reValidateMode:"onBlur"}),u=b.useWatch({control:a});g.useEffect(()=>{c(i.filters.values)},[i.filters.values,c]),fE(u);const d=i.filters.visibleInView(t.id),h=g.useMemo(()=>d.every(y=>y.should_auto_submit),[d]),p=g.useMemo(()=>d.filter(y=>v.get(y,"config.required",!1)),[d]),f=g.useMemo(()=>p.length===0?!1:p.some(y=>!y.requiredAndPass(u[y.key])),[u,p]);if(d.length===0)return null;const m=(y,_)=>(k,S)=>{_(k),(y.should_auto_submit||S)&&i.filters.setValueByKey(y.key,k)};return r.jsxs("form",{onSubmit:l(i.filters.setValues),children:[r.jsx(gE,{opened:n,toggle:s}),r.jsx(o.Collapse,{in:n,children:r.jsxs(o.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:h?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[r.jsx(o.Group,{align:"flex-start",children:d.map(y=>r.jsx(b.Controller,{name:y.key,control:a,render:({field:_})=>r.jsx(pE,{filter:y,value:_.value,onChange:m(y,_.onChange)})},y.id))}),!h&&r.jsx(o.Group,{sx:{alignSelf:"flex-end"},children:r.jsx(hE,{disabled:f})})]})})]})}),mE={viewPanelInFullScreen:v.noop,inFullScreen:!1},pi=g.createContext(mE),sl=x.types.model("MockContextMeta",{current:x.types.optional(x.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get keySet(){return new Set(this.keys)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},defaults(t){e.current={...t,...e.current}},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function il(e){return{current:e}}const xE=x.types.model("PanelStyleBorderMeta",{enabled:x.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),tf=x.types.model("PanelStyleMeta",{border:xE}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),nf=x.types.model("PanelTitleMeta",{show:x.types.optional(x.types.boolean,!0)}).views(e=>({get json(){const{show:t}=e;return{show:t}}})).actions(e=>({setShow(t){e.show=t}})),rf=x.types.model("VariableMeta",{name:x.types.string,size:x.types.string,weight:x.types.string,color:x.types.union(x.types.model({type:x.types.literal("static"),staticColor:x.types.string}),x.types.model({type:x.types.literal("continuous"),valueRange:x.types.array(x.types.number),colorRange:x.types.array(x.types.string)}),x.types.model({type:x.types.literal("piecewise")})),formatter:x.types.model({output:x.types.enumeration("Output",["number","percent"]),average:x.types.optional(x.types.boolean,!1),mantissa:x.types.number,trimMantissa:x.types.optional(x.types.boolean,!1),absolute:x.types.optional(x.types.boolean,!1)}),data_field:x.types.string,aggregation:x.types.union(x.types.model({type:x.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:x.types.frozen(),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("quantile"),config:x.types.model({p:x.types.number}),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("pick_record"),config:x.types.model({method:x.types.enumeration("Pick Record Method",["first","last"])}),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("custom"),config:x.types.model({func:x.types.string}),fallback:x.types.optional(x.types.string,"0")}))}).views(e=>({get json(){const{name:t,size:n,weight:s,color:i,formatter:a,data_field:l,aggregation:c}=e;return v.cloneDeep({name:t,size:n,color:i,weight:s,formatter:a,data_field:l,aggregation:c})}})),sf=x.types.model("PanelVizMeta",{type:x.types.string,conf:x.types.frozen()}).views(e=>({get json(){return{conf:e.conf,type:e.type}}})).actions(e=>({setType(t){e.type=t},setConf(t){e.conf=t}})),af=x.types.model({id:x.types.string,name:x.types.optional(x.types.string,""),title:nf,description:x.types.string,queryIDs:x.types.array(x.types.string),viz:sf,style:tf,variables:x.types.optional(x.types.array(rf),[])}).views(e=>({get json(){const{id:t,name:n,title:s,description:i,queryIDs:a}=e;return{id:t,viz:e.viz.json,name:n,style:e.style.json,title:s.json,queryIDs:[...a],variables:e.variables.map(l=>l.json),description:i}},get queryIDSet(){return new Set(e.queryIDs)}})).actions(e=>({setID(t){e.id=t},setName(t){e.name=t},setDescription(t){e.description=t},addQueryID(t){e.queryIDSet.has(t)||e.queryIDs.push(t)},removeQueryID(t){if(!e.queryIDSet.has(t))return;const n=new Set(e.queryIDSet);n.delete(t),e.queryIDs=x.cast(Array.from(n))},setQueryIDs(t){e.queryIDs=x.cast(t)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)}}));var Ee=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e.Transform="transform",e))(Ee||{});const of=x.types.model("QueryMeta",{id:x.types.string,name:x.types.string,type:x.types.enumeration("DataSourceType",[Ee.Postgresql,Ee.MySQL,Ee.HTTP,Ee.Transform]),key:x.types.string,sql:x.types.string,pre_process:x.types.optional(x.types.string,""),post_process:x.types.optional(x.types.string,""),run_by:x.types.optional(x.types.array(x.types.string),[]),react_to:x.types.optional(x.types.array(x.types.string),[]),dep_query_ids:x.types.optional(x.types.array(x.types.string),[])}).views(e=>({get valid(){return e.id&&e.type&&e.key&&e.name?e.type===Ee.HTTP?!!e.pre_process:!!e.sql:!1},get json(){const{id:t,name:n,type:s,key:i,sql:a,run_by:l,react_to:c,pre_process:u,post_process:d,dep_query_ids:h}=e;return cr({id:t,key:i,sql:a,name:n,type:s,run_by:l,react_to:c,pre_process:u,post_process:d,dep_query_ids:h})}})).actions(e=>({setName(t){e.name=t},setKey(t){e.key=t},setType(t){e.type=t},setSQL(t){e.sql=t},setRunBy(t){e.run_by.length=0,e.run_by.push(...t)},setReactTo(t){e.react_to.length=0,e.react_to.push(...t)},setPreProcess(t){e.pre_process=t},setPostProcess(t){e.post_process=t},setDependantQueryIDs(t){e.dep_query_ids.length=0,e.dep_query_ids.push(...t)}})),lf=x.types.model("LayoutItemMeta",{id:x.types.identifier,panelID:x.types.string,x:x.types.number,y:x.types.maybeNull(x.types.number),w:x.types.number,h:x.types.number,moved:x.types.optional(x.types.boolean,!1),static:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{id:t,panelID:n,x:s,y:i,w:a,h:l,moved:c}=e;return{h:l,w:a,x:s,y:i===null?0:i,id:t,moved:c,static:e.static,panelID:n}},get contentModel(){return x.getRoot(e).content},get panel(){const{panelID:t}=e;return this.contentModel.panels.findByID(t)},get layoutProperies(){const{id:t,x:n,y:s,w:i,h:a,moved:l}=e;return{id:t,i:t,x:n,y:s===null?1/0:s,w:i,h:a,moved:l,static:e.static}}})).actions(e=>({set(t){const{isDraggable:n,x:s,y:i,w:a,h:l,moved:c}=t;e.x=s,e.y=i,e.w=a,e.h=l,e.moved=!!c,e.static=!!t.static},setWidth(t){e.w=t},setHeight(t){e.h=t}})),cf=x.types.model("LayoutSetMeta",{id:x.types.identifier,name:x.types.string,breakpoint:x.types.number,list:x.types.optional(x.types.array(lf),[])}).views(e=>({get contentModel(){return x.getRoot(e).content},get json(){const{id:t,name:n,breakpoint:s,list:i}=e;return{id:t,name:n,breakpoint:s,list:i.map(a=>cr(a.json))}},jsonByPanelIDSet(t){const{id:n,name:s,breakpoint:i,list:a}=e;return{id:n,name:s,breakpoint:i,list:a.filter(l=>t.has(l.panelID)).map(l=>cr(l.json))}},findByID(t){return e.list.find(n=>n.id===t)},findByPanelID(t){return e.list.find(n=>n.panelID===t)}})).actions(e=>({setName(t){e.name=t},setBreakpoint(t){e.breakpoint=t},addLayout(t){e.list.push(t)},addNewLayout(t){e.list.push({id:on.v4(),panelID:t,x:0,y:1/0,w:18,h:300,static:!1,moved:!1})},removeByPanelID(t){const n=e.list.findIndex(s=>s.panelID===t);n>=0&&e.list.splice(n,1)},updateLayoutItem(t){const n=e.list.find(s=>s.id===t.i);if(!n){console.error("Trying to update a layout that doesn't exist"),console.log({strangeLayoutItem:t});return}n.set(t)}})).actions(e=>({afterCreate(){x.addDisposer(e,ae.reaction(()=>{const t=e.list.length,n=e.contentModel.panels.list.length;return{match:t===n,layoutCount:t,panelCount:n}},({match:t,panelCount:n,layoutCount:s})=>{if(t)return;const i={id:"layout panel count mismatch",title:"Error detected, please don't save changes.",message:`${s} layout items against and ${n} panels.`,color:"red",autoClose:!1};Yt.showNotification(i),Yt.updateNotification(i)},{fireImmediately:!0,delay:0}))}})),uf=x.types.model("SQLSnippetMeta",{key:x.types.string,value:x.types.string}).views(e=>({get json(){const{key:t,value:n}=e;return{key:t,value:n}}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.value=t}}));var Ce=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(Ce||{});const al=x.types.model("FilterCheckboxConfigMeta",{_name:x.types.literal("checkbox"),description:x.types.optional(x.types.string,""),default_value:x.types.boolean}).views(e=>({get json(){const{_name:t,description:n,default_value:s}=e;return{_name:t,description:n,default_value:s}},get isDescriptionEmpty(){const{description:t}=e;return t===""||t==="<p></p>"}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDescription(t){e.description=t}})),df=()=>al.create({_name:"checkbox",description:"",default_value:!1});function pf(e,t){return e.map(n=>{try{return n?P.tz(n,"UTC").format(t):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}const yE=x.types.model("FilterDateRangeConfigMeta",{_name:x.types.literal("date-range"),required:x.types.boolean,inputFormat:x.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:x.types.optional(x.types.array(x.types.union(x.types.string,x.types.null)),[null,null]),default_shortcut:x.types.optional(x.types.string,""),clearable:x.types.boolean,max_days:x.types.optional(x.types.number,0),allowSingleDateInRange:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{_name:t,max_days:n,required:s,clearable:i,inputFormat:a,default_value:l,default_shortcut:c,allowSingleDateInRange:u}=e;return{_name:t,max_days:n,required:s,clearable:i,inputFormat:a,default_value:pf(l,a),default_shortcut:c,allowSingleDateInRange:u}},truthy(t){return Array.isArray(t)&&t.length===2&&t.every(n=>!!n)},get filter(){return x.getParent(e)}})).actions(e=>({setFilterValue(t){try{e.filter.setValue(t)}catch(n){console.error(n)}}})).actions(e=>({setRequired(t){e.required=t},setClearable(t){e.clearable=t},setInputFormat(t){e.inputFormat=t},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t),e.setFilterValue(t)},setDefaultShortcut(t){if(e.default_shortcut=t,!t)return;const n=Jh(e.default_shortcut);if(console.log(n),n){const s=n.map(i=>P(i).format(e.inputFormat));e.setFilterValue(s)}},setMaxDays(t){e.max_days=t,t>0&&(e.clearable=!0)},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),ol=x.types.snapshotProcessor(yE,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>n===null?null:P.tz(n,"UTC").toISOString())}},postProcessor(e){const{default_value:t,...n}=e;return{...n,default_value:pf(t,n.inputFormat)}}}),hf=()=>ol.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),bE=x.types.model({label:x.types.string,value:x.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),ll=x.types.model("FilterConfigModel_BaseSelect",{static_options:x.types.optional(x.types.array(bE),[]),options_query_id:x.types.optional(x.types.string,""),default_selection_count:x.types.optional(x.types.number,0),required:x.types.optional(x.types.boolean,!1)}).views(e=>({get contentModel(){return x.getRoot(e).content},get filter(){return x.getParent(e)},get usingQuery(){return!!e.options_query_id}})).views(e=>({get optionsLoading(){if(!e.usingQuery)return!1;const{state:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t==="loading"},get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:n}=e.contentModel.getDataStuffByID(e.options_query_id);return n==="error"?[]:Array.isArray(t)?t.filter(s=>"label"in s&&"value"in s):[]}})).actions(e=>({setRequired(t){e.required=t},addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},setDefaultSelectionCount(t){e.default_selection_count=t},setOptionsQueryID(t){e.options_query_id=t??""}})),cl=x.types.compose("FilterMultiSelectConfigMeta",x.types.model({_name:x.types.literal("multi-select"),min_width:x.types.optional(x.types.string,""),default_value:x.types.optional(x.types.array(x.types.string),[])}),ll).views(e=>({get json(){const{_name:t,default_value:n,required:s,min_width:i,static_options:a,options_query_id:l,default_selection_count:c}=e;return cr({_name:t,required:!!s,min_width:i,default_value:n,static_options:a,options_query_id:l,default_selection_count:c})},get defaultSelection(){const t=e.filter.formattedDefaultValue;return Array.isArray(t)&&t.length>0||!e.usingQuery?t:e.options.slice(0,e.default_selection_count).map(n=>n.value)},initialSelection(t){return t||this.defaultSelection},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=x.cast(t)},setMinWidth(t){e.min_width=t},setDefaultSelection(){if(e.optionsLoading)return;const t=new Set(e.options.map(i=>i.value)),s=(e.filter.value??[]).filter(i=>t.has(i));s.length>0?e.filter.setValue(s):e.filter.setValue(e.defaultSelection)}})).actions(e=>({afterCreate(){x.addDisposer(e,ae.reaction(()=>ae.toJS(e.defaultSelection),e.setDefaultSelection,{fireImmediately:!1,delay:0}))}})),ff=()=>cl.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),ul=x.types.compose("FilterConfigModel_Select",x.types.model({_name:x.types.literal("select"),default_value:x.types.string,width:x.types.optional(x.types.string,""),clearable:x.types.optional(x.types.boolean,!1)}),ll).views(e=>({get json(){const{_name:t,clearable:n,default_value:s,required:i,width:a,static_options:l,options_query_id:c,default_selection_count:u}=e;return cr({_name:t,width:a,required:i,clearable:n,default_value:s,static_options:l,options_query_id:c,default_selection_count:u})},truthy(t){return!!t},getSelectOption(t){return e.options.find(n=>n.value===t)},get default_selection(){return e.usingQuery?e.default_selection_count>0&&e.options.length>0?e.options[0].value:"":e.filter.formattedDefaultValue}})).actions(e=>({setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t},setClearable(t){e.clearable=t},setDefaultSelection(){var s;const t=e.filter.value,n=(s=e.options.find(i=>i.value===t))==null?void 0:s.value;n?e.filter.setValue(n):e.filter.setValue(e.default_selection)}})).actions(e=>({afterCreate(){x.addDisposer(e,ae.reaction(()=>ae.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!1,delay:0}))}})),gf=()=>ul.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),dl=x.types.model("FilterTextInputConfigMeta",{_name:x.types.literal("text-input"),required:x.types.boolean,default_value:x.types.string}).views(e=>({get json(){const{_name:t,required:n,default_value:s}=e;return{_name:t,required:n,default_value:s}},truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),pl=()=>dl.create({_name:"text-input",required:!1,default_value:""});function vE(e){return Hg.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function _E(e){return e.map(t=>{const{label:n,description:s,...i}=t,a={...i,filterBasis:`${n}___${s??""}`,description:s,label:n};return s&&(a.label=g.createElement("div",{},[g.createElement(o.Text,{key:0,title:t.label},t.label),g.createElement(o.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description},t.description)])),a})}const hl=x.types.compose("FilterTreeSelectConfigMeta",x.types.model({_name:x.types.literal("tree-select"),min_width:x.types.optional(x.types.string,""),default_value:x.types.optional(x.types.array(x.types.string),[]),treeCheckStrictly:x.types.optional(x.types.boolean,!1)}),ll).views(e=>({get json(){const{_name:t,default_value:n,required:s,min_width:i,static_options:a,options_query_id:l,default_selection_count:c,treeCheckStrictly:u}=e;return{_name:t,required:!!s,min_width:i,default_value:n,static_options:a,options_query_id:l,treeCheckStrictly:u,default_selection_count:c}},get plainData(){const{data:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeData(){const t=this.plainData,n=_E(t);return vE(n)},get errorMessage(){const{error:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeDataLoading(){const{state:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t==="loading"},get defaultSelection(){const t=e.filter.formattedDefaultValue;if(Array.isArray(t)&&t.length>0)return t;const{default_selection_count:n}=e;return n?this.treeData.slice(0,n).map(i=>i.value):[]},valueObjects(t){const n=new Set(t);return this.plainData.filter(s=>n.has(s.value))},initialSelection(t){return t?this.valueObjects(t):this.valueObjects(this.defaultSelection)},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=x.cast(t)},setMinWidth(t){e.min_width=t},setTreeCheckStrictly(t){e.treeCheckStrictly=t},applyDefaultSelection(){const t=e.filter.value,n=new Set(e.plainData.map(i=>i.value)),s=(t??[]).filter(i=>n.has(i));s.length>0?e.filter.setValue(s):e.filter.setValue(e.defaultSelection)},afterCreate(){x.addDisposer(e,ae.reaction(()=>JSON.stringify(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!0,delay:0}))}})),mf=()=>hl.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),fl=x.types.model("FilterMeta",{id:x.types.identifier,key:x.types.string,label:x.types.string,order:x.types.number,visibleInViewsIDs:x.types.array(x.types.string),auto_submit:x.types.optional(x.types.boolean,!1),default_value_func:x.types.optional(x.types.string,""),type:x.types.enumeration("DashboardFilterType",[Ce.Select,Ce.MultiSelect,Ce.TreeSelect,Ce.TextInput,Ce.Checkbox,Ce.DateRange]),config:x.types.union(ul,cl,hl,dl,al,ol)}).views(e=>({get contentModel(){return x.getRoot(e).content},get filters(){return this.contentModel.filters},get value(){return this.filters.values[e.key]},get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==Ce.TreeSelect},get usingDefaultValueFunc(){return!!e.default_value_func},get formattedDefaultValue(){return this.filters.formattedDefaultValues[e.key]},get auto_submit_supported(){return[Ce.Select,Ce.Checkbox,Ce.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:n,label:s,order:i,visibleInViewsIDs:a,default_value_func:l,auto_submit:c,type:u,config:d}=e;return{id:t,key:n,type:u,label:s,order:i,config:d.json,auto_submit:c,visibleInViewsIDs:ae.toJS(a),default_value_func:l}},get visibleInViewsIDSet(){return new Set(e.visibleInViewsIDs)},get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return v.get(e.config,"required",!1)?v.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.filters.setValueByKey(e.key,t)},setLabel(t){e.label=t},setOrder(t){e.order=t},setType(t){switch(t){case Ce.Select:e.config=gf();break;case Ce.MultiSelect:e.config=ff();break;case Ce.TreeSelect:e.config=mf();break;case Ce.TextInput:e.config=pl();break;case Ce.Checkbox:e.config=df();break;case Ce.DateRange:e.config=hf();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t},setDefaultValueFunc(t){e.default_value_func=t}}));var G=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(G||{});const gl=x.types.model("ViewDivisionConfig",{_name:x.types.literal(G.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})),xf=()=>gl.create({_name:G.Division}),jE=x.types.model("CustomModalTitleModel",{enabled:x.types.optional(x.types.boolean,!1),func_content:x.types.optional(x.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:n}=e;return{enabled:t,func_content:n}},get value(){const{enabled:t,func_content:n}=e,s=x.getParent(e,2),i=x.getRoot(e);if(!t)return s.name;try{const a={filters:i.content.filters.values,context:i.context.current};return new Function(`return ${n}`)()(a)}catch(a){return console.error(a),s.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:n}){e.enabled=t,e.func_content=n}})),hi={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
470
- `)},ml=x.types.model("ViewModalConfig",{_name:x.types.literal(G.Modal),width:x.types.string,height:x.types.string,custom_modal_title:x.types.optional(jE,hi)}).views(e=>({get json(){const{_name:t,width:n,height:s,custom_modal_title:i}=e;return{_name:t,width:n,height:s,custom_modal_title:i.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),yf=()=>ml.create({_name:G.Modal,width:"90vw",height:"90vh"}),wE=x.types.model("ViewTabsTabModel",{id:x.types.identifier,name:x.types.string,view_id:x.types.string,color:x.types.optional(x.types.string,""),order:x.types.optional(x.types.number,0)}).views(e=>({get json(){const{id:t,name:n,view_id:s,color:i,order:a}=e;return{id:t,name:n,color:i,order:a,view_id:s}}})).actions(e=>({setName(t){e.name=t},setViewID(t){e.view_id=t},setColor(t){e.color=t},setOrder(t){e.order=t}})),xl=x.types.model("ViewTabsConfig",{_name:x.types.literal(G.Modal),tabs:x.types.optional(x.types.array(wE),[]),variant:x.types.optional(x.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:x.types.optional(x.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:n,orientation:s,tabs:i,grow:a}=e;return{grow:a,tabs:i.map(l=>l.json),_name:t,variant:n,orientation:s}},get tabsInOrder(){return v.sortBy(e.tabs,"order")}})).actions(e=>({setVariant(t){e.variant=t},setOrientation(t){e.orientation=t},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=x.cast(t)},addTab(){const t=Se.randomId(),n={id:t,name:t,view_id:""};e.tabs.push(n)},removeTab(t){e.tabs.splice(t,1)}})),bf=()=>xl.create({_name:G.Modal,tabs:[]}),vf=x.types.model({id:x.types.identifier,name:x.types.string,type:x.types.enumeration("EViewComponentType",[G.Division,G.Modal,G.Tabs]),config:x.types.union(gl,ml,xl),panelIDs:x.types.optional(x.types.array(x.types.string),[])}).views(e=>({get json(){const{id:t,name:n,type:s,config:i}=e;return{id:t,name:n,type:s,config:i.json,panelIDs:e.panelIDs.map(a=>a)}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case G.Division:e.config=xf();break;case G.Modal:e.config=yf();break;case G.Tabs:e.config=bf();break}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},appendPanelIDs(t){e.panelIDs.push(...t)},removePanelID(t){const n=e.panelIDs.filter(s=>s!==t);e.panelIDs.length=0,e.panelIDs.push(...n)}})),gn="11.10.0",CE={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:G.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:gn,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},yl=x.types.model("DataSourceMetaModel",{id:x.types.string,type:x.types.enumeration("DataSourceType",[Ee.HTTP,Ee.MySQL,Ee.Postgresql]),key:x.types.string,config:x.types.frozen()}),_f=x.types.model("DataSourcesMetaModel",{list:x.types.optional(x.types.array(yl),[])}).views(e=>({find({type:t,key:n}){return e.list.find(s=>s.key===n&&s.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),jf=x.types.model({id:x.types.string,content:x.types.string,create_time:x.types.string,update_time:x.types.string,is_preset:x.types.boolean}),bl=x.types.model("GlobalSQLSnippetsMeta",{list:x.types.optional(x.types.array(jf),[])}).views(e=>({find(t){return e.list.find(n=>n.id===t)},get options(){return e.list.map(t=>({value:t.id,label:t.id}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),fi=x.types.model("ContextMeta",{current:x.types.optional(x.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function vl(e){return fi.create({current:e})}const _l=x.types.compose("ViewRenderModel",vf,x.types.model({tab:x.types.optional(x.types.string,"")})).views(e=>({get tabs(){return e.config.tabs},get tabInfo(){const t=this.tabs.find(n=>n.id===e.tab);return t?{id:t.id,name:t.name}:null},get tabView(){return e.type!==G.Tabs?null:this.tabs.find(t=>t.id===e.tab)},get tabViewID(){return this.tabView?this.tabView.view_id??"":""},get contentModel(){return x.getParent(e,3)},get panels(){if(e.type!==G.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs);const t=this.tabViewID,n=this.contentModel.views.findByID(t);return(n==null?void 0:n.panels)??[]},get renderViewIDs(){const t=[e.id];return e.type===G.Tabs&&t.push(this.tabViewID),t},async downloadScreenshot(t){const n=t.offsetWidth*2+10,s=t.offsetHeight*2+10,i=new jc,a=new Date().getTime(),l=await _c.toBlob(t,{bgcolor:"white",width:n,height:s,style:{transformOrigin:"0 0",transform:"scale(2)"}});i.file(`${e.name}_${a}.png`,l),i.file(`dashboard_state_${a}.json`,JSON.stringify(this.contentModel.dashboardState,null,4)),i.generateAsync({type:"blob"}).then(c=>{os.saveAs(c,`${e.name}_${a}.zip`)}).catch(c=>{console.error(c),Yt.notifications.show({color:"red",title:"Failed to download screenshot with dashboard state",message:c.message})})}})).actions(e=>({setTab(t){e.tab=t??""},setTabByTabInfo(t){e.tab=t.id??""}})),jl=x.types.model("ViewsRenderModel",{current:x.types.optional(x.types.array(_l),[]),visibleViewIDs:x.types.array(x.types.string)}).views(e=>({get json(){return e.current.map(t=>cr(t.json))},get idMap(){const t=new Map;return e.current.forEach(n=>{t.set(n.id,n)}),t},findByID(t){return e.current.find(n=>n.id===t)},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:n})=>n===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:n})=>t.has(n))},get firstVisibleTabsView(){return this.visibleViews.find(t=>t.type===G.Tabs)},get firstVisibleTabsViewActiveTab(){const t=this.firstVisibleTabsView;return t?t.tabInfo:null}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(s=>s)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const n=e.visibleViewIDs.findIndex(s=>s===t);n!==-1&&e.visibleViewIDs.splice(n,1)},setFirstVisibleTabsViewActiveTab(t){if(!t)return;const n=e.firstVisibleTabsView;n==null||n.setTabByTabInfo(t)}}));function wf(e,t){const n=e.length>0?[e[0].id]:[],s=e.map(i=>{const{_name:a=i.type}=i.config,l={...i,tab:"",config:{...i.config,_name:a},panelIDs:i.panelIDs};if(i.type===G.Tabs){const c=v.minBy(i.config.tabs,u=>u.order);l.tab=(c==null?void 0:c.id)??""}return l});return t&&(s[0].tab=t.id),{current:s,visibleViewIDs:n}}const SE=new em.AsyncParser({withBOM:!0});async function Cf(e){return!Array.isArray(e)||e.length===0?"":await SE.parse(e).promise()}async function kE(e,t){const n=await Cf(t),s=new Blob([n],{type:"text/csv"});os.saveAs(s,`${e}.csv`)}function Sf(e){const t=new jc,n=e.map(async({id:s,data:i})=>{const a=await Cf(i);t.file(`${s}.csv`,a)});Promise.all(n).then(()=>{t.generateAsync({type:"blob"}).then(s=>{os.saveAs(s,"dashboard_data.zip")})}).catch(s=>{console.error(s),Yt.notifications.show({color:"red",title:"Failed to download data",message:s.message})})}function fr(e,t){const n=new Blob([t],{type:"application/json"});os.saveAs(n,`${e}.json`)}const wl=af.views(e=>({get contentModel(){return x.getRoot(e).content}})).views(e=>({get queries(){return e.contentModel.queries.findByIDSet(e.queryIDSet)},get firstQuery(){return this.queries.length>0?this.queries[0]:null},get firstQueryData(){return this.firstQuery?this.firstQuery.data:[]},queryByID(t){return this.queries.find(n=>n.id===t)},get data(){return this.queries.reduce((t,n)=>(t[n.id]=n.data,t),{})},get variableStrings(){return Bp(e.variables,this.data)},get variableAggValueMap(){const t={},n=this.data;return e.variables.reduce((s,i)=>(s[i.name]=nn(i,n),s),t),t},get variableValueMap(){const t={},n=this.variableAggValueMap;return e.variables.reduce((s,i)=>(s[i.name]=vt(i,n[i.name]),s),t),t},get variableStyleMap(){const t=this.variableValueMap,n={};return e.variables.reduce((s,i)=>{const a=u_(i.color,t[i.name]);return s[i.name]={color:a,"font-size":i.size,"font-weight":i.weight,variable:i},s},n),n},get dataLoading(){return this.queries.some(t=>t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(a=>!a.runByConditionsMet);if(t.length===0)return"";const n=new Set,s=new Set;t.forEach(a=>{const l=a.conditionNames;l.context.forEach(c=>n.add(c)),l.filters.forEach(c=>s.add(c))});const i=[];return n.size>0&&(console.log(n),i.push(`context: ${Array.from(n).join(", ")}`)),s.size>0&&i.push(`filter${s.size>1?"s":""}: ${Array.from(s).join(", ")}`),i.length===2&&i.splice(1,0,"and"),i.unshift("Waiting for"),i.join(" ")},get queryErrors(){return this.queries.map(t=>t.error).filter(t=>!!t)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading}})).actions(e=>({refreshData(){e.queries.forEach(t=>t.fetchData(!0))},downloadData(){e.contentModel.queries.downloadDataByQueryIDs(e.queryIDs)},getSchema(){const t=e.json;return t.viz.conf={...t.viz.conf,__INTERACTIONS:{},__OPERATIONS:{},__TRIGGERS:{}},{panel:t,queries:e.queries.map(n=>n.json),layouts:e.contentModel.layouts.jsonByPanelIDSet(new Set([e.id]))}},downloadSchema(){const{panel:t,queries:n,layouts:s}=this.getSchema(),a=JSON.stringify({panels:[t],definition:{queries:n},layouts:s,version:gn},null,2),l=e.name;fr(l,a)}}));function kf(e){return{id:e,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:Wo.name,conf:Wo.createConfig()},style:{border:{enabled:!0}}}}const Cl=x.types.model("PanelsRenderModel",{list:x.types.optional(x.types.array(wl),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(n=>n.id===t)},get idMap(){const t=new Map;return e.list.forEach(n=>{t.set(n.id,n)}),t}})).views(e=>({panelsByIDs(t){const n=[];return t.forEach(s=>{const i=e.idMap.get(s);i?n.push(i):console.warn(`Panel is not found, id:${s}`)}),n}}));function Tf(e){const t=e.config,n=t.default_value;if(n===void 0)return n;if(t._name==="date-range")try{if(t.default_shortcut){const i=Jh(t.default_shortcut);if(i)return i.map(a=>P(a).format(t.inputFormat))}const[...s]=n;return s.map(i=>i===null?i:P.tz(i,"UTC").format(t.inputFormat)??i)}catch(s){return console.error(s),n}return n}function TE(e,t){const n=e.default_value_func;try{return new Function(`return ${n}`)()(e,At,t)}catch(s){return console.error(s),Tf(e)}}function Df(e,t){var n;return(n=e.default_value_func)!=null&&n.trim()?TE(e,t):Tf(e)}function Mf(e,t){return e.reduce((n,s)=>(n[s.key]=Df(s,t),n),{})}const Sl=x.types.model("FiltersRenderModel",{current:x.types.optional(x.types.array(fl),[]),values:x.types.optional(x.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get valuesString(){return JSON.stringify(e.values)},get contentModel(){return x.getRoot(e).content},get context(){return this.contentModel.payloadForSQL.context},get initialValuesDep(){return JSON.stringify({filters:e.current.map(({default_value_func:t,config:n})=>({default_value_func:t,config:n})),context:this.contentModel.payloadForSQL.context})},get formattedDefaultValues(){return Mf(this.json,this.contentModel.context)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get inOrder(){return v.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return v.sortBy(e.current.filter(n=>n.visibleInViewsIDSet.has(t)),"order")},get firstFilterValueKey(){return Object.keys(e.values)[0]??""},get keySet(){return new Set(e.current.map(t=>t.key))},get keyLabelMap(){return e.current.reduce((t,n)=>(t[n.key]=n.label,t),{})},getSelectOption(t){const n=this.findByID(t);if(!n||!("getSelectOption"in n.config))return null;const s=e.values[n.key];return n.config.getSelectOption(s)}})).actions(e=>({setValues(t){console.debug("⚪️ setting filter values: ",JSON.stringify(t)),e.values=t},patchValues(t){console.debug("⚪️ patching filter values: ",JSON.stringify(t)),e.values=v.defaults({},t,e.values)},setValueByKey(t,n){console.debug(`⚪️ setting filter[${t}] to value: `,JSON.stringify(n)),e.values={...e.values,[t]:n}},applyValuesPatch(t){e.values={...e.values,...t}},getValueByKey(t){return e.values[t]},getSchema(t,n){return{filters:e.findByIDSet(new Set(t)).map(a=>({...a.json,visibleInViewsIDs:n?a.json.visibleInViewsIDs:[]})),version:gn}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t,!1),null,2);fr("Filters",n)}}));function kl(e,t,n,s){const i=v.defaults({},s,Mf(e,{...n,...t}));return{current:e,values:i}}const If=of.views(e=>({get rootModel(){return x.getRoot(e)},get contentModel(){return this.rootModel.content},get conditionOptions(){if(!x.isAlive(e))return[];const{context:t}=this.contentModel.payloadForSQL,n=Object.keys(t).map(l=>({group:"Context",label:l,value:`context.${l}`,description:void 0})),s=this.contentModel.filters.keyLabelOptions.map(l=>({group:"Filters",label:l.label,value:`filters.${l.value}`,description:l.value})),i=[...n,...s],a=new Set(i.map(l=>l.value));return e.run_by.forEach(l=>{a.has(l)||i.push({group:"Invalid",label:l,value:l})}),i},get unmetRunByConditions(){if(!x.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const n=this.contentModel.payloadForSQL;return t.filter(s=>{const i=v.get(n,s);return Array.isArray(i)?i.length===0:typeof i=="number"?Number.isNaN(i):!i})}})).views(e=>({get payload(){return e.contentModel.payloadForSQL},get formattedSQL(){return Mi(e.sql,this.payload)},get httpConfigString(){const{context:t,filters:n}=this.payload,{name:s,pre_process:i}=e.json,a=b_(i,t,n);return console.groupCollapsed(`Request config for: ${s}`),console.log(a),console.groupEnd(),JSON.stringify(a)},get typedAsSQL(){return[Ee.Postgresql,Ee.MySQL].includes(e.type)},get typedAsHTTP(){return[Ee.HTTP].includes(e.type)},get isTransform(){return e.type===Ee.Transform},get reQueryKey(){const{react_to:t=[]}=e;if(t.length===0)return"";const n=e.contentModel.payloadForSQL,s=[...t].reduce((i,a)=>(i[a]=v.get(n,a),i),{});return JSON.stringify(s)},get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=e.contentModel.filters,n=e.unmetRunByConditions.filter(i=>i.startsWith("context.")).map(i=>i.replace("context.","")),s=e.unmetRunByConditions.filter(i=>i.startsWith("filters.")).map(i=>v.get({filters:t},i,i.replace("filters.",""))).filter(i=>!!i);return{context:n,filters:s}},get queries(){return x.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)},get dependencies(){if(!this.typedAsSQL)return[];const t=v.uniq(e.sql.match(Xs.sqlSnippet)),n=v.uniq(e.sql.match(Xs.filter)),s=v.uniq(e.sql.match(Xs.context)),i=[];return t.forEach(a=>{i.push({type:"sql_snippet",key:a,valid:e.contentModel.sqlSnippets.keySet.has(a)})}),n.forEach(a=>{i.push({type:"filter",key:a,valid:e.contentModel.filters.keySet.has(a)})}),s.forEach(a=>{i.push({type:"context",key:a,valid:e.contentModel.mock_context.keySet.has(a)})}),i}})),Tl=x.types.compose("QueryRenderModel",If,x.types.model({state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),data:x.types.optional(x.types.frozen([]),[]),error:x.types.frozen()})).views(e=>({get datasource(){const{key:t,type:n}=e;return e.rootModel.datasources.find({type:n,key:t})},get additionalQueryInfo(){return e.contentModel.getAdditionalQueryInfo(e.id)},get depQueryModels(){return e.contentModel.queries.findByIDSet(new Set(e.dep_query_ids))},get depQueryModelStates(){return this.depQueryModels.map(t=>t.state)},get depQueryModelStatesString(){return this.depQueryModelStates.toString()}})).views(e=>({get stateMessage(){if(e.state!=="idle")return"";if(!e.runByConditionsMet){const{context:t,filters:n}=e.conditionNames;if(t.length===0&&n.length===0)return"Waiting";const s=[];return t.length>0&&s.push(`context: ${t.join(", ")}`),n.length>0&&s.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),s.length===2&&s.splice(1,0,"and"),s.unshift("Waiting for"),s.join(" ")}return e.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:x.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const n=e.payload;e.data=yield*x.toGenerator(T_({payload:n,name:e.name,query:e.json,additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(!Rt.isCancel(n)){e.data=[];const s=v.get(n,"message","unkown error");e.error=v.get(n,"response.data.detail.message",s),e.state="error"}}}}),runHTTP:x.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{type:n,key:s,post_process:i}=e.json;let a=JSON.parse(e.httpConfigString);a=v_(e.datasource,a);const l=yield*x.toGenerator(D_({type:n,key:s,configString:JSON.stringify(a),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=__(e.datasource,l),u=j_(i,c,e.contentModel.dashboardState);e.data=u,e.state="idle",e.error=null}catch(n){if(console.error(n),!Rt.isCancel(n)){e.data=[];const s=v.get(n,"message","unkown error");e.error=v.get(n,"response.data.detail.message",s),e.state="error"}}}}),runTransformation(){e.state="loading";try{const n=e.contentModel.queries.findByIDSet(new Set(e.dep_query_ids)).map(l=>({id:l.id,name:l.name,data:v.cloneDeep(l.data)})),s=e.contentModel.dashboardState,i=e.pre_process,a=new Function(`return ${i}`)()(n,s,At);e.data=a,e.state="idle",e.error=null}catch(t){e.data=[],e.error=t.message,e.state="error"}}})).actions(e=>({fetchData:t=>{if(!e.inUse&&!t){console.debug(`🟡 Skipping query[${e.name}]`);return}return console.debug(`🔵 Running query[${e.name}]`),e.isTransform?e.runTransformation():e.typedAsHTTP?e.runHTTP():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){x.addDisposer(e,ae.reaction(()=>{var n;return e.isTransform?[e.inUse,e.id,e.key,e.dep_query_ids.toString(),e.pre_process,e.depQueryModelStatesString].join("--"):e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(n=e.datasource)==null?void 0:n.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},t=>(e.name==="getProjectGroupContributors"&&console.log("🔵 deps: ",t),e.fetchData(!1)),{fireImmediately:!0,delay:0}))}})),Dl=x.types.model("QueriesRenderModel",{current:x.types.optional(x.types.array(Tl),[])}).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get contentModel(){return x.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:n,queries:s}=this.contentModel,i=[];t.visibleViews.forEach(c=>{c.panels.forEach(u=>{i.push(...u.queryIDs)})});const a=v.uniq(t.visibleViews.map(c=>c.renderViewIDs).flat());n.current.forEach(c=>{const u=v.get(c,"config.options_query_id");if(!u)return;a.some(h=>c.visibleInViewsIDSet.has(h))&&i.push(u)}),s.findByIDSet(new Set(i)).forEach(c=>{!c.isTransform||c.dep_query_ids.length===0||i.push(...c.dep_query_ids)});const l=new Set(i);return console.debug("QueryIDs:",l),l},isQueryInUse(t){return this.visibleQueryIDSet.has(t)}})).actions(e=>({downloadAllData(){const t=e.current.map(({name:n,data:s})=>({id:n,data:s}));Sf(t)},downloadDataByQueryIDs(t){const n=new Set(t),s=e.current.filter(i=>n.has(i.id)).map(({name:i,data:a})=>({id:i,data:a}));Sf(s)},downloadDataByQueryID(t){const n=e.findByID(t);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:s,data:i}=n;kE(s,i)},refetchDataByQueryID(t){const n=e.findByID(t);if(!n){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return n.fetchData(!0)},getSchema(t){return{definition:{queries:e.findByIDSet(new Set(t)).map(i=>i.json)},version:gn}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t),null,2);fr("Queries",n)}}));function zf(e){return{current:e}}function Ef({min:e,max:t}){const n=`${e}px`,s=Number.isFinite(t)?`${t}px`:"∞";return`[${n}, ${s})`}const Ml=x.types.model("LayoutsRenderModel",{list:x.types.array(cf),currentBreakpoint:x.types.string}).views(e=>({get json(){return e.list.map(t=>t.json)},jsonByPanelIDSet(t){return e.list.map(n=>n.jsonByPanelIDSet(t))},get root(){return x.getRoot(e)},get contentModel(){return this.root.content},get basisLayoutSet(){return e.list.find(t=>t.id==="basis")},get currentLayoutSet(){return e.list.find(t=>t.id===e.currentBreakpoint)},get currentLayoutRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentRangeText(){const t=this.currentLayoutRange;return Ef(t)},get cols(){const t={};return e.list.forEach(n=>{t[n.id]=36}),t},get breakpoints(){const t={};return e.list.forEach(n=>{t[n.id]=n.breakpoint}),t},get breakpointNameRecord(){const t={};return e.list.forEach(n=>{t[n.name]=n.breakpoint}),t},get breakpointRanges(){const t=e.list.map(n=>({id:n.id,name:n.name,min:n.breakpoint,max:1/0,text:""}));return t.sort((n,s)=>n.min-s.min).forEach((n,s)=>{s!==t.length-1&&(n.max=t[s+1].min)}),t.forEach(n=>{n.text=Ef(n)}),t},get breakpointsInfo(){return e.list.map(t=>({id:t.id,name:t.name,breakpoint:t.breakpoint})).sort((t,n)=>t.breakpoint-n.breakpoint)},get currentBreakpointRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentLayoutPreviewWidth(){const t=this.currentBreakpointRange;if(t)return t.max===1/0?t.min===0?void 0:t.min+1:t.max},items(t){const n=new Set(t);return this.currentLayoutSet.list.filter(i=>n.has(i.panelID))},gridLayouts(t){const n=new Set(t),s={};return e.list.forEach(i=>{s[i.id]=i.list.filter(a=>n.has(a.panelID)).map(a=>a.layoutProperies)}),s},findItemByPanelID(t){return this.currentLayoutSet.findByPanelID(t)}})).actions(e=>({setCurrentBreakpoint(t){console.log("🔴 onBreakpointChange:",t),e.currentBreakpoint=t},afterCreate(){x.addDisposer(e,ae.reaction(()=>e.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),Af=uf.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!x.getParent(e,2).findByKey(t)}})),Il=x.types.model("SQLSnippetsRenderModel",{current:x.types.optional(x.types.array(Af),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,n)=>(t[n.key]=n.value,t),{})},get keySet(){return new Set(e.current.map(t=>t.key))},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(n=>n.key===t)},findByKeySet(t){return e.current.filter(n=>t.has(n.key))}})).actions(e=>({getSchema(t){return{definition:{sqlSnippets:e.findByKeySet(new Set(t)).map(i=>i.json)},version:gn}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t),null,2);fr("SQL Snippets",n)}}));function Pf(e){return{current:e}}function es(e,t,n,s){return e.reduce((i,a)=>{try{i[a[t]]=Di(a[n],s)}catch(l){i[a[t]]=l.message}return i},{})}class Of{constructor(t){N(this,"origin");N(this,"copy");this.origin=t,this.copy=x.clone(t),ae.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!v.isEqual(x.getSnapshot(this.origin),x.getSnapshot(this.copy))}commit(){x.applySnapshot(this.origin,x.getSnapshot(this.copy))}reset(){x.applySnapshot(this.copy,x.getSnapshot(this.origin))}update(t){x.applySnapshot(this.copy,t)}}const Lf=e=>new Of(e),DE=D.observer(()=>{const{t:e}=j.useTranslation(),t=le(),{panel:n}=Je(),s=n.realQueryOptions,i=a=>{t.editor.open(["_QUERIES_",a])};return s.length===0?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{label:e(s.length>1?"query.labels":"query.label"),labelPosition:"center"}),s.map(a=>r.jsx(o.Menu.Item,{onClick:()=>i(a.value),icon:r.jsx(M.IconDatabase,{size:14}),children:a.label},a.value))]})}),ME=D.observer(({view:e,title:t})=>{const{t:n}=j.useTranslation(),s=le(),i=re(),a=wt.useModals(),{panel:l,downloadPanelScreenshot:c}=Je(),{id:u}=l,{viewPanelInFullScreen:d,inFullScreen:h}=g.useContext(pi),p=()=>{i.duplicatePanelByID(u,e.id)},f=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u])},m=()=>a.openConfirmModal({title:`${n("panel.delete")}?`,labels:{confirm:n("common.actions.confirm"),cancel:n("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.removePanelByID(u,e.id),confirmProps:{color:"red"},zIndex:320}),y=g.useCallback(()=>{d(u)},[u,d]),_=!h&&e.type!==G.Modal;return r.jsx(r.Fragment,{children:r.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:r.jsxs(o.Menu,{withinPortal:!0,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{onClick:l.refreshData,icon:r.jsx(W.Refresh,{size:14}),children:n("common.actions.refresh")}),r.jsx(o.Menu.Item,{onClick:l.downloadData,icon:r.jsx(W.Download,{size:14}),children:n("common.actions.download_data")}),r.jsx(o.Menu.Item,{onClick:l.downloadSchema,icon:r.jsx(M.IconCode,{size:14}),children:n("common.actions.download_schema")}),r.jsx(o.Menu.Item,{onClick:c,icon:r.jsx(M.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),_&&r.jsx(o.Menu.Item,{onClick:y,icon:r.jsx(W.ArrowsMaximize,{size:14}),disabled:!0,children:n("common.actions.enter_fullscreen")}),r.jsx(DE,{}),r.jsx(o.Divider,{label:n("common.actions.edit"),labelPosition:"center"}),r.jsx(o.Menu.Item,{onClick:f,icon:r.jsx(W.Settings,{size:14}),children:n("common.titles.settings")}),r.jsx(o.Menu.Item,{onClick:p,icon:r.jsx(W.Copy,{size:14}),children:n("common.actions.duplicate")}),r.jsx(o.Menu.Item,{color:"red",onClick:m,icon:r.jsx(W.Trash,{size:14}),children:n("common.actions.delete")})]})]})})})});function IE(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const zl=D.observer(()=>{const{t:e}=j.useTranslation(),[t,n]=g.useState(!1),{panel:s}=Lt();return IE(s.description)?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:()=>n(!1),title:s.title.show?s.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:r.jsx(Kr,{value:s.description,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}}})}),r.jsx(o.Tooltip,{label:e("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:r.jsx(W.InfoCircle,{size:20})})})]})}),bV="",zE=D.observer(function(){const{panel:t}=Lt(),{name:n,title:s}=t;return s.show?r.jsx(o.Group,{grow:!0,position:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:r.jsx(o.Text,{align:"center",lineClamp:1,className:"panel-title-text",children:n})}):null});function EE(e){const t=g.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const s=t.current;if(!s)return;const i=s.offsetWidth*2,a=s.offsetHeight*2;_c.toBlob(t.current,{bgcolor:"white",width:i,height:a,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(l=>{window.saveAs(l,`${e.name?e.name:e.viz.type}.png`)})}}}var Vf=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(Vf||{}),gi=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(gi||{});class AE{constructor(t){N(this,"vizInstance");N(this,"operationManager");N(this,"triggerManager");N(this,"vizManager");N(this,"runningMigration");N(this,"panelModel");N(this,"status","notStarted");this.panelModel=t.getRequired(Oe.instanceScope.panelModel),this.vizInstance=t.getRequired(Oe.instanceScope.vizInstance),this.operationManager=t.getRequired(Oe.instanceScope.operationManager),this.triggerManager=t.getRequired(Oe.instanceScope.triggerManager),this.vizManager=t.getRequired(Oe.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(t=>(this.status="done",t))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(n)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return t.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function Bf(e){const{panel:t}=Lt();return g.useCallback(n=>{const s=n.getRequired(Oe.vizManager),i=s.resolveComponent(e.viz.type);return n.createScoped().provideFactory(Oe.instanceScope.vizInstance,()=>s.getOrCreateInstance(e)).provideFactory(Oe.instanceScope.interactionManager,a=>{const l=a.getRequired(Oe.instanceScope.vizInstance);return new yo(l,i,Hs)}).provideFactory(Oe.instanceScope.operationManager,a=>a.getRequired(Oe.instanceScope.interactionManager).operationManager).provideFactory(Oe.instanceScope.triggerManager,a=>a.getRequired(Oe.instanceScope.interactionManager).triggerManager).provideValue(Oe.instanceScope.panelModel,t).provideFactory(Oe.instanceScope.migrator,a=>new AE(a))},[e.viz.type,e.viz.conf])}function qf(e){const[t,n]=g.useState(!1),s=Xh().getRequired(Oe.instanceScope.migrator);return J.useAsyncEffect(async()=>{const i=s.status===gi.notStarted;n(s.status===gi.done),s.status===gi.notStarted&&s.runMigration().then(a=>{a===Vf.migrated&&i&&(e==null||e())}).finally(()=>{n(!0)})},[s]),t}function Nf(e,t){const n=Xh().getRequired(Oe.instanceScope.vizInstance);return g.useEffect(()=>(n.instanceData.setItem(null,t.viz.conf),n.instanceData.watchItem(null,s=>{e(s)})),[e,t.viz.type]),n}function PE({setVizConf:e,...t}){const{panel:n}=t,s=Nf(e,n),i=qf(()=>{Yt.showNotification({title:`${n.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return J.useAsyncEffect(async()=>{await s.instanceData.setItem(null,n.viz.conf)},[s,n.viz.type]),i?r.jsx(E_,{...t}):r.jsx(o.Text,{children:"Checking update..."})}function OE(e){const{panel:t,setVizConf:n}=e;Nf(n,t);const{inEditMode:s}=g.useContext(Ss);return qf(()=>{s&&Yt.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?r.jsx(z_,{...e}):r.jsx(o.Text,{children:"Checking update"})}const vV="";function LE(e,t){const{vizManager:n}=g.useContext(rn),{panel:{viz:s,title:i,id:a,name:l,description:c,queryIDs:u,variables:d}}=Lt(),h={id:a,name:l,title:i,description:c,queryIDs:u,viz:s},p=Bf(h);try{return n.resolveComponent(s.type),r.jsx(di,{configure:p,children:r.jsx(OE,{setVizConf:s.setConf,panel:h,measure:t,data:e,variables:d,vizManager:n})})}catch(f){return console.info(v.get(f,"message")),null}}const $f=D.observer(function({data:t}){const{ref:n,width:s,height:i}=Se.useElementSize(),a=LE(t,{w:s,h:i}),l=s>0&&i>0;return r.jsx("div",{className:"viz-root",ref:n,children:r.jsx(o.Box,{sx:{width:s,height:i,overflow:"hidden"},children:l&&r.jsx(Re,{children:a})})})}),Ff=D.observer(({panel:e})=>r.jsxs(o.Stack,{children:[e.queryErrors.map((t,n)=>r.jsx(o.Text,{color:"red",size:"sm",align:"center",sx:{fontFamily:"monospace"},children:t},`${n}-${t}`)),r.jsx(o.Text,{color:"gray",align:"center",size:"sm",children:e.queryStateMessages})]})),El=D.observer(({panel:e})=>r.jsxs(o.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[r.jsx(o.LoadingOverlay,{visible:e.dataLoading,exitTransitionDuration:0}),!e.canRenderViz&&r.jsx(Ff,{panel:e}),e.canRenderViz&&r.jsx($f,{data:e.data})]})),VE={border:"1px solid #e9ecef"},Gf=D.observer(({panel:e,panelStyle:t,dropdownContent:n})=>{const{ref:s,downloadPanelScreenshot:i}=EE(e);return e.title.show,r.jsx(ra,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:i},children:r.jsxs(o.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,ref:s,p:0,sx:{...VE,...t},children:[r.jsx(o.Box,{className:"panel-description-popover-wrapper",children:r.jsx(zl,{})}),n,r.jsx(zE,{}),r.jsx(El,{panel:e})]})})}),BE={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function qE(e){return e.style.border.enabled?{}:BE}const Wf=D.observer(function({panel:t,view:n}){const s=qE(t);return r.jsx(Gf,{panel:t,panelStyle:s,dropdownContent:r.jsx(ME,{view:n,title:t.name})})});function NE(e){return!["richText","button"].includes(e)}const $E=D.observer(({view:e,title:t})=>{const{t:n}=j.useTranslation(),{panel:s,downloadPanelScreenshot:i}=Lt(),{id:a}=s,{viewPanelInFullScreen:l,inFullScreen:c}=g.useContext(pi),u=g.useCallback(()=>{l(a)},[a,l]),d=!c&&e.type!==G.Modal;return NE(s.viz.type)?r.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:r.jsxs(o.Menu,{withinPortal:!0,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Box,{className:"panel-dropdown-target"})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{onClick:s.refreshData,icon:r.jsx(W.Refresh,{size:14}),children:n("common.actions.refresh")}),r.jsx(o.Menu.Item,{onClick:s.downloadData,icon:r.jsx(W.Download,{size:14}),children:n("common.actions.download_data")}),r.jsx(o.Menu.Item,{onClick:i,icon:r.jsx(M.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),d&&r.jsx(o.Menu.Item,{onClick:u,icon:r.jsx(W.ArrowsMaximize,{size:14}),children:n("common.actions.enter_fullscreen")})]})]})}):null});function FE(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const Al=D.observer(({panel:e,view:t})=>{const n=FE(e);return r.jsx(Gf,{panel:e,panelStyle:n,dropdownContent:r.jsx($E,{title:e.name,view:t})})}),GE={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},Rf=D.observer(function({view:t,panel:n,exitFullScreen:s}){return r.jsx(o.Modal,{opened:!0,fullScreen:!0,onClose:s,title:r.jsx(o.Button,{color:"blue",size:"xs",onClick:s,leftIcon:r.jsx(W.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:GE,children:r.jsx(o.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:r.jsx(Al,{view:t,panel:n})})})});function Qf(e,t,n){const{panels:s}=Pe(),i=e.id==="Main",[a,l]=g.useState(()=>i&&s.findByID(t)?t:null),c=g.useCallback(p=>{l(p),i&&n(p)},[i,n]),u=g.useCallback(()=>{l(null),i&&n("")},[i,n]),d=a?s.findByID(a):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const _V="",WE=g.forwardRef(({h:e},t)=>r.jsx(o.ActionIcon,{ref:t,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:e>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:r.jsx(W.ArrowsMove,{size:16})})),RE=g.forwardRef(({handleAxis:e,...t},n)=>r.jsx(o.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:r.jsx(W.ChevronDownRight,{size:16})})),QE=as.WidthProvider(as.Responsive),UE=D.observer(({view:e,className:t="layout"})=>{const s=re().layouts,i=s.items(e.panelIDs),a=s.gridLayouts(e.panelIDs),l=(d,h,p,f)=>{console.log("🔴 onResize",d),p.h<30&&(p.h=30,f.h=30),p.w<4&&(p.w=4,f.w=4)},c=(d,h,p)=>{console.log("🔴 onResizeStop",{layouts:d,oldItem:h,newItem:p}),s.updateCurrentLayoutItem(p)},u=(d,h,p)=>{console.log("🔴 onDragStop",{layouts:d,oldItem:h,newItem:p}),s.updateCurrentLayoutItems(d)};return r.jsx(QE,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:s.cols,layouts:a,draggableHandle:".react-grid-customDragHandle",resizeHandle:r.jsx(RE,{}),onResize:l,breakpoints:s.breakpoints,onBreakpointChange:s.setCurrentBreakpoint,onResizeStop:c,onDragStop:u,width:s.currentLayoutPreviewWidth,children:i.map(d=>r.jsxs("div",{"data-grid":d.layoutProperies,className:"panel-grid-item",children:[r.jsx(WE,{h:d.h}),r.jsx(Wf,{view:e,panel:d.panel})]},d.id))})}),YE=as.WidthProvider(as.Responsive),KE=D.observer(({view:e,className:t="layout"})=>{const n=Pe(),s=n.layouts.items(e.panelIDs),i=n.layouts.gridLayouts(e.panelIDs);return r.jsx(YE,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:n.layouts.cols,layouts:i,breakpoints:n.layouts.breakpoints,onBreakpointChange:n.layouts.setCurrentBreakpoint,children:s.map(a=>r.jsx("div",{"data-grid":a.layoutProperies,className:"panel-grid-item",children:r.jsx(Al,{view:e,panel:a.panel})},a.id))})});function Pl(e){const t=g.useRef(null);return{ref:t,downloadScreenshot:()=>{var i;const s=(i=t.current)==null?void 0:i.querySelector(".react-grid-layout");s&&e.downloadScreenshot(s)}}}const XE=D.observer(({downloadScreenshot:e})=>{const{t}=j.useTranslation(),[n,{setTrue:s,setFalse:i}]=J.useBoolean(!1),a=wu(),l=Pe(),c=()=>{const u=JSON.stringify(l.contentJSON,null,2),d=`${a.name}__${l.name}`;fr(d,u)};return r.jsxs(o.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:r.jsx(o.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:s,onMouseLeave:i,sx:{opacity:n?1:.6,transform:`translateX(${n?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:r.jsx(M.IconShare3,{size:"1rem"})})})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{icon:r.jsx(M.IconCamera,{size:14}),onClick:e,children:t("common.actions.download_screenshot")}),r.jsx(o.Menu.Divider,{}),r.jsx(o.Menu.Item,{icon:r.jsx(M.IconDownload,{size:14}),onClick:l.queries.downloadAllData,children:t("common.actions.download_data")}),r.jsx(o.Menu.Item,{icon:r.jsx(M.IconCode,{size:14}),onClick:c,children:t("common.actions.download_schema")})]})]})}),Uf=D.observer(({children:e,view:t,sx:n={}})=>{const{ref:s,downloadScreenshot:i}=Pl(t);return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{ref:s,pt:10,pb:10,sx:n,children:e}),r.jsx(XE,{downloadScreenshot:i})]})}),Yf=D.observer(({downloadScreenshot:e})=>r.jsx(o.ActionIcon,{className:"download-screenshot-button",color:"blue",onClick:e,children:r.jsx(M.IconCamera,{size:14})})),JE=D.observer(({children:e,view:t})=>{const n=Pe(),s=t.config,i=n.views.visibleViewIDs.includes(t.id),a=()=>n.views.rmVisibleViewID(t.id),{ref:l,downloadScreenshot:c}=Pl(t);return r.jsx(o.Modal,{size:s.width,centered:!0,opened:i,onClose:a,withCloseButton:!1,title:r.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[r.jsx(o.Box,{children:s.custom_modal_title.value}),r.jsx(Yf,{downloadScreenshot:c})]}),trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:s.height,overflow:"auto",position:"relative",paddingBottom:10},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:r.jsx(o.Box,{ref:l,children:e})})}),ZE=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},HE=D.observer(({view:e})=>{const t=Pe(),n=e.config;return r.jsxs(o.Tabs,{className:"render-view-tabs",variant:n.variant,orientation:n.orientation,value:e.tab,onTabChange:e.setTab,styles:{root:{height:"100%",overflow:n.orientation==="horizontal"?"hidden":"auto"},panel:{padding:n.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[r.jsx(o.Tabs.List,{grow:n.grow,children:n.tabsInOrder.map(s=>r.jsx(o.Tabs.Tab,{value:s.id,sx:ZE(s),disabled:!s.view_id,children:s.name??s.id},s.id))}),n.tabsInOrder.map(s=>{const i=t.views.findByID(s.view_id);return i?r.jsx(o.Tabs.Panel,{value:s.id,children:r.jsx(mi,{view:i})},s.id):null})]})}),eA=D.observer(({view:e,children:t})=>{switch(e.type){case G.Modal:return r.jsx(JE,{view:e,children:t});case G.Tabs:return r.jsx(HE,{view:e});case G.Division:default:return r.jsx(Uf,{view:e,children:t})}}),tA=D.observer(({children:e,view:t})=>{const s=re().layouts,[i,a]=Se.useResizeObserver();return g.useEffect(()=>{s.setCurrentLayoutWrapperWidth(a.width)},[a.width]),r.jsx(o.Box,{sx:{height:"100%"},ref:i,children:r.jsx(o.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:s.currentLayoutPreviewWidth??"100%",transform:`scale(${s.divisionPreviewScale})`,transformOrigin:"0 0"},children:r.jsx(Uf,{view:t,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:e})})})});function Kf(e){return e.replace(/(vw|vh)/,"%")}const nA=D.observer(({children:e,view:t})=>{const n=t.config,{width:s,height:i}=g.useMemo(()=>({width:Kf(n.width),height:Kf(n.height)}),[n.width,n.height]),{ref:a,downloadScreenshot:l}=Pl(t);return r.jsx(o.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:r.jsx(o.Modal,{size:n.width,opened:!0,onClose:v.noop,withCloseButton:!1,title:r.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[r.jsx(o.Box,{children:n.custom_modal_title.value}),r.jsx(Yf,{downloadScreenshot:l})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:s,height:i,maxHeight:i},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:r.jsx(o.Box,{ref:a,children:e})})})}),rA=({variant:e,orientation:t})=>{const n={root:{height:"100%",overflow:"hidden"},tabsList:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(n.tab.paddingTop="6px",n.tab.paddingBottom="6px"),t==="vertical"&&(n.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},n.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),n},sA=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},iA=D.observer(({view:e})=>{const{t}=j.useTranslation(),n=wt.useModals(),s=re(),i=g.useMemo(()=>s.views.options.filter(u=>u.type===G.Division),[e.id,s.views.options]),a=e.config,l=u=>n.openConfirmModal({title:`${t("view.component.tabs.tab.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{a.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),c=a.tabs.length===0;return r.jsxs(o.Tabs,{className:"preview-view-tabs",variant:a.variant,orientation:a.orientation,value:e.tab,onTabChange:e.setTab,styles:rA(a),children:[r.jsxs(o.Tabs.List,{grow:a.grow,children:[a.tabsInOrder.map(u=>r.jsx(o.Tabs.Tab,{value:u.id,sx:sA(u),children:u.name??u.id},u.id)),r.jsx(o.Tabs.Tab,{onClick:a.addTab,value:"add",className:"add-a-tab",children:r.jsx(W.Plus,{size:18,color:"#228be6"})})]}),a.tabsInOrder.map((u,d)=>{const h=s.views.findByID(u.view_id);return r.jsxs(o.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[r.jsxs(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[r.jsx(o.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),r.jsxs(o.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[r.jsx(o.TextInput,{label:t("view.component.tabs.tab.name"),required:!0,value:u.name,onChange:p=>u.setName(p.currentTarget.value)}),r.jsx(o.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:i}),r.jsx(o.NumberInput,{label:t("view.component.tabs.tab.order"),required:!0,value:u.order,onChange:p=>u.setOrder(p||0),min:0,max:1e3,step:1}),r.jsx(o.ColorInput,{label:t("view.component.tabs.tab.color"),value:u.color,onChange:u.setColor,disabled:a.variant!=="default"}),h&&r.jsx(o.Button,{mt:20,variant:"gradient",leftIcon:r.jsx(M.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>s.views.setIDOfVIE(h.id),children:t("view.component.tabs.tab.switch_to_view",{name:h.name})}),r.jsx(o.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>l(d),disabled:c,leftIcon:r.jsx(M.IconTrash,{size:14}),children:t("view.component.tabs.tab.delete")})]})]}),h&&r.jsx(mi,{view:h})]},u.id)})]})}),aA=D.observer(({view:e,children:t})=>{switch(e.type){case G.Modal:return r.jsx(nA,{view:e,children:t});case G.Tabs:return r.jsx(iA,{view:e});case G.Division:default:return r.jsx(tA,{view:e,children:t})}}),Xf=D.observer(function({view:t}){const s=re().layouts.divisionPreviewScale!==1;return r.jsx(pi.Provider,{value:{viewPanelInFullScreen:v.noop,inFullScreen:!1},children:r.jsx(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:s?"transparent":"#efefef"},children:r.jsx(aA,{view:t,children:r.jsxs(o.Box,{sx:{position:"relative"},children:[r.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:r.jsx(ef,{view:t})}),r.jsx(UE,{view:t})]})})})})}),mi=D.observer(function({view:t}){const{fullScreenPanelID:n,setFullScreenPanelID:s}=Eu(),{viewPanelInFullScreen:i,exitFullScreen:a,inFullScreen:l,fullScreenPanel:c}=Qf(t,n,s);return r.jsx(pi.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:l},children:r.jsxs(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===G.Modal?"0 !important":"100%"},children:[l&&r.jsx(Rf,{view:t,panel:c,exitFullScreen:a}),r.jsx(eA,{view:t,children:r.jsxs(o.Box,{sx:{position:"relative"},children:[!l&&r.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:r.jsx(ef,{view:t})}),!l&&r.jsx(KE,{view:t})]})})]})})});var Jf=(e=>(e.Use="use",e.Edit="edit",e))(Jf||{});const oA={[G.Division]:"Division",[G.Tabs]:"Tabs",[G.Modal]:"Modal"},Zf={[G.Division]:"rgba(255, 0, 0, 0.2)",[G.Modal]:"rgba(0, 0, 0, 0.2)",[G.Tabs]:"rgba(255, 200, 100, 0.4)"},lA={[G.Division]:"#ff4000",[G.Modal]:"#000",[G.Tabs]:"#ffad18"};function cA(e,t,n){x.addDisposer(e,x.addMiddleware(e,(s,i)=>{i(s,()=>{x.getType(s.context)===t&&s.type==="action"&&n(s.name,s.context)})}))}const Hf=x.types.compose("FiltersModel",Sl,x.types.model("FiltersModel",{previewValues:x.types.optional(x.types.frozen(),{})})).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get keySet(){return new Set(e.current.map(t=>t.key))},get options(){return e.current.map(t=>({label:t.label??t.id,value:t.id,_type:"filter"}))},get selects(){return e.current.filter(t=>t.type===Ce.Select).map(t=>({label:t.label??t.id,value:t.id}))},get keyLabelOptions(){return e.current.map(t=>({label:t.label??t.key,value:t.key}))},get sortedList(){return v.sortBy(e.current,t=>t.label.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.idSet.has(s.id));e.current.push(...n)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(s=>s.id===t);n>=0&&e.current.splice(n,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){cA(e.current,fl,(n,s)=>{if(n==="setType"){const i=Df(s.config.default_value,s.config);e.setValueByKey(s.key,i),e.updatePreviewValues({...e.previewValues,[s.key]:i})}})}return{afterCreate(){t()}}}),eg=Tl.views(e=>({get canPreviewData(){return e.isTransform?e.dep_query_ids.length>0&&!!e.pre_process:!!e.datasource},get guideToPreviewData(){return e.isTransform?"Need to complete settings in Transform tab":"Need to pick a Data Source first"}})),tg=x.types.compose("QueriesModel",Dl,x.types.model({current:x.types.optional(x.types.array(eg),[])})).views(e=>({get options(){const t=e.current.map(n=>({value:n.id,label:n.name,_type:"query"}));return v.sortBy(t,n=>n.label.toLowerCase())},get optionsWithoutTransform(){const t=e.current.filter(n=>n.type!==Ee.Transform).map(n=>({value:n.id,label:n.name,_type:"query"}));return v.sortBy(t,n=>n.label.toLowerCase())},get sortedList(){return v.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.idSet.has(s.id));e.current.push(...n)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},removeQuery(t){const n=e.current.find(s=>s.id===t);n&&(x.detach(n),e.current.remove(n))},removeQueries(t){const n=new Set(t);e.current.forEach(i=>{n.has(i.id)&&x.detach(i)});const s=[...e.current];v.remove(s,i=>n.has(i.id)),e.current=x.cast(s)}})),ng=Il.views(e=>({get sortedList(){return v.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(n=>({label:n.key,value:n.key,_type:"sql_snippet"}));return v.sortBy(t,n=>n.label.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.keySet.has(s.key));e.current.push(...n)},remove(t){e.current.splice(t,1)},removeByKey(t){const n=e.current.findIndex(s=>s.key===t);n>=0&&e.current.splice(n,1)},removeByKeys(t){const n=new Set(t);e.current.forEach(i=>{n.has(i.key)&&x.detach(i)});const s=[...e.current];v.remove(s,i=>n.has(i.key)),e.current=x.cast(s)},replaceByIndex(t,n){e.current.splice(t,1,n)}})),uA=x.types.model({data:x.types.optional(x.types.frozen(),[]),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),dA=x.types.model({data:x.types.optional(x.types.frozen(),[]),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),pA=x.types.model({page:x.types.optional(x.types.number,1),limit:x.types.optional(x.types.number,20),data:x.types.optional(x.types.frozen(),[]),total:x.types.optional(x.types.number,0),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get keywords(){return x.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:n}=x.getParent(e,1);return`${n}||${t}`}})).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0},get maxPage(){return Math.ceil(e.total/e.limit)},get offset(){return(e.page-1)*e.limit},get countSql(){const{table_name:t,table_schema:n}=e.keywords;return`
470
+ `)},ml=x.types.model("ViewModalConfig",{_name:x.types.literal(G.Modal),width:x.types.string,height:x.types.string,custom_modal_title:x.types.optional(jE,hi)}).views(e=>({get json(){const{_name:t,width:n,height:s,custom_modal_title:i}=e;return{_name:t,width:n,height:s,custom_modal_title:i.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),yf=()=>ml.create({_name:G.Modal,width:"90vw",height:"90vh"}),wE=x.types.model("ViewTabsTabModel",{id:x.types.identifier,name:x.types.string,view_id:x.types.string,color:x.types.optional(x.types.string,""),order:x.types.optional(x.types.number,0)}).views(e=>({get json(){const{id:t,name:n,view_id:s,color:i,order:a}=e;return{id:t,name:n,color:i,order:a,view_id:s}}})).actions(e=>({setName(t){e.name=t},setViewID(t){e.view_id=t},setColor(t){e.color=t},setOrder(t){e.order=t}})),xl=x.types.model("ViewTabsConfig",{_name:x.types.literal(G.Modal),tabs:x.types.optional(x.types.array(wE),[]),variant:x.types.optional(x.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:x.types.optional(x.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:n,orientation:s,tabs:i,grow:a}=e;return{grow:a,tabs:i.map(l=>l.json),_name:t,variant:n,orientation:s}},get tabsInOrder(){return v.sortBy(e.tabs,"order")}})).actions(e=>({setVariant(t){e.variant=t},setOrientation(t){e.orientation=t},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=x.cast(t)},addTab(){const t=Se.randomId(),n={id:t,name:t,view_id:""};e.tabs.push(n)},removeTab(t){e.tabs.splice(t,1)}})),bf=()=>xl.create({_name:G.Modal,tabs:[]}),vf=x.types.model({id:x.types.identifier,name:x.types.string,type:x.types.enumeration("EViewComponentType",[G.Division,G.Modal,G.Tabs]),config:x.types.union(gl,ml,xl),panelIDs:x.types.optional(x.types.array(x.types.string),[])}).views(e=>({get json(){const{id:t,name:n,type:s,config:i}=e;return{id:t,name:n,type:s,config:i.json,panelIDs:e.panelIDs.map(a=>a)}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case G.Division:e.config=xf();break;case G.Modal:e.config=yf();break;case G.Tabs:e.config=bf();break}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},appendPanelIDs(t){e.panelIDs.push(...t)},removePanelID(t){const n=e.panelIDs.filter(s=>s!==t);e.panelIDs.length=0,e.panelIDs.push(...n)}})),gn="11.10.0",CE={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:G.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:gn,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},yl=x.types.model("DataSourceMetaModel",{id:x.types.string,type:x.types.enumeration("DataSourceType",[Ee.HTTP,Ee.MySQL,Ee.Postgresql]),key:x.types.string,config:x.types.frozen()}),_f=x.types.model("DataSourcesMetaModel",{list:x.types.optional(x.types.array(yl),[])}).views(e=>({find({type:t,key:n}){return e.list.find(s=>s.key===n&&s.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),jf=x.types.model({id:x.types.string,content:x.types.string,create_time:x.types.string,update_time:x.types.string,is_preset:x.types.boolean}),bl=x.types.model("GlobalSQLSnippetsMeta",{list:x.types.optional(x.types.array(jf),[])}).views(e=>({find(t){return e.list.find(n=>n.id===t)},get options(){return e.list.map(t=>({value:t.id,label:t.id}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),fi=x.types.model("ContextMeta",{current:x.types.optional(x.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function vl(e){return fi.create({current:e})}const _l=x.types.compose("ViewRenderModel",vf,x.types.model({tab:x.types.optional(x.types.string,"")})).views(e=>({get tabs(){return e.config.tabs},get tabInfo(){const t=this.tabs.find(n=>n.id===e.tab);return t?{id:t.id,name:t.name}:null},get tabView(){return e.type!==G.Tabs?null:this.tabs.find(t=>t.id===e.tab)},get tabViewID(){return this.tabView?this.tabView.view_id??"":""},get contentModel(){return x.getParent(e,3)},get panels(){if(e.type!==G.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs);const t=this.tabViewID,n=this.contentModel.views.findByID(t);return(n==null?void 0:n.panels)??[]},get renderViewIDs(){const t=[e.id];return e.type===G.Tabs&&t.push(this.tabViewID),t},async downloadScreenshot(t){const n=t.offsetWidth*2+10,s=t.offsetHeight*2+10,i=new jc,a=new Date().getTime(),l=await _c.toBlob(t,{bgcolor:"white",width:n,height:s,style:{transformOrigin:"0 0",transform:"scale(2)"}});i.file(`${e.name}_${a}.png`,l),i.file(`dashboard_state_${a}.json`,JSON.stringify(this.contentModel.dashboardState,null,4)),i.generateAsync({type:"blob"}).then(c=>{os.saveAs(c,`${e.name}_${a}.zip`)}).catch(c=>{console.error(c),Yt.notifications.show({color:"red",title:"Failed to download screenshot with dashboard state",message:c.message})})}})).actions(e=>({setTab(t){e.tab=t??""},setTabByTabInfo(t){e.tab=t.id??""}})),jl=x.types.model("ViewsRenderModel",{current:x.types.optional(x.types.array(_l),[]),visibleViewIDs:x.types.array(x.types.string)}).views(e=>({get json(){return e.current.map(t=>cr(t.json))},get idMap(){const t=new Map;return e.current.forEach(n=>{t.set(n.id,n)}),t},findByID(t){return e.current.find(n=>n.id===t)},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:n})=>n===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:n})=>t.has(n))},get firstVisibleTabsView(){return this.visibleViews.find(t=>t.type===G.Tabs)},get firstVisibleTabsViewActiveTab(){const t=this.firstVisibleTabsView;return t?t.tabInfo:null}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(s=>s)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const n=e.visibleViewIDs.findIndex(s=>s===t);n!==-1&&e.visibleViewIDs.splice(n,1)},setFirstVisibleTabsViewActiveTab(t){if(!t)return;const n=e.firstVisibleTabsView;n==null||n.setTabByTabInfo(t)}}));function wf(e,t){const n=e.length>0?[e[0].id]:[],s=e.map(i=>{const{_name:a=i.type}=i.config,l={...i,tab:"",config:{...i.config,_name:a},panelIDs:i.panelIDs};if(i.type===G.Tabs){const c=v.minBy(i.config.tabs,u=>u.order);l.tab=(c==null?void 0:c.id)??""}return l});return t&&(s[0].tab=t.id),{current:s,visibleViewIDs:n}}const SE=new em.AsyncParser({withBOM:!0});async function Cf(e){return!Array.isArray(e)||e.length===0?"":await SE.parse(e).promise()}async function kE(e,t){const n=await Cf(t),s=new Blob([n],{type:"text/csv"});os.saveAs(s,`${e}.csv`)}function Sf(e){const t=new jc,n=e.map(async({id:s,data:i})=>{const a=await Cf(i);t.file(`${s}.csv`,a)});Promise.all(n).then(()=>{t.generateAsync({type:"blob"}).then(s=>{os.saveAs(s,"dashboard_data.zip")})}).catch(s=>{console.error(s),Yt.notifications.show({color:"red",title:"Failed to download data",message:s.message})})}function fr(e,t){const n=new Blob([t],{type:"application/json"});os.saveAs(n,`${e}.json`)}const wl=af.views(e=>({get contentModel(){return x.getRoot(e).content}})).views(e=>({get queries(){return e.contentModel.queries.findByIDSet(e.queryIDSet)},get firstQuery(){return this.queries.length>0?this.queries[0]:null},get firstQueryData(){return this.firstQuery?this.firstQuery.data:[]},queryByID(t){return this.queries.find(n=>n.id===t)},get data(){return this.queries.reduce((t,n)=>(t[n.id]=n.data,t),{})},get variableStrings(){return Bp(e.variables,this.data)},get variableAggValueMap(){const t={},n=this.data;return e.variables.reduce((s,i)=>(s[i.name]=nn(i,n),s),t),t},get variableValueMap(){const t={},n=this.variableAggValueMap;return e.variables.reduce((s,i)=>(s[i.name]=vt(i,n[i.name]),s),t),t},get variableStyleMap(){const t=this.variableValueMap,n={};return e.variables.reduce((s,i)=>{const a=u_(i.color,t[i.name]);return s[i.name]={color:a,"font-size":i.size,"font-weight":i.weight,variable:i},s},n),n},get dataLoading(){return this.queries.some(t=>t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(a=>!a.runByConditionsMet);if(t.length===0)return"";const n=new Set,s=new Set;t.forEach(a=>{const l=a.conditionNames;l.context.forEach(c=>n.add(c)),l.filters.forEach(c=>s.add(c))});const i=[];return n.size>0&&(console.log(n),i.push(`context: ${Array.from(n).join(", ")}`)),s.size>0&&i.push(`filter${s.size>1?"s":""}: ${Array.from(s).join(", ")}`),i.length===2&&i.splice(1,0,"and"),i.unshift("Waiting for"),i.join(" ")},get queryErrors(){return this.queries.map(t=>t.error).filter(t=>!!t)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading}})).actions(e=>({refreshData(){e.queries.forEach(t=>t.fetchData(!0))},downloadData(){e.contentModel.queries.downloadDataByQueryIDs(e.queryIDs)},getSchema(){const t=e.json;return t.viz.conf={...t.viz.conf,__INTERACTIONS:{},__OPERATIONS:{},__TRIGGERS:{}},{panel:t,queries:e.queries.map(n=>n.json),layouts:e.contentModel.layouts.jsonByPanelIDSet(new Set([e.id]))}},downloadSchema(){const{panel:t,queries:n,layouts:s}=this.getSchema(),a=JSON.stringify({panels:[t],definition:{queries:n},layouts:s,version:gn},null,2),l=e.name;fr(l,a)}}));function kf(e){return{id:e,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:Wo.name,conf:Wo.createConfig()},style:{border:{enabled:!0}}}}const Cl=x.types.model("PanelsRenderModel",{list:x.types.optional(x.types.array(wl),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(n=>n.id===t)},get idMap(){const t=new Map;return e.list.forEach(n=>{t.set(n.id,n)}),t}})).views(e=>({panelsByIDs(t){const n=[];return t.forEach(s=>{const i=e.idMap.get(s);i?n.push(i):console.warn(`Panel is not found, id:${s}`)}),n}}));function Tf(e){const t=e.config,n=t.default_value;if(n===void 0)return n;if(t._name==="date-range")try{if(t.default_shortcut){const i=Jh(t.default_shortcut);if(i)return i.map(a=>P(a).format(t.inputFormat))}const[...s]=n;return s.map(i=>i===null?i:P.tz(i,"UTC").format(t.inputFormat)??i)}catch(s){return console.error(s),n}return n}function TE(e,t){const n=e.default_value_func;try{return new Function(`return ${n}`)()(e,At,t)}catch(s){return console.error(s),Tf(e)}}function Df(e,t){var n;return(n=e.default_value_func)!=null&&n.trim()?TE(e,t):Tf(e)}function Mf(e,t){return e.reduce((n,s)=>(n[s.key]=Df(s,t),n),{})}const Sl=x.types.model("FiltersRenderModel",{current:x.types.optional(x.types.array(fl),[]),values:x.types.optional(x.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get valuesString(){return JSON.stringify(e.values)},get contentModel(){return x.getRoot(e).content},get context(){return this.contentModel.payloadForSQL.context},get initialValuesDep(){return JSON.stringify({filters:e.current.map(({default_value_func:t,config:n})=>({default_value_func:t,config:n})),context:this.contentModel.payloadForSQL.context})},get formattedDefaultValues(){return Mf(this.json,this.contentModel.context)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get inOrder(){return v.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return v.sortBy(e.current.filter(n=>n.visibleInViewsIDSet.has(t)),"order")},get firstFilterValueKey(){return Object.keys(e.values)[0]??""},get keySet(){return new Set(e.current.map(t=>t.key))},get keyLabelMap(){return e.current.reduce((t,n)=>(t[n.key]=n.label,t),{})},getSelectOption(t){const n=this.findByID(t);if(!n||!("getSelectOption"in n.config))return null;const s=e.values[n.key];return n.config.getSelectOption(s)}})).actions(e=>({setValues(t){console.debug("⚪️ setting filter values: ",JSON.stringify(t)),e.values=t},patchValues(t){console.debug("⚪️ patching filter values: ",JSON.stringify(t)),e.values=v.defaults({},t,e.values)},setValueByKey(t,n){console.debug(`⚪️ setting filter[${t}] to value: `,JSON.stringify(n)),e.values={...e.values,[t]:n}},applyValuesPatch(t){e.values={...e.values,...t}},getValueByKey(t){return e.values[t]},getSchema(t,n){return{filters:e.findByIDSet(new Set(t)).map(a=>({...a.json,visibleInViewsIDs:n?a.json.visibleInViewsIDs:[]})),version:gn}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t,!1),null,2);fr("Filters",n)}}));function kl(e,t,n,s){const i=v.defaults({},s,Mf(e,{...n,...t}));return{current:e,values:i}}const If=of.views(e=>({get rootModel(){return x.getRoot(e)},get contentModel(){return this.rootModel.content},get conditionOptions(){if(!x.isAlive(e))return[];const{context:t}=this.contentModel.payloadForSQL,n=Object.keys(t).map(l=>({group:"Context",label:l,value:`context.${l}`,description:void 0})),s=this.contentModel.filters.keyLabelOptions.map(l=>({group:"Filters",label:l.label,value:`filters.${l.value}`,description:l.value})),i=[...n,...s],a=new Set(i.map(l=>l.value));return e.run_by.forEach(l=>{a.has(l)||i.push({group:"Invalid",label:l,value:l})}),i},get unmetRunByConditions(){if(!x.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const n=this.contentModel.payloadForSQL;return t.filter(s=>{const i=v.get(n,s);return Array.isArray(i)?i.length===0:typeof i=="number"?Number.isNaN(i):!i})}})).views(e=>({get payload(){return e.contentModel.payloadForSQL},get formattedSQL(){return Mi(e.sql,this.payload)},get httpConfigString(){const{context:t,filters:n}=this.payload,{name:s,pre_process:i}=e.json,a=b_(i,t,n);return console.groupCollapsed(`Request config for: ${s}`),console.log(a),console.groupEnd(),JSON.stringify(a)},get typedAsSQL(){return[Ee.Postgresql,Ee.MySQL].includes(e.type)},get typedAsHTTP(){return[Ee.HTTP].includes(e.type)},get isTransform(){return e.type===Ee.Transform},get reQueryKey(){const{react_to:t=[]}=e;if(t.length===0)return"";const n=e.contentModel.payloadForSQL,s=[...t].reduce((i,a)=>(i[a]=v.get(n,a),i),{});return JSON.stringify(s)},get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=e.contentModel.filters,n=e.unmetRunByConditions.filter(i=>i.startsWith("context.")).map(i=>i.replace("context.","")),s=e.unmetRunByConditions.filter(i=>i.startsWith("filters.")).map(i=>v.get({filters:t},i,i.replace("filters.",""))).filter(i=>!!i);return{context:n,filters:s}},get queries(){return x.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)},get dependencies(){if(!this.typedAsSQL)return[];const t=v.uniq(e.sql.match(Xs.sqlSnippet)),n=v.uniq(e.sql.match(Xs.filter)),s=v.uniq(e.sql.match(Xs.context)),i=[];return t.forEach(a=>{i.push({type:"sql_snippet",key:a,valid:e.contentModel.sqlSnippets.keySet.has(a)})}),n.forEach(a=>{i.push({type:"filter",key:a,valid:e.contentModel.filters.keySet.has(a)})}),s.forEach(a=>{i.push({type:"context",key:a,valid:e.contentModel.mock_context.keySet.has(a)})}),i}})),Tl=x.types.compose("QueryRenderModel",If,x.types.model({state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),data:x.types.optional(x.types.frozen([]),[]),error:x.types.frozen()})).views(e=>({get datasource(){const{key:t,type:n}=e;return e.rootModel.datasources.find({type:n,key:t})},get additionalQueryInfo(){return e.contentModel.getAdditionalQueryInfo(e.id)},get depQueryModels(){return e.contentModel.queries.findByIDSet(new Set(e.dep_query_ids))},get depQueryModelStates(){return this.depQueryModels.map(t=>t.state)},get depQueryModelStatesString(){return this.depQueryModelStates.toString()}})).views(e=>({get stateMessage(){if(e.state!=="idle")return"";if(!e.runByConditionsMet){const{context:t,filters:n}=e.conditionNames;if(t.length===0&&n.length===0)return"Waiting";const s=[];return t.length>0&&s.push(`context: ${t.join(", ")}`),n.length>0&&s.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),s.length===2&&s.splice(1,0,"and"),s.unshift("Waiting for"),s.join(" ")}return e.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:x.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const n=e.payload;e.data=yield*x.toGenerator(T_({payload:n,name:e.name,query:e.json,additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(Rt.isCancel(n))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const s=v.get(n,"message","unkown error");e.error=v.get(n,"response.data.detail.message",s),e.state="error"}}}}),runHTTP:x.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{type:n,key:s,post_process:i}=e.json;let a=JSON.parse(e.httpConfigString);a=v_(e.datasource,a);const l=yield*x.toGenerator(D_({type:n,key:s,configString:JSON.stringify(a),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=__(e.datasource,l),u=j_(i,c,e.contentModel.dashboardState);e.data=u,e.state="idle",e.error=null}catch(n){if(console.error(n),Rt.isCancel(n))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const s=v.get(n,"message","unkown error");e.error=v.get(n,"response.data.detail.message",s),e.state="error"}}}}),runTransformation(){e.state="loading";try{const n=e.contentModel.queries.findByIDSet(new Set(e.dep_query_ids)).map(l=>({id:l.id,name:l.name,data:v.cloneDeep(l.data)})),s=e.contentModel.dashboardState,i=e.pre_process,a=new Function(`return ${i}`)()(n,s,At);e.data=a,e.state="idle",e.error=null}catch(t){e.data=[],e.error=t.message,e.state="error"}}})).actions(e=>({fetchData:t=>{if(!e.inUse&&!t){console.debug(`🟡 Skipping query[${e.name}]`);return}return console.debug(`🔵 Running query[${e.name}]`),e.isTransform?e.runTransformation():e.typedAsHTTP?e.runHTTP():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){x.addDisposer(e,ae.reaction(()=>{var n;return e.isTransform?[e.inUse,e.id,e.key,e.dep_query_ids.toString(),e.pre_process,e.depQueryModelStatesString].join("--"):e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(n=e.datasource)==null?void 0:n.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},t=>(e.name==="getProjectGroupContributors"&&console.log("🔵 deps: ",t),e.fetchData(!1)),{fireImmediately:!0,delay:0}))}})),Dl=x.types.model("QueriesRenderModel",{current:x.types.optional(x.types.array(Tl),[])}).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get contentModel(){return x.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:n,queries:s}=this.contentModel,i=[];t.visibleViews.forEach(c=>{c.panels.forEach(u=>{i.push(...u.queryIDs)})});const a=v.uniq(t.visibleViews.map(c=>c.renderViewIDs).flat());n.current.forEach(c=>{const u=v.get(c,"config.options_query_id");if(!u)return;a.some(h=>c.visibleInViewsIDSet.has(h))&&i.push(u)}),s.findByIDSet(new Set(i)).forEach(c=>{!c.isTransform||c.dep_query_ids.length===0||i.push(...c.dep_query_ids)});const l=new Set(i);return console.debug("QueryIDs:",l),l},isQueryInUse(t){return this.visibleQueryIDSet.has(t)}})).actions(e=>({downloadAllData(){const t=e.current.map(({name:n,data:s})=>({id:n,data:s}));Sf(t)},downloadDataByQueryIDs(t){const n=new Set(t),s=e.current.filter(i=>n.has(i.id)).map(({name:i,data:a})=>({id:i,data:a}));Sf(s)},downloadDataByQueryID(t){const n=e.findByID(t);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:s,data:i}=n;kE(s,i)},refetchDataByQueryID(t){const n=e.findByID(t);if(!n){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return n.fetchData(!0)},getSchema(t){return{definition:{queries:e.findByIDSet(new Set(t)).map(i=>i.json)},version:gn}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t),null,2);fr("Queries",n)}}));function zf(e){return{current:e}}function Ef({min:e,max:t}){const n=`${e}px`,s=Number.isFinite(t)?`${t}px`:"∞";return`[${n}, ${s})`}const Ml=x.types.model("LayoutsRenderModel",{list:x.types.array(cf),currentBreakpoint:x.types.string}).views(e=>({get json(){return e.list.map(t=>t.json)},jsonByPanelIDSet(t){return e.list.map(n=>n.jsonByPanelIDSet(t))},get root(){return x.getRoot(e)},get contentModel(){return this.root.content},get basisLayoutSet(){return e.list.find(t=>t.id==="basis")},get currentLayoutSet(){return e.list.find(t=>t.id===e.currentBreakpoint)},get currentLayoutRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentRangeText(){const t=this.currentLayoutRange;return Ef(t)},get cols(){const t={};return e.list.forEach(n=>{t[n.id]=36}),t},get breakpoints(){const t={};return e.list.forEach(n=>{t[n.id]=n.breakpoint}),t},get breakpointNameRecord(){const t={};return e.list.forEach(n=>{t[n.name]=n.breakpoint}),t},get breakpointRanges(){const t=e.list.map(n=>({id:n.id,name:n.name,min:n.breakpoint,max:1/0,text:""}));return t.sort((n,s)=>n.min-s.min).forEach((n,s)=>{s!==t.length-1&&(n.max=t[s+1].min)}),t.forEach(n=>{n.text=Ef(n)}),t},get breakpointsInfo(){return e.list.map(t=>({id:t.id,name:t.name,breakpoint:t.breakpoint})).sort((t,n)=>t.breakpoint-n.breakpoint)},get currentBreakpointRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentLayoutPreviewWidth(){const t=this.currentBreakpointRange;if(t)return t.max===1/0?t.min===0?void 0:t.min+1:t.max},items(t){const n=new Set(t);return this.currentLayoutSet.list.filter(i=>n.has(i.panelID))},gridLayouts(t){const n=new Set(t),s={};return e.list.forEach(i=>{s[i.id]=i.list.filter(a=>n.has(a.panelID)).map(a=>a.layoutProperies)}),s},findItemByPanelID(t){return this.currentLayoutSet.findByPanelID(t)}})).actions(e=>({setCurrentBreakpoint(t){console.log("🔴 onBreakpointChange:",t),e.currentBreakpoint=t},afterCreate(){x.addDisposer(e,ae.reaction(()=>e.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),Af=uf.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!x.getParent(e,2).findByKey(t)}})),Il=x.types.model("SQLSnippetsRenderModel",{current:x.types.optional(x.types.array(Af),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,n)=>(t[n.key]=n.value,t),{})},get keySet(){return new Set(e.current.map(t=>t.key))},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(n=>n.key===t)},findByKeySet(t){return e.current.filter(n=>t.has(n.key))}})).actions(e=>({getSchema(t){return{definition:{sqlSnippets:e.findByKeySet(new Set(t)).map(i=>i.json)},version:gn}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t),null,2);fr("SQL Snippets",n)}}));function Pf(e){return{current:e}}function es(e,t,n,s){return e.reduce((i,a)=>{try{i[a[t]]=Di(a[n],s)}catch(l){i[a[t]]=l.message}return i},{})}class Of{constructor(t){N(this,"origin");N(this,"copy");this.origin=t,this.copy=x.clone(t),ae.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!v.isEqual(x.getSnapshot(this.origin),x.getSnapshot(this.copy))}commit(){x.applySnapshot(this.origin,x.getSnapshot(this.copy))}reset(){x.applySnapshot(this.copy,x.getSnapshot(this.origin))}update(t){x.applySnapshot(this.copy,t)}}const Lf=e=>new Of(e),DE=D.observer(()=>{const{t:e}=j.useTranslation(),t=le(),{panel:n}=Je(),s=n.realQueryOptions,i=a=>{t.editor.open(["_QUERIES_",a])};return s.length===0?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{label:e(s.length>1?"query.labels":"query.label"),labelPosition:"center"}),s.map(a=>r.jsx(o.Menu.Item,{onClick:()=>i(a.value),icon:r.jsx(M.IconDatabase,{size:14}),children:a.label},a.value))]})}),ME=D.observer(({view:e,title:t})=>{const{t:n}=j.useTranslation(),s=le(),i=re(),a=wt.useModals(),{panel:l,downloadPanelScreenshot:c}=Je(),{id:u}=l,{viewPanelInFullScreen:d,inFullScreen:h}=g.useContext(pi),p=()=>{i.duplicatePanelByID(u,e.id)},f=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u])},m=()=>a.openConfirmModal({title:`${n("panel.delete")}?`,labels:{confirm:n("common.actions.confirm"),cancel:n("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.removePanelByID(u,e.id),confirmProps:{color:"red"},zIndex:320}),y=g.useCallback(()=>{d(u)},[u,d]),_=!h&&e.type!==G.Modal;return r.jsx(r.Fragment,{children:r.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:r.jsxs(o.Menu,{withinPortal:!0,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{onClick:l.refreshData,icon:r.jsx(W.Refresh,{size:14}),children:n("common.actions.refresh")}),r.jsx(o.Menu.Item,{onClick:l.downloadData,icon:r.jsx(W.Download,{size:14}),children:n("common.actions.download_data")}),r.jsx(o.Menu.Item,{onClick:l.downloadSchema,icon:r.jsx(M.IconCode,{size:14}),children:n("common.actions.download_schema")}),r.jsx(o.Menu.Item,{onClick:c,icon:r.jsx(M.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),_&&r.jsx(o.Menu.Item,{onClick:y,icon:r.jsx(W.ArrowsMaximize,{size:14}),disabled:!0,children:n("common.actions.enter_fullscreen")}),r.jsx(DE,{}),r.jsx(o.Divider,{label:n("common.actions.edit"),labelPosition:"center"}),r.jsx(o.Menu.Item,{onClick:f,icon:r.jsx(W.Settings,{size:14}),children:n("common.titles.settings")}),r.jsx(o.Menu.Item,{onClick:p,icon:r.jsx(W.Copy,{size:14}),children:n("common.actions.duplicate")}),r.jsx(o.Menu.Item,{color:"red",onClick:m,icon:r.jsx(W.Trash,{size:14}),children:n("common.actions.delete")})]})]})})})});function IE(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const zl=D.observer(()=>{const{t:e}=j.useTranslation(),[t,n]=g.useState(!1),{panel:s}=Lt();return IE(s.description)?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:()=>n(!1),title:s.title.show?s.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:r.jsx(Kr,{value:s.description,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}}})}),r.jsx(o.Tooltip,{label:e("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:r.jsx(W.InfoCircle,{size:20})})})]})}),bV="",zE=D.observer(function(){const{panel:t}=Lt(),{name:n,title:s}=t;return s.show?r.jsx(o.Group,{grow:!0,position:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:r.jsx(o.Text,{align:"center",lineClamp:1,className:"panel-title-text",children:n})}):null});function EE(e){const t=g.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const s=t.current;if(!s)return;const i=s.offsetWidth*2,a=s.offsetHeight*2;_c.toBlob(t.current,{bgcolor:"white",width:i,height:a,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(l=>{window.saveAs(l,`${e.name?e.name:e.viz.type}.png`)})}}}var Vf=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(Vf||{}),gi=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(gi||{});class AE{constructor(t){N(this,"vizInstance");N(this,"operationManager");N(this,"triggerManager");N(this,"vizManager");N(this,"runningMigration");N(this,"panelModel");N(this,"status","notStarted");this.panelModel=t.getRequired(Oe.instanceScope.panelModel),this.vizInstance=t.getRequired(Oe.instanceScope.vizInstance),this.operationManager=t.getRequired(Oe.instanceScope.operationManager),this.triggerManager=t.getRequired(Oe.instanceScope.triggerManager),this.vizManager=t.getRequired(Oe.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(t=>(this.status="done",t))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(n)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return t.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function Bf(e){const{panel:t}=Lt();return g.useCallback(n=>{const s=n.getRequired(Oe.vizManager),i=s.resolveComponent(e.viz.type);return n.createScoped().provideFactory(Oe.instanceScope.vizInstance,()=>s.getOrCreateInstance(e)).provideFactory(Oe.instanceScope.interactionManager,a=>{const l=a.getRequired(Oe.instanceScope.vizInstance);return new yo(l,i,Hs)}).provideFactory(Oe.instanceScope.operationManager,a=>a.getRequired(Oe.instanceScope.interactionManager).operationManager).provideFactory(Oe.instanceScope.triggerManager,a=>a.getRequired(Oe.instanceScope.interactionManager).triggerManager).provideValue(Oe.instanceScope.panelModel,t).provideFactory(Oe.instanceScope.migrator,a=>new AE(a))},[e.viz.type,e.viz.conf])}function qf(e){const[t,n]=g.useState(!1),s=Xh().getRequired(Oe.instanceScope.migrator);return J.useAsyncEffect(async()=>{const i=s.status===gi.notStarted;n(s.status===gi.done),s.status===gi.notStarted&&s.runMigration().then(a=>{a===Vf.migrated&&i&&(e==null||e())}).finally(()=>{n(!0)})},[s]),t}function Nf(e,t){const n=Xh().getRequired(Oe.instanceScope.vizInstance);return g.useEffect(()=>(n.instanceData.setItem(null,t.viz.conf),n.instanceData.watchItem(null,s=>{e(s)})),[e,t.viz.type]),n}function PE({setVizConf:e,...t}){const{panel:n}=t,s=Nf(e,n),i=qf(()=>{Yt.showNotification({title:`${n.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return J.useAsyncEffect(async()=>{await s.instanceData.setItem(null,n.viz.conf)},[s,n.viz.type]),i?r.jsx(E_,{...t}):r.jsx(o.Text,{children:"Checking update..."})}function OE(e){const{panel:t,setVizConf:n}=e;Nf(n,t);const{inEditMode:s}=g.useContext(Ss);return qf(()=>{s&&Yt.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?r.jsx(z_,{...e}):r.jsx(o.Text,{children:"Checking update"})}const vV="";function LE(e,t){const{vizManager:n}=g.useContext(rn),{panel:{viz:s,title:i,id:a,name:l,description:c,queryIDs:u,variables:d}}=Lt(),h={id:a,name:l,title:i,description:c,queryIDs:u,viz:s},p=Bf(h);try{return n.resolveComponent(s.type),r.jsx(di,{configure:p,children:r.jsx(OE,{setVizConf:s.setConf,panel:h,measure:t,data:e,variables:d,vizManager:n})})}catch(f){return console.info(v.get(f,"message")),null}}const $f=D.observer(function({data:t}){const{ref:n,width:s,height:i}=Se.useElementSize(),a=LE(t,{w:s,h:i}),l=s>0&&i>0;return r.jsx("div",{className:"viz-root",ref:n,children:r.jsx(o.Box,{sx:{width:s,height:i,overflow:"hidden"},children:l&&r.jsx(Re,{children:a})})})}),Ff=D.observer(({panel:e})=>r.jsxs(o.Stack,{children:[e.queryErrors.map((t,n)=>r.jsx(o.Text,{color:"red",size:"sm",align:"center",sx:{fontFamily:"monospace"},children:t},`${n}-${t}`)),r.jsx(o.Text,{color:"gray",align:"center",size:"sm",children:e.queryStateMessages})]})),El=D.observer(({panel:e})=>r.jsxs(o.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[r.jsx(o.LoadingOverlay,{visible:e.dataLoading,exitTransitionDuration:0}),!e.canRenderViz&&r.jsx(Ff,{panel:e}),e.canRenderViz&&r.jsx($f,{data:e.data})]})),VE={border:"1px solid #e9ecef"},Gf=D.observer(({panel:e,panelStyle:t,dropdownContent:n})=>{const{ref:s,downloadPanelScreenshot:i}=EE(e);return e.title.show,r.jsx(ra,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:i},children:r.jsxs(o.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,ref:s,p:0,sx:{...VE,...t},children:[r.jsx(o.Box,{className:"panel-description-popover-wrapper",children:r.jsx(zl,{})}),n,r.jsx(zE,{}),r.jsx(El,{panel:e})]})})}),BE={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function qE(e){return e.style.border.enabled?{}:BE}const Wf=D.observer(function({panel:t,view:n}){const s=qE(t);return r.jsx(Gf,{panel:t,panelStyle:s,dropdownContent:r.jsx(ME,{view:n,title:t.name})})});function NE(e){return!["richText","button"].includes(e)}const $E=D.observer(({view:e,title:t})=>{const{t:n}=j.useTranslation(),{panel:s,downloadPanelScreenshot:i}=Lt(),{id:a}=s,{viewPanelInFullScreen:l,inFullScreen:c}=g.useContext(pi),u=g.useCallback(()=>{l(a)},[a,l]),d=!c&&e.type!==G.Modal;return NE(s.viz.type)?r.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:r.jsxs(o.Menu,{withinPortal:!0,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Box,{className:"panel-dropdown-target"})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{onClick:s.refreshData,icon:r.jsx(W.Refresh,{size:14}),children:n("common.actions.refresh")}),r.jsx(o.Menu.Item,{onClick:s.downloadData,icon:r.jsx(W.Download,{size:14}),children:n("common.actions.download_data")}),r.jsx(o.Menu.Item,{onClick:i,icon:r.jsx(M.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),d&&r.jsx(o.Menu.Item,{onClick:u,icon:r.jsx(W.ArrowsMaximize,{size:14}),children:n("common.actions.enter_fullscreen")})]})]})}):null});function FE(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const Al=D.observer(({panel:e,view:t})=>{const n=FE(e);return r.jsx(Gf,{panel:e,panelStyle:n,dropdownContent:r.jsx($E,{title:e.name,view:t})})}),GE={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},Rf=D.observer(function({view:t,panel:n,exitFullScreen:s}){return r.jsx(o.Modal,{opened:!0,fullScreen:!0,onClose:s,title:r.jsx(o.Button,{color:"blue",size:"xs",onClick:s,leftIcon:r.jsx(W.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:GE,children:r.jsx(o.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:r.jsx(Al,{view:t,panel:n})})})});function Qf(e,t,n){const{panels:s}=Pe(),i=e.id==="Main",[a,l]=g.useState(()=>i&&s.findByID(t)?t:null),c=g.useCallback(p=>{l(p),i&&n(p)},[i,n]),u=g.useCallback(()=>{l(null),i&&n("")},[i,n]),d=a?s.findByID(a):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const _V="",WE=g.forwardRef(({h:e},t)=>r.jsx(o.ActionIcon,{ref:t,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:e>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:r.jsx(W.ArrowsMove,{size:16})})),RE=g.forwardRef(({handleAxis:e,...t},n)=>r.jsx(o.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:r.jsx(W.ChevronDownRight,{size:16})})),QE=as.WidthProvider(as.Responsive),UE=D.observer(({view:e,className:t="layout"})=>{const s=re().layouts,i=s.items(e.panelIDs),a=s.gridLayouts(e.panelIDs),l=(d,h,p,f)=>{console.log("🔴 onResize",d),p.h<30&&(p.h=30,f.h=30),p.w<4&&(p.w=4,f.w=4)},c=(d,h,p)=>{console.log("🔴 onResizeStop",{layouts:d,oldItem:h,newItem:p}),s.updateCurrentLayoutItem(p)},u=(d,h,p)=>{console.log("🔴 onDragStop",{layouts:d,oldItem:h,newItem:p}),s.updateCurrentLayoutItems(d)};return r.jsx(QE,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:s.cols,layouts:a,draggableHandle:".react-grid-customDragHandle",resizeHandle:r.jsx(RE,{}),onResize:l,breakpoints:s.breakpoints,onBreakpointChange:s.setCurrentBreakpoint,onResizeStop:c,onDragStop:u,width:s.currentLayoutPreviewWidth,children:i.map(d=>r.jsxs("div",{"data-grid":d.layoutProperies,className:"panel-grid-item",children:[r.jsx(WE,{h:d.h}),r.jsx(Wf,{view:e,panel:d.panel})]},d.id))})}),YE=as.WidthProvider(as.Responsive),KE=D.observer(({view:e,className:t="layout"})=>{const n=Pe(),s=n.layouts.items(e.panelIDs),i=n.layouts.gridLayouts(e.panelIDs);return r.jsx(YE,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:n.layouts.cols,layouts:i,breakpoints:n.layouts.breakpoints,onBreakpointChange:n.layouts.setCurrentBreakpoint,children:s.map(a=>r.jsx("div",{"data-grid":a.layoutProperies,className:"panel-grid-item",children:r.jsx(Al,{view:e,panel:a.panel})},a.id))})});function Pl(e){const t=g.useRef(null);return{ref:t,downloadScreenshot:()=>{var i;const s=(i=t.current)==null?void 0:i.querySelector(".react-grid-layout");s&&e.downloadScreenshot(s)}}}const XE=D.observer(({downloadScreenshot:e})=>{const{t}=j.useTranslation(),[n,{setTrue:s,setFalse:i}]=J.useBoolean(!1),a=wu(),l=Pe(),c=()=>{const u=JSON.stringify(l.contentJSON,null,2),d=`${a.name}__${l.name}`;fr(d,u)};return r.jsxs(o.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:r.jsx(o.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:s,onMouseLeave:i,sx:{opacity:n?1:.6,transform:`translateX(${n?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:r.jsx(M.IconShare3,{size:"1rem"})})})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{icon:r.jsx(M.IconCamera,{size:14}),onClick:e,children:t("common.actions.download_screenshot")}),r.jsx(o.Menu.Divider,{}),r.jsx(o.Menu.Item,{icon:r.jsx(M.IconDownload,{size:14}),onClick:l.queries.downloadAllData,children:t("common.actions.download_data")}),r.jsx(o.Menu.Item,{icon:r.jsx(M.IconCode,{size:14}),onClick:c,children:t("common.actions.download_schema")})]})]})}),Uf=D.observer(({children:e,view:t,sx:n={}})=>{const{ref:s,downloadScreenshot:i}=Pl(t);return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{ref:s,pt:10,pb:10,sx:n,children:e}),r.jsx(XE,{downloadScreenshot:i})]})}),Yf=D.observer(({downloadScreenshot:e})=>r.jsx(o.ActionIcon,{className:"download-screenshot-button",color:"blue",onClick:e,children:r.jsx(M.IconCamera,{size:14})})),JE=D.observer(({children:e,view:t})=>{const n=Pe(),s=t.config,i=n.views.visibleViewIDs.includes(t.id),a=()=>n.views.rmVisibleViewID(t.id),{ref:l,downloadScreenshot:c}=Pl(t);return r.jsx(o.Modal,{size:s.width,centered:!0,opened:i,onClose:a,withCloseButton:!1,title:r.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[r.jsx(o.Box,{children:s.custom_modal_title.value}),r.jsx(Yf,{downloadScreenshot:c})]}),trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:s.height,overflow:"auto",position:"relative",paddingBottom:10},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:r.jsx(o.Box,{ref:l,children:e})})}),ZE=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},HE=D.observer(({view:e})=>{const t=Pe(),n=e.config;return r.jsxs(o.Tabs,{className:"render-view-tabs",variant:n.variant,orientation:n.orientation,value:e.tab,onTabChange:e.setTab,styles:{root:{height:"100%",overflow:n.orientation==="horizontal"?"hidden":"auto"},panel:{padding:n.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[r.jsx(o.Tabs.List,{grow:n.grow,children:n.tabsInOrder.map(s=>r.jsx(o.Tabs.Tab,{value:s.id,sx:ZE(s),disabled:!s.view_id,children:s.name??s.id},s.id))}),n.tabsInOrder.map(s=>{const i=t.views.findByID(s.view_id);return i?r.jsx(o.Tabs.Panel,{value:s.id,children:r.jsx(mi,{view:i})},s.id):null})]})}),eA=D.observer(({view:e,children:t})=>{switch(e.type){case G.Modal:return r.jsx(JE,{view:e,children:t});case G.Tabs:return r.jsx(HE,{view:e});case G.Division:default:return r.jsx(Uf,{view:e,children:t})}}),tA=D.observer(({children:e,view:t})=>{const s=re().layouts,[i,a]=Se.useResizeObserver();return g.useEffect(()=>{s.setCurrentLayoutWrapperWidth(a.width)},[a.width]),r.jsx(o.Box,{sx:{height:"100%"},ref:i,children:r.jsx(o.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:s.currentLayoutPreviewWidth??"100%",transform:`scale(${s.divisionPreviewScale})`,transformOrigin:"0 0"},children:r.jsx(Uf,{view:t,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:e})})})});function Kf(e){return e.replace(/(vw|vh)/,"%")}const nA=D.observer(({children:e,view:t})=>{const n=t.config,{width:s,height:i}=g.useMemo(()=>({width:Kf(n.width),height:Kf(n.height)}),[n.width,n.height]),{ref:a,downloadScreenshot:l}=Pl(t);return r.jsx(o.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:r.jsx(o.Modal,{size:n.width,opened:!0,onClose:v.noop,withCloseButton:!1,title:r.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[r.jsx(o.Box,{children:n.custom_modal_title.value}),r.jsx(Yf,{downloadScreenshot:l})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:s,height:i,maxHeight:i},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:r.jsx(o.Box,{ref:a,children:e})})})}),rA=({variant:e,orientation:t})=>{const n={root:{height:"100%",overflow:"hidden"},tabsList:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(n.tab.paddingTop="6px",n.tab.paddingBottom="6px"),t==="vertical"&&(n.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},n.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),n},sA=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},iA=D.observer(({view:e})=>{const{t}=j.useTranslation(),n=wt.useModals(),s=re(),i=g.useMemo(()=>s.views.options.filter(u=>u.type===G.Division),[e.id,s.views.options]),a=e.config,l=u=>n.openConfirmModal({title:`${t("view.component.tabs.tab.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{a.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),c=a.tabs.length===0;return r.jsxs(o.Tabs,{className:"preview-view-tabs",variant:a.variant,orientation:a.orientation,value:e.tab,onTabChange:e.setTab,styles:rA(a),children:[r.jsxs(o.Tabs.List,{grow:a.grow,children:[a.tabsInOrder.map(u=>r.jsx(o.Tabs.Tab,{value:u.id,sx:sA(u),children:u.name??u.id},u.id)),r.jsx(o.Tabs.Tab,{onClick:a.addTab,value:"add",className:"add-a-tab",children:r.jsx(W.Plus,{size:18,color:"#228be6"})})]}),a.tabsInOrder.map((u,d)=>{const h=s.views.findByID(u.view_id);return r.jsxs(o.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[r.jsxs(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[r.jsx(o.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),r.jsxs(o.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[r.jsx(o.TextInput,{label:t("view.component.tabs.tab.name"),required:!0,value:u.name,onChange:p=>u.setName(p.currentTarget.value)}),r.jsx(o.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:i}),r.jsx(o.NumberInput,{label:t("view.component.tabs.tab.order"),required:!0,value:u.order,onChange:p=>u.setOrder(p||0),min:0,max:1e3,step:1}),r.jsx(o.ColorInput,{label:t("view.component.tabs.tab.color"),value:u.color,onChange:u.setColor,disabled:a.variant!=="default"}),h&&r.jsx(o.Button,{mt:20,variant:"gradient",leftIcon:r.jsx(M.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>s.views.setIDOfVIE(h.id),children:t("view.component.tabs.tab.switch_to_view",{name:h.name})}),r.jsx(o.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>l(d),disabled:c,leftIcon:r.jsx(M.IconTrash,{size:14}),children:t("view.component.tabs.tab.delete")})]})]}),h&&r.jsx(mi,{view:h})]},u.id)})]})}),aA=D.observer(({view:e,children:t})=>{switch(e.type){case G.Modal:return r.jsx(nA,{view:e,children:t});case G.Tabs:return r.jsx(iA,{view:e});case G.Division:default:return r.jsx(tA,{view:e,children:t})}}),Xf=D.observer(function({view:t}){const s=re().layouts.divisionPreviewScale!==1;return r.jsx(pi.Provider,{value:{viewPanelInFullScreen:v.noop,inFullScreen:!1},children:r.jsx(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:s?"transparent":"#efefef"},children:r.jsx(aA,{view:t,children:r.jsxs(o.Box,{sx:{position:"relative"},children:[r.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:r.jsx(ef,{view:t})}),r.jsx(UE,{view:t})]})})})})}),mi=D.observer(function({view:t}){const{fullScreenPanelID:n,setFullScreenPanelID:s}=Eu(),{viewPanelInFullScreen:i,exitFullScreen:a,inFullScreen:l,fullScreenPanel:c}=Qf(t,n,s);return r.jsx(pi.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:l},children:r.jsxs(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===G.Modal?"0 !important":"100%"},children:[l&&r.jsx(Rf,{view:t,panel:c,exitFullScreen:a}),r.jsx(eA,{view:t,children:r.jsxs(o.Box,{sx:{position:"relative"},children:[!l&&r.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:r.jsx(ef,{view:t})}),!l&&r.jsx(KE,{view:t})]})})]})})});var Jf=(e=>(e.Use="use",e.Edit="edit",e))(Jf||{});const oA={[G.Division]:"Division",[G.Tabs]:"Tabs",[G.Modal]:"Modal"},Zf={[G.Division]:"rgba(255, 0, 0, 0.2)",[G.Modal]:"rgba(0, 0, 0, 0.2)",[G.Tabs]:"rgba(255, 200, 100, 0.4)"},lA={[G.Division]:"#ff4000",[G.Modal]:"#000",[G.Tabs]:"#ffad18"};function cA(e,t,n){x.addDisposer(e,x.addMiddleware(e,(s,i)=>{i(s,()=>{x.getType(s.context)===t&&s.type==="action"&&n(s.name,s.context)})}))}const Hf=x.types.compose("FiltersModel",Sl,x.types.model("FiltersModel",{previewValues:x.types.optional(x.types.frozen(),{})})).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get keySet(){return new Set(e.current.map(t=>t.key))},get options(){return e.current.map(t=>({label:t.label??t.id,value:t.id,_type:"filter"}))},get selects(){return e.current.filter(t=>t.type===Ce.Select).map(t=>({label:t.label??t.id,value:t.id}))},get keyLabelOptions(){return e.current.map(t=>({label:t.label??t.key,value:t.key}))},get sortedList(){return v.sortBy(e.current,t=>t.label.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.idSet.has(s.id));e.current.push(...n)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(s=>s.id===t);n>=0&&e.current.splice(n,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){cA(e.current,fl,(n,s)=>{if(n==="setType"){const i=Df(s.config.default_value,s.config);e.setValueByKey(s.key,i),e.updatePreviewValues({...e.previewValues,[s.key]:i})}})}return{afterCreate(){t()}}}),eg=Tl.views(e=>({get canPreviewData(){return e.isTransform?e.dep_query_ids.length>0&&!!e.pre_process:!!e.datasource},get guideToPreviewData(){return e.isTransform?"Need to complete settings in Transform tab":"Need to pick a Data Source first"}})),tg=x.types.compose("QueriesModel",Dl,x.types.model({current:x.types.optional(x.types.array(eg),[])})).views(e=>({get options(){const t=e.current.map(n=>({value:n.id,label:n.name,_type:"query"}));return v.sortBy(t,n=>n.label.toLowerCase())},get optionsWithoutTransform(){const t=e.current.filter(n=>n.type!==Ee.Transform).map(n=>({value:n.id,label:n.name,_type:"query"}));return v.sortBy(t,n=>n.label.toLowerCase())},get sortedList(){return v.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.idSet.has(s.id));e.current.push(...n)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},removeQuery(t){const n=e.current.find(s=>s.id===t);n&&(x.detach(n),e.current.remove(n))},removeQueries(t){const n=new Set(t);e.current.forEach(i=>{n.has(i.id)&&x.detach(i)});const s=[...e.current];v.remove(s,i=>n.has(i.id)),e.current=x.cast(s)}})),ng=Il.views(e=>({get sortedList(){return v.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(n=>({label:n.key,value:n.key,_type:"sql_snippet"}));return v.sortBy(t,n=>n.label.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.keySet.has(s.key));e.current.push(...n)},remove(t){e.current.splice(t,1)},removeByKey(t){const n=e.current.findIndex(s=>s.key===t);n>=0&&e.current.splice(n,1)},removeByKeys(t){const n=new Set(t);e.current.forEach(i=>{n.has(i.key)&&x.detach(i)});const s=[...e.current];v.remove(s,i=>n.has(i.key)),e.current=x.cast(s)},replaceByIndex(t,n){e.current.splice(t,1,n)}})),uA=x.types.model({data:x.types.optional(x.types.frozen(),[]),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),dA=x.types.model({data:x.types.optional(x.types.frozen(),[]),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),pA=x.types.model({page:x.types.optional(x.types.number,1),limit:x.types.optional(x.types.number,20),data:x.types.optional(x.types.frozen(),[]),total:x.types.optional(x.types.number,0),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get keywords(){return x.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:n}=x.getParent(e,1);return`${n}||${t}`}})).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0},get maxPage(){return Math.ceil(e.total/e.limit)},get offset(){return(e.page-1)*e.limit},get countSql(){const{table_name:t,table_schema:n}=e.keywords;return`
471
471
  SELECT count(*) AS total
472
472
  FROM ${n}.${t}
473
473
  `}})).actions(e=>({setPage(t){e.page=t},resetPage(){e.page=1},setLimit(t){e.limit=t}})).actions(e=>({afterCreate(){x.addDisposer(e,ae.reaction(()=>e.keywordString,e.resetPage,{fireImmediately:!1,delay:0})),x.addDisposer(e,ae.reaction(()=>e.limit,e.resetPage,{fireImmediately:!1,delay:0}))}})),hA=x.types.model({data:x.types.optional(x.types.frozen(),{}),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return Object.keys(e.data).length===0}})),fA=x.types.compose("DataSourceModel",yl,x.types.model({tables:x.types.optional(hA,{}),columns:x.types.optional(uA,{}),tableData:x.types.optional(pA,{}),indexes:x.types.optional(dA,{}),table_schema:x.types.optional(x.types.string,""),table_name:x.types.optional(x.types.string,"")})).views(e=>({get sqlDataSourceType(){return e.type},get reloadConditionString(){const{type:t,table_name:n,table_schema:s}=e;return`${t};${n};${s}`}})).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(e=>({setKeywords(t,n){e.table_schema=t,e.table_name=n}})).actions(e=>({initKeywords(){if(e.tables.empty)return;const t=Object.keys(e.tables.data)[0],n=e.tables.data[t][0].table_name;e.setKeywords(t,n)}})).actions(e=>{const t=x.flow(function*(){var n;(n=e.controllers.tables)==null||n.abort(),e.controllers.tables=new AbortController,e.tables.state="loading";try{const s=yield*x.toGenerator(Kt.structure(e.controllers.tables.signal)({query_type:"TABLES",type:e.sqlDataSourceType,key:e.key,table_schema:"",table_name:""},{params:{query_type:"TABLES"}}));e.tables.data=v.groupBy(s,"table_schema"),e.tables.state="idle",e.tables.error=null,e.initKeywords()}catch(s){if(!Rt.isCancel(s)){e.tables.data={};const i=v.get(s,"message","unkown error");e.tables.error=v.get(s,"response.data.detail.message",i),e.tables.state="error"}}});return{loadTables:t,loadTablesIfEmpty(){e.tables.empty&&t()},loadColumns:x.flow(function*(){var n;(n=e.controllers.columns)==null||n.abort(),e.controllers.columns=new AbortController,e.columns.state="loading";try{e.columns.data=yield*x.toGenerator(Kt.structure(e.controllers.columns.signal)({query_type:"COLUMNS",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"COLUMNS"}})),e.columns.state="idle",e.columns.error=null}catch(s){if(Rt.isCancel(s))e.columns.state="idle",e.columns.error=null;else{e.columns.data=[];const i=v.get(s,"message","unkown error");e.columns.error=v.get(s,"response.data.detail.message",i),e.columns.state="error"}}}),loadIndexes:x.flow(function*(){var n;(n=e.controllers.indexes)==null||n.abort(),e.controllers.indexes=new AbortController,e.indexes.state="loading";try{e.indexes.data=yield*x.toGenerator(Kt.structure(e.controllers.indexes.signal)({query_type:"INDEXES",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"INDEXES"}})),e.indexes.state="idle",e.indexes.error=null}catch(s){if(Rt.isCancel(s))e.indexes.state="idle",e.indexes.error=null;else{e.indexes.data=[];const i=v.get(s,"message","unkown error");e.indexes.error=v.get(s,"response.data.detail.message",i),e.indexes.state="error"}}}),loadTableData:x.flow(function*(){var s;(s=e.controllers.tableData)==null||s.abort(),e.controllers.tableData=new AbortController;const n=e.tableData;n.state="loading";try{n.data=yield*x.toGenerator(Kt.structure(e.controllers.tableData.signal)({query_type:"DATA",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name,limit:n.limit,offset:n.offset},{params:{query_type:"DATA"}}));const[{total:i}]=yield*x.toGenerator(Kt.structure(e.controllers.tableData.signal)({query_type:"COUNT",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"COUNT"}}));n.total=Number(i),n.state="idle",n.error=null}catch(i){if(Rt.isCancel(i))n.state="idle",n.error=null;else{n.data=[];const a=v.get(i,"message","unkown error");n.error=v.get(i,"response.data.detail.message",a),n.state="error"}}})}}).actions(e=>({afterCreate(){x.addDisposer(e,ae.reaction(()=>e.reloadConditionString,e.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(e=>({afterCreate(){x.addDisposer(e,ae.reaction(()=>e.reloadConditionString,e.loadIndexes,{fireImmediately:!1,delay:500})),x.addDisposer(e,ae.reaction(()=>`${e.reloadConditionString};limit:${e.tableData.limit};offset:${e.tableData.offset}`,e.loadTableData,{fireImmediately:!1,delay:0}))}})),gA=x.types.model("DataSourcesModel",{list:x.types.optional(x.types.array(fA),[])}).views(e=>({find({type:t,key:n}){return e.list.find(s=>s.key===n&&s.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}}));function Gn(e){return{label:e,value:e,_type:"ACTION",_action_type:e,Icon:null,children:null}}function mA(e){switch(e._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",e.value];case"sql_snippet":return["_SQL_SNIPPETS_",e.value];case"query":return["_QUERIES_",e.value];case"view":return["_VIEWS_",e.value];case"panel":return e.parentID?["_VIEWS_",e.parentID,"_PANELS_",e.value]:(console.error("[getPathFromOption] parentID is required"),null)}}const xA=x.types.model("EditorModel",{path:x.types.optional(x.types.frozen(),[]),settings_open:x.types.optional(x.types.boolean,!1)}).views(e=>({get navOptions(){const{content:t}=x.getRoot(e),{filters:n,views:s,sqlSnippets:i,queries:a}=t;return[{label:"query_variable.labels",value:"_QUERY_VARS_",_type:"query_variables",Icon:M.IconVariable},{label:"mock_context.label",value:"_MOCK_CONTEXT_",Icon:M.IconCodeDots,_type:"mock_context"},{label:"filter.labels",value:"_FILTERS_",Icon:M.IconFilter,children:[Gn("_FILTERS_SETTINGS_"),...n.options,Gn("_Add_A_Filter_")],_type:"GROUP"},{label:"sql_snippet.labels",value:"_SQL_SNIPPETS_",Icon:M.IconCopy,children:[Gn("_SQL_SNIPPETS_SETTINGS_"),...i.options,Gn("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"query.labels",value:"_QUERIES_",Icon:M.IconDatabase,children:[Gn("_QUERIES_SETTINGS_"),...a.options,Gn("_Add_A_QUERY_")],_type:"GROUP"},{label:"view.labels",value:"_VIEWS_",Icon:M.IconBoxMultiple,children:[...s.editorOptions,Gn("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(t,n){return t.length===0?!1:t[t.length-1]===n.value},isOptionOpened(t){const{path:n}=e;return n.length===0||!t.children||t.children.length===0?!1:n.includes(t.value)}})).actions(e=>({setPath(t){e.path=t},setSettingsOpen(t){e.settings_open=t}})).actions(e=>({open(t){e.setPath(t),e.setSettingsOpen(!0)},close(){e.setSettingsOpen(!1)},navigate(t){const n=mA(t);n&&e.setPath(n)}})),yA=x.types.compose("LayoutsModel",Ml,x.types.model({currentLayoutWrapperWidth:x.types.optional(x.types.number,0)})).views(e=>({get divisionPreviewScale(){const t=e.currentLayoutPreviewWidth,n=e.currentLayoutWrapperWidth;return!t||!n||t<=n?1:n/t}})).actions(e=>({addALayoutItem(t){e.list.forEach(n=>{n.addNewLayout(t)})},duplicateLayoutItemsByPanelID(t,n){e.list.forEach(s=>{const i=s.findByPanelID(t);if(!i){console.error(`Can't find a layout item by panelID[${t}] in layoutSet[${s.name}]`);return}s.list.push({...i,id:on.v4(),panelID:n,y:1/0})})},removeByPanelID(t){e.list.forEach(n=>{n.removeByPanelID(t)})},setCurrentLayoutWrapperWidth(t){e.currentLayoutWrapperWidth=t},addALayoutSet(t,n,s){const i=e.basisLayoutSet,a={id:t,name:n,breakpoint:s,list:i.json.list.map(l=>({...l,id:on.v4()}))};e.list.push(a)},updateLayoutSetsInfo(t){const n=v.keyBy(e.list,"id");t.forEach(a=>{const l=n[a.id];if(l){l.setName(a.name),l.setBreakpoint(a.breakpoint),delete n[a.id];return}this.addALayoutSet(a.id,a.name,a.breakpoint)});const s=new Set(Object.keys(n)),i=s.size>0;s.forEach(a=>{const l=e.list.findIndex(c=>c.id===a);e.list.splice(l,1)}),i&&e.setCurrentBreakpoint("basis")},updateCurrentLayoutItem(t){e.currentLayoutSet.updateLayoutItem(t)},updateCurrentLayoutItems(t){t.forEach(n=>{e.currentLayoutSet.updateLayoutItem(n)})},append(t){e.list.push(t)},appendMultiple(t){t.length!==0&&e.list.push(...t)},remove(t){e.list.splice(t,1)},removeByID(t){const n=e.list.findIndex(s=>s.id===t);n!==-1&&e.list.splice(n,1)},removeByIDs(t){t.forEach(n=>{this.removeByID(n)})}})),rg=wl.views(e=>({get realDataFieldOptions(){return e.queryIDs.length===0?[]:e.queries.map(t=>{const n=t.data;return n.length===0?[]:Object.keys(n[0]).map(i=>({label:i,value:`${t.id}.${i}`,group:t.name,group_id:t.id,disabled:!1}))}).flat()},get realQueryOptions(){return e.queryIDs.length===0?[]:e.queries.map(t=>({label:t.name,value:t.id,disabled:!1}))},queryOptions(t,n){const s=[...this.realQueryOptions];return t&&!s.find(i=>i.value===t)&&s.unshift({label:t,value:t,disabled:!0}),n&&s.unshift({label:"unset",value:"",disabled:!1}),s},get realVariableOptions(){const t=e.variableValueMap;return Object.entries(e.variableAggValueMap).map(([n,s])=>({label:n,value:n,formattedValue:t[n],aggValue:s,disabled:!1}))},variableOptions(t,n){const s=[...this.realVariableOptions];return t&&!s.find(i=>i.value===t)&&s.unshift({label:t,value:t,formattedValue:"",aggValue:"",disabled:!0}),n&&s.unshift({label:"unset",value:"",formattedValue:"",aggValue:"",disabled:!1}),s},dataFieldOptions(t,n,s){let i=[...this.realDataFieldOptions];if(s&&(i=i.filter(a=>a.group_id===s)),t&&!i.find(a=>a.value===t)){const a=L(t),l=e.queryByID(a.queryID);i.unshift({label:a.columnKey,value:t,group:l?l.name:a.queryID,group_id:l?l.id:"",disabled:!0})}return n&&i.unshift({label:"unset",value:"",group:"",group_id:"",disabled:!1}),i},explainDataKey(t){const{queryID:n,columnKey:s}=L(t),i=e.queries.find(a=>a.id===n);return i?{queryID:n,queryName:i.name,columnKey:s}:{queryID:n,queryName:null,columnKey:s}}})).actions(e=>({removeSelf(){x.getParent(e,2).removeByID(e.id)}})).actions(e=>({moveToView(t,n){x.getRoot(e).content.views.findByID(t).removePanelID(e.id),x.getRoot(e).content.views.findByID(n).appendPanelID(e.id),x.getRoot(e).editor.setPath(["_VIEWS_",n,"_PANELS_",e.id])}})),sg=x.types.compose("PanelsModel",Cl,x.types.model({list:x.types.optional(x.types.array(rg),[])})).views(e=>({get contentModel(){return x.getRoot(e).content},editorOptions(t,n){const s=e.panelsByIDs(n);s.length!==n.length&&console.warn(`Unfulfilled panels for View[${t}]`);const i=s.map(l=>({label:l.name,value:l.id,_type:"panel",parentID:t})),a="_Add_A_PANEL_";return i.push({label:a,value:a,_type:"ACTION",_action_type:a,parentID:t,Icon:null,children:null}),i}})).actions(e=>({replace(t){e.list=x.castToSnapshot(t)},append(t){e.list.push(t)},appendMultiple(t){t.length!==0&&e.list.push(...t)},remove(t){e.list.splice(t,1)},removeByID(t){const n=e.list.findIndex(s=>s.id===t);n!==-1&&e.list.splice(n,1)},removeByIDs(t){t.forEach(n=>{this.removeByID(n)})},duplicateByID(t){const n=e.list.find(i=>i.id===t);if(!n){console.error(new Error(`[duplicate panel] Can't find a panel by id[${t}]`));return}const s=new Date().getTime().toString();return e.list.push({...n.json,id:s,title:{...n.json.title}}),e.contentModel.layouts.duplicateLayoutItemsByPanelID(n.id,s),s},replaceByIndex(t,n){e.list.splice(t,1,n)}})),bA=_l.actions(e=>({getSchema(){const t=e.json,n=[],s=[];e.panels.forEach(l=>{const c=l.getSchema();n.push(c.panel),c.queries.length>0&&s.push(...c.queries)});const i=e.contentModel.layouts.jsonByPanelIDSet(new Set(e.panelIDs));return{views:[t],panels:n,definition:{queries:v.uniqBy(s,l=>l.id)},layouts:i,version:gn}},downloadSchema(){if(e.type===G.Tabs){console.error(new Error("Please choose a tab first"));return}const t=JSON.stringify(this.getSchema(),null,2),n=e.name;fr(n,t)}})),ig=x.types.compose("ViewsModel",jl,x.types.model({current:x.types.optional(x.types.array(bA),[]),idOfVIE:x.types.string})).views(e=>({get isVIETheFirstView(){return e.current.length===0||!e.idOfVIE?!1:e.current[0].id===e.idOfVIE},get VIE(){return e.current.find(({id:t})=>t===e.idOfVIE)},get options(){return e.current.map(t=>({label:t.name,value:t.id,type:t.type}))},get editorOptions(){const t=x.getRoot(e).content.panels;return e.current.map(n=>({label:n.name,value:n.id,_type:"view",children:t.editorOptions(n.id,n.panelIDs)}))}})).actions(e=>({setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},replace(t){e.current.replace(t)},addANewView(t,n,s,i){e.current.push({id:t,name:n,type:s,config:i,panelIDs:[]})},append(t){e.current.push(t)},appendMultiple(t){t.length!==0&&e.current.push(...t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(a=>a.id===t);if(n===-1)return;const s=e.current[n];x.getRoot(e).content.panels.removeByIDs(s.panelIDs),e.current.splice(n,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},addARandomNewView(){const t=new Date().getTime().toString();this.addANewView(t,G.Division,G.Division,{_name:G.Division}),this.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(this.removeByID(e.idOfVIE),this.setIDOfVIE(e.current[0].id))}}));function Ol(e){const t=e.length>0?[e[0].id]:[],n=e.length>0?e[0].id:"";return{current:e.map(i=>{const{_name:a=i.type}=i.config;return{...i,config:{...i.config,_name:a},panelIDs:i.panelIDs}}),visibleViewIDs:t,idOfVIE:n}}const vA=x.types.model({id:x.types.string,name:x.types.string,dashboard_id:x.types.string,create_time:x.types.string,update_time:x.types.string,version:x.types.string,filters:Hf,queries:tg,sqlSnippets:ng,views:ig,panels:sg,layouts:yA,mock_context:sl,origin:x.types.maybe(x.types.frozen())}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get filtersChanged(){const t="filters.current";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get queriesChanged(){const t="queries.current",n=x.getSnapshot(v.get(e,t)).map(s=>v.pick(s,["id","name","key","type","sql","run_by","react_to","pre_process","post_process","dep_query_ids"]));return!v.isEqual(n,v.get(e.origin,t))},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get viewsChanged(){const t="views.current";return!v.isEqual(e.views.json,v.get(e.origin,t))},get panelsChanged(){const t="panels.list";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get layoutsChanged(){const t="layouts.list";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get mockContextChanged(){const t="mock_context.current";return!v.isEqual(v.get(e,t),v.get(e.origin,t))},get context(){const t=x.getParent(e).context.current;return{...e.mock_context.current,...t}},get payloadForSQL(){const t=x.getParent(e).globalSQLSnippets,n={context:this.context,filters:e.filters.values};return{...n,sql_snippets:es(e.sqlSnippets.current,"key","value",n),global_sql_snippets:es(t.list,"id","content",n)}},get payloadForViz(){const t=x.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.values}},get dashboardState(){return po(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardState}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.layoutsChanged||this.mockContextChanged},get data(){return e.queries.current.map(({id:n,data:s})=>({id:n,data:s})).reduce((n,s)=>(n[s.id]=s.data,n),{})},getDataStuffByID(t){const n=e.queries.findByID(t);return n?{data:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).views(e=>({get queriesUsage(){const t=e.panels.idMap,n=[];e.views.current.forEach(i=>{i.panelIDs.forEach(a=>{const l=t.get(a);if(!l)return;const c="panel",u=l.name,d=[{id:i.id,label:i.name}];l.queryIDs.forEach(h=>{n.push({id:a,queryID:h,type:c,type_label:"panel.label",label:u,views:d})})})});const s=e.views.idMap;return e.filters.current.filter(i=>!!v.get(i,"config.options_query_id")).forEach(i=>{n.push({type:"filter",type_label:"filter.label",id:i.id,queryID:v.get(i,"config.options_query_id"),label:i.label,views:i.visibleInViewsIDs.map(a=>{var l;return{id:a,label:((l=s.get(a))==null?void 0:l.name)??a}})})}),e.queries.current.forEach(i=>{i.isTransform&&i.dep_query_ids.forEach(a=>{n.push({type:"transform-query",type_label:"query.transform.full_label",id:i.id,queryID:a,label:i.name,views:[]})})}),v.groupBy(n,"queryID")},get hasUnusedQueries(){return e.queries.current.length>Object.keys(this.queriesUsage).length},findQueryUsage(t){return this.queriesUsage[t]??[]},get sqlSnippetsUsage(){const t=[];return e.queries.current.forEach(n=>{if(!n.typedAsSQL)return;v.uniq(n.sql.match(Xs.sqlSnippet)).forEach(i=>{t.push({queryID:n.id,sqlSnippetKey:i,queryName:n.name})})}),v.groupBy(t,"sqlSnippetKey")},get hasUnusedSQLSnippets(){return e.sqlSnippets.current.length>Object.keys(this.sqlSnippetsUsage).length},findSQLSnippetUsage(t){return this.sqlSnippetsUsage[t]??[]}})).actions(e=>({removeUnusedQueries(){const t=new Set(Object.keys(e.queriesUsage)),n=e.queries.current.filter(s=>!t.has(s.id)).map(s=>s.id);e.queries.removeQueries(n)},removeUnusedSQLSnippets(){const t=new Set(Object.keys(e.sqlSnippetsUsage)),n=e.sqlSnippets.current.filter(s=>!t.has(s.key)).map(s=>s.key);e.sqlSnippets.removeByKeys(n)},duplicatePanelByID(t,n){var i;const s=e.panels.duplicateByID(t);s&&((i=e.views.findByID(n))==null||i.appendPanelID(s))},removePanelByID(t,n){var s;e.panels.removeByID(t),e.layouts.removeByPanelID(t),(s=e.views.findByID(n))==null||s.removePanelID(t)},addANewPanel(t){var s;const n=on.v4();e.panels.append(kf(n)),(s=e.views.findByID(t))==null||s.appendPanelID(n),e.layouts.addALayoutItem(n)},applyJSONSchema(t){var p;const{views:n,panels:s,filters:i,definition:a={},layouts:l}=t,{queries:c,sqlSnippets:u,mock_context:d}=a,h=new Map;if(Array.isArray(s)){const f=s.map(m=>{const y=on.v4();return h.set(m.id,y),{...m,id:y}});if(e.panels.appendMultiple(f),!Array.isArray(n)||n.length===0){const m=f.map(y=>y.id);(p=e.views.VIE)==null||p.appendPanelIDs(m)}}if(Array.isArray(n)){const f=n.map(m=>{const y=m.panelIDs.map(_=>h.get(_)??_);return{...m,id:on.v4(),panelIDs:y}});e.views.appendMultiple(f)}if(Array.isArray(l)){const f=(_,k)=>e.layouts.breakpointNameRecord[_]===k;let m=[];const y=l.filter(_=>f(_.name,_.breakpoint));y.forEach(_=>{_.id==="basis"&&(m=_.list),_.list.forEach(k=>{const S=h.get(k.panelID);k.id=on.v4(),k.panelID=S})}),e.layouts.list.forEach(_=>{const k=y.find(S=>S.name===_.name&&S.breakpoint===_.breakpoint);if(!k){m.forEach(S=>{_.addLayout(S)});return}k.list.forEach(S=>{_.addLayout(S)})})}Array.isArray(i)&&e.filters.appendMultiple(i),Array.isArray(c)&&e.queries.appendMultiple(c),Array.isArray(u)&&e.sqlSnippets.appendMultiple(u),d&&Object.keys(d).length>0&&e.mock_context.defaults(d)}})).actions(e=>({reset(){x.applySnapshot(e.filters.current,e.origin.filters.current),x.applySnapshot(e.queries.current,e.origin.queries.current),x.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),x.applySnapshot(e.views.current,e.origin.views.current),x.applySnapshot(e.panels.list,e.origin.panels.list),x.applySnapshot(e.layouts.list,e.origin.layouts.list),e.mock_context.current=e.origin.mock_context.current},resetFilters(){x.applySnapshot(e.filters.current,e.origin.filters.current)},updateCurrent(t){const{id:n,name:s,content:i}=t;if(!i)throw new Error("unexpected null content when updating a content model");const{version:a,filters:l,views:c,panels:u,definition:{queries:d,sqlSnippets:h,mock_context:p={}}}=i;e.id=n,e.name=s,e.version=a,x.applySnapshot(e.filters.current,l),x.applySnapshot(e.views.current,Ol(c).current),x.applySnapshot(e.panels.list,u),x.applySnapshot(e.queries.current,d),x.applySnapshot(e.sqlSnippets.current,h),e.mock_context.current=p}})),Ll=x.types.snapshotProcessor(vA,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=x.castToSnapshot(e.queries.current.map(n=>v.pick(n,["id","key","type","sql"])));return v.defaults({},{queries:{current:t}},e)}});function _A(e,t){t.filters&&x.applySnapshot(e.filters.current,t.filters)}function ag({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,content:a},l,c){if(!a)throw new Error("unexpected null content when creating a content model");const{version:u,filters:d,views:h,panels:p,layouts:f,definition:{queries:m,sqlSnippets:y,mock_context:_={}}}=a;return Ll.create({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,version:u,filters:kl(d,l,_,c),queries:{current:m},sqlSnippets:{current:y},mock_context:il(_),views:Ol(h),panels:{list:p},layouts:{list:f,currentBreakpoint:f[0].id}})}const og=x.types.model({id:x.types.identifier,name:x.types.string,group:x.types.string,content:Ll,content_id:x.types.string,datasources:gA,globalSQLSnippets:bl,context:fi,editor:xA}).views(e=>({get json(){return{id:e.id,name:e.name,group:e.group,content_id:e.content_id}}})).actions(e=>({updateCurrentContent(t){e.content.updateCurrent(t)},updateCurrent(t,n){const{id:s,name:i,group:a,content_id:l}=t;e.id=s,e.name=i,e.group=a,e.content_id=l,this.updateCurrentContent(n)}}));function lg({id:e,name:t,group:n,content_id:s},i,a,l,c,u){return og.create({id:e,name:t,group:n,content_id:s,content:ag(i,c,u),datasources:{list:a},globalSQLSnippets:{list:l},context:vl(c),editor:{}})}const jA={translation:{filter:{label:"Filter",labels:"Filters",add:"Add a Filter",manage:"Manage Filters",show_filters:"Show Filters",hide_filters:"Hide Filters",field:{widget:"Widget",visible_in:"Visible in...",key_placeholder:"A unique key to refer",label_placeholder:"Label for this field",auto_submit:"Submit automatically",order:"Placement Order",custom_default_value:{trigger:"Custom",title:"Custom default value",tips:"Tips",tip_1:"Function has the highest priority of getting filter's default value",tip_2:"Leave this editor empty to disable this feature"}},widget:{names:{select:"Select",multi_select:"Multi Select",tree_select:"Tree Select",text_input:"Text Input",checkbox:"Checkbox",date_range:"Date Range"},common:{use_query_data_as_options:"Use query data as options",fetch_options_from_datasource:"Fetch options from datasource",or_fetch_options_from_datasource:"Or fetch options from datasource",selector_option_empty:"Not found",see_data_structure:"Click to see expected data structure",using_query:"Using query",default_selection_count:"Select first N options by default",min_width:"Min width",x_selected:"{{count}} selected"},text_input:{default_value:"Default Value",required:"Required"},select:{width:"Width",required:"Required",clearable:"Clearable",configure_options:"Configure options",default_selection:"Default Selection",no_default_selection:"none",select_first_option_by_default:"Select the first option by default"},multi_select:{width_description:"At least 160px"},tree_select:{strictly:"Parent and children nodes are not associated"},checkbox:{description:"Description",default_checked:"Default checked"},date_range:{required:"Required",allow_single_date:"Allow choosing 1 day",display_format:"Display format",max_days:"Max days",one_day:"1 day",x_days:"{{count}} days",x_max_days:"{{max_days}} days max",default_value:"Default value",default_by_shortcut:"Default by shortcut",default_by_shortcut_placeholder:"Priors default value",start_date:"Start date",end_date:"End date",shortcut:{last:{label:"last",d:"yesterday",w:"week",m:"month",m2:"2 months",m3:"3 months",y:"year",full:{d:"yesterday",w:"last week",m:"last month",m2:"last 2 months",m3:"last 3 months",y:"last year"}},recent:{label:"recent",d7:"7 days",d30:"30 days",d60:"60 days",d90:"90 days",d180:"180 days",d365:"365 days",full:{d7:"recent 7 days",d30:"recent 30 days",d60:"recent 60 days",d90:"recent 90 days",d180:"recent 180 days",d365:"recent 365 days"}},this:{label:"this",d:"today",w:"week",m:"month",y:"year",full:{d:"today",w:"this week",m:"this month",y:"this year"}},this_so_far:{label:"this...so far",w:"week",m:"month",y:"year",full:{w:"this week so far",m:"this month so far",y:"this year so far"}}}}}},view:{label:"View",labels:"Views",add:"Add a View",delete:"Delete this View",download_schema:"Download this View",component:{div:{label:"Division"},tabs:{label:"Tabs",tabs_settings:"Tabs Settings",tab:{name:"Tab Name",view:"View",order:"Placement Order",color:"Color",delete:"Delete this tab",switch_to_view:"Swith to View: {{name}}"}},modal:{label:"Modal",modal_settings:"Modal settings",title:"Modal Title",custom_title:"Customize modal title",width:"Width",height:"Height"}}},interactions:{label:"Interactions",add:"Add an interaction",interactions_viewer:"Interactions Viewer",unavailable:"Unavailable",unavailable_reason:"This visualization does not have available interactions to choose from",trigger:{setup:"Setup Trigger",label:"Trigger",payload:"Payload"},operation:{setup:"Operation Settings",label:"Operation",settings:"Settings",variables:"Variables",console_log:{label:"console.log | debug",log_content:"log content"},open_link:{label:"Open Link",url:"URL",open_in_new_tab:"Open in new tab"},open_view:{label:"Open View",view:"View"},set_filter_values:{label:"Set Filter Values",set_filter:"Set filter",with:"with"},clear_filter_values:{label:"Clear Filter Values",select_filter:"Select filters to clear"}}},query_variable:{label:"Query Variable",labels:"Query Variables",add:"Add a Variable",guide:{tabs:{guide:"Guide",variables_in_this_dashboard:"Variables in this dashboard",global_sql_snippets:"Global SQL Snippets"}},open:"See Query Variables"},sql_snippet:{label:"SQL Snippet",labels:"SQL Snippets",add:"Add a SQL Snippet",delete:"Delete this SQL Snippet",delete_unused:"Delete unused SQL Snippets",manage:"Manage SQL Snippets",key:"Key",key_occupied:"This key is occupied by another snippet",edit_snippet:"Edit SQL Snippet",preview_snippet:"Preview SQL Snippet",usage:{label:"Usage"}},global_sql_snippet:{label:"Global SQL Snippet",labels:"Global SQL Snippets",description:"SQL snippets worth sharing between dashboards are managed in System Settings by admins."},common:{titles:{settings:"Settings",edit:"Edit",config:"Config"},pagination:{page_size:"Page Size",total:"Total",total_rows:"Total {{total}} row(s)"},align:{horizontal:{label:"Horizontal Align",left:"left",center:"center",right:"right"},vertical:{label:"Vertical Align",top:"top",center:"center",bottom:"bottom"}},id:"ID",name:"Name",key:"Key",label:"Label",value:"Value",type:"Type",info:"Info",min:"Min",max:"Max",data_field:"Data Field",name_data_field:"Name Data Field",value_data_field:"Value Data Field",color_data_field:"Color Data Field",enabled:"Enabled",copied:"Copied to clipboard",action:"Action",actions:{open:"Open",close:"Close",save:"Save",save_changes:"Save Changes",revert:"Revert",revert_changes:"Revert Changes",reset_to_default:"Reset to default",init_with_default:"Init with default",select_all:"Select All",clear:"Clear",clear_selection:"Clear Selection",refresh:"Refresh",download_data:"Download Data",download_schema:"Download Schema",download_screenshot:"Screenshot",enter_fullscreen:"Full Screen",duplicate:"Duplicate",delete:"Delete",cancel:"Cancel",confirm:"Confirm",add_an_option:"Add an Option",edit:"Edit",end_editing:"End editing <1>{{name}}</1>"},tabs:{variant:{label:"Variant",default:"Default",outline:"Outline",pills:"Pills"},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},grow_tabs:"Grow Tabs"},choose_a_tab_first:"Please choose a tab first"},breakpoint:{label_one:"Screen size",label_other:"Screen sizes",add:"Add a screen size",manage:"Manage screen sizes",breakpoint:"Min Width"},context:{label:"Context"},mock_context:{label:"Mock Context",hint:"A valid json string is required"},panel:{label:"Panel",labels:"Panels",add:"Add a Panel",delete:"Delete This Panel",panel_name:"Panel Name",panel_description:"Description",panel_description_click:"Click to see description",show_title:"Show title",use_name_as_title:"Use name as title",settings:{change_view:"Move into Another View",change_view_title:"Move panel into another view",choose_queries:"Choose queries",need_to_choose_queries:"Choose at least 1 query for its data"},style:{label:"Style",width:"Width",width_postfix:"of 36 columns",height:"Height",height_postfix:"px",border:"Border"},variable:{label:"Variable",labels:"Variables",add:"Add a Variable",delete:"Delete this Variable",aggregation:{label:"Aggregation",fallback_value:"Fallback Value",fallback_value_description:"Used when data is empty or the aggregation yields NaN"}}},style:{label:"Style",font_size:{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"Font Weight"},size:{xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl"},flex:{justify_content:{label:"Justify Content",left:"Left",center:"Center",right:"Right",space_between:"Space Between",space_around:"Space Around",space_evenly:"Space Evenly"},align_items:{label:"Align Items",start:"Start",center:"Center",end:"End",stretch:"Stretch"}},color:{type:{label:"Color Type",static:"Static",interpolation:"Interpolation",none:"None"},interpolation:{setup:"Setup color interpolation",palette:{label:"Palette",category:{sequential:"Sequential",diverging:"Diverging"},red_green:"Red / Green",yellow_blue:"Yellow / Blue",red:"Red",green:"Green",blue:"Blue",orange:"Orange",mapping:{value_input_label:"Map a value to this color"}}}}},query:{label:"Query",labels:"Queries",add:"Add a Query",delete:"Delete this Query",cant_delete:"Can't delete this query for it's being used, check out Usage tab for details",delete_unused:"Delete unused queries",name:"Name",name_description:"A unique name",manage:"Manage Queries",open:"Open this query",configurations:"Configurations",basics:"Basics",conditions:"Conditions",run_by_condition:{label:"Run query when these are truthy",unset:"Always run this query on load"},re_run_condition:{label:"Re-run query when these changed",unset:"Leave it empty to never re-run this query"},dependency:{label:"Dependency",has_none:"This query has no dependency"},edit_sql:"Edit SQL",preview_sql:"Preview SQL",request:"Request",build_request:"Build Request",process_request:"Process Request",process_result:"Process Result",usage:{label:"Usage",in_views:"In View(s)",unused_description:"This query is not used by any filter or panel"},transform:{label:"Transform",full_label:"Transform Query",data_source:"Use other queries' data",guide:{pick_queries:"Pick queries for data input",write_function:"Write a function for making new data"}}},data:{label:"Data",preview_data:"Preview Data",empty_data:"Empty Data",requires_data:"Requires data"},data_source:{label:"Data Source",explore:"Explore Data Source",explorer:"Data Source Explorer",table_structure:"Table Structure",table_structure_short:"Structure",see_table_structure:"See Table Structure"},visualization:{label:"Visualization",component:"Visualization",label_short:"Viz"},numbro:{format:{label:"Format",absolute:"Absolute",absolute_description:"Non-negative",abbreviation:"Abbreviation",abbreviation_description:"like 1.23k, 1.23m",mantissa:"Mantissa",trim_mantissa:"Trim mantissa",trim_mantissa_description:"hide trailing zero(s)",preview:{open:"Open Preview",close:"Close Preview",input:"In",output:"Out"}}},import:{label:"Import...",title:"Import content with schema json",json_file:"JSON File",this_dashboard:"This dashboard",this_file:"This file"},function_utils:{trigger_text:"About parameter 'utils'",modal_title:"About FunctionUtils",description:"Parameter <code>utils</code> is <code>FunctionUtils</code>, which contains:",document:"Document"},aggregation:{option:{none:"None",sum:"Sum",mean:"Mean",median:"Median",min:"Min",max:"Max",cov:"Coefficient of Variation",std:"Standard Variation",quantile:{label:"Quantile",label_with_hint:"Quantile(99%, 95%, ...)"},custom:{label:"Custom",label_trigger:"Edit Function",title:"Custom Aggregation"},pick_record:{label:"Pick Record",method:{label:"Record",first:"First Record",last:"Last Record"}}}},rich_text:{label:"Rich Text",content:{label:"Content"},dynamic_color:{label:"Dynamic Color",edit:"Edit dynamic color",clear:"Clear dynamic color"},color_mapping:{label:"Color Mapping",edit:"Edit color mapping",clear:"Clear color mapping",choose_value_var:"Choose a variable for color mapping",min:{val:"Fallback value",var:"Min value variable"},max:{val:"Fallback value",var:"Max value variable"}}},chart:{chart_config:"Chart Config",data_field:"Data Field",groups:{merico_suite:"Merico suite",echarts_based_charts:"ECharts-based charts",others:"Others"},label:{label:"Label",label_full:"Label",label_style:"Label Style",label_format:"Label Format"},label_position:{label:"Label Position",off:"Off",top:"Top",left:"Left",right:"Right",bottom:"Bottom",inside:"Inside",inside_top:"Inside Top",inside_left:"Inside Left",inside_center:"Inside Center",inside_right:"Inside Right",inside_bottom:"Inside Bottom",inside_top_left:"Inside Top Left",inside_top_right:"Inside Top Right",inside_bottom_left:"Inside Bottom Left",inside_bottom_right:"Inside Bottom Right",outside:"Outside"},visual_map:{label:"Visual Map",continuous:{label:"Continuous"},piecewise:{label:"Piecewise",mode:{pieces:"Pieces",categories:"Categories"},add_a_piece:"Add a piece",interval:"Interval",piece_label:"Label"},bar_width:"Bar Width",bar_height:"Bar Height",item_width:"Item Width",item_height:"Item Height",calculable:"Show drag handle",min_value:"Min Value",max_value:"Max Value",min_text:"Min Text",max_text:"Max Text",use_palette_x:'Use palette "{{x}}"',built_in_palettes:"Built-in Palettes",precision:"Data Precision",skip_range:{lt_min:"Color for smaller values than min value",min:"Color for min value",max:"Color for max value",gt_max:"Color for greater values than max value",follow_visual_map:"follow gradient rule"}},number_or_dynamic_value:{type:{static:"Static",dynamic:"Dynamic"},dynamic:{setup:"Setup",setup_title:"Setup dynamic value",guide:"Dyanmic by a custom function"}},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},symbol_size:{label:"Symbol Size",static:"Static",dynamic:"Dynamic",setup:{label:"Setup",title:"Setup dynamic size",description:"Dynamic by a custom function"}},series:{label:"Series",name:"Name",y_axis:"Y Axis",data_field:"Data Field",add:"Add a series",delete:"Delete this series",line:{label:"Line",line_settings:"Line Settings",line_style:"Line Style",type:{label:"Line Type",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},line_width:"Line Width",step:{label:"Step",off:"Off",start:"Start",middle:"Middle",end:"End"},smooth_line:"Smooth Line",show_name_on_line:"Display Name on Line",show_symbol_on_line:"Show Symbol on Line"},bar:{label:"Bar",stack:"Stack",stack_hint:"Stack bars by this ID",bar_gap:{label:"Bar Gap",no_gap:"No gap between bars",overlap:"Bars overlapping on each other"},bar_width:{min:"Bar Width(min)",exact:"Bar Width",max:"Bar Width(max)"}},scatter:{label:"Scatter"},group_by:{label:"Split into multiple seires by this field...",label_line:"Split into multiple lines by this field..."}},axis:{tick_label:"Tick Label",customize_label:"Customize Label",overflow:{label:"Overflow",max_width:"Max Width",truncate:"Truncate",break_line:"Break Line",break_word:"Break Word",ellipsis:"Ellipsis",section_title:{on_axis:"Overflow on Axis",in_tooltip:"Overflow in Tooltip"}},section_title:{label_format:"Label Format"},type:{value:"Value",category:"Category",time:"Time",log:"Log",click_to_learn_more:"Click <1>here</1> to learn more about these options"}},name_text:{align:{label:"Name Anchor",left:"Left",center:"Center",right:"Right"}},rotate:"Rotate",degree:"degree",padding:"Padding",content_template:{label:"Content Template",hint:"Average: ${avg}"},x_axis:{label:"X Axis",labels:"X Axes",label_format:"Label Format",add:"Add an X Axis",delete:"Delete this X Axis",x_axis_name:"X Axis Name",x_axis_data_field:"X Axis Data Field",x_axis_type:"X Axis Type",layout:"Layout",position:{label:"Position",top:"Top",bottom:"Bottom"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},y_axis:{label:"Y Axis",labels:"Y Axes",label_format:"Label Format",add:"Add a Y Axis",delete:"Delete this Y Axis",y_axis_name:"Y Axis Name",y_axis_name_anchor:"Name Anchor",y_axis_data_field:"Y Axis Data Field",layout:"Layout",position:{label:"Position",left:"Left",right:"Right"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},stats:{label:"Stats",template:{above_chart:"Template for stats above the chart",under_chart:"Template for stats under the chart"}},legend:{label:"Legend",show_legend:"Show Legend",show_in_legend:"Show in legend",hide_in_legend:"Hide in legend",orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"}},tooltip:{label:"Tooltip",additional_metrics:{description:"Set additional metrics to show in scatter's tooltip",add:"Add a metic",delete:"Delete this Metric"},trigger:{label:"Trigger",scatter_point:"Scatter Point",x_axis:"X Axis"}},style:{label:"Style"},color:{label:"Color",or:"or",set_any_color:"Set any color",pick_a_theme_color:"Pick a theme color",background_color:"Background Color",text_color:"Text Color",click_to_add_a_color:"Click to add a color",color_gradient:"Color Gradient"},behavior:{label:"Behavior",invisible:"Invisible"},heatmap:{heatblock:{label:"Heat Block",show_label:"Show Label"}},reference_line:{label:"Reference Line",labels:"Reference Lines",add:"Add a reference line",name_placeholder:"Average Reference Line",delete:"Remove this Reference Line",orientation:{vertical_hint:"Works only when xAxis values are numbers"}},regression_line:{label:"Regression Line",labels:"Regression Lines",add:"Add a line",delete:"Delete this line",method:{label:"Method",linear:"Linear",exponential:"Exponential",logistic:"Logistic",polynomial:"Polynomial",polynomial_order:"Order"}},reference_area:{label:"Reference Area",labels:"Reference Areas",add:"Add a reference area",delete:"Remove this reference area",type:{label:"Type",rectangle:"Rectangle"},direction:{label:"Direction",horizontal:"Horizontal"},boundary:{upper:"Upper Boundary",lower:"Lower Boundary"},content:{label:"Content",content_text:"Content Text",text_position:"Text Position"},endpoint:{labels:"Endpoints",left_bottom_point:"Left-Bottom Point",right_top_point:"Right-Top Point"}},zooming:{label:"Zooming",scroll:{label:"Scroll to zoom",x_axis:"Enable on X Axis",y_axis:"Enable on Y Axis"},slider:{label:"Slider for zooming",x_axis:"Slider for X Axis",y_axis:"Slider for Y Axis",y_axis_disabled:"Not available for now, will overlap y-axis's label"}}},viz:{viz_config_banner:"Visualization Settings"},validation:{number:{require_a_number:"A number is required"}}}},wA={translation:{filter:{label:"筛选器",labels:"筛选器",add:"新增筛选器",manage:"管理筛选器",show_filters:"展开筛选器",hide_filters:"收起筛选器",field:{widget:"控件",visible_in:"在...视图中可见",key_placeholder:"用于引用此筛选器,需保持唯一",label_placeholder:"用于展示的标签文案",auto_submit:"自动提交",order:"排列次序",custom_default_value:{trigger:"自定义",title:"自定义默认值",tips:"提示",tip_1:"在指定筛选器默认值这事上,自定义函数具备最高优先级",tip_2:"清空下方编辑器来禁用本功能"}},widget:{names:{select:"单选",multi_select:"多选",tree_select:"树形选择器",text_input:"文本框",checkbox:"勾选框",date_range:"日期范围"},common:{use_query_data_as_options:"使用所查数据为选项",fetch_options_from_datasource:"从数据源查选项",or_fetch_options_from_datasource:"或从数据源查选项",selector_option_empty:"无选项可用",see_data_structure:"点击查看期望的数据格式",using_query:"在用查询获取选项",default_selection_count:"默认选中前N项",min_width:"控件最小宽度",x_selected:"已选数:{{count}}"},text_input:{default_value:"默认值",required:"必填"},select:{width:"控件宽度",required:"必选",clearable:"可取消选择",configure_options:"配置选项",default_selection:"默认选项",no_default_selection:"无",select_first_option_by_default:"默认选中第一个选项"},multi_select:{width_description:"至少160px"},tree_select:{strictly:"枝叶节点不相关,各选各的"},checkbox:{description:"描述信息",default_checked:"默认勾选"},date_range:{required:"必选",allow_single_date:"允许选一天作为范围",display_format:"展示格式",max_days:"最大选择天数",one_day:"1天",x_days:"{{count}}天",x_max_days:"最多可选{{max_days}}天",default_value:"默认日期范围(具体)",default_by_shortcut:"默认日期范围(快捷方式)",default_by_shortcut_placeholder:"优先于左侧",start_date:"开始日期",end_date:"结束日期",shortcut:{last:{label:"过往整周期",d:"昨天",w:"周",m:"月",m2:"两个月",m3:"三个月",y:"年",full:{d:"昨天",w:"上周",m:"上个月",m2:"上两月",m3:"上三月",y:"去年"}},recent:{label:"最近",d7:"7天",d30:"30天",d60:"60天",d90:"90天",d180:"180天",d365:"365天",full:{d7:"近7天",d30:"近30天",d60:"近60天",d90:"近90天",d180:"近180天",d365:"近365天"}},this:{label:"当前整周期",d:"今天",w:"周",m:"月",y:"年",full:{d:"今天",w:"本周",m:"本月",y:"今年"}},this_so_far:{label:"至今",w:"周",m:"月",y:"年",full:{w:"本周至今",m:"本月至今",y:"本年至今"}}}}}},view:{label:"视图",labels:"视图",add:"新增视图",delete:"删除此视图",download_schema:"下载此视图描述文件",component:{div:{label:"内容"},tabs:{label:"标签页",tabs_settings:"标签页设置",tab:{name:"名称",view:"内容视图",order:"排列次序",color:"颜色",delete:"删除这个标签页",switch_to_view:"打开视图: {{name}}"}},modal:{label:"弹窗",modal_settings:"弹窗设置",title:"弹窗标题",custom_title:"自定义弹窗标题",width:"宽度",height:"高度"}}},interactions:{label:"交互",add:"新增交互",interactions_viewer:"纵览交互",unavailable:"不可用",unavailable_reason:"此可视化组件没有交互功能",trigger:{setup:"设置触发动作",label:"触发动作",payload:"触发时的参数"},operation:{setup:"操作设置",label:"操作",settings:"设置",variables:"变量",console_log:{label:"console.log | 调试用",log_content:"打印内容"},open_link:{label:"打开链接",url:"URL",open_in_new_tab:"在新标签页中打开"},open_view:{label:"唤出视图",view:"视图"},set_filter_values:{label:"设置筛选器值",set_filter:"将筛选器的值",with:"设为"},clear_filter_values:{label:"清除筛选器值",select_filter:"选择筛选器以清除其值"}}},query_variable:{label:"查询变量",labels:"查询变量",add:"新增变量",guide:{tabs:{guide:"使用指南",variables_in_this_dashboard:"本看板中的查询变量",global_sql_snippets:"全局SQL片段"}},open:"查看查询变量"},sql_snippet:{label:"SQL片段",labels:"SQL片段",add:"新增SQL片段",delete:"删除这个SQL片段",delete_unused:"删除未用到的SQL片段",manage:"管理SQL片段",key:"键",key_occupied:"此键已被其他SQL片段占用",edit_snippet:"编辑SQL片段",preview_snippet:"预览SQL片段",usage:{label:"使用情况"}},global_sql_snippet:{label:"全局SQL片段",labels:"全局SQL片段",description:"管理员负责在系统设置中维护全局SQL片段"},common:{titles:{settings:"设置",edit:"编辑",config:"配置"},pagination:{page_size:"页容量",total:"共",total_rows:"共 {{total}} 行"},align:{horizontal:{label:"水平对齐",left:"居左",center:"居中",right:"居右"},vertical:{label:"垂直对齐",top:"居上",center:"居中",bottom:"居下"}},id:"ID",name:"名称",key:"键",label:"标签",value:"值",type:"类型",info:"信息",min:"最小值",max:"最大值",data_field:"数据字段",name_data_field:"名称字段",value_data_field:"值字段",color_data_field:"颜色字段",enabled:"启用",copied:"已复制到剪切板",action:"操作",actions:{open:"打开",close:"关闭",save:"保存",save_changes:"保存改动",revert:"还原",revert_changes:"还原改动",reset_to_default:"重置为初始值",init_with_default:"初始化",select_all:"全选",clear:"清除",clear_selection:"撤销选择",refresh:"刷新",download_data:"下载数据",download_schema:"下载描述文件",download_screenshot:"下载截图",enter_fullscreen:"全屏",duplicate:"复制",delete:"删除",cancel:"取消",confirm:"确认",add_an_option:"新增选项",edit:"编辑",end_editing:"结束编辑 <1>{{name}}</1>"},tabs:{variant:{label:"风格",default:"默认",outline:"轮廓",pills:"胶囊"},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},grow_tabs:"拉伸标签卡宽度"},choose_a_tab_first:"请先选择一个标签页"},breakpoint:{label_one:"屏幕尺寸",label_other:"屏幕尺寸",add:"新增屏幕尺寸",manage:"管理屏幕尺寸",breakpoint:"最小宽度"},context:{label:"上下文"},mock_context:{label:"模拟上下文",hint:"内容格式为JSON"},panel:{label:"卡片",labels:"卡片",add:"新增卡片",delete:"删除这个卡片",panel_name:"卡片名",panel_description:"卡片描述",panel_description_click:"点击查看卡片描述",show_title:"展示卡片标题",use_name_as_title:"使用卡片名作为标题",settings:{change_view:"移至另一个视图下",change_view_title:"移动此卡片至另一个视图下",choose_queries:"关联查询",need_to_choose_queries:"请关联至少一个查询以使用其数据"},style:{label:"样式",width:"宽",width_postfix:"之 36 栏",height:"高",height_postfix:"px",border:"边框"},variable:{label:"变量",labels:"变量",add:"新增变量",delete:"删除此变量",aggregation:{label:"聚合",fallback_value:"兜底值",fallback_value_description:"当数据为空或聚合结果非数字时,使用此兜底值"}}},style:{label:"样式",font_size:{label:"字号",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"字重"},size:{xs:"特小",sm:"小",md:"中",lg:"大",xl:"特大"},flex:{justify_content:{label:"内容分布",left:"从左起",center:"居中",right:"从右起",space_between:"均匀分布,首尾顶格",space_around:"均匀分布,首尾留空一半",space_evenly:"均匀分布,首尾留空"},align_items:{label:"对齐位置",start:"起点对齐",center:"居中对齐",end:"末端对齐",stretch:"拉伸对齐"}},color:{type:{label:"颜色类型",static:"单色",interpolation:"插值取色",none:"无"},interpolation:{setup:"设置取色方案",palette:{label:"色板",category:{sequential:"单色渐变",diverging:"双色渐变"},red_green:"红 / 绿",yellow_blue:"黄 / 蓝",red:"红",green:"绿",blue:"蓝",orange:"橙",mapping:{value_input_label:"映射一个值到此颜色"}}}}},query:{label:"查询",labels:"查询",add:"新增查询",delete:"删除这个查询",cant_delete:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",delete_unused:"删除未用到的查询",name:"名称",name_description:"唯一名称",manage:"管理查询",open:"打开此查询",configurations:"配置",basics:"基本信息",conditions:"条件",run_by_condition:{label:"以下条件满足时,才运行本查询",unset:"看板加载时便运行本查询"},re_run_condition:{label:"当以下条件改变时,重新运行此查询",unset:"留空则永不重新运行此查询"},dependency:{label:"依赖",has_none:"此查询无依赖"},edit_sql:"编辑SQL",preview_sql:"预览SQL",request:"请求",build_request:"构造请求",process_request:"加工请求",process_result:"加工结果",usage:{label:"使用情况",in_views:"所在视图",unused_description:"此查询未被任何筛选器或卡片用到"},transform:{label:"查询变形",full_label:"查询变形",data_source:"基于其他查询的数据,加工出新数据",guide:{pick_queries:"选择一至多个查询作为数据输入",write_function:"编写函数,返回新数据"}}},data:{label:"数据",preview_data:"预览数据",empty_data:"无数据",requires_data:"请先关联查询"},data_source:{label:"数据源",explore:"查看数据源",explorer:"数据源查看器",table_structure:"数据表结构",table_structure_short:"表结构",see_table_structure:"查看数据表结构"},visualization:{label:"可视化",component:"可视化组件",label_short:"可视化"},numbro:{format:{label:"格式",absolute:"绝对值",absolute_description:"非负",abbreviation:"缩写",abbreviation_description:"如1.23k、1.23m",mantissa:"小数",trim_mantissa:"抹零",trim_mantissa_description:"省略末尾的零",preview:{open:"展开预览",close:"收起预览",input:"输入",output:"输出"}}},import:{label:"导入...",title:"自描述文件导入看板内容",json_file:"描述文件(JSON格式)",this_dashboard:"此看板",this_file:"此文件"},function_utils:{trigger_text:"关于utils参数",modal_title:"关于utils参数",description:"参数 <code>utils</code> 是 <code>FunctionUtils</code>,包含以下内容:",document:"文档"},aggregation:{option:{none:"无",sum:"和",mean:"平均值",median:"中位数",min:"最小值",max:"最大值",cov:"变异系数",std:"标准差",quantile:{label:"分位",label_with_hint:"分位(99%, 95%, ...)"},custom:{label:"自定义",label_trigger:"编写函数",title:"自定义聚合方式"},pick_record:{label:"直接选择数据",method:{label:"数据记录",first:"第一条",last:"最后一条"}}}},rich_text:{label:"富文本",content:{label:"内容"},dynamic_color:{label:"动态颜色",edit:"编辑动态颜色",clear:"清除动态颜色"},color_mapping:{label:"颜色映射",edit:"编辑颜色映射",clear:"清除颜色映射",choose_value_var:"选择用于映射颜色的变量",min:{val:"固定最小值",var:"动态最小值(优先)"},max:{val:"固定最大值",var:"动态最大值(优先)"}}},chart:{chart_config:"图表设置",data_field:"数据字段",groups:{merico_suite:"思码逸套件",echarts_based_charts:"基于ECharts的图表",others:"其他"},label:{label:"文案",label_full:"标签文案",label_style:"标签文案样式",label_format:"标签文案格式"},label_position:{label:"文案位置",off:"不显示文案",top:"上",left:"左",right:"右",bottom:"下",inside:"内",inside_top:"内-上",inside_left:"内-左",inside_center:"内-中",inside_right:"内-右",inside_bottom:"内-下",inside_top_left:"内-上-左",inside_top_right:"内-上-右",inside_bottom_left:"内-下-左",inside_bottom_right:"内-下-右",outside:"外"},visual_map:{label:"视觉映射",continuous:{label:"连续型"},piecewise:{label:"分段型",mode:{pieces:"连续数据",categories:"离散数据"},add_a_piece:"加一个分段",interval:"值区间",piece_label:"文案"},bar_width:"长条的宽度",bar_height:"长条的高度",item_width:"小块的宽度",item_height:"小块的高度",calculable:"显示拖拽手柄",min_value:"最小值",max_value:"最大值",min_text:"最小值文案",max_text:"最大值文案",use_palette_x:'使用配色方案"{{x}}"',built_in_palettes:"内置配色方案",precision:"数据精度",skip_range:{lt_min:"小于最小值时的颜色",min:"最小值的颜色",max:"最大值的颜色",gt_max:"大于最大值时的颜色",follow_visual_map:"颜色跟随渐变规则"}},number_or_dynamic_value:{type:{static:"具体值",dynamic:"动态值"},dynamic:{setup:"设置",setup_title:"设置动态值",guide:"由函数确定动态值"}},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},symbol_size:{label:"标记点大小",static:"固定值",dynamic:"动态值",setup:{label:"设置",title:"设置动态值",description:"由函数确定动态值"}},series:{label:"系列",name:"名称",y_axis:"Y轴",data_field:"数据字段",add:"增加一个系列",delete:"删除这个系列",line:{label:"线",line_settings:"线段设置",line_style:"线条样式",type:{label:"类型",solid:"实线",dashed:"方虚线",dotted:"圆点虚线"},line_width:"线宽",step:{label:"阶梯状",off:"不启用",start:"在当前点拐弯",middle:"在当前点与下个点中间拐弯",end:"在下个点拐弯"},smooth_line:"平滑曲线",show_name_on_line:"显示标签文案",show_symbol_on_line:"显示标记点"},bar:{label:"柱",stack:"堆放",stack_hint:"此值相同的柱系列会堆叠在一起",bar_gap:{label:"柱间隔",no_gap:"柱子之间无间隔",overlap:"柱子可互相重叠"},bar_width:{min:"最小柱宽",exact:"柱宽",max:"最大柱宽"}},scatter:{label:"散点"},group_by:{label:"按此字段拆分为多个系列",label_line:"按此字段拆分为多条线"}},axis:{tick_label:"刻度文案",customize_label:"自定义文案",overflow:{label:"溢出",max_width:"最大宽度",truncate:"截断",break_line:"换行",break_word:"断词换行",ellipsis:"省略符",section_title:{on_axis:"轴刻度上文案的溢出",in_tooltip:"提示框中的文案溢出"}},section_title:{label_format:"文案格式"},type:{value:"数值轴",category:"类目轴",time:"时间轴",log:"对数轴",click_to_learn_more:"点击 <1>这里</1> 以进一步了解这些选项"}},name_text:{align:{label:"名称贴靠侧",left:"左",center:"中",right:"右"}},rotate:"旋转",degree:"度",padding:"内间距",content_template:{label:"内容模板",hint:"均值: ${avg}"},x_axis:{label:"X轴",labels:"X轴",label_format:"刻度文案格式",add:"增加一条X轴",delete:"删除这条X轴",x_axis_name:"X轴名称",x_axis_data_field:"X轴数据字段",x_axis_type:"X轴类型",layout:"布局",position:{label:"位置",top:"上",bottom:"下"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},y_axis:{label:"Y轴",labels:"Y轴",label_format:"刻度文案格式",add:"增加一条Y轴",delete:"删除这条Y轴",y_axis_name:"Y轴名称",y_axis_name_anchor:"名称贴靠侧",y_axis_data_field:"Y轴数据字段",layout:"布局",position:{label:"位置",left:"左",right:"右"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},stats:{label:"统计内容",template:{above_chart:"统计内容模板(图表上方)",under_chart:"统计内容模板(图表下方)"}},legend:{label:"图例",show_legend:"显示图例",show_in_legend:"显示在图例中",hide_in_legend:"不显示在图例中",orientation:{label:"布局朝向",horizontal:"横向",vertical:"纵向"}},tooltip:{label:"提示框",additional_metrics:{description:"在此设置更多指标,来展示在散点的提示框",add:"增加一个指标",delete:"删除这个指标"},trigger:{label:"触发者",scatter_point:"散点",x_axis:"X轴"}},style:{label:"样式"},color:{label:"颜色",or:"或",set_any_color:"输入色号",pick_a_theme_color:"选择一个主题色",background_color:"背景色",text_color:"文字颜色",click_to_add_a_color:"点击增加一个颜色",color_gradient:"颜色渐变"},behavior:{label:"表现",invisible:"隐藏不可见"},heatmap:{heatblock:{label:"热力块",show_label:"展示值文案"}},reference_line:{label:"参考线",labels:"参考线",add:"增加一条参考线",name_placeholder:"均值参考线",delete:"删除这条参考线",orientation:{vertical_hint:"仅当X轴值为数字时可绘制"}},regression_line:{label:"回归线",labels:"回归线",add:"增加一条回归线",delete:"删除这条回归线",method:{label:"方法",linear:"线性回归",exponential:"指数回归",logistic:"指数回归",polynomial:"多项式回归",polynomial_order:"次"}},reference_area:{label:"参考区域",labels:"参考区域",add:"增加一面参考区域",delete:"删除这面参考区域",type:{label:"形状",rectangle:"矩形"},direction:{label:"方向",horizontal:"水平"},boundary:{upper:"上边界",lower:"下边界"},content:{label:"内容",content_text:"内容文字",text_position:"文字位置"},endpoint:{labels:"端点",left_bottom_point:"左下点",right_top_point:"右上点"}},zooming:{label:"缩放",scroll:{label:"滚轮缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用"},slider:{label:"滚动条缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用",y_axis_disabled:"暂不可用,会与Y轴刻度文字重叠"}}},viz:{viz_config_banner:"可视化参数配置"},validation:{number:{require_a_number:"请填写一个数字"}}}},xi=Pm.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:jA,zh:wA}}).use(Om).use(j.initReactI18next);xi.init(),Yh.forEach(e=>{var t;(t=e.translation)==null||t.forEach(n=>{xi.addResourceBundle(n.lang,"translation",{viz:n.resources},!0,!0)})});function cg({lang:e,children:t}){return g.useEffect(()=>{xi.changeLanguage(e)},[e]),r.jsx(j.I18nextProvider,{i18n:xi,children:t})}function yi(e){console.groupCollapsed("Running operation ",e.type),console.log(e),console.groupEnd()}function ug(e,t){g.useEffect(()=>{const n=s=>{yi(s);const{viewID:i}=s.detail;if(!i){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(i),t&&e.views.setIDOfVIE(i)};return window.addEventListener("open-view",n),()=>{window.removeEventListener("open-view",n)}},[e,t]),g.useEffect(()=>{const n=s=>{yi(s);const{dictionary:i,payload:a}=s.detail;if(!a||Object.keys(a).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}const l={};Object.entries(i).forEach(([c,u])=>{const d=v.get(a,u);l[c]=d}),e.filters.applyValuesPatch(l)};return window.addEventListener("set-filter-values",n),()=>{window.removeEventListener("set-filter-values",n)}},[e]),g.useEffect(()=>{function n(i){return Array.isArray(i)?[]:typeof i=="object"?{}:typeof i=="boolean"?!1:typeof i=="string"?"":typeof i=="number"?0:i}const s=i=>{yi(i);const a={},{filter_keys:l}=i.detail;l.forEach(c=>{const u=v.get(e.filters.values,c),d=n(u);a[c]=d}),e.filters.applyValuesPatch(a)};return window.addEventListener("clear-filter-values",s),()=>{window.removeEventListener("clear-filter-values",s)}},[e]),g.useEffect(()=>{const n=s=>{yi(s);const{urlTemplate:i,openInNewTab:a,enableEncoding:l=!1,payload:c}=s.detail;if(!i){console.error(new Error("[Open Link] URL is empty"));return}function u(p){return v.cloneDeepWith(p,m=>{if(l&&typeof m=="string")return encodeURIComponent(m)})}const h=v.template(i||"")(u({...c,filters:e.payloadForSQL.filters,context:e.payloadForSQL.context}));window.open(h,a?"_blank":"_self","noopener")};return window.addEventListener("open-link",n),()=>{window.removeEventListener("open-link",n)}},[e])}function dg(e){return g.useCallback(t=>t.provideValue(Oe.pluginManager,e.pluginManager).provideValue(Oe.vizManager,e.vizManager).provideValue(Oe.colorManager,e.colorManager),[])}const jV="",CA=D.observer(({saveDashboardChanges:e})=>{const{t}=j.useTranslation(),n=wt.useModals(),s=re(),i=()=>{n.openConfirmModal({title:r.jsxs(o.Group,{position:"left",children:[r.jsx(M.IconAlertTriangle,{size:18,color:"red"}),r.jsx(o.Text,{children:"You are reverting changes"})]}),labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>s.reset(),zIndex:320,withCloseButton:!1})},a=s.changed;return r.jsxs(o.Group,{spacing:0,children:[r.jsx(o.Button,{color:"green",variant:"filled",size:"xs",leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),onClick:e,disabled:!a,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:t("common.actions.save_changes")}),r.jsxs(o.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!a,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.ActionIcon,{variant:"default",disabled:!a,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:r.jsx(M.IconCaretDown,{size:18})})}),r.jsx(o.Menu.Dropdown,{children:r.jsx(o.Menu.Item,{icon:r.jsx(M.IconRecycle,{size:14,color:"red"}),disabled:!a,onClick:i,children:t("common.actions.revert_changes")})})]})]})}),SA=D.observer(({saveDashboardChanges:e,onExit:t,headerSlot:n=null})=>{j.useTranslation();const s=le(),i=s.content.changed,a=()=>{t({hasChanges:i,dashboardId:s.id})};return r.jsx(o.Header,{height:60,px:"md",py:0,sx:{zIndex:299},children:r.jsxs(o.Group,{position:"apart",sx:{height:60,minWidth:"1000px",position:"relative"},children:[r.jsxs(o.Group,{children:[r.jsx(o.Button,{size:"xs",color:i?"red":"green",leftIcon:r.jsx(M.IconArrowLeft,{size:20}),onClick:a,children:r.jsx(o.Group,{spacing:4,children:r.jsxs(j.Trans,{i18nKey:"common.actions.end_editing",values:{name:s.name},children:["End Editing ",r.jsx(o.Text,{td:"underline",children:s.name})]})})}),r.jsx(CA,{saveDashboardChanges:e})]}),r.jsx(o.Group,{position:"right",sx:{flexGrow:1},children:n})]})})}),pg={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},kA=D.observer(()=>{var i;const{t:e}=j.useTranslation(),t=re(),n=((i=t.views.VIE)==null?void 0:i.type)===G.Tabs,s=()=>t.addANewPanel(t.views.idOfVIE);return n?r.jsx(o.Tooltip,{label:e("common.choose_a_tab_first"),children:r.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:r.jsx(M.IconPlaylistAdd,{size:20}),sx:{...pg,transform:"none !important"},children:e("panel.add")})}):r.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:s,leftIcon:r.jsx(M.IconPlaylistAdd,{size:20}),sx:{...pg,background:"rgb(231, 245, 255)"},children:e("panel.add")})}),TA=D.observer(({done:e})=>{var E,R;const{t}=j.useTranslation(),s=re().layouts,i=g.useMemo(()=>({list:s.breakpointsInfo}),[s.breakpointsInfo]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d,formState:h}=b.useForm({defaultValues:i}),{fields:p,append:f,remove:m}=b.useFieldArray({control:a,name:"list",rules:{validate:K=>{if(console.log({values:K}),v.uniqBy(K,"breakpoint").length!==K.length)return"Screen sizes should be unique by min width"}}}),y=c("list"),_=p.map((K,ye)=>({...K,...y[ye]})),k=()=>{f({id:on.v4(),name:"",breakpoint:""})},S=({list:K})=>{const ye=K.filter(xe=>Number.isFinite(xe.breakpoint));s.updateLayoutSetsInfo(ye),e()},T=u(),I=g.useMemo(()=>{const K={list:T.list.filter(ye=>!!ye.name&&Number.isFinite(ye.breakpoint))};return!v.isEqual(K,i)},[T,i]),z=(R=(E=h.errors.list)==null?void 0:E.root)==null?void 0:R.message;return r.jsx(r.Fragment,{children:r.jsxs("form",{onSubmit:l(S),children:[r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,withBorder:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"340px"},children:t("common.name")}),r.jsx("th",{style:{width:"160px"},children:t("breakpoint.breakpoint")}),r.jsx("th",{})]})}),r.jsxs("tbody",{children:[_.map((K,ye)=>r.jsxs("tr",{children:[r.jsx("th",{children:K.id==="basis"?K.name:r.jsx(b.Controller,{name:`list.${ye}.name`,control:a,render:({field:xe})=>r.jsx(o.TextInput,{size:"xs",label:"",required:!0,sx:{flex:1},...xe})})}),r.jsx("td",{children:K.id==="basis"?r.jsxs(o.Text,{ff:"monospace",children:[K.breakpoint,"px"]}):r.jsx(b.Controller,{name:`list.${ye}.breakpoint`,control:a,render:({field:xe})=>r.jsx(o.NumberInput,{size:"xs",label:"",required:!0,max:1e4,hideControls:!0,rightSection:r.jsx(o.Text,{color:"dimmed",children:"px"}),rightSectionProps:{style:{width:"30px"}},sx:{flex:1,fontFamily:"monospace"},styles:{input:{paddingRight:"30px"}},...xe})})}),r.jsx("td",{children:K.id!=="basis"&&r.jsx(o.ActionIcon,{mx:"auto",size:"xs",variant:"subtle",color:"red",onClick:()=>m(ye),children:r.jsx(M.IconTrash,{})})})]},K.id)),r.jsx("tr",{style:{backgroundColor:"transparent"},children:r.jsx("td",{colSpan:3,style:{padding:"0"},children:r.jsx(o.Tooltip,{label:t("breakpoint.add"),children:r.jsx(o.ActionIcon,{variant:"subtle",size:"md",color:"blue",onClick:k,sx:{width:"100%"},children:r.jsx(M.IconPlus,{size:18})})})})})]})]}),r.jsx(o.Text,{mt:6,ta:"right",size:"xs",color:"red",children:z??" "}),r.jsxs(o.Group,{mt:6,position:"apart",children:[r.jsx(o.Button,{color:"orange",size:"xs",onClick:()=>d(),leftIcon:r.jsx(M.IconRecycle,{size:18}),disabled:!I,children:t("common.actions.revert")}),r.jsx(o.Button,{color:"green",size:"xs",type:"submit",leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),disabled:!I,children:t("common.actions.save_changes")})]})]})})}),DA=D.observer(()=>{const{t:e}=j.useTranslation(),[t,{open:n,close:s}]=Se.useDisclosure(!1),i=re(),a=i.layouts.currentBreakpoint,l=i.layouts.currentLayoutRange,c=()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},u=()=>{s(),c()};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{children:[r.jsxs(o.Menu,{withArrow:!0,withinPortal:!0,zIndex:320,trigger:"hover",children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Button,{size:"xs",variant:"subtle",leftIcon:r.jsx(M.IconDevices,{size:16}),sx:{borderRadius:0},children:r.jsxs(o.Group,{spacing:6,children:[r.jsx(o.Text,{size:"xs",fw:"normal",children:l.name}),r.jsx(o.Text,{size:"xs",color:"#777",children:i.layouts.currentRangeText})]})})}),r.jsxs(o.Menu.Dropdown,{children:[i.layouts.breakpointRanges.map(d=>r.jsx(o.Menu.Item,{onClick:()=>i.layouts.setCurrentBreakpoint(d.id),disabled:a===d.id,children:r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Text,{size:"sm",children:d.name}),r.jsx(o.Text,{size:"xs",color:"dimmed",children:d.text})]})},d.id)),r.jsx(o.Menu.Divider,{}),r.jsx(o.Menu.Item,{color:"blue",icon:r.jsx(M.IconSettings,{size:14}),onClick:n,children:r.jsx(o.Text,{size:"sm",children:e("breakpoint.manage")})})]})]}),i.layouts.divisionPreviewScale<1&&r.jsx(o.Text,{size:"xs",color:"dimmed",children:ss(i.layouts.divisionPreviewScale).format({output:"percent",mantissa:0})})]}),r.jsx(o.Modal,{opened:t,onClose:u,title:e("breakpoint.label",{count:2}),withinPortal:!0,zIndex:320,size:600,closeOnClickOutside:!1,children:r.jsx(TA,{done:u})})]})}),hg={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},MA=D.observer(()=>{var i;const{t:e}=j.useTranslation(),t=re(),n=((i=t.views.VIE)==null?void 0:i.type)===G.Tabs,s=()=>{var a;return(a=t.views.VIE)==null?void 0:a.downloadSchema()};return n?r.jsx(o.Tooltip,{label:e("common.choose_a_tab_first"),children:r.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:r.jsx(M.IconCode,{size:16}),sx:{...hg,transform:"none !important"},children:e("view.download_schema")})}):r.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:s,leftIcon:r.jsx(M.IconCode,{size:16}),sx:{...hg},children:e("view.download_schema")})}),bi=({headers:e,rows:t})=>r.jsxs(o.Table,{fontSize:"xs",highlightOnHover:!0,sx:{tableLayout:"fixed",fontFamily:"monospace"},children:[r.jsx("thead",{children:e}),r.jsx("tbody",{children:t})]}),IA=({content:e})=>{const{t}=j.useTranslation(),n=e.views;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("view.labels")}),r.jsx(bi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.name")}),r.jsx("th",{children:t("common.type")})]}),rows:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.id}),r.jsx("td",{children:s.name}),r.jsx("td",{children:t(`view.component.${s.type}.label`)})]},s.id))})]})},zA=({content:e})=>{const{t}=j.useTranslation(),n=e.filters;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("filter.labels")}),r.jsx(bi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.key")}),r.jsx("th",{children:t("common.label")})]}),rows:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.id}),r.jsx("td",{children:s.key}),r.jsx("td",{children:s.label})]},s.id))})]})},EA=({content:e})=>{const{t}=j.useTranslation(),n=e.panels;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("panel.labels")}),r.jsx(bi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.name")}),r.jsx("th",{children:t("visualization.component")})]}),rows:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.id}),r.jsx("td",{children:s.name}),r.jsx("td",{children:s.viz.type})]},s.id))})]})},AA=({content:e})=>{var s;const{t}=j.useTranslation(),n=(s=e.definition)==null?void 0:s.queries;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("query.labels")}),r.jsx(bi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.name")}),r.jsx("th",{style:{width:"140px"},children:t("common.type")}),r.jsx("th",{style:{width:"260px"},children:t("data_source.label")})]}),rows:n.map(i=>r.jsxs("tr",{children:[r.jsx("td",{children:i.id}),r.jsx("td",{children:i.name}),r.jsx("td",{children:i.type}),r.jsx("td",{children:i.key})]},i.id))})]})},PA=({content:e})=>{var s;const{t}=j.useTranslation(),n=(s=e.definition)==null?void 0:s.sqlSnippets;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("sql_snippet.labels")}),r.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:r.jsx(M.IconPointFilled,{size:10}),children:n.map(i=>r.jsx(o.List.Item,{children:i.key},i.key))})]})},OA=({content:e})=>{var s;const{t}=j.useTranslation(),n=Object.keys(((s=e.definition)==null?void 0:s.mock_context)??{});return n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("mock_context.label")}),r.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:r.jsx(M.IconPointFilled,{size:10}),children:n.map(i=>r.jsx(o.List.Item,{children:i},i))})]})},LA=({content:e})=>e?r.jsxs(o.Box,{children:[r.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(o.Text,{ta:"left",c:"dimmed",children:"Preview"}),r.jsxs(o.Stack,{children:[r.jsx(IA,{content:e}),r.jsx(zA,{content:e}),r.jsx(EA,{content:e}),r.jsx(AA,{content:e}),r.jsx(PA,{content:e}),r.jsx(OA,{content:e})]})]}):null;function VA(e){if(e.target===null)throw new Error("FileReader failed with null result");if(typeof e.target.result!="string")throw new Error(`Unparsable file content of type: ${typeof e.target.result}`);let t=JSON.parse(e.target.result);if("content"in t&&(t=t.content),t.version!==gn)throw new Error("Schema version mismatch");return t}const BA=D.observer(({onSuccess:e,stretchModal:t,shrinkModal:n})=>{var S,T;const{t:s}=j.useTranslation(),i=re(),{handleSubmit:a,formState:{errors:l},setValue:c,watch:u,setError:d,clearErrors:h}=b.useForm({defaultValues:{content:null}}),p=({content:I})=>{try{if(!I)throw new Error("please use a valid json file");i.applyJSONSchema(I),Yt.showNotification({title:"Successful",message:"",color:"green"}),e()}catch(z){console.error(z),Yt.showNotification({title:"Failed",message:z.message,color:"red"})}},[f,m]=g.useState(null);g.useEffect(()=>{if(!f)return;const I=new FileReader;I.readAsText(f,"UTF-8"),I.onload=z=>{try{const E=VA(z);c("content",E),h("content")}catch(E){console.error(E),d("content",{type:"custom",message:E.message})}},I.onabort=()=>console.log("🟨 abort"),I.onerror=()=>{I.error&&(console.error(I.error),d("content",{type:"custom",message:I.error.message}))}},[f]);const[y]=u(["content"]),_=!y,k=(S=l==null?void 0:l.content)==null?void 0:S.message;return g.useEffect(()=>{!y||k?n():t()},[y,k]),r.jsx(o.Box,{mx:"auto",sx:{position:"relative"},children:r.jsxs("form",{onSubmit:a(p),children:[r.jsx(o.FileInput,{label:s("import.json_file"),required:!0,value:f,onChange:m,error:(T=l==null?void 0:l.content)==null?void 0:T.message,sx:{maxWidth:500}}),k?r.jsx(o.Table,{fontSize:12,mt:10,children:r.jsxs("tbody",{children:[r.jsxs("tr",{children:[r.jsx("th",{children:s("import.this_dashboard")}),r.jsx("td",{children:gn})]}),r.jsxs("tr",{children:[r.jsx("th",{children:s("import.this_file")}),r.jsx("td",{style:{color:"red"},children:y==null?void 0:y.version})]})]})}):r.jsxs(r.Fragment,{children:[r.jsx(LA,{content:y}),r.jsx(o.Group,{position:"right",my:"md",children:r.jsx(o.Button,{type:"submit",color:"green",disabled:_,children:s("common.actions.confirm")})})]})]})})}),fg={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},qA=D.observer(()=>{var d;const{t:e}=j.useTranslation(),[t,{open:n,close:s}]=Se.useDisclosure(!1),[i,{setTrue:a,setFalse:l}]=J.useBoolean(!1),u=((d=le().content.views.VIE)==null?void 0:d.type)===G.Tabs;return u?r.jsx(o.Tooltip,{label:e("common.choose_a_tab_first"),children:r.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:r.jsx(M.IconFileImport,{size:16}),sx:{...fg,transform:"none !important"},children:e("import.label")})}):r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"subtle",color:"blue",radius:0,size:"xs",disabled:u||t,onClick:n,leftIcon:r.jsx(M.IconFileImport,{size:16}),sx:{...fg},children:e("import.label")}),r.jsx(o.Modal,{opened:t,onClose:s,title:e("import.title"),trapFocus:!0,onDragStart:h=>{h.stopPropagation()},withinPortal:!0,zIndex:320,size:i?"90vw":500,children:r.jsx(BA,{onSuccess:s,stretchModal:a,shrinkModal:l})})]})}),NA={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},$A=D.observer(()=>r.jsx(o.Box,{sx:NA,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:r.jsxs(o.Group,{position:"apart",align:"center",sx:{height:"30px"},children:[r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(kA,{}),r.jsx(qA,{})]}),r.jsx(DA,{}),r.jsx(o.Group,{position:"right",spacing:0,children:r.jsx(MA,{})})]})})),FA=D.observer(e=>r.jsxs(r.Fragment,{children:[r.jsx(SA,{...e}),r.jsx($A,{})]})),wV="";function GA(e,t,n){const s=[];return e.filter(i=>"__INTERACTIONS"in i.viz.conf).forEach((i,a)=>{const l=t[i.id];l.data.interactions=v.get(l,"data.interactions",[]);const{__INTERACTIONS:c,__OPERATIONS:u,__TRIGGERS:d}=i.viz.conf;Object.entries(u).forEach(([h,p])=>{const{schemaRef:f,data:m}=p,{config:y}=m;switch(f){case"builtin:op:open-link":let _=y.urlTemplate.substring(0,100);y.urlTemplate.length>=20&&(_+="..."),l.type="interaction",l.data.interactions.push({schemaRef:f,urlTemplate:y.urlTemplate,shortURLTemplate:_});return;case"builtin:op:open_view":s.push({id:`OPERATION--${h}`,source:i.id,target:y.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:f,filters:Object.keys(y.dictionary).map(k=>({key:k,label:n[k]}))});return;case"builtin:op:clear_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:f,filters:y.filter_keys.map(k=>({key:k,label:n[k]}))});return;default:return}})}),s}function WA(e,t){const n=e.filters.keyLabelMap;return{edges:GA(e.panels.list,t,n),edgeNodes:[]}}function gg(e,t,n){return e*t+e*n}function RA(e,t,n){return e*t+(e-1)*n}const vi=25,Vl=40,mg=25,Bl=350,QA=150,UA=150,xg=150,yg=300,_i=40,bg=25,YA=300;function KA(e,t){const n=v.keyBy(t,i=>i.id),s=[];return e.current.forEach((i,a)=>{i.panelIDs.forEach((l,c)=>{const u=gg(c,_i,bg)+Vl,d=n[l];if(!d){s.push({id:l,_node_type:"panel",parentNode:i.id,data:{label:`!: ${l}`},position:{x:vi,y:u},sourcePosition:Ue.Position.Right,targetPosition:Ue.Position.Left,style:{width:yg,height:_i}});return}const h=d.name;s.push({id:d.id,_node_type:"panel",parentNode:i.id,data:{label:h},position:{x:vi,y:u},sourcePosition:Ue.Position.Right,targetPosition:Ue.Position.Left,style:{width:yg,height:_i}})})}),s}const XA={[G.Division]:"Div",[G.Modal]:"Modal",[G.Tabs]:"Tabs"},JA=Zf;function ZA(e){return e.current.map((n,s)=>{const i=RA(n.panelIDs.length,_i,bg)+Vl+mg;let a=[];return n.type===G.Tabs&&(a=n.config.tabsInOrder.map(c=>c.view_id)),{id:n.id,_node_type:"view-root",_view_type:n.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:a,data:{label:`${XA[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:Ue.Position.Right,targetPosition:Ue.Position.Left,className:"light",style:{backgroundColor:JA[n.type],width:Bl,height:i}}})}function HA(e){const t=v.keyBy(e,n=>n.id);e.forEach(n=>{n._node_type!=="view-root"||n._view_type!==G.Tabs||n._tab_view_ids.forEach(s=>{t[s].parentNode=n.id})})}function eP(e){const t=ZA(e.views);HA(t);const n=KA(e.views,e.panels.list);return[...t,...n]}function tP({nodeMap:e,nodes:t,edges:n}){t.forEach(s=>{s._node_type!=="view-root"||s._view_type!==G.Tabs||(s.sourcePosition=Ue.Position.Bottom,s.style.width=Bl+vi*2,s.style.height=mg+s._tab_view_ids.reduce((i,a)=>{const l=e[a];l.position.y=i,l.position.x=vi;const c=l.style.height;return i+c+20},Vl))})}function nP({nodeMap:e,nodes:t,edges:n}){n.filter(s=>s.label==="Open View").forEach(s=>{const i=e[s.source],a=e[s.target];if(!i||!a||!i.parentNode)return;const l=e[i.parentNode];l._node_type!=="view-root"||a._node_type!=="view-root"||(a._view_level+=1+l._view_level,l._sub_view_ids.push(a.id))}),t.sort((s,i)=>s._node_type==="view-root"&&i._node_type==="view-root"?s._view_level-i._view_level:s._node_type!=="view-root"&&i._node_type!=="view-root"?0:s._node_type==="view-root"?-1:1)}function rP({nodeMap:e,nodes:t,edges:n}){const s={};n.forEach(i=>{if(i.label!=="Open View")return;const a=e[i.source],l=e[i.target];if(a&&l&&a.parentNode){const c=e[a.parentNode],u=c.position.x,d=Number(v.get(l,"style.height",0)),h=Number(c.style.width);l.position.x=u+h+YA,c._view_level===0&&l._sub_view_ids.length===0&&(a.sourcePosition=Ue.Position.Left,l.targetPosition=Ue.Position.Right,l.position.x*=-1);const f=l.position.x,m=v.get(s,f,0);l.position.y=m,s[f]=m+d+xg}})}function sP({nodeMap:e,nodes:t,edges:n}){const s=new Set,i=new Set;n.forEach(l=>{s.add(l.source),i.add(l.target)}),t.filter(l=>l._node_type!=="view-root"||l.id==="Main"||l.parentNode?!1:!s.has(l.id)&&!i.has(l.id)).forEach((l,c)=>{l.position.x=gg(c,Bl,UA),l.position.y=0-QA-xg})}function iP({nodeMap:e,nodes:t,edges:n}){const s={nodeMap:e,nodes:t,edges:n};return sP(s),nP(s),tP(s),rP(s),{nodes:t,edges:n}}function aP(e){const t=eP(e),n=v.keyBy(t,u=>u.id),{edges:s,edgeNodes:i}=WA(e,n),a=[...t,...i],l=v.keyBy(a,u=>u.id),c={edges:v.uniqBy(s,u=>u.id),nodes:a,nodeMap:l};return iP(c)}const CV="",ql={"builtin:op:open-link":r.jsx(o.ThemeIcon,{color:"blue",size:20,radius:"xl",children:r.jsx(M.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":r.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:r.jsx(M.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":r.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:r.jsx(M.IconCircleOff,{size:14})})};function oP(e){const t=[];return e.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":t.push({key:n.urlTemplate,icon:ql[n.schemaRef],text:r.jsxs(o.Group,{spacing:4,children:[r.jsx(o.Text,{children:"Open: "}),r.jsx(o.Text,{color:"dimmed",children:n.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":n.filters.forEach(({key:s,label:i})=>{t.push({key:n.schemaRef+s,icon:ql[n.schemaRef],text:r.jsx(o.Group,{spacing:4,children:r.jsxs(o.Text,{children:["Set Filter: ",i]})})})});return;case"builtin:op:clear_filter_values":n.filters.forEach(({key:s,label:i})=>{t.push({key:n.schemaRef+s,icon:ql[n.schemaRef],text:r.jsx(o.Group,{spacing:4,children:r.jsxs(o.Text,{children:["Clear Filter: ",i]})})})});return}}),t}const lP=g.memo(({data:e,isConnectable:t,sourcePosition:n=Ue.Position.Right,targetPosition:s=Ue.Position.Left,...i})=>{const a=g.useMemo(()=>oP(e.interactions),[e.interactions]);return r.jsxs(r.Fragment,{children:[r.jsx(Ue.Handle,{type:"target",position:s,isConnectable:t}),r.jsx(o.Box,{sx:{position:"absolute",top:0,right:0},children:r.jsx(W.ChevronsUpRight,{size:12})}),r.jsxs(o.HoverCard,{shadow:"xl",withinPortal:!0,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Text,{children:e.label})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(o.List,{spacing:"xs",size:"sm",center:!0,children:a.map(l=>r.jsx(o.List.Item,{icon:l.icon,children:l.text},l.key))})})]}),r.jsx(Ue.Handle,{type:"source",position:n,isConnectable:t})]})}),SV="",cP={interaction:lP},uP=D.observer(()=>{const e=Pe(),{edges:t,nodes:n}=aP(e);return r.jsxs(Ue,{nodes:n,edges:t,onNodesChange:v.noop,onEdgesChange:v.noop,onConnect:v.noop,className:"interactions-viewer",fitView:!0,nodeTypes:cP,children:[r.jsx(Ue.MiniMap,{}),r.jsx(Ue.Controls,{}),r.jsx(Ue.Background,{})]})}),dP=D.observer(({opened:e,close:t})=>{const{t:n}=j.useTranslation();return r.jsx(o.Modal,{size:"96vw",opened:e,onClose:t,title:n("interactions.interactions_viewer"),trapFocus:!0,onDragStart:s=>{s.stopPropagation()},styles:{body:{height:"calc(90vh - 54px)"},content:{transform:"none !important"}},zIndex:300,children:r.jsx(uP,{})})}),pP={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}};function hP({onClick:e,name:t,active:n,openSettings:s}){return r.jsxs(o.Box,{sx:{position:"relative"},children:[r.jsx(o.UnstyledButton,{sx:i=>({display:"block",width:"100%",padding:i.spacing.xs,borderRadius:0,position:"relative",color:i.black,"&:hover":{backgroundColor:i.colors.gray[0]},backgroundColor:n?i.colors.gray[2]:"transparent"}),children:r.jsx(o.Group,{sx:{width:"calc(100% - 28px)"},onClick:e,children:r.jsx(o.Text,{size:"sm",children:t})})}),n&&r.jsx(o.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:r.jsx(o.ActionIcon,{onClick:s,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:r.jsx(M.IconAdjustments,{size:16})})})]})}const fP=D.observer(()=>{const{t:e}=j.useTranslation(),t=le(),n=re(),s=g.useCallback(a=>()=>n.views.setIDOfVIE(a),[n]),i=a=>{t.editor.open(["_VIEWS_",a])};return r.jsxs(o.Box,{sx:{position:"relative"},children:[n.views.options.map(a=>r.jsx(hP,{active:n.views.idOfVIE===a.value,name:a.label,onClick:s(a.value),openSettings:()=>i(a.value)},a.value)),r.jsx(o.Divider,{variant:"dashed"}),r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:n.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:e("view.add")})]})}),gP=D.observer(()=>{const{t:e}=j.useTranslation(),t=le(),n=re(),s=()=>{if(!n.queries.firstID){t.editor.open(["_QUERIES_",""]);return}t.editor.open(["_QUERIES_",n.queries.firstID])},i=()=>{if(!n.filters.firstID){t.editor.open(["_FILTERS_",""]);return}t.editor.open(["_FILTERS_",n.filters.firstID])},[a,l]=g.useState(!1),c=()=>l(!0),u=()=>l(!1);return r.jsxs(o.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},zIndex:299,children:[r.jsxs(o.Navbar.Section,{children:[r.jsxs(o.Group,{grow:!0,spacing:0,sx:{...pP,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[r.jsx(o.Tooltip,{label:e("filter.labels"),withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:i,children:r.jsx(M.IconFilter,{size:18})})}),r.jsx(o.Tooltip,{label:e("query.labels"),withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:s,children:r.jsx(M.IconDatabase,{size:18})})}),r.jsx(o.Tooltip,{label:e("interactions.interactions_viewer"),withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:c,children:r.jsx(M.IconLink,{size:18})})})]}),r.jsx(dP,{opened:a,close:u})]}),r.jsx(o.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:e("view.labels")})}),r.jsx(o.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:r.jsx(fP,{})}),r.jsx(o.Navbar.Section,{children:r.jsx(o.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:r.jsx(o.Button,{size:"xs",leftIcon:r.jsx(M.IconSettings,{size:20}),onClick:()=>t.editor.open([]),children:e("common.titles.settings")})})})]})}),mP={[Ce.Checkbox]:"true",[Ce.DateRange]:"[new Date('2023-01-01 00:00:00'), new Date('2024-01-01 00:00:00')]",[Ce.MultiSelect]:"[]",[Ce.Select]:'""',[Ce.TreeSelect]:"[]",[Ce.TextInput]:'""'},xP=e=>["function getDefaultValue(filter, utils, context) {",` return ${mP[e]};`,"}"].join(`