@devtable/dashboard 14.16.1 → 14.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,12 +1,12 @@
1
- (function(C,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("dayjs"),require("dayjs/plugin/advancedFormat"),require("dayjs/plugin/arraySupport"),require("dayjs/plugin/buddhistEra"),require("dayjs/plugin/calendar"),require("dayjs/plugin/customParseFormat"),require("dayjs/plugin/dayOfYear"),require("dayjs/plugin/duration"),require("dayjs/plugin/isBetween"),require("dayjs/plugin/isLeapYear"),require("dayjs/plugin/isMoment"),require("dayjs/plugin/isoWeek"),require("dayjs/plugin/isoWeeksInYear"),require("dayjs/plugin/isSameOrAfter"),require("dayjs/plugin/isSameOrBefore"),require("dayjs/plugin/isToday"),require("dayjs/plugin/isTomorrow"),require("dayjs/plugin/isYesterday"),require("dayjs/plugin/localeData"),require("dayjs/plugin/localizedFormat"),require("dayjs/plugin/minMax"),require("dayjs/plugin/objectSupport"),require("dayjs/plugin/pluralGetSet"),require("dayjs/plugin/preParsePostFormat"),require("dayjs/plugin/quarterOfYear"),require("dayjs/plugin/relativeTime"),require("dayjs/plugin/timezone"),require("dayjs/plugin/toArray"),require("dayjs/plugin/toObject"),require("dayjs/plugin/updateLocale"),require("dayjs/plugin/utc"),require("dayjs/plugin/weekday"),require("dayjs/plugin/weekOfYear"),require("dayjs/plugin/weekYear"),require("i18next"),require("react-i18next"),require("i18next-browser-languagedetector"),require("intl-pluralrules"),require("lodash"),require("mobx"),require("eventemitter2"),require("react/jsx-runtime"),require("react"),require("chroma-js"),require("echarts-for-react/lib/core"),require("echarts-gl"),require("echarts/core"),require("ahooks"),require("@mantine/core"),require("@mantine/hooks"),require("popmotion"),require("d3-array"),require("mathjs"),require("@faker-js/faker"),require("crypto-js"),require("numbro"),require("@tabler/icons-react"),require("@mantine/tiptap"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-placeholder"),require("@tiptap/extension-subscript"),require("@tiptap/extension-superscript"),require("@tiptap/extension-table"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-table-row"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-underline"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("@mantine/dates"),require("@monaco-editor/react"),require("@tiptap/core"),require("d3-scale"),require("react-hook-form"),require("mobx-react-lite"),require("@dnd-kit/helpers"),require("@dnd-kit/react"),require("@dnd-kit/react/sortable"),require("uuid"),require("echarts/charts"),require("echarts/components"),require("echarts/renderers"),require("constrained-editor-plugin"),require("@mantine/notifications"),require("@mantine/emotion"),require("d3-regression"),require("@mantine/code-highlight"),require("@tanstack/react-table"),require("@tanstack/react-virtual"),require("axios"),require("@mantine/modals"),require("js-base64"),require("mobx-state-tree"),require("file-saver"),require("dom-to-image-more"),require("jszip"),require("@json2csv/whatwg"),require("rc-tree-select"),require("performant-array-to-tree"),require("rc-select"),require("react-grid-layout"),require("react-dom"),require("@mantine/spotlight"),require("@mantine/spotlight/styles.css"),require("reactflow"),require("reactflow/dist/style.css")):typeof define=="function"&&define.amd?define(["exports","dayjs","dayjs/plugin/advancedFormat","dayjs/plugin/arraySupport","dayjs/plugin/buddhistEra","dayjs/plugin/calendar","dayjs/plugin/customParseFormat","dayjs/plugin/dayOfYear","dayjs/plugin/duration","dayjs/plugin/isBetween","dayjs/plugin/isLeapYear","dayjs/plugin/isMoment","dayjs/plugin/isoWeek","dayjs/plugin/isoWeeksInYear","dayjs/plugin/isSameOrAfter","dayjs/plugin/isSameOrBefore","dayjs/plugin/isToday","dayjs/plugin/isTomorrow","dayjs/plugin/isYesterday","dayjs/plugin/localeData","dayjs/plugin/localizedFormat","dayjs/plugin/minMax","dayjs/plugin/objectSupport","dayjs/plugin/pluralGetSet","dayjs/plugin/preParsePostFormat","dayjs/plugin/quarterOfYear","dayjs/plugin/relativeTime","dayjs/plugin/timezone","dayjs/plugin/toArray","dayjs/plugin/toObject","dayjs/plugin/updateLocale","dayjs/plugin/utc","dayjs/plugin/weekday","dayjs/plugin/weekOfYear","dayjs/plugin/weekYear","i18next","react-i18next","i18next-browser-languagedetector","intl-pluralrules","lodash","mobx","eventemitter2","react/jsx-runtime","react","chroma-js","echarts-for-react/lib/core","echarts-gl","echarts/core","ahooks","@mantine/core","@mantine/hooks","popmotion","d3-array","mathjs","@faker-js/faker","crypto-js","numbro","@tabler/icons-react","@mantine/tiptap","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-placeholder","@tiptap/extension-subscript","@tiptap/extension-superscript","@tiptap/extension-table","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-table-row","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-underline","@tiptap/react","@tiptap/starter-kit","@mantine/dates","@monaco-editor/react","@tiptap/core","d3-scale","react-hook-form","mobx-react-lite","@dnd-kit/helpers","@dnd-kit/react","@dnd-kit/react/sortable","uuid","echarts/charts","echarts/components","echarts/renderers","constrained-editor-plugin","@mantine/notifications","@mantine/emotion","d3-regression","@mantine/code-highlight","@tanstack/react-table","@tanstack/react-virtual","axios","@mantine/modals","js-base64","mobx-state-tree","file-saver","dom-to-image-more","jszip","@json2csv/whatwg","rc-tree-select","performant-array-to-tree","rc-select","react-grid-layout","react-dom","@mantine/spotlight","@mantine/spotlight/styles.css","reactflow","reactflow/dist/style.css"],D):(C=typeof globalThis<"u"?globalThis:C||self,D(C.dashboard={},C.dayjs,C["dayjs/plugin/advancedFormat"],C["dayjs/plugin/arraySupport"],C["dayjs/plugin/buddhistEra"],C["dayjs/plugin/calendar"],C["dayjs/plugin/customParseFormat"],C["dayjs/plugin/dayOfYear"],C["dayjs/plugin/duration"],C["dayjs/plugin/isBetween"],C["dayjs/plugin/isLeapYear"],C["dayjs/plugin/isMoment"],C["dayjs/plugin/isoWeek"],C["dayjs/plugin/isoWeeksInYear"],C["dayjs/plugin/isSameOrAfter"],C["dayjs/plugin/isSameOrBefore"],C["dayjs/plugin/isToday"],C["dayjs/plugin/isTomorrow"],C["dayjs/plugin/isYesterday"],C["dayjs/plugin/localeData"],C["dayjs/plugin/localizedFormat"],C["dayjs/plugin/minMax"],C["dayjs/plugin/objectSupport"],C["dayjs/plugin/pluralGetSet"],C["dayjs/plugin/preParsePostFormat"],C["dayjs/plugin/quarterOfYear"],C["dayjs/plugin/relativeTime"],C["dayjs/plugin/timezone"],C["dayjs/plugin/toArray"],C["dayjs/plugin/toObject"],C["dayjs/plugin/updateLocale"],C["dayjs/plugin/utc"],C["dayjs/plugin/weekday"],C["dayjs/plugin/weekOfYear"],C["dayjs/plugin/weekYear"],C.i18next,C["react-i18next"],C["i18next-browser-languagedetector"],C["intl-pluralrules"],C._,C.mobx,C.eventemitter2,C["react/jsx-runtime"],C.react,C["chroma-js"],C["echarts-for-react/lib/core"],C["echarts-gl"],C["echarts/core"],C.ahooks,C["@mantine/core"],C["@mantine/hooks"],C.popmotion,C["d3-array"],C.mathjs,C["@faker-js/faker"],C.CryptoJS,C.numbro,C["@tabler/icons-react"],C["@mantine/tiptap"],C["@tiptap/extension-color"],C["@tiptap/extension-highlight"],C["@tiptap/extension-placeholder"],C["@tiptap/extension-subscript"],C["@tiptap/extension-superscript"],C["@tiptap/extension-table"],C["@tiptap/extension-table-cell"],C["@tiptap/extension-table-header"],C["@tiptap/extension-table-row"],C["@tiptap/extension-text-align"],C["@tiptap/extension-text-style"],C["@tiptap/extension-underline"],C["@tiptap/react"],C["@tiptap/starter-kit"],C["@mantine/dates"],C["@monaco-editor/react"],C["@tiptap/core"],C["d3-scale"],C["react-hook-form"],C["mobx-react-lite"],C["@dnd-kit/helpers"],C["@dnd-kit/react"],C["@dnd-kit/react/sortable"],C.uuid,C["echarts/charts"],C["echarts/components"],C["echarts/renderers"],C["constrained-editor-plugin"],C["@mantine/notifications"],C["@mantine/emotion"],C["d3-regression"],C["@mantine/code-highlight"],C["@tanstack/react-table"],C["@tanstack/react-virtual"],C.axios,C["@mantine/modals"],C["js-base64"],C["mobx-state-tree"],C["file-saver"],C["dom-to-image-more"],C.jszip,C["@json2csv/whatwg"],C["rc-tree-select"],C["performant-array-to-tree"],C["rc-select"],C["react-grid-layout"],C["react-dom"],C["@mantine/spotlight"],C["@mantine/spotlight/styles"].css,C.reactflow))})(this,function(C,D,ot,Pc,Vc,$c,Ec,Bc,Lc,qc,Oc,Nc,Gc,Fc,jc,Qc,Wc,Uc,Yc,Kc,Xc,Zc,Jc,Hc,Rc,ed,td,nd,rd,ad,sd,ld,od,id,cd,dd,m,ud,s3,b,j,Ba,n,g,$e,pe,l3,La,q,s,te,et,It,pd,hd,qa,ct,T,G,Oa,Na,Ga,Fa,ja,Qa,Wa,Ua,Ya,Ka,Xa,Za,Ja,Ha,Ra,we,zn,gd,y,S,es,Dn,In,Fe,je,tt,fd,bd,Qe,nt,yd,Ee,he,vd,Ce,Te,ts,h,Ot,ns,rs,_d,Mn,xd,as,Nt,md,dt,o3,ie){"use strict";var r3=Object.defineProperty;var a3=(C,D,ot)=>D in C?r3(C,D,{enumerable:!0,configurable:!0,writable:!0,value:ot}):C[D]=ot;var P=(C,D,ot)=>(a3(C,typeof D!="symbol"?D+"":D,ot),ot);function ut(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const ce=ut(La),wd=ut(et),ss=ut(It),vt=ut(pd),Cd=ut(qa),Td=ut(gd),rt=ut(yd);D.extend(ot),D.extend(Pc),D.extend(Vc),D.extend($c),D.extend(Ec),D.extend(Bc),D.extend(Lc),D.extend(qc),D.extend(Oc),D.extend(Nc),D.extend(jc),D.extend(Qc),D.extend(Wc),D.extend(Uc),D.extend(Yc),D.extend(Gc),D.extend(Fc),D.extend(Kc),D.extend(Xc),D.extend(Zc),D.extend(Jc),D.extend(Hc),D.extend(Rc),D.extend(ed),D.extend(td),D.extend(nd),D.extend(rd),D.extend(ad),D.extend(sd),D.extend(ld),D.extend(id),D.extend(cd),D.extend(od),D.tz.setDefault("UTC"),D.updateLocale("en",{weekStart:1});const Sd={translation:{filter:{label:"Filter",labels:"Filters",add:"Add a Filter",manage:"Manage Filters",delete:"Delete this filter",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 default value",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",tree_single_select:"Tree Single 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",preset_options:{apply:"Apply preset options",date_unit:"Date units"}},multi_select:{width_description:"At least 160px"},tree_select:{strictly:"Parent and children nodes are not associated"},tree_single_select:{select_first_option_by_default:"Select the first option by default"},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:{label:"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",invalid:"Invalid",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:{actions:"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 <0>{{name}}</0>"},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"},guide:{text:`-- You may reference dashboard state & panel variables in rich-text content or custom functions.
1
+ (function(C,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("dayjs"),require("dayjs/plugin/advancedFormat"),require("dayjs/plugin/arraySupport"),require("dayjs/plugin/buddhistEra"),require("dayjs/plugin/calendar"),require("dayjs/plugin/customParseFormat"),require("dayjs/plugin/dayOfYear"),require("dayjs/plugin/duration"),require("dayjs/plugin/isBetween"),require("dayjs/plugin/isLeapYear"),require("dayjs/plugin/isMoment"),require("dayjs/plugin/isoWeek"),require("dayjs/plugin/isoWeeksInYear"),require("dayjs/plugin/isSameOrAfter"),require("dayjs/plugin/isSameOrBefore"),require("dayjs/plugin/isToday"),require("dayjs/plugin/isTomorrow"),require("dayjs/plugin/isYesterday"),require("dayjs/plugin/localeData"),require("dayjs/plugin/localizedFormat"),require("dayjs/plugin/minMax"),require("dayjs/plugin/objectSupport"),require("dayjs/plugin/pluralGetSet"),require("dayjs/plugin/preParsePostFormat"),require("dayjs/plugin/quarterOfYear"),require("dayjs/plugin/relativeTime"),require("dayjs/plugin/timezone"),require("dayjs/plugin/toArray"),require("dayjs/plugin/toObject"),require("dayjs/plugin/updateLocale"),require("dayjs/plugin/utc"),require("dayjs/plugin/weekday"),require("dayjs/plugin/weekOfYear"),require("dayjs/plugin/weekYear"),require("i18next"),require("react-i18next"),require("i18next-browser-languagedetector"),require("intl-pluralrules"),require("lodash"),require("mobx"),require("eventemitter2"),require("react/jsx-runtime"),require("react"),require("chroma-js"),require("echarts-for-react/lib/core"),require("echarts-gl"),require("echarts/core"),require("ahooks"),require("@mantine/core"),require("@mantine/hooks"),require("popmotion"),require("d3-array"),require("mathjs"),require("@faker-js/faker"),require("crypto-js"),require("numbro"),require("@tabler/icons-react"),require("@mantine/tiptap"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-placeholder"),require("@tiptap/extension-subscript"),require("@tiptap/extension-superscript"),require("@tiptap/extension-table"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-table-row"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-underline"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("@mantine/dates"),require("@monaco-editor/react"),require("@tiptap/core"),require("d3-scale"),require("react-hook-form"),require("mobx-react-lite"),require("@dnd-kit/helpers"),require("@dnd-kit/react"),require("@dnd-kit/react/sortable"),require("uuid"),require("echarts/charts"),require("echarts/components"),require("echarts/renderers"),require("constrained-editor-plugin"),require("@mantine/notifications"),require("@mantine/emotion"),require("d3-regression"),require("@mantine/code-highlight"),require("@tanstack/react-table"),require("@tanstack/react-virtual"),require("axios"),require("@mantine/modals"),require("js-base64"),require("mobx-state-tree"),require("file-saver"),require("dom-to-image-more"),require("jszip"),require("@json2csv/whatwg"),require("rc-tree-select"),require("performant-array-to-tree"),require("rc-select"),require("react-grid-layout"),require("react-dom"),require("@mantine/spotlight"),require("@mantine/spotlight/styles.css"),require("reactflow"),require("reactflow/dist/style.css")):typeof define=="function"&&define.amd?define(["exports","dayjs","dayjs/plugin/advancedFormat","dayjs/plugin/arraySupport","dayjs/plugin/buddhistEra","dayjs/plugin/calendar","dayjs/plugin/customParseFormat","dayjs/plugin/dayOfYear","dayjs/plugin/duration","dayjs/plugin/isBetween","dayjs/plugin/isLeapYear","dayjs/plugin/isMoment","dayjs/plugin/isoWeek","dayjs/plugin/isoWeeksInYear","dayjs/plugin/isSameOrAfter","dayjs/plugin/isSameOrBefore","dayjs/plugin/isToday","dayjs/plugin/isTomorrow","dayjs/plugin/isYesterday","dayjs/plugin/localeData","dayjs/plugin/localizedFormat","dayjs/plugin/minMax","dayjs/plugin/objectSupport","dayjs/plugin/pluralGetSet","dayjs/plugin/preParsePostFormat","dayjs/plugin/quarterOfYear","dayjs/plugin/relativeTime","dayjs/plugin/timezone","dayjs/plugin/toArray","dayjs/plugin/toObject","dayjs/plugin/updateLocale","dayjs/plugin/utc","dayjs/plugin/weekday","dayjs/plugin/weekOfYear","dayjs/plugin/weekYear","i18next","react-i18next","i18next-browser-languagedetector","intl-pluralrules","lodash","mobx","eventemitter2","react/jsx-runtime","react","chroma-js","echarts-for-react/lib/core","echarts-gl","echarts/core","ahooks","@mantine/core","@mantine/hooks","popmotion","d3-array","mathjs","@faker-js/faker","crypto-js","numbro","@tabler/icons-react","@mantine/tiptap","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-placeholder","@tiptap/extension-subscript","@tiptap/extension-superscript","@tiptap/extension-table","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-table-row","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-underline","@tiptap/react","@tiptap/starter-kit","@mantine/dates","@monaco-editor/react","@tiptap/core","d3-scale","react-hook-form","mobx-react-lite","@dnd-kit/helpers","@dnd-kit/react","@dnd-kit/react/sortable","uuid","echarts/charts","echarts/components","echarts/renderers","constrained-editor-plugin","@mantine/notifications","@mantine/emotion","d3-regression","@mantine/code-highlight","@tanstack/react-table","@tanstack/react-virtual","axios","@mantine/modals","js-base64","mobx-state-tree","file-saver","dom-to-image-more","jszip","@json2csv/whatwg","rc-tree-select","performant-array-to-tree","rc-select","react-grid-layout","react-dom","@mantine/spotlight","@mantine/spotlight/styles.css","reactflow","reactflow/dist/style.css"],D):(C=typeof globalThis<"u"?globalThis:C||self,D(C.dashboard={},C.dayjs,C["dayjs/plugin/advancedFormat"],C["dayjs/plugin/arraySupport"],C["dayjs/plugin/buddhistEra"],C["dayjs/plugin/calendar"],C["dayjs/plugin/customParseFormat"],C["dayjs/plugin/dayOfYear"],C["dayjs/plugin/duration"],C["dayjs/plugin/isBetween"],C["dayjs/plugin/isLeapYear"],C["dayjs/plugin/isMoment"],C["dayjs/plugin/isoWeek"],C["dayjs/plugin/isoWeeksInYear"],C["dayjs/plugin/isSameOrAfter"],C["dayjs/plugin/isSameOrBefore"],C["dayjs/plugin/isToday"],C["dayjs/plugin/isTomorrow"],C["dayjs/plugin/isYesterday"],C["dayjs/plugin/localeData"],C["dayjs/plugin/localizedFormat"],C["dayjs/plugin/minMax"],C["dayjs/plugin/objectSupport"],C["dayjs/plugin/pluralGetSet"],C["dayjs/plugin/preParsePostFormat"],C["dayjs/plugin/quarterOfYear"],C["dayjs/plugin/relativeTime"],C["dayjs/plugin/timezone"],C["dayjs/plugin/toArray"],C["dayjs/plugin/toObject"],C["dayjs/plugin/updateLocale"],C["dayjs/plugin/utc"],C["dayjs/plugin/weekday"],C["dayjs/plugin/weekOfYear"],C["dayjs/plugin/weekYear"],C.i18next,C["react-i18next"],C["i18next-browser-languagedetector"],C["intl-pluralrules"],C._,C.mobx,C.eventemitter2,C["react/jsx-runtime"],C.react,C["chroma-js"],C["echarts-for-react/lib/core"],C["echarts-gl"],C["echarts/core"],C.ahooks,C["@mantine/core"],C["@mantine/hooks"],C.popmotion,C["d3-array"],C.mathjs,C["@faker-js/faker"],C.CryptoJS,C.numbro,C["@tabler/icons-react"],C["@mantine/tiptap"],C["@tiptap/extension-color"],C["@tiptap/extension-highlight"],C["@tiptap/extension-placeholder"],C["@tiptap/extension-subscript"],C["@tiptap/extension-superscript"],C["@tiptap/extension-table"],C["@tiptap/extension-table-cell"],C["@tiptap/extension-table-header"],C["@tiptap/extension-table-row"],C["@tiptap/extension-text-align"],C["@tiptap/extension-text-style"],C["@tiptap/extension-underline"],C["@tiptap/react"],C["@tiptap/starter-kit"],C["@mantine/dates"],C["@monaco-editor/react"],C["@tiptap/core"],C["d3-scale"],C["react-hook-form"],C["mobx-react-lite"],C["@dnd-kit/helpers"],C["@dnd-kit/react"],C["@dnd-kit/react/sortable"],C.uuid,C["echarts/charts"],C["echarts/components"],C["echarts/renderers"],C["constrained-editor-plugin"],C["@mantine/notifications"],C["@mantine/emotion"],C["d3-regression"],C["@mantine/code-highlight"],C["@tanstack/react-table"],C["@tanstack/react-virtual"],C.axios,C["@mantine/modals"],C["js-base64"],C["mobx-state-tree"],C["file-saver"],C["dom-to-image-more"],C.jszip,C["@json2csv/whatwg"],C["rc-tree-select"],C["performant-array-to-tree"],C["rc-select"],C["react-grid-layout"],C["react-dom"],C["@mantine/spotlight"],C["@mantine/spotlight/styles"].css,C.reactflow))})(this,function(C,D,ot,Pc,Vc,$c,Ec,Bc,Lc,qc,Oc,Nc,Gc,Fc,jc,Qc,Wc,Uc,Yc,Kc,Xc,Zc,Jc,Hc,Rc,ed,td,nd,rd,ad,sd,ld,od,id,cd,dd,m,ud,s3,b,j,Ba,n,g,$e,pe,l3,La,q,s,te,et,It,pd,hd,qa,ct,T,G,Oa,Na,Ga,Fa,ja,Qa,Wa,Ua,Ya,Ka,Xa,Za,Ja,Ha,Ra,we,zn,gd,y,S,es,Dn,In,Fe,je,tt,fd,bd,Qe,nt,yd,Ee,he,vd,Ce,Te,ts,h,Ot,ns,rs,_d,Mn,xd,as,Nt,md,dt,o3,ie){"use strict";var r3=Object.defineProperty;var a3=(C,D,ot)=>D in C?r3(C,D,{enumerable:!0,configurable:!0,writable:!0,value:ot}):C[D]=ot;var P=(C,D,ot)=>(a3(C,typeof D!="symbol"?D+"":D,ot),ot);function ut(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const ce=ut(La),wd=ut(et),ss=ut(It),vt=ut(pd),Cd=ut(qa),Td=ut(gd),rt=ut(yd);D.extend(ot),D.extend(Pc),D.extend(Vc),D.extend($c),D.extend(Ec),D.extend(Bc),D.extend(Lc),D.extend(qc),D.extend(Oc),D.extend(Nc),D.extend(jc),D.extend(Qc),D.extend(Wc),D.extend(Uc),D.extend(Yc),D.extend(Gc),D.extend(Fc),D.extend(Kc),D.extend(Xc),D.extend(Zc),D.extend(Jc),D.extend(Hc),D.extend(Rc),D.extend(ed),D.extend(td),D.extend(nd),D.extend(rd),D.extend(ad),D.extend(sd),D.extend(ld),D.extend(id),D.extend(cd),D.extend(od),D.tz.setDefault("UTC"),D.updateLocale("en",{weekStart:1});const Sd={translation:{filter:{label:"Filter",labels:"Filters",add:"Add a Filter",manage:"Manage Filters",delete:"Delete this filter",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 default value",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",tree_single_select:"Tree Single 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",preset_options:{apply:"Apply preset options",date_unit:"Date units"}},multi_select:{width_description:"At least 160px"},tree_select:{strictly:"Parent and children nodes are not associated"},tree_single_select:{select_first_option_by_default:"Select the first option by default"},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:{label:"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",invalid:"Invalid",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:{search:"Search",reload:"Reload",actions:"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 <0>{{name}}</0>"},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"},guide:{text:`-- You may reference dashboard state & panel variables in rich-text content or custom functions.
2
2
  -- use double curly brackets to wrap code in rich-text content.
3
3
  Project ID: {{ context.project_id }}
4
4
  Keyword: {{ filters.keyword }}
5
- Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel variables"}}}},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",description:"Falsy: empty array / NaN / false / empty string / undefined / null",unset:"Leave it empty to 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"},series_order:{label:"Order series by...",name:"Name",value:"Value",raw:"Record order",asc:"Ascending",desc:"Descending"},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",area_style:{label:"Area style",enabled:"Enable area style",color:"Area color",use_series_color:"Use series' color",origin:{label:"Origin position of the area",auto:{label:"Auto",description:"Fill between axis line and data (Default)"},start:{label:"Start",description:"Fill between min axis value and data"},end:{label:"End",description:"Fill between max axis value and data"}},shadow_blur:"Shadow Blur",shadow_color:"Shadow Color",shadow_offset_x:"Shadow Offset X",shadow_offset_y:"Shadow Offset Y",opacity:"Opacity"}},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",inverse:"Inverse",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:"Stats above the chart",under_chart:"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",background_color:"Background Color",text_color:"Text Color",click_to_add_a_color:"Click to add a color",color_gradient:"Color Gradient",not_set:"Not set"},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"}},spotlight:{trigger_text:"Search",main_group:"Main",placeholder:"Search to open...",not_found:"Nothing found..."}}},kd={translation:{filter:{label:"筛选器",labels:"筛选器",add:"新增筛选器",manage:"管理筛选器",delete:"删除这个筛选器",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:"树形选择器",tree_single_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:"默认选中第一个选项",preset_options:{apply:"使用预设选项列表",date_unit:"日期步长"}},multi_select:{width_description:"至少160px"},tree_select:{strictly:"枝叶节点不相关,各选各的"},tree_single_select:{select_first_option_by_default:"默认选中第一个选项"},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:{label:"分页",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:"最大值",invalid:"无效的",data_field:"数据字段",name_data_field:"名称字段",value_data_field:"值字段",color_data_field:"颜色字段",enabled:"启用",copied:"已复制到剪切板",action:"操作",actions:{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:"结束编辑 <0>{{name}}</0>"},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:"当数据为空或聚合结果非数字时,使用此兜底值"},guide:{text:`-- 可以在富文本和自定义函数中,使用看板信息以及卡片的变量。
5
+ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel variables"}}}},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",description:"Falsy: empty array / NaN / false / empty string / undefined / null",unset:"Leave it empty to 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"},series_order:{label:"Order series by...",name:"Name",value:"Value",raw:"Record order",asc:"Ascending",desc:"Descending"},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",area_style:{label:"Area style",enabled:"Enable area style",color:"Area color",use_series_color:"Use series' color",origin:{label:"Origin position of the area",auto:{label:"Auto",description:"Fill between axis line and data (Default)"},start:{label:"Start",description:"Fill between min axis value and data"},end:{label:"End",description:"Fill between max axis value and data"}},shadow_blur:"Shadow Blur",shadow_color:"Shadow Color",shadow_offset_x:"Shadow Offset X",shadow_offset_y:"Shadow Offset Y",opacity:"Opacity"}},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",inverse:"Inverse",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:"Stats above the chart",under_chart:"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",background_color:"Background Color",text_color:"Text Color",click_to_add_a_color:"Click to add a color",color_gradient:"Color Gradient",not_set:"Not set"},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"}},spotlight:{trigger_text:"Search",main_group:"Main",placeholder:"Search to open...",not_found:"Nothing found..."}}},kd={translation:{filter:{label:"筛选器",labels:"筛选器",add:"新增筛选器",manage:"管理筛选器",delete:"删除这个筛选器",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:"树形选择器",tree_single_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:"默认选中第一个选项",preset_options:{apply:"使用预设选项列表",date_unit:"日期步长"}},multi_select:{width_description:"至少160px"},tree_select:{strictly:"枝叶节点不相关,各选各的"},tree_single_select:{select_first_option_by_default:"默认选中第一个选项"},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:{label:"分页",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:"最大值",invalid:"无效的",data_field:"数据字段",name_data_field:"名称字段",value_data_field:"值字段",color_data_field:"颜色字段",enabled:"启用",copied:"已复制到剪切板",action:"操作",actions:{search:"查询",reload:"刷新",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:"结束编辑 <0>{{name}}</0>"},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:"当数据为空或聚合结果非数字时,使用此兜底值"},guide:{text:`-- 可以在富文本和自定义函数中,使用看板信息以及卡片的变量。
6
6
  -- 在富文本中,要使用双重花括号来包裹代码。
7
7
  项目ID:{{ context.project_id }}
8
8
  搜索关键字:{{ filters.keyword }}
9
- 我的卡片变量: {{ your_var }}`,tabs:{guide:"使用指南",vars:"看板信息与卡片的变量"}}}},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:"以下条件为真时,才运行本查询",description:"为假的情况: 空数组 / NaN / false / 空字符串 / undefined / null",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:"其他"},series_order:{label:"排序依据",name:"名称",value:"值",raw:"不排序,保持数据本身的顺序",asc:"升序",desc:"降序"},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:"显示标记点",area_style:{label:"区域填充样式",enabled:"启用区域填充",color:"填充颜色",use_series_color:"沿用系列本色",origin:{label:"图形区域的起始位置",auto:{label:"自动",description:"填充坐标轴线到数据间的区域(默认)"},start:{label:"自下而上",description:"填充坐标轴底部到数据间的区域"},end:{label:"自上而下",description:"填充坐标轴顶部到数据间的区域"}},shadow_blur:"图形阴影的模糊大小",shadow_color:"图形阴影的颜色",shadow_offset_x:"阴影水平方向上的偏移距离",shadow_offset_y:"阴影垂直方向上的偏移距离",opacity:"图形透明度"}},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轴数据字段",inverse:"反向坐标轴",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:"颜色",background_color:"背景色",text_color:"文字颜色",click_to_add_a_color:"点击增加一个颜色",color_gradient:"颜色渐变",not_set:"未设置"},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:"请填写一个数字"}},spotlight:{trigger_text:"搜索",main_group:"主要项",placeholder:"打开…",not_found:"无匹配项"}}};class Gt{constructor(t){P(this,"rootRef");this.rootRef=j.observable({current:t})}async deleteItem(t){j.runInAction(()=>{b.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?j.toJS(this.rootRef.current):b.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(b.isObject(r))j.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else j.runInAction(()=>{b.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,a){return j.reaction(()=>this.getValueFromRoot(t),(l,o)=>{r(l,o)},{requiresObservable:!0,fireImmediately:b.get(a,"fireImmediately",!1)})}}class zd{constructor(){P(this,"channels",new Map);P(this,"globalChannel",new Ba)}getChannel(t){const r=this.channels.get(t);if(r)return r;const a=new Ba;return this.channels.set(t,a),a}}class Dd{constructor(t){P(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const r=this.instances.get(t.id);if(r)return r;const a={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new zd,instanceData:new Gt(t.viz.conf)};return this.instances.set(t.id,a),a}}function ls(e,t,r,a){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new Gt({}),colorPalette:{getColor(){return()=>""}},data:t,variables:a}}const Id=e=>{const{panel:t,measure:r,vizManager:a,data:l,variables:o}=e,i=a.resolveComponent(t.viz.type),c=a.getOrCreateInstance(t),d={...ls(c,l,a,o),viewport:{width:r.w,height:r.h}},u=i.viewRender;return n.jsx(u,{context:d,instance:c,...b.omit(e,["panel","vizManager","data"])})},Md=e=>{const{vizManager:t,panel:r,data:a,variables:l}=e,o=t.resolveComponent(r.viz.type),i=t.getOrCreateInstance(r),c={...ls(i,a,t,l)},d=o.configRender;return n.jsx(d,{context:c,instance:i,...b.omit(e,["panel","vizManager","data"])})},os=(e,t)=>{const r=$e.bezier(e),a=$e.bezier(t);return function(l){return l<50?r(l*2/100).hex():a((l-50)*2/100).hex()}},Ft=e=>{const t=$e.bezier(e);return function(r){return t(r/100).hex()}},Ad={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:os(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Pd={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:os(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Vd={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:Ft(["#fff7f1","darkred"]),name:"red",category:"sequential"},$d={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:Ft(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ed={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:Ft(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Bd={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:Ft(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Ld{constructor(t){P(this,"symbol");this.symbol=Symbol(t)}}function We(e){return new Ld(e)}class An{constructor(){P(this,"parent");P(this,"factoryRegistry",new Map);P(this,"instanceRegistry",new Map)}createScoped(){const t=new An;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const r=this.factoryRegistry.get(t.symbol);if(r){const a=r(this);return this.instanceRegistry.set(t.symbol,a),a}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=b.get(t,"dispose");b.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}class qd{constructor(t){this.pluginManager=t}createPanelAddonNode(t){const a=this.pluginManager.installedPlugins.flatMap(l=>l.manifest.panelAddon).filter(l=>!!l).map(l=>g.createElement(l.addonRender,{...t,key:l.name}));return n.jsx(n.Fragment,{children:a})}}const is=g.createContext({addonSlotId:null});function cs({children:e}){const t=`panel-addon-slot-${g.useId()}`;return n.jsxs(is.Provider,{value:{addonSlotId:t},children:[n.jsx("div",{style:{position:"static",top:0,left:0},id:t}),e]})}function Od(){const{addonSlotId:e}=g.useContext(is);return e?document.getElementById(e):null}const ds="14.16.1",Nd=Object.freeze(Object.defineProperty({__proto__:null,version:ds},Symbol.toStringTag,{value:"Module"}));class Gd{constructor(t){P(this,"staticColors",new Map);P(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(a=>{this.register(a)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(r,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class Fd{constructor(){P(this,"plugins",new Map);P(this,"vizComponents",new Map);P(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class jd{constructor(){P(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,a){var i;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const l=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),o=b.orderBy(l,"version","asc");if(((i=b.last(o))==null?void 0:i.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((c,d)=>d.handler(c,a),r)}}class R extends jd{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(a,l)=>({version:t,...r(a,l)}))}async migrate({configData:t,panelModel:r}){const a=await t.getItem(null),l=b.get(a,"version",0),o=this.run({from:l,to:this.VERSION},a,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return b.get(r,"version",0)<this.VERSION}}const B=(e,t)=>{const[r,{setFalse:a}]=q.useBoolean(!0),[l,o]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{o(c),a()}),e.watchItem(t,c=>{o(c)})));const i=g.useCallback(async c=>{await e.setItem(t,c),o(c)},[e,t]);return{loading:r,value:l,set:i}},ve={top:16,right:16,bottom:16,left:16},Be=e=>Math.max(0,e-ve.left-ve.right),Le=e=>Math.max(0,e-ve.top-ve.bottom),Mt=(e,t)=>({width:Be(e),height:Le(t)}),_e=({width:e,height:t,children:r})=>n.jsx(s.Box,{pt:ve.top,pr:ve.right,pb:ve.bottom,pl:ve.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:r});g.forwardRef(function({value:t,onChange:r,...a},l){return n.jsx(s.TextInput,{ref:l,value:t,onChange:r,...a})});class Qd{constructor({valueRange:t,colorRange:r}){P(this,"mapper");this.mapper=et.interpolate(t,r)}getColor(t){return this.mapper(t)}}function Wd(e,t){if(e.type==="static")return e.staticColor;if(e.type==="continuous")try{const r=Number(t);if(Number.isNaN(r))throw new Error(`[getColorByColorConf] Invalid type of aggregated value: ${t}, parsed: ${r}`);return new Qd(e).getColor(r)}catch(r){return console.error(r),"black"}return"black"}const Ud=Wd;function A(e){const[t,r]=e.split(".");return{queryID:t,columnKey:r}}function Yd(e){return e.includes(".")?A(e):{queryID:"",columnKey:e}}function Ie(e,t){var l;const{queryID:r,columnKey:a}=A(t);return r?a?((l=e[r])==null?void 0:l.map(o=>o[a]))??[]:e[r]:[]}function jt(e,t){const{queryID:r}=A(t);return r?e[r]:[]}function Kd(e){return Object.values(e)[0]}function Qt(e,t){const{queryID:r,columnKey:a}=A(t);return e[a]}const qe={CryptoJS:qa,d3Array:ss,dayjs:D,lodash:b,numbro:ct,mathjs:vt,faker:hd.faker,popmotion:wd},Xd=[{name:"CryptoJS",url:"https://github.com/brix/crypto-js",version:"4.1.1"},{name:"d3Array",url:"https://github.com/d3/d3-array",version:"3.2.4"},{name:"dayjs",url:"https://day.js.org/",version:"1.11.6"},{name:"lodash",url:"https://lodash.com/docs/4.17.15",version:"4.17.21"},{name:"mathjs",url:"https://mathjs.org/",version:"11.12.0"},{name:"numbro",url:"https://numbrojs.com/",version:"2.3.6"},{name:"faker",url:"https://fakerjs.dev/",version:"7.6.0"},{name:"popmotion",url:"https://popmotion.io/",version:"11.0.3"}],Zd=e=>`
9
+ 我的卡片变量: {{ your_var }}`,tabs:{guide:"使用指南",vars:"看板信息与卡片的变量"}}}},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:"以下条件为真时,才运行本查询",description:"为假的情况: 空数组 / NaN / false / 空字符串 / undefined / null",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:"其他"},series_order:{label:"排序依据",name:"名称",value:"值",raw:"不排序,保持数据本身的顺序",asc:"升序",desc:"降序"},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:"显示标记点",area_style:{label:"区域填充样式",enabled:"启用区域填充",color:"填充颜色",use_series_color:"沿用系列本色",origin:{label:"图形区域的起始位置",auto:{label:"自动",description:"填充坐标轴线到数据间的区域(默认)"},start:{label:"自下而上",description:"填充坐标轴底部到数据间的区域"},end:{label:"自上而下",description:"填充坐标轴顶部到数据间的区域"}},shadow_blur:"图形阴影的模糊大小",shadow_color:"图形阴影的颜色",shadow_offset_x:"阴影水平方向上的偏移距离",shadow_offset_y:"阴影垂直方向上的偏移距离",opacity:"图形透明度"}},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轴数据字段",inverse:"反向坐标轴",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:"颜色",background_color:"背景色",text_color:"文字颜色",click_to_add_a_color:"点击增加一个颜色",color_gradient:"颜色渐变",not_set:"未设置"},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:"请填写一个数字"}},spotlight:{trigger_text:"搜索",main_group:"主要项",placeholder:"打开…",not_found:"无匹配项"}}};class Gt{constructor(t){P(this,"rootRef");this.rootRef=j.observable({current:t})}async deleteItem(t){j.runInAction(()=>{b.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?j.toJS(this.rootRef.current):b.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(b.isObject(r))j.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else j.runInAction(()=>{b.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,a){return j.reaction(()=>this.getValueFromRoot(t),(l,o)=>{r(l,o)},{requiresObservable:!0,fireImmediately:b.get(a,"fireImmediately",!1)})}}class zd{constructor(){P(this,"channels",new Map);P(this,"globalChannel",new Ba)}getChannel(t){const r=this.channels.get(t);if(r)return r;const a=new Ba;return this.channels.set(t,a),a}}class Dd{constructor(t){P(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const r=this.instances.get(t.id);if(r)return r;const a={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new zd,instanceData:new Gt(t.viz.conf)};return this.instances.set(t.id,a),a}}function ls(e,t,r,a){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new Gt({}),colorPalette:{getColor(){return()=>""}},data:t,variables:a}}const Id=e=>{const{panel:t,measure:r,vizManager:a,data:l,variables:o}=e,i=a.resolveComponent(t.viz.type),c=a.getOrCreateInstance(t),d={...ls(c,l,a,o),viewport:{width:r.w,height:r.h}},u=i.viewRender;return n.jsx(u,{context:d,instance:c,...b.omit(e,["panel","vizManager","data"])})},Md=e=>{const{vizManager:t,panel:r,data:a,variables:l}=e,o=t.resolveComponent(r.viz.type),i=t.getOrCreateInstance(r),c={...ls(i,a,t,l)},d=o.configRender;return n.jsx(d,{context:c,instance:i,...b.omit(e,["panel","vizManager","data"])})},os=(e,t)=>{const r=$e.bezier(e),a=$e.bezier(t);return function(l){return l<50?r(l*2/100).hex():a((l-50)*2/100).hex()}},Ft=e=>{const t=$e.bezier(e);return function(r){return t(r/100).hex()}},Ad={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:os(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Pd={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:os(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Vd={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:Ft(["#fff7f1","darkred"]),name:"red",category:"sequential"},$d={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:Ft(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ed={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:Ft(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Bd={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:Ft(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Ld{constructor(t){P(this,"symbol");this.symbol=Symbol(t)}}function We(e){return new Ld(e)}class An{constructor(){P(this,"parent");P(this,"factoryRegistry",new Map);P(this,"instanceRegistry",new Map)}createScoped(){const t=new An;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const r=this.factoryRegistry.get(t.symbol);if(r){const a=r(this);return this.instanceRegistry.set(t.symbol,a),a}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=b.get(t,"dispose");b.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}class qd{constructor(t){this.pluginManager=t}createPanelAddonNode(t){const a=this.pluginManager.installedPlugins.flatMap(l=>l.manifest.panelAddon).filter(l=>!!l).map(l=>g.createElement(l.addonRender,{...t,key:l.name}));return n.jsx(n.Fragment,{children:a})}}const is=g.createContext({addonSlotId:null});function cs({children:e}){const t=`panel-addon-slot-${g.useId()}`;return n.jsxs(is.Provider,{value:{addonSlotId:t},children:[n.jsx("div",{style:{position:"static",top:0,left:0},id:t}),e]})}function Od(){const{addonSlotId:e}=g.useContext(is);return e?document.getElementById(e):null}const ds="14.17.0",Nd=Object.freeze(Object.defineProperty({__proto__:null,version:ds},Symbol.toStringTag,{value:"Module"}));class Gd{constructor(t){P(this,"staticColors",new Map);P(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(a=>{this.register(a)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(r,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class Fd{constructor(){P(this,"plugins",new Map);P(this,"vizComponents",new Map);P(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class jd{constructor(){P(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,a){var i;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const l=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),o=b.orderBy(l,"version","asc");if(((i=b.last(o))==null?void 0:i.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((c,d)=>d.handler(c,a),r)}}class R extends jd{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(a,l)=>({version:t,...r(a,l)}))}async migrate({configData:t,panelModel:r}){const a=await t.getItem(null),l=b.get(a,"version",0),o=this.run({from:l,to:this.VERSION},a,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return b.get(r,"version",0)<this.VERSION}}const B=(e,t)=>{const[r,{setFalse:a}]=q.useBoolean(!0),[l,o]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{o(c),a()}),e.watchItem(t,c=>{o(c)})));const i=g.useCallback(async c=>{await e.setItem(t,c),o(c)},[e,t]);return{loading:r,value:l,set:i}},ve={top:16,right:16,bottom:16,left:16},Be=e=>Math.max(0,e-ve.left-ve.right),Le=e=>Math.max(0,e-ve.top-ve.bottom),Mt=(e,t)=>({width:Be(e),height:Le(t)}),_e=({width:e,height:t,children:r})=>n.jsx(s.Box,{pt:ve.top,pr:ve.right,pb:ve.bottom,pl:ve.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:r});g.forwardRef(function({value:t,onChange:r,...a},l){return n.jsx(s.TextInput,{ref:l,value:t,onChange:r,...a})});class Qd{constructor({valueRange:t,colorRange:r}){P(this,"mapper");this.mapper=et.interpolate(t,r)}getColor(t){return this.mapper(t)}}function Wd(e,t){if(e.type==="static")return e.staticColor;if(e.type==="continuous")try{const r=Number(t);if(Number.isNaN(r))throw new Error(`[getColorByColorConf] Invalid type of aggregated value: ${t}, parsed: ${r}`);return new Qd(e).getColor(r)}catch(r){return console.error(r),"black"}return"black"}const Ud=Wd;function A(e){const[t,r]=e.split(".");return{queryID:t,columnKey:r}}function Yd(e){return e.includes(".")?A(e):{queryID:"",columnKey:e}}function Ie(e,t){var l;const{queryID:r,columnKey:a}=A(t);return r?a?((l=e[r])==null?void 0:l.map(o=>o[a]))??[]:e[r]:[]}function jt(e,t){const{queryID:r}=A(t);return r?e[r]:[]}function Kd(e){return Object.values(e)[0]}function Qt(e,t){const{queryID:r,columnKey:a}=A(t);return e[a]}const qe={CryptoJS:qa,d3Array:ss,dayjs:D,lodash:b,numbro:ct,mathjs:vt,faker:hd.faker,popmotion:wd},Xd=[{name:"CryptoJS",url:"https://github.com/brix/crypto-js",version:"4.1.1"},{name:"d3Array",url:"https://github.com/d3/d3-array",version:"3.2.4"},{name:"dayjs",url:"https://day.js.org/",version:"1.11.6"},{name:"lodash",url:"https://lodash.com/docs/4.17.15",version:"4.17.21"},{name:"mathjs",url:"https://mathjs.org/",version:"11.12.0"},{name:"numbro",url:"https://numbrojs.com/",version:"2.3.6"},{name:"faker",url:"https://fakerjs.dev/",version:"7.6.0"},{name:"popmotion",url:"https://popmotion.io/",version:"11.0.3"}],Zd=e=>`
10
10
  <tr>
11
11
  <td><code>${e.name}</code></td>
12
12
  <td>
@@ -465,7 +465,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
465
465
  `,Lo=()=>{const{t:e}=m.useTranslation(),[t,r]=g.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsx(s.Button,{variant:"subtle",size:"compact-sm",onClick:()=>r(a=>!a),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),n.jsx(s.Collapse,{in:t,children:n.jsx(Ee.CodeHighlight,{language:"typescript",withCopyButton:!1,code:tC})})]})},nC={[$.Checkbox]:"true",[$.DateRange]:"[new Date('2023-01-01 00:00:00'), new Date('2024-01-01 00:00:00')]",[$.MultiSelect]:"[]",[$.Select]:'""',[$.TreeSelect]:"[]",[$.TreeSingleSelect]:'""',[$.TextInput]:'""'},rC=e=>["function getDefaultValue(filter, utils, context) {",` return ${nC[e]};`,"}"].join(`
466
466
  `),bt=S.observer(({filter:e})=>{const{t}=m.useTranslation();return n.jsx(Un,{label:"",title:t("filter.field.custom_default_value.title"),triggerLabel:t("filter.field.custom_default_value.trigger"),value:e.default_value_func,onChange:e.setDefaultValueFunc,defaultValue:rC(e.type),triggerButtonProps:{size:"xs",color:"grape",sx:{flexGrow:0,alignSelf:"flex-start"},leftSection:n.jsx(T.IconMathFunction,{size:16})},description:n.jsx(s.Alert,{title:t("filter.field.custom_default_value.tips"),color:"gray",mb:16,children:n.jsxs(s.List,{size:"xs",type:"ordered",children:[n.jsx(s.List.Item,{children:t("filter.field.custom_default_value.tip_1")}),n.jsx(s.List.Item,{children:t("filter.field.custom_default_value.tip_2")})]})})})}),fn=S.observer(({value:e,onChange:t})=>{const{t:r}=m.useTranslation(),a=W(),l=Q(),o=g.useMemo(()=>l.queries.options,[l.queries.current]),i=o.length===0,c=d=>{a.editor.setPath(["_QUERIES_",d])};return n.jsx(s.Select,{label:n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Text,{fw:500,size:"sm",children:r("filter.widget.common.use_query_data_as_options")}),e&&n.jsx(s.Button,{size:"xs",leftSection:n.jsx(T.IconArrowCurveRight,{size:16}),variant:"subtle",color:"blue",onClick:()=>c(e),children:r("query.open")})]}),data:o,value:e,onChange:Z(t),allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:i,error:i?"You need to add a query in Data Settings":void 0,styles:{label:{display:"block"}}})}),aC=S.observer(function({filter:t}){const{t:r}=m.useTranslation(),a=t.config;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Checkbox,{checked:a.required,onChange:l=>a.setRequired(l.currentTarget.checked),label:r("filter.widget.select.required")}),n.jsx(bt,{filter:t})]}),n.jsx(s.TextInput,{label:r("filter.widget.common.min_width"),value:a.min_width,onChange:l=>a.setMinWidth(l.currentTarget.value),placeholder:"200px"}),n.jsx(s.Divider,{label:r("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),n.jsx(s.Checkbox,{checked:a.treeCheckStrictly,onChange:l=>a.setTreeCheckStrictly(l.currentTarget.checked),label:r("filter.widget.tree_select.strictly")}),n.jsx(s.NumberInput,{value:a.default_selection_count,onChange:a.setDefaultSelectionCount,label:r("filter.widget.common.default_selection_count")}),n.jsx(fn,{value:a.options_query_id,onChange:a.setOptionsQueryID}),n.jsx(Lo,{})]})}),Xr=({errorMessage:e})=>{const{t}=m.useTranslation();return e?n.jsx(s.Text,{c:"red",size:"12px",children:e}):n.jsx(s.Text,{c:"dimmed",size:"12px",children:t("filter.widget.common.selector_option_empty")})},sC=({rotate:e,onClick:t})=>n.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:n.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"})}),qo=({expanded:e,isLeaf:t,value:r,onClick:a,...l})=>t?n.jsx("span",{style:{width:"14px",display:"inline-block"}}):n.jsx(sC,{rotate:e?"0":"-90",onClick:a,...l}),lC=({onClick:e})=>n.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:[n.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),n.jsx("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),n.jsx("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),n.jsx("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),Oo=({onClick:e,...t})=>n.jsx(lC,{onClick:e,...t}),oC=nt.createStyles((e,{radius:t=4,width:r,name:a})=>({root:{borderRadius:s.getRadius(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",position:"absolute",width:`${r} !important`,"&.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:"0px 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-treenode-disabled":{color:"#aaa",".rc-tree-select-tree-title, .rc-tree-select-tree-iconEle":{cursor:"not-allowed"},".rc-tree-select-tree-iconEle":{"svg .border":{fill:"#ced4da"}}},".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",width:"100%",padding:"8px 0",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"}}}})),iC=({disabled:e,radius:t,style:r,label:a,value:l,onChange:o,treeData:i,errorMessage:c,required:d,treeCheckStrictly:u})=>{const{t:p}=m.useTranslation(),{classes:f,cx:v}=oC({radius:t,width:r.width,name:"FilterTreeSelectWidget"}),[x,_]=g.useState(!1),w=z=>{_(z)},k=x&&(l==null?void 0:l.length)>0;return n.jsxs(s.Stack,{gap:3,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsxs(s.Text,{className:f.label,size:"sm",children:[a,d&&n.jsx("span",{className:f.required,"aria-hidden":"true",children:"*"})]}),k&&n.jsx(s.Tooltip,{label:p("filter.widget.common.x_selected",{count:l.length}),children:n.jsx(s.Badge,{variant:"light",children:l.length})})]}),n.jsx(Mn,{disabled:e,allowClear:{clearIcon:n.jsx(s.CloseButton,{size:"sm"})},treeCheckStrictly:u,labelInValue:!0,className:v(f.root,"check-select"),dropdownClassName:v(f.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:r,listHeight:510,treeLine:!0,switcherIcon:qo,treeIcon:Oo,maxTagTextLength:10,value:l,treeData:i,notFoundContent:n.jsx(Xr,{errorMessage:c}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:Mn.SHOW_PARENT,onChange:o,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:()=>p("filter.widget.common.x_selected",{count:l.length})})]})},cC=S.observer(({label:e,config:t,value:r,onChange:a})=>{const{treeData:l,treeDataLoading:o,errorMessage:i}=t,c=v=>{const x=v.map(_=>_.value);a(x,!1)},d=g.useMemo(()=>t.initialSelection(r),[r,t.initialSelection,o]),u=t.min_width?t.min_width:"200px",f=!!t.options_query_id?o:!1;return n.jsx(iC,{disabled:f,style:{minWidth:"160px",width:u,maxWidth:f?u:"unset",borderColor:"#e9ecef"},value:[...d],onChange:c,treeData:l,errorMessage:i,label:e,required:t.required,treeCheckStrictly:t.treeCheckStrictly})}),dC=S.observer(({filter:e})=>{const{t}=m.useTranslation(),r=e.config;return n.jsxs(n.Fragment,{children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsx(s.Checkbox,{checked:r.required,onChange:a=>r.setRequired(a.currentTarget.checked),label:t("filter.widget.select.required")}),n.jsx(bt,{filter:e})]}),n.jsx(s.TextInput,{label:t("filter.widget.common.min_width"),value:r.min_width,onChange:a=>r.setMinWidth(a.currentTarget.value),placeholder:"200px"}),n.jsx(s.Divider,{label:t("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),n.jsx(s.Checkbox,{checked:r.default_selection_count===1,onChange:a=>r.setDefaultSelectionCount(a.currentTarget.checked?1:0),label:t("filter.widget.tree_single_select.select_first_option_by_default")}),n.jsx(fn,{value:r.options_query_id,onChange:r.setOptionsQueryID}),n.jsx(Lo,{})]})}),uC=nt.createStyles((e,{radius:t=4,width:r,name:a})=>({root:{borderRadius:s.getRadius(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-focused":{".rc-tree-select-selection-item":{color:"#aaa"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"calc(2.25rem / 3)",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",position:"relative"},".rc-tree-select-selection-search":{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:1,".rc-tree-select-selection-search-input":{height:"36px",paddingLeft:"calc(2.25rem / 3)",textOverflow:"ellipsis"}},".rc-tree-select-selection-item":{position:"absolute",top:0,bottom:0,left:0,paddingLeft:"calc(2.25rem / 3)",color:"#000",lineHeight:"36px",fontSize:"0.875rem",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",transition:"color 200ms ease"},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",position:"absolute",width:`${r} !important`,"&.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:"0px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden",transition:"background-color 200ms ease","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-selected":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-disabled":{color:"#aaa",".rc-tree-select-tree-title, .rc-tree-select-tree-iconEle":{cursor:"not-allowed"},".rc-tree-select-tree-iconEle":{"svg .border":{fill:"#ced4da"}}},".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",width:"100%",padding:"8px 0","&: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"}}}})),pC=({disabled:e,radius:t,style:r,label:a,value:l,onChange:o,treeData:i,errorMessage:c,required:d})=>{m.useTranslation();const{classes:u,cx:p}=uC({radius:t,width:r.width,name:"FilterTreeSelectWidget"});return n.jsxs(s.Stack,{gap:3,children:[n.jsx(s.Group,{justify:"space-between",children:n.jsxs(s.Text,{className:u.label,size:"sm",children:[a,d&&n.jsx("span",{className:u.required,"aria-hidden":"true",children:"*"})]})}),n.jsx(Mn,{disabled:e,allowClear:{clearIcon:n.jsx(s.CloseButton,{size:"sm"})},multiple:!1,labelInValue:!0,className:p(u.root,"check-select"),dropdownClassName:p(u.dropdown,""),transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:r,listHeight:510,treeLine:!0,switcherIcon:qo,treeIcon:Oo,value:l,treeData:i,notFoundContent:n.jsx(Xr,{errorMessage:c}),treeNodeFilterProp:"filterBasis",treeCheckable:!1,onChange:o,onSelect:console.log,showSearch:!0})]})},hC=S.observer(({label:e,config:t,value:r,onChange:a})=>{const{treeData:l,treeDataLoading:o,errorMessage:i}=t,c=v=>{a(v?v.value:null,!1)},d=g.useMemo(()=>t.initialSelection(r),[r,t.initialSelection,t.treeDataLoading]),u=t.min_width?t.min_width:"200px",f=!!t.options_query_id?o:!1;return n.jsx(pC,{disabled:f,style:{width:u,maxWidth:f?u:"unset",borderColor:"#e9ecef"},value:d,onChange:c,treeData:l,errorMessage:i,label:e,required:t.required})});function gC(e){return xd.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function fC(e){return e.map(t=>{const{label:r,description:a,...l}=t,o={...l,filterBasis:`${r}___${a??""}`,description:a,label:r};return a&&(o.label=g.createElement("div",{},[g.createElement(s.Text,{key:0,title:t.label},t.label),g.createElement(s.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description},t.description)])),o})}const No=h.types.compose("FilterConfigModel_BaseTreeSelect",h.types.model({min_width:h.types.optional(h.types.string,"")}),Qr).views(e=>({get plainData(){const{data:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeData(){const t=this.plainData,r=fC(t);return gC(r)},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"}})).actions(e=>({setMinWidth(t){e.min_width=t}})),Zr=h.types.compose("FilterTreeSelectConfigMeta",h.types.model({_name:h.types.literal("tree-select"),default_value:h.types.optional(h.types.array(h.types.string),[]),treeCheckStrictly:h.types.optional(h.types.boolean,!1)}),No).views(e=>({get json(){const{_name:t,default_value:r,required:a,min_width:l,static_options:o,options_query_id:i,default_selection_count:c,treeCheckStrictly:d}=e;return{_name:t,required:!!a,min_width:l,default_value:r,static_options:o,options_query_id:i,treeCheckStrictly:d,default_selection_count:c}},get defaultSelection(){const t=e.filter.formattedDefaultValue;if(Array.isArray(t)&&t.length>0)return t;const{default_selection_count:r}=e;return r?e.treeData.slice(0,r).map(l=>l.value):[]},valueObjects(t){const r=new Set(t);return e.plainData.filter(a=>r.has(a.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=h.cast(t)},setTreeCheckStrictly(t){e.treeCheckStrictly=t},applyDefaultSelection(){if(e.optionsLoading)return;const t=e.filter.value,r=new Set(e.plainData.map(l=>l.value)),a=(t??[]).filter(l=>r.has(l));a.length>0?e.filter.setValue(a):e.filter.setValue(e.defaultSelection)},afterCreate(){h.addDisposer(e,j.reaction(()=>JSON.stringify(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!1,delay:0}))}})),Go=()=>Zr.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),Jr=h.types.compose("FilterTreeSingleSelectConfigMeta",h.types.model({_name:h.types.literal("tree-single-select"),default_value:h.types.optional(h.types.string,"")}),No).views(e=>({get json(){const{_name:t,default_value:r,required:a,min_width:l,static_options:o,options_query_id:i,default_selection_count:c}=e;return{_name:t,required:!!a,min_width:l,default_value:r,static_options:o,options_query_id:i,default_selection_count:c}},get selectFirstByDefault(){return e.default_selection_count===1},get defaultSelection(){if(e.treeDataLoading)return"";const t=e.filter.formattedDefaultValue;return t||(this.selectFirstByDefault&&e.treeData.length>0?e.treeData[0].value:"")},valueObject(t){if(t)return e.plainData.find(r=>r.value===t)},initialSelection(t){if(t)return this.valueObject(t)},truthy(t){return typeof t=="string"&&t!==""}})).actions(e=>({setDefaultValue(t){e.default_value=t},applyDefaultSelection(){if(e.treeDataLoading)return;const t=e.filter.value;e.optionValuesSet.has(t)?e.filter.setValue(t):e.filter.setValue(e.defaultSelection)},afterCreate(){h.addDisposer(e,j.reaction(()=>j.toJS(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!1,delay:0}))}})),Fo=()=>Jr.create({_name:"tree-single-select",default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),Hr=h.types.model("FilterMeta",{id:h.types.identifier,key:h.types.string,label:h.types.string,order:h.types.number,visibleInViewsIDs:h.types.array(h.types.string),auto_submit:h.types.optional(h.types.boolean,!1),default_value_func:h.types.optional(h.types.string,""),type:h.types.enumeration("DashboardFilterType",[$.Select,$.MultiSelect,$.TreeSelect,$.TreeSingleSelect,$.TextInput,$.Checkbox,$.DateRange]),config:h.types.union(Ur,Wr,Zr,Jr,Yr,Gr,jr)}).views(e=>({get contentModel(){return h.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!==$.TreeSelect&&e.type!==$.TreeSingleSelect},get usingDefaultValueFunc(){return!!e.default_value_func},get formattedDefaultValue(){return this.filters.formattedDefaultValues[e.key]},get auto_submit_supported(){return[$.Select,$.Checkbox,$.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:r,label:a,order:l,visibleInViewsIDs:o,default_value_func:i,auto_submit:c,type:d,config:u}=e;return{id:t,key:r,type:d,label:a,order:l,config:u.json,auto_submit:c,visibleInViewsIDs:j.toJS(o),default_value_func:i}},get visibleInViewsIDSet(){return new Set(e.visibleInViewsIDs)},get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return b.get(e.config,"required",!1)?b.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){const r=Number(t);Number.isFinite(r)&&(e.order=r)},setType(t){switch(t){case $.Select:e.config=Bo();break;case $.MultiSelect:e.config=Eo();break;case $.TreeSelect:e.config=Go();break;case $.TreeSingleSelect:e.config=Fo();break;case $.TextInput:e.config=Kr();break;case $.Checkbox:e.config=Do();break;case $.DateRange:e.config=Vo();break;default:return}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 E=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(E||{});const Rr=h.types.model("ViewDivisionConfig",{_name:h.types.literal(E.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})),jo=()=>Rr.create({_name:E.Division}),bC=h.types.model("CustomModalTitleModel",{enabled:h.types.optional(h.types.boolean,!1),func_content:h.types.optional(h.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:r}=e;return{enabled:t,func_content:r}},get value(){const{enabled:t,func_content:r}=e,a=h.getParent(e,2),l=h.getRoot(e);if(!t)return a.name;try{const o={filters:l.content.filters.valuesForPayload,context:l.context.current};return new Function(`return ${r}`)()(o)}catch(o){return console.error(o),a.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:r}){e.enabled=t,e.func_content=r}})),bn={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
467
467
  `)},ea=h.types.model("ViewModalConfig",{_name:h.types.literal(E.Modal),width:h.types.string,height:h.types.string,custom_modal_title:h.types.optional(bC,bn)}).views(e=>({get json(){const{_name:t,width:r,height:a,custom_modal_title:l}=e;return{_name:t,width:r,height:a,custom_modal_title:l.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),Qo=()=>ea.create({_name:E.Modal,width:"90vw",height:"90vh"}),yC=h.types.model("ViewTabsTabModel",{id:h.types.identifier,name:h.types.string,view_id:h.types.string,color:h.types.optional(h.types.string,""),order:h.types.optional(h.types.number,0)}).views(e=>({get json(){const{id:t,name:r,view_id:a,color:l,order:o}=e;return{id:t,name:r,color:l,order:o,view_id:a}}})).actions(e=>({setName(t){e.name=t},setViewID(t){t&&(e.view_id=t)},setColor(t){e.color=t},setOrder(t){typeof t!="string"&&(e.order=t)}})),ta=h.types.model("ViewTabsConfig",{_name:h.types.literal(E.Modal),tabs:h.types.optional(h.types.array(yC),[]),variant:h.types.optional(h.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:h.types.optional(h.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:h.types.optional(h.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:r,orientation:a,tabs:l,grow:o}=e;return{grow:o,tabs:l.map(i=>i.json),_name:t,variant:r,orientation:a}},get tabsInOrder(){return b.sortBy(e.tabs,"order")}})).actions(e=>({setVariant(t){t&&(e.variant=t)},setOrientation(t){t&&(e.orientation=t)},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=h.cast(t)},addTab(){const t=te.randomId(),r={id:t,name:t,view_id:""};e.tabs.push(r)},removeTab(t){e.tabs.splice(t,1)}})),Wo=()=>ta.create({_name:E.Modal,tabs:[]}),Uo=h.types.model({id:h.types.identifier,name:h.types.string,type:h.types.enumeration("EViewComponentType",[E.Division,E.Modal,E.Tabs]),config:h.types.union(Rr,ea,ta),panelIDs:h.types.optional(h.types.array(h.types.string),[])}).views(e=>({get json(){const{id:t,name:r,type:a,config:l}=e;return{id:t,name:r,type:a,config:l.json,panelIDs:e.panelIDs.map(o=>o)}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case E.Division:e.config=jo();break;case E.Modal:e.config=Qo();break;case E.Tabs:e.config=Wo();break;default:return}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},appendPanelIDs(t){e.panelIDs.push(...t)},removePanelID(t){const r=e.panelIDs.filter(a=>a!==t);e.panelIDs.length=0,e.panelIDs.push(...r)}})),He="13.45.0",vC={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:E.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:He,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},na=h.types.model("DataSourceMetaModel",{id:h.types.string,type:h.types.enumeration("DataSourceType",[F.HTTP,F.MySQL,F.Postgresql,F.MericoMetricSystem]),key:h.types.string,config:h.types.frozen()}),Yo=h.types.model("DataSourcesMetaModel",{list:h.types.optional(h.types.array(na),[])}).views(e=>({find({type:t,key:r}){return e.list.find(a=>a.key===r&&a.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)}})),Ko=h.types.model({id:h.types.string,content:h.types.string,create_time:h.types.string,update_time:h.types.string,is_preset:h.types.boolean}),ra=h.types.model("GlobalSQLSnippetsMeta",{list:h.types.optional(h.types.array(Ko),[])}).views(e=>({find(t){return e.list.find(r=>r.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)}})),yn=h.types.model("ContextMeta",{current:h.types.optional(h.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,r){e.current[t]=r}}));function aa(e){return yn.create({current:e})}const sa=h.types.compose("ViewRenderModel",Uo,h.types.model({tab:h.types.optional(h.types.string,"")})).views(e=>({get tabs(){return e.config.tabs},get tabInfo(){const t=this.tabs.find(r=>r.id===e.tab);return t?{id:t.id,name:t.name}:null},get tabView(){return e.type!==E.Tabs?null:this.tabs.find(t=>t.id===e.tab)},get tabViewID(){return this.tabView?this.tabView.view_id??"":""},get contentModel(){return h.getParent(e,3)},get panels(){if(e.type!==E.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs);const t=this.tabViewID,r=this.contentModel.views.findByID(t);return(r==null?void 0:r.panels)??[]},get renderViewIDs(){const t=[e.id];return e.type===E.Tabs&&t.push(this.tabViewID),t},async downloadScreenshot(t){const r=t.offsetWidth*2+10,a=t.offsetHeight*2+10,l=new rs,o=new Date().getTime(),i=await ns.toBlob(t,{bgcolor:"white",width:r,height:a,style:{transformOrigin:"0 0",transform:"scale(2)"}});l.file(`${e.name}_${o}.png`,i),l.file(`dashboard_state_${o}.json`,JSON.stringify(this.contentModel.dashboardState,null,4)),l.generateAsync({type:"blob"}).then(c=>{Ot.saveAs(c,`${e.name}_${o}.zip`)}).catch(c=>{console.error(c),Qe.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??""}})),la=h.types.model("ViewsRenderModel",{current:h.types.optional(h.types.array(sa),[]),visibleViewIDs:h.types.array(h.types.string)}).views(e=>({get json(){return e.current.map(t=>Xe(t.json))},get idMap(){const t=new Map;return e.current.forEach(r=>{t.set(r.id,r)}),t},findByID(t){return e.current.find(r=>r.id===t)},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:r})=>r===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:r})=>t.has(r))},get firstVisibleTabsView(){return this.visibleViews.find(t=>t.type===E.Tabs)},get firstVisibleTabsViewActiveTab(){const t=this.firstVisibleTabsView;return t?t.tabInfo:null},get firstVisibleTabsViewActiveTabStr(){return JSON.stringify(this.firstVisibleTabsViewActiveTab)}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(a=>a)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const r=e.visibleViewIDs.findIndex(a=>a===t);r!==-1&&e.visibleViewIDs.splice(r,1)},setFirstVisibleTabsViewActiveTab(t){if(!t)return;const r=e.firstVisibleTabsView;r==null||r.setTabByTabInfo(t)}}));function Xo(e,t){const r=e.length>0?[e[0].id]:[],a=e.map(l=>{const{_name:o=l.type}=l.config,i={...l,tab:"",config:{...l.config,_name:o},panelIDs:l.panelIDs};if(l.type===E.Tabs){let c=b.minBy(l.config.tabs,d=>d.order);!c&&l.config.tabs.length>0&&(c=l.config.tabs[0]),i.tab=(c==null?void 0:c.id)??""}return i});return t&&(a[0].tab=t.id),{current:a,visibleViewIDs:r}}const _C=new _d.AsyncParser({withBOM:!0});async function Zo(e){return!Array.isArray(e)||e.length===0?"":await _C.parse(e).promise()}async function Jo(e,t){const r=await Zo(t),a=new Blob([r],{type:"text/csv"});Ot.saveAs(a,`${e}.csv`)}function Ho(e,t){const r=new rs,a=t.map(async({id:l,data:o})=>{const i=await Zo(o);r.file(`${l}.csv`,i)});Promise.all(a).then(()=>{r.generateAsync({type:"blob"}).then(l=>{Ot.saveAs(l,`${e}.zip`)})}).catch(l=>{console.error(l),Qe.notifications.show({color:"red",title:"Failed to download data",message:l.message})})}function Dt(e,t){const r=new Blob([t],{type:"application/json"});Ot.saveAs(r,`${e}.json`)}const oa=vo.views(e=>({get contentModel(){return h.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(r=>r.id===t)},get data(){return this.queries.reduce((t,r)=>(t[r.id]=r.data,t),{})},get variableStrings(){return Xs(e.variables,this.data)},get variableAggValueMap(){const t={},r=this.data;return e.variables.reduce((a,l)=>(a[l.name]=Ye(l,r),a),t),t},get variableValueMap(){const t={},r=this.variableAggValueMap;return e.variables.reduce((a,l)=>(a[l.name]=Me(l,r[l.name]),a),t),t},get variableStyleMap(){const t=this.variableValueMap,r={};return e.variables.reduce((a,l)=>{const o=Ud(l.color,t[l.name]);return a[l.name]={color:o,"font-size":l.size,"font-weight":l.weight,variable:l},a},r),r},get dataLoading(){return this.queries.some(t=>t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(o=>!o.runByConditionsMet);if(t.length===0)return"";const r=new Set,a=new Set;t.forEach(o=>{const i=o.conditionNames;i.context.forEach(c=>r.add(c)),i.filters.forEach(c=>a.add(c))});const l=[];return r.size>0&&l.push(`context: ${Array.from(r).join(", ")}`),a.size>0&&l.push(`filter${a.size>1?"s":""}: ${Array.from(a).join(", ")}`),l.length===2&&l.splice(1,0,"and"),l.unshift("Waiting for"),l.join(" ")},get queryErrors(){return this.queries.map(t=>t.error??t.metricQueryPayloadErrorString).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.name,e.queryIDs)},getSchema(){const t=e.json;return t.viz.conf={...t.viz.conf,__INTERACTIONS:{},__OPERATIONS:{},__TRIGGERS:{}},{panel:t,queries:e.queries.map(r=>r.json),layouts:e.contentModel.layouts.jsonByPanelIDSet(new Set([e.id]))}},downloadSchema(){const{panel:t,queries:r,layouts:a}=this.getSchema(),o=JSON.stringify({panels:[t],definition:{queries:r},layouts:a,version:He},null,2),i=e.name;Dt(i,o)}}));function Ro(e){return{id:e,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:Tr.name,conf:Tr.createConfig()},style:{border:{enabled:!0}}}}const ia=h.types.model("PanelsRenderModel",{list:h.types.optional(h.types.array(oa),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(r=>r.id===t)},get idMap(){const t=new Map;return e.list.forEach(r=>{t.set(r.id,r)}),t}})).views(e=>({panelsByIDs(t){const r=[];return t.forEach(a=>{const l=e.idMap.get(a);l?r.push(l):console.warn(`Panel is not found, id:${a}`)}),r}}));function ei(e){const t=e.config,r=t==null?void 0:t.default_value;return r===void 0?r:t._name==="date-range"?Ao(t):r}function xC(e,t){const r=e.default_value_func;try{const a=new Function(`return ${r}`)()(e,qe,t);return e.config._name==="date-range"&&Array.isArray(a)?{value:a,shortcut:null}:a}catch(a){return console.error(a),ei(e)}}function ti(e,t){var r;return(r=e.default_value_func)!=null&&r.trim()?xC(e,t):ei(e)}function ni(e,t){return e.reduce((r,a)=>(r[a.key]=ti(a,t),r),{})}function ri(e,t){const r={};return Object.entries(t).forEach(([a,l])=>{const o=e[a];return typeof l=="object"&&"shortcut"in l&&Array.isArray(o)?r[a]={value:o,shortcut:null}:r[a]=o??l,r}),r}const ca=h.types.model("FiltersRenderModel",{current:h.types.optional(h.types.array(Hr),[]),values:h.types.optional(h.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get valuesString(){return JSON.stringify(e.values)},get filter(){return h.getParent(e)},get valuesForPayload(){const t={};return Object.entries(e.values).forEach(([r,a])=>{t[r]=a;const l=this.findByKey(r);l&&l.config._name==="date-range"&&(t[r]=l.config.dateStringsValue)}),t},get contentModel(){return h.getRoot(e).content},get context(){return this.contentModel.payloadForSQL.context},get initialValuesDep(){return JSON.stringify({filters:e.current.map(({default_value_func:t,config:r})=>({default_value_func:t,config:r})),context:this.contentModel.payloadForSQL.context})},get formattedDefaultValues(){return ni(this.json,this.contentModel.context)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(r=>r.id===t)},findByKey(t){return e.current.find(r=>r.key===t)},findByIDSet(t){return e.current.filter(r=>t.has(r.id))},get inOrder(){return b.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return b.sortBy(e.current.filter(r=>r.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,r)=>(t[r.key]=r.label,t),{})},getSelectOption(t){const r=this.findByID(t);if(!r||!("getSelectOption"in r.config))return null;const a=e.values[r.key];return r.config.getSelectOption(a)}})).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=ri(t,e.values)},setValueByKey(t,r){console.debug(`⚪️ setting filter[${t}] to value: `,JSON.stringify(r)),e.values={...e.values,[t]:r}},applyValuesPatch(t){e.values={...e.values,...t}},getValueByKey(t){return e.values[t]},getSchema(t,r){return{filters:e.findByIDSet(new Set(t)).map(o=>({...o.json,visibleInViewsIDs:r?o.json.visibleInViewsIDs:[]})),version:He}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t,!1),null,2);Dt("Filters",r)}}));function da(e,t,r,a){const l={...r,...t},o=ni(e,l),i=ri(a,o);return{current:e,values:i}}const ai=To.views(e=>({get rootModel(){return h.getRoot(e)},get contentModel(){return this.rootModel.content},get conditionOptions(){if(!h.isAlive(e))return{optionGroups:[],validValues:new Set};const t=new Set,{context:r}=this.contentModel.payloadForSQL,a={group:"context.label",items:Object.keys(r).map(i=>{const c=`context.${i}`;return t.add(c),{label:i,value:c,description:void 0,type:"context"}})},l={group:"filter.labels",items:this.contentModel.filters.keyLabelOptions.map(i=>{const c=`filters.${i.value}`;return t.add(c),{label:i.label,value:c,description:i.value,type:"filter",widget:i.widget}})};return{optionGroups:[a,l],validValues:t}},getConditionOptionsWithInvalidValue(t){const{optionGroups:r,validValues:a}=this.conditionOptions;if(!t||a.has(t))return this.conditionOptions;const l={group:"common.invalid",items:[{label:t,value:t}]};return{optionGroups:[...r,l],validValues:a}},get conditionOptionsWithInvalidRunbys(){const{optionGroups:t,validValues:r}=this.conditionOptions,a={group:"common.invalid",items:[]};return e.run_by.forEach(l=>{r.has(l)||a.items.push({label:l,value:l})}),{optionGroups:[...t,a],validValues:r}},get unmetRunByConditions(){if(!h.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const r=this.contentModel.payloadForSQL;return t.filter(a=>{const l=b.get(r,a);return Array.isArray(l)?l.length===0:typeof l=="number"?Number.isNaN(l):!l})}})).views(e=>({get payload(){return e.contentModel.payloadForSQL},get formattedSQL(){const t=b.get(e,"config.sql","");return Jn(t,this.payload)},get httpConfigString(){const{context:t,filters:r}=this.payload,{name:a,pre_process:l}=e.json,o=Ru(l,t,r);return console.groupCollapsed(`Request config for: ${a}`),console.log(o),console.groupEnd(),JSON.stringify(o)},get typedAsSQL(){return[F.Postgresql,F.MySQL].includes(e.type)},get typedAsHTTP(){return[F.HTTP].includes(e.type)},get isMericoMetricQuery(){return e.type===F.MericoMetricSystem},get isTransform(){return e.type===F.Transform},get reQueryKey(){const t=b.get(e,"config.react_to",[]);if(t.length===0)return"";const r=e.contentModel.payloadForSQL,a=[...t].reduce((l,o)=>(l[o]=b.get(r,o),l),{});return JSON.stringify(a)},get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=e.contentModel.filters,r=e.unmetRunByConditions.filter(l=>l.startsWith("context.")).map(l=>l.replace("context.","")),a=e.unmetRunByConditions.filter(l=>l.startsWith("filters.")).map(l=>b.get({filters:t},l,l.replace("filters.",""))).filter(l=>!!l);return{context:r,filters:a}},get queries(){return h.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)},get dependencies(){if(!this.typedAsSQL)return[];const t=b.get(e,"config.sql","");if(!t)return[];const r=b.uniq(t.match(Xt.sqlSnippet)),a=b.uniq(t.match(Xt.filter)),l=b.uniq(t.match(Xt.context)),o=[];return r.forEach(i=>{o.push({type:"sql_snippet",key:i,valid:e.contentModel.sqlSnippets.keySet.has(i)})}),a.forEach(i=>{o.push({type:"filter",key:i,valid:e.contentModel.filters.keySet.has(i)})}),l.forEach(i=>{o.push({type:"context",key:i,valid:e.contentModel.mock_context.keySet.has(i)})}),o},get metricQueryPayload(){if(e.type!==F.MericoMetricSystem)return null;const t=this.payload,r=e.config,a=r.filters.reduce((p,f)=>(p[f.dimension]={eq:b.get(t,f.variable)},p),{}),l={id:r.id,type:r.type,filters:a,groupBys:r.groupBys};if(!r.timeQuery.enabled)return l;const{range_variable:o,unit_variable:i}=r.timeQuery,c="YYYY-MM-DD",d="PRC",u={start:"",end:"",unitOfTime:b.get(t,i,""),unitNumber:1,timezone:"PRC",stepKeyFormat:c};if(o){const p=b.get(t,o);Array.isArray(p)&&p.length===2&&(u.start=D(p[0]).tz(d).format(c),u.end=D(p[1]).tz(d).format(c))}return l.timeQuery=u,l},get metricQueryPayloadString(){return this.metricQueryPayload?JSON.stringify(this.metricQueryPayload,null,2):""},get metricQueryPayloadError(){const t=[];if(!this.metricQueryPayload)return t;const r=e.config,{timeQuery:a}=this.metricQueryPayload;if(!a)return r.groupByValues.length>2&&t.push("分组聚合维度:最多支持两个维度的聚合计算"),t;r.groupByValues.length>1&&t.push("分组聚合维度:按时间序列展示时,仅可选择一个聚合维度");const{start:l,end:o,unitOfTime:i}=a;return(!l||!o)&&t.push("时间维度:时间范围不完整"),i||t.push("步长:必选"),t},get metricQueryPayloadErrorString(){return this.metricQueryPayloadError.join(`
468
- `)},get metricQueryPayloadValid(){return this.metricQueryPayload?this.metricQueryPayloadError.length===0:!1}})),ua=h.types.compose("QueryRenderModel",ai,h.types.model({state:h.types.optional(h.types.enumeration(["idle","loading","error"]),"idle"),data:h.types.optional(h.types.frozen([]),[]),error:h.types.frozen()})).views(e=>({get datasource(){const{key:t,type:r}=e;return e.rootModel.datasources.find({type:r,key:t})},get additionalQueryInfo(){return e.contentModel.getAdditionalQueryInfo(e.id)},get depQueryModels(){const t=b.get(e,"config.dep_query_ids",[]);return e.contentModel.queries.findByIDSet(new Set(t))},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:r}=e.conditionNames;if(t.length===0&&r.length===0)return"Waiting";const a=[];return t.length>0&&a.push(`context: ${t.join(", ")}`),r.length>0&&a.push(`filter${r.length>1?"s":""}: ${r.join(", ")}`),a.length===2&&a.splice(1,0,"and"),a.unshift("Waiting for"),a.join(" ")}return e.data.length>0?"":"data.empty_data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:h.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const r=e.payload,a=e.config;e.data=yield*h.toGenerator(Y1({payload:r,name:e.name,query:{type:e.type,key:e.key,sql:a.sql,pre_process:e.pre_process,post_process:e.post_process},additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(r){if(Ce.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const a=b.get(r,"message","unkown error");e.error=b.get(r,"response.data.detail.message",a),e.state="error"}}}}),runHTTP:h.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:r,key:a,post_process:l}=e.json;let o=JSON.parse(e.httpConfigString);o=Yt(e.datasource,o);const i=yield*h.toGenerator(K1({type:r,key:a,configString:JSON.stringify(o),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=Kt(e.datasource,i),d=Js(l,c,e.contentModel.dashboardState);e.data=d,e.state="idle",e.error=null}catch(r){if(console.error(r),Ce.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const a=b.get(r,"message","unkown error");e.error=b.get(r,"response.data.detail.message",a),e.state="error"}}}}),runMericoMetricQuery:h.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet&&e.metricQueryPayloadValid)){e.controller=new AbortController,e.state="loading";try{const{type:r,key:a,post_process:l}=e.json;let o={url:"/buffet/api/metric_management/query",method:"POST",data:e.metricQueryPayload};o=Yt(e.datasource,o);const i=yield*h.toGenerator(X1({key:a,configString:JSON.stringify(o),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=Kt(e.datasource,i),d=Js(l,c,e.contentModel.dashboardState);e.data=d.data,e.state="idle",e.error=null}catch(r){if(console.error(r),Ce.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const a=b.get(r,"message","unkown error");e.error=b.get(r,"response.data.detail.message",a),e.state="error"}}}}),runTransformation(){e.state="loading";try{const t=e.depQueryModels.map(o=>({id:o.id,name:o.name,data:b.cloneDeep(o.data)})),r=e.contentModel.dashboardState,a=e.pre_process,l=new Function(`return ${a}`)()(t,r,qe);e.data=l,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.isMericoMetricQuery?e.runMericoMetricQuery():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){h.addDisposer(e,j.reaction(()=>{var r,a;if(e.isTransform){const l=e.config;return[e.inUse,e.id,e.key,l.dep_query_ids.toString(),e.pre_process,e.depQueryModelStatesString].join("--")}return e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(r=e.datasource)==null?void 0:r.id}`:e.isMericoMetricQuery?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(a=e.datasource)==null?void 0:a.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},()=>e.fetchData(!1),{fireImmediately:!0,delay:0}))}})),pa=h.types.model("QueriesRenderModel",{current:h.types.optional(h.types.array(ua),[])}).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(r=>r.id===t)},findByIDSet(t){return e.current.filter(r=>t.has(r.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get root(){return h.getRoot(e)},get dashboardName(){return this.root.name},get contentModel(){return h.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:r,queries:a}=this.contentModel,l=[];t.visibleViews.forEach(c=>{c.panels.forEach(d=>{l.push(...d.queryIDs)})});const o=b.uniq(t.visibleViews.map(c=>c.renderViewIDs).flat());r.current.forEach(c=>{const d=b.get(c,"config.options_query_id");if(!d)return;o.some(p=>c.visibleInViewsIDSet.has(p))&&l.push(d)}),a.findByIDSet(new Set(l)).forEach(c=>{const d=c.config;!c.isTransform||d.dep_query_ids.length===0||l.push(...d.dep_query_ids)});const i=new Set(l);return console.debug("QueryIDs:",i),i},isQueryInUse(t){return this.visibleQueryIDSet.has(t)}})).actions(e=>({downloadAllData(){const t=e.current.map(({name:r,data:a})=>({id:r,data:a}));Ho(e.dashboardName,t)},downloadDataByQueryIDs(t,r){if(r.length===1)return this.downloadDataByQueryID(t,r[0]);const a=new Set(r),l=e.current.filter(o=>a.has(o.id)).map(({name:o,data:i})=>({id:o,data:i}));Ho(t,l)},downloadDataByQueryID(t,r){const a=e.findByID(r);if(!a){console.log("[downloadDataByQueryID] query not found");return}const{data:l}=a,o=t??a.name;Jo(o,l)},refetchDataByQueryID(t){const r=e.findByID(t);if(!r){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return r.fetchData(!0)},getSchema(t){return{definition:{queries:e.findByIDSet(new Set(t)).map(l=>l.json)},version:He}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t),null,2);Dt("Queries",r)}}));function si(e){return{current:e}}function li({min:e,max:t}){const r=`${e}px`,a=Number.isFinite(t)?`${t}px`:"∞";return`[${r}, ${a})`}const ha=h.types.model("LayoutsRenderModel",{list:h.types.array(ko),currentBreakpoint:h.types.string}).views(e=>({get json(){return e.list.map(t=>t.json)},jsonByPanelIDSet(t){return e.list.map(r=>r.jsonByPanelIDSet(t))},get root(){return h.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 li(t)},get cols(){const t={};return e.list.forEach(r=>{t[r.id]=36}),t},get breakpoints(){const t={};return e.list.forEach(r=>{t[r.id]=r.breakpoint}),t},get breakpointNameRecord(){const t={};return e.list.forEach(r=>{t[r.name]=r.breakpoint}),t},get breakpointRanges(){const t=e.list.map(r=>({id:r.id,name:r.name,min:r.breakpoint,max:1/0,text:""}));return t.sort((r,a)=>r.min-a.min).forEach((r,a)=>{a!==t.length-1&&(r.max=t[a+1].min)}),t.forEach(r=>{r.text=li(r)}),t},get breakpointsInfo(){return e.list.map(t=>({id:t.id,name:t.name,breakpoint:t.breakpoint})).sort((t,r)=>t.breakpoint-r.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 r=new Set(t);return this.currentLayoutSet.list.filter(l=>r.has(l.panelID))},gridLayouts(t){const r=new Set(t),a={};return e.list.forEach(l=>{a[l.id]=l.list.filter(o=>r.has(o.panelID)).map(o=>o.layoutProperies)}),a},findItemByPanelID(t){return this.currentLayoutSet.findByPanelID(t)}})).actions(e=>({setCurrentBreakpoint(t){console.log("🔴 onBreakpointChange:",t),e.currentBreakpoint=t},afterCreate(){h.addDisposer(e,j.reaction(()=>e.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),oi=zo.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!h.getParent(e,2).findByKey(t)}})),ga=h.types.model("SQLSnippetsRenderModel",{current:h.types.optional(h.types.array(oi),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,r)=>(t[r.key]=r.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(r=>r.key===t)},findByKeySet(t){return e.current.filter(r=>t.has(r.key))}})).actions(e=>({getSchema(t){return{definition:{sqlSnippets:e.findByKeySet(new Set(t)).map(l=>l.json)},version:He}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t),null,2);Dt("SQL Snippets",r)}}));function ii(e){return{current:e}}function Bt(e,t,r,a){return e.reduce((l,o)=>{try{l[o[t]]=Zn(o[r],a)}catch(i){l[o[t]]=i.message}return l},{})}class ci{constructor(t){P(this,"origin");P(this,"copy");this.origin=t,this.copy=h.clone(t),j.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!b.isEqual(h.getSnapshot(this.origin),h.getSnapshot(this.copy))}commit(){h.applySnapshot(this.origin,h.getSnapshot(this.copy))}reset(){h.applySnapshot(this.copy,h.getSnapshot(this.origin))}update(t){h.applySnapshot(this.copy,t)}}const di=e=>new ci(e),mC=({description:e,isDescriptionEmpty:t})=>t?null:n.jsx(s.Tooltip,{color:"white",label:n.jsx(mt,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:n.jsx(s.Box,{sx:{height:"16px",alignSelf:"center"},children:n.jsx(T.IconInfoCircle,{size:16,color:"gray"})})}),wC=S.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:a,...l},value:o,onChange:i})=>n.jsxs(s.Box,{children:[n.jsx(s.Text,{size:"sm",children:" "}),n.jsx(s.Checkbox,{label:n.jsxs(s.Group,{wrap:"nowrap",justify:"space-between",align:"middle",gap:6,children:[n.jsx(s.Box,{sx:{flexGrow:1},children:e}),n.jsx(mC,{description:r,isDescriptionEmpty:a})]}),checked:o||!1,onChange:c=>i(c.currentTarget.checked),...l,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),CC=({value:e,onChange:t,close:r,max_days:a,allowSingleDateInRange:l})=>{const o=e.value,[i,c]=o,d=g.useMemo(()=>i||new Date,[i]),u=g.useMemo(()=>{if(i&&!c)return i},[i,c]),p=g.useMemo(()=>{if(i&&!c&&a>0)return D(i).add(a-1,"days").toDate()},[i,c,a]),f=v=>{const[x,_]=v;t({value:v,shortcut:null}),x&&_&&r()};return n.jsx(Ra.DatePicker,{defaultDate:d,numberOfColumns:2,type:"range",value:o,onChange:f,onNextMonth:console.log,minDate:u,maxDate:p,allowSingleDateInRange:l})},TC=({begin:e,end:t})=>{const{t:r}=m.useTranslation(),a=g.useMemo(()=>!t&&!e?Number.NaN:D(t).diff(D(e),"days")+1,[e,t]);if(Number.isNaN(a))return n.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const l=a===1?r("filter.widget.date_range.one_day"):r("filter.widget.date_range.x_days",{count:a});return n.jsx(s.Tooltip,{label:l,children:n.jsx(s.Badge,{size:"sm",variant:"light",children:a})})},SC=({max_days:e})=>{const{t}=m.useTranslation();return e?n.jsxs(n.Fragment,{children:[n.jsx(s.Group,{justify:"flex-end",children:n.jsx(s.Badge,{size:"xs",variant:"light",children:t("filter.widget.date_range.x_max_days",{max_days:e})})}),n.jsx(s.Divider,{variant:"dashed",my:10})]}):null},kC=({onChange:e})=>{const{t,i18n:r}=m.useTranslation(),a=i=>()=>{const c=i();e(c)},l=g.useMemo(()=>Mo(),[]),o=r.language==="zh";return n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(s.Table,{withTableBorder:!1,sx:{"tbody > tr":{border:"none"},"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:n.jsx(s.Table.Tbody,{children:Object.entries(l).map(([i,c])=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:n.jsx(s.Text,{size:"xs",c:"#555",fw:500,sx:{textAlignLast:"justify"},children:t(`filter.widget.date_range.shortcut.${i}.label`)})}),c.map(({key:d,value:u,getRange:p})=>n.jsx(s.Table.Td,{children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",onClick:a(p),children:t(`filter.widget.date_range.shortcut.${i}.${o?"full.":""}${d}`)})},d))]},i))})})]})},ui=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),zC=({label:e,required:t,value:r,onChange:a,max_days:l,allowSingleDateInRange:o,inputFormat:i,disabled:c})=>{const{t:d}=m.useTranslation(),[u,{open:p,close:f}]=te.useDisclosure(!1),[v,x]=r.value,_=v?D(v).format(i):"",w=x?D(x).format(i):"";return n.jsxs(s.Popover,{opened:u,onClose:f,position:"bottom-start",shadow:"md",children:[n.jsxs(s.Group,{justify:"flex-start",grow:!0,wrap:"nowrap",gap:0,w:"288px",sx:{marginTop:"3px"},children:[n.jsx(s.Popover.Target,{children:n.jsx(s.TextInput,{label:e,labelProps:{title:e},required:t,leftSection:n.jsx(T.IconCalendar,{size:16}),placeholder:d("filter.widget.date_range.start_date"),readOnly:!0,disabled:c,value:_,onFocus:p,styles:ui(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},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to left, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})}),n.jsx(s.TextInput,{label:n.jsx(s.Group,{justify:"flex-end",children:n.jsx(TC,{begin:v,end:x})}),leftSection:n.jsx(T.IconMinus,{size:16}),placeholder:d("filter.widget.date_range.end_date"),readOnly:!0,disabled:!v||c,value:w,onFocus:p,styles:ui(u),sx:{".mantine-Input-section":{transform:"translateX(-18px)"},".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}}})]}),n.jsxs(s.Popover.Dropdown,{p:"sm",children:[n.jsx(SC,{max_days:l}),n.jsx(CC,{value:r,onChange:a,close:f,allowSingleDateInRange:o,max_days:l}),n.jsx(kC,{onChange:a})]})]})},pi={value:[null,null],shortcut:null},hi=e=>{const t=Fr(e.shortcut);return t||(Array.isArray(e.value)?e:pi)},DC=e=>g.useMemo(()=>hi(e),[e]),gi=S.observer(({label:e,config:t,value:r=pi,onChange:a,disabled:l})=>{const{inputFormat:o,required:i,max_days:c,allowSingleDateInRange:d}=t,u=DC(r);return n.jsx(zC,{label:e,value:u,onChange:a,inputFormat:o,allowSingleDateInRange:d,max_days:c,required:i,disabled:l})}),IC=nt.createStyles((e,{radius:t=4,name:r,...a})=>({root:{borderRadius:s.getRadius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef",...a,"&.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-select-item-option-state-icon":{lineHeight:"20px"}},".rc-virtual-list-holder-inner":{alignItems:"flex-start"}}})),MC={root:{cursor:"pointer","&:hover":{backgroundColor:"var(--mantine-color-default-hover)"},"input, .mantine-Checkbox-labelWrapper":{cursor:"pointer",pointerEvents:"none"}}},AC=({disabled:e,radius:t,style:r,label:a,value:l,onChange:o,options:i,errorMessage:c,required:d})=>{const{t:u}=m.useTranslation(),{classes:p,cx:f}=IC({radius:t,name:"MultiSelectWidget"}),[v,x]=g.useState(!1),_=N=>{x(N)},w=v&&(l==null?void 0:l.length)>0,[k,z]=g.useState(""),I=g.useMemo(()=>{if(!k)return i;const N=k.toLowerCase(),de=H=>{var ae;return((ae=H.description)==null?void 0:ae.toLowerCase().includes(N))||H.label.toLowerCase().includes(N)};return i.filter(de)},[k,i]),M=g.useMemo(()=>new Set(i.map(N=>N.value)),[i]),O=g.useMemo(()=>new Set(l),[l]),V=g.useMemo(()=>O.size!==M.size?!1:Array.from(M).every(N=>O.has(N)),[O,M]),Y=()=>{if(V){o([]);return}const N=Array.from(M);o(N)};return n.jsxs(s.Stack,{gap:3,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsxs(s.Text,{className:p.label,size:"sm",children:[a,d&&n.jsx("span",{className:p.required,"aria-hidden":"true",children:"*"})]}),w&&n.jsx(s.Tooltip,{label:u("filter.widget.common.x_selected",{count:l.length}),children:n.jsx(s.Badge,{variant:"light",children:l.length})})]}),n.jsx(as,{disabled:e,allowClear:!0,className:f(p.root,"check-select"),dropdownClassName:f(p.dropdown,""),onDropdownVisibleChange:_,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:r,clearIcon:()=>n.jsx(s.CloseButton,{size:"sm"}),value:l,onChange:o,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:n.jsx(Xr,{errorMessage:c}),maxTagTextLength:10,maxTagPlaceholder:N=>u("filter.widget.common.x_selected",{count:N.length}),searchValue:k,onSearch:z,filterOption:!1,dropdownRender:N=>n.jsxs(n.Fragment,{children:[M.size>0&&!k&&n.jsx(s.Group,{px:"xs",py:"xs",onClick:Y,styles:MC,children:n.jsx(s.Checkbox,{size:"xs",checked:V,onChange:b.noop,label:u("common.actions.select_all")})}),n.jsx(s.Divider,{}),N]}),children:I.map(N=>n.jsxs(as.Option,{title:N.label,children:[n.jsx(s.Text,{size:"sm","data-role":"label",children:N.label}),N.description&&n.jsx(s.Text,{size:"xs",c:"dimmed","data-role":"description",children:N.description})]},N.value))})]})},PC=S.observer(({label:e,config:t,value:r,onChange:a})=>{const l=ee(),o=!!t.options_query_id,{state:i,error:c}=l.getDataStuffByID(t.options_query_id),d=i==="loading",u=t.min_width?t.min_width:"200px",p=o?d:!1,f=g.useMemo(()=>t.initialSelection(r),[r,t.initialSelection]),v=x=>a(x,!1);return n.jsx(AC,{label:e,options:t.options,style:{minWidth:"160px",width:u,maxWidth:p?u:"unset",borderColor:"#e9ecef"},disabled:p,value:[...f],onChange:v,errorMessage:c,required:t.required})}),VC=({option:e,...t})=>{const{label:r,description:a}=e;return n.jsx("div",{...t,children:n.jsx(s.Group,{wrap:"nowrap",children:n.jsxs("div",{children:[n.jsx(s.Text,{size:"sm","data-role":"label",children:r}),n.jsx(s.Text,{size:"xs",c:"dimmed","data-role":"description",children:a})]})})})},$C=S.observer(({label:e,config:t,value:r,onChange:a})=>{const{t:l}=m.useTranslation(),o=ee(),i=!!t.options_query_id,{state:c,error:d}=o.getDataStuffByID(t.options_query_id),u=c==="loading",p=g.useCallback((f,v)=>{f&&a(f,!1)},[a]);return n.jsx(s.Select,{label:e,data:t.options,disabled:i?u:!1,value:r,onChange:p,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"}},renderOption:VC,searchable:!d,nothingFoundMessage:d||l("filter.widget.common.selector_option_empty"),clearable:t.clearable})});function EC({label:e,config:t,value:r,onChange:a}){return n.jsx(s.TextInput,{label:e,value:r||"",onChange:l=>a(l.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const BC=S.observer(({filter:{type:e,config:t,key:r,...a},formFieldProps:l})=>{switch(e){case $.Select:return n.jsx($C,{...a,...l,config:t});case $.MultiSelect:return n.jsx(PC,{...a,...l,config:t});case $.TreeSelect:return n.jsx(cC,{...a,...l,config:t});case $.TreeSingleSelect:return n.jsx(hC,{...a,...l,config:t});case $.TextInput:return n.jsx(EC,{...a,...l,config:t});case $.DateRange:return n.jsx(gi,{...a,...l,config:t});case $.Checkbox:return n.jsx(wC,{...a,...l,config:t});default:return null}}),LC=S.observer(g.forwardRef(({filter:e,...t},r)=>n.jsx("div",{className:"filter-root",ref:r,children:n.jsx(ne,{children:n.jsx(BC,{filter:e,formFieldProps:t})})}))),qC=({disabled:e,onSubmit:t})=>{const{renderSearchButton:r}=fs();return r?r({disabled:e,onSubmit:t}):n.jsx(s.Button,{color:"blue",size:"sm",onClick:t,disabled:e,children:"Search"})};function OC(e){const t=Q();g.useEffect(()=>{var r,a;(a=(r=t.filters).updatePreviewValues)==null||a.call(r,e)},[e])}const fi="N/A";function NC(){const e=At(),t=e.content.views.visibleViews;return g.useMemo(()=>t.map(l=>{var o;return l.type===E.Tabs?(o=l.tabView)==null?void 0:o.view_id:l.id}).filter(Boolean).flatMap(l=>e.content.filters.visibleInView(l)).filter(Boolean).map(l=>GC(l)),[t])}function GC(e){switch(e.type){case $.Select:case $.MultiSelect:case $.TreeSelect:case $.TreeSingleSelect:return{label:e.label,value:FC(e.config,e.value)};case $.TextInput:return{label:e.label,value:e.value};case $.DateRange:return{label:e.label,value:jC(e.config,e.value)};case $.Checkbox:return{label:e.label,value:QC(e.value)};default:return{label:e.label,value:e.value}}}function FC(e,t){const r=new Set;return Array.isArray(t)?t.forEach(a=>r.add(a)):r.add(t),r.size===0?fi:e.options.filter(a=>r.has(a.value)).map(a=>a.label).join(", ")}function tz(e){return e}function jC(e,t){const a=hi(t).value.filter(l=>!!l).map(l=>D(l).format(e.inputFormat));return a.length===0?fi:a.join(" - ")}function QC(e){return e?"✔️":"❌"}const WC=({opened:e,toggle:t})=>{const{t:r}=m.useTranslation();return n.jsx(s.Group,{justify:"flex-end",ml:-4,mt:-4,mb:e?4:0,children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",color:e?"gray":"blue",leftSection:e?n.jsx(T.IconChevronsUp,{size:14}):n.jsx(T.IconChevronsDown,{size:14}),onClick:t,children:r(e?"filter.hide_filters":"filter.show_filters")})})},bi=S.observer(function({view:t}){const[r,{toggle:a}]=te.useDisclosure(!0),l=ee(),{control:o,handleSubmit:i,reset:c}=y.useForm({defaultValues:l.filters.values,reValidateMode:"onBlur"}),d=y.useWatch({control:o});g.useEffect(()=>{c(l.filters.values)},[l.filters.values,c]),OC(d);const u=l.filters.visibleInView(t.id),p=g.useMemo(()=>u.every(w=>w.should_auto_submit),[u]),f=g.useMemo(()=>u.filter(w=>b.get(w,"config.required",!1)),[u]),v=g.useMemo(()=>f.length===0?!1:f.some(w=>!w.requiredAndPass(d[w.key])),[d,f]);if(u.length===0)return null;const x=(w,k)=>(z,I)=>{k(z),(w.should_auto_submit||I)&&l.filters.setValueByKey(w.key,z)},_=g.useMemo(()=>i(l.filters.setValues),[i,l.filters.setValues]);return n.jsxs("form",{children:[n.jsx(WC,{opened:r,toggle:a}),n.jsx(s.Collapse,{in:r,children:n.jsxs(s.Group,{className:"dashboard-filters",justify:"space-between",wrap:"nowrap",sx:p?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n.jsx(s.Group,{align:"flex-start",children:u.map(w=>n.jsx(y.Controller,{name:w.key,control:o,render:({field:k})=>n.jsx(LC,{filter:w,value:k.value,onChange:x(w,k.onChange)})},w.id))}),!p&&n.jsx(s.Group,{sx:{alignSelf:"flex-end"},children:n.jsx(qC,{disabled:v,onSubmit:_})})]})})]})}),UC={viewPanelInFullScreen:b.noop,inFullScreen:!1},vn=g.createContext(UC),YC=S.observer(({view:e})=>{const{t}=m.useTranslation(),r=W(),{panel:a}=re(),l=a.realQueryOptions,o=c=>{r.editor.open(["_QUERIES_",c])},i=()=>{r.editor.open(["_VIEWS_",e.id,"_PANELS_",a.id,"_TABS_","Data"])};return l.length===0?null:n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{label:t(l.length>1?"query.labels":"query.label"),labelPosition:"center"}),n.jsx(s.Menu.Item,{onClick:i,leftSection:n.jsx(T.IconDatabase,{size:14}),children:t("data.label")}),l.map(c=>n.jsx(s.Menu.Item,{onClick:()=>o(c.value),leftSection:n.jsx(T.IconDatabase,{size:14}),children:c.label},c.value))]})}),KC=S.observer(({view:e,title:t})=>{const{t:r}=m.useTranslation(),a=W(),l=Q(),o=Te.useModals(),{panel:i,downloadPanelScreenshot:c}=re(),{id:d}=i,{viewPanelInFullScreen:u,inFullScreen:p}=g.useContext(vn),f=()=>{l.duplicatePanelByID(d,e.id)},v=()=>{a.editor.open(["_VIEWS_",e.id,"_PANELS_",d,"_TABS_","Panel"])},x=()=>{a.editor.open(["_VIEWS_",e.id,"_PANELS_",d,"_TABS_","Variables"])},_=()=>{a.editor.open(["_VIEWS_",e.id,"_PANELS_",d,"_TABS_","Visualization"])},w=()=>{a.editor.open(["_VIEWS_",e.id,"_PANELS_",d,"_TABS_","Interactions"])},k=()=>o.openConfirmModal({title:`${r("panel.delete")}?`,labels:{confirm:r("common.actions.confirm"),cancel:r("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>l.removePanelByID(d,e.id),confirmProps:{color:"red"},zIndex:320}),z=g.useCallback(()=>{u(d)},[d,u]),I=!p&&e.type!==E.Modal;return n.jsx(n.Fragment,{children:n.jsx(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:n.jsxs(s.Menu,{withinPortal:!0,children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Item,{onClick:i.refreshData,leftSection:n.jsx(T.IconRefresh,{size:14}),children:r("common.actions.refresh")}),n.jsx(s.Menu.Item,{onClick:i.downloadData,leftSection:n.jsx(T.IconDownload,{size:14}),children:r("common.actions.download_data")}),n.jsx(s.Menu.Item,{onClick:i.downloadSchema,leftSection:n.jsx(T.IconCode,{size:14}),children:r("common.actions.download_schema")}),n.jsx(s.Menu.Item,{onClick:c,leftSection:n.jsx(T.IconCamera,{size:14}),children:r("common.actions.download_screenshot")}),I&&n.jsx(s.Menu.Item,{onClick:z,leftSection:n.jsx(T.IconArrowsMaximize,{size:14}),disabled:!0,children:r("common.actions.enter_fullscreen")}),n.jsx(YC,{view:e}),n.jsx(s.Divider,{label:r("common.actions.edit"),labelPosition:"center"}),n.jsx(s.Menu.Item,{onClick:v,leftSection:n.jsx(T.IconAppWindow,{size:14}),children:r("panel.label")}),n.jsx(s.Menu.Item,{onClick:x,leftSection:n.jsx(T.IconVariable,{size:14}),children:r("panel.variable.labels")}),n.jsx(s.Menu.Item,{onClick:_,leftSection:n.jsx(T.IconChartHistogram,{size:14}),children:r("visualization.label")}),n.jsx(s.Menu.Item,{onClick:w,leftSection:n.jsx(T.IconRoute,{size:14}),children:r("interactions.label")}),n.jsx(s.Divider,{label:r("common.actions.actions"),labelPosition:"center"}),n.jsx(s.Menu.Item,{onClick:f,leftSection:n.jsx(T.IconCopy,{size:14}),children:r("common.actions.duplicate")}),n.jsx(s.Menu.Item,{color:"red",onClick:k,leftSection:n.jsx(T.IconTrash,{size:14}),children:r("common.actions.delete")})]})]})})})});function XC(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const ZC=S.observer(()=>{const e=ee(),{panel:t}=be(),r=g.useMemo(()=>Zt(t.description,t.json.variables,e.payloadForViz,t.data),[t.data,t.description,t.json.variables,e.payloadForViz]);return n.jsx(mt,{value:r,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}},dashboardState:e.dashboardState,variableAggValueMap:t.variableAggValueMap})}),fa=S.observer(()=>{const{t:e}=m.useTranslation(),[t,r]=g.useState(!1),{panel:a}=be();return XC(a.description)?null:n.jsxs(n.Fragment,{children:[n.jsx(s.Modal,{opened:t,onClose:()=>r(!1),title:a.title.show?a.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:n.jsx(ZC,{})}),n.jsx(s.Tooltip,{label:e("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(l=>!l),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n.jsx(T.IconInfoCircle,{size:20})})})]})}),nz="",JC=S.observer(function(){const{panel:t}=be(),{name:r,title:a}=t;return a.show?n.jsx(s.Group,{grow:!0,justify:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:n.jsx(s.Text,{size:"sm",ta:"center",lineClamp:1,className:"panel-title-text",children:r})}):null});function HC(e){const t=g.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const a=t.current;if(!a)return;const l=a.offsetWidth*2,o=a.offsetHeight*2;ns.toBlob(t.current,{bgcolor:"white",width:l,height:o,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(i=>{window.saveAs(i,`${e.name?e.name:e.viz.type}.png`)})}}}var yi=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(yi||{}),_n=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(_n||{});class RC{constructor(t){P(this,"vizInstance");P(this,"operationManager");P(this,"triggerManager");P(this,"vizManager");P(this,"runningMigration");P(this,"panelModel");P(this,"status","notStarted");this.panelModel=t.getRequired(J.instanceScope.panelModel),this.vizInstance=t.getRequired(J.instanceScope.vizInstance),this.operationManager=t.getRequired(J.instanceScope.operationManager),this.triggerManager=t.getRequired(J.instanceScope.triggerManager),this.vizManager=t.getRequired(J.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(r){return console.warn("check migration failed",r),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(r=>r())),"migrated"}catch(r){return console.warn("migration failed",r),"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),r={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(r)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),r={configData:this.vizInstance.instanceData};return t.migrator.needMigration(r)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}class eT{getTriggerSchemaList(){return[]}getTriggerList(){return Promise.resolve([])}removeTrigger(){return Promise.resolve()}createOrGetTrigger(){return Promise.resolve(vi)}retrieveTrigger(){return Promise.resolve(vi)}watchTriggerSnapshotList(){return()=>{}}needMigration(){return Promise.resolve(!1)}runMigration(){return Promise.resolve()}}class tT{constructor(){P(this,"id","");P(this,"schemaRef","");P(this,"triggerData",new Gt({}))}}const vi=new tT;class nT{getOperationSchemaList(){return[]}getOperationList(){return Promise.resolve([])}removeOperation(){return Promise.resolve()}createOrGetOperation(){return Promise.resolve(_i)}runOperation(){return Promise.resolve()}retrieveTrigger(){return Promise.resolve(_i)}runMigration(){return Promise.resolve()}needMigration(){return Promise.resolve(!1)}}class rT{constructor(){P(this,"id","");P(this,"schemaRef","");P(this,"operationData",new Gt({}))}}const _i=new rT,kn=class kn{constructor(){P(this,"triggerManager",new eT);P(this,"operationManager",new nT)}getInteractionList(){return Promise.resolve([])}addInteraction(){return Promise.resolve()}removeInteraction(){return Promise.resolve()}runInteraction(){return Promise.resolve()}};P(kn,"instance",new kn);let ba=kn;function xi(e,t=!0){const{panel:r}=be();return g.useCallback(a=>{const l=a.getRequired(J.vizManager),o=l.resolveComponent(e.viz.type);return a.createScoped().provideFactory(J.instanceScope.vizInstance,()=>l.getOrCreateInstance(e)).provideFactory(J.instanceScope.interactionManager,i=>{const c=i.getRequired(J.instanceScope.vizInstance);return t?new rl(c,o,nr):new ba}).provideFactory(J.instanceScope.operationManager,i=>i.getRequired(J.instanceScope.interactionManager).operationManager).provideFactory(J.instanceScope.triggerManager,i=>i.getRequired(J.instanceScope.interactionManager).triggerManager).provideValue(J.instanceScope.panelModel,r).provideFactory(J.instanceScope.migrator,i=>new RC(i))},[e.viz.type,e.viz.conf,t])}const mi={withInteraction:!0,withAddon:!0,withPanelTitle:!0},wi=g.createContext(mi);function aT({children:e,...t}){const r=b.defaults({},t,mi);return n.jsx(wi.Provider,{value:r,children:e})}function ya(){return g.useContext(wi)}function Ci(e){const[t,r]=g.useState(!1),a=Rt().getRequired(J.instanceScope.migrator);return q.useAsyncEffect(async()=>{const l=a.status===_n.notStarted;r(a.status===_n.done),a.status===_n.notStarted&&a.runMigration().then(o=>{o===yi.migrated&&l&&(e==null||e())}).finally(()=>{r(!0)})},[a]),t}function Ti(e,t){const r=Rt().getRequired(J.instanceScope.vizInstance);return q.useAsyncEffect(async()=>{b.isEqual(await r.instanceData.getItem(null),t.viz.conf)||await r.instanceData.setItem(null,t.viz.conf)},[r,t.viz.conf]),g.useEffect(()=>r.instanceData.watchItem(null,a=>{e(a)}),[e,t.viz.type]),r}function sT({setVizConf:e,...t}){const{panel:r}=t,a=Ti(e,r),l=Ci(()=>{Qe.showNotification({title:`${r.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return q.useAsyncEffect(async()=>{await a.instanceData.setItem(null,r.viz.conf)},[a,r.viz.type]),l?n.jsx(Md,{...t}):n.jsx(s.Text,{size:"sm",children:"Checking update..."})}function lT(e){const{panel:t,setVizConf:r}=e;Ti(r,t);const{inEditMode:a}=g.useContext(Pt);return Ci(()=>{a&&Qe.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?n.jsx(Id,{...e}):n.jsx(s.Text,{size:"sm",children:"Checking update"})}const rz="";function oT(e,t){const{vizManager:r}=g.useContext(Je),{panel:{viz:a,title:l,id:o,name:i,description:c,queryIDs:d,variables:u}}=be(),p={id:o,name:i,title:l,description:c,queryIDs:d,viz:a},{withInteraction:f}=ya(),v=xi(p,f);try{return r.resolveComponent(a.type),n.jsxs(Ht,{configure:v,children:[n.jsx(lT,{setVizConf:a.setConf,panel:p,measure:t,data:e,variables:u,vizManager:r}),n.jsx(ki,{})]})}catch(x){return console.info(b.get(x,"message")),null}}const Si=S.observer(function({data:t}){const{ref:r,width:a,height:l}=te.useElementSize(),o=oT(t,{w:a,h:l}),i=a>0&&l>0;return n.jsx("div",{className:"viz-root",ref:r,children:n.jsx(s.Box,{sx:{width:a,height:l,overflow:"hidden"},children:i&&n.jsx(ne,{children:o})})})}),ki=()=>{const e=Rt(),t=e.getRequired(J.instanceScope.vizInstance),{inEditMode:r}=g.useContext(Pt),a=e.getRequired(J.panelAddonManager),{withAddon:l}=ya(),o=Od();return!o||!l?null:md.createPortal(n.jsx(n.Fragment,{children:a.createPanelAddonNode({viz:t,isInEditMode:r})}),o,"addon")},zi=S.observer(({panel:e})=>n.jsxs(s.Stack,{children:[e.queryErrors.map((t,r)=>n.jsx(s.Text,{c:"red",size:"sm",ta:"center",ff:"monospace",children:t},`${r}-${t}`)),n.jsx(s.Text,{c:"gray",ta:"center",size:"sm",children:e.queryStateMessages})]})),va=S.observer(({panel:e})=>n.jsxs(s.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[n.jsx(s.LoadingOverlay,{visible:e.dataLoading,transitionProps:{exitDuration:0}}),!e.canRenderViz&&n.jsx(zi,{panel:e}),e.canRenderViz&&n.jsx(Si,{data:e.data})]})),iT={border:"1px solid #e9ecef"},_a=S.observer(({panel:e,panelStyle:t,dropdownContent:r})=>{const{ref:a,downloadPanelScreenshot:l}=HC(e),{withAddon:o,withPanelTitle:i}=ya(),c=o?cs:g.Fragment;return n.jsx(Ln,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:l},children:n.jsx(s.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,ref:a,p:0,sx:{...iT,...t},children:n.jsxs(c,{children:[i&&n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{className:"panel-description-popover-wrapper",children:n.jsx(fa,{})}),r,n.jsx(JC,{})]}),n.jsx(va,{panel:e})]})})})}),cT={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function dT(e){return e.style.border.enabled?{}:cT}const Di=S.observer(function({panel:t,view:r}){const a=dT(t);return n.jsx(_a,{panel:t,panelStyle:a,dropdownContent:n.jsx(KC,{view:r,title:t.name})})});function uT(e){return!["richText","button"].includes(e)}const pT=S.observer(({view:e,title:t})=>{const{t:r}=m.useTranslation(),{panel:a,downloadPanelScreenshot:l}=be(),{id:o}=a,{viewPanelInFullScreen:i,inFullScreen:c}=g.useContext(vn),d=g.useCallback(()=>{i(o)},[o,i]),u=!c&&e.type!==E.Modal;return uT(a.viz.type)?n.jsx(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:n.jsxs(s.Menu,{withinPortal:!0,children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Box,{className:"panel-dropdown-target"})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Item,{onClick:a.refreshData,leftSection:n.jsx(T.IconRefresh,{size:14}),children:r("common.actions.refresh")}),n.jsx(s.Menu.Item,{onClick:a.downloadData,leftSection:n.jsx(T.IconDownload,{size:14}),children:r("common.actions.download_data")}),n.jsx(s.Menu.Item,{onClick:l,leftSection:n.jsx(T.IconCamera,{size:14}),children:r("common.actions.download_screenshot")}),u&&n.jsx(s.Menu.Item,{onClick:d,leftSection:n.jsx(T.IconArrowsMaximize,{size:14}),children:r("common.actions.enter_fullscreen")})]})]})}):null});function hT(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const xa=S.observer(({panel:e,view:t})=>{const r=hT(e);return n.jsx(_a,{panel:e,panelStyle:r,dropdownContent:n.jsx(pT,{title:e.name,view:t})})}),gT={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},Ii=S.observer(function({view:t,panel:r,exitFullScreen:a}){return n.jsx(s.Modal,{opened:!0,fullScreen:!0,onClose:a,title:n.jsx(s.Button,{color:"blue",size:"xs",onClick:a,leftSection:n.jsx(T.IconArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:gT,children:n.jsx(s.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:n.jsx(xa,{view:t,panel:r})})})});function Mi(e,t,r){const{panels:a}=ee(),l=e.id==="Main",[o,i]=g.useState(()=>l&&a.findByID(t)?t:null),c=g.useCallback(f=>{i(f),l&&r(f)},[l,r]),d=g.useCallback(()=>{i(null),l&&r("")},[l,r]),u=o?a.findByID(o):null;return{viewPanelInFullScreen:c,exitFullScreen:d,inFullScreen:!!u,fullScreenPanel:u}}function fT(e){const t=At(),r=g.useMemo(()=>t.content.panels.findByID(e.panelId),[e.panelId]);return r?n.jsx(aT,{withAddon:!1,withPanelTitle:!1,withInteraction:!1,children:n.jsx(_a,{panel:r,panelStyle:{}})}):null}const az="",bT=g.forwardRef(({h:e},t)=>n.jsx(s.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:n.jsx(T.IconArrowsMove,{size:16})})),yT=g.forwardRef(({handleAxis:e,...t},r)=>n.jsx(s.ActionIcon,{ref:r,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:n.jsx(T.IconChevronDownRight,{size:16})})),vT=Nt.WidthProvider(Nt.Responsive),_T=S.observer(({view:e,className:t="layout"})=>{const a=Q().layouts,l=a.items(e.panelIDs),o=a.gridLayouts(e.panelIDs),i=(u,p,f,v)=>{f.h<30&&(f.h=30,v.h=30),f.w<4&&(f.w=4,v.w=4)},c=(u,p,f)=>{console.log("🔴 onResizeStop",{layouts:u,oldItem:p,newItem:f}),a.updateCurrentLayoutItem(f)},d=(u,p,f)=>{console.log("🔴 onDragStop",{layouts:u,oldItem:p,newItem:f}),a.updateCurrentLayoutItems(u)};return n.jsx(vT,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:a.cols,layouts:o,draggableHandle:".react-grid-customDragHandle",resizeHandle:n.jsx(yT,{}),onResize:i,breakpoints:a.breakpoints,onBreakpointChange:a.setCurrentBreakpoint,onResizeStop:c,onDragStop:d,width:a.currentLayoutPreviewWidth,children:l.map(u=>n.jsxs("div",{"data-grid":u.layoutProperies,className:"panel-grid-item",children:[n.jsx(bT,{h:u.h}),n.jsx(Di,{view:e,panel:u.panel})]},u.id))})}),xT=Nt.WidthProvider(Nt.Responsive),mT=S.observer(({view:e,className:t="layout"})=>{const r=ee(),a=r.layouts.items(e.panelIDs),l=r.layouts.gridLayouts(e.panelIDs);return n.jsx(xT,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:r.layouts.cols,layouts:l,breakpoints:r.layouts.breakpoints,onBreakpointChange:r.layouts.setCurrentBreakpoint,children:a.map(o=>n.jsx("div",{"data-grid":o.layoutProperies,className:"panel-grid-item",children:n.jsx(xa,{view:e,panel:o.panel})},o.id))})});function ma(e){const t=g.useRef(null);return{ref:t,downloadScreenshot:()=>{var l;const a=(l=t.current)==null?void 0:l.querySelector(".react-grid-layout");a&&e.downloadScreenshot(a)}}}const wT=S.observer(({downloadScreenshot:e})=>{const{t}=m.useTranslation(),[r,{setTrue:a,setFalse:l}]=q.useBoolean(!1),o=hs(),i=ee(),c=()=>{const d=JSON.stringify(i.contentJSON,null,2),u=`${o.name}__${i.name}`;Dt(u,d)};return n.jsxs(s.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:n.jsx(s.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:a,onMouseLeave:l,sx:{opacity:r?1:.6,transform:`translateX(${r?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:n.jsx(T.IconShare3,{size:"1rem"})})})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconCamera,{size:14}),onClick:e,children:t("common.actions.download_screenshot")}),n.jsx(s.Menu.Divider,{}),n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconDownload,{size:14}),onClick:i.queries.downloadAllData,children:t("common.actions.download_data")}),n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconCode,{size:14}),onClick:c,children:t("common.actions.download_schema")})]})]})}),Ai=S.observer(({children:e,view:t,sx:r={}})=>{const{ref:a,downloadScreenshot:l}=ma(t);return n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{ref:a,pt:10,pb:10,sx:r,children:e}),n.jsx(wT,{downloadScreenshot:l})]})}),Pi=S.observer(({downloadScreenshot:e})=>n.jsx(s.ActionIcon,{className:"download-screenshot-button",color:"blue",variant:"subtle",onClick:e,children:n.jsx(T.IconCamera,{size:14})})),CT=S.observer(({children:e,view:t})=>{const r=ee(),a=t.config,l=r.views.visibleViewIDs.includes(t.id),o=()=>r.views.rmVisibleViewID(t.id),{ref:i,downloadScreenshot:c}=ma(t);return n.jsx(s.Modal,{size:a.width,centered:!0,opened:l,onClose:o,withCloseButton:!1,title:n.jsxs(s.Group,{justify:"space-between",px:"1rem",h:"48px",children:[n.jsx(s.Box,{children:a.custom_modal_title.value}),n.jsx(Pi,{downloadScreenshot:c})]}),trapFocus:!0,onDragStart:d=>{d.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:a.height,overflow:"auto",position:"relative",paddingBottom:10},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:n.jsx(s.Box,{ref:i,children:e})})}),TT=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},ST=S.observer(({view:e})=>{const t=ee(),r=e.config;return n.jsxs(s.Tabs,{className:"render-view-tabs",variant:r.variant,orientation:r.orientation,value:e.tab,onChange:e.setTab,styles:{root:{height:"100%",overflow:r.orientation==="horizontal"?"hidden":"auto"},panel:{padding:r.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[n.jsx(s.Tabs.List,{grow:r.grow,children:r.tabsInOrder.map(a=>n.jsx(s.Tabs.Tab,{value:a.id,sx:TT(a),disabled:!a.view_id,children:a.name??a.id},a.id))}),r.tabsInOrder.map(a=>{const l=t.views.findByID(a.view_id);return l?n.jsx(s.Tabs.Panel,{value:a.id,children:n.jsx(xn,{view:l})},a.id):null})]})}),kT=S.observer(({view:e,children:t})=>{switch(e.type){case E.Modal:return n.jsx(CT,{view:e,children:t});case E.Tabs:return n.jsx(ST,{view:e});case E.Division:default:return n.jsx(Ai,{view:e,children:t})}}),zT=S.observer(({children:e,view:t})=>{const a=Q().layouts,[l,o]=te.useResizeObserver();return g.useEffect(()=>{a.setCurrentLayoutWrapperWidth(o.width)},[o.width]),n.jsx(s.Box,{sx:{height:"100%"},ref:l,children:n.jsx(s.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:a.currentLayoutPreviewWidth??"100%",transform:`scale(${a.divisionPreviewScale})`,transformOrigin:"0 0"},children:n.jsx(Ai,{view:t,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:e})})})});function Vi(e){return e.replace(/(vw|vh)/,"%")}const DT=S.observer(({children:e,view:t})=>{const r=t.config,{width:a,height:l}=g.useMemo(()=>({width:Vi(r.width),height:Vi(r.height)}),[r.width,r.height]),{ref:o,downloadScreenshot:i}=ma(t);return n.jsx(s.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:n.jsx(s.Modal,{size:r.width,opened:!0,onClose:b.noop,withCloseButton:!1,title:n.jsxs(s.Group,{justify:"space-between",px:"1rem",h:"48px",children:[n.jsx(s.Box,{children:r.custom_modal_title.value}),n.jsx(Pi,{downloadScreenshot:i})]}),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:a,height:l,maxHeight:l},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:n.jsx(s.Box,{ref:o,children:e})})})}),IT=({variant:e,orientation:t})=>{const r={root:{height:"100%",overflow:"hidden"},list:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(r.tab.paddingTop="6px",r.tab.paddingBottom="6px"),t==="vertical"&&(r.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},r.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),r},MT=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},AT=S.observer(({view:e})=>{const{t}=m.useTranslation(),r=Te.useModals(),a=Q(),l=g.useMemo(()=>a.views.options.filter(u=>u.type===E.Division),[e.id,a.views.options]),o=e.config,i=u=>r.openConfirmModal({title:`${t("view.component.tabs.tab.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),c=o.tabs.length===0,d=o.tabsInOrder.length===0?void 0:o.tabsInOrder[0].id;return n.jsxs(s.Tabs,{className:"preview-view-tabs",variant:o.variant,orientation:o.orientation,value:e.tab||d,onChange:e.setTab,styles:IT(o),children:[n.jsxs(s.Tabs.List,{grow:o.grow,children:[o.tabsInOrder.map(u=>n.jsx(s.Tabs.Tab,{value:u.id,sx:MT(u),children:u.name??u.id},u.id)),n.jsx(s.Tabs.Tab,{onClick:o.addTab,value:"add",className:"add-a-tab",children:n.jsx(T.IconPlus,{size:18,color:"#228be6"})})]}),o.tabsInOrder.map((u,p)=>{const f=a.views.findByID(u.view_id);return n.jsxs(s.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[n.jsxs(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[n.jsx(s.Overlay,{backgroundOpacity:.8,color:"#FFF",blur:10,zIndex:100}),n.jsxs(s.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[n.jsx(s.TextInput,{label:t("view.component.tabs.tab.name"),required:!0,value:u.name,onChange:v=>u.setName(v.currentTarget.value)}),n.jsx(s.Select,{label:t("view.label"),value:u.view_id,onChange:u.setViewID,data:l}),n.jsx(s.NumberInput,{label:t("view.component.tabs.tab.order"),required:!0,value:u.order,onChange:v=>u.setOrder(v||0),min:0,max:1e3,step:1}),n.jsx(s.ColorInput,{label:t("view.component.tabs.tab.color"),value:u.color,onChange:u.setColor,disabled:o.variant!=="default"}),f&&n.jsx(s.Button,{mt:20,variant:"gradient",leftSection:n.jsx(T.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>a.views.setIDOfVIE(f.id),children:t("view.component.tabs.tab.switch_to_view",{name:f.name})}),n.jsx(s.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>i(p),disabled:c,leftSection:n.jsx(T.IconTrash,{size:14}),children:t("view.component.tabs.tab.delete")})]})]}),f&&n.jsx(xn,{view:f})]},u.id)})]})}),PT=S.observer(({view:e,children:t})=>{switch(e.type){case E.Modal:return n.jsx(DT,{view:e,children:t});case E.Tabs:return n.jsx(AT,{view:e});case E.Division:default:return n.jsx(zT,{view:e,children:t})}}),$i=S.observer(function({view:t}){const a=Q().layouts.divisionPreviewScale!==1;return n.jsx(vn.Provider,{value:{viewPanelInFullScreen:b.noop,inFullScreen:!1},children:n.jsx(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:a?"transparent":"#efefef"},children:n.jsx(PT,{view:t,children:n.jsxs(s.Box,{sx:{position:"relative"},children:[n.jsx(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n.jsx(bi,{view:t})}),n.jsx(_T,{view:t})]})})})})}),xn=S.observer(function({view:t}){const{fullScreenPanelID:r,setFullScreenPanelID:a}=ws(),{viewPanelInFullScreen:l,exitFullScreen:o,inFullScreen:i,fullScreenPanel:c}=Mi(t,r,a);return n.jsx(vn.Provider,{value:{viewPanelInFullScreen:l,inFullScreen:i},children:n.jsxs(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===E.Modal?"0 !important":"100%"},children:[i&&n.jsx(Ii,{view:t,panel:c,exitFullScreen:o}),n.jsx(kT,{view:t,children:n.jsxs(s.Box,{sx:{position:"relative"},children:[!i&&n.jsx(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n.jsx(bi,{view:t})}),!i&&n.jsx(mT,{view:t})]})})]})})});var Ei=(e=>(e.Use="use",e.Edit="edit",e))(Ei||{});const VT={[E.Division]:"Division",[E.Tabs]:"Tabs",[E.Modal]:"Modal"},Bi={[E.Division]:"rgba(255, 0, 0, 0.2)",[E.Modal]:"rgba(0, 0, 0, 0.2)",[E.Tabs]:"rgba(255, 200, 100, 0.4)"},$T={[E.Division]:"#ff4000",[E.Modal]:"#000",[E.Tabs]:"#ffad18"};function ET(e,t,r){h.addDisposer(e,h.addMiddleware(e,(a,l)=>{l(a,()=>{h.getType(a.context)===t&&a.type==="action"&&r(a.name,a.context)})}))}const Li=h.types.compose("FiltersModel",ca,h.types.model("FiltersModel",{previewValues:h.types.optional(h.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===$.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,widget:t.type}))},get sortedList(){return b.sortBy(e.current,t=>t.label.toLowerCase())}})).actions(e=>({replace(t){e.current=h.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(a=>!e.idSet.has(a.id));e.current.push(...r)},remove(t){e.current.splice(t,1)},removeByID(t){const r=e.current.findIndex(a=>a.id===t);r>=0&&e.current.splice(r,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){ET(e.current,Hr,(r,a)=>{if(r==="setType"){const l=ti(a.config.default_value,a.config);e.setValueByKey(a.key,l),e.updatePreviewValues({...e.previewValues,[a.key]:l})}})}return{afterCreate(){t()}}}),qi=ua.views(e=>({get canPreviewData(){return e.isTransform?e.config.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"},get usage(){return e.contentModel.findQueryUsage(e.id)},get runBySet(){return new Set(e.run_by)},keyInRunBy(t){return this.runBySet.has(t)}})).actions(e=>({changeRunByRecord(t,r){const a=new Set(e.run_by);r?a.add(t):a.delete(t),e.run_by.length=0,e.run_by.push(...a)}})),Oi=h.types.compose("QueriesModel",pa,h.types.model({current:h.types.optional(h.types.array(qi),[])})).views(e=>({get options(){const t=e.current.map(r=>({value:r.id,label:r.name,_type:"query"}));return b.sortBy(t,r=>r.label.toLowerCase())},get optionsWithoutTransform(){const t=e.current.filter(r=>r.type!==F.Transform).map(r=>({value:r.id,label:r.name,_type:"query"}));return b.sortBy(t,r=>r.label.toLowerCase())},get sortedList(){return b.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=h.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(a=>!e.idSet.has(a.id));e.current.push(...r)},remove(t){e.current.splice(t,1)},replaceByIndex(t,r){e.current.splice(t,1,r)},removeQuery(t){const r=e.current.find(a=>a.id===t);r&&(h.detach(r),e.current.remove(r))},removeQueries(t){const r=new Set(t);e.current.forEach(l=>{r.has(l.id)&&h.detach(l)});const a=[...e.current];b.remove(a,l=>r.has(l.id)),e.current=h.cast(a)}})),Ni=ga.views(e=>({get sortedList(){return b.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(r=>({label:r.key,value:r.key,_type:"sql_snippet"}));return b.sortBy(t,r=>r.label.toLowerCase())}})).actions(e=>({replace(t){e.current=h.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(a=>!e.keySet.has(a.key));e.current.push(...r)},remove(t){e.current.splice(t,1)},removeByKey(t){const r=e.current.findIndex(a=>a.key===t);r>=0&&e.current.splice(r,1)},removeByKeys(t){const r=new Set(t);e.current.forEach(l=>{r.has(l.key)&&h.detach(l)});const a=[...e.current];b.remove(a,l=>r.has(l.key)),e.current=h.cast(a)},replaceByIndex(t,r){e.current.splice(t,1,r)}})),BT=h.types.model({data:h.types.optional(h.types.frozen(),[]),state:h.types.optional(h.types.enumeration(["idle","loading","error"]),"idle"),error:h.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),LT=h.types.model({data:h.types.optional(h.types.frozen(),[]),state:h.types.optional(h.types.enumeration(["idle","loading","error"]),"idle"),error:h.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),qT=h.types.model({page:h.types.optional(h.types.number,1),limit:h.types.optional(h.types.number,20),data:h.types.optional(h.types.frozen(),[]),total:h.types.optional(h.types.number,0),state:h.types.optional(h.types.enumeration(["idle","loading","error"]),"idle"),error:h.types.frozen()}).views(e=>({get keywords(){return h.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:r}=h.getParent(e,1);return`${r}||${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:r}=e.keywords;return`
468
+ `)},get metricQueryPayloadValid(){return this.metricQueryPayload?this.metricQueryPayloadError.length===0:!1}})),ua=h.types.compose("QueryRenderModel",ai,h.types.model({state:h.types.optional(h.types.enumeration(["idle","loading","error"]),"idle"),data:h.types.optional(h.types.frozen([]),[]),error:h.types.frozen()})).views(e=>({get datasource(){const{key:t,type:r}=e;return e.rootModel.datasources.find({type:r,key:t})},get additionalQueryInfo(){return e.contentModel.getAdditionalQueryInfo(e.id)},get depQueryModels(){const t=b.get(e,"config.dep_query_ids",[]);return e.contentModel.queries.findByIDSet(new Set(t))},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:r}=e.conditionNames;if(t.length===0&&r.length===0)return"Waiting";const a=[];return t.length>0&&a.push(`context: ${t.join(", ")}`),r.length>0&&a.push(`filter${r.length>1?"s":""}: ${r.join(", ")}`),a.length===2&&a.splice(1,0,"and"),a.unshift("Waiting for"),a.join(" ")}return e.data.length>0?"":"data.empty_data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:h.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const r=e.payload,a=e.config;e.data=yield*h.toGenerator(Y1({payload:r,name:e.name,query:{type:e.type,key:e.key,sql:a.sql,pre_process:e.pre_process,post_process:e.post_process},additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(r){if(Ce.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const a=b.get(r,"message","unkown error");e.error=b.get(r,"response.data.detail.message",a),e.state="error"}}}}),runHTTP:h.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:r,key:a,post_process:l}=e.json;let o=JSON.parse(e.httpConfigString);o=Yt(e.datasource,o);const i=yield*h.toGenerator(K1({type:r,key:a,configString:JSON.stringify(o),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=Kt(e.datasource,i),d=Js(l,c,e.contentModel.dashboardState);e.data=d,e.state="idle",e.error=null}catch(r){if(console.error(r),Ce.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const a=b.get(r,"message","unkown error");e.error=b.get(r,"response.data.detail.message",a),e.state="error"}}}}),runMericoMetricQuery:h.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet&&e.metricQueryPayloadValid)){e.controller=new AbortController,e.state="loading";try{const{type:r,key:a,post_process:l}=e.json;let o={url:"/buffet/api/metric_management/query",method:"POST",data:e.metricQueryPayload};o=Yt(e.datasource,o);const i=yield*h.toGenerator(X1({key:a,configString:JSON.stringify(o),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=Kt(e.datasource,i),d=Js(l,c,e.contentModel.dashboardState);e.data=d.data,e.state="idle",e.error=null}catch(r){if(console.error(r),Ce.isCancel(r))console.debug(`🟡 Query[${e.name}] is cancelled`),e.data=[],e.state="idle";else{e.data=[];const a=b.get(r,"message","unkown error");e.error=b.get(r,"response.data.detail.message",a),e.state="error"}}}}),runTransformation(){e.state="loading";try{const t=e.depQueryModels.map(o=>({id:o.id,name:o.name,data:b.cloneDeep(o.data)})),r=e.contentModel.dashboardState,a=e.pre_process,l=new Function(`return ${a}`)()(t,r,qe);e.data=l,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.isMericoMetricQuery?e.runMericoMetricQuery():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){h.addDisposer(e,j.reaction(()=>{var r,a;if(e.isTransform){const l=e.config;return[e.inUse,e.id,e.key,l.dep_query_ids.toString(),e.pre_process,e.depQueryModelStatesString].join("--")}return e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(r=e.datasource)==null?void 0:r.id}`:e.isMericoMetricQuery?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(a=e.datasource)==null?void 0:a.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},()=>e.fetchData(!1),{fireImmediately:!0,delay:0}))}})),pa=h.types.model("QueriesRenderModel",{current:h.types.optional(h.types.array(ua),[])}).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(r=>r.id===t)},findByIDSet(t){return e.current.filter(r=>t.has(r.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get root(){return h.getRoot(e)},get dashboardName(){return this.root.name},get contentModel(){return h.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:r}=this.contentModel,a=[];t.visibleViews.forEach(i=>{i.panels.forEach(c=>{a.push(...c.queryIDs)})});const l=b.uniq(t.visibleViews.map(i=>i.renderViewIDs).flat());r.current.forEach(i=>{const c=b.get(i,"config.options_query_id");if(!c)return;l.some(u=>i.visibleInViewsIDSet.has(u))&&a.push(c)}),this.findByIDSet(new Set(a)).forEach(i=>{const c=i.config;!i.isTransform||c.dep_query_ids.length===0||a.push(...c.dep_query_ids)});const o=new Set(a);return console.debug("QueryIDs:",o),o},isQueryInUse(t){return this.visibleQueryIDSet.has(t)},addTransformDepQueryIDs(t,r){this.findByIDSet(t).forEach(a=>{const l=a.config;!a.isTransform||l.dep_query_ids.length===0||l.dep_query_ids.forEach(o=>{r!=null&&r.has(o)||t.add(o)})})},get querisToForceReload(){const t=new Set,r=new Set,{views:a,filters:l}=this.contentModel,o=b.uniq(a.visibleViews.map(i=>i.renderViewIDs).flat());return l.current.forEach(i=>{const c=b.get(i,"config.options_query_id");if(!c)return;o.some(u=>i.visibleInViewsIDSet.has(u))&&t.add(c)}),this.addTransformDepQueryIDs(t),a.visibleViews.forEach(i=>{i.panels.forEach(c=>{c.queryIDs.forEach(d=>{t.has(d)||r.add(d)})})}),this.addTransformDepQueryIDs(r,t),{filterQueries:this.findByIDSet(t),panelQueries:this.findByIDSet(r)}}})).actions(e=>({downloadAllData(){const t=e.current.map(({name:r,data:a})=>({id:r,data:a}));Ho(e.dashboardName,t)},downloadDataByQueryIDs(t,r){if(r.length===1)return this.downloadDataByQueryID(t,r[0]);const a=new Set(r),l=e.current.filter(o=>a.has(o.id)).map(({name:o,data:i})=>({id:o,data:i}));Ho(t,l)},downloadDataByQueryID(t,r){const a=e.findByID(r);if(!a){console.log("[downloadDataByQueryID] query not found");return}const{data:l}=a,o=t??a.name;Jo(o,l)},refetchDataByQueryID(t){const r=e.findByID(t);if(!r){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return r.fetchData(!0)},getSchema(t){return{definition:{queries:e.findByIDSet(new Set(t)).map(l=>l.json)},version:He}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t),null,2);Dt("Queries",r)},forceReloadVisibleQueries:h.flow(function*(){const{filterQueries:t,panelQueries:r}=e.querisToForceReload;if(console.log("🟡 Force reloading queries"),t.length>0){const a=yield Promise.allSettled(t.map(l=>l.fetchData(!0)));console.log("🟡 Queries from filters reloaded",a)}else console.log("🟡 Found no query from visible filters, skipping");if(r.length>0){const a=yield Promise.allSettled(r.map(l=>l.fetchData(!0)));console.log("🟡 Queries from filters reloaded",a)}else console.log("🟡 Found no query from visible panels, skipping")})}));function si(e){return{current:e}}function li({min:e,max:t}){const r=`${e}px`,a=Number.isFinite(t)?`${t}px`:"∞";return`[${r}, ${a})`}const ha=h.types.model("LayoutsRenderModel",{list:h.types.array(ko),currentBreakpoint:h.types.string}).views(e=>({get json(){return e.list.map(t=>t.json)},jsonByPanelIDSet(t){return e.list.map(r=>r.jsonByPanelIDSet(t))},get root(){return h.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 li(t)},get cols(){const t={};return e.list.forEach(r=>{t[r.id]=36}),t},get breakpoints(){const t={};return e.list.forEach(r=>{t[r.id]=r.breakpoint}),t},get breakpointNameRecord(){const t={};return e.list.forEach(r=>{t[r.name]=r.breakpoint}),t},get breakpointRanges(){const t=e.list.map(r=>({id:r.id,name:r.name,min:r.breakpoint,max:1/0,text:""}));return t.sort((r,a)=>r.min-a.min).forEach((r,a)=>{a!==t.length-1&&(r.max=t[a+1].min)}),t.forEach(r=>{r.text=li(r)}),t},get breakpointsInfo(){return e.list.map(t=>({id:t.id,name:t.name,breakpoint:t.breakpoint})).sort((t,r)=>t.breakpoint-r.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 r=new Set(t);return this.currentLayoutSet.list.filter(l=>r.has(l.panelID))},gridLayouts(t){const r=new Set(t),a={};return e.list.forEach(l=>{a[l.id]=l.list.filter(o=>r.has(o.panelID)).map(o=>o.layoutProperies)}),a},findItemByPanelID(t){return this.currentLayoutSet.findByPanelID(t)}})).actions(e=>({setCurrentBreakpoint(t){console.log("🔴 onBreakpointChange:",t),e.currentBreakpoint=t},afterCreate(){h.addDisposer(e,j.reaction(()=>e.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),oi=zo.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!h.getParent(e,2).findByKey(t)}})),ga=h.types.model("SQLSnippetsRenderModel",{current:h.types.optional(h.types.array(oi),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,r)=>(t[r.key]=r.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(r=>r.key===t)},findByKeySet(t){return e.current.filter(r=>t.has(r.key))}})).actions(e=>({getSchema(t){return{definition:{sqlSnippets:e.findByKeySet(new Set(t)).map(l=>l.json)},version:He}},downloadSchema(t){const r=JSON.stringify(this.getSchema(t),null,2);Dt("SQL Snippets",r)}}));function ii(e){return{current:e}}function Bt(e,t,r,a){return e.reduce((l,o)=>{try{l[o[t]]=Zn(o[r],a)}catch(i){l[o[t]]=i.message}return l},{})}class ci{constructor(t){P(this,"origin");P(this,"copy");this.origin=t,this.copy=h.clone(t),j.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!b.isEqual(h.getSnapshot(this.origin),h.getSnapshot(this.copy))}commit(){h.applySnapshot(this.origin,h.getSnapshot(this.copy))}reset(){h.applySnapshot(this.copy,h.getSnapshot(this.origin))}update(t){h.applySnapshot(this.copy,t)}}const di=e=>new ci(e),mC=({description:e,isDescriptionEmpty:t})=>t?null:n.jsx(s.Tooltip,{color:"white",label:n.jsx(mt,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:n.jsx(s.Box,{sx:{height:"16px",alignSelf:"center"},children:n.jsx(T.IconInfoCircle,{size:16,color:"gray"})})}),wC=S.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:a,...l},value:o,onChange:i})=>n.jsxs(s.Box,{children:[n.jsx(s.Text,{size:"sm",children:" "}),n.jsx(s.Checkbox,{label:n.jsxs(s.Group,{wrap:"nowrap",justify:"space-between",align:"middle",gap:6,children:[n.jsx(s.Box,{sx:{flexGrow:1},children:e}),n.jsx(mC,{description:r,isDescriptionEmpty:a})]}),checked:o||!1,onChange:c=>i(c.currentTarget.checked),...l,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),CC=({value:e,onChange:t,close:r,max_days:a,allowSingleDateInRange:l})=>{const o=e.value,[i,c]=o,d=g.useMemo(()=>i||new Date,[i]),u=g.useMemo(()=>{if(i&&!c)return i},[i,c]),p=g.useMemo(()=>{if(i&&!c&&a>0)return D(i).add(a-1,"days").toDate()},[i,c,a]),f=v=>{const[x,_]=v;t({value:v,shortcut:null}),x&&_&&r()};return n.jsx(Ra.DatePicker,{defaultDate:d,numberOfColumns:2,type:"range",value:o,onChange:f,onNextMonth:console.log,minDate:u,maxDate:p,allowSingleDateInRange:l})},TC=({begin:e,end:t})=>{const{t:r}=m.useTranslation(),a=g.useMemo(()=>!t&&!e?Number.NaN:D(t).diff(D(e),"days")+1,[e,t]);if(Number.isNaN(a))return n.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const l=a===1?r("filter.widget.date_range.one_day"):r("filter.widget.date_range.x_days",{count:a});return n.jsx(s.Tooltip,{label:l,children:n.jsx(s.Badge,{size:"sm",variant:"light",children:a})})},SC=({max_days:e})=>{const{t}=m.useTranslation();return e?n.jsxs(n.Fragment,{children:[n.jsx(s.Group,{justify:"flex-end",children:n.jsx(s.Badge,{size:"xs",variant:"light",children:t("filter.widget.date_range.x_max_days",{max_days:e})})}),n.jsx(s.Divider,{variant:"dashed",my:10})]}):null},kC=({onChange:e})=>{const{t,i18n:r}=m.useTranslation(),a=i=>()=>{const c=i();e(c)},l=g.useMemo(()=>Mo(),[]),o=r.language==="zh";return n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{variant:"dashed",my:10}),n.jsx(s.Table,{withTableBorder:!1,sx:{"tbody > tr":{border:"none"},"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:n.jsx(s.Table.Tbody,{children:Object.entries(l).map(([i,c])=>n.jsxs(s.Table.Tr,{children:[n.jsx(s.Table.Th,{children:n.jsx(s.Text,{size:"xs",c:"#555",fw:500,sx:{textAlignLast:"justify"},children:t(`filter.widget.date_range.shortcut.${i}.label`)})}),c.map(({key:d,value:u,getRange:p})=>n.jsx(s.Table.Td,{children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",onClick:a(p),children:t(`filter.widget.date_range.shortcut.${i}.${o?"full.":""}${d}`)})},d))]},i))})})]})},ui=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),zC=({label:e,required:t,value:r,onChange:a,max_days:l,allowSingleDateInRange:o,inputFormat:i,disabled:c})=>{const{t:d}=m.useTranslation(),[u,{open:p,close:f}]=te.useDisclosure(!1),[v,x]=r.value,_=v?D(v).format(i):"",w=x?D(x).format(i):"";return n.jsxs(s.Popover,{opened:u,onClose:f,position:"bottom-start",shadow:"md",children:[n.jsxs(s.Group,{justify:"flex-start",grow:!0,wrap:"nowrap",gap:0,w:"288px",sx:{marginTop:"3px"},children:[n.jsx(s.Popover.Target,{children:n.jsx(s.TextInput,{label:e,labelProps:{title:e},required:t,leftSection:n.jsx(T.IconCalendar,{size:16}),placeholder:d("filter.widget.date_range.start_date"),readOnly:!0,disabled:c,value:_,onFocus:p,styles:ui(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},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to left, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})}),n.jsx(s.TextInput,{label:n.jsx(s.Group,{justify:"flex-end",children:n.jsx(TC,{begin:v,end:x})}),leftSection:n.jsx(T.IconMinus,{size:16}),placeholder:d("filter.widget.date_range.end_date"),readOnly:!0,disabled:!v||c,value:w,onFocus:p,styles:ui(u),sx:{".mantine-Input-section":{transform:"translateX(-18px)"},".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}}})]}),n.jsxs(s.Popover.Dropdown,{p:"sm",children:[n.jsx(SC,{max_days:l}),n.jsx(CC,{value:r,onChange:a,close:f,allowSingleDateInRange:o,max_days:l}),n.jsx(kC,{onChange:a})]})]})},pi={value:[null,null],shortcut:null},hi=e=>{const t=Fr(e.shortcut);return t||(Array.isArray(e.value)?e:pi)},DC=e=>g.useMemo(()=>hi(e),[e]),gi=S.observer(({label:e,config:t,value:r=pi,onChange:a,disabled:l})=>{const{inputFormat:o,required:i,max_days:c,allowSingleDateInRange:d}=t,u=DC(r);return n.jsx(zC,{label:e,value:u,onChange:a,inputFormat:o,allowSingleDateInRange:d,max_days:c,required:i,disabled:l})}),IC=nt.createStyles((e,{radius:t=4,name:r,...a})=>({root:{borderRadius:s.getRadius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef",...a,"&.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-select-item-option-state-icon":{lineHeight:"20px"}},".rc-virtual-list-holder-inner":{alignItems:"flex-start"}}})),MC={root:{cursor:"pointer","&:hover":{backgroundColor:"var(--mantine-color-default-hover)"},"input, .mantine-Checkbox-labelWrapper":{cursor:"pointer",pointerEvents:"none"}}},AC=({disabled:e,radius:t,style:r,label:a,value:l,onChange:o,options:i,errorMessage:c,required:d})=>{const{t:u}=m.useTranslation(),{classes:p,cx:f}=IC({radius:t,name:"MultiSelectWidget"}),[v,x]=g.useState(!1),_=N=>{x(N)},w=v&&(l==null?void 0:l.length)>0,[k,z]=g.useState(""),I=g.useMemo(()=>{if(!k)return i;const N=k.toLowerCase(),de=H=>{var ae;return((ae=H.description)==null?void 0:ae.toLowerCase().includes(N))||H.label.toLowerCase().includes(N)};return i.filter(de)},[k,i]),M=g.useMemo(()=>new Set(i.map(N=>N.value)),[i]),O=g.useMemo(()=>new Set(l),[l]),V=g.useMemo(()=>O.size!==M.size?!1:Array.from(M).every(N=>O.has(N)),[O,M]),Y=()=>{if(V){o([]);return}const N=Array.from(M);o(N)};return n.jsxs(s.Stack,{gap:3,children:[n.jsxs(s.Group,{justify:"space-between",children:[n.jsxs(s.Text,{className:p.label,size:"sm",children:[a,d&&n.jsx("span",{className:p.required,"aria-hidden":"true",children:"*"})]}),w&&n.jsx(s.Tooltip,{label:u("filter.widget.common.x_selected",{count:l.length}),children:n.jsx(s.Badge,{variant:"light",children:l.length})})]}),n.jsx(as,{disabled:e,allowClear:!0,className:f(p.root,"check-select"),dropdownClassName:f(p.dropdown,""),onDropdownVisibleChange:_,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:r,clearIcon:()=>n.jsx(s.CloseButton,{size:"sm"}),value:l,onChange:o,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:n.jsx(Xr,{errorMessage:c}),maxTagTextLength:10,maxTagPlaceholder:N=>u("filter.widget.common.x_selected",{count:N.length}),searchValue:k,onSearch:z,filterOption:!1,dropdownRender:N=>n.jsxs(n.Fragment,{children:[M.size>0&&!k&&n.jsx(s.Group,{px:"xs",py:"xs",onClick:Y,styles:MC,children:n.jsx(s.Checkbox,{size:"xs",checked:V,onChange:b.noop,label:u("common.actions.select_all")})}),n.jsx(s.Divider,{}),N]}),children:I.map(N=>n.jsxs(as.Option,{title:N.label,children:[n.jsx(s.Text,{size:"sm","data-role":"label",children:N.label}),N.description&&n.jsx(s.Text,{size:"xs",c:"dimmed","data-role":"description",children:N.description})]},N.value))})]})},PC=S.observer(({label:e,config:t,value:r,onChange:a})=>{const l=ee(),o=!!t.options_query_id,{state:i,error:c}=l.getDataStuffByID(t.options_query_id),d=i==="loading",u=t.min_width?t.min_width:"200px",p=o?d:!1,f=g.useMemo(()=>t.initialSelection(r),[r,t.initialSelection]),v=x=>a(x,!1);return n.jsx(AC,{label:e,options:t.options,style:{minWidth:"160px",width:u,maxWidth:p?u:"unset",borderColor:"#e9ecef"},disabled:p,value:[...f],onChange:v,errorMessage:c,required:t.required})}),VC=({option:e,...t})=>{const{label:r,description:a}=e;return n.jsx("div",{...t,children:n.jsx(s.Group,{wrap:"nowrap",children:n.jsxs("div",{children:[n.jsx(s.Text,{size:"sm","data-role":"label",children:r}),n.jsx(s.Text,{size:"xs",c:"dimmed","data-role":"description",children:a})]})})})},$C=S.observer(({label:e,config:t,value:r,onChange:a})=>{const{t:l}=m.useTranslation(),o=ee(),i=!!t.options_query_id,{state:c,error:d}=o.getDataStuffByID(t.options_query_id),u=c==="loading",p=g.useCallback((f,v)=>{f&&a(f,!1)},[a]);return n.jsx(s.Select,{label:e,data:t.options,disabled:i?u:!1,value:r,onChange:p,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"}},renderOption:VC,searchable:!d,nothingFoundMessage:d||l("filter.widget.common.selector_option_empty"),clearable:t.clearable})});function EC({label:e,config:t,value:r,onChange:a}){return n.jsx(s.TextInput,{label:e,value:r||"",onChange:l=>a(l.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const BC=S.observer(({filter:{type:e,config:t,key:r,...a},formFieldProps:l})=>{switch(e){case $.Select:return n.jsx($C,{...a,...l,config:t});case $.MultiSelect:return n.jsx(PC,{...a,...l,config:t});case $.TreeSelect:return n.jsx(cC,{...a,...l,config:t});case $.TreeSingleSelect:return n.jsx(hC,{...a,...l,config:t});case $.TextInput:return n.jsx(EC,{...a,...l,config:t});case $.DateRange:return n.jsx(gi,{...a,...l,config:t});case $.Checkbox:return n.jsx(wC,{...a,...l,config:t});default:return null}}),LC=S.observer(g.forwardRef(({filter:e,...t},r)=>n.jsx("div",{className:"filter-root",ref:r,children:n.jsx(ne,{children:n.jsx(BC,{filter:e,formFieldProps:t})})}))),qC=({disabled:e,onSubmit:t})=>{const{t:r}=m.useTranslation(),{renderSearchButton:a}=fs();return a?a({disabled:e,onSubmit:t}):n.jsxs(s.Button.Group,{children:[n.jsx(s.Button,{color:"blue",size:"sm",onClick:()=>t(),disabled:e,children:r("common.actions.search")}),n.jsxs(s.Menu,{trigger:"hover",disabled:e,position:"bottom-end",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Button,{disabled:e,color:"blue",px:"xs",style:{borderLeft:`1px solid ${e?"white":"var(--mantine-color-gray-4)"}`},children:n.jsx(T.IconChevronDown,{size:16})})}),n.jsx(s.Menu.Dropdown,{children:n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconRefresh,{size:14}),disabled:e,onClick:()=>t({force:!0}),children:r("common.actions.reload")})})]})]})};function OC(e){const t=Q();g.useEffect(()=>{var r,a;(a=(r=t.filters).updatePreviewValues)==null||a.call(r,e)},[e])}const fi="N/A";function NC(){const e=At(),t=e.content.views.visibleViews;return g.useMemo(()=>t.map(l=>{var o;return l.type===E.Tabs?(o=l.tabView)==null?void 0:o.view_id:l.id}).filter(Boolean).flatMap(l=>e.content.filters.visibleInView(l)).filter(Boolean).map(l=>GC(l)),[t])}function GC(e){switch(e.type){case $.Select:case $.MultiSelect:case $.TreeSelect:case $.TreeSingleSelect:return{label:e.label,value:FC(e.config,e.value)};case $.TextInput:return{label:e.label,value:e.value};case $.DateRange:return{label:e.label,value:jC(e.config,e.value)};case $.Checkbox:return{label:e.label,value:QC(e.value)};default:return{label:e.label,value:e.value}}}function FC(e,t){const r=new Set;return Array.isArray(t)?t.forEach(a=>r.add(a)):r.add(t),r.size===0?fi:e.options.filter(a=>r.has(a.value)).map(a=>a.label).join(", ")}function tz(e){return e}function jC(e,t){const a=hi(t).value.filter(l=>!!l).map(l=>D(l).format(e.inputFormat));return a.length===0?fi:a.join(" - ")}function QC(e){return e?"✔️":"❌"}const WC=({opened:e,toggle:t})=>{const{t:r}=m.useTranslation();return n.jsx(s.Group,{justify:"flex-end",ml:-4,mt:-4,mb:e?4:0,children:n.jsx(s.Button,{size:"compact-xs",variant:"subtle",color:e?"gray":"blue",leftSection:e?n.jsx(T.IconChevronsUp,{size:14}):n.jsx(T.IconChevronsDown,{size:14}),onClick:t,children:r(e?"filter.hide_filters":"filter.show_filters")})})},bi=S.observer(function({view:t}){const[r,{toggle:a}]=te.useDisclosure(!0),l=ee(),{control:o,handleSubmit:i,reset:c}=y.useForm({defaultValues:l.filters.values,reValidateMode:"onBlur"}),d=y.useWatch({control:o});g.useEffect(()=>{c(l.filters.values)},[l.filters.values,c]),OC(d);const u=l.filters.visibleInView(t.id),p=g.useMemo(()=>u.every(w=>w.should_auto_submit),[u]),f=g.useMemo(()=>u.filter(w=>b.get(w,"config.required",!1)),[u]),v=g.useMemo(()=>f.length===0?!1:f.some(w=>!w.requiredAndPass(d[w.key])),[d,f]);if(u.length===0)return null;const x=(w,k)=>(z,I)=>{k(z),(w.should_auto_submit||I)&&l.filters.setValueByKey(w.key,z)},_=g.useCallback(w=>{const k=b.get(w,"force",!1);i(l.filters.setValues),k&&l.queries.forceReloadVisibleQueries()},[i,l.filters.setValues]);return n.jsxs("form",{children:[n.jsx(WC,{opened:r,toggle:a}),n.jsx(s.Collapse,{in:r,children:n.jsxs(s.Group,{className:"dashboard-filters",justify:"space-between",wrap:"nowrap",sx:p?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n.jsx(s.Group,{align:"flex-start",children:u.map(w=>n.jsx(y.Controller,{name:w.key,control:o,render:({field:k})=>n.jsx(LC,{filter:w,value:k.value,onChange:x(w,k.onChange)})},w.id))}),!p&&n.jsx(s.Group,{sx:{alignSelf:"flex-end"},children:n.jsx(qC,{disabled:v,onSubmit:_})})]})})]})}),UC={viewPanelInFullScreen:b.noop,inFullScreen:!1},vn=g.createContext(UC),YC=S.observer(({view:e})=>{const{t}=m.useTranslation(),r=W(),{panel:a}=re(),l=a.realQueryOptions,o=c=>{r.editor.open(["_QUERIES_",c])},i=()=>{r.editor.open(["_VIEWS_",e.id,"_PANELS_",a.id,"_TABS_","Data"])};return l.length===0?null:n.jsxs(n.Fragment,{children:[n.jsx(s.Divider,{label:t(l.length>1?"query.labels":"query.label"),labelPosition:"center"}),n.jsx(s.Menu.Item,{onClick:i,leftSection:n.jsx(T.IconDatabase,{size:14}),children:t("data.label")}),l.map(c=>n.jsx(s.Menu.Item,{onClick:()=>o(c.value),leftSection:n.jsx(T.IconDatabase,{size:14}),children:c.label},c.value))]})}),KC=S.observer(({view:e,title:t})=>{const{t:r}=m.useTranslation(),a=W(),l=Q(),o=Te.useModals(),{panel:i,downloadPanelScreenshot:c}=re(),{id:d}=i,{viewPanelInFullScreen:u,inFullScreen:p}=g.useContext(vn),f=()=>{l.duplicatePanelByID(d,e.id)},v=()=>{a.editor.open(["_VIEWS_",e.id,"_PANELS_",d,"_TABS_","Panel"])},x=()=>{a.editor.open(["_VIEWS_",e.id,"_PANELS_",d,"_TABS_","Variables"])},_=()=>{a.editor.open(["_VIEWS_",e.id,"_PANELS_",d,"_TABS_","Visualization"])},w=()=>{a.editor.open(["_VIEWS_",e.id,"_PANELS_",d,"_TABS_","Interactions"])},k=()=>o.openConfirmModal({title:`${r("panel.delete")}?`,labels:{confirm:r("common.actions.confirm"),cancel:r("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>l.removePanelByID(d,e.id),confirmProps:{color:"red"},zIndex:320}),z=g.useCallback(()=>{u(d)},[d,u]),I=!p&&e.type!==E.Modal;return n.jsx(n.Fragment,{children:n.jsx(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:n.jsxs(s.Menu,{withinPortal:!0,children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Item,{onClick:i.refreshData,leftSection:n.jsx(T.IconRefresh,{size:14}),children:r("common.actions.refresh")}),n.jsx(s.Menu.Item,{onClick:i.downloadData,leftSection:n.jsx(T.IconDownload,{size:14}),children:r("common.actions.download_data")}),n.jsx(s.Menu.Item,{onClick:i.downloadSchema,leftSection:n.jsx(T.IconCode,{size:14}),children:r("common.actions.download_schema")}),n.jsx(s.Menu.Item,{onClick:c,leftSection:n.jsx(T.IconCamera,{size:14}),children:r("common.actions.download_screenshot")}),I&&n.jsx(s.Menu.Item,{onClick:z,leftSection:n.jsx(T.IconArrowsMaximize,{size:14}),disabled:!0,children:r("common.actions.enter_fullscreen")}),n.jsx(YC,{view:e}),n.jsx(s.Divider,{label:r("common.actions.edit"),labelPosition:"center"}),n.jsx(s.Menu.Item,{onClick:v,leftSection:n.jsx(T.IconAppWindow,{size:14}),children:r("panel.label")}),n.jsx(s.Menu.Item,{onClick:x,leftSection:n.jsx(T.IconVariable,{size:14}),children:r("panel.variable.labels")}),n.jsx(s.Menu.Item,{onClick:_,leftSection:n.jsx(T.IconChartHistogram,{size:14}),children:r("visualization.label")}),n.jsx(s.Menu.Item,{onClick:w,leftSection:n.jsx(T.IconRoute,{size:14}),children:r("interactions.label")}),n.jsx(s.Divider,{label:r("common.actions.actions"),labelPosition:"center"}),n.jsx(s.Menu.Item,{onClick:f,leftSection:n.jsx(T.IconCopy,{size:14}),children:r("common.actions.duplicate")}),n.jsx(s.Menu.Item,{color:"red",onClick:k,leftSection:n.jsx(T.IconTrash,{size:14}),children:r("common.actions.delete")})]})]})})})});function XC(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const ZC=S.observer(()=>{const e=ee(),{panel:t}=be(),r=g.useMemo(()=>Zt(t.description,t.json.variables,e.payloadForViz,t.data),[t.data,t.description,t.json.variables,e.payloadForViz]);return n.jsx(mt,{value:r,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}},dashboardState:e.dashboardState,variableAggValueMap:t.variableAggValueMap})}),fa=S.observer(()=>{const{t:e}=m.useTranslation(),[t,r]=g.useState(!1),{panel:a}=be();return XC(a.description)?null:n.jsxs(n.Fragment,{children:[n.jsx(s.Modal,{opened:t,onClose:()=>r(!1),title:a.title.show?a.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:n.jsx(ZC,{})}),n.jsx(s.Tooltip,{label:e("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:n.jsx(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(l=>!l),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n.jsx(T.IconInfoCircle,{size:20})})})]})}),nz="",JC=S.observer(function(){const{panel:t}=be(),{name:r,title:a}=t;return a.show?n.jsx(s.Group,{grow:!0,justify:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:n.jsx(s.Text,{size:"sm",ta:"center",lineClamp:1,className:"panel-title-text",children:r})}):null});function HC(e){const t=g.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const a=t.current;if(!a)return;const l=a.offsetWidth*2,o=a.offsetHeight*2;ns.toBlob(t.current,{bgcolor:"white",width:l,height:o,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(i=>{window.saveAs(i,`${e.name?e.name:e.viz.type}.png`)})}}}var yi=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(yi||{}),_n=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(_n||{});class RC{constructor(t){P(this,"vizInstance");P(this,"operationManager");P(this,"triggerManager");P(this,"vizManager");P(this,"runningMigration");P(this,"panelModel");P(this,"status","notStarted");this.panelModel=t.getRequired(J.instanceScope.panelModel),this.vizInstance=t.getRequired(J.instanceScope.vizInstance),this.operationManager=t.getRequired(J.instanceScope.operationManager),this.triggerManager=t.getRequired(J.instanceScope.triggerManager),this.vizManager=t.getRequired(J.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(r){return console.warn("check migration failed",r),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(r=>r())),"migrated"}catch(r){return console.warn("migration failed",r),"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),r={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(r)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),r={configData:this.vizInstance.instanceData};return t.migrator.needMigration(r)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}class eT{getTriggerSchemaList(){return[]}getTriggerList(){return Promise.resolve([])}removeTrigger(){return Promise.resolve()}createOrGetTrigger(){return Promise.resolve(vi)}retrieveTrigger(){return Promise.resolve(vi)}watchTriggerSnapshotList(){return()=>{}}needMigration(){return Promise.resolve(!1)}runMigration(){return Promise.resolve()}}class tT{constructor(){P(this,"id","");P(this,"schemaRef","");P(this,"triggerData",new Gt({}))}}const vi=new tT;class nT{getOperationSchemaList(){return[]}getOperationList(){return Promise.resolve([])}removeOperation(){return Promise.resolve()}createOrGetOperation(){return Promise.resolve(_i)}runOperation(){return Promise.resolve()}retrieveTrigger(){return Promise.resolve(_i)}runMigration(){return Promise.resolve()}needMigration(){return Promise.resolve(!1)}}class rT{constructor(){P(this,"id","");P(this,"schemaRef","");P(this,"operationData",new Gt({}))}}const _i=new rT,kn=class kn{constructor(){P(this,"triggerManager",new eT);P(this,"operationManager",new nT)}getInteractionList(){return Promise.resolve([])}addInteraction(){return Promise.resolve()}removeInteraction(){return Promise.resolve()}runInteraction(){return Promise.resolve()}};P(kn,"instance",new kn);let ba=kn;function xi(e,t=!0){const{panel:r}=be();return g.useCallback(a=>{const l=a.getRequired(J.vizManager),o=l.resolveComponent(e.viz.type);return a.createScoped().provideFactory(J.instanceScope.vizInstance,()=>l.getOrCreateInstance(e)).provideFactory(J.instanceScope.interactionManager,i=>{const c=i.getRequired(J.instanceScope.vizInstance);return t?new rl(c,o,nr):new ba}).provideFactory(J.instanceScope.operationManager,i=>i.getRequired(J.instanceScope.interactionManager).operationManager).provideFactory(J.instanceScope.triggerManager,i=>i.getRequired(J.instanceScope.interactionManager).triggerManager).provideValue(J.instanceScope.panelModel,r).provideFactory(J.instanceScope.migrator,i=>new RC(i))},[e.viz.type,e.viz.conf,t])}const mi={withInteraction:!0,withAddon:!0,withPanelTitle:!0},wi=g.createContext(mi);function aT({children:e,...t}){const r=b.defaults({},t,mi);return n.jsx(wi.Provider,{value:r,children:e})}function ya(){return g.useContext(wi)}function Ci(e){const[t,r]=g.useState(!1),a=Rt().getRequired(J.instanceScope.migrator);return q.useAsyncEffect(async()=>{const l=a.status===_n.notStarted;r(a.status===_n.done),a.status===_n.notStarted&&a.runMigration().then(o=>{o===yi.migrated&&l&&(e==null||e())}).finally(()=>{r(!0)})},[a]),t}function Ti(e,t){const r=Rt().getRequired(J.instanceScope.vizInstance);return q.useAsyncEffect(async()=>{b.isEqual(await r.instanceData.getItem(null),t.viz.conf)||await r.instanceData.setItem(null,t.viz.conf)},[r,t.viz.conf]),g.useEffect(()=>r.instanceData.watchItem(null,a=>{e(a)}),[e,t.viz.type]),r}function sT({setVizConf:e,...t}){const{panel:r}=t,a=Ti(e,r),l=Ci(()=>{Qe.showNotification({title:`${r.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return q.useAsyncEffect(async()=>{await a.instanceData.setItem(null,r.viz.conf)},[a,r.viz.type]),l?n.jsx(Md,{...t}):n.jsx(s.Text,{size:"sm",children:"Checking update..."})}function lT(e){const{panel:t,setVizConf:r}=e;Ti(r,t);const{inEditMode:a}=g.useContext(Pt);return Ci(()=>{a&&Qe.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?n.jsx(Id,{...e}):n.jsx(s.Text,{size:"sm",children:"Checking update"})}const rz="";function oT(e,t){const{vizManager:r}=g.useContext(Je),{panel:{viz:a,title:l,id:o,name:i,description:c,queryIDs:d,variables:u}}=be(),p={id:o,name:i,title:l,description:c,queryIDs:d,viz:a},{withInteraction:f}=ya(),v=xi(p,f);try{return r.resolveComponent(a.type),n.jsxs(Ht,{configure:v,children:[n.jsx(lT,{setVizConf:a.setConf,panel:p,measure:t,data:e,variables:u,vizManager:r}),n.jsx(ki,{})]})}catch(x){return console.info(b.get(x,"message")),null}}const Si=S.observer(function({data:t}){const{ref:r,width:a,height:l}=te.useElementSize(),o=oT(t,{w:a,h:l}),i=a>0&&l>0;return n.jsx("div",{className:"viz-root",ref:r,children:n.jsx(s.Box,{sx:{width:a,height:l,overflow:"hidden"},children:i&&n.jsx(ne,{children:o})})})}),ki=()=>{const e=Rt(),t=e.getRequired(J.instanceScope.vizInstance),{inEditMode:r}=g.useContext(Pt),a=e.getRequired(J.panelAddonManager),{withAddon:l}=ya(),o=Od();return!o||!l?null:md.createPortal(n.jsx(n.Fragment,{children:a.createPanelAddonNode({viz:t,isInEditMode:r})}),o,"addon")},zi=S.observer(({panel:e})=>n.jsxs(s.Stack,{children:[e.queryErrors.map((t,r)=>n.jsx(s.Text,{c:"red",size:"sm",ta:"center",ff:"monospace",children:t},`${r}-${t}`)),n.jsx(s.Text,{c:"gray",ta:"center",size:"sm",children:e.queryStateMessages})]})),va=S.observer(({panel:e})=>n.jsxs(s.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[n.jsx(s.LoadingOverlay,{visible:e.dataLoading,transitionProps:{exitDuration:0}}),!e.canRenderViz&&n.jsx(zi,{panel:e}),e.canRenderViz&&n.jsx(Si,{data:e.data})]})),iT={border:"1px solid #e9ecef"},_a=S.observer(({panel:e,panelStyle:t,dropdownContent:r})=>{const{ref:a,downloadPanelScreenshot:l}=HC(e),{withAddon:o,withPanelTitle:i}=ya(),c=o?cs:g.Fragment;return n.jsx(Ln,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:l},children:n.jsx(s.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,ref:a,p:0,sx:{...iT,...t},children:n.jsxs(c,{children:[i&&n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{className:"panel-description-popover-wrapper",children:n.jsx(fa,{})}),r,n.jsx(JC,{})]}),n.jsx(va,{panel:e})]})})})}),cT={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function dT(e){return e.style.border.enabled?{}:cT}const Di=S.observer(function({panel:t,view:r}){const a=dT(t);return n.jsx(_a,{panel:t,panelStyle:a,dropdownContent:n.jsx(KC,{view:r,title:t.name})})});function uT(e){return!["richText","button"].includes(e)}const pT=S.observer(({view:e,title:t})=>{const{t:r}=m.useTranslation(),{panel:a,downloadPanelScreenshot:l}=be(),{id:o}=a,{viewPanelInFullScreen:i,inFullScreen:c}=g.useContext(vn),d=g.useCallback(()=>{i(o)},[o,i]),u=!c&&e.type!==E.Modal;return uT(a.viz.type)?n.jsx(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:n.jsxs(s.Menu,{withinPortal:!0,children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Box,{className:"panel-dropdown-target"})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Item,{onClick:a.refreshData,leftSection:n.jsx(T.IconRefresh,{size:14}),children:r("common.actions.refresh")}),n.jsx(s.Menu.Item,{onClick:a.downloadData,leftSection:n.jsx(T.IconDownload,{size:14}),children:r("common.actions.download_data")}),n.jsx(s.Menu.Item,{onClick:l,leftSection:n.jsx(T.IconCamera,{size:14}),children:r("common.actions.download_screenshot")}),u&&n.jsx(s.Menu.Item,{onClick:d,leftSection:n.jsx(T.IconArrowsMaximize,{size:14}),children:r("common.actions.enter_fullscreen")})]})]})}):null});function hT(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const xa=S.observer(({panel:e,view:t})=>{const r=hT(e);return n.jsx(_a,{panel:e,panelStyle:r,dropdownContent:n.jsx(pT,{title:e.name,view:t})})}),gT={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},Ii=S.observer(function({view:t,panel:r,exitFullScreen:a}){return n.jsx(s.Modal,{opened:!0,fullScreen:!0,onClose:a,title:n.jsx(s.Button,{color:"blue",size:"xs",onClick:a,leftSection:n.jsx(T.IconArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:gT,children:n.jsx(s.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:n.jsx(xa,{view:t,panel:r})})})});function Mi(e,t,r){const{panels:a}=ee(),l=e.id==="Main",[o,i]=g.useState(()=>l&&a.findByID(t)?t:null),c=g.useCallback(f=>{i(f),l&&r(f)},[l,r]),d=g.useCallback(()=>{i(null),l&&r("")},[l,r]),u=o?a.findByID(o):null;return{viewPanelInFullScreen:c,exitFullScreen:d,inFullScreen:!!u,fullScreenPanel:u}}function fT(e){const t=At(),r=g.useMemo(()=>t.content.panels.findByID(e.panelId),[e.panelId]);return r?n.jsx(aT,{withAddon:!1,withPanelTitle:!1,withInteraction:!1,children:n.jsx(_a,{panel:r,panelStyle:{}})}):null}const az="",bT=g.forwardRef(({h:e},t)=>n.jsx(s.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:n.jsx(T.IconArrowsMove,{size:16})})),yT=g.forwardRef(({handleAxis:e,...t},r)=>n.jsx(s.ActionIcon,{ref:r,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:n.jsx(T.IconChevronDownRight,{size:16})})),vT=Nt.WidthProvider(Nt.Responsive),_T=S.observer(({view:e,className:t="layout"})=>{const a=Q().layouts,l=a.items(e.panelIDs),o=a.gridLayouts(e.panelIDs),i=(u,p,f,v)=>{f.h<30&&(f.h=30,v.h=30),f.w<4&&(f.w=4,v.w=4)},c=(u,p,f)=>{console.log("🔴 onResizeStop",{layouts:u,oldItem:p,newItem:f}),a.updateCurrentLayoutItem(f)},d=(u,p,f)=>{console.log("🔴 onDragStop",{layouts:u,oldItem:p,newItem:f}),a.updateCurrentLayoutItems(u)};return n.jsx(vT,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:a.cols,layouts:o,draggableHandle:".react-grid-customDragHandle",resizeHandle:n.jsx(yT,{}),onResize:i,breakpoints:a.breakpoints,onBreakpointChange:a.setCurrentBreakpoint,onResizeStop:c,onDragStop:d,width:a.currentLayoutPreviewWidth,children:l.map(u=>n.jsxs("div",{"data-grid":u.layoutProperies,className:"panel-grid-item",children:[n.jsx(bT,{h:u.h}),n.jsx(Di,{view:e,panel:u.panel})]},u.id))})}),xT=Nt.WidthProvider(Nt.Responsive),mT=S.observer(({view:e,className:t="layout"})=>{const r=ee(),a=r.layouts.items(e.panelIDs),l=r.layouts.gridLayouts(e.panelIDs);return n.jsx(xT,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:r.layouts.cols,layouts:l,breakpoints:r.layouts.breakpoints,onBreakpointChange:r.layouts.setCurrentBreakpoint,children:a.map(o=>n.jsx("div",{"data-grid":o.layoutProperies,className:"panel-grid-item",children:n.jsx(xa,{view:e,panel:o.panel})},o.id))})});function ma(e){const t=g.useRef(null);return{ref:t,downloadScreenshot:()=>{var l;const a=(l=t.current)==null?void 0:l.querySelector(".react-grid-layout");a&&e.downloadScreenshot(a)}}}const wT=S.observer(({downloadScreenshot:e})=>{const{t}=m.useTranslation(),[r,{setTrue:a,setFalse:l}]=q.useBoolean(!1),o=hs(),i=ee(),c=()=>{const d=JSON.stringify(i.contentJSON,null,2),u=`${o.name}__${i.name}`;Dt(u,d)};return n.jsxs(s.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[n.jsx(s.Menu.Target,{children:n.jsx(s.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:n.jsx(s.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:a,onMouseLeave:l,sx:{opacity:r?1:.6,transform:`translateX(${r?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:n.jsx(T.IconShare3,{size:"1rem"})})})}),n.jsxs(s.Menu.Dropdown,{children:[n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconCamera,{size:14}),onClick:e,children:t("common.actions.download_screenshot")}),n.jsx(s.Menu.Divider,{}),n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconDownload,{size:14}),onClick:i.queries.downloadAllData,children:t("common.actions.download_data")}),n.jsx(s.Menu.Item,{leftSection:n.jsx(T.IconCode,{size:14}),onClick:c,children:t("common.actions.download_schema")})]})]})}),Ai=S.observer(({children:e,view:t,sx:r={}})=>{const{ref:a,downloadScreenshot:l}=ma(t);return n.jsxs(n.Fragment,{children:[n.jsx(s.Box,{ref:a,pt:10,pb:10,sx:r,children:e}),n.jsx(wT,{downloadScreenshot:l})]})}),Pi=S.observer(({downloadScreenshot:e})=>n.jsx(s.ActionIcon,{className:"download-screenshot-button",color:"blue",variant:"subtle",onClick:e,children:n.jsx(T.IconCamera,{size:14})})),CT=S.observer(({children:e,view:t})=>{const r=ee(),a=t.config,l=r.views.visibleViewIDs.includes(t.id),o=()=>r.views.rmVisibleViewID(t.id),{ref:i,downloadScreenshot:c}=ma(t);return n.jsx(s.Modal,{size:a.width,centered:!0,opened:l,onClose:o,withCloseButton:!1,title:n.jsxs(s.Group,{justify:"space-between",px:"1rem",h:"48px",children:[n.jsx(s.Box,{children:a.custom_modal_title.value}),n.jsx(Pi,{downloadScreenshot:c})]}),trapFocus:!0,onDragStart:d=>{d.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:a.height,overflow:"auto",position:"relative",paddingBottom:10},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:n.jsx(s.Box,{ref:i,children:e})})}),TT=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},ST=S.observer(({view:e})=>{const t=ee(),r=e.config;return n.jsxs(s.Tabs,{className:"render-view-tabs",variant:r.variant,orientation:r.orientation,value:e.tab,onChange:e.setTab,styles:{root:{height:"100%",overflow:r.orientation==="horizontal"?"hidden":"auto"},panel:{padding:r.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[n.jsx(s.Tabs.List,{grow:r.grow,children:r.tabsInOrder.map(a=>n.jsx(s.Tabs.Tab,{value:a.id,sx:TT(a),disabled:!a.view_id,children:a.name??a.id},a.id))}),r.tabsInOrder.map(a=>{const l=t.views.findByID(a.view_id);return l?n.jsx(s.Tabs.Panel,{value:a.id,children:n.jsx(xn,{view:l})},a.id):null})]})}),kT=S.observer(({view:e,children:t})=>{switch(e.type){case E.Modal:return n.jsx(CT,{view:e,children:t});case E.Tabs:return n.jsx(ST,{view:e});case E.Division:default:return n.jsx(Ai,{view:e,children:t})}}),zT=S.observer(({children:e,view:t})=>{const a=Q().layouts,[l,o]=te.useResizeObserver();return g.useEffect(()=>{a.setCurrentLayoutWrapperWidth(o.width)},[o.width]),n.jsx(s.Box,{sx:{height:"100%"},ref:l,children:n.jsx(s.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:a.currentLayoutPreviewWidth??"100%",transform:`scale(${a.divisionPreviewScale})`,transformOrigin:"0 0"},children:n.jsx(Ai,{view:t,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:e})})})});function Vi(e){return e.replace(/(vw|vh)/,"%")}const DT=S.observer(({children:e,view:t})=>{const r=t.config,{width:a,height:l}=g.useMemo(()=>({width:Vi(r.width),height:Vi(r.height)}),[r.width,r.height]),{ref:o,downloadScreenshot:i}=ma(t);return n.jsx(s.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:n.jsx(s.Modal,{size:r.width,opened:!0,onClose:b.noop,withCloseButton:!1,title:n.jsxs(s.Group,{justify:"space-between",px:"1rem",h:"48px",children:[n.jsx(s.Box,{children:r.custom_modal_title.value}),n.jsx(Pi,{downloadScreenshot:i})]}),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:a,height:l,maxHeight:l},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:n.jsx(s.Box,{ref:o,children:e})})})}),IT=({variant:e,orientation:t})=>{const r={root:{height:"100%",overflow:"hidden"},list:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(r.tab.paddingTop="6px",r.tab.paddingBottom="6px"),t==="vertical"&&(r.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},r.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),r},MT=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},AT=S.observer(({view:e})=>{const{t}=m.useTranslation(),r=Te.useModals(),a=Q(),l=g.useMemo(()=>a.views.options.filter(u=>u.type===E.Division),[e.id,a.views.options]),o=e.config,i=u=>r.openConfirmModal({title:`${t("view.component.tabs.tab.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),c=o.tabs.length===0,d=o.tabsInOrder.length===0?void 0:o.tabsInOrder[0].id;return n.jsxs(s.Tabs,{className:"preview-view-tabs",variant:o.variant,orientation:o.orientation,value:e.tab||d,onChange:e.setTab,styles:IT(o),children:[n.jsxs(s.Tabs.List,{grow:o.grow,children:[o.tabsInOrder.map(u=>n.jsx(s.Tabs.Tab,{value:u.id,sx:MT(u),children:u.name??u.id},u.id)),n.jsx(s.Tabs.Tab,{onClick:o.addTab,value:"add",className:"add-a-tab",children:n.jsx(T.IconPlus,{size:18,color:"#228be6"})})]}),o.tabsInOrder.map((u,p)=>{const f=a.views.findByID(u.view_id);return n.jsxs(s.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[n.jsxs(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[n.jsx(s.Overlay,{backgroundOpacity:.8,color:"#FFF",blur:10,zIndex:100}),n.jsxs(s.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[n.jsx(s.TextInput,{label:t("view.component.tabs.tab.name"),required:!0,value:u.name,onChange:v=>u.setName(v.currentTarget.value)}),n.jsx(s.Select,{label:t("view.label"),value:u.view_id,onChange:u.setViewID,data:l}),n.jsx(s.NumberInput,{label:t("view.component.tabs.tab.order"),required:!0,value:u.order,onChange:v=>u.setOrder(v||0),min:0,max:1e3,step:1}),n.jsx(s.ColorInput,{label:t("view.component.tabs.tab.color"),value:u.color,onChange:u.setColor,disabled:o.variant!=="default"}),f&&n.jsx(s.Button,{mt:20,variant:"gradient",leftSection:n.jsx(T.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>a.views.setIDOfVIE(f.id),children:t("view.component.tabs.tab.switch_to_view",{name:f.name})}),n.jsx(s.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>i(p),disabled:c,leftSection:n.jsx(T.IconTrash,{size:14}),children:t("view.component.tabs.tab.delete")})]})]}),f&&n.jsx(xn,{view:f})]},u.id)})]})}),PT=S.observer(({view:e,children:t})=>{switch(e.type){case E.Modal:return n.jsx(DT,{view:e,children:t});case E.Tabs:return n.jsx(AT,{view:e});case E.Division:default:return n.jsx(zT,{view:e,children:t})}}),$i=S.observer(function({view:t}){const a=Q().layouts.divisionPreviewScale!==1;return n.jsx(vn.Provider,{value:{viewPanelInFullScreen:b.noop,inFullScreen:!1},children:n.jsx(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:a?"transparent":"#efefef"},children:n.jsx(PT,{view:t,children:n.jsxs(s.Box,{sx:{position:"relative"},children:[n.jsx(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n.jsx(bi,{view:t})}),n.jsx(_T,{view:t})]})})})})}),xn=S.observer(function({view:t}){const{fullScreenPanelID:r,setFullScreenPanelID:a}=ws(),{viewPanelInFullScreen:l,exitFullScreen:o,inFullScreen:i,fullScreenPanel:c}=Mi(t,r,a);return n.jsx(vn.Provider,{value:{viewPanelInFullScreen:l,inFullScreen:i},children:n.jsxs(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===E.Modal?"0 !important":"100%"},children:[i&&n.jsx(Ii,{view:t,panel:c,exitFullScreen:o}),n.jsx(kT,{view:t,children:n.jsxs(s.Box,{sx:{position:"relative"},children:[!i&&n.jsx(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n.jsx(bi,{view:t})}),!i&&n.jsx(mT,{view:t})]})})]})})});var Ei=(e=>(e.Use="use",e.Edit="edit",e))(Ei||{});const VT={[E.Division]:"Division",[E.Tabs]:"Tabs",[E.Modal]:"Modal"},Bi={[E.Division]:"rgba(255, 0, 0, 0.2)",[E.Modal]:"rgba(0, 0, 0, 0.2)",[E.Tabs]:"rgba(255, 200, 100, 0.4)"},$T={[E.Division]:"#ff4000",[E.Modal]:"#000",[E.Tabs]:"#ffad18"};function ET(e,t,r){h.addDisposer(e,h.addMiddleware(e,(a,l)=>{l(a,()=>{h.getType(a.context)===t&&a.type==="action"&&r(a.name,a.context)})}))}const Li=h.types.compose("FiltersModel",ca,h.types.model("FiltersModel",{previewValues:h.types.optional(h.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===$.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,widget:t.type}))},get sortedList(){return b.sortBy(e.current,t=>t.label.toLowerCase())}})).actions(e=>({replace(t){e.current=h.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(a=>!e.idSet.has(a.id));e.current.push(...r)},remove(t){e.current.splice(t,1)},removeByID(t){const r=e.current.findIndex(a=>a.id===t);r>=0&&e.current.splice(r,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){ET(e.current,Hr,(r,a)=>{if(r==="setType"){const l=ti(a.config.default_value,a.config);e.setValueByKey(a.key,l),e.updatePreviewValues({...e.previewValues,[a.key]:l})}})}return{afterCreate(){t()}}}),qi=ua.views(e=>({get canPreviewData(){return e.isTransform?e.config.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"},get usage(){return e.contentModel.findQueryUsage(e.id)},get runBySet(){return new Set(e.run_by)},keyInRunBy(t){return this.runBySet.has(t)}})).actions(e=>({changeRunByRecord(t,r){const a=new Set(e.run_by);r?a.add(t):a.delete(t),e.run_by.length=0,e.run_by.push(...a)}})),Oi=h.types.compose("QueriesModel",pa,h.types.model({current:h.types.optional(h.types.array(qi),[])})).views(e=>({get options(){const t=e.current.map(r=>({value:r.id,label:r.name,_type:"query"}));return b.sortBy(t,r=>r.label.toLowerCase())},get optionsWithoutTransform(){const t=e.current.filter(r=>r.type!==F.Transform).map(r=>({value:r.id,label:r.name,_type:"query"}));return b.sortBy(t,r=>r.label.toLowerCase())},get sortedList(){return b.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=h.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(a=>!e.idSet.has(a.id));e.current.push(...r)},remove(t){e.current.splice(t,1)},replaceByIndex(t,r){e.current.splice(t,1,r)},removeQuery(t){const r=e.current.find(a=>a.id===t);r&&(h.detach(r),e.current.remove(r))},removeQueries(t){const r=new Set(t);e.current.forEach(l=>{r.has(l.id)&&h.detach(l)});const a=[...e.current];b.remove(a,l=>r.has(l.id)),e.current=h.cast(a)}})),Ni=ga.views(e=>({get sortedList(){return b.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(r=>({label:r.key,value:r.key,_type:"sql_snippet"}));return b.sortBy(t,r=>r.label.toLowerCase())}})).actions(e=>({replace(t){e.current=h.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const r=t.filter(a=>!e.keySet.has(a.key));e.current.push(...r)},remove(t){e.current.splice(t,1)},removeByKey(t){const r=e.current.findIndex(a=>a.key===t);r>=0&&e.current.splice(r,1)},removeByKeys(t){const r=new Set(t);e.current.forEach(l=>{r.has(l.key)&&h.detach(l)});const a=[...e.current];b.remove(a,l=>r.has(l.key)),e.current=h.cast(a)},replaceByIndex(t,r){e.current.splice(t,1,r)}})),BT=h.types.model({data:h.types.optional(h.types.frozen(),[]),state:h.types.optional(h.types.enumeration(["idle","loading","error"]),"idle"),error:h.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),LT=h.types.model({data:h.types.optional(h.types.frozen(),[]),state:h.types.optional(h.types.enumeration(["idle","loading","error"]),"idle"),error:h.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),qT=h.types.model({page:h.types.optional(h.types.number,1),limit:h.types.optional(h.types.number,20),data:h.types.optional(h.types.frozen(),[]),total:h.types.optional(h.types.number,0),state:h.types.optional(h.types.enumeration(["idle","loading","error"]),"idle"),error:h.types.frozen()}).views(e=>({get keywords(){return h.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:r}=h.getParent(e,1);return`${r}||${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:r}=e.keywords;return`
469
469
  SELECT count(*) AS total
470
470
  FROM ${r}.${t}
471
471
  `}})).actions(e=>({setPage(t){e.page=t},resetPage(){e.page=1},setLimit(t){e.limit=t}})).actions(e=>({afterCreate(){h.addDisposer(e,j.reaction(()=>e.keywordString,e.resetPage,{fireImmediately:!1,delay:0})),h.addDisposer(e,j.reaction(()=>e.limit,e.resetPage,{fireImmediately:!1,delay:0}))}})),OT=h.types.model({data:h.types.optional(h.types.frozen(),{}),state:h.types.optional(h.types.enumeration(["idle","loading","error"]),"idle"),error:h.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return Object.keys(e.data).length===0}})),NT=h.types.model({tables:h.types.optional(OT,{}),columns:h.types.optional(BT,{}),tableData:h.types.optional(qT,{}),indexes:h.types.optional(LT,{}),table_schema:h.types.optional(h.types.string,""),table_name:h.types.optional(h.types.string,"")}).views(e=>({get dataSource(){return h.getParent(e)},get key(){return this.dataSource.key},get type(){return this.dataSource.type},get sqlDataSourceType(){return this.type},get reloadConditionString(){const t=this.type,{table_name:r,table_schema:a}=e;return`${t};${r};${a}`}})).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(e=>({setKeywords(t,r){e.table_schema=t,e.table_name=r}})).actions(e=>({initKeywords(){if(e.tables.empty)return;const t=Object.keys(e.tables.data)[0],r=e.tables.data[t][0].table_name;e.setKeywords(t,r)}})).actions(e=>{const t=h.flow(function*(){var r;(r=e.controllers.tables)==null||r.abort(),e.controllers.tables=new AbortController,e.tables.state="loading";try{const a=yield*h.toGenerator(De.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=b.groupBy(a,"table_schema"),e.tables.state="idle",e.tables.error=null,e.initKeywords()}catch(a){if(!Ce.isCancel(a)){e.tables.data={};const l=b.get(a,"message","unkown error");e.tables.error=b.get(a,"response.data.detail.message",l),e.tables.state="error"}}});return{loadTables:t,loadTablesIfEmpty(){e.tables.empty&&t()},loadColumns:h.flow(function*(){var r;(r=e.controllers.columns)==null||r.abort(),e.controllers.columns=new AbortController,e.columns.state="loading";try{e.columns.data=yield*h.toGenerator(De.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(a){if(Ce.isCancel(a))e.columns.state="idle",e.columns.error=null;else{e.columns.data=[];const l=b.get(a,"message","unkown error");e.columns.error=b.get(a,"response.data.detail.message",l),e.columns.state="error"}}}),loadIndexes:h.flow(function*(){var r;(r=e.controllers.indexes)==null||r.abort(),e.controllers.indexes=new AbortController,e.indexes.state="loading";try{e.indexes.data=yield*h.toGenerator(De.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(a){if(Ce.isCancel(a))e.indexes.state="idle",e.indexes.error=null;else{e.indexes.data=[];const l=b.get(a,"message","unkown error");e.indexes.error=b.get(a,"response.data.detail.message",l),e.indexes.state="error"}}}),loadTableData:h.flow(function*(){var a;(a=e.controllers.tableData)==null||a.abort(),e.controllers.tableData=new AbortController;const r=e.tableData;r.state="loading";try{r.data=yield*h.toGenerator(De.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:r.limit,offset:r.offset},{params:{query_type:"DATA"}}));const[{total:l}]=yield*h.toGenerator(De.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"}}));r.total=Number(l),r.state="idle",r.error=null}catch(l){if(Ce.isCancel(l))r.state="idle",r.error=null;else{r.data=[];const o=b.get(l,"message","unkown error");r.error=b.get(l,"response.data.detail.message",o),r.state="error"}}})}}).actions(e=>({afterCreate(){h.addDisposer(e,j.reaction(()=>e.reloadConditionString,e.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(e=>({afterCreate(){h.addDisposer(e,j.reaction(()=>e.reloadConditionString,e.loadIndexes,{fireImmediately:!1,delay:500})),h.addDisposer(e,j.reaction(()=>`${e.reloadConditionString};limit:${e.tableData.limit};offset:${e.tableData.offset}`,e.loadTableData,{fireImmediately:!1,delay:0}))}})),Gi=new Set(["yoy_ratio","step_ratio","span_steps_calculation"]),Fi={accumulate:"累计计算",yoy_ratio:"年同比率(yoy)",step_ratio:"环比率",span_steps_calculation:"移动计算",percentage_total:"总占"};function GT(e){var a;if("cols"in e){const{cols:l}=e,o=((a=l.find(c=>c.type==="trending_date_col"))==null?void 0:a.metricSourceCol)??null,i=Gi.has(e.calculation)?`当前指标涉及 ${b.get(Fi,e.calculation,e.calculation)},缺少时序则无法展示有效结果。