@databrainhq/plugin 0.14.67 → 0.14.68

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.
@@ -28072,7 +28072,7 @@ function s1(e, M, t) {
28072
28072
  var i = Ww(e, M, t);
28073
28073
  return Pze(i, pze);
28074
28074
  }
28075
- const Ub = "https://api-uat.usedatabrain.com", Xj = "/api/v2/dashboard", k0 = "/api/v2/metric", Ate = "/api/v3/metric", Ote = "dashboardData", Fze = `${Xj}/embeddedMetric`, Gze = "embeddedMetric", Bze = `${k0}/layout`, xte = "dashboardLayout", Vze = `${Xj}/scheduledReport`, Wze = "dashboardScheduledReport", Hze = `${k0}/saveLayout`, $ze = "saveLayout", Zze = `${Xj}/saveScheduleReport`, Jze = "saveScheduleReport", Xze = `${Xj}/deleteScheduleReport`, Kze = "deleteScheduleReport", qze = `${Xj}/createMetric`, e1e = "createMetric", t1e = `${Xj}/updateMetric`, M1e = "updateMetric", i1e = `${Xj}/updateAdminMetric`, u1e = "updateAdminMetric", N1e = `${Xj}/generateMetric`, n1e = "generateMetric", r1e = `${Xj}/datasetMetricCreation`, a1e = "datasetMetricCreation", j1e = `${Xj}/previewTable`, D1e = "previewTable", o1e = `${Xj}/generatetMetricData`, s1e = "/generatetMetricData", L1e = `${Xj}/getOpenaiChatResponse`, g1e = "getOpenaiChatResponse", c1e = `${Xj}/getTheme`, T1e = "getTheme", l1e = `${Ate}/query`, y1e = "query", I1e = `${Ate}/datasetMetricCreation`, z1e = "newDatasetMetricCreation", A1e = `${k0}/rawDownloadSettings`, O1e = "rawDownloadSettings", x1e = `${k0}/column`, S1e = "column", E1e = `${k0}/underlyingData`, d1e = "underlyingData", f1e = `${k0}/invokeShareCsv`, C1e = "invokeShareCsv", w1e = `${k0}/markArchived`, h1e = "markArchived", EV = `${k0}/download-csv`, Q1e = () => localStorage.getItem(Xle), An = async (e, M = { method: "GET" }) => {
28075
+ const Ub = "https://api.usedatabrain.com", Xj = "/api/v2/dashboard", k0 = "/api/v2/metric", Ate = "/api/v3/metric", Ote = "dashboardData", Fze = `${Xj}/embeddedMetric`, Gze = "embeddedMetric", Bze = `${k0}/layout`, xte = "dashboardLayout", Vze = `${Xj}/scheduledReport`, Wze = "dashboardScheduledReport", Hze = `${k0}/saveLayout`, $ze = "saveLayout", Zze = `${Xj}/saveScheduleReport`, Jze = "saveScheduleReport", Xze = `${Xj}/deleteScheduleReport`, Kze = "deleteScheduleReport", qze = `${Xj}/createMetric`, e1e = "createMetric", t1e = `${Xj}/updateMetric`, M1e = "updateMetric", i1e = `${Xj}/updateAdminMetric`, u1e = "updateAdminMetric", N1e = `${Xj}/generateMetric`, n1e = "generateMetric", r1e = `${Xj}/datasetMetricCreation`, a1e = "datasetMetricCreation", j1e = `${Xj}/previewTable`, D1e = "previewTable", o1e = `${Xj}/generatetMetricData`, s1e = "/generatetMetricData", L1e = `${Xj}/getOpenaiChatResponse`, g1e = "getOpenaiChatResponse", c1e = `${Xj}/getTheme`, T1e = "getTheme", l1e = `${Ate}/query`, y1e = "query", I1e = `${Ate}/datasetMetricCreation`, z1e = "newDatasetMetricCreation", A1e = `${k0}/rawDownloadSettings`, O1e = "rawDownloadSettings", x1e = `${k0}/column`, S1e = "column", E1e = `${k0}/underlyingData`, d1e = "underlyingData", f1e = `${k0}/invokeShareCsv`, C1e = "invokeShareCsv", w1e = `${k0}/markArchived`, h1e = "markArchived", EV = `${k0}/download-csv`, Q1e = () => localStorage.getItem(Xle), An = async (e, M = { method: "GET" }) => {
28076
28076
  var N;
28077
28077
  const t = {
28078
28078
  method: M.method,
@@ -28402,7 +28402,7 @@ const y0 = Symbol(), Yb = (e) => !!e[y0], lC = (e) => !e[y0].c, fS = (e) => {
28402
28402
  ), Z1e = /* @__PURE__ */ new WeakMap(), yC = (e) => "init" in e, bb = "r", _b = "w", Uh = "c", Rb = "s", dV = "h", J1e = "n", X1e = "l", K1e = "a", q1e = "m", eAe = (e) => {
28403
28403
  const M = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new Map();
28404
28404
  let u, N;
28405
- if (({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && (u = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set()), e)
28405
+ if (({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && (u = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set()), e)
28406
28406
  for (const [G, $] of e) {
28407
28407
  const X = {
28408
28408
  v: $,
@@ -28411,7 +28411,7 @@ const y0 = Symbol(), Yb = (e) => !!e[y0], lC = (e) => !e[y0].c, fS = (e) => {
28411
28411
  // not invalidated
28412
28412
  d: /* @__PURE__ */ new Map()
28413
28413
  };
28414
- ({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && (Object.freeze(X), yC(G) || console.warn(
28414
+ ({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && (Object.freeze(X), yC(G) || console.warn(
28415
28415
  "Found initial value for derived atom which can cause unexpected behavior",
28416
28416
  G
28417
28417
  )), M.set(G, X);
@@ -28437,7 +28437,7 @@ const y0 = Symbol(), Yb = (e) => !!e[y0], lC = (e) => !e[y0].c, fS = (e) => {
28437
28437
  }
28438
28438
  return M.get($);
28439
28439
  }, s = (G, $, X) => {
28440
- if (({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && Object.freeze(X), G)
28440
+ if (({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && Object.freeze(X), G)
28441
28441
  j(G).set($, X);
28442
28442
  else {
28443
28443
  const B = M.get($);
@@ -28542,7 +28542,7 @@ const y0 = Symbol(), Yb = (e) => !!e[y0], lC = (e) => !e[y0].c, fS = (e) => {
28542
28542
  };
28543
28543
  s(G, $, B);
28544
28544
  } else
28545
- ({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && console.warn("[Bug] could not invalidate non existing atom", $);
28545
+ ({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && console.warn("[Bug] could not invalidate non existing atom", $);
28546
28546
  }, O = (G, $, X) => {
28547
28547
  if (!X) {
28548
28548
  const K = o(G, $);
@@ -28620,14 +28620,14 @@ const y0 = Symbol(), Yb = (e) => !!e[y0], lC = (e) => !e[y0].c, fS = (e) => {
28620
28620
  () => K(re, je)
28621
28621
  ) : K(re, je);
28622
28622
  });
28623
- throw ({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && console.info(
28623
+ throw ({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && console.info(
28624
28624
  "Reading pending atom state in write operation. We throw a promise for now.",
28625
28625
  re
28626
28626
  ), ge.p;
28627
28627
  }
28628
28628
  if ("v" in ge)
28629
28629
  return ge.v;
28630
- throw ({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && console.warn(
28630
+ throw ({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && console.warn(
28631
28631
  "[Bug] no value found while reading atom in write operation. This is probably a bug.",
28632
28632
  re
28633
28633
  ), new Error("no value found");
@@ -28654,7 +28654,7 @@ const y0 = Symbol(), Yb = (e) => !!e[y0], lC = (e) => !e[y0].c, fS = (e) => {
28654
28654
  t: new Set(X && [X]),
28655
28655
  l: /* @__PURE__ */ new Set()
28656
28656
  };
28657
- if (t.set($, B), ({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && N.add($), O(void 0, $).d.forEach((te, ee) => {
28657
+ if (t.set($, B), ({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && N.add($), O(void 0, $).d.forEach((te, ee) => {
28658
28658
  const re = t.get(ee);
28659
28659
  re ? re.t.add($) : ee !== $ && w(G, ee, $);
28660
28660
  }), h($) && $.onMount) {
@@ -28665,14 +28665,14 @@ const y0 = Symbol(), Yb = (e) => !!e[y0], lC = (e) => !e[y0].c, fS = (e) => {
28665
28665
  }, m = (G, $) => {
28666
28666
  var X;
28667
28667
  const B = (X = t.get($)) == null ? void 0 : X.u;
28668
- B && B(), t.delete($), ({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && N.delete($);
28668
+ B && B(), t.delete($), ({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && N.delete($);
28669
28669
  const K = o(G, $);
28670
28670
  K ? ("p" in K && fS(K.p), K.d.forEach((te, ee) => {
28671
28671
  if (ee !== $) {
28672
28672
  const re = t.get(ee);
28673
28673
  re && (re.t.delete($), E(ee, re) && m(G, ee));
28674
28674
  }
28675
- })) : ({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && console.warn("[Bug] could not find atom state to unmount", $);
28675
+ })) : ({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && console.warn("[Bug] could not find atom state to unmount", $);
28676
28676
  }, Y = (G, $, X, B) => {
28677
28677
  const K = new Set(X.d.keys());
28678
28678
  B == null || B.forEach((te, ee) => {
@@ -28708,7 +28708,7 @@ const y0 = Symbol(), Yb = (e) => !!e[y0], lC = (e) => !e[y0].c, fS = (e) => {
28708
28708
  te == null || te.l.forEach((ee) => ee());
28709
28709
  });
28710
28710
  }
28711
- ({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && u.forEach(($) => $());
28711
+ ({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && u.forEach(($) => $());
28712
28712
  }, P = (G) => {
28713
28713
  j(G).forEach((X, B) => {
28714
28714
  const K = M.get(B);
@@ -28726,7 +28726,7 @@ const y0 = Symbol(), Yb = (e) => !!e[y0], lC = (e) => !e[y0].c, fS = (e) => {
28726
28726
  yC(X) && (I($, X, B), p($, X));
28727
28727
  R($);
28728
28728
  };
28729
- return ({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" ? {
28729
+ return ({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" ? {
28730
28730
  [bb]: f,
28731
28731
  [_b]: k,
28732
28732
  [Uh]: V,
@@ -28752,7 +28752,7 @@ function Cte(e, M) {
28752
28752
  function MAe(e, M) {
28753
28753
  const t = fte(M), i = ue.useContext(t), { s: u, v: N } = i, n = (s) => {
28754
28754
  const L = u[bb](e, s);
28755
- if (({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && !L.y)
28755
+ if (({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && !L.y)
28756
28756
  throw new Error("should not be invalidated");
28757
28757
  if ("e" in L)
28758
28758
  throw L.e;
@@ -28790,7 +28790,7 @@ function iAe(e, M) {
28790
28790
  const t = fte(M), { s: i, w: u } = ue.useContext(t);
28791
28791
  return ue.useCallback(
28792
28792
  (n) => {
28793
- if (({ VITE_END_POINT: "https://api-uat.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && !("write" in e))
28793
+ if (({ VITE_END_POINT: "https://api.usedatabrain.com", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 } && "production") !== "production" && !("write" in e))
28794
28794
  throw new Error("not writable atom");
28795
28795
  const r = (a) => i[_b](e, n, a);
28796
28796
  return u ? u(r) : r();
@@ -987,7 +987,7 @@ Check the top-level render call using <`+Je+">.")}return _e}}function Ri(Ie,_e){
987
987
  </symbol>
988
988
 
989
989
  </svg>`,xt=({name:e,size:M="md",color:t="primary"})=>{const[i,u]=ue.useState(!1);return ue.useEffect(()=>{const N=document.querySelectorAll(".dbn-icon-svg-sprite");N.length===0?u(!0):u(!1),N.length>1&&[...N].forEach((n,r)=>{r!==0&&n.remove()})},[]),x.jsxs(x.Fragment,{children:[i?x.jsx("span",{className:`${WS["dbn-icon-svg-sprite"]} ${WS.iconSvgSpriteHidden}`,dangerouslySetInnerHTML:{__html:Tse}}):null,x.jsx("svg",{className:`${WS[M]} ${WS[t]}`,children:x.jsx("use",{href:`#${e}`})})]})},lse=({name:e,width:M=48})=>x.jsx("img",{src:cse[e],width:M,alt:e}),LQ=({datatype:e="unknown",className:M,size:t="sm"})=>bL.includes(e.toLowerCase())?x.jsx(xt,{name:"number",size:t}):pz.includes(e.toLowerCase())||e.toLowerCase().includes("char")?x.jsx(xt,{name:"string",size:t}):ise.includes(e.toLowerCase())?x.jsx(xt,{name:"array",size:t}):Pl.includes(e.toLowerCase())?x.jsx(xt,{name:"date",size:t}):use.includes(e.toLowerCase())?x.jsx(xt,{name:"boolean",size:t}):x.jsx(xt,{name:"unknown",size:t}),gQ={primary:"_primary_o0tsr_197","primary-title":"_primary-title_o0tsr_1","primary-dark":"_primary-dark_o0tsr_1",secondary:"_secondary_o0tsr_1","secondary-dark":"_secondary-dark_o0tsr_1",infoAlert:"_infoAlert_o0tsr_1",white:"_white_o0tsr_1",gray:"_gray_o0tsr_1","gray-dark":"_gray-dark_o0tsr_1",alert:"_alert_o0tsr_1","alert-light":"_alert-light_o0tsr_1","alert-dark":"_alert-dark_o0tsr_1",success:"_success_o0tsr_1","success-dark":"_success-dark_o0tsr_1","success-light":"_success-light_o0tsr_1",warning:"_warning_o0tsr_1","warning-dark":"_warning-dark_o0tsr_1",info:"_info_o0tsr_1","info-light":"_info-light_o0tsr_1",cta:"_cta_o0tsr_1","bg-primary":"_bg-primary_o0tsr_1","bg-primary-dark":"_bg-primary-dark_o0tsr_1","bg-secondary":"_bg-secondary_o0tsr_1","bg-secondary-dark":"_bg-secondary-dark_o0tsr_1","bg-white":"_bg-white_o0tsr_1","bg-gray":"_bg-gray_o0tsr_1","bg-gray-dark":"_bg-gray-dark_o0tsr_1","bg-alert":"_bg-alert_o0tsr_1","bg-alert-light":"_bg-alert-light_o0tsr_1","bg-alert-dark":"_bg-alert-dark_o0tsr_1","bg-success":"_bg-success_o0tsr_1","bg-success-dark":"_bg-success-dark_o0tsr_1","bg-success-light":"_bg-success-light_o0tsr_1","bg-warning":"_bg-warning_o0tsr_1","bg-warning-dark":"_bg-warning-dark_o0tsr_1","bg-info":"_bg-info_o0tsr_1","bg-info-light":"_bg-info-light_o0tsr_1",display:"_display_o0tsr_5","heading-xl":"_heading-xl_o0tsr_13","heading-2":"_heading-2_o0tsr_21","heading-lg":"_heading-lg_o0tsr_29",heading:"_heading_o0tsr_13","heading-sm":"_heading-sm_o0tsr_45","heading-xs":"_heading-xs_o0tsr_53","body-text-lg":"_body-text-lg_o0tsr_61","body-text":"_body-text_o0tsr_61","body-text-sm":"_body-text-sm_o0tsr_77","body-text-xs":"_body-text-xs_o0tsr_85",btn:"_btn_o0tsr_93",label:"_label_o0tsr_101","sub-label":"_sub-label_o0tsr_109","input-label":"_input-label_o0tsr_117",subtext:"_subtext_o0tsr_125","tag-or-flag":"_tag-or-flag_o0tsr_133","subtext-forms":"_subtext-forms_o0tsr_141",code:"_code_o0tsr_149","small-text":"_small-text_o0tsr_157","inline-truncate":"_inline-truncate_o0tsr_165",inline:"_inline_o0tsr_165",block:"_block_o0tsr_181",storyBookPrimary:"_storyBookPrimary_o0tsr_189",primaryStoryHeading:"_primaryStoryHeading_o0tsr_197",primaryStorySection:"_primaryStorySection_o0tsr_213",primaryStoryTextInfo:"_primaryStoryTextInfo_o0tsr_245"},VP={"heading-xl":"h1","heading-lg":"h2",heading:"h3","heading-2":"h2","heading-sm":"h5","heading-xs":"h6","body-text-lg":"p","body-text":"p","body-text-sm":"p",display:"p",btn:"span",label:"span","input-label":"span",subtext:"span","tag-or-flag":"span","subtext-forms":"span",code:"p","sub-label":"span","body-text-xs":"span","small-text":"sapn"},Ye=({children:e="",variant:M="body-text",color:t="primary-title",display:i,onClick:u,opacity:N=1})=>{i||(i=VP[M]==="span"?"inline":"block");const n=VP[M],r=[gQ[M],gQ[t],gQ[i],"truncate"].join(" ");return x.jsx(n,{className:`${r}`,style:{opacity:N},onClick:u,children:e})},WP=({message:e=""})=>x.jsx(Ye,{variant:"body-text-sm",color:"alert",children:e}),yse={container:"_container_1af2w_1",windowIcon:"_windowIcon_1af2w_7"},Ise=()=>x.jsxs("div",{role:"alert",className:yse.container,children:[x.jsx(xt,{name:"info",size:"xl"}),x.jsx(Ye,{variant:"body-text-lg",children:"Something went wrong!"}),x.jsx(yt,{variant:"primary",type:"button",onClick:()=>location.reload(),children:"Try again"})]});var Y5=e=>e.type==="checkbox",vz=e=>e instanceof Date,Sa=e=>e==null;const HP=e=>typeof e=="object";var Tn=e=>!Sa(e)&&!Array.isArray(e)&&HP(e)&&!vz(e),$P=e=>Tn(e)&&e.target?Y5(e.target)?e.target.checked:e.target.value:e,zse=e=>e.substring(0,e.search(/\.\d+(\.|$)/))||e,ZP=(e,M)=>e.has(zse(M)),Ase=e=>{const M=e.constructor&&e.constructor.prototype;return Tn(M)&&M.hasOwnProperty("isPrototypeOf")},cQ=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function dg(e){let M;const t=Array.isArray(e);if(e instanceof Date)M=new Date(e);else if(e instanceof Set)M=new Set(e);else if(!(cQ&&(e instanceof Blob||e instanceof FileList))&&(t||Tn(e)))if(M=t?[]:{},!Array.isArray(e)&&!Ase(e))M=e;else for(const i in e)M[i]=dg(e[i]);else return e;return M}var m5=e=>Array.isArray(e)?e.filter(Boolean):[],_4=e=>e===void 0,UM=(e,M,t)=>{if(!M||!Tn(e))return t;const i=m5(M.split(/[,[\].]+?/)).reduce((u,N)=>Sa(u)?u:u[N],e);return _4(i)||i===e?_4(e[M])?t:e[M]:i};const HS={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change"},Ls={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},fg={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},Ose=Ge.createContext(null),TQ=()=>Ge.useContext(Ose);var JP=(e,M,t,i=!0)=>{const u={defaultValues:M._defaultValues};for(const N in e)Object.defineProperty(u,N,{get:()=>{const n=N;return M._proxyFormState[n]!==Ls.all&&(M._proxyFormState[n]=!i||Ls.all),t&&(t[n]=!0),e[n]}});return u},RD=e=>Tn(e)&&!Object.keys(e).length,XP=(e,M,t,i)=>{t(e);const{name:u,...N}=e;return RD(N)||Object.keys(N).length>=Object.keys(M).length||Object.keys(N).find(n=>M[n]===(!i||Ls.all))},$S=e=>Array.isArray(e)?e:[e],KP=(e,M,t)=>t&&M?e===M:!e||!M||e===M||$S(e).some(i=>i&&(i.startsWith(M)||M.startsWith(i)));function lQ(e){const M=Ge.useRef(e);M.current=e,Ge.useEffect(()=>{const t=!e.disabled&&M.current.subject&&M.current.subject.subscribe({next:M.current.next});return()=>{t&&t.unsubscribe()}},[e.disabled])}function xse(e){const M=TQ(),{control:t=M.control,disabled:i,name:u,exact:N}=e||{},[n,r]=Ge.useState(t._formState),a=Ge.useRef(!0),D=Ge.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1}),j=Ge.useRef(u);return j.current=u,lQ({disabled:i,next:o=>a.current&&KP(j.current,o.name,N)&&XP(o,D.current,t._updateFormState)&&r({...t._formState,...o}),subject:t._subjects.state}),Ge.useEffect(()=>(a.current=!0,D.current.isValid&&t._updateValid(!0),()=>{a.current=!1}),[t]),JP(n,t,D.current,!1)}var _L=e=>typeof e=="string",qP=(e,M,t,i,u)=>_L(e)?(i&&M.watch.add(e),UM(t,e,u)):Array.isArray(e)?e.map(N=>(i&&M.watch.add(N),UM(t,N))):(i&&(M.watchAll=!0),t);function Sse(e){const M=TQ(),{control:t=M.control,name:i,defaultValue:u,disabled:N,exact:n}=e||{},r=Ge.useRef(i);r.current=i,lQ({disabled:N,subject:t._subjects.values,next:j=>{KP(r.current,j.name,n)&&D(dg(qP(r.current,t._names,j.values||t._formValues,!1,u)))}});const[a,D]=Ge.useState(t._getWatch(i,u));return Ge.useEffect(()=>t._removeUnmounted()),a}var yQ=e=>/^\w*$/.test(e),eF=e=>m5(e.replace(/["|']|\]/g,"").split(/\.|\[/));function BN(e,M,t){let i=-1;const u=yQ(M)?[M]:eF(M),N=u.length,n=N-1;for(;++i<N;){const r=u[i];let a=t;if(i!==n){const D=e[r];a=Tn(D)||Array.isArray(D)?D:isNaN(+u[i+1])?{}:[]}e[r]=a,e=e[r]}return e}function Ese(e){const M=TQ(),{name:t,control:i=M.control,shouldUnregister:u}=e,N=ZP(i._names.array,t),n=Sse({control:i,name:t,defaultValue:UM(i._formValues,t,UM(i._defaultValues,t,e.defaultValue)),exact:!0}),r=xse({control:i,name:t}),a=Ge.useRef(i.register(t,{...e.rules,value:n}));return Ge.useEffect(()=>{const D=i._options.shouldUnregister||u,j=(o,s)=>{const L=UM(i._fields,o);L&&(L._f.mount=s)};if(j(t,!0),D){const o=dg(UM(i._options.defaultValues,t));BN(i._defaultValues,t,o),_4(UM(i._formValues,t))&&BN(i._formValues,t,o)}return()=>{(N?D&&!i._state.action:D)?i.unregister(t):j(t,!1)}},[t,i,N,u]),{field:{name:t,value:n,onChange:Ge.useCallback(D=>a.current.onChange({target:{value:$P(D),name:t},type:HS.CHANGE}),[t]),onBlur:Ge.useCallback(()=>a.current.onBlur({target:{value:UM(i._formValues,t),name:t},type:HS.BLUR}),[t,i]),ref:D=>{const j=UM(i._fields,t);j&&D&&(j._f.ref={focus:()=>D.focus(),select:()=>D.select(),setCustomValidity:o=>D.setCustomValidity(o),reportValidity:()=>D.reportValidity()})}},formState:r,fieldState:Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!UM(r.errors,t)},isDirty:{enumerable:!0,get:()=>!!UM(r.dirtyFields,t)},isTouched:{enumerable:!0,get:()=>!!UM(r.touchedFields,t)},error:{enumerable:!0,get:()=>UM(r.errors,t)}})}}const kz=e=>e.render(Ese(e));var dse=(e,M,t,i,u)=>M?{...t[e],types:{...t[e]&&t[e].types?t[e].types:{},[i]:u||!0}}:{};const IQ=(e,M,t)=>{for(const i of t||Object.keys(e)){const u=UM(e,i);if(u){const{_f:N,...n}=u;if(N&&M(N.name)){if(N.ref.focus){N.ref.focus();break}else if(N.refs&&N.refs[0].focus){N.refs[0].focus();break}}else Tn(n)&&IQ(n,M)}}};var tF=e=>({isOnSubmit:!e||e===Ls.onSubmit,isOnBlur:e===Ls.onBlur,isOnChange:e===Ls.onChange,isOnAll:e===Ls.all,isOnTouch:e===Ls.onTouched}),MF=(e,M,t)=>!t&&(M.watchAll||M.watch.has(e)||[...M.watch].some(i=>e.startsWith(i)&&/^\.\w+/.test(e.slice(i.length)))),fse=(e,M,t)=>{const i=m5(UM(e,t));return BN(i,"root",M[t]),BN(e,t,i),e},Uz=e=>typeof e=="boolean",zQ=e=>e.type==="file",O1=e=>typeof e=="function",ZS=e=>{if(!cQ)return!1;const M=e?e.ownerDocument:0;return e instanceof(M&&M.defaultView?M.defaultView.HTMLElement:HTMLElement)},JS=e=>_L(e),AQ=e=>e.type==="radio",XS=e=>e instanceof RegExp;const iF={value:!1,isValid:!1},uF={value:!0,isValid:!0};var NF=e=>{if(Array.isArray(e)){if(e.length>1){const M=e.filter(t=>t&&t.checked&&!t.disabled).map(t=>t.value);return{value:M,isValid:!!M.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!_4(e[0].attributes.value)?_4(e[0].value)||e[0].value===""?uF:{value:e[0].value,isValid:!0}:uF:iF}return iF};const nF={isValid:!1,value:null};var rF=e=>Array.isArray(e)?e.reduce((M,t)=>t&&t.checked&&!t.disabled?{isValid:!0,value:t.value}:M,nF):nF;function aF(e,M,t="validate"){if(JS(e)||Array.isArray(e)&&e.every(JS)||Uz(e)&&!e)return{type:t,message:JS(e)?e:"",ref:M}}var Yz=e=>Tn(e)&&!XS(e)?e:{value:e,message:""},jF=async(e,M,t,i,u)=>{const{ref:N,refs:n,required:r,maxLength:a,minLength:D,min:j,max:o,pattern:s,validate:L,name:g,valueAsNumber:c,mount:l,disabled:I}=e._f,z=UM(M,g);if(!l||I)return{};const O=n?n[0]:N,f=w=>{i&&O.reportValidity&&(O.setCustomValidity(Uz(w)?"":w||""),O.reportValidity())},S={},E=AQ(N),p=Y5(N),Q=E||p,k=(c||zQ(N))&&_4(N.value)&&_4(z)||ZS(N)&&N.value===""||z===""||Array.isArray(z)&&!z.length,v=dse.bind(null,g,t,S),h=(w,m,Y,R=fg.maxLength,P=fg.minLength)=>{const V=w?m:Y;S[g]={type:w?R:P,message:V,ref:N,...v(w?R:P,V)}};if(u?!Array.isArray(z)||!z.length:r&&(!Q&&(k||Sa(z))||Uz(z)&&!z||p&&!NF(n).isValid||E&&!rF(n).isValid)){const{value:w,message:m}=JS(r)?{value:!!r,message:r}:Yz(r);if(w&&(S[g]={type:fg.required,message:m,ref:O,...v(fg.required,m)},!t))return f(m),S}if(!k&&(!Sa(j)||!Sa(o))){let w,m;const Y=Yz(o),R=Yz(j);if(!Sa(z)&&!isNaN(z)){const P=N.valueAsNumber||z&&+z;Sa(Y.value)||(w=P>Y.value),Sa(R.value)||(m=P<R.value)}else{const P=N.valueAsDate||new Date(z),V=G=>new Date(new Date().toDateString()+" "+G),H=N.type=="time",Z=N.type=="week";_L(Y.value)&&z&&(w=H?V(z)>V(Y.value):Z?z>Y.value:P>new Date(Y.value)),_L(R.value)&&z&&(m=H?V(z)<V(R.value):Z?z<R.value:P<new Date(R.value))}if((w||m)&&(h(!!w,Y.message,R.message,fg.max,fg.min),!t))return f(S[g].message),S}if((a||D)&&!k&&(_L(z)||u&&Array.isArray(z))){const w=Yz(a),m=Yz(D),Y=!Sa(w.value)&&z.length>+w.value,R=!Sa(m.value)&&z.length<+m.value;if((Y||R)&&(h(Y,w.message,m.message),!t))return f(S[g].message),S}if(s&&!k&&_L(z)){const{value:w,message:m}=Yz(s);if(XS(w)&&!z.match(w)&&(S[g]={type:fg.pattern,message:m,ref:N,...v(fg.pattern,m)},!t))return f(m),S}if(L){if(O1(L)){const w=await L(z,M),m=aF(w,O);if(m&&(S[g]={...m,...v(fg.validate,m.message)},!t))return f(m.message),S}else if(Tn(L)){let w={};for(const m in L){if(!RD(w)&&!t)break;const Y=aF(await L[m](z,M),O,m);Y&&(w={...Y,...v(m,Y.message)},f(Y.message),t&&(S[g]=w))}if(!RD(w)&&(S[g]={ref:O,...w},!t))return S}}return f(!0),S};function Cse(e,M){const t=M.slice(0,-1).length;let i=0;for(;i<t;)e=_4(e)?i++:e[M[i++]];return e}function wse(e){for(const M in e)if(!_4(e[M]))return!1;return!0}function ar(e,M){const t=Array.isArray(M)?M:yQ(M)?[M]:eF(M),i=t.length===1?e:Cse(e,t),u=t.length-1,N=t[u];return i&&delete i[N],u!==0&&(Tn(i)&&RD(i)||Array.isArray(i)&&wse(i))&&ar(e,t.slice(0,-1)),e}function OQ(){let e=[];return{get observers(){return e},next:u=>{for(const N of e)N.next&&N.next(u)},subscribe:u=>(e.push(u),{unsubscribe:()=>{e=e.filter(N=>N!==u)}}),unsubscribe:()=>{e=[]}}}var KS=e=>Sa(e)||!HP(e);function Fl(e,M){if(KS(e)||KS(M))return e===M;if(vz(e)&&vz(M))return e.getTime()===M.getTime();const t=Object.keys(e),i=Object.keys(M);if(t.length!==i.length)return!1;for(const u of t){const N=e[u];if(!i.includes(u))return!1;if(u!=="ref"){const n=M[u];if(vz(N)&&vz(n)||Tn(N)&&Tn(n)||Array.isArray(N)&&Array.isArray(n)?!Fl(N,n):N!==n)return!1}}return!0}var DF=e=>e.type==="select-multiple",hse=e=>AQ(e)||Y5(e),xQ=e=>ZS(e)&&e.isConnected,oF=e=>{for(const M in e)if(O1(e[M]))return!0;return!1};function qS(e,M={}){const t=Array.isArray(e);if(Tn(e)||t)for(const i in e)Array.isArray(e[i])||Tn(e[i])&&!oF(e[i])?(M[i]=Array.isArray(e[i])?[]:{},qS(e[i],M[i])):Sa(e[i])||(M[i]=!0);return M}function sF(e,M,t){const i=Array.isArray(e);if(Tn(e)||i)for(const u in e)Array.isArray(e[u])||Tn(e[u])&&!oF(e[u])?_4(M)||KS(t[u])?t[u]=Array.isArray(e[u])?qS(e[u],[]):{...qS(e[u])}:sF(e[u],Sa(M)?{}:M[u],t[u]):t[u]=!Fl(e[u],M[u]);return t}var SQ=(e,M)=>sF(e,M,qS(M)),LF=(e,{valueAsNumber:M,valueAsDate:t,setValueAs:i})=>_4(e)?e:M?e===""?NaN:e&&+e:t&&_L(e)?new Date(e):i?i(e):e;function EQ(e){const M=e.ref;if(!(e.refs?e.refs.every(t=>t.disabled):M.disabled))return zQ(M)?M.files:AQ(M)?rF(e.refs).value:DF(M)?[...M.selectedOptions].map(({value:t})=>t):Y5(M)?NF(e.refs).value:LF(_4(M.value)?e.ref.value:M.value,e)}var pse=(e,M,t,i)=>{const u={};for(const N of e){const n=UM(M,N);n&&BN(u,N,n._f)}return{criteriaMode:t,names:[...e],fields:u,shouldUseNativeValidation:i}},b5=e=>_4(e)?e:XS(e)?e.source:Tn(e)?XS(e.value)?e.value.source:e.value:e,Qse=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate);function gF(e,M,t){const i=UM(e,t);if(i||yQ(t))return{error:i,name:t};const u=t.split(".");for(;u.length;){const N=u.join("."),n=UM(M,N),r=UM(e,N);if(n&&!Array.isArray(n)&&t!==N)return{name:t};if(r&&r.type)return{name:N,error:r};u.pop()}return{name:t}}var vse=(e,M,t,i,u)=>u.isOnAll?!1:!t&&u.isOnTouch?!(M||e):(t?i.isOnBlur:u.isOnBlur)?!e:(t?i.isOnChange:u.isOnChange)?e:!0,kse=(e,M)=>!m5(UM(e,M)).length&&ar(e,M);const Use={mode:Ls.onSubmit,reValidateMode:Ls.onChange,shouldFocusError:!0};function Yse(e={},M){let t={...Use,...e},i={submitCount:0,isDirty:!1,isLoading:O1(t.defaultValues),isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},errors:{}},u={},N=Tn(t.defaultValues)||Tn(t.values)?dg(t.defaultValues||t.values)||{}:{},n=t.shouldUnregister?{}:dg(N),r={action:!1,mount:!1,watch:!1},a={mount:new Set,unMount:new Set,array:new Set,watch:new Set},D,j=0;const o={isDirty:!1,dirtyFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},s={values:OQ(),array:OQ(),state:OQ()},L=e.resetOptions&&e.resetOptions.keepDirtyValues,g=tF(t.mode),c=tF(t.reValidateMode),l=t.criteriaMode===Ls.all,I=ce=>he=>{clearTimeout(j),j=setTimeout(ce,he)},z=async ce=>{if(o.isValid||ce){const he=t.resolver?RD((await k()).errors):await h(u,!0);he!==i.isValid&&s.state.next({isValid:he})}},O=ce=>o.isValidating&&s.state.next({isValidating:ce}),f=(ce,he=[],ve,Oe,pe=!0,le=!0)=>{if(Oe&&ve){if(r.action=!0,le&&Array.isArray(UM(u,ce))){const fe=ve(UM(u,ce),Oe.argA,Oe.argB);pe&&BN(u,ce,fe)}if(le&&Array.isArray(UM(i.errors,ce))){const fe=ve(UM(i.errors,ce),Oe.argA,Oe.argB);pe&&BN(i.errors,ce,fe),kse(i.errors,ce)}if(o.touchedFields&&le&&Array.isArray(UM(i.touchedFields,ce))){const fe=ve(UM(i.touchedFields,ce),Oe.argA,Oe.argB);pe&&BN(i.touchedFields,ce,fe)}o.dirtyFields&&(i.dirtyFields=SQ(N,n)),s.state.next({name:ce,isDirty:m(ce,he),dirtyFields:i.dirtyFields,errors:i.errors,isValid:i.isValid})}else BN(n,ce,he)},S=(ce,he)=>{BN(i.errors,ce,he),s.state.next({errors:i.errors})},E=(ce,he,ve,Oe)=>{const pe=UM(u,ce);if(pe){const le=UM(n,ce,_4(ve)?UM(N,ce):ve);_4(le)||Oe&&Oe.defaultChecked||he?BN(n,ce,he?le:EQ(pe._f)):P(ce,le),r.mount&&z()}},p=(ce,he,ve,Oe,pe)=>{let le=!1,fe=!1;const de={name:ce};if(!ve||Oe){o.isDirty&&(fe=i.isDirty,i.isDirty=de.isDirty=m(),le=fe!==de.isDirty);const Ze=Fl(UM(N,ce),he);fe=UM(i.dirtyFields,ce),Ze?ar(i.dirtyFields,ce):BN(i.dirtyFields,ce,!0),de.dirtyFields=i.dirtyFields,le=le||o.dirtyFields&&fe!==!Ze}if(ve){const Ze=UM(i.touchedFields,ce);Ze||(BN(i.touchedFields,ce,ve),de.touchedFields=i.touchedFields,le=le||o.touchedFields&&Ze!==ve)}return le&&pe&&s.state.next(de),le?de:{}},Q=(ce,he,ve,Oe)=>{const pe=UM(i.errors,ce),le=o.isValid&&Uz(he)&&i.isValid!==he;if(e.delayError&&ve?(D=I(()=>S(ce,ve)),D(e.delayError)):(clearTimeout(j),D=null,ve?BN(i.errors,ce,ve):ar(i.errors,ce)),(ve?!Fl(pe,ve):pe)||!RD(Oe)||le){const fe={...Oe,...le&&Uz(he)?{isValid:he}:{},errors:i.errors,name:ce};i={...i,...fe},s.state.next(fe)}O(!1)},k=async ce=>t.resolver(n,t.context,pse(ce||a.mount,u,t.criteriaMode,t.shouldUseNativeValidation)),v=async ce=>{const{errors:he}=await k();if(ce)for(const ve of ce){const Oe=UM(he,ve);Oe?BN(i.errors,ve,Oe):ar(i.errors,ve)}else i.errors=he;return he},h=async(ce,he,ve={valid:!0})=>{for(const Oe in ce){const pe=ce[Oe];if(pe){const{_f:le,...fe}=pe;if(le){const de=a.array.has(le.name),Ze=await jF(pe,n,l,t.shouldUseNativeValidation&&!he,de);if(Ze[le.name]&&(ve.valid=!1,he))break;!he&&(UM(Ze,le.name)?de?fse(i.errors,Ze,le.name):BN(i.errors,le.name,Ze[le.name]):ar(i.errors,le.name))}fe&&await h(fe,he,ve)}}return ve.valid},w=()=>{for(const ce of a.unMount){const he=UM(u,ce);he&&(he._f.refs?he._f.refs.every(ve=>!xQ(ve)):!xQ(he._f.ref))&&ee(ce)}a.unMount=new Set},m=(ce,he)=>(ce&&he&&BN(n,ce,he),!Fl($(),N)),Y=(ce,he,ve)=>qP(ce,a,{...r.mount?n:_4(he)?N:_L(ce)?{[ce]:he}:he},ve,he),R=ce=>m5(UM(r.mount?n:N,ce,e.shouldUnregister?UM(N,ce,[]):[])),P=(ce,he,ve={})=>{const Oe=UM(u,ce);let pe=he;if(Oe){const le=Oe._f;le&&(!le.disabled&&BN(n,ce,LF(he,le)),pe=ZS(le.ref)&&Sa(he)?"":he,DF(le.ref)?[...le.ref.options].forEach(fe=>fe.selected=pe.includes(fe.value)):le.refs?Y5(le.ref)?le.refs.length>1?le.refs.forEach(fe=>(!fe.defaultChecked||!fe.disabled)&&(fe.checked=Array.isArray(pe)?!!pe.find(de=>de===fe.value):pe===fe.value)):le.refs[0]&&(le.refs[0].checked=!!pe):le.refs.forEach(fe=>fe.checked=fe.value===pe):zQ(le.ref)?le.ref.value="":(le.ref.value=pe,le.ref.type||s.values.next({name:ce,values:{...n}})))}(ve.shouldDirty||ve.shouldTouch)&&p(ce,pe,ve.shouldTouch,ve.shouldDirty,!0),ve.shouldValidate&&G(ce)},V=(ce,he,ve)=>{for(const Oe in he){const pe=he[Oe],le=`${ce}.${Oe}`,fe=UM(u,le);(a.array.has(ce)||!KS(pe)||fe&&!fe._f)&&!vz(pe)?V(le,pe,ve):P(le,pe,ve)}},H=(ce,he,ve={})=>{const Oe=UM(u,ce),pe=a.array.has(ce),le=dg(he);BN(n,ce,le),pe?(s.array.next({name:ce,values:{...n}}),(o.isDirty||o.dirtyFields)&&ve.shouldDirty&&s.state.next({name:ce,dirtyFields:SQ(N,n),isDirty:m(ce,le)})):Oe&&!Oe._f&&!Sa(le)?V(ce,le,ve):P(ce,le,ve),MF(ce,a)&&s.state.next({...i}),s.values.next({name:ce,values:{...n}}),!r.mount&&M()},Z=async ce=>{const he=ce.target;let ve=he.name,Oe=!0;const pe=UM(u,ve),le=()=>he.type?EQ(pe._f):$P(ce);if(pe){let fe,de;const Ze=le(),me=ce.type===HS.BLUR||ce.type===HS.FOCUS_OUT,$e=!Qse(pe._f)&&!t.resolver&&!UM(i.errors,ve)&&!pe._f.deps||vse(me,UM(i.touchedFields,ve),i.isSubmitted,c,g),Ke=MF(ve,a,me);BN(n,ve,Ze),me?(pe._f.onBlur&&pe._f.onBlur(ce),D&&D(0)):pe._f.onChange&&pe._f.onChange(ce);const Ot=p(ve,Ze,me,!1),Ft=!RD(Ot)||Ke;if(!me&&s.values.next({name:ve,type:ce.type,values:{...n}}),$e)return o.isValid&&z(),Ft&&s.state.next({name:ve,...Ke?{}:Ot});if(!me&&Ke&&s.state.next({...i}),O(!0),t.resolver){const{errors:Gt}=await k([ve]),at=gF(i.errors,u,ve),st=gF(Gt,u,at.name||ve);fe=st.error,ve=st.name,de=RD(Gt)}else fe=(await jF(pe,n,l,t.shouldUseNativeValidation))[ve],Oe=isNaN(Ze)||Ze===UM(n,ve,Ze),Oe&&(fe?de=!1:o.isValid&&(de=await h(u,!0)));Oe&&(pe._f.deps&&G(pe._f.deps),Q(ve,de,fe,Ot))}},G=async(ce,he={})=>{let ve,Oe;const pe=$S(ce);if(O(!0),t.resolver){const le=await v(_4(ce)?ce:pe);ve=RD(le),Oe=ce?!pe.some(fe=>UM(le,fe)):ve}else ce?(Oe=(await Promise.all(pe.map(async le=>{const fe=UM(u,le);return await h(fe&&fe._f?{[le]:fe}:fe)}))).every(Boolean),!(!Oe&&!i.isValid)&&z()):Oe=ve=await h(u);return s.state.next({...!_L(ce)||o.isValid&&ve!==i.isValid?{}:{name:ce},...t.resolver||!ce?{isValid:ve}:{},errors:i.errors,isValidating:!1}),he.shouldFocus&&!Oe&&IQ(u,le=>le&&UM(i.errors,le),ce?pe:a.mount),Oe},$=ce=>{const he={...N,...r.mount?n:{}};return _4(ce)?he:_L(ce)?UM(he,ce):ce.map(ve=>UM(he,ve))},X=(ce,he)=>({invalid:!!UM((he||i).errors,ce),isDirty:!!UM((he||i).dirtyFields,ce),isTouched:!!UM((he||i).touchedFields,ce),error:UM((he||i).errors,ce)}),B=ce=>{ce&&$S(ce).forEach(he=>ar(i.errors,he)),s.state.next({errors:ce?i.errors:{}})},K=(ce,he,ve)=>{const Oe=(UM(u,ce,{_f:{}})._f||{}).ref;BN(i.errors,ce,{...he,ref:Oe}),s.state.next({name:ce,errors:i.errors,isValid:!1}),ve&&ve.shouldFocus&&Oe&&Oe.focus&&Oe.focus()},te=(ce,he)=>O1(ce)?s.values.subscribe({next:ve=>ce(Y(void 0,he),ve)}):Y(ce,he,!0),ee=(ce,he={})=>{for(const ve of ce?$S(ce):a.mount)a.mount.delete(ve),a.array.delete(ve),he.keepValue||(ar(u,ve),ar(n,ve)),!he.keepError&&ar(i.errors,ve),!he.keepDirty&&ar(i.dirtyFields,ve),!he.keepTouched&&ar(i.touchedFields,ve),!t.shouldUnregister&&!he.keepDefaultValue&&ar(N,ve);s.values.next({values:{...n}}),s.state.next({...i,...he.keepDirty?{isDirty:m()}:{}}),!he.keepIsValid&&z()},re=(ce,he={})=>{let ve=UM(u,ce);const Oe=Uz(he.disabled);return BN(u,ce,{...ve||{},_f:{...ve&&ve._f?ve._f:{ref:{name:ce}},name:ce,mount:!0,...he}}),a.mount.add(ce),ve?Oe&&BN(n,ce,he.disabled?void 0:UM(n,ce,EQ(ve._f))):E(ce,!0,he.value),{...Oe?{disabled:he.disabled}:{},...t.shouldUseNativeValidation?{required:!!he.required,min:b5(he.min),max:b5(he.max),minLength:b5(he.minLength),maxLength:b5(he.maxLength),pattern:b5(he.pattern)}:{},name:ce,onChange:Z,onBlur:Z,ref:pe=>{if(pe){re(ce,he),ve=UM(u,ce);const le=_4(pe.value)&&pe.querySelectorAll&&pe.querySelectorAll("input,select,textarea")[0]||pe,fe=hse(le),de=ve._f.refs||[];if(fe?de.find(Ze=>Ze===le):le===ve._f.ref)return;BN(u,ce,{_f:{...ve._f,...fe?{refs:[...de.filter(xQ),le,...Array.isArray(UM(N,ce))?[{}]:[]],ref:{type:le.type,name:ce}}:{ref:le}}}),E(ce,!1,void 0,le)}else ve=UM(u,ce,{}),ve._f&&(ve._f.mount=!1),(t.shouldUnregister||he.shouldUnregister)&&!(ZP(a.array,ce)&&r.action)&&a.unMount.add(ce)}}},je=()=>t.shouldFocusError&&IQ(u,ce=>ce&&UM(i.errors,ce),a.mount),ge=(ce,he)=>async ve=>{ve&&(ve.preventDefault&&ve.preventDefault(),ve.persist&&ve.persist());let Oe=dg(n);if(s.state.next({isSubmitting:!0}),t.resolver){const{errors:pe,values:le}=await k();i.errors=pe,Oe=le}else await h(u);ar(i.errors,"root"),RD(i.errors)?(s.state.next({errors:{}}),await ce(Oe,ve)):(he&&await he({...i.errors},ve),je(),setTimeout(je)),s.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:RD(i.errors),submitCount:i.submitCount+1,errors:i.errors})},ze=(ce,he={})=>{UM(u,ce)&&(_4(he.defaultValue)?H(ce,UM(N,ce)):(H(ce,he.defaultValue),BN(N,ce,he.defaultValue)),he.keepTouched||ar(i.touchedFields,ce),he.keepDirty||(ar(i.dirtyFields,ce),i.isDirty=he.defaultValue?m(ce,UM(N,ce)):m()),he.keepError||(ar(i.errors,ce),o.isValid&&z()),s.state.next({...i}))},Ae=(ce,he={})=>{const ve=ce||N,Oe=dg(ve),pe=ce&&!RD(ce)?Oe:N;if(he.keepDefaultValues||(N=ve),!he.keepValues){if(he.keepDirtyValues||L)for(const le of a.mount)UM(i.dirtyFields,le)?BN(pe,le,UM(n,le)):H(le,UM(pe,le));else{if(cQ&&_4(ce))for(const le of a.mount){const fe=UM(u,le);if(fe&&fe._f){const de=Array.isArray(fe._f.refs)?fe._f.refs[0]:fe._f.ref;if(ZS(de)){const Ze=de.closest("form");if(Ze){Ze.reset();break}}}}u={}}n=e.shouldUnregister?he.keepDefaultValues?dg(N):{}:Oe,s.array.next({values:{...pe}}),s.values.next({values:{...pe}})}a={mount:new Set,unMount:new Set,array:new Set,watch:new Set,watchAll:!1,focus:""},!r.mount&&M(),r.mount=!o.isValid||!!he.keepIsValid,r.watch=!!e.shouldUnregister,s.state.next({submitCount:he.keepSubmitCount?i.submitCount:0,isDirty:he.keepDirty?i.isDirty:!!(he.keepDefaultValues&&!Fl(ce,N)),isSubmitted:he.keepIsSubmitted?i.isSubmitted:!1,dirtyFields:he.keepDirtyValues?i.dirtyFields:he.keepDefaultValues&&ce?SQ(N,ce):{},touchedFields:he.keepTouched?i.touchedFields:{},errors:he.keepErrors?i.errors:{},isSubmitting:!1,isSubmitSuccessful:!1})},Te=(ce,he)=>Ae(O1(ce)?ce(n):ce,he);return{control:{register:re,unregister:ee,getFieldState:X,_executeSchema:k,_getWatch:Y,_getDirty:m,_updateValid:z,_removeUnmounted:w,_updateFieldArray:f,_getFieldArray:R,_reset:Ae,_resetDefaultValues:()=>O1(t.defaultValues)&&t.defaultValues().then(ce=>{Te(ce,t.resetOptions),s.state.next({isLoading:!1})}),_updateFormState:ce=>{i={...i,...ce}},_subjects:s,_proxyFormState:o,get _fields(){return u},get _formValues(){return n},get _state(){return r},set _state(ce){r=ce},get _defaultValues(){return N},get _names(){return a},set _names(ce){a=ce},get _formState(){return i},set _formState(ce){i=ce},get _options(){return t},set _options(ce){t={...t,...ce}}},trigger:G,register:re,handleSubmit:ge,watch:te,setValue:H,getValues:$,reset:Te,resetField:ze,clearErrors:B,unregister:ee,setError:K,setFocus:(ce,he={})=>{const ve=UM(u,ce),Oe=ve&&ve._f;if(Oe){const pe=Oe.refs?Oe.refs[0]:Oe.ref;pe.focus&&(pe.focus(),he.shouldSelect&&pe.select())}},getFieldState:X}}function eE(e={}){const M=Ge.useRef(),[t,i]=Ge.useState({isDirty:!1,isValidating:!1,isLoading:O1(e.defaultValues),isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,submitCount:0,dirtyFields:{},touchedFields:{},errors:{},defaultValues:O1(e.defaultValues)?void 0:e.defaultValues});M.current||(M.current={...Yse(e,()=>i(N=>({...N}))),formState:t});const u=M.current.control;return u._options=e,lQ({subject:u._subjects.state,next:N=>{XP(N,u._proxyFormState,u._updateFormState,!0)&&i({...u._formState})}}),Ge.useEffect(()=>{e.values&&!Fl(e.values,u._defaultValues)?u._reset(e.values,u._options.resetOptions):u._resetDefaultValues()},[e.values,u]),Ge.useEffect(()=>{u._state.mount||(u._updateValid(),u._state.mount=!0),u._state.watch&&(u._state.watch=!1,u._subjects.state.next({...u._formState})),u._removeUnmounted()}),M.current.formState=JP(t,u),M.current}const cF={container:"_container_1nruh_1",field:"_field_1nruh_9",fieldLabel:"_fieldLabel_1nruh_17",save:"_save_1nruh_25",cancel:"_cancel_1nruh_33",error:"_error_1nruh_41"},dQ=({onSubmit:e,defaultValues:M,onCancel:t,error:i,isCreatingMetric:u})=>{var D,j;const{register:N,handleSubmit:n,setValue:r,formState:{errors:a}}=eE();return ue.useEffect(()=>{M&&(r("name",M.name),r("description",M.description),r("metricId",M.metricId))},[M]),x.jsxs("form",{onSubmit:n(e),children:[x.jsxs("div",{className:cF.container,children:[x.jsx(MM,{name:"name",type:"text",placeholder:"What is the name of metric?",label:"Metric Name",register:N("name",{required:{value:!0,message:"Metric name is required"}}),error:(D=a.name)==null?void 0:D.message,defaultValue:M==null?void 0:M.name}),x.jsx(MM,{name:"name",type:"text",placeholder:"Unique Id to identify metric",label:"Metric ID",error:(j=a.metricId)==null?void 0:j.message,register:N("metricId",{required:{value:!0,message:"Metric ID is required"}}),defaultValue:M==null?void 0:M.metricId}),x.jsx(dPe,{className:cF.field,id:"desc",placeholder:"What is the name of metric?",label:"Description",rows:5,register:N("description"),defaultValue:M==null?void 0:M.description})]}),!!i&&x.jsx(Ye,{variant:"body-text-sm",color:"alert",children:i}),x.jsxs(mw,{children:[x.jsx(yt,{type:"reset",variant:"tab",onClick:t,children:"Cancel"}),x.jsx(yt,{type:"submit",variant:"primary",isDisabled:u,children:"Save"})]})]})},R4={wrapper:"_wrapper_huol6_1",valueWrapper:"_valueWrapper_huol6_9",label:"_label_huol6_15",value:"_value_huol6_9",noOptions:"_noOptions_huol6_31",floatingLabel:"_floatingLabel_huol6_39",badge:"_badge_huol6_47",floatingLabel2:"_floatingLabel2_huol6_61",floating2:"_floating2_huol6_69",floatingText:"_floatingText_huol6_77",staticText:"_staticText_huol6_85",staticLabel:"_staticLabel_huol6_87",InnerText:"_InnerText_huol6_89",normalText:"_normalText_huol6_97",staticValueWrapper:"_staticValueWrapper_huol6_105",selectedOption:"_selectedOption_huol6_121",dropdown:"_dropdown_huol6_129",options:"_options_huol6_137",optionsWrapper:"_optionsWrapper_huol6_145",checkedOption:"_checkedOption_huol6_153",optionSelected:"_optionSelected_huol6_161",option:"_option_huol6_137",icon:"_icon_huol6_177",text:"_text_huol6_185",search:"_search_huol6_193",loadMore:"_loadMore_huol6_201",loadMoreIcon:"_loadMoreIcon_huol6_209",optionDiv:"_optionDiv_huol6_217",optionWrapper1:"_optionWrapper1_huol6_225",optionWrapper2:"_optionWrapper2_huol6_233",dropContainer:"_dropContainer_huol6_241",subValue:"_subValue_huol6_257",labelWithIcon:"_labelWithIcon_huol6_265",tableDiv:"_tableDiv_huol6_273",searchDiv:"_searchDiv_huol6_281",rotate:"_rotate_huol6_289"},Vn=({label:e,labelVariant:M="static",selectedOption:t,onChange:i,button:u,options:N,isDisabled:n,icon:r,buttonWidth:a="220px",menuWidth:D,isSearchEnabled:j,searchIcon:o,closeControl:s,searchPlaceholder:L,isShowSelectedOptions:g=!1,radius:c,isFilter:l})=>{var $,X;const[I,z]=ue.useState(!1),[O,f]=ue.useState(""),[S,E]=ue.useState(20),p=ue.useRef(null),[Q,k]=ue.useState([0,6]),v=ue.useRef(null),[h,w]=ue.useState(!1),[m,Y]=ue.useState(0),R=ue.useRef([]),P=ue.useRef(null),[V,H]=ue.useState([]),Z=()=>{var re,je,ge;const B=I?400:(((re=v.current)==null?void 0:re.offsetWidth)||0)-(((je=P.current)==null?void 0:je.offsetWidth)||0)-30;let K=0,te=t==null?void 0:t.length,ee=!1;for(let ze=0;ze<te;ze+=1)if(K+=V[ze]+5,K>B){te=ze,ee=!0;break}K+(((ge=P.current)==null?void 0:ge.offsetWidth)||0)>B&&(te>1&&(te=Math.max(0,te-1)),ee=!0),w(ee),Y(te)};ue.useEffect(()=>{Z()},[t,N,I]),ue.useEffect(()=>{s!=null&&s.close&&z(!1)},[s==null?void 0:s.close]);const G=ue.useMemo(()=>O?N.filter(B=>B.label.toLowerCase().includes(O)).slice(0,S)||[]:N.slice(0,S),[O,N,S]);return ue.useEffect(()=>{const B=p.current;if(!B)return;const K=B.getBoundingClientRect().height;k([0,-K-6])},[t]),x.jsx(ia,{position:"bottom-start",menuWidth:D||"auto",buttonWidth:I?"auto":a,isDisabled:n,offset:Q,tabMenu:!0,getIsOpen:B=>{z(B)},buttonContent:x.jsxs(x.Fragment,{children:[e&&M==="static"?x.jsx(x.Fragment,{children:l?x.jsx("span",{className:"dbn-text-sm dbn-leading-5 dbn-font-medium dbn-inline-block dbn-font-sans dbn-selectBox",children:e}):x.jsx(Ye,{variant:"input-label",color:"primary",children:e})}):null,x.jsxs("div",{className:`${R4.wrapper} ${l?"dbn-selectBox":""}`,style:{opacity:n?.6:1,cursor:n?"not-allowed":"pointer",borderRadius:c||"4px",minWidth:a,maxWidth:"500px"},ref:v,children:[x.jsxs("div",{className:R4.valueWrapper,children:[e&&M==="floating"?x.jsx("div",{className:`${R4.floatingLabel} ${l?"dbn-selectBox":""}`,children:e}):null,x.jsx("div",{className:R4.value,children:M==="static"?x.jsxs("div",{className:R4.staticValueWrapper,children:[r,x.jsx("div",{children:(t==null?void 0:t.length)>0?t.slice(0,m).map((B,K)=>{const te=R.current[K];return te&&!V[K]&&H(ee=>[...ee,te.offsetWidth]),x.jsx("span",{className:`${R4.badge} dbn-truncate`,title:B==null?void 0:B.label,ref:ee=>{R.current[K]=ee},children:B==null?void 0:B.label},`badge-${K}`)}):x.jsx("span",{children:"Select Options"})}),h&&x.jsxs("span",{className:`${R4.badge} dbn-truncate`,ref:P,children:["+",(t==null?void 0:t.length)-m," more"]})]}):x.jsx("span",{className:`dbn-text-sm dbn-leading-5 dbn-font-normal dbn-font-sans ${l?"dbn-selectBox":""}`,children:M==="floating"?x.jsxs("div",{className:"dbn-flex",children:[(t==null?void 0:t.length)>0?t.slice(0,m).map((B,K)=>{var ee;const te=R.current[K];return te&&!V[K]&&H(re=>[...re,te.offsetWidth]),x.jsx("span",{className:`${R4.badge} dbn-truncate`,title:B==null?void 0:B.label,ref:re=>{R.current[K]=re},children:((ee=N==null?void 0:N.find(re=>re.value===(B==null?void 0:B.value)))==null?void 0:ee.label)||(B==null?void 0:B.label)},`badge-${K}`)}):x.jsx("span",{children:"Select Options"}),h&&x.jsxs("span",{className:`${R4.badge} dbn-truncate`,ref:P,title:(X=($=t==null?void 0:t.slice(m))==null?void 0:$.map(B=>B==null?void 0:B.label))==null?void 0:X.join(`
990
- `),children:["+",(t==null?void 0:t.length)-m," more"]})]}):null})})]}),x.jsx("div",{children:x.jsx(xt,{name:"chevron-down",color:"gray"})})]}),g&&x.jsx("div",{className:"dbn-flex dbn-gap-1 dbn-flex-wrap dbn-mt-4",ref:p,children:(t==null?void 0:t.length)>0&&(t==null?void 0:t.map(B=>x.jsx(x.Fragment,{children:x.jsx("div",{className:R4.selectedOption,children:B.label})})))})]}),children:x.jsxs("div",{className:R4.dropdown,children:[x.jsxs("div",{className:R4.options,children:[j&&x.jsxs("div",{className:R4.searchDiv,children:[o||null,x.jsx(Hw,{setSearchKeyword:f,placeholder:L})]}),!(G!=null&&G.length)&&x.jsx("div",{className:R4.noOptions,children:"Not Available"}),x.jsxs("div",{className:R4.optionsWrapper,children:[G==null?void 0:G.map(B=>{const K=!!(t!=null&&t.find(te=>(te==null?void 0:te.value)===(B==null?void 0:B.value)));return x.jsx("div",{className:K?R4.checkedOption:R4.option,onClick:()=>{const te=t==null?void 0:t.findIndex(ee=>(ee==null?void 0:ee.value)===(B==null?void 0:B.value));if(te!==-1){const ee=t==null?void 0:t.filter((re,je)=>je!==te);i(ee)}else i([...t,B])},children:x.jsx("div",{className:R4.optionDiv,children:x.jsx("div",{className:R4.optionWrapper1,children:x.jsxs("div",{className:R4.labelWithIcon,children:[x.jsx(w3,{onClick:()=>{const te=t==null?void 0:t.findIndex(ee=>(ee==null?void 0:ee.value)===(B==null?void 0:B.value));if(te!==-1){const ee=t==null?void 0:t.filter((re,je)=>je!==te);i(ee)}else i([...t,B])},checked:(t==null?void 0:t.findIndex(te=>(te==null?void 0:te.value)===(B==null?void 0:B.value)))!==-1}),x.jsx("span",{className:`${R4.optionLabel}`,children:B.label})]})})})},B.key||B.value)}),S<=N.length&&x.jsx(yt,{variant:"tab",type:"button",onClick:()=>E(B=>B+20),rightIcon:x.jsx(xt,{name:"chevron-down"}),fitContainer:!0,"data-closepopover":"remainOpen",children:"Load More"})]}),(t==null?void 0:t.length)>0&&x.jsx(yt,{variant:"tab",type:"button",onClick:()=>i([]),fitContainer:!0,"data-closepopover":"remainOpen",children:"Clear All"})]}),u||null]})})},e4={wrapper:"_wrapper_1dz65_1",valueWrapper:"_valueWrapper_1dz65_9",md:"_md_1dz65_17",xl:"_xl_1dz65_25",label:"_label_1dz65_33",label2:"_label2_1dz65_41","label-md":"_label-md_1dz65_49","label-sm":"_label-sm_1dz65_57",value:"_value_1dz65_9",floatingValueWrapper:"_floatingValueWrapper_1dz65_73",noOptions:"_noOptions_1dz65_89",floatingLabel:"_floatingLabel_1dz65_97",badge:"_badge_1dz65_105",floatingLabel2:"_floatingLabel2_1dz65_113",floating2:"_floating2_1dz65_121",floatingText:"_floatingText_1dz65_129",staticText:"_staticText_1dz65_137",staticLabel:"_staticLabel_1dz65_139",InnerText:"_InnerText_1dz65_141",normalText:"_normalText_1dz65_149",staticValueWrapper:"_staticValueWrapper_1dz65_157",dropdown:"_dropdown_1dz65_173",options:"_options_1dz65_189",checkedOption:"_checkedOption_1dz65_197",option:"_option_1dz65_189",option2:"_option2_1dz65_211",icon:"_icon_1dz65_219",text:"_text_1dz65_227",searchTab:"_searchTab_1dz65_235",loadMore:"_loadMore_1dz65_243",loadMoreIcon:"_loadMoreIcon_1dz65_251",optionDiv:"_optionDiv_1dz65_259",optionWrapper1:"_optionWrapper1_1dz65_267",optionWrapper2:"_optionWrapper2_1dz65_275",dropContainer:"_dropContainer_1dz65_283",subValue:"_subValue_1dz65_297",subValue2:"_subValue2_1dz65_303",subValText:"_subValText_1dz65_309",labelWithIcon:"_labelWithIcon_1dz65_315",labelWithIcon2:"_labelWithIcon2_1dz65_321",popOption:"_popOption_1dz65_329"},zi=({label:e,labelVariant:M="static",selectedOption:t,onChange:i,button:u,options:N=[],isDisabled:n,customButton:r,icon:a,buttonWidth:D="200px",buttonHeight:j,menuWidth:o="200px",size:s,isSearchEnabled:L,searchPlaceholder:g,placeholder:c,children:l,radius:I,isFilter:z,disableAutoClose:O=!1,isClearEnabled:f})=>{var H,Z;const[S,E]=ue.useState(""),[p,Q]=ue.useState(20),[k,v]=ue.useState(!1),h=((H=N==null?void 0:N.find(G=>G.value===(t==null?void 0:t.value)))==null?void 0:H.label)||t.label||t.value,w=t.badge,m=t.icon,Y={width:a||(Z=N==null?void 0:N[0])!=null&&Z.badge?"70%":"100%"},R=ue.useMemo(()=>S?N.filter(G=>G.label.toString().toLowerCase().includes(S)).slice(0,p)||[]:(N==null?void 0:N.slice(0,p))||[],[S,N,p]),P=ue.useMemo(()=>f&&(t==null?void 0:t.value),[f,t==null?void 0:t.value]),V=ue.useMemo(()=>{if(P)switch(D){case"130px":return"dbn-w-[70%]";case"180px":case"250px":default:return"dbn-w-[88%]"}return""},[P,D]);return x.jsx(ia,{tabMenu:O,buttonWidth:D,isDisabled:n,position:"bottom-start",menuWidth:o,offset:[0,6],isClearEnabled:f,isMenuOpen:f?k:void 0,setMenuOpen:v,buttonContent:x.jsxs(x.Fragment,{children:[e&&M==="static"?x.jsx(x.Fragment,{children:z?x.jsx("span",{className:"dbn-text-xs dbn-leading-6 dbn-font-normal dbn-inline-block dbn-font-sans dbn-selectBox",children:e}):x.jsx(Ye,{variant:"input-label",color:"primary-title",children:e})}):null,x.jsxs("div",{className:`${e4.wrapper} ${z?"dbn-selectBox":""} ${s?e4[s]:""}`,style:{opacity:n?.6:1,cursor:n?"not-allowed":"pointer",borderRadius:I||"6px",height:j||"36px"},children:[x.jsxs("div",{className:`${e4.valueWrapper} ${V}`,onClick:()=>v(!k),children:[e&&M==="floating"?x.jsx("div",{className:`${e4.floatingLabel} ${z?"dbn-selectBox":""}`,children:e}):null,x.jsx("div",{className:e4.value,children:r||x.jsxs(x.Fragment,{children:[M==="static"&&x.jsxs("div",{className:e4.staticValueWrapper,children:[m?x.jsx(xt,{name:m}):null,x.jsx("div",{className:`${e4.staticLabel} ${z?"dbn-selectBox":""}`,children:h||c||"Select an option"}),w?x.jsx("span",{className:e4.badge,children:w}):null]}),M==="floating"?x.jsxs("div",{className:e4.floatingValueWrapper,children:[x.jsx("span",{className:z?"dbn-selectBox":"",children:h||c||"Select an option"}),w?x.jsx("span",{className:e4.badge,children:w}):null]}):null]})})]}),x.jsxs("div",{className:"dbn-flex dbn-gap-1",children:[P?x.jsx(yt,{variant:"popover",leftIcon:x.jsx(xt,{name:"cross",size:"xs"}),onClick:()=>i({value:"",label:""})}):null,x.jsx(yt,{variant:"popover",className:P?"dbn-border-l dbn-border-secondary dbn-pl-1":"",leftIcon:x.jsx(xt,{name:"chevron-down",size:"xs",color:"gray"}),onClick:()=>v(!k)})]})]})]}),children:x.jsxs("div",{className:e4.dropdown,children:[L&&x.jsx("div",{className:e4.searchTab,children:x.jsx(Hw,{setSearchKeyword:E,placeholder:g})}),x.jsx("div",{className:e4.options,children:R!=null&&R.length?x.jsxs(x.Fragment,{children:[R==null?void 0:R.map(G=>{var B;const $=((B=G==null?void 0:G.labelType)==null?void 0:B.toLowerCase())==="custom"?"remainOpen":"",X=G.value===t.value;return x.jsx("div",{className:X?e4.checkedOption:e4.option,"data-closepopover":$,onClick:()=>i(G),children:x.jsxs("div",{className:e4.optionDiv,children:[x.jsxs("div",{className:e4.optionWrapper1,style:Y,children:[x.jsxs("div",{className:e4.labelWithIcon,children:[G.icon?x.jsx(xt,{name:G.icon}):null,x.jsx("span",{className:e4.label,children:G.label})]}),G.subValue?x.jsx("span",{className:e4.subValue,children:G.subValue}):null]}),a||G.badge?x.jsxs("div",{className:e4.optionWrapper2,children:[a||null,G.badge?x.jsx("span",{className:e4.badge,children:G.badge}):null]}):null]})},G.key||G.value)}),p<=N.length&&x.jsx(yt,{variant:"tab",type:"button",onClick:()=>Q(G=>G+20),rightIcon:x.jsx(xt,{name:"chevron-down"}),fitContainer:!0,"data-closepopover":"remainOpen",children:"Load More"})]}):x.jsx("div",{className:e4.noOptions,children:"Not Available"})}),l||u?x.jsx("div",{className:e4.footerBtn,children:l||u||null}):null]})})},TF=ue.createContext({isLoading:void 0,data:void 0,token:void 0}),_5=()=>ue.useContext(TF);function tE(e,M){return tE=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,u){return i.__proto__=u,i},tE(e,M)}function Gl(e,M){e.prototype=Object.create(M.prototype),e.prototype.constructor=e,tE(e,M)}var mz=function(){function e(){this.listeners=[]}var M=e.prototype;return M.subscribe=function(i){var u=this,N=i||function(){};return this.listeners.push(N),this.onSubscribe(),function(){u.listeners=u.listeners.filter(function(n){return n!==N}),u.onUnsubscribe()}},M.hasListeners=function(){return this.listeners.length>0},M.onSubscribe=function(){},M.onUnsubscribe=function(){},e}();function zu(){return zu=Object.assign?Object.assign.bind():function(e){for(var M=1;M<arguments.length;M++){var t=arguments[M];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},zu.apply(this,arguments)}var ME=typeof window>"u";function jr(){}function mse(e,M){return typeof e=="function"?e(M):e}function fQ(e){return typeof e=="number"&&e>=0&&e!==1/0}function iE(e){return Array.isArray(e)?e:[e]}function lF(e,M){return Math.max(e+(M||0)-Date.now(),0)}function uE(e,M,t){return R5(e)?typeof M=="function"?zu({},t,{queryKey:e,queryFn:M}):zu({},M,{queryKey:e}):e}function bse(e,M,t){return R5(e)?typeof M=="function"?zu({},t,{mutationKey:e,mutationFn:M}):zu({},M,{mutationKey:e}):typeof e=="function"?zu({},M,{mutationFn:e}):zu({},e)}function x1(e,M,t){return R5(e)?[zu({},M,{queryKey:e}),t]:[e||{},M]}function _se(e,M){if(e===!0&&M===!0||e==null&&M==null)return"all";if(e===!1&&M===!1)return"none";var t=e??!M;return t?"active":"inactive"}function yF(e,M){var t=e.active,i=e.exact,u=e.fetching,N=e.inactive,n=e.predicate,r=e.queryKey,a=e.stale;if(R5(r)){if(i){if(M.queryHash!==CQ(r,M.options))return!1}else if(!NE(M.queryKey,r))return!1}var D=_se(t,N);if(D==="none")return!1;if(D!=="all"){var j=M.isActive();if(D==="active"&&!j||D==="inactive"&&j)return!1}return!(typeof a=="boolean"&&M.isStale()!==a||typeof u=="boolean"&&M.isFetching()!==u||n&&!n(M))}function IF(e,M){var t=e.exact,i=e.fetching,u=e.predicate,N=e.mutationKey;if(R5(N)){if(!M.options.mutationKey)return!1;if(t){if(Bl(M.options.mutationKey)!==Bl(N))return!1}else if(!NE(M.options.mutationKey,N))return!1}return!(typeof i=="boolean"&&M.state.status==="loading"!==i||u&&!u(M))}function CQ(e,M){var t=(M==null?void 0:M.queryKeyHashFn)||Bl;return t(e)}function Bl(e){var M=iE(e);return Rse(M)}function Rse(e){return JSON.stringify(e,function(M,t){return wQ(t)?Object.keys(t).sort().reduce(function(i,u){return i[u]=t[u],i},{}):t})}function NE(e,M){return zF(iE(e),iE(M))}function zF(e,M){return e===M?!0:typeof e!=typeof M?!1:e&&M&&typeof e=="object"&&typeof M=="object"?!Object.keys(M).some(function(t){return!zF(e[t],M[t])}):!1}function nE(e,M){if(e===M)return e;var t=Array.isArray(e)&&Array.isArray(M);if(t||wQ(e)&&wQ(M)){for(var i=t?e.length:Object.keys(e).length,u=t?M:Object.keys(M),N=u.length,n=t?[]:{},r=0,a=0;a<N;a++){var D=t?a:u[a];n[D]=nE(e[D],M[D]),n[D]===e[D]&&r++}return i===N&&r===i?e:n}return M}function Pse(e,M){if(e&&!M||M&&!e)return!1;for(var t in e)if(e[t]!==M[t])return!1;return!0}function wQ(e){if(!AF(e))return!1;var M=e.constructor;if(typeof M>"u")return!0;var t=M.prototype;return!(!AF(t)||!t.hasOwnProperty("isPrototypeOf"))}function AF(e){return Object.prototype.toString.call(e)==="[object Object]"}function R5(e){return typeof e=="string"||Array.isArray(e)}function Fse(e){return new Promise(function(M){setTimeout(M,e)})}function OF(e){Promise.resolve().then(e).catch(function(M){return setTimeout(function(){throw M})})}function xF(){if(typeof AbortController=="function")return new AbortController}var Gse=function(e){Gl(M,e);function M(){var i;return i=e.call(this)||this,i.setup=function(u){var N;if(!ME&&((N=window)!=null&&N.addEventListener)){var n=function(){return u()};return window.addEventListener("visibilitychange",n,!1),window.addEventListener("focus",n,!1),function(){window.removeEventListener("visibilitychange",n),window.removeEventListener("focus",n)}}},i}var t=M.prototype;return t.onSubscribe=function(){this.cleanup||this.setEventListener(this.setup)},t.onUnsubscribe=function(){if(!this.hasListeners()){var u;(u=this.cleanup)==null||u.call(this),this.cleanup=void 0}},t.setEventListener=function(u){var N,n=this;this.setup=u,(N=this.cleanup)==null||N.call(this),this.cleanup=u(function(r){typeof r=="boolean"?n.setFocused(r):n.onFocus()})},t.setFocused=function(u){this.focused=u,u&&this.onFocus()},t.onFocus=function(){this.listeners.forEach(function(u){u()})},t.isFocused=function(){return typeof this.focused=="boolean"?this.focused:typeof document>"u"?!0:[void 0,"visible","prerender"].includes(document.visibilityState)},M}(mz),P5=new Gse,Bse=function(e){Gl(M,e);function M(){var i;return i=e.call(this)||this,i.setup=function(u){var N;if(!ME&&((N=window)!=null&&N.addEventListener)){var n=function(){return u()};return window.addEventListener("online",n,!1),window.addEventListener("offline",n,!1),function(){window.removeEventListener("online",n),window.removeEventListener("offline",n)}}},i}var t=M.prototype;return t.onSubscribe=function(){this.cleanup||this.setEventListener(this.setup)},t.onUnsubscribe=function(){if(!this.hasListeners()){var u;(u=this.cleanup)==null||u.call(this),this.cleanup=void 0}},t.setEventListener=function(u){var N,n=this;this.setup=u,(N=this.cleanup)==null||N.call(this),this.cleanup=u(function(r){typeof r=="boolean"?n.setOnline(r):n.onOnline()})},t.setOnline=function(u){this.online=u,u&&this.onOnline()},t.onOnline=function(){this.listeners.forEach(function(u){u()})},t.isOnline=function(){return typeof this.online=="boolean"?this.online:typeof navigator>"u"||typeof navigator.onLine>"u"?!0:navigator.onLine},M}(mz),rE=new Bse;function Vse(e){return Math.min(1e3*Math.pow(2,e),3e4)}function aE(e){return typeof(e==null?void 0:e.cancel)=="function"}var SF=function(M){this.revert=M==null?void 0:M.revert,this.silent=M==null?void 0:M.silent};function jE(e){return e instanceof SF}var EF=function(M){var t=this,i=!1,u,N,n,r;this.abort=M.abort,this.cancel=function(s){return u==null?void 0:u(s)},this.cancelRetry=function(){i=!0},this.continueRetry=function(){i=!1},this.continue=function(){return N==null?void 0:N()},this.failureCount=0,this.isPaused=!1,this.isResolved=!1,this.isTransportCancelable=!1,this.promise=new Promise(function(s,L){n=s,r=L});var a=function(L){t.isResolved||(t.isResolved=!0,M.onSuccess==null||M.onSuccess(L),N==null||N(),n(L))},D=function(L){t.isResolved||(t.isResolved=!0,M.onError==null||M.onError(L),N==null||N(),r(L))},j=function(){return new Promise(function(L){N=L,t.isPaused=!0,M.onPause==null||M.onPause()}).then(function(){N=void 0,t.isPaused=!1,M.onContinue==null||M.onContinue()})},o=function s(){if(!t.isResolved){var L;try{L=M.fn()}catch(g){L=Promise.reject(g)}u=function(c){if(!t.isResolved&&(D(new SF(c)),t.abort==null||t.abort(),aE(L)))try{L.cancel()}catch{}},t.isTransportCancelable=aE(L),Promise.resolve(L).then(a).catch(function(g){var c,l;if(!t.isResolved){var I=(c=M.retry)!=null?c:3,z=(l=M.retryDelay)!=null?l:Vse,O=typeof z=="function"?z(t.failureCount,g):z,f=I===!0||typeof I=="number"&&t.failureCount<I||typeof I=="function"&&I(t.failureCount,g);if(i||!f){D(g);return}t.failureCount++,M.onFail==null||M.onFail(t.failureCount,g),Fse(O).then(function(){if(!P5.isFocused()||!rE.isOnline())return j()}).then(function(){i?D(g):s()})}})}};o()},Wse=function(){function e(){this.queue=[],this.transactions=0,this.notifyFn=function(t){t()},this.batchNotifyFn=function(t){t()}}var M=e.prototype;return M.batch=function(i){var u;this.transactions++;try{u=i()}finally{this.transactions--,this.transactions||this.flush()}return u},M.schedule=function(i){var u=this;this.transactions?this.queue.push(i):OF(function(){u.notifyFn(i)})},M.batchCalls=function(i){var u=this;return function(){for(var N=arguments.length,n=new Array(N),r=0;r<N;r++)n[r]=arguments[r];u.schedule(function(){i.apply(void 0,n)})}},M.flush=function(){var i=this,u=this.queue;this.queue=[],u.length&&OF(function(){i.batchNotifyFn(function(){u.forEach(function(N){i.notifyFn(N)})})})},M.setNotifyFunction=function(i){this.notifyFn=i},M.setBatchNotifyFunction=function(i){this.batchNotifyFn=i},e}(),t4=new Wse,dF=console;function DE(){return dF}function Hse(e){dF=e}var $se=function(){function e(t){this.abortSignalConsumed=!1,this.hadObservers=!1,this.defaultOptions=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.cache=t.cache,this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.initialState=t.state||this.getDefaultState(this.options),this.state=this.initialState,this.meta=t.meta,this.scheduleGc()}var M=e.prototype;return M.setOptions=function(i){var u;this.options=zu({},this.defaultOptions,i),this.meta=i==null?void 0:i.meta,this.cacheTime=Math.max(this.cacheTime||0,(u=this.options.cacheTime)!=null?u:5*60*1e3)},M.setDefaultOptions=function(i){this.defaultOptions=i},M.scheduleGc=function(){var i=this;this.clearGcTimeout(),fQ(this.cacheTime)&&(this.gcTimeout=setTimeout(function(){i.optionalRemove()},this.cacheTime))},M.clearGcTimeout=function(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)},M.optionalRemove=function(){this.observers.length||(this.state.isFetching?this.hadObservers&&this.scheduleGc():this.cache.remove(this))},M.setData=function(i,u){var N,n,r=this.state.data,a=mse(i,r);return(N=(n=this.options).isDataEqual)!=null&&N.call(n,r,a)?a=r:this.options.structuralSharing!==!1&&(a=nE(r,a)),this.dispatch({data:a,type:"success",dataUpdatedAt:u==null?void 0:u.updatedAt}),a},M.setState=function(i,u){this.dispatch({type:"setState",state:i,setStateOptions:u})},M.cancel=function(i){var u,N=this.promise;return(u=this.retryer)==null||u.cancel(i),N?N.then(jr).catch(jr):Promise.resolve()},M.destroy=function(){this.clearGcTimeout(),this.cancel({silent:!0})},M.reset=function(){this.destroy(),this.setState(this.initialState)},M.isActive=function(){return this.observers.some(function(i){return i.options.enabled!==!1})},M.isFetching=function(){return this.state.isFetching},M.isStale=function(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(function(i){return i.getCurrentResult().isStale})},M.isStaleByTime=function(i){return i===void 0&&(i=0),this.state.isInvalidated||!this.state.dataUpdatedAt||!lF(this.state.dataUpdatedAt,i)},M.onFocus=function(){var i,u=this.observers.find(function(N){return N.shouldFetchOnWindowFocus()});u&&u.refetch(),(i=this.retryer)==null||i.continue()},M.onOnline=function(){var i,u=this.observers.find(function(N){return N.shouldFetchOnReconnect()});u&&u.refetch(),(i=this.retryer)==null||i.continue()},M.addObserver=function(i){this.observers.indexOf(i)===-1&&(this.observers.push(i),this.hadObservers=!0,this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:i}))},M.removeObserver=function(i){this.observers.indexOf(i)!==-1&&(this.observers=this.observers.filter(function(u){return u!==i}),this.observers.length||(this.retryer&&(this.retryer.isTransportCancelable||this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.cacheTime?this.scheduleGc():this.cache.remove(this)),this.cache.notify({type:"observerRemoved",query:this,observer:i}))},M.getObserversCount=function(){return this.observers.length},M.invalidate=function(){this.state.isInvalidated||this.dispatch({type:"invalidate"})},M.fetch=function(i,u){var N=this,n,r,a;if(this.state.isFetching){if(this.state.dataUpdatedAt&&(u!=null&&u.cancelRefetch))this.cancel({silent:!0});else if(this.promise){var D;return(D=this.retryer)==null||D.continueRetry(),this.promise}}if(i&&this.setOptions(i),!this.options.queryFn){var j=this.observers.find(function(z){return z.options.queryFn});j&&this.setOptions(j.options)}var o=iE(this.queryKey),s=xF(),L={queryKey:o,pageParam:void 0,meta:this.meta};Object.defineProperty(L,"signal",{enumerable:!0,get:function(){if(s)return N.abortSignalConsumed=!0,s.signal}});var g=function(){return N.options.queryFn?(N.abortSignalConsumed=!1,N.options.queryFn(L)):Promise.reject("Missing queryFn")},c={fetchOptions:u,options:this.options,queryKey:o,state:this.state,fetchFn:g,meta:this.meta};if((n=this.options.behavior)!=null&&n.onFetch){var l;(l=this.options.behavior)==null||l.onFetch(c)}if(this.revertState=this.state,!this.state.isFetching||this.state.fetchMeta!==((r=c.fetchOptions)==null?void 0:r.meta)){var I;this.dispatch({type:"fetch",meta:(I=c.fetchOptions)==null?void 0:I.meta})}return this.retryer=new EF({fn:c.fetchFn,abort:s==null||(a=s.abort)==null?void 0:a.bind(s),onSuccess:function(O){N.setData(O),N.cache.config.onSuccess==null||N.cache.config.onSuccess(O,N),N.cacheTime===0&&N.optionalRemove()},onError:function(O){jE(O)&&O.silent||N.dispatch({type:"error",error:O}),jE(O)||(N.cache.config.onError==null||N.cache.config.onError(O,N),DE().error(O)),N.cacheTime===0&&N.optionalRemove()},onFail:function(){N.dispatch({type:"failed"})},onPause:function(){N.dispatch({type:"pause"})},onContinue:function(){N.dispatch({type:"continue"})},retry:c.options.retry,retryDelay:c.options.retryDelay}),this.promise=this.retryer.promise,this.promise},M.dispatch=function(i){var u=this;this.state=this.reducer(this.state,i),t4.batch(function(){u.observers.forEach(function(N){N.onQueryUpdate(i)}),u.cache.notify({query:u,type:"queryUpdated",action:i})})},M.getDefaultState=function(i){var u=typeof i.initialData=="function"?i.initialData():i.initialData,N=typeof i.initialData<"u",n=N?typeof i.initialDataUpdatedAt=="function"?i.initialDataUpdatedAt():i.initialDataUpdatedAt:0,r=typeof u<"u";return{data:u,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchMeta:null,isFetching:!1,isInvalidated:!1,isPaused:!1,status:r?"success":"idle"}},M.reducer=function(i,u){var N,n;switch(u.type){case"failed":return zu({},i,{fetchFailureCount:i.fetchFailureCount+1});case"pause":return zu({},i,{isPaused:!0});case"continue":return zu({},i,{isPaused:!1});case"fetch":return zu({},i,{fetchFailureCount:0,fetchMeta:(N=u.meta)!=null?N:null,isFetching:!0,isPaused:!1},!i.dataUpdatedAt&&{error:null,status:"loading"});case"success":return zu({},i,{data:u.data,dataUpdateCount:i.dataUpdateCount+1,dataUpdatedAt:(n=u.dataUpdatedAt)!=null?n:Date.now(),error:null,fetchFailureCount:0,isFetching:!1,isInvalidated:!1,isPaused:!1,status:"success"});case"error":var r=u.error;return jE(r)&&r.revert&&this.revertState?zu({},this.revertState):zu({},i,{error:r,errorUpdateCount:i.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:i.fetchFailureCount+1,isFetching:!1,isPaused:!1,status:"error"});case"invalidate":return zu({},i,{isInvalidated:!0});case"setState":return zu({},i,u.state);default:return i}},e}(),Zse=function(e){Gl(M,e);function M(i){var u;return u=e.call(this)||this,u.config=i||{},u.queries=[],u.queriesMap={},u}var t=M.prototype;return t.build=function(u,N,n){var r,a=N.queryKey,D=(r=N.queryHash)!=null?r:CQ(a,N),j=this.get(D);return j||(j=new $se({cache:this,queryKey:a,queryHash:D,options:u.defaultQueryOptions(N),state:n,defaultOptions:u.getQueryDefaults(a),meta:N.meta}),this.add(j)),j},t.add=function(u){this.queriesMap[u.queryHash]||(this.queriesMap[u.queryHash]=u,this.queries.push(u),this.notify({type:"queryAdded",query:u}))},t.remove=function(u){var N=this.queriesMap[u.queryHash];N&&(u.destroy(),this.queries=this.queries.filter(function(n){return n!==u}),N===u&&delete this.queriesMap[u.queryHash],this.notify({type:"queryRemoved",query:u}))},t.clear=function(){var u=this;t4.batch(function(){u.queries.forEach(function(N){u.remove(N)})})},t.get=function(u){return this.queriesMap[u]},t.getAll=function(){return this.queries},t.find=function(u,N){var n=x1(u,N),r=n[0];return typeof r.exact>"u"&&(r.exact=!0),this.queries.find(function(a){return yF(r,a)})},t.findAll=function(u,N){var n=x1(u,N),r=n[0];return Object.keys(r).length>0?this.queries.filter(function(a){return yF(r,a)}):this.queries},t.notify=function(u){var N=this;t4.batch(function(){N.listeners.forEach(function(n){n(u)})})},t.onFocus=function(){var u=this;t4.batch(function(){u.queries.forEach(function(N){N.onFocus()})})},t.onOnline=function(){var u=this;t4.batch(function(){u.queries.forEach(function(N){N.onOnline()})})},M}(mz),Jse=function(){function e(t){this.options=zu({},t.defaultOptions,t.options),this.mutationId=t.mutationId,this.mutationCache=t.mutationCache,this.observers=[],this.state=t.state||fF(),this.meta=t.meta}var M=e.prototype;return M.setState=function(i){this.dispatch({type:"setState",state:i})},M.addObserver=function(i){this.observers.indexOf(i)===-1&&this.observers.push(i)},M.removeObserver=function(i){this.observers=this.observers.filter(function(u){return u!==i})},M.cancel=function(){return this.retryer?(this.retryer.cancel(),this.retryer.promise.then(jr).catch(jr)):Promise.resolve()},M.continue=function(){return this.retryer?(this.retryer.continue(),this.retryer.promise):this.execute()},M.execute=function(){var i=this,u,N=this.state.status==="loading",n=Promise.resolve();return N||(this.dispatch({type:"loading",variables:this.options.variables}),n=n.then(function(){i.mutationCache.config.onMutate==null||i.mutationCache.config.onMutate(i.state.variables,i)}).then(function(){return i.options.onMutate==null?void 0:i.options.onMutate(i.state.variables)}).then(function(r){r!==i.state.context&&i.dispatch({type:"loading",context:r,variables:i.state.variables})})),n.then(function(){return i.executeMutation()}).then(function(r){u=r,i.mutationCache.config.onSuccess==null||i.mutationCache.config.onSuccess(u,i.state.variables,i.state.context,i)}).then(function(){return i.options.onSuccess==null?void 0:i.options.onSuccess(u,i.state.variables,i.state.context)}).then(function(){return i.options.onSettled==null?void 0:i.options.onSettled(u,null,i.state.variables,i.state.context)}).then(function(){return i.dispatch({type:"success",data:u}),u}).catch(function(r){return i.mutationCache.config.onError==null||i.mutationCache.config.onError(r,i.state.variables,i.state.context,i),DE().error(r),Promise.resolve().then(function(){return i.options.onError==null?void 0:i.options.onError(r,i.state.variables,i.state.context)}).then(function(){return i.options.onSettled==null?void 0:i.options.onSettled(void 0,r,i.state.variables,i.state.context)}).then(function(){throw i.dispatch({type:"error",error:r}),r})})},M.executeMutation=function(){var i=this,u;return this.retryer=new EF({fn:function(){return i.options.mutationFn?i.options.mutationFn(i.state.variables):Promise.reject("No mutationFn found")},onFail:function(){i.dispatch({type:"failed"})},onPause:function(){i.dispatch({type:"pause"})},onContinue:function(){i.dispatch({type:"continue"})},retry:(u=this.options.retry)!=null?u:0,retryDelay:this.options.retryDelay}),this.retryer.promise},M.dispatch=function(i){var u=this;this.state=Xse(this.state,i),t4.batch(function(){u.observers.forEach(function(N){N.onMutationUpdate(i)}),u.mutationCache.notify(u)})},e}();function fF(){return{context:void 0,data:void 0,error:null,failureCount:0,isPaused:!1,status:"idle",variables:void 0}}function Xse(e,M){switch(M.type){case"failed":return zu({},e,{failureCount:e.failureCount+1});case"pause":return zu({},e,{isPaused:!0});case"continue":return zu({},e,{isPaused:!1});case"loading":return zu({},e,{context:M.context,data:void 0,error:null,isPaused:!1,status:"loading",variables:M.variables});case"success":return zu({},e,{data:M.data,error:null,status:"success",isPaused:!1});case"error":return zu({},e,{data:void 0,error:M.error,failureCount:e.failureCount+1,isPaused:!1,status:"error"});case"setState":return zu({},e,M.state);default:return e}}var Kse=function(e){Gl(M,e);function M(i){var u;return u=e.call(this)||this,u.config=i||{},u.mutations=[],u.mutationId=0,u}var t=M.prototype;return t.build=function(u,N,n){var r=new Jse({mutationCache:this,mutationId:++this.mutationId,options:u.defaultMutationOptions(N),state:n,defaultOptions:N.mutationKey?u.getMutationDefaults(N.mutationKey):void 0,meta:N.meta});return this.add(r),r},t.add=function(u){this.mutations.push(u),this.notify(u)},t.remove=function(u){this.mutations=this.mutations.filter(function(N){return N!==u}),u.cancel(),this.notify(u)},t.clear=function(){var u=this;t4.batch(function(){u.mutations.forEach(function(N){u.remove(N)})})},t.getAll=function(){return this.mutations},t.find=function(u){return typeof u.exact>"u"&&(u.exact=!0),this.mutations.find(function(N){return IF(u,N)})},t.findAll=function(u){return this.mutations.filter(function(N){return IF(u,N)})},t.notify=function(u){var N=this;t4.batch(function(){N.listeners.forEach(function(n){n(u)})})},t.onFocus=function(){this.resumePausedMutations()},t.onOnline=function(){this.resumePausedMutations()},t.resumePausedMutations=function(){var u=this.mutations.filter(function(N){return N.state.isPaused});return t4.batch(function(){return u.reduce(function(N,n){return N.then(function(){return n.continue().catch(jr)})},Promise.resolve())})},M}(mz);function qse(){return{onFetch:function(M){M.fetchFn=function(){var t,i,u,N,n,r,a=(t=M.fetchOptions)==null||(i=t.meta)==null?void 0:i.refetchPage,D=(u=M.fetchOptions)==null||(N=u.meta)==null?void 0:N.fetchMore,j=D==null?void 0:D.pageParam,o=(D==null?void 0:D.direction)==="forward",s=(D==null?void 0:D.direction)==="backward",L=((n=M.state.data)==null?void 0:n.pages)||[],g=((r=M.state.data)==null?void 0:r.pageParams)||[],c=xF(),l=c==null?void 0:c.signal,I=g,z=!1,O=M.options.queryFn||function(){return Promise.reject("Missing queryFn")},f=function(Y,R,P,V){return I=V?[R].concat(I):[].concat(I,[R]),V?[P].concat(Y):[].concat(Y,[P])},S=function(Y,R,P,V){if(z)return Promise.reject("Cancelled");if(typeof P>"u"&&!R&&Y.length)return Promise.resolve(Y);var H={queryKey:M.queryKey,signal:l,pageParam:P,meta:M.meta},Z=O(H),G=Promise.resolve(Z).then(function(X){return f(Y,P,X,V)});if(aE(Z)){var $=G;$.cancel=Z.cancel}return G},E;if(!L.length)E=S([]);else if(o){var p=typeof j<"u",Q=p?j:CF(M.options,L);E=S(L,p,Q)}else if(s){var k=typeof j<"u",v=k?j:eLe(M.options,L);E=S(L,k,v,!0)}else(function(){I=[];var m=typeof M.options.getNextPageParam>"u",Y=a&&L[0]?a(L[0],0,L):!0;E=Y?S([],m,g[0]):Promise.resolve(f([],g[0],L[0]));for(var R=function(H){E=E.then(function(Z){var G=a&&L[H]?a(L[H],H,L):!0;if(G){var $=m?g[H]:CF(M.options,Z);return S(Z,m,$)}return Promise.resolve(f(Z,g[H],L[H]))})},P=1;P<L.length;P++)R(P)})();var h=E.then(function(m){return{pages:m,pageParams:I}}),w=h;return w.cancel=function(){z=!0,c==null||c.abort(),aE(E)&&E.cancel()},h}}}}function CF(e,M){return e.getNextPageParam==null?void 0:e.getNextPageParam(M[M.length-1],M)}function eLe(e,M){return e.getPreviousPageParam==null?void 0:e.getPreviousPageParam(M[0],M)}var tLe=function(){function e(t){t===void 0&&(t={}),this.queryCache=t.queryCache||new Zse,this.mutationCache=t.mutationCache||new Kse,this.defaultOptions=t.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[]}var M=e.prototype;return M.mount=function(){var i=this;this.unsubscribeFocus=P5.subscribe(function(){P5.isFocused()&&rE.isOnline()&&(i.mutationCache.onFocus(),i.queryCache.onFocus())}),this.unsubscribeOnline=rE.subscribe(function(){P5.isFocused()&&rE.isOnline()&&(i.mutationCache.onOnline(),i.queryCache.onOnline())})},M.unmount=function(){var i,u;(i=this.unsubscribeFocus)==null||i.call(this),(u=this.unsubscribeOnline)==null||u.call(this)},M.isFetching=function(i,u){var N=x1(i,u),n=N[0];return n.fetching=!0,this.queryCache.findAll(n).length},M.isMutating=function(i){return this.mutationCache.findAll(zu({},i,{fetching:!0})).length},M.getQueryData=function(i,u){var N;return(N=this.queryCache.find(i,u))==null?void 0:N.state.data},M.getQueriesData=function(i){return this.getQueryCache().findAll(i).map(function(u){var N=u.queryKey,n=u.state,r=n.data;return[N,r]})},M.setQueryData=function(i,u,N){var n=uE(i),r=this.defaultQueryOptions(n);return this.queryCache.build(this,r).setData(u,N)},M.setQueriesData=function(i,u,N){var n=this;return t4.batch(function(){return n.getQueryCache().findAll(i).map(function(r){var a=r.queryKey;return[a,n.setQueryData(a,u,N)]})})},M.getQueryState=function(i,u){var N;return(N=this.queryCache.find(i,u))==null?void 0:N.state},M.removeQueries=function(i,u){var N=x1(i,u),n=N[0],r=this.queryCache;t4.batch(function(){r.findAll(n).forEach(function(a){r.remove(a)})})},M.resetQueries=function(i,u,N){var n=this,r=x1(i,u,N),a=r[0],D=r[1],j=this.queryCache,o=zu({},a,{active:!0});return t4.batch(function(){return j.findAll(a).forEach(function(s){s.reset()}),n.refetchQueries(o,D)})},M.cancelQueries=function(i,u,N){var n=this,r=x1(i,u,N),a=r[0],D=r[1],j=D===void 0?{}:D;typeof j.revert>"u"&&(j.revert=!0);var o=t4.batch(function(){return n.queryCache.findAll(a).map(function(s){return s.cancel(j)})});return Promise.all(o).then(jr).catch(jr)},M.invalidateQueries=function(i,u,N){var n,r,a,D=this,j=x1(i,u,N),o=j[0],s=j[1],L=zu({},o,{active:(n=(r=o.refetchActive)!=null?r:o.active)!=null?n:!0,inactive:(a=o.refetchInactive)!=null?a:!1});return t4.batch(function(){return D.queryCache.findAll(o).forEach(function(g){g.invalidate()}),D.refetchQueries(L,s)})},M.refetchQueries=function(i,u,N){var n=this,r=x1(i,u,N),a=r[0],D=r[1],j=t4.batch(function(){return n.queryCache.findAll(a).map(function(s){return s.fetch(void 0,zu({},D,{meta:{refetchPage:a==null?void 0:a.refetchPage}}))})}),o=Promise.all(j).then(jr);return D!=null&&D.throwOnError||(o=o.catch(jr)),o},M.fetchQuery=function(i,u,N){var n=uE(i,u,N),r=this.defaultQueryOptions(n);typeof r.retry>"u"&&(r.retry=!1);var a=this.queryCache.build(this,r);return a.isStaleByTime(r.staleTime)?a.fetch(r):Promise.resolve(a.state.data)},M.prefetchQuery=function(i,u,N){return this.fetchQuery(i,u,N).then(jr).catch(jr)},M.fetchInfiniteQuery=function(i,u,N){var n=uE(i,u,N);return n.behavior=qse(),this.fetchQuery(n)},M.prefetchInfiniteQuery=function(i,u,N){return this.fetchInfiniteQuery(i,u,N).then(jr).catch(jr)},M.cancelMutations=function(){var i=this,u=t4.batch(function(){return i.mutationCache.getAll().map(function(N){return N.cancel()})});return Promise.all(u).then(jr).catch(jr)},M.resumePausedMutations=function(){return this.getMutationCache().resumePausedMutations()},M.executeMutation=function(i){return this.mutationCache.build(this,i).execute()},M.getQueryCache=function(){return this.queryCache},M.getMutationCache=function(){return this.mutationCache},M.getDefaultOptions=function(){return this.defaultOptions},M.setDefaultOptions=function(i){this.defaultOptions=i},M.setQueryDefaults=function(i,u){var N=this.queryDefaults.find(function(n){return Bl(i)===Bl(n.queryKey)});N?N.defaultOptions=u:this.queryDefaults.push({queryKey:i,defaultOptions:u})},M.getQueryDefaults=function(i){var u;return i?(u=this.queryDefaults.find(function(N){return NE(i,N.queryKey)}))==null?void 0:u.defaultOptions:void 0},M.setMutationDefaults=function(i,u){var N=this.mutationDefaults.find(function(n){return Bl(i)===Bl(n.mutationKey)});N?N.defaultOptions=u:this.mutationDefaults.push({mutationKey:i,defaultOptions:u})},M.getMutationDefaults=function(i){var u;return i?(u=this.mutationDefaults.find(function(N){return NE(i,N.mutationKey)}))==null?void 0:u.defaultOptions:void 0},M.defaultQueryOptions=function(i){if(i!=null&&i._defaulted)return i;var u=zu({},this.defaultOptions.queries,this.getQueryDefaults(i==null?void 0:i.queryKey),i,{_defaulted:!0});return!u.queryHash&&u.queryKey&&(u.queryHash=CQ(u.queryKey,u)),u},M.defaultQueryObserverOptions=function(i){return this.defaultQueryOptions(i)},M.defaultMutationOptions=function(i){return i!=null&&i._defaulted?i:zu({},this.defaultOptions.mutations,this.getMutationDefaults(i==null?void 0:i.mutationKey),i,{_defaulted:!0})},M.clear=function(){this.queryCache.clear(),this.mutationCache.clear()},e}(),MLe=function(e){Gl(M,e);function M(i,u){var N;return N=e.call(this)||this,N.client=i,N.options=u,N.trackedProps=[],N.selectError=null,N.bindMethods(),N.setOptions(u),N}var t=M.prototype;return t.bindMethods=function(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)},t.onSubscribe=function(){this.listeners.length===1&&(this.currentQuery.addObserver(this),wF(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())},t.onUnsubscribe=function(){this.listeners.length||this.destroy()},t.shouldFetchOnReconnect=function(){return hQ(this.currentQuery,this.options,this.options.refetchOnReconnect)},t.shouldFetchOnWindowFocus=function(){return hQ(this.currentQuery,this.options,this.options.refetchOnWindowFocus)},t.destroy=function(){this.listeners=[],this.clearTimers(),this.currentQuery.removeObserver(this)},t.setOptions=function(u,N){var n=this.options,r=this.currentQuery;if(this.options=this.client.defaultQueryObserverOptions(u),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=n.queryKey),this.updateQuery();var a=this.hasListeners();a&&hF(this.currentQuery,r,this.options,n)&&this.executeFetch(),this.updateResult(N),a&&(this.currentQuery!==r||this.options.enabled!==n.enabled||this.options.staleTime!==n.staleTime)&&this.updateStaleTimeout();var D=this.computeRefetchInterval();a&&(this.currentQuery!==r||this.options.enabled!==n.enabled||D!==this.currentRefetchInterval)&&this.updateRefetchInterval(D)},t.getOptimisticResult=function(u){var N=this.client.defaultQueryObserverOptions(u),n=this.client.getQueryCache().build(this.client,N);return this.createResult(n,N)},t.getCurrentResult=function(){return this.currentResult},t.trackResult=function(u,N){var n=this,r={},a=function(j){n.trackedProps.includes(j)||n.trackedProps.push(j)};return Object.keys(u).forEach(function(D){Object.defineProperty(r,D,{configurable:!1,enumerable:!0,get:function(){return a(D),u[D]}})}),(N.useErrorBoundary||N.suspense)&&a("error"),r},t.getNextResult=function(u){var N=this;return new Promise(function(n,r){var a=N.subscribe(function(D){D.isFetching||(a(),D.isError&&(u!=null&&u.throwOnError)?r(D.error):n(D))})})},t.getCurrentQuery=function(){return this.currentQuery},t.remove=function(){this.client.getQueryCache().remove(this.currentQuery)},t.refetch=function(u){return this.fetch(zu({},u,{meta:{refetchPage:u==null?void 0:u.refetchPage}}))},t.fetchOptimistic=function(u){var N=this,n=this.client.defaultQueryObserverOptions(u),r=this.client.getQueryCache().build(this.client,n);return r.fetch().then(function(){return N.createResult(r,n)})},t.fetch=function(u){var N=this;return this.executeFetch(u).then(function(){return N.updateResult(),N.currentResult})},t.executeFetch=function(u){this.updateQuery();var N=this.currentQuery.fetch(this.options,u);return u!=null&&u.throwOnError||(N=N.catch(jr)),N},t.updateStaleTimeout=function(){var u=this;if(this.clearStaleTimeout(),!(ME||this.currentResult.isStale||!fQ(this.options.staleTime))){var N=lF(this.currentResult.dataUpdatedAt,this.options.staleTime),n=N+1;this.staleTimeoutId=setTimeout(function(){u.currentResult.isStale||u.updateResult()},n)}},t.computeRefetchInterval=function(){var u;return typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.currentResult.data,this.currentQuery):(u=this.options.refetchInterval)!=null?u:!1},t.updateRefetchInterval=function(u){var N=this;this.clearRefetchInterval(),this.currentRefetchInterval=u,!(ME||this.options.enabled===!1||!fQ(this.currentRefetchInterval)||this.currentRefetchInterval===0)&&(this.refetchIntervalId=setInterval(function(){(N.options.refetchIntervalInBackground||P5.isFocused())&&N.executeFetch()},this.currentRefetchInterval))},t.updateTimers=function(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())},t.clearTimers=function(){this.clearStaleTimeout(),this.clearRefetchInterval()},t.clearStaleTimeout=function(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)},t.clearRefetchInterval=function(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)},t.createResult=function(u,N){var n=this.currentQuery,r=this.options,a=this.currentResult,D=this.currentResultState,j=this.currentResultOptions,o=u!==n,s=o?u.state:this.currentQueryInitialState,L=o?this.currentResult:this.previousQueryResult,g=u.state,c=g.dataUpdatedAt,l=g.error,I=g.errorUpdatedAt,z=g.isFetching,O=g.status,f=!1,S=!1,E;if(N.optimisticResults){var p=this.hasListeners(),Q=!p&&wF(u,N),k=p&&hF(u,n,N,r);(Q||k)&&(z=!0,c||(O="loading"))}if(N.keepPreviousData&&!g.dataUpdateCount&&(L!=null&&L.isSuccess)&&O!=="error")E=L.data,c=L.dataUpdatedAt,O=L.status,f=!0;else if(N.select&&typeof g.data<"u")if(a&&g.data===(D==null?void 0:D.data)&&N.select===this.selectFn)E=this.selectResult;else try{this.selectFn=N.select,E=N.select(g.data),N.structuralSharing!==!1&&(E=nE(a==null?void 0:a.data,E)),this.selectResult=E,this.selectError=null}catch(w){DE().error(w),this.selectError=w}else E=g.data;if(typeof N.placeholderData<"u"&&typeof E>"u"&&(O==="loading"||O==="idle")){var v;if(a!=null&&a.isPlaceholderData&&N.placeholderData===(j==null?void 0:j.placeholderData))v=a.data;else if(v=typeof N.placeholderData=="function"?N.placeholderData():N.placeholderData,N.select&&typeof v<"u")try{v=N.select(v),N.structuralSharing!==!1&&(v=nE(a==null?void 0:a.data,v)),this.selectError=null}catch(w){DE().error(w),this.selectError=w}typeof v<"u"&&(O="success",E=v,S=!0)}this.selectError&&(l=this.selectError,E=this.selectResult,I=Date.now(),O="error");var h={status:O,isLoading:O==="loading",isSuccess:O==="success",isError:O==="error",isIdle:O==="idle",data:E,dataUpdatedAt:c,error:l,errorUpdatedAt:I,failureCount:g.fetchFailureCount,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>s.dataUpdateCount||g.errorUpdateCount>s.errorUpdateCount,isFetching:z,isRefetching:z&&O!=="loading",isLoadingError:O==="error"&&g.dataUpdatedAt===0,isPlaceholderData:S,isPreviousData:f,isRefetchError:O==="error"&&g.dataUpdatedAt!==0,isStale:pQ(u,N),refetch:this.refetch,remove:this.remove};return h},t.shouldNotifyListeners=function(u,N){if(!N)return!0;var n=this.options,r=n.notifyOnChangeProps,a=n.notifyOnChangePropsExclusions;if(!r&&!a||r==="tracked"&&!this.trackedProps.length)return!0;var D=r==="tracked"?this.trackedProps:r;return Object.keys(u).some(function(j){var o=j,s=u[o]!==N[o],L=D==null?void 0:D.some(function(c){return c===j}),g=a==null?void 0:a.some(function(c){return c===j});return s&&!g&&(!D||L)})},t.updateResult=function(u){var N=this.currentResult;if(this.currentResult=this.createResult(this.currentQuery,this.options),this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,!Pse(this.currentResult,N)){var n={cache:!0};(u==null?void 0:u.listeners)!==!1&&this.shouldNotifyListeners(this.currentResult,N)&&(n.listeners=!0),this.notify(zu({},n,u))}},t.updateQuery=function(){var u=this.client.getQueryCache().build(this.client,this.options);if(u!==this.currentQuery){var N=this.currentQuery;this.currentQuery=u,this.currentQueryInitialState=u.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(N==null||N.removeObserver(this),u.addObserver(this))}},t.onQueryUpdate=function(u){var N={};u.type==="success"?N.onSuccess=!0:u.type==="error"&&!jE(u.error)&&(N.onError=!0),this.updateResult(N),this.hasListeners()&&this.updateTimers()},t.notify=function(u){var N=this;t4.batch(function(){u.onSuccess?(N.options.onSuccess==null||N.options.onSuccess(N.currentResult.data),N.options.onSettled==null||N.options.onSettled(N.currentResult.data,null)):u.onError&&(N.options.onError==null||N.options.onError(N.currentResult.error),N.options.onSettled==null||N.options.onSettled(void 0,N.currentResult.error)),u.listeners&&N.listeners.forEach(function(n){n(N.currentResult)}),u.cache&&N.client.getQueryCache().notify({query:N.currentQuery,type:"observerResultsUpdated"})})},M}(mz);function iLe(e,M){return M.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&M.retryOnMount===!1)}function wF(e,M){return iLe(e,M)||e.state.dataUpdatedAt>0&&hQ(e,M,M.refetchOnMount)}function hQ(e,M,t){if(M.enabled!==!1){var i=typeof t=="function"?t(e):t;return i==="always"||i!==!1&&pQ(e,M)}return!1}function hF(e,M,t,i){return t.enabled!==!1&&(e!==M||i.enabled===!1)&&(!t.suspense||e.state.status!=="error")&&pQ(e,t)}function pQ(e,M){return e.isStaleByTime(M.staleTime)}var uLe=function(e){Gl(M,e);function M(i,u){var N;return N=e.call(this)||this,N.client=i,N.setOptions(u),N.bindMethods(),N.updateResult(),N}var t=M.prototype;return t.bindMethods=function(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)},t.setOptions=function(u){this.options=this.client.defaultMutationOptions(u)},t.onUnsubscribe=function(){if(!this.listeners.length){var u;(u=this.currentMutation)==null||u.removeObserver(this)}},t.onMutationUpdate=function(u){this.updateResult();var N={listeners:!0};u.type==="success"?N.onSuccess=!0:u.type==="error"&&(N.onError=!0),this.notify(N)},t.getCurrentResult=function(){return this.currentResult},t.reset=function(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})},t.mutate=function(u,N){return this.mutateOptions=N,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,zu({},this.options,{variables:typeof u<"u"?u:this.options.variables})),this.currentMutation.addObserver(this),this.currentMutation.execute()},t.updateResult=function(){var u=this.currentMutation?this.currentMutation.state:fF(),N=zu({},u,{isLoading:u.status==="loading",isSuccess:u.status==="success",isError:u.status==="error",isIdle:u.status==="idle",mutate:this.mutate,reset:this.reset});this.currentResult=N},t.notify=function(u){var N=this;t4.batch(function(){N.mutateOptions&&(u.onSuccess?(N.mutateOptions.onSuccess==null||N.mutateOptions.onSuccess(N.currentResult.data,N.currentResult.variables,N.currentResult.context),N.mutateOptions.onSettled==null||N.mutateOptions.onSettled(N.currentResult.data,null,N.currentResult.variables,N.currentResult.context)):u.onError&&(N.mutateOptions.onError==null||N.mutateOptions.onError(N.currentResult.error,N.currentResult.variables,N.currentResult.context),N.mutateOptions.onSettled==null||N.mutateOptions.onSettled(void 0,N.currentResult.error,N.currentResult.variables,N.currentResult.context))),u.listeners&&N.listeners.forEach(function(n){n(N.currentResult)})})},M}(mz),NLe=kS.unstable_batchedUpdates;t4.setBatchNotifyFunction(NLe);var nLe=console;Hse(nLe);var pF=Ge.createContext(void 0),QF=Ge.createContext(!1);function vF(e){return e&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=pF),window.ReactQueryClientContext):pF}var oE=function(){var M=Ge.useContext(vF(Ge.useContext(QF)));if(!M)throw new Error("No QueryClient set, use QueryClientProvider to set one");return M},rLe=function(M){var t=M.client,i=M.contextSharing,u=i===void 0?!1:i,N=M.children;Ge.useEffect(function(){return t.mount(),function(){t.unmount()}},[t]);var n=vF(u);return Ge.createElement(QF.Provider,{value:u},Ge.createElement(n.Provider,{value:t},N))};function aLe(){var e=!1;return{clearReset:function(){e=!1},reset:function(){e=!0},isReset:function(){return e}}}var jLe=Ge.createContext(aLe()),DLe=function(){return Ge.useContext(jLe)};function kF(e,M,t){return typeof M=="function"?M.apply(void 0,t):typeof M=="boolean"?M:!!e}function Zr(e,M,t){var i=Ge.useRef(!1),u=Ge.useState(0),N=u[1],n=bse(e,M,t),r=oE(),a=Ge.useRef();a.current?a.current.setOptions(n):a.current=new uLe(r,n);var D=a.current.getCurrentResult();Ge.useEffect(function(){i.current=!0;var o=a.current.subscribe(t4.batchCalls(function(){i.current&&N(function(s){return s+1})}));return function(){i.current=!1,o()}},[]);var j=Ge.useCallback(function(o,s){a.current.mutate(o,s).catch(jr)},[]);if(D.error&&kF(void 0,a.current.options.useErrorBoundary,[D.error]))throw D.error;return zu({},D,{mutate:j,mutateAsync:D.mutate})}function oLe(e,M){var t=Ge.useRef(!1),i=Ge.useState(0),u=i[1],N=oE(),n=DLe(),r=N.defaultQueryObserverOptions(e);r.optimisticResults=!0,r.onError&&(r.onError=t4.batchCalls(r.onError)),r.onSuccess&&(r.onSuccess=t4.batchCalls(r.onSuccess)),r.onSettled&&(r.onSettled=t4.batchCalls(r.onSettled)),r.suspense&&(typeof r.staleTime!="number"&&(r.staleTime=1e3),r.cacheTime===0&&(r.cacheTime=1)),(r.suspense||r.useErrorBoundary)&&(n.isReset()||(r.retryOnMount=!1));var a=Ge.useState(function(){return new M(N,r)}),D=a[0],j=D.getOptimisticResult(r);if(Ge.useEffect(function(){t.current=!0,n.clearReset();var o=D.subscribe(t4.batchCalls(function(){t.current&&u(function(s){return s+1})}));return D.updateResult(),function(){t.current=!1,o()}},[n,D]),Ge.useEffect(function(){D.setOptions(r,{listeners:!1})},[r,D]),r.suspense&&j.isLoading)throw D.fetchOptimistic(r).then(function(o){var s=o.data;r.onSuccess==null||r.onSuccess(s),r.onSettled==null||r.onSettled(s,null)}).catch(function(o){n.clearReset(),r.onError==null||r.onError(o),r.onSettled==null||r.onSettled(void 0,o)});if(j.isError&&!n.isReset()&&!j.isFetching&&kF(r.suspense,r.useErrorBoundary,[j.error,D.getCurrentQuery()]))throw j.error;return r.notifyOnChangeProps==="tracked"&&(j=D.trackResult(j,r)),j}function Vl(e,M,t){var i=uE(e,M,t);return oLe(i,MLe)}const QQ="https://api-uat.usedatabrain.com",Ea="/api/v2/dashboard",S1="/api/v2/metric",UF="/api/v3/metric",YF="dashboardData",sLe=`${Ea}/embeddedMetric`,LLe="embeddedMetric",gLe=`${S1}/layout`,mF="dashboardLayout",cLe=`${Ea}/scheduledReport`,TLe="dashboardScheduledReport",lLe=`${S1}/saveLayout`,yLe="saveLayout",ILe=`${Ea}/saveScheduleReport`,zLe="saveScheduleReport",ALe=`${Ea}/deleteScheduleReport`,OLe="deleteScheduleReport",xLe=`${Ea}/createMetric`,SLe="createMetric",ELe=`${Ea}/updateMetric`,dLe="updateMetric",fLe=`${Ea}/updateAdminMetric`,CLe="updateAdminMetric",wLe=`${Ea}/generateMetric`,hLe="generateMetric",pLe=`${Ea}/datasetMetricCreation`,QLe="datasetMetricCreation",vLe=`${Ea}/previewTable`,kLe="previewTable",ULe=`${Ea}/generatetMetricData`,YLe="/generatetMetricData",mLe=`${Ea}/getOpenaiChatResponse`,bLe="getOpenaiChatResponse",_Le=`${Ea}/getTheme`,RLe="getTheme",PLe=`${UF}/query`,FLe="query",GLe=`${UF}/datasetMetricCreation`,BLe="newDatasetMetricCreation",VLe=`${S1}/rawDownloadSettings`,WLe="rawDownloadSettings",HLe=`${S1}/column`,$Le="column",ZLe=`${S1}/underlyingData`,JLe="underlyingData",XLe=`${S1}/invokeShareCsv`,KLe="invokeShareCsv",qLe=`${S1}/markArchived`,e0e="markArchived",bF=`${S1}/download-csv`,t0e=()=>localStorage.getItem(Mse),o4=async(e,M={method:"GET"})=>{var N;const t={method:M.method,headers:{"Content-Type":"application/json","X-Plugin-Token":M.token||"","X-Plugin-Origin":window.location.host,...M.isFrontend?{"X-Dbn-Secret":M.clientId}:{},...M.isFrontend?{"X-Dbn-token":t0e()||""}:{}}};M.data&&(t.body=JSON.stringify(M.data));const u=await(await fetch(`${((N=window.dbn)==null?void 0:N.baseUrl)||QQ}${e}`,t)).json();if(u.error){const{message:n}=u.error;throw new Error(n)}return u.data},M0e=()=>Zr(yLe,e=>o4(lLe,{method:"POST",data:e})),i0e=()=>Zr(zLe,e=>o4(ILe,{method:"POST",data:e.data,token:e.token})),u0e=()=>Zr(OLe,e=>o4(ALe,{method:"POST",data:e,token:e.token})),N0e=()=>Zr(SLe,({data:e,token:M})=>o4(xLe,{method:"POST",data:e,token:M})),n0e=()=>Zr(dLe,({data:e,token:M})=>o4(ELe,{method:"POST",data:e,token:M})),r0e=()=>Zr(CLe,({data:e,token:M})=>o4(fLe,{method:"POST",data:e,token:M})),a0e=()=>Zr(hLe,({data:e,token:M})=>o4(wLe,{method:"POST",data:e,token:M})),_F=()=>Zr(QLe,({data:e,token:M})=>o4(pLe,{method:"POST",data:e,token:M})),j0e=()=>Zr(kLe,({data:e,token:M})=>o4(vLe,{method:"POST",data:e,token:M})),D0e=()=>Zr(YLe,({data:e,token:M})=>o4(ULe,{method:"POST",data:e,token:M})),o0e=()=>Zr(bLe,({data:e,token:M})=>o4(mLe,{method:"POST",data:e,token:M})),vQ=({onSuccess:e,companyIntegrationId:M,selectedColumns:t,query:i,metricQuery:u,integrationName:N,outputColumns:n,chartSettings:r,clientId:a,companyId:D,isLiveMode:j,timeGrain:o,dashboardIds:s,isEnableGroupBy:L,groupBy:g,selectedGroupBy:c,metric:l,datasetMetricSettings:I})=>{var R,P,V;const{token:z,data:O}=_5(),[f,S]=ue.useState(""),{mutate:E,isLoading:p}=N0e(),{mutate:Q}=j0e(),k=H=>{S(""),E({data:{companyId:D,companyIntegrationId:M,description:H.description,inputFields:t,metricId:H.metricId,name:H.name,query:i,metricQuery:u,integrationName:N,outputColumns:n,createdBy:a||"external user",isLive:j||!1,chartOptions:r,datasetMetricSettings:I,clientId:a||null,isCreatedByClient:!!a,timeGrain:o||null,externalDashboardIds:s.map(Z=>({externalDashboardId:Z})),isEnableGroupBy:L,groupBy:g??{},selectedGroupBy:c},token:z},{onSuccess:Z=>{var G;(G=Z==null?void 0:Z.insert_externalMetrics_one)!=null&&G.id?e():S("Metric Id already exists")},onError:()=>{S&&S("Metric Id already exists")}})},{mutateAsync:v,isLoading:h}=r0e(),{mutateAsync:w,isLoading:m}=n0e(),Y=ue.useCallback(H=>{if(S(""),!(l!=null&&l.isCreatedByClient))v({data:{externalMetricId:l==null?void 0:l.id,clientId:a,object:{companyId:D,companyIntegrationId:M||(l==null?void 0:l.companyIntegrationId),description:H.description,inputFields:t,metricId:H.metricId===(l==null?void 0:l.metricId)?`update_${H.metricId}_by_${a}_${Date.now()}`:H.metricId,name:H.name,query:i,metricQuery:u,datasetMetricSettings:I,integrationName:N,outputColumns:n,createdBy:a||"external user",isCreatedByClient:!!a,resizeAttributes:l==null?void 0:l.resizeAttributes,externalDashboardMetrics:{data:s.map(Z=>({externalDashboardId:Z}))},isLive:j||H.isLive,chartOptions:r}},token:z},{onSuccess:Z=>{!(Z!=null&&Z.insert_clientDeletedMetrics_one)||!(Z!=null&&Z.insert_externalMetrics_one)||(S(""),e())},onError:()=>{S("Something went wrong! Please try again later.")}});else{const Z={chartOptions:r,datasetMetricSettings:I};H.description&&(Z.description=H.description),H.metricId&&(Z.metricId=H.metricId),H.name&&(Z.name=H.name),w({data:{externalMetricId:l==null?void 0:l.id,set:Z},token:z},{onSuccess:G=>{var $;console.log(G),($=G==null?void 0:G.update_externalMetrics_by_pk)!=null&&$.id&&(S(""),e())},onError:()=>{S("Something went wrong! Please try again later.")}})}},[r,l,w,v,a,D,M,N,j,s,i,t,n,u,I]);return{createExternalMetric:k,updateExternalMetric:Y,error:f,isLoading:p||h||m,clientSubsetData:O==null?void 0:O.clientSubsetData,previewTable:Q,token:z,workspaceId:(R=O==null?void 0:O.workspace)==null?void 0:R.id,dashboardOptions:[{value:(P=O==null?void 0:O.externalDashboard)==null?void 0:P.id,label:((V=O==null?void 0:O.externalDashboard)==null?void 0:V.name)||"Dashboard"}],isDatabaseTenancy:(O==null?void 0:O.companyTenancyType)===hz}},RF=()=>Zr($Le,e=>o4(HLe,{method:"POST",data:e})),s0e=()=>Zr(JLe,e=>o4(ZLe,{method:"POST",data:e})),L0e=()=>Zr(KLe,e=>o4(XLe,{method:"POST",data:e})),g0e=()=>Zr(e0e,e=>o4(qLe,{method:"POST",data:e})),c0e=()=>Zr(BLe,({data:e,token:M,clientId:t,isFrontendApp:i})=>o4(GLe,{method:"POST",data:e,isFrontend:i,clientId:t,token:M})),PF=()=>{const{mutate:e,isLoading:M,error:t}=a0e(),{mutate:i}=RF();return{generateDatasetMetric:e,isGeneratingDataset:M,generateError:t,fetchColumnValues:i}};let T0e=0;function l0e(e,M){const t=`atom${++T0e}`,i={toString:()=>t};return typeof e=="function"?i.read=e:(i.init=e,i.read=u=>u(i),i.write=(u,N,n)=>N(i,typeof n=="function"?n(u(i)):n)),M&&(i.write=M),i}const E1=Symbol(),kQ=e=>!!e[E1],sE=e=>!e[E1].c,F5=e=>{var M;const{b:t,c:i}=e[E1];i&&(i(),(M=I0e.get(t))==null||M())},LE=(e,M)=>{const t=e[E1].o,i=M[E1].o;return t===i||e===i||kQ(t)&&LE(t,M)},UQ=(e,M)=>{const t={b:e,o:M,c:null},i=new Promise(u=>{t.c=()=>{t.c=null,u()},M.finally(t.c)});return i[E1]=t,i},y0e=e=>UQ(e[E1].b,e[E1].o),I0e=new WeakMap,gE=e=>"init"in e,YQ="r",mQ="w",cE="c",bQ="s",FF="h",z0e="n",A0e="l",O0e="a",x0e="m",S0e=e=>{const M=new WeakMap,t=new WeakMap,i=new Map;let u,N;if(({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&(u=new Set,N=new Set),e)for(const[G,$]of e){const X={v:$,r:0,y:!0,d:new Map};({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&(Object.freeze(X),gE(G)||console.warn("Found initial value for derived atom which can cause unexpected behavior",G)),M.set(G,X)}const n=new WeakMap,r=(G,$,X)=>{let B=n.get($);B||(B=new Map,n.set($,B)),X.then(()=>{B.get(G)===X&&(B.delete(G),B.size||n.delete($))}),B.set(G,X)},a=G=>{const $=new Set,X=n.get(G);return X&&(n.delete(G),X.forEach((B,K)=>{F5(B),$.add(K)})),$},D=new WeakMap,j=G=>{let $=D.get(G);return $||($=new Map,D.set(G,$)),$},o=(G,$)=>{if(G){const X=j(G);let B=X.get($);return B||(B=o(G.p,$),B&&"p"in B&&sE(B.p)&&(B=void 0),B&&X.set($,B)),B}return M.get($)},s=(G,$,X)=>{if(({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&Object.freeze(X),G)j(G).set($,X);else{const B=M.get($);M.set($,X),i.has($)||i.set($,B)}},L=(G,$=new Map,X)=>{if(!X)return $;const B=new Map;let K=!1;return X.forEach(te=>{var ee;const re=((ee=o(G,te))==null?void 0:ee.r)||0;B.set(te,re),$.get(te)!==re&&(K=!0)}),$.size===B.size&&!K?$:B},g=(G,$,X,B,K)=>{const te=o(G,$);if(te){if(K&&(!("p"in te)||!LE(te.p,K)))return te;"p"in te&&F5(te.p)}const ee={v:X,r:(te==null?void 0:te.r)||0,y:!0,d:L(G,te==null?void 0:te.d,B)};let re=!(te!=null&&te.y);return!te||!("v"in te)||!Object.is(te.v,X)?(re=!0,++ee.r,ee.d.has($)&&(ee.d=new Map(ee.d).set($,ee.r))):ee.d!==te.d&&(ee.d.size!==te.d.size||!Array.from(ee.d.keys()).every(je=>te.d.has(je)))&&(re=!0,Promise.resolve().then(()=>{R(G)})),te&&!re?te:(s(G,$,ee),ee)},c=(G,$,X,B,K)=>{const te=o(G,$);if(te){if(K&&(!("p"in te)||!LE(te.p,K)))return te;"p"in te&&F5(te.p)}const ee={e:X,r:((te==null?void 0:te.r)||0)+1,y:!0,d:L(G,te==null?void 0:te.d,B)};return s(G,$,ee),ee},l=(G,$,X,B)=>{const K=o(G,$);if(K&&"p"in K){if(LE(K.p,X)&&!sE(K.p))return K.y?K:{...K,y:!0};F5(K.p)}r(G,$,X);const te={p:X,r:((K==null?void 0:K.r)||0)+1,y:!0,d:L(G,K==null?void 0:K.d,B)};return s(G,$,te),te},I=(G,$,X,B)=>{if(X instanceof Promise){const K=UQ(X,X.then(te=>{g(G,$,te,B,K)}).catch(te=>{if(te instanceof Promise)return kQ(te)?te.then(()=>{O(G,$,!0)}):te;c(G,$,te,B,K)}));return l(G,$,K,B)}return g(G,$,X,B)},z=(G,$)=>{const X=o(G,$);if(X){const B={...X,y:!1};s(G,$,B)}else({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.warn("[Bug] could not invalidate non existing atom",$)},O=(G,$,X)=>{if(!X){const K=o(G,$);if(K){if(K.y&&"p"in K&&!sE(K.p))return K;if(K.d.forEach((te,ee)=>{if(ee!==$)if(!t.has(ee))O(G,ee);else{const re=o(G,ee);re&&!re.y&&O(G,ee)}}),Array.from(K.d).every(([te,ee])=>{const re=o(G,te);return re&&!("p"in re)&&re.r===ee}))return K.y?K:{...K,y:!0}}}const B=new Set;try{const K=$.read(te=>{B.add(te);const ee=te===$?o(G,te):O(G,te);if(ee){if("e"in ee)throw ee.e;if("p"in ee)throw ee.p;return ee.v}if(gE(te))return te.init;throw new Error("no atom init")});return I(G,$,K,B)}catch(K){if(K instanceof Promise){const te=kQ(K)&&sE(K)?y0e(K):UQ(K,K);return l(G,$,te,B)}return c(G,$,K,B)}},f=(G,$)=>O($,G),S=(G,$)=>{let X=t.get($);return X||(X=w(G,$)),X},E=(G,$)=>!$.l.size&&(!$.t.size||$.t.size===1&&$.t.has(G)),p=(G,$)=>{const X=t.get($);X&&E($,X)&&m(G,$)},Q=(G,$)=>{const X=t.get($);X==null||X.t.forEach(B=>{B!==$&&(z(G,B),Q(G,B))})},k=(G,$,X)=>{let B=!0;const K=(re,je)=>{const ge=O(G,re);if("e"in ge)throw ge.e;if("p"in ge){if(je!=null&&je.unstable_promise)return ge.p.then(()=>{const ze=o(G,re);return ze&&"p"in ze&&ze.p===ge.p?new Promise(Ae=>setTimeout(Ae)).then(()=>K(re,je)):K(re,je)});throw({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",re),ge.p}if("v"in ge)return ge.v;throw({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.warn("[Bug] no value found while reading atom in write operation. This is probably a bug.",re),new Error("no value found")},te=(re,je)=>{let ge;if(re===$){if(!gE(re))throw new Error("atom not writable");a(re).forEach(Xe=>{Xe!==G&&I(Xe,re,je)});const Ae=o(G,re),Te=I(G,re,je);Ae!==Te&&Q(G,re)}else ge=k(G,re,je);return B||R(G),ge},ee=$.write(K,te,X);return B=!1,ee},v=(G,$,X)=>{const B=k(X,G,$);return R(X),B},h=G=>!!G.write,w=(G,$,X)=>{const B={t:new Set(X&&[X]),l:new Set};if(t.set($,B),({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&N.add($),O(void 0,$).d.forEach((te,ee)=>{const re=t.get(ee);re?re.t.add($):ee!==$&&w(G,ee,$)}),h($)&&$.onMount){const te=re=>v($,re,G),ee=$.onMount(te);G=void 0,ee&&(B.u=ee)}return B},m=(G,$)=>{var X;const B=(X=t.get($))==null?void 0:X.u;B&&B(),t.delete($),({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&N.delete($);const K=o(G,$);K?("p"in K&&F5(K.p),K.d.forEach((te,ee)=>{if(ee!==$){const re=t.get(ee);re&&(re.t.delete($),E(ee,re)&&m(G,ee))}})):({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.warn("[Bug] could not find atom state to unmount",$)},Y=(G,$,X,B)=>{const K=new Set(X.d.keys());B==null||B.forEach((te,ee)=>{if(K.has(ee)){K.delete(ee);return}const re=t.get(ee);re&&(re.t.delete($),E(ee,re)&&m(G,ee))}),K.forEach(te=>{const ee=t.get(te);ee?ee.t.add($):t.has($)&&w(G,te,$)})},R=G=>{if(G){j(G).forEach((X,B)=>{const K=M.get(B);if(X!==K){const te=t.get(B);te==null||te.l.forEach(ee=>ee(G))}});return}for(;i.size;){const $=Array.from(i);i.clear(),$.forEach(([X,B])=>{const K=o(void 0,X);if(K&&K.d!==(B==null?void 0:B.d)&&Y(void 0,X,K,B==null?void 0:B.d),B&&!B.y&&(K!=null&&K.y))return;const te=t.get(X);te==null||te.l.forEach(ee=>ee())})}({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&u.forEach($=>$())},P=G=>{j(G).forEach((X,B)=>{const K=M.get(B);(!K||X.r>K.r||X.y!==K.y||X.r===K.r&&X.d!==K.d)&&(M.set(B,X),X.d!==(K==null?void 0:K.d)&&Y(G,B,X,K==null?void 0:K.d))})},V=(G,$)=>{$&&P($),R(void 0)},H=(G,$,X)=>{const K=S(X,G).l;return K.add($),()=>{K.delete($),p(X,G)}},Z=(G,$)=>{for(const[X,B]of G)gE(X)&&(I($,X,B),Q($,X));R($)};return({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"?{[YQ]:f,[mQ]:v,[cE]:V,[bQ]:H,[FF]:Z,[z0e]:G=>(u.add(G),()=>{u.delete(G)}),[A0e]:()=>N.values(),[O0e]:G=>M.get(G),[x0e]:G=>t.get(G)}:{[YQ]:f,[mQ]:v,[cE]:V,[bQ]:H,[FF]:Z}},E0e=(e,M)=>({s:M?M(e).SECRET_INTERNAL_store:S0e(e)}),_Q=new Map,GF=e=>(_Q.has(e)||_Q.set(e,ue.createContext(E0e())),_Q.get(e));function BF(e,M){return l0e(e,M)}function d0e(e,M){const t=GF(M),i=ue.useContext(t),{s:u,v:N}=i,n=s=>{const L=u[YQ](e,s);if(({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&!L.y)throw new Error("should not be invalidated");if("e"in L)throw L.e;if("p"in L)throw L.p;if("v"in L)return L.v;throw new Error("no atom value")},[[r,a,D],j]=ue.useReducer((s,L)=>{const g=n(L);return Object.is(s[1],g)&&s[2]===e?s:[L,g,e]},N,s=>{const L=n(s);return[s,L,e]});let o=a;return D!==e&&(j(r),o=n(r)),ue.useEffect(()=>{const{v:s}=i;s&&u[cE](e,s);const L=u[bQ](e,j,s);return j(s),L},[u,e,i]),ue.useEffect(()=>{u[cE](e,r)}),ue.useDebugValue(o),o}function f0e(e,M){const t=GF(M),{s:i,w:u}=ue.useContext(t);return ue.useCallback(n=>{if(({VITE_END_POINT:"https://api-uat.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&!("write"in e))throw new Error("not writable atom");const r=a=>i[mQ](e,n,a);return u?u(r):r()},[i,u,e])}function RQ(e,M){return"scope"in e&&(console.warn("atom.scope is deprecated. Please do useAtom(atom, scope) instead."),M=e.scope),[d0e(e,M),f0e(e,M)]}const PQ=({onOutsideClick:e,wrapRef:M,portalRef:t})=>{ue.useEffect(()=>{const i=u=>{const N=M.current&&!M.current.contains("composedPath"in u?u.composedPath()[0]:u.target),n=t&&!t.contains("composedPath"in u?u.composedPath()[0]:u.target);t?N&&n&&e():N&&e()};return document.addEventListener("click",i,!0),()=>{document.removeEventListener("click",i,!0)}},[M,e,t])},C0e=({wrapRef:e,portalRef:M,autoCloseParent:t=!1})=>{const[i]=RQ(Zie);ue.useEffect(()=>{const u=N=>{i==null||i.forEach(n=>{var a,D,j,o,s,L;if(!(((a=n.popperElement)==null?void 0:a.contains("composedPath"in N?N.composedPath()[0]:N.target))||((D=n.referenceElement)==null?void 0:D.contains("composedPath"in N?N.composedPath()[0]:N.target)))){const g=i.find(c=>{var I,z;const l=((I=n.popperElement)==null?void 0:I.contains(c.referenceElement))&&(c.isOpen===!0||c.isMenuOpen===!0);return t?l&&((z=c.popperElement)==null?void 0:z.contains("composedPath"in N?N.composedPath()[0]:N.target)):l});g?((j=g==null?void 0:g.setOpen)==null||j.call(g,!0),(o=g==null?void 0:g.setMenuOpen)==null||o.call(g,!0)):((s=n.setOpen)==null||s.call(n,!1),(L=n.setMenuOpen)==null||L.call(n,!1))}})};return document.addEventListener("click",u,!0),()=>{document.removeEventListener("click",u,!0)}},[e,M,i])},w0e=({token:e,dashboardId:M})=>Vl([YF,{dashboardId:M}],()=>{const t=M?`${Ea}?dashboardId=${M}`:Ea;return o4(t,{method:"GET",token:e})},{enabled:!!e}),h0e=(e,M)=>Vl([mF,{dashboardId:e,clientId:M}],()=>o4(`${gLe}?id=${e}&clientId=${M}`,{method:"GET"}),{enabled:!!e&&!!M}),p0e=e=>Vl(TLe,()=>o4(cLe,{method:"GET",token:e}),{enabled:!!e}),Q0e=(e,M)=>Vl([LLe,{id:M}],()=>o4(`${sLe}?metricId=${M}`,{method:"GET",token:e}),{enabled:!!e}),VF=({token:e,name:M,companyId:t})=>Vl([RLe,{name:M}],()=>o4(_Le,{method:"POST",token:e,data:{name:M,companyId:t}}),{enabled:!!(M&&e&&t)}),v0e=({externalDashboardId:e,clientId:M})=>{const t=oE(),{data:i,isLoading:u}=h0e(e,M),[N,n]=ue.useMemo(()=>{const j=i;return[(j==null?void 0:j.layout)||[],!!(j!=null&&j.isLocked)]},[i]),{mutateAsync:r,isLoading:a}=M0e();return{saveLayout:ue.useCallback(async(j,o)=>{await r({clientId:M,externalDashboardId:e,layout:j,isLocked:!!o},{onSuccess:s=>{if(!s)return;const L=s;t.setQueryData([mF,{dashboardId:e,clientId:M}],g=>({...g,...L}))}})},[r,M,e]),layout:N,isLayoutLocked:n,isLoadingLayout:u||a}},k0e=({query:e,limit:M,offset:t,dbName:i})=>{let u=e.replace(/;(^;]*)$/,"");const N=parseInt(M,10);if(u.toLowerCase().includes("limit")){const n=parseInt(u.toLowerCase().split("limit")[1].trim(),10),r=t?M:Math.min(n,N);(i==null?void 0:i.toLowerCase())==U5?(u=u.replace(`limit ${n}`,`order by(select null) ${`offset ${t||0} rows`} fetch next ${r} rows only`),u=u.replace(`LIMIT ${n}`,`ORDER BY(SELECT NULL) ${`OFFSET ${t||0} ROWS`}
990
+ `),children:["+",(t==null?void 0:t.length)-m," more"]})]}):null})})]}),x.jsx("div",{children:x.jsx(xt,{name:"chevron-down",color:"gray"})})]}),g&&x.jsx("div",{className:"dbn-flex dbn-gap-1 dbn-flex-wrap dbn-mt-4",ref:p,children:(t==null?void 0:t.length)>0&&(t==null?void 0:t.map(B=>x.jsx(x.Fragment,{children:x.jsx("div",{className:R4.selectedOption,children:B.label})})))})]}),children:x.jsxs("div",{className:R4.dropdown,children:[x.jsxs("div",{className:R4.options,children:[j&&x.jsxs("div",{className:R4.searchDiv,children:[o||null,x.jsx(Hw,{setSearchKeyword:f,placeholder:L})]}),!(G!=null&&G.length)&&x.jsx("div",{className:R4.noOptions,children:"Not Available"}),x.jsxs("div",{className:R4.optionsWrapper,children:[G==null?void 0:G.map(B=>{const K=!!(t!=null&&t.find(te=>(te==null?void 0:te.value)===(B==null?void 0:B.value)));return x.jsx("div",{className:K?R4.checkedOption:R4.option,onClick:()=>{const te=t==null?void 0:t.findIndex(ee=>(ee==null?void 0:ee.value)===(B==null?void 0:B.value));if(te!==-1){const ee=t==null?void 0:t.filter((re,je)=>je!==te);i(ee)}else i([...t,B])},children:x.jsx("div",{className:R4.optionDiv,children:x.jsx("div",{className:R4.optionWrapper1,children:x.jsxs("div",{className:R4.labelWithIcon,children:[x.jsx(w3,{onClick:()=>{const te=t==null?void 0:t.findIndex(ee=>(ee==null?void 0:ee.value)===(B==null?void 0:B.value));if(te!==-1){const ee=t==null?void 0:t.filter((re,je)=>je!==te);i(ee)}else i([...t,B])},checked:(t==null?void 0:t.findIndex(te=>(te==null?void 0:te.value)===(B==null?void 0:B.value)))!==-1}),x.jsx("span",{className:`${R4.optionLabel}`,children:B.label})]})})})},B.key||B.value)}),S<=N.length&&x.jsx(yt,{variant:"tab",type:"button",onClick:()=>E(B=>B+20),rightIcon:x.jsx(xt,{name:"chevron-down"}),fitContainer:!0,"data-closepopover":"remainOpen",children:"Load More"})]}),(t==null?void 0:t.length)>0&&x.jsx(yt,{variant:"tab",type:"button",onClick:()=>i([]),fitContainer:!0,"data-closepopover":"remainOpen",children:"Clear All"})]}),u||null]})})},e4={wrapper:"_wrapper_1dz65_1",valueWrapper:"_valueWrapper_1dz65_9",md:"_md_1dz65_17",xl:"_xl_1dz65_25",label:"_label_1dz65_33",label2:"_label2_1dz65_41","label-md":"_label-md_1dz65_49","label-sm":"_label-sm_1dz65_57",value:"_value_1dz65_9",floatingValueWrapper:"_floatingValueWrapper_1dz65_73",noOptions:"_noOptions_1dz65_89",floatingLabel:"_floatingLabel_1dz65_97",badge:"_badge_1dz65_105",floatingLabel2:"_floatingLabel2_1dz65_113",floating2:"_floating2_1dz65_121",floatingText:"_floatingText_1dz65_129",staticText:"_staticText_1dz65_137",staticLabel:"_staticLabel_1dz65_139",InnerText:"_InnerText_1dz65_141",normalText:"_normalText_1dz65_149",staticValueWrapper:"_staticValueWrapper_1dz65_157",dropdown:"_dropdown_1dz65_173",options:"_options_1dz65_189",checkedOption:"_checkedOption_1dz65_197",option:"_option_1dz65_189",option2:"_option2_1dz65_211",icon:"_icon_1dz65_219",text:"_text_1dz65_227",searchTab:"_searchTab_1dz65_235",loadMore:"_loadMore_1dz65_243",loadMoreIcon:"_loadMoreIcon_1dz65_251",optionDiv:"_optionDiv_1dz65_259",optionWrapper1:"_optionWrapper1_1dz65_267",optionWrapper2:"_optionWrapper2_1dz65_275",dropContainer:"_dropContainer_1dz65_283",subValue:"_subValue_1dz65_297",subValue2:"_subValue2_1dz65_303",subValText:"_subValText_1dz65_309",labelWithIcon:"_labelWithIcon_1dz65_315",labelWithIcon2:"_labelWithIcon2_1dz65_321",popOption:"_popOption_1dz65_329"},zi=({label:e,labelVariant:M="static",selectedOption:t,onChange:i,button:u,options:N=[],isDisabled:n,customButton:r,icon:a,buttonWidth:D="200px",buttonHeight:j,menuWidth:o="200px",size:s,isSearchEnabled:L,searchPlaceholder:g,placeholder:c,children:l,radius:I,isFilter:z,disableAutoClose:O=!1,isClearEnabled:f})=>{var H,Z;const[S,E]=ue.useState(""),[p,Q]=ue.useState(20),[k,v]=ue.useState(!1),h=((H=N==null?void 0:N.find(G=>G.value===(t==null?void 0:t.value)))==null?void 0:H.label)||t.label||t.value,w=t.badge,m=t.icon,Y={width:a||(Z=N==null?void 0:N[0])!=null&&Z.badge?"70%":"100%"},R=ue.useMemo(()=>S?N.filter(G=>G.label.toString().toLowerCase().includes(S)).slice(0,p)||[]:(N==null?void 0:N.slice(0,p))||[],[S,N,p]),P=ue.useMemo(()=>f&&(t==null?void 0:t.value),[f,t==null?void 0:t.value]),V=ue.useMemo(()=>{if(P)switch(D){case"130px":return"dbn-w-[70%]";case"180px":case"250px":default:return"dbn-w-[88%]"}return""},[P,D]);return x.jsx(ia,{tabMenu:O,buttonWidth:D,isDisabled:n,position:"bottom-start",menuWidth:o,offset:[0,6],isClearEnabled:f,isMenuOpen:f?k:void 0,setMenuOpen:v,buttonContent:x.jsxs(x.Fragment,{children:[e&&M==="static"?x.jsx(x.Fragment,{children:z?x.jsx("span",{className:"dbn-text-xs dbn-leading-6 dbn-font-normal dbn-inline-block dbn-font-sans dbn-selectBox",children:e}):x.jsx(Ye,{variant:"input-label",color:"primary-title",children:e})}):null,x.jsxs("div",{className:`${e4.wrapper} ${z?"dbn-selectBox":""} ${s?e4[s]:""}`,style:{opacity:n?.6:1,cursor:n?"not-allowed":"pointer",borderRadius:I||"6px",height:j||"36px"},children:[x.jsxs("div",{className:`${e4.valueWrapper} ${V}`,onClick:()=>v(!k),children:[e&&M==="floating"?x.jsx("div",{className:`${e4.floatingLabel} ${z?"dbn-selectBox":""}`,children:e}):null,x.jsx("div",{className:e4.value,children:r||x.jsxs(x.Fragment,{children:[M==="static"&&x.jsxs("div",{className:e4.staticValueWrapper,children:[m?x.jsx(xt,{name:m}):null,x.jsx("div",{className:`${e4.staticLabel} ${z?"dbn-selectBox":""}`,children:h||c||"Select an option"}),w?x.jsx("span",{className:e4.badge,children:w}):null]}),M==="floating"?x.jsxs("div",{className:e4.floatingValueWrapper,children:[x.jsx("span",{className:z?"dbn-selectBox":"",children:h||c||"Select an option"}),w?x.jsx("span",{className:e4.badge,children:w}):null]}):null]})})]}),x.jsxs("div",{className:"dbn-flex dbn-gap-1",children:[P?x.jsx(yt,{variant:"popover",leftIcon:x.jsx(xt,{name:"cross",size:"xs"}),onClick:()=>i({value:"",label:""})}):null,x.jsx(yt,{variant:"popover",className:P?"dbn-border-l dbn-border-secondary dbn-pl-1":"",leftIcon:x.jsx(xt,{name:"chevron-down",size:"xs",color:"gray"}),onClick:()=>v(!k)})]})]})]}),children:x.jsxs("div",{className:e4.dropdown,children:[L&&x.jsx("div",{className:e4.searchTab,children:x.jsx(Hw,{setSearchKeyword:E,placeholder:g})}),x.jsx("div",{className:e4.options,children:R!=null&&R.length?x.jsxs(x.Fragment,{children:[R==null?void 0:R.map(G=>{var B;const $=((B=G==null?void 0:G.labelType)==null?void 0:B.toLowerCase())==="custom"?"remainOpen":"",X=G.value===t.value;return x.jsx("div",{className:X?e4.checkedOption:e4.option,"data-closepopover":$,onClick:()=>i(G),children:x.jsxs("div",{className:e4.optionDiv,children:[x.jsxs("div",{className:e4.optionWrapper1,style:Y,children:[x.jsxs("div",{className:e4.labelWithIcon,children:[G.icon?x.jsx(xt,{name:G.icon}):null,x.jsx("span",{className:e4.label,children:G.label})]}),G.subValue?x.jsx("span",{className:e4.subValue,children:G.subValue}):null]}),a||G.badge?x.jsxs("div",{className:e4.optionWrapper2,children:[a||null,G.badge?x.jsx("span",{className:e4.badge,children:G.badge}):null]}):null]})},G.key||G.value)}),p<=N.length&&x.jsx(yt,{variant:"tab",type:"button",onClick:()=>Q(G=>G+20),rightIcon:x.jsx(xt,{name:"chevron-down"}),fitContainer:!0,"data-closepopover":"remainOpen",children:"Load More"})]}):x.jsx("div",{className:e4.noOptions,children:"Not Available"})}),l||u?x.jsx("div",{className:e4.footerBtn,children:l||u||null}):null]})})},TF=ue.createContext({isLoading:void 0,data:void 0,token:void 0}),_5=()=>ue.useContext(TF);function tE(e,M){return tE=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,u){return i.__proto__=u,i},tE(e,M)}function Gl(e,M){e.prototype=Object.create(M.prototype),e.prototype.constructor=e,tE(e,M)}var mz=function(){function e(){this.listeners=[]}var M=e.prototype;return M.subscribe=function(i){var u=this,N=i||function(){};return this.listeners.push(N),this.onSubscribe(),function(){u.listeners=u.listeners.filter(function(n){return n!==N}),u.onUnsubscribe()}},M.hasListeners=function(){return this.listeners.length>0},M.onSubscribe=function(){},M.onUnsubscribe=function(){},e}();function zu(){return zu=Object.assign?Object.assign.bind():function(e){for(var M=1;M<arguments.length;M++){var t=arguments[M];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e},zu.apply(this,arguments)}var ME=typeof window>"u";function jr(){}function mse(e,M){return typeof e=="function"?e(M):e}function fQ(e){return typeof e=="number"&&e>=0&&e!==1/0}function iE(e){return Array.isArray(e)?e:[e]}function lF(e,M){return Math.max(e+(M||0)-Date.now(),0)}function uE(e,M,t){return R5(e)?typeof M=="function"?zu({},t,{queryKey:e,queryFn:M}):zu({},M,{queryKey:e}):e}function bse(e,M,t){return R5(e)?typeof M=="function"?zu({},t,{mutationKey:e,mutationFn:M}):zu({},M,{mutationKey:e}):typeof e=="function"?zu({},M,{mutationFn:e}):zu({},e)}function x1(e,M,t){return R5(e)?[zu({},M,{queryKey:e}),t]:[e||{},M]}function _se(e,M){if(e===!0&&M===!0||e==null&&M==null)return"all";if(e===!1&&M===!1)return"none";var t=e??!M;return t?"active":"inactive"}function yF(e,M){var t=e.active,i=e.exact,u=e.fetching,N=e.inactive,n=e.predicate,r=e.queryKey,a=e.stale;if(R5(r)){if(i){if(M.queryHash!==CQ(r,M.options))return!1}else if(!NE(M.queryKey,r))return!1}var D=_se(t,N);if(D==="none")return!1;if(D!=="all"){var j=M.isActive();if(D==="active"&&!j||D==="inactive"&&j)return!1}return!(typeof a=="boolean"&&M.isStale()!==a||typeof u=="boolean"&&M.isFetching()!==u||n&&!n(M))}function IF(e,M){var t=e.exact,i=e.fetching,u=e.predicate,N=e.mutationKey;if(R5(N)){if(!M.options.mutationKey)return!1;if(t){if(Bl(M.options.mutationKey)!==Bl(N))return!1}else if(!NE(M.options.mutationKey,N))return!1}return!(typeof i=="boolean"&&M.state.status==="loading"!==i||u&&!u(M))}function CQ(e,M){var t=(M==null?void 0:M.queryKeyHashFn)||Bl;return t(e)}function Bl(e){var M=iE(e);return Rse(M)}function Rse(e){return JSON.stringify(e,function(M,t){return wQ(t)?Object.keys(t).sort().reduce(function(i,u){return i[u]=t[u],i},{}):t})}function NE(e,M){return zF(iE(e),iE(M))}function zF(e,M){return e===M?!0:typeof e!=typeof M?!1:e&&M&&typeof e=="object"&&typeof M=="object"?!Object.keys(M).some(function(t){return!zF(e[t],M[t])}):!1}function nE(e,M){if(e===M)return e;var t=Array.isArray(e)&&Array.isArray(M);if(t||wQ(e)&&wQ(M)){for(var i=t?e.length:Object.keys(e).length,u=t?M:Object.keys(M),N=u.length,n=t?[]:{},r=0,a=0;a<N;a++){var D=t?a:u[a];n[D]=nE(e[D],M[D]),n[D]===e[D]&&r++}return i===N&&r===i?e:n}return M}function Pse(e,M){if(e&&!M||M&&!e)return!1;for(var t in e)if(e[t]!==M[t])return!1;return!0}function wQ(e){if(!AF(e))return!1;var M=e.constructor;if(typeof M>"u")return!0;var t=M.prototype;return!(!AF(t)||!t.hasOwnProperty("isPrototypeOf"))}function AF(e){return Object.prototype.toString.call(e)==="[object Object]"}function R5(e){return typeof e=="string"||Array.isArray(e)}function Fse(e){return new Promise(function(M){setTimeout(M,e)})}function OF(e){Promise.resolve().then(e).catch(function(M){return setTimeout(function(){throw M})})}function xF(){if(typeof AbortController=="function")return new AbortController}var Gse=function(e){Gl(M,e);function M(){var i;return i=e.call(this)||this,i.setup=function(u){var N;if(!ME&&((N=window)!=null&&N.addEventListener)){var n=function(){return u()};return window.addEventListener("visibilitychange",n,!1),window.addEventListener("focus",n,!1),function(){window.removeEventListener("visibilitychange",n),window.removeEventListener("focus",n)}}},i}var t=M.prototype;return t.onSubscribe=function(){this.cleanup||this.setEventListener(this.setup)},t.onUnsubscribe=function(){if(!this.hasListeners()){var u;(u=this.cleanup)==null||u.call(this),this.cleanup=void 0}},t.setEventListener=function(u){var N,n=this;this.setup=u,(N=this.cleanup)==null||N.call(this),this.cleanup=u(function(r){typeof r=="boolean"?n.setFocused(r):n.onFocus()})},t.setFocused=function(u){this.focused=u,u&&this.onFocus()},t.onFocus=function(){this.listeners.forEach(function(u){u()})},t.isFocused=function(){return typeof this.focused=="boolean"?this.focused:typeof document>"u"?!0:[void 0,"visible","prerender"].includes(document.visibilityState)},M}(mz),P5=new Gse,Bse=function(e){Gl(M,e);function M(){var i;return i=e.call(this)||this,i.setup=function(u){var N;if(!ME&&((N=window)!=null&&N.addEventListener)){var n=function(){return u()};return window.addEventListener("online",n,!1),window.addEventListener("offline",n,!1),function(){window.removeEventListener("online",n),window.removeEventListener("offline",n)}}},i}var t=M.prototype;return t.onSubscribe=function(){this.cleanup||this.setEventListener(this.setup)},t.onUnsubscribe=function(){if(!this.hasListeners()){var u;(u=this.cleanup)==null||u.call(this),this.cleanup=void 0}},t.setEventListener=function(u){var N,n=this;this.setup=u,(N=this.cleanup)==null||N.call(this),this.cleanup=u(function(r){typeof r=="boolean"?n.setOnline(r):n.onOnline()})},t.setOnline=function(u){this.online=u,u&&this.onOnline()},t.onOnline=function(){this.listeners.forEach(function(u){u()})},t.isOnline=function(){return typeof this.online=="boolean"?this.online:typeof navigator>"u"||typeof navigator.onLine>"u"?!0:navigator.onLine},M}(mz),rE=new Bse;function Vse(e){return Math.min(1e3*Math.pow(2,e),3e4)}function aE(e){return typeof(e==null?void 0:e.cancel)=="function"}var SF=function(M){this.revert=M==null?void 0:M.revert,this.silent=M==null?void 0:M.silent};function jE(e){return e instanceof SF}var EF=function(M){var t=this,i=!1,u,N,n,r;this.abort=M.abort,this.cancel=function(s){return u==null?void 0:u(s)},this.cancelRetry=function(){i=!0},this.continueRetry=function(){i=!1},this.continue=function(){return N==null?void 0:N()},this.failureCount=0,this.isPaused=!1,this.isResolved=!1,this.isTransportCancelable=!1,this.promise=new Promise(function(s,L){n=s,r=L});var a=function(L){t.isResolved||(t.isResolved=!0,M.onSuccess==null||M.onSuccess(L),N==null||N(),n(L))},D=function(L){t.isResolved||(t.isResolved=!0,M.onError==null||M.onError(L),N==null||N(),r(L))},j=function(){return new Promise(function(L){N=L,t.isPaused=!0,M.onPause==null||M.onPause()}).then(function(){N=void 0,t.isPaused=!1,M.onContinue==null||M.onContinue()})},o=function s(){if(!t.isResolved){var L;try{L=M.fn()}catch(g){L=Promise.reject(g)}u=function(c){if(!t.isResolved&&(D(new SF(c)),t.abort==null||t.abort(),aE(L)))try{L.cancel()}catch{}},t.isTransportCancelable=aE(L),Promise.resolve(L).then(a).catch(function(g){var c,l;if(!t.isResolved){var I=(c=M.retry)!=null?c:3,z=(l=M.retryDelay)!=null?l:Vse,O=typeof z=="function"?z(t.failureCount,g):z,f=I===!0||typeof I=="number"&&t.failureCount<I||typeof I=="function"&&I(t.failureCount,g);if(i||!f){D(g);return}t.failureCount++,M.onFail==null||M.onFail(t.failureCount,g),Fse(O).then(function(){if(!P5.isFocused()||!rE.isOnline())return j()}).then(function(){i?D(g):s()})}})}};o()},Wse=function(){function e(){this.queue=[],this.transactions=0,this.notifyFn=function(t){t()},this.batchNotifyFn=function(t){t()}}var M=e.prototype;return M.batch=function(i){var u;this.transactions++;try{u=i()}finally{this.transactions--,this.transactions||this.flush()}return u},M.schedule=function(i){var u=this;this.transactions?this.queue.push(i):OF(function(){u.notifyFn(i)})},M.batchCalls=function(i){var u=this;return function(){for(var N=arguments.length,n=new Array(N),r=0;r<N;r++)n[r]=arguments[r];u.schedule(function(){i.apply(void 0,n)})}},M.flush=function(){var i=this,u=this.queue;this.queue=[],u.length&&OF(function(){i.batchNotifyFn(function(){u.forEach(function(N){i.notifyFn(N)})})})},M.setNotifyFunction=function(i){this.notifyFn=i},M.setBatchNotifyFunction=function(i){this.batchNotifyFn=i},e}(),t4=new Wse,dF=console;function DE(){return dF}function Hse(e){dF=e}var $se=function(){function e(t){this.abortSignalConsumed=!1,this.hadObservers=!1,this.defaultOptions=t.defaultOptions,this.setOptions(t.options),this.observers=[],this.cache=t.cache,this.queryKey=t.queryKey,this.queryHash=t.queryHash,this.initialState=t.state||this.getDefaultState(this.options),this.state=this.initialState,this.meta=t.meta,this.scheduleGc()}var M=e.prototype;return M.setOptions=function(i){var u;this.options=zu({},this.defaultOptions,i),this.meta=i==null?void 0:i.meta,this.cacheTime=Math.max(this.cacheTime||0,(u=this.options.cacheTime)!=null?u:5*60*1e3)},M.setDefaultOptions=function(i){this.defaultOptions=i},M.scheduleGc=function(){var i=this;this.clearGcTimeout(),fQ(this.cacheTime)&&(this.gcTimeout=setTimeout(function(){i.optionalRemove()},this.cacheTime))},M.clearGcTimeout=function(){this.gcTimeout&&(clearTimeout(this.gcTimeout),this.gcTimeout=void 0)},M.optionalRemove=function(){this.observers.length||(this.state.isFetching?this.hadObservers&&this.scheduleGc():this.cache.remove(this))},M.setData=function(i,u){var N,n,r=this.state.data,a=mse(i,r);return(N=(n=this.options).isDataEqual)!=null&&N.call(n,r,a)?a=r:this.options.structuralSharing!==!1&&(a=nE(r,a)),this.dispatch({data:a,type:"success",dataUpdatedAt:u==null?void 0:u.updatedAt}),a},M.setState=function(i,u){this.dispatch({type:"setState",state:i,setStateOptions:u})},M.cancel=function(i){var u,N=this.promise;return(u=this.retryer)==null||u.cancel(i),N?N.then(jr).catch(jr):Promise.resolve()},M.destroy=function(){this.clearGcTimeout(),this.cancel({silent:!0})},M.reset=function(){this.destroy(),this.setState(this.initialState)},M.isActive=function(){return this.observers.some(function(i){return i.options.enabled!==!1})},M.isFetching=function(){return this.state.isFetching},M.isStale=function(){return this.state.isInvalidated||!this.state.dataUpdatedAt||this.observers.some(function(i){return i.getCurrentResult().isStale})},M.isStaleByTime=function(i){return i===void 0&&(i=0),this.state.isInvalidated||!this.state.dataUpdatedAt||!lF(this.state.dataUpdatedAt,i)},M.onFocus=function(){var i,u=this.observers.find(function(N){return N.shouldFetchOnWindowFocus()});u&&u.refetch(),(i=this.retryer)==null||i.continue()},M.onOnline=function(){var i,u=this.observers.find(function(N){return N.shouldFetchOnReconnect()});u&&u.refetch(),(i=this.retryer)==null||i.continue()},M.addObserver=function(i){this.observers.indexOf(i)===-1&&(this.observers.push(i),this.hadObservers=!0,this.clearGcTimeout(),this.cache.notify({type:"observerAdded",query:this,observer:i}))},M.removeObserver=function(i){this.observers.indexOf(i)!==-1&&(this.observers=this.observers.filter(function(u){return u!==i}),this.observers.length||(this.retryer&&(this.retryer.isTransportCancelable||this.abortSignalConsumed?this.retryer.cancel({revert:!0}):this.retryer.cancelRetry()),this.cacheTime?this.scheduleGc():this.cache.remove(this)),this.cache.notify({type:"observerRemoved",query:this,observer:i}))},M.getObserversCount=function(){return this.observers.length},M.invalidate=function(){this.state.isInvalidated||this.dispatch({type:"invalidate"})},M.fetch=function(i,u){var N=this,n,r,a;if(this.state.isFetching){if(this.state.dataUpdatedAt&&(u!=null&&u.cancelRefetch))this.cancel({silent:!0});else if(this.promise){var D;return(D=this.retryer)==null||D.continueRetry(),this.promise}}if(i&&this.setOptions(i),!this.options.queryFn){var j=this.observers.find(function(z){return z.options.queryFn});j&&this.setOptions(j.options)}var o=iE(this.queryKey),s=xF(),L={queryKey:o,pageParam:void 0,meta:this.meta};Object.defineProperty(L,"signal",{enumerable:!0,get:function(){if(s)return N.abortSignalConsumed=!0,s.signal}});var g=function(){return N.options.queryFn?(N.abortSignalConsumed=!1,N.options.queryFn(L)):Promise.reject("Missing queryFn")},c={fetchOptions:u,options:this.options,queryKey:o,state:this.state,fetchFn:g,meta:this.meta};if((n=this.options.behavior)!=null&&n.onFetch){var l;(l=this.options.behavior)==null||l.onFetch(c)}if(this.revertState=this.state,!this.state.isFetching||this.state.fetchMeta!==((r=c.fetchOptions)==null?void 0:r.meta)){var I;this.dispatch({type:"fetch",meta:(I=c.fetchOptions)==null?void 0:I.meta})}return this.retryer=new EF({fn:c.fetchFn,abort:s==null||(a=s.abort)==null?void 0:a.bind(s),onSuccess:function(O){N.setData(O),N.cache.config.onSuccess==null||N.cache.config.onSuccess(O,N),N.cacheTime===0&&N.optionalRemove()},onError:function(O){jE(O)&&O.silent||N.dispatch({type:"error",error:O}),jE(O)||(N.cache.config.onError==null||N.cache.config.onError(O,N),DE().error(O)),N.cacheTime===0&&N.optionalRemove()},onFail:function(){N.dispatch({type:"failed"})},onPause:function(){N.dispatch({type:"pause"})},onContinue:function(){N.dispatch({type:"continue"})},retry:c.options.retry,retryDelay:c.options.retryDelay}),this.promise=this.retryer.promise,this.promise},M.dispatch=function(i){var u=this;this.state=this.reducer(this.state,i),t4.batch(function(){u.observers.forEach(function(N){N.onQueryUpdate(i)}),u.cache.notify({query:u,type:"queryUpdated",action:i})})},M.getDefaultState=function(i){var u=typeof i.initialData=="function"?i.initialData():i.initialData,N=typeof i.initialData<"u",n=N?typeof i.initialDataUpdatedAt=="function"?i.initialDataUpdatedAt():i.initialDataUpdatedAt:0,r=typeof u<"u";return{data:u,dataUpdateCount:0,dataUpdatedAt:r?n??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchMeta:null,isFetching:!1,isInvalidated:!1,isPaused:!1,status:r?"success":"idle"}},M.reducer=function(i,u){var N,n;switch(u.type){case"failed":return zu({},i,{fetchFailureCount:i.fetchFailureCount+1});case"pause":return zu({},i,{isPaused:!0});case"continue":return zu({},i,{isPaused:!1});case"fetch":return zu({},i,{fetchFailureCount:0,fetchMeta:(N=u.meta)!=null?N:null,isFetching:!0,isPaused:!1},!i.dataUpdatedAt&&{error:null,status:"loading"});case"success":return zu({},i,{data:u.data,dataUpdateCount:i.dataUpdateCount+1,dataUpdatedAt:(n=u.dataUpdatedAt)!=null?n:Date.now(),error:null,fetchFailureCount:0,isFetching:!1,isInvalidated:!1,isPaused:!1,status:"success"});case"error":var r=u.error;return jE(r)&&r.revert&&this.revertState?zu({},this.revertState):zu({},i,{error:r,errorUpdateCount:i.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:i.fetchFailureCount+1,isFetching:!1,isPaused:!1,status:"error"});case"invalidate":return zu({},i,{isInvalidated:!0});case"setState":return zu({},i,u.state);default:return i}},e}(),Zse=function(e){Gl(M,e);function M(i){var u;return u=e.call(this)||this,u.config=i||{},u.queries=[],u.queriesMap={},u}var t=M.prototype;return t.build=function(u,N,n){var r,a=N.queryKey,D=(r=N.queryHash)!=null?r:CQ(a,N),j=this.get(D);return j||(j=new $se({cache:this,queryKey:a,queryHash:D,options:u.defaultQueryOptions(N),state:n,defaultOptions:u.getQueryDefaults(a),meta:N.meta}),this.add(j)),j},t.add=function(u){this.queriesMap[u.queryHash]||(this.queriesMap[u.queryHash]=u,this.queries.push(u),this.notify({type:"queryAdded",query:u}))},t.remove=function(u){var N=this.queriesMap[u.queryHash];N&&(u.destroy(),this.queries=this.queries.filter(function(n){return n!==u}),N===u&&delete this.queriesMap[u.queryHash],this.notify({type:"queryRemoved",query:u}))},t.clear=function(){var u=this;t4.batch(function(){u.queries.forEach(function(N){u.remove(N)})})},t.get=function(u){return this.queriesMap[u]},t.getAll=function(){return this.queries},t.find=function(u,N){var n=x1(u,N),r=n[0];return typeof r.exact>"u"&&(r.exact=!0),this.queries.find(function(a){return yF(r,a)})},t.findAll=function(u,N){var n=x1(u,N),r=n[0];return Object.keys(r).length>0?this.queries.filter(function(a){return yF(r,a)}):this.queries},t.notify=function(u){var N=this;t4.batch(function(){N.listeners.forEach(function(n){n(u)})})},t.onFocus=function(){var u=this;t4.batch(function(){u.queries.forEach(function(N){N.onFocus()})})},t.onOnline=function(){var u=this;t4.batch(function(){u.queries.forEach(function(N){N.onOnline()})})},M}(mz),Jse=function(){function e(t){this.options=zu({},t.defaultOptions,t.options),this.mutationId=t.mutationId,this.mutationCache=t.mutationCache,this.observers=[],this.state=t.state||fF(),this.meta=t.meta}var M=e.prototype;return M.setState=function(i){this.dispatch({type:"setState",state:i})},M.addObserver=function(i){this.observers.indexOf(i)===-1&&this.observers.push(i)},M.removeObserver=function(i){this.observers=this.observers.filter(function(u){return u!==i})},M.cancel=function(){return this.retryer?(this.retryer.cancel(),this.retryer.promise.then(jr).catch(jr)):Promise.resolve()},M.continue=function(){return this.retryer?(this.retryer.continue(),this.retryer.promise):this.execute()},M.execute=function(){var i=this,u,N=this.state.status==="loading",n=Promise.resolve();return N||(this.dispatch({type:"loading",variables:this.options.variables}),n=n.then(function(){i.mutationCache.config.onMutate==null||i.mutationCache.config.onMutate(i.state.variables,i)}).then(function(){return i.options.onMutate==null?void 0:i.options.onMutate(i.state.variables)}).then(function(r){r!==i.state.context&&i.dispatch({type:"loading",context:r,variables:i.state.variables})})),n.then(function(){return i.executeMutation()}).then(function(r){u=r,i.mutationCache.config.onSuccess==null||i.mutationCache.config.onSuccess(u,i.state.variables,i.state.context,i)}).then(function(){return i.options.onSuccess==null?void 0:i.options.onSuccess(u,i.state.variables,i.state.context)}).then(function(){return i.options.onSettled==null?void 0:i.options.onSettled(u,null,i.state.variables,i.state.context)}).then(function(){return i.dispatch({type:"success",data:u}),u}).catch(function(r){return i.mutationCache.config.onError==null||i.mutationCache.config.onError(r,i.state.variables,i.state.context,i),DE().error(r),Promise.resolve().then(function(){return i.options.onError==null?void 0:i.options.onError(r,i.state.variables,i.state.context)}).then(function(){return i.options.onSettled==null?void 0:i.options.onSettled(void 0,r,i.state.variables,i.state.context)}).then(function(){throw i.dispatch({type:"error",error:r}),r})})},M.executeMutation=function(){var i=this,u;return this.retryer=new EF({fn:function(){return i.options.mutationFn?i.options.mutationFn(i.state.variables):Promise.reject("No mutationFn found")},onFail:function(){i.dispatch({type:"failed"})},onPause:function(){i.dispatch({type:"pause"})},onContinue:function(){i.dispatch({type:"continue"})},retry:(u=this.options.retry)!=null?u:0,retryDelay:this.options.retryDelay}),this.retryer.promise},M.dispatch=function(i){var u=this;this.state=Xse(this.state,i),t4.batch(function(){u.observers.forEach(function(N){N.onMutationUpdate(i)}),u.mutationCache.notify(u)})},e}();function fF(){return{context:void 0,data:void 0,error:null,failureCount:0,isPaused:!1,status:"idle",variables:void 0}}function Xse(e,M){switch(M.type){case"failed":return zu({},e,{failureCount:e.failureCount+1});case"pause":return zu({},e,{isPaused:!0});case"continue":return zu({},e,{isPaused:!1});case"loading":return zu({},e,{context:M.context,data:void 0,error:null,isPaused:!1,status:"loading",variables:M.variables});case"success":return zu({},e,{data:M.data,error:null,status:"success",isPaused:!1});case"error":return zu({},e,{data:void 0,error:M.error,failureCount:e.failureCount+1,isPaused:!1,status:"error"});case"setState":return zu({},e,M.state);default:return e}}var Kse=function(e){Gl(M,e);function M(i){var u;return u=e.call(this)||this,u.config=i||{},u.mutations=[],u.mutationId=0,u}var t=M.prototype;return t.build=function(u,N,n){var r=new Jse({mutationCache:this,mutationId:++this.mutationId,options:u.defaultMutationOptions(N),state:n,defaultOptions:N.mutationKey?u.getMutationDefaults(N.mutationKey):void 0,meta:N.meta});return this.add(r),r},t.add=function(u){this.mutations.push(u),this.notify(u)},t.remove=function(u){this.mutations=this.mutations.filter(function(N){return N!==u}),u.cancel(),this.notify(u)},t.clear=function(){var u=this;t4.batch(function(){u.mutations.forEach(function(N){u.remove(N)})})},t.getAll=function(){return this.mutations},t.find=function(u){return typeof u.exact>"u"&&(u.exact=!0),this.mutations.find(function(N){return IF(u,N)})},t.findAll=function(u){return this.mutations.filter(function(N){return IF(u,N)})},t.notify=function(u){var N=this;t4.batch(function(){N.listeners.forEach(function(n){n(u)})})},t.onFocus=function(){this.resumePausedMutations()},t.onOnline=function(){this.resumePausedMutations()},t.resumePausedMutations=function(){var u=this.mutations.filter(function(N){return N.state.isPaused});return t4.batch(function(){return u.reduce(function(N,n){return N.then(function(){return n.continue().catch(jr)})},Promise.resolve())})},M}(mz);function qse(){return{onFetch:function(M){M.fetchFn=function(){var t,i,u,N,n,r,a=(t=M.fetchOptions)==null||(i=t.meta)==null?void 0:i.refetchPage,D=(u=M.fetchOptions)==null||(N=u.meta)==null?void 0:N.fetchMore,j=D==null?void 0:D.pageParam,o=(D==null?void 0:D.direction)==="forward",s=(D==null?void 0:D.direction)==="backward",L=((n=M.state.data)==null?void 0:n.pages)||[],g=((r=M.state.data)==null?void 0:r.pageParams)||[],c=xF(),l=c==null?void 0:c.signal,I=g,z=!1,O=M.options.queryFn||function(){return Promise.reject("Missing queryFn")},f=function(Y,R,P,V){return I=V?[R].concat(I):[].concat(I,[R]),V?[P].concat(Y):[].concat(Y,[P])},S=function(Y,R,P,V){if(z)return Promise.reject("Cancelled");if(typeof P>"u"&&!R&&Y.length)return Promise.resolve(Y);var H={queryKey:M.queryKey,signal:l,pageParam:P,meta:M.meta},Z=O(H),G=Promise.resolve(Z).then(function(X){return f(Y,P,X,V)});if(aE(Z)){var $=G;$.cancel=Z.cancel}return G},E;if(!L.length)E=S([]);else if(o){var p=typeof j<"u",Q=p?j:CF(M.options,L);E=S(L,p,Q)}else if(s){var k=typeof j<"u",v=k?j:eLe(M.options,L);E=S(L,k,v,!0)}else(function(){I=[];var m=typeof M.options.getNextPageParam>"u",Y=a&&L[0]?a(L[0],0,L):!0;E=Y?S([],m,g[0]):Promise.resolve(f([],g[0],L[0]));for(var R=function(H){E=E.then(function(Z){var G=a&&L[H]?a(L[H],H,L):!0;if(G){var $=m?g[H]:CF(M.options,Z);return S(Z,m,$)}return Promise.resolve(f(Z,g[H],L[H]))})},P=1;P<L.length;P++)R(P)})();var h=E.then(function(m){return{pages:m,pageParams:I}}),w=h;return w.cancel=function(){z=!0,c==null||c.abort(),aE(E)&&E.cancel()},h}}}}function CF(e,M){return e.getNextPageParam==null?void 0:e.getNextPageParam(M[M.length-1],M)}function eLe(e,M){return e.getPreviousPageParam==null?void 0:e.getPreviousPageParam(M[0],M)}var tLe=function(){function e(t){t===void 0&&(t={}),this.queryCache=t.queryCache||new Zse,this.mutationCache=t.mutationCache||new Kse,this.defaultOptions=t.defaultOptions||{},this.queryDefaults=[],this.mutationDefaults=[]}var M=e.prototype;return M.mount=function(){var i=this;this.unsubscribeFocus=P5.subscribe(function(){P5.isFocused()&&rE.isOnline()&&(i.mutationCache.onFocus(),i.queryCache.onFocus())}),this.unsubscribeOnline=rE.subscribe(function(){P5.isFocused()&&rE.isOnline()&&(i.mutationCache.onOnline(),i.queryCache.onOnline())})},M.unmount=function(){var i,u;(i=this.unsubscribeFocus)==null||i.call(this),(u=this.unsubscribeOnline)==null||u.call(this)},M.isFetching=function(i,u){var N=x1(i,u),n=N[0];return n.fetching=!0,this.queryCache.findAll(n).length},M.isMutating=function(i){return this.mutationCache.findAll(zu({},i,{fetching:!0})).length},M.getQueryData=function(i,u){var N;return(N=this.queryCache.find(i,u))==null?void 0:N.state.data},M.getQueriesData=function(i){return this.getQueryCache().findAll(i).map(function(u){var N=u.queryKey,n=u.state,r=n.data;return[N,r]})},M.setQueryData=function(i,u,N){var n=uE(i),r=this.defaultQueryOptions(n);return this.queryCache.build(this,r).setData(u,N)},M.setQueriesData=function(i,u,N){var n=this;return t4.batch(function(){return n.getQueryCache().findAll(i).map(function(r){var a=r.queryKey;return[a,n.setQueryData(a,u,N)]})})},M.getQueryState=function(i,u){var N;return(N=this.queryCache.find(i,u))==null?void 0:N.state},M.removeQueries=function(i,u){var N=x1(i,u),n=N[0],r=this.queryCache;t4.batch(function(){r.findAll(n).forEach(function(a){r.remove(a)})})},M.resetQueries=function(i,u,N){var n=this,r=x1(i,u,N),a=r[0],D=r[1],j=this.queryCache,o=zu({},a,{active:!0});return t4.batch(function(){return j.findAll(a).forEach(function(s){s.reset()}),n.refetchQueries(o,D)})},M.cancelQueries=function(i,u,N){var n=this,r=x1(i,u,N),a=r[0],D=r[1],j=D===void 0?{}:D;typeof j.revert>"u"&&(j.revert=!0);var o=t4.batch(function(){return n.queryCache.findAll(a).map(function(s){return s.cancel(j)})});return Promise.all(o).then(jr).catch(jr)},M.invalidateQueries=function(i,u,N){var n,r,a,D=this,j=x1(i,u,N),o=j[0],s=j[1],L=zu({},o,{active:(n=(r=o.refetchActive)!=null?r:o.active)!=null?n:!0,inactive:(a=o.refetchInactive)!=null?a:!1});return t4.batch(function(){return D.queryCache.findAll(o).forEach(function(g){g.invalidate()}),D.refetchQueries(L,s)})},M.refetchQueries=function(i,u,N){var n=this,r=x1(i,u,N),a=r[0],D=r[1],j=t4.batch(function(){return n.queryCache.findAll(a).map(function(s){return s.fetch(void 0,zu({},D,{meta:{refetchPage:a==null?void 0:a.refetchPage}}))})}),o=Promise.all(j).then(jr);return D!=null&&D.throwOnError||(o=o.catch(jr)),o},M.fetchQuery=function(i,u,N){var n=uE(i,u,N),r=this.defaultQueryOptions(n);typeof r.retry>"u"&&(r.retry=!1);var a=this.queryCache.build(this,r);return a.isStaleByTime(r.staleTime)?a.fetch(r):Promise.resolve(a.state.data)},M.prefetchQuery=function(i,u,N){return this.fetchQuery(i,u,N).then(jr).catch(jr)},M.fetchInfiniteQuery=function(i,u,N){var n=uE(i,u,N);return n.behavior=qse(),this.fetchQuery(n)},M.prefetchInfiniteQuery=function(i,u,N){return this.fetchInfiniteQuery(i,u,N).then(jr).catch(jr)},M.cancelMutations=function(){var i=this,u=t4.batch(function(){return i.mutationCache.getAll().map(function(N){return N.cancel()})});return Promise.all(u).then(jr).catch(jr)},M.resumePausedMutations=function(){return this.getMutationCache().resumePausedMutations()},M.executeMutation=function(i){return this.mutationCache.build(this,i).execute()},M.getQueryCache=function(){return this.queryCache},M.getMutationCache=function(){return this.mutationCache},M.getDefaultOptions=function(){return this.defaultOptions},M.setDefaultOptions=function(i){this.defaultOptions=i},M.setQueryDefaults=function(i,u){var N=this.queryDefaults.find(function(n){return Bl(i)===Bl(n.queryKey)});N?N.defaultOptions=u:this.queryDefaults.push({queryKey:i,defaultOptions:u})},M.getQueryDefaults=function(i){var u;return i?(u=this.queryDefaults.find(function(N){return NE(i,N.queryKey)}))==null?void 0:u.defaultOptions:void 0},M.setMutationDefaults=function(i,u){var N=this.mutationDefaults.find(function(n){return Bl(i)===Bl(n.mutationKey)});N?N.defaultOptions=u:this.mutationDefaults.push({mutationKey:i,defaultOptions:u})},M.getMutationDefaults=function(i){var u;return i?(u=this.mutationDefaults.find(function(N){return NE(i,N.mutationKey)}))==null?void 0:u.defaultOptions:void 0},M.defaultQueryOptions=function(i){if(i!=null&&i._defaulted)return i;var u=zu({},this.defaultOptions.queries,this.getQueryDefaults(i==null?void 0:i.queryKey),i,{_defaulted:!0});return!u.queryHash&&u.queryKey&&(u.queryHash=CQ(u.queryKey,u)),u},M.defaultQueryObserverOptions=function(i){return this.defaultQueryOptions(i)},M.defaultMutationOptions=function(i){return i!=null&&i._defaulted?i:zu({},this.defaultOptions.mutations,this.getMutationDefaults(i==null?void 0:i.mutationKey),i,{_defaulted:!0})},M.clear=function(){this.queryCache.clear(),this.mutationCache.clear()},e}(),MLe=function(e){Gl(M,e);function M(i,u){var N;return N=e.call(this)||this,N.client=i,N.options=u,N.trackedProps=[],N.selectError=null,N.bindMethods(),N.setOptions(u),N}var t=M.prototype;return t.bindMethods=function(){this.remove=this.remove.bind(this),this.refetch=this.refetch.bind(this)},t.onSubscribe=function(){this.listeners.length===1&&(this.currentQuery.addObserver(this),wF(this.currentQuery,this.options)&&this.executeFetch(),this.updateTimers())},t.onUnsubscribe=function(){this.listeners.length||this.destroy()},t.shouldFetchOnReconnect=function(){return hQ(this.currentQuery,this.options,this.options.refetchOnReconnect)},t.shouldFetchOnWindowFocus=function(){return hQ(this.currentQuery,this.options,this.options.refetchOnWindowFocus)},t.destroy=function(){this.listeners=[],this.clearTimers(),this.currentQuery.removeObserver(this)},t.setOptions=function(u,N){var n=this.options,r=this.currentQuery;if(this.options=this.client.defaultQueryObserverOptions(u),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=n.queryKey),this.updateQuery();var a=this.hasListeners();a&&hF(this.currentQuery,r,this.options,n)&&this.executeFetch(),this.updateResult(N),a&&(this.currentQuery!==r||this.options.enabled!==n.enabled||this.options.staleTime!==n.staleTime)&&this.updateStaleTimeout();var D=this.computeRefetchInterval();a&&(this.currentQuery!==r||this.options.enabled!==n.enabled||D!==this.currentRefetchInterval)&&this.updateRefetchInterval(D)},t.getOptimisticResult=function(u){var N=this.client.defaultQueryObserverOptions(u),n=this.client.getQueryCache().build(this.client,N);return this.createResult(n,N)},t.getCurrentResult=function(){return this.currentResult},t.trackResult=function(u,N){var n=this,r={},a=function(j){n.trackedProps.includes(j)||n.trackedProps.push(j)};return Object.keys(u).forEach(function(D){Object.defineProperty(r,D,{configurable:!1,enumerable:!0,get:function(){return a(D),u[D]}})}),(N.useErrorBoundary||N.suspense)&&a("error"),r},t.getNextResult=function(u){var N=this;return new Promise(function(n,r){var a=N.subscribe(function(D){D.isFetching||(a(),D.isError&&(u!=null&&u.throwOnError)?r(D.error):n(D))})})},t.getCurrentQuery=function(){return this.currentQuery},t.remove=function(){this.client.getQueryCache().remove(this.currentQuery)},t.refetch=function(u){return this.fetch(zu({},u,{meta:{refetchPage:u==null?void 0:u.refetchPage}}))},t.fetchOptimistic=function(u){var N=this,n=this.client.defaultQueryObserverOptions(u),r=this.client.getQueryCache().build(this.client,n);return r.fetch().then(function(){return N.createResult(r,n)})},t.fetch=function(u){var N=this;return this.executeFetch(u).then(function(){return N.updateResult(),N.currentResult})},t.executeFetch=function(u){this.updateQuery();var N=this.currentQuery.fetch(this.options,u);return u!=null&&u.throwOnError||(N=N.catch(jr)),N},t.updateStaleTimeout=function(){var u=this;if(this.clearStaleTimeout(),!(ME||this.currentResult.isStale||!fQ(this.options.staleTime))){var N=lF(this.currentResult.dataUpdatedAt,this.options.staleTime),n=N+1;this.staleTimeoutId=setTimeout(function(){u.currentResult.isStale||u.updateResult()},n)}},t.computeRefetchInterval=function(){var u;return typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.currentResult.data,this.currentQuery):(u=this.options.refetchInterval)!=null?u:!1},t.updateRefetchInterval=function(u){var N=this;this.clearRefetchInterval(),this.currentRefetchInterval=u,!(ME||this.options.enabled===!1||!fQ(this.currentRefetchInterval)||this.currentRefetchInterval===0)&&(this.refetchIntervalId=setInterval(function(){(N.options.refetchIntervalInBackground||P5.isFocused())&&N.executeFetch()},this.currentRefetchInterval))},t.updateTimers=function(){this.updateStaleTimeout(),this.updateRefetchInterval(this.computeRefetchInterval())},t.clearTimers=function(){this.clearStaleTimeout(),this.clearRefetchInterval()},t.clearStaleTimeout=function(){this.staleTimeoutId&&(clearTimeout(this.staleTimeoutId),this.staleTimeoutId=void 0)},t.clearRefetchInterval=function(){this.refetchIntervalId&&(clearInterval(this.refetchIntervalId),this.refetchIntervalId=void 0)},t.createResult=function(u,N){var n=this.currentQuery,r=this.options,a=this.currentResult,D=this.currentResultState,j=this.currentResultOptions,o=u!==n,s=o?u.state:this.currentQueryInitialState,L=o?this.currentResult:this.previousQueryResult,g=u.state,c=g.dataUpdatedAt,l=g.error,I=g.errorUpdatedAt,z=g.isFetching,O=g.status,f=!1,S=!1,E;if(N.optimisticResults){var p=this.hasListeners(),Q=!p&&wF(u,N),k=p&&hF(u,n,N,r);(Q||k)&&(z=!0,c||(O="loading"))}if(N.keepPreviousData&&!g.dataUpdateCount&&(L!=null&&L.isSuccess)&&O!=="error")E=L.data,c=L.dataUpdatedAt,O=L.status,f=!0;else if(N.select&&typeof g.data<"u")if(a&&g.data===(D==null?void 0:D.data)&&N.select===this.selectFn)E=this.selectResult;else try{this.selectFn=N.select,E=N.select(g.data),N.structuralSharing!==!1&&(E=nE(a==null?void 0:a.data,E)),this.selectResult=E,this.selectError=null}catch(w){DE().error(w),this.selectError=w}else E=g.data;if(typeof N.placeholderData<"u"&&typeof E>"u"&&(O==="loading"||O==="idle")){var v;if(a!=null&&a.isPlaceholderData&&N.placeholderData===(j==null?void 0:j.placeholderData))v=a.data;else if(v=typeof N.placeholderData=="function"?N.placeholderData():N.placeholderData,N.select&&typeof v<"u")try{v=N.select(v),N.structuralSharing!==!1&&(v=nE(a==null?void 0:a.data,v)),this.selectError=null}catch(w){DE().error(w),this.selectError=w}typeof v<"u"&&(O="success",E=v,S=!0)}this.selectError&&(l=this.selectError,E=this.selectResult,I=Date.now(),O="error");var h={status:O,isLoading:O==="loading",isSuccess:O==="success",isError:O==="error",isIdle:O==="idle",data:E,dataUpdatedAt:c,error:l,errorUpdatedAt:I,failureCount:g.fetchFailureCount,errorUpdateCount:g.errorUpdateCount,isFetched:g.dataUpdateCount>0||g.errorUpdateCount>0,isFetchedAfterMount:g.dataUpdateCount>s.dataUpdateCount||g.errorUpdateCount>s.errorUpdateCount,isFetching:z,isRefetching:z&&O!=="loading",isLoadingError:O==="error"&&g.dataUpdatedAt===0,isPlaceholderData:S,isPreviousData:f,isRefetchError:O==="error"&&g.dataUpdatedAt!==0,isStale:pQ(u,N),refetch:this.refetch,remove:this.remove};return h},t.shouldNotifyListeners=function(u,N){if(!N)return!0;var n=this.options,r=n.notifyOnChangeProps,a=n.notifyOnChangePropsExclusions;if(!r&&!a||r==="tracked"&&!this.trackedProps.length)return!0;var D=r==="tracked"?this.trackedProps:r;return Object.keys(u).some(function(j){var o=j,s=u[o]!==N[o],L=D==null?void 0:D.some(function(c){return c===j}),g=a==null?void 0:a.some(function(c){return c===j});return s&&!g&&(!D||L)})},t.updateResult=function(u){var N=this.currentResult;if(this.currentResult=this.createResult(this.currentQuery,this.options),this.currentResultState=this.currentQuery.state,this.currentResultOptions=this.options,!Pse(this.currentResult,N)){var n={cache:!0};(u==null?void 0:u.listeners)!==!1&&this.shouldNotifyListeners(this.currentResult,N)&&(n.listeners=!0),this.notify(zu({},n,u))}},t.updateQuery=function(){var u=this.client.getQueryCache().build(this.client,this.options);if(u!==this.currentQuery){var N=this.currentQuery;this.currentQuery=u,this.currentQueryInitialState=u.state,this.previousQueryResult=this.currentResult,this.hasListeners()&&(N==null||N.removeObserver(this),u.addObserver(this))}},t.onQueryUpdate=function(u){var N={};u.type==="success"?N.onSuccess=!0:u.type==="error"&&!jE(u.error)&&(N.onError=!0),this.updateResult(N),this.hasListeners()&&this.updateTimers()},t.notify=function(u){var N=this;t4.batch(function(){u.onSuccess?(N.options.onSuccess==null||N.options.onSuccess(N.currentResult.data),N.options.onSettled==null||N.options.onSettled(N.currentResult.data,null)):u.onError&&(N.options.onError==null||N.options.onError(N.currentResult.error),N.options.onSettled==null||N.options.onSettled(void 0,N.currentResult.error)),u.listeners&&N.listeners.forEach(function(n){n(N.currentResult)}),u.cache&&N.client.getQueryCache().notify({query:N.currentQuery,type:"observerResultsUpdated"})})},M}(mz);function iLe(e,M){return M.enabled!==!1&&!e.state.dataUpdatedAt&&!(e.state.status==="error"&&M.retryOnMount===!1)}function wF(e,M){return iLe(e,M)||e.state.dataUpdatedAt>0&&hQ(e,M,M.refetchOnMount)}function hQ(e,M,t){if(M.enabled!==!1){var i=typeof t=="function"?t(e):t;return i==="always"||i!==!1&&pQ(e,M)}return!1}function hF(e,M,t,i){return t.enabled!==!1&&(e!==M||i.enabled===!1)&&(!t.suspense||e.state.status!=="error")&&pQ(e,t)}function pQ(e,M){return e.isStaleByTime(M.staleTime)}var uLe=function(e){Gl(M,e);function M(i,u){var N;return N=e.call(this)||this,N.client=i,N.setOptions(u),N.bindMethods(),N.updateResult(),N}var t=M.prototype;return t.bindMethods=function(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)},t.setOptions=function(u){this.options=this.client.defaultMutationOptions(u)},t.onUnsubscribe=function(){if(!this.listeners.length){var u;(u=this.currentMutation)==null||u.removeObserver(this)}},t.onMutationUpdate=function(u){this.updateResult();var N={listeners:!0};u.type==="success"?N.onSuccess=!0:u.type==="error"&&(N.onError=!0),this.notify(N)},t.getCurrentResult=function(){return this.currentResult},t.reset=function(){this.currentMutation=void 0,this.updateResult(),this.notify({listeners:!0})},t.mutate=function(u,N){return this.mutateOptions=N,this.currentMutation&&this.currentMutation.removeObserver(this),this.currentMutation=this.client.getMutationCache().build(this.client,zu({},this.options,{variables:typeof u<"u"?u:this.options.variables})),this.currentMutation.addObserver(this),this.currentMutation.execute()},t.updateResult=function(){var u=this.currentMutation?this.currentMutation.state:fF(),N=zu({},u,{isLoading:u.status==="loading",isSuccess:u.status==="success",isError:u.status==="error",isIdle:u.status==="idle",mutate:this.mutate,reset:this.reset});this.currentResult=N},t.notify=function(u){var N=this;t4.batch(function(){N.mutateOptions&&(u.onSuccess?(N.mutateOptions.onSuccess==null||N.mutateOptions.onSuccess(N.currentResult.data,N.currentResult.variables,N.currentResult.context),N.mutateOptions.onSettled==null||N.mutateOptions.onSettled(N.currentResult.data,null,N.currentResult.variables,N.currentResult.context)):u.onError&&(N.mutateOptions.onError==null||N.mutateOptions.onError(N.currentResult.error,N.currentResult.variables,N.currentResult.context),N.mutateOptions.onSettled==null||N.mutateOptions.onSettled(void 0,N.currentResult.error,N.currentResult.variables,N.currentResult.context))),u.listeners&&N.listeners.forEach(function(n){n(N.currentResult)})})},M}(mz),NLe=kS.unstable_batchedUpdates;t4.setBatchNotifyFunction(NLe);var nLe=console;Hse(nLe);var pF=Ge.createContext(void 0),QF=Ge.createContext(!1);function vF(e){return e&&typeof window<"u"?(window.ReactQueryClientContext||(window.ReactQueryClientContext=pF),window.ReactQueryClientContext):pF}var oE=function(){var M=Ge.useContext(vF(Ge.useContext(QF)));if(!M)throw new Error("No QueryClient set, use QueryClientProvider to set one");return M},rLe=function(M){var t=M.client,i=M.contextSharing,u=i===void 0?!1:i,N=M.children;Ge.useEffect(function(){return t.mount(),function(){t.unmount()}},[t]);var n=vF(u);return Ge.createElement(QF.Provider,{value:u},Ge.createElement(n.Provider,{value:t},N))};function aLe(){var e=!1;return{clearReset:function(){e=!1},reset:function(){e=!0},isReset:function(){return e}}}var jLe=Ge.createContext(aLe()),DLe=function(){return Ge.useContext(jLe)};function kF(e,M,t){return typeof M=="function"?M.apply(void 0,t):typeof M=="boolean"?M:!!e}function Zr(e,M,t){var i=Ge.useRef(!1),u=Ge.useState(0),N=u[1],n=bse(e,M,t),r=oE(),a=Ge.useRef();a.current?a.current.setOptions(n):a.current=new uLe(r,n);var D=a.current.getCurrentResult();Ge.useEffect(function(){i.current=!0;var o=a.current.subscribe(t4.batchCalls(function(){i.current&&N(function(s){return s+1})}));return function(){i.current=!1,o()}},[]);var j=Ge.useCallback(function(o,s){a.current.mutate(o,s).catch(jr)},[]);if(D.error&&kF(void 0,a.current.options.useErrorBoundary,[D.error]))throw D.error;return zu({},D,{mutate:j,mutateAsync:D.mutate})}function oLe(e,M){var t=Ge.useRef(!1),i=Ge.useState(0),u=i[1],N=oE(),n=DLe(),r=N.defaultQueryObserverOptions(e);r.optimisticResults=!0,r.onError&&(r.onError=t4.batchCalls(r.onError)),r.onSuccess&&(r.onSuccess=t4.batchCalls(r.onSuccess)),r.onSettled&&(r.onSettled=t4.batchCalls(r.onSettled)),r.suspense&&(typeof r.staleTime!="number"&&(r.staleTime=1e3),r.cacheTime===0&&(r.cacheTime=1)),(r.suspense||r.useErrorBoundary)&&(n.isReset()||(r.retryOnMount=!1));var a=Ge.useState(function(){return new M(N,r)}),D=a[0],j=D.getOptimisticResult(r);if(Ge.useEffect(function(){t.current=!0,n.clearReset();var o=D.subscribe(t4.batchCalls(function(){t.current&&u(function(s){return s+1})}));return D.updateResult(),function(){t.current=!1,o()}},[n,D]),Ge.useEffect(function(){D.setOptions(r,{listeners:!1})},[r,D]),r.suspense&&j.isLoading)throw D.fetchOptimistic(r).then(function(o){var s=o.data;r.onSuccess==null||r.onSuccess(s),r.onSettled==null||r.onSettled(s,null)}).catch(function(o){n.clearReset(),r.onError==null||r.onError(o),r.onSettled==null||r.onSettled(void 0,o)});if(j.isError&&!n.isReset()&&!j.isFetching&&kF(r.suspense,r.useErrorBoundary,[j.error,D.getCurrentQuery()]))throw j.error;return r.notifyOnChangeProps==="tracked"&&(j=D.trackResult(j,r)),j}function Vl(e,M,t){var i=uE(e,M,t);return oLe(i,MLe)}const QQ="https://api.usedatabrain.com",Ea="/api/v2/dashboard",S1="/api/v2/metric",UF="/api/v3/metric",YF="dashboardData",sLe=`${Ea}/embeddedMetric`,LLe="embeddedMetric",gLe=`${S1}/layout`,mF="dashboardLayout",cLe=`${Ea}/scheduledReport`,TLe="dashboardScheduledReport",lLe=`${S1}/saveLayout`,yLe="saveLayout",ILe=`${Ea}/saveScheduleReport`,zLe="saveScheduleReport",ALe=`${Ea}/deleteScheduleReport`,OLe="deleteScheduleReport",xLe=`${Ea}/createMetric`,SLe="createMetric",ELe=`${Ea}/updateMetric`,dLe="updateMetric",fLe=`${Ea}/updateAdminMetric`,CLe="updateAdminMetric",wLe=`${Ea}/generateMetric`,hLe="generateMetric",pLe=`${Ea}/datasetMetricCreation`,QLe="datasetMetricCreation",vLe=`${Ea}/previewTable`,kLe="previewTable",ULe=`${Ea}/generatetMetricData`,YLe="/generatetMetricData",mLe=`${Ea}/getOpenaiChatResponse`,bLe="getOpenaiChatResponse",_Le=`${Ea}/getTheme`,RLe="getTheme",PLe=`${UF}/query`,FLe="query",GLe=`${UF}/datasetMetricCreation`,BLe="newDatasetMetricCreation",VLe=`${S1}/rawDownloadSettings`,WLe="rawDownloadSettings",HLe=`${S1}/column`,$Le="column",ZLe=`${S1}/underlyingData`,JLe="underlyingData",XLe=`${S1}/invokeShareCsv`,KLe="invokeShareCsv",qLe=`${S1}/markArchived`,e0e="markArchived",bF=`${S1}/download-csv`,t0e=()=>localStorage.getItem(Mse),o4=async(e,M={method:"GET"})=>{var N;const t={method:M.method,headers:{"Content-Type":"application/json","X-Plugin-Token":M.token||"","X-Plugin-Origin":window.location.host,...M.isFrontend?{"X-Dbn-Secret":M.clientId}:{},...M.isFrontend?{"X-Dbn-token":t0e()||""}:{}}};M.data&&(t.body=JSON.stringify(M.data));const u=await(await fetch(`${((N=window.dbn)==null?void 0:N.baseUrl)||QQ}${e}`,t)).json();if(u.error){const{message:n}=u.error;throw new Error(n)}return u.data},M0e=()=>Zr(yLe,e=>o4(lLe,{method:"POST",data:e})),i0e=()=>Zr(zLe,e=>o4(ILe,{method:"POST",data:e.data,token:e.token})),u0e=()=>Zr(OLe,e=>o4(ALe,{method:"POST",data:e,token:e.token})),N0e=()=>Zr(SLe,({data:e,token:M})=>o4(xLe,{method:"POST",data:e,token:M})),n0e=()=>Zr(dLe,({data:e,token:M})=>o4(ELe,{method:"POST",data:e,token:M})),r0e=()=>Zr(CLe,({data:e,token:M})=>o4(fLe,{method:"POST",data:e,token:M})),a0e=()=>Zr(hLe,({data:e,token:M})=>o4(wLe,{method:"POST",data:e,token:M})),_F=()=>Zr(QLe,({data:e,token:M})=>o4(pLe,{method:"POST",data:e,token:M})),j0e=()=>Zr(kLe,({data:e,token:M})=>o4(vLe,{method:"POST",data:e,token:M})),D0e=()=>Zr(YLe,({data:e,token:M})=>o4(ULe,{method:"POST",data:e,token:M})),o0e=()=>Zr(bLe,({data:e,token:M})=>o4(mLe,{method:"POST",data:e,token:M})),vQ=({onSuccess:e,companyIntegrationId:M,selectedColumns:t,query:i,metricQuery:u,integrationName:N,outputColumns:n,chartSettings:r,clientId:a,companyId:D,isLiveMode:j,timeGrain:o,dashboardIds:s,isEnableGroupBy:L,groupBy:g,selectedGroupBy:c,metric:l,datasetMetricSettings:I})=>{var R,P,V;const{token:z,data:O}=_5(),[f,S]=ue.useState(""),{mutate:E,isLoading:p}=N0e(),{mutate:Q}=j0e(),k=H=>{S(""),E({data:{companyId:D,companyIntegrationId:M,description:H.description,inputFields:t,metricId:H.metricId,name:H.name,query:i,metricQuery:u,integrationName:N,outputColumns:n,createdBy:a||"external user",isLive:j||!1,chartOptions:r,datasetMetricSettings:I,clientId:a||null,isCreatedByClient:!!a,timeGrain:o||null,externalDashboardIds:s.map(Z=>({externalDashboardId:Z})),isEnableGroupBy:L,groupBy:g??{},selectedGroupBy:c},token:z},{onSuccess:Z=>{var G;(G=Z==null?void 0:Z.insert_externalMetrics_one)!=null&&G.id?e():S("Metric Id already exists")},onError:()=>{S&&S("Metric Id already exists")}})},{mutateAsync:v,isLoading:h}=r0e(),{mutateAsync:w,isLoading:m}=n0e(),Y=ue.useCallback(H=>{if(S(""),!(l!=null&&l.isCreatedByClient))v({data:{externalMetricId:l==null?void 0:l.id,clientId:a,object:{companyId:D,companyIntegrationId:M||(l==null?void 0:l.companyIntegrationId),description:H.description,inputFields:t,metricId:H.metricId===(l==null?void 0:l.metricId)?`update_${H.metricId}_by_${a}_${Date.now()}`:H.metricId,name:H.name,query:i,metricQuery:u,datasetMetricSettings:I,integrationName:N,outputColumns:n,createdBy:a||"external user",isCreatedByClient:!!a,resizeAttributes:l==null?void 0:l.resizeAttributes,externalDashboardMetrics:{data:s.map(Z=>({externalDashboardId:Z}))},isLive:j||H.isLive,chartOptions:r}},token:z},{onSuccess:Z=>{!(Z!=null&&Z.insert_clientDeletedMetrics_one)||!(Z!=null&&Z.insert_externalMetrics_one)||(S(""),e())},onError:()=>{S("Something went wrong! Please try again later.")}});else{const Z={chartOptions:r,datasetMetricSettings:I};H.description&&(Z.description=H.description),H.metricId&&(Z.metricId=H.metricId),H.name&&(Z.name=H.name),w({data:{externalMetricId:l==null?void 0:l.id,set:Z},token:z},{onSuccess:G=>{var $;console.log(G),($=G==null?void 0:G.update_externalMetrics_by_pk)!=null&&$.id&&(S(""),e())},onError:()=>{S("Something went wrong! Please try again later.")}})}},[r,l,w,v,a,D,M,N,j,s,i,t,n,u,I]);return{createExternalMetric:k,updateExternalMetric:Y,error:f,isLoading:p||h||m,clientSubsetData:O==null?void 0:O.clientSubsetData,previewTable:Q,token:z,workspaceId:(R=O==null?void 0:O.workspace)==null?void 0:R.id,dashboardOptions:[{value:(P=O==null?void 0:O.externalDashboard)==null?void 0:P.id,label:((V=O==null?void 0:O.externalDashboard)==null?void 0:V.name)||"Dashboard"}],isDatabaseTenancy:(O==null?void 0:O.companyTenancyType)===hz}},RF=()=>Zr($Le,e=>o4(HLe,{method:"POST",data:e})),s0e=()=>Zr(JLe,e=>o4(ZLe,{method:"POST",data:e})),L0e=()=>Zr(KLe,e=>o4(XLe,{method:"POST",data:e})),g0e=()=>Zr(e0e,e=>o4(qLe,{method:"POST",data:e})),c0e=()=>Zr(BLe,({data:e,token:M,clientId:t,isFrontendApp:i})=>o4(GLe,{method:"POST",data:e,isFrontend:i,clientId:t,token:M})),PF=()=>{const{mutate:e,isLoading:M,error:t}=a0e(),{mutate:i}=RF();return{generateDatasetMetric:e,isGeneratingDataset:M,generateError:t,fetchColumnValues:i}};let T0e=0;function l0e(e,M){const t=`atom${++T0e}`,i={toString:()=>t};return typeof e=="function"?i.read=e:(i.init=e,i.read=u=>u(i),i.write=(u,N,n)=>N(i,typeof n=="function"?n(u(i)):n)),M&&(i.write=M),i}const E1=Symbol(),kQ=e=>!!e[E1],sE=e=>!e[E1].c,F5=e=>{var M;const{b:t,c:i}=e[E1];i&&(i(),(M=I0e.get(t))==null||M())},LE=(e,M)=>{const t=e[E1].o,i=M[E1].o;return t===i||e===i||kQ(t)&&LE(t,M)},UQ=(e,M)=>{const t={b:e,o:M,c:null},i=new Promise(u=>{t.c=()=>{t.c=null,u()},M.finally(t.c)});return i[E1]=t,i},y0e=e=>UQ(e[E1].b,e[E1].o),I0e=new WeakMap,gE=e=>"init"in e,YQ="r",mQ="w",cE="c",bQ="s",FF="h",z0e="n",A0e="l",O0e="a",x0e="m",S0e=e=>{const M=new WeakMap,t=new WeakMap,i=new Map;let u,N;if(({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&(u=new Set,N=new Set),e)for(const[G,$]of e){const X={v:$,r:0,y:!0,d:new Map};({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&(Object.freeze(X),gE(G)||console.warn("Found initial value for derived atom which can cause unexpected behavior",G)),M.set(G,X)}const n=new WeakMap,r=(G,$,X)=>{let B=n.get($);B||(B=new Map,n.set($,B)),X.then(()=>{B.get(G)===X&&(B.delete(G),B.size||n.delete($))}),B.set(G,X)},a=G=>{const $=new Set,X=n.get(G);return X&&(n.delete(G),X.forEach((B,K)=>{F5(B),$.add(K)})),$},D=new WeakMap,j=G=>{let $=D.get(G);return $||($=new Map,D.set(G,$)),$},o=(G,$)=>{if(G){const X=j(G);let B=X.get($);return B||(B=o(G.p,$),B&&"p"in B&&sE(B.p)&&(B=void 0),B&&X.set($,B)),B}return M.get($)},s=(G,$,X)=>{if(({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&Object.freeze(X),G)j(G).set($,X);else{const B=M.get($);M.set($,X),i.has($)||i.set($,B)}},L=(G,$=new Map,X)=>{if(!X)return $;const B=new Map;let K=!1;return X.forEach(te=>{var ee;const re=((ee=o(G,te))==null?void 0:ee.r)||0;B.set(te,re),$.get(te)!==re&&(K=!0)}),$.size===B.size&&!K?$:B},g=(G,$,X,B,K)=>{const te=o(G,$);if(te){if(K&&(!("p"in te)||!LE(te.p,K)))return te;"p"in te&&F5(te.p)}const ee={v:X,r:(te==null?void 0:te.r)||0,y:!0,d:L(G,te==null?void 0:te.d,B)};let re=!(te!=null&&te.y);return!te||!("v"in te)||!Object.is(te.v,X)?(re=!0,++ee.r,ee.d.has($)&&(ee.d=new Map(ee.d).set($,ee.r))):ee.d!==te.d&&(ee.d.size!==te.d.size||!Array.from(ee.d.keys()).every(je=>te.d.has(je)))&&(re=!0,Promise.resolve().then(()=>{R(G)})),te&&!re?te:(s(G,$,ee),ee)},c=(G,$,X,B,K)=>{const te=o(G,$);if(te){if(K&&(!("p"in te)||!LE(te.p,K)))return te;"p"in te&&F5(te.p)}const ee={e:X,r:((te==null?void 0:te.r)||0)+1,y:!0,d:L(G,te==null?void 0:te.d,B)};return s(G,$,ee),ee},l=(G,$,X,B)=>{const K=o(G,$);if(K&&"p"in K){if(LE(K.p,X)&&!sE(K.p))return K.y?K:{...K,y:!0};F5(K.p)}r(G,$,X);const te={p:X,r:((K==null?void 0:K.r)||0)+1,y:!0,d:L(G,K==null?void 0:K.d,B)};return s(G,$,te),te},I=(G,$,X,B)=>{if(X instanceof Promise){const K=UQ(X,X.then(te=>{g(G,$,te,B,K)}).catch(te=>{if(te instanceof Promise)return kQ(te)?te.then(()=>{O(G,$,!0)}):te;c(G,$,te,B,K)}));return l(G,$,K,B)}return g(G,$,X,B)},z=(G,$)=>{const X=o(G,$);if(X){const B={...X,y:!1};s(G,$,B)}else({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.warn("[Bug] could not invalidate non existing atom",$)},O=(G,$,X)=>{if(!X){const K=o(G,$);if(K){if(K.y&&"p"in K&&!sE(K.p))return K;if(K.d.forEach((te,ee)=>{if(ee!==$)if(!t.has(ee))O(G,ee);else{const re=o(G,ee);re&&!re.y&&O(G,ee)}}),Array.from(K.d).every(([te,ee])=>{const re=o(G,te);return re&&!("p"in re)&&re.r===ee}))return K.y?K:{...K,y:!0}}}const B=new Set;try{const K=$.read(te=>{B.add(te);const ee=te===$?o(G,te):O(G,te);if(ee){if("e"in ee)throw ee.e;if("p"in ee)throw ee.p;return ee.v}if(gE(te))return te.init;throw new Error("no atom init")});return I(G,$,K,B)}catch(K){if(K instanceof Promise){const te=kQ(K)&&sE(K)?y0e(K):UQ(K,K);return l(G,$,te,B)}return c(G,$,K,B)}},f=(G,$)=>O($,G),S=(G,$)=>{let X=t.get($);return X||(X=w(G,$)),X},E=(G,$)=>!$.l.size&&(!$.t.size||$.t.size===1&&$.t.has(G)),p=(G,$)=>{const X=t.get($);X&&E($,X)&&m(G,$)},Q=(G,$)=>{const X=t.get($);X==null||X.t.forEach(B=>{B!==$&&(z(G,B),Q(G,B))})},k=(G,$,X)=>{let B=!0;const K=(re,je)=>{const ge=O(G,re);if("e"in ge)throw ge.e;if("p"in ge){if(je!=null&&je.unstable_promise)return ge.p.then(()=>{const ze=o(G,re);return ze&&"p"in ze&&ze.p===ge.p?new Promise(Ae=>setTimeout(Ae)).then(()=>K(re,je)):K(re,je)});throw({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",re),ge.p}if("v"in ge)return ge.v;throw({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.warn("[Bug] no value found while reading atom in write operation. This is probably a bug.",re),new Error("no value found")},te=(re,je)=>{let ge;if(re===$){if(!gE(re))throw new Error("atom not writable");a(re).forEach(Xe=>{Xe!==G&&I(Xe,re,je)});const Ae=o(G,re),Te=I(G,re,je);Ae!==Te&&Q(G,re)}else ge=k(G,re,je);return B||R(G),ge},ee=$.write(K,te,X);return B=!1,ee},v=(G,$,X)=>{const B=k(X,G,$);return R(X),B},h=G=>!!G.write,w=(G,$,X)=>{const B={t:new Set(X&&[X]),l:new Set};if(t.set($,B),({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&N.add($),O(void 0,$).d.forEach((te,ee)=>{const re=t.get(ee);re?re.t.add($):ee!==$&&w(G,ee,$)}),h($)&&$.onMount){const te=re=>v($,re,G),ee=$.onMount(te);G=void 0,ee&&(B.u=ee)}return B},m=(G,$)=>{var X;const B=(X=t.get($))==null?void 0:X.u;B&&B(),t.delete($),({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&N.delete($);const K=o(G,$);K?("p"in K&&F5(K.p),K.d.forEach((te,ee)=>{if(ee!==$){const re=t.get(ee);re&&(re.t.delete($),E(ee,re)&&m(G,ee))}})):({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.warn("[Bug] could not find atom state to unmount",$)},Y=(G,$,X,B)=>{const K=new Set(X.d.keys());B==null||B.forEach((te,ee)=>{if(K.has(ee)){K.delete(ee);return}const re=t.get(ee);re&&(re.t.delete($),E(ee,re)&&m(G,ee))}),K.forEach(te=>{const ee=t.get(te);ee?ee.t.add($):t.has($)&&w(G,te,$)})},R=G=>{if(G){j(G).forEach((X,B)=>{const K=M.get(B);if(X!==K){const te=t.get(B);te==null||te.l.forEach(ee=>ee(G))}});return}for(;i.size;){const $=Array.from(i);i.clear(),$.forEach(([X,B])=>{const K=o(void 0,X);if(K&&K.d!==(B==null?void 0:B.d)&&Y(void 0,X,K,B==null?void 0:B.d),B&&!B.y&&(K!=null&&K.y))return;const te=t.get(X);te==null||te.l.forEach(ee=>ee())})}({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&u.forEach($=>$())},P=G=>{j(G).forEach((X,B)=>{const K=M.get(B);(!K||X.r>K.r||X.y!==K.y||X.r===K.r&&X.d!==K.d)&&(M.set(B,X),X.d!==(K==null?void 0:K.d)&&Y(G,B,X,K==null?void 0:K.d))})},V=(G,$)=>{$&&P($),R(void 0)},H=(G,$,X)=>{const K=S(X,G).l;return K.add($),()=>{K.delete($),p(X,G)}},Z=(G,$)=>{for(const[X,B]of G)gE(X)&&(I($,X,B),Q($,X));R($)};return({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"?{[YQ]:f,[mQ]:v,[cE]:V,[bQ]:H,[FF]:Z,[z0e]:G=>(u.add(G),()=>{u.delete(G)}),[A0e]:()=>N.values(),[O0e]:G=>M.get(G),[x0e]:G=>t.get(G)}:{[YQ]:f,[mQ]:v,[cE]:V,[bQ]:H,[FF]:Z}},E0e=(e,M)=>({s:M?M(e).SECRET_INTERNAL_store:S0e(e)}),_Q=new Map,GF=e=>(_Q.has(e)||_Q.set(e,ue.createContext(E0e())),_Q.get(e));function BF(e,M){return l0e(e,M)}function d0e(e,M){const t=GF(M),i=ue.useContext(t),{s:u,v:N}=i,n=s=>{const L=u[YQ](e,s);if(({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&!L.y)throw new Error("should not be invalidated");if("e"in L)throw L.e;if("p"in L)throw L.p;if("v"in L)return L.v;throw new Error("no atom value")},[[r,a,D],j]=ue.useReducer((s,L)=>{const g=n(L);return Object.is(s[1],g)&&s[2]===e?s:[L,g,e]},N,s=>{const L=n(s);return[s,L,e]});let o=a;return D!==e&&(j(r),o=n(r)),ue.useEffect(()=>{const{v:s}=i;s&&u[cE](e,s);const L=u[bQ](e,j,s);return j(s),L},[u,e,i]),ue.useEffect(()=>{u[cE](e,r)}),ue.useDebugValue(o),o}function f0e(e,M){const t=GF(M),{s:i,w:u}=ue.useContext(t);return ue.useCallback(n=>{if(({VITE_END_POINT:"https://api.usedatabrain.com",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&!("write"in e))throw new Error("not writable atom");const r=a=>i[mQ](e,n,a);return u?u(r):r()},[i,u,e])}function RQ(e,M){return"scope"in e&&(console.warn("atom.scope is deprecated. Please do useAtom(atom, scope) instead."),M=e.scope),[d0e(e,M),f0e(e,M)]}const PQ=({onOutsideClick:e,wrapRef:M,portalRef:t})=>{ue.useEffect(()=>{const i=u=>{const N=M.current&&!M.current.contains("composedPath"in u?u.composedPath()[0]:u.target),n=t&&!t.contains("composedPath"in u?u.composedPath()[0]:u.target);t?N&&n&&e():N&&e()};return document.addEventListener("click",i,!0),()=>{document.removeEventListener("click",i,!0)}},[M,e,t])},C0e=({wrapRef:e,portalRef:M,autoCloseParent:t=!1})=>{const[i]=RQ(Zie);ue.useEffect(()=>{const u=N=>{i==null||i.forEach(n=>{var a,D,j,o,s,L;if(!(((a=n.popperElement)==null?void 0:a.contains("composedPath"in N?N.composedPath()[0]:N.target))||((D=n.referenceElement)==null?void 0:D.contains("composedPath"in N?N.composedPath()[0]:N.target)))){const g=i.find(c=>{var I,z;const l=((I=n.popperElement)==null?void 0:I.contains(c.referenceElement))&&(c.isOpen===!0||c.isMenuOpen===!0);return t?l&&((z=c.popperElement)==null?void 0:z.contains("composedPath"in N?N.composedPath()[0]:N.target)):l});g?((j=g==null?void 0:g.setOpen)==null||j.call(g,!0),(o=g==null?void 0:g.setMenuOpen)==null||o.call(g,!0)):((s=n.setOpen)==null||s.call(n,!1),(L=n.setMenuOpen)==null||L.call(n,!1))}})};return document.addEventListener("click",u,!0),()=>{document.removeEventListener("click",u,!0)}},[e,M,i])},w0e=({token:e,dashboardId:M})=>Vl([YF,{dashboardId:M}],()=>{const t=M?`${Ea}?dashboardId=${M}`:Ea;return o4(t,{method:"GET",token:e})},{enabled:!!e}),h0e=(e,M)=>Vl([mF,{dashboardId:e,clientId:M}],()=>o4(`${gLe}?id=${e}&clientId=${M}`,{method:"GET"}),{enabled:!!e&&!!M}),p0e=e=>Vl(TLe,()=>o4(cLe,{method:"GET",token:e}),{enabled:!!e}),Q0e=(e,M)=>Vl([LLe,{id:M}],()=>o4(`${sLe}?metricId=${M}`,{method:"GET",token:e}),{enabled:!!e}),VF=({token:e,name:M,companyId:t})=>Vl([RLe,{name:M}],()=>o4(_Le,{method:"POST",token:e,data:{name:M,companyId:t}}),{enabled:!!(M&&e&&t)}),v0e=({externalDashboardId:e,clientId:M})=>{const t=oE(),{data:i,isLoading:u}=h0e(e,M),[N,n]=ue.useMemo(()=>{const j=i;return[(j==null?void 0:j.layout)||[],!!(j!=null&&j.isLocked)]},[i]),{mutateAsync:r,isLoading:a}=M0e();return{saveLayout:ue.useCallback(async(j,o)=>{await r({clientId:M,externalDashboardId:e,layout:j,isLocked:!!o},{onSuccess:s=>{if(!s)return;const L=s;t.setQueryData([mF,{dashboardId:e,clientId:M}],g=>({...g,...L}))}})},[r,M,e]),layout:N,isLayoutLocked:n,isLoadingLayout:u||a}},k0e=({query:e,limit:M,offset:t,dbName:i})=>{let u=e.replace(/;(^;]*)$/,"");const N=parseInt(M,10);if(u.toLowerCase().includes("limit")){const n=parseInt(u.toLowerCase().split("limit")[1].trim(),10),r=t?M:Math.min(n,N);(i==null?void 0:i.toLowerCase())==U5?(u=u.replace(`limit ${n}`,`order by(select null) ${`offset ${t||0} rows`} fetch next ${r} rows only`),u=u.replace(`LIMIT ${n}`,`ORDER BY(SELECT NULL) ${`OFFSET ${t||0} ROWS`}
991
991
  FETCH NEXT ${r} ROWS ONLY`)):(u=u.replace(`limit ${n}`,`limit ${r} ${t?`OFFSET ${t}`:""}`),u=u.replace(`LIMIT ${n}`,`LIMIT ${r} ${t?`OFFSET ${t}`:""}`))}else(i==null?void 0:i.toLowerCase())==U5?u+=` order by(select null) ${`offset ${t||0} rows`} fetch next ${N} rows only`:u+=` limit ${N} ${t?`OFFSET ${t}`:""}`;return u},U0e=({limit:e,query:M,dbName:t,clientName:i,tenancyType:u,values:N})=>{const n=k0e({query:M,limit:e,dbName:t}),r=i?u===hz?n.replace(new RegExp(CP,"g"),i):Number(i)?n.replace(new RegExp(_S,"g"),i):n.replace(new RegExp(SP,"g"),i):n;return N?r.replace(/[^']+_variable/g,D=>`${N[D]}`):r},Y0e=({clientName:e,dbName:M,tenancyType:t,values:i,query:u,companyId:N,workspaceId:n,metricId:r})=>{const{mutate:a}=s0e();return{getUnderlyingData:({columnName:j,value:o,setData:s,setLoading:L,isSingleValueChart:g})=>{const c=U0e({query:u,limit:"5000",clientName:e,tenancyType:t,values:i,dbName:M});s([]),L(!0),a({columnName:g?void 0:j,companyId:N,query:c,value:g||o==null?void 0:o.replace(/'/g,"''"),workspaceId:n,metricId:r},{onSuccess(l){const I=l==null?void 0:l.data;I&&Array.isArray(I)&&I.length?(s(I),L(!1)):(s([]),L(!1))},onError(){s([]),L(!1)}})}}},m0e=({clientId:e,data:M,token:t,isFrontendApp:i})=>Vl([FLe,M,e],()=>o4(PLe,{method:"POST",data:M,isFrontend:i,clientId:e,token:t}),{enabled:!!M.id}),b0e=e=>Vl([WLe,e],()=>o4(`${VLe}?id=${e}`,{method:"GET"}),{enabled:!!e}),WF=e=>e instanceof Date&&!Number.isNaN(e.getTime()),_0e=new Set(["mysql","mssql","mongodb","clickhouse","awss3"]),R0e=()=>new Date().getMonth()===0,P0e=()=>{const e=new Date,M=e.getMonth(),t=e.getDate();return M===0&&t===1},F0e=()=>{const e=new Date,M=e.getFullYear(),t=new Date(M,0,1),i=Math.floor((+e-+t)/(24*60*60*1e3));return Math.ceil((i+t.getDay()+1)/7)===1},G0e=({isTimeColumn:e,timeColumnName:M,timeCount:t,timeGrain:i,timeRangeIndicator:u,databaseType:N,endDate:n=new Date,startDate:r=new Date,comparsionOperator:a})=>{const D=N==null?void 0:N.toLowerCase();let j="";const o=_0e.has(D||"");switch(u){case"last":if(t===1){const s=R0e(),L=`${s?"- 1":""}`;if(i==="day"){const g=P0e();if(D==="bigquery"){const c=`${g?"365":`EXTRACT(DAYOFYEAR FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) - ${t}`}`;j=`EXTRACT(DAYOFYEAR FROM ${M}) = ${c} AND EXTRACT(YEAR FROM ${M}) = EXTRACT(YEAR FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) ${g?L:""}`}else if(o){const c=`${g?"365":`DAYOFYEAR(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"}) - ${t}`}`;j=`DAYOFYEAR(${M}) = ${c} AND YEAR(${M}) = YEAR(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"}) ${g?L:""}`}else{const c=`${g?"365":`EXTRACT('doy' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) - ${t}`}`;j=`EXTRACT('doy' FROM ${M}) = ${c} AND EXTRACT('year' FROM ${M}) = EXTRACT('year' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) ${g?L:""}`}}else if(i==="year")D==="bigquery"?j=`EXTRACT(YEAR FROM ${M}) = EXTRACT(YEAR FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) - ${t}`:o?j=`YEAR(${M}) = YEAR(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"}) - ${t}`:j=`EXTRACT('year' FROM ${M}) = EXTRACT('year' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) - ${t}`;else if(i==="quarter")D==="bigquery"?j=`EXTRACT(QUARTER FROM ${M}) = EXTRACT(QUARTER FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) - ${t} AND EXTRACT(YEAR FROM ${M}) = EXTRACT(YEAR FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"})`:o?j=`QUARTER(${M}) = QUARTER(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"}) - ${t} AND YEAR(${M}) = YEAR(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"})`:j=`EXTRACT('quarter' FROM ${M}) = EXTRACT('quarter' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) - ${t} AND EXTRACT('year' FROM ${M}) = EXTRACT('year' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"})`;else if(i==="week"){const g=F0e();if(D==="bigquery"){const c=`${g?"4":`EXTRACT(WEEK FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) - ${t}`}`;j=`EXTRACT(WEEK FROM ${M}) = ${c} AND EXTRACT(YEAR FROM ${M}) = EXTRACT(YEAR FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) ${L}`}else if(o){const c=`${g?"4":`WEEK(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"}) - ${t}`}`;j=`WEEK(${M}) = ${c} AND YEAR(${M}) = YEAR(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"}) ${L}`}else{const c=`${g?"4":`EXTRACT('week' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) - ${t}`}`;j=`EXTRACT('week' FROM ${M}) = ${c} AND EXTRACT('year' FROM ${M}) = EXTRACT('year' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) ${L}`}}else if(i==="month")if(D==="bigquery"){const g=`${s?"12":`EXTRACT(MONTH FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) - ${t}`}`;j=`EXTRACT(MONTH FROM ${M}) = ${g} AND EXTRACT(YEAR FROM ${M}) = EXTRACT(YEAR FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) ${L}`}else if(o){const g=`${s?"12":`MONTH(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"}) - ${t}`}`;j=`MONTH(${M}) = ${g} AND YEAR(${M}) = YEAR(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"}) ${L}`}else{const g=`${s?"12":`EXTRACT('month' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) - ${t}`}`;j=`EXTRACT('month' FROM ${M}) = ${g} AND EXTRACT('year' FROM ${M}) = EXTRACT('year' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) ${L}`}}else if(D==="bigquery"){const s=`INTERVAL ${t} ${i.toUpperCase()}`;j=`${M} >= DATE_SUB( CURRENT_DATE(), ${s})
992
992
  AND ${M} < CURRENT_DATE()`}else if(o){const s=`${t} ${i}`;j=`${M} >= ${e?"CURRENT_TIMESTAMP()":"CURDATE()"} - INTERVAL ${s} AND ${M} < ${e?"CURRENT_TIMESTAMP()":"CURDATE()"}`}else{const s=`INTERVAL '${t} ${i}s'`;j=`${M} >= ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"} - ${s} AND ${M} < ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}`}break;case"this":i==="day"?D==="bigquery"?j=`EXTRACT(DAYOFYEAR FROM ${M}) = EXTRACT(DAYOFYEAR FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) AND EXTRACT(YEAR FROM ${M}) = EXTRACT(YEAR FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"})`:o?j=`DAYOFYEAR(${M}) = DAYOFYEAR(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"}) AND YEAR(${M}) = YEAR(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"})`:j=`EXTRACT('doy' FROM ${M}) = EXTRACT('doy' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) AND EXTRACT('year' FROM ${M}) = EXTRACT('year' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"})`:i==="year"?D==="bigquery"?j=`EXTRACT(YEAR FROM ${M}) = EXTRACT(YEAR FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"})`:o?j=`YEAR(${M}) = YEAR(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"})`:j=`EXTRACT('year' FROM ${M}) = EXTRACT('year' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"})`:i==="quarter"?D==="bigquery"?j=`EXTRACT(QUARTER FROM ${M}) = EXTRACT(QUARTER FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) AND EXTRACT(YEAR FROM ${M}) = EXTRACT(YEAR FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"})`:o?j=`QUARTER(${M}) = QUARTER(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"}) AND YEAR(${M}) = YEAR(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"})`:j=`EXTRACT('quarter' FROM ${M}) = EXTRACT('quarter' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) AND EXTRACT('year' FROM ${M}) = EXTRACT('year' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"})`:i==="week"?D==="bigquery"?j=`EXTRACT(WEEK FROM ${M}) = EXTRACT(WEEK FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) AND EXTRACT(YEAR FROM ${M}) = EXTRACT(YEAR FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"})`:o?j=`WEEK(${M}) = WEEK(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"}) AND YEAR(${M}) = YEAR(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"})`:j=`EXTRACT('week' FROM ${M}) = EXTRACT('week' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) AND EXTRACT('year' FROM ${M}) = EXTRACT('year' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"})`:i==="month"&&(D==="bigquery"?j=`EXTRACT(MONTH FROM ${M}) = EXTRACT(MONTH FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) AND EXTRACT(YEAR FROM ${M}) = EXTRACT(YEAR FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"})`:o?j=`MONTH(${M}) = MONTH(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"}) AND YEAR(${M}) = YEAR(${e?"CURRENT_TIMESTAMP()":"CURRENT_DATE()"})`:j=`EXTRACT('month' FROM ${M}) = EXTRACT('month' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"}) AND EXTRACT('year' FROM ${M}) = EXTRACT('year' FROM ${e?"CURRENT_TIMESTAMP":"CURRENT_DATE"})`);break;case"custom date":{const L=new Date(r).toISOString().slice(0,10);j=`${M} ${a||"="} '${L}'`;break}default:{const s=new Date(r),L=new Date(n);if(WF(s)&&WF(L)){const g=s.toISOString().slice(0,10),c=L.toISOString().slice(0,10);j=`${M} BETWEEN '${g}' AND '${c}'`}else{const g=new Date().toISOString().slice(0,10),c=new Date().toISOString().slice(0,10);j=`${M} BETWEEN '${g}' AND '${c}'`}break}}return j},HF=(e,M)=>e.reduce((t,i)=>{const u=i[M];return u&&(t[u]||(t[u]=[]),t[u].push(i)),t},{}),gs=({clientId:e,query:M,tenancyLevel:t,isAllClient:i})=>{if(!e)return M;if(t===hz)return M.replace(new RegExp(CP,"g"),e.toString());if(typeof e===w5){const N=new RegExp(`=\\s*['"]?${_S}['"]?`,"g");return i?M.replace(N,RS):M.replace(new RegExp(_S,"g"),e.toString())}const u=new RegExp(`=\\s*['"]?${_S}['"]?`,"g");return i?M.replace(u,RS):M.replace(new RegExp(SP,"g"),`${e}`)},B0e=(e,M)=>Array.isArray(e)?` ( ${e.map(t=>`'${t}'`).join(" , ")} ) `:M===_D?`${e}`:` '${e}' `,bz=(e,M,t)=>e.replace(new RegExp(M,"g"),t),$F=e=>{var r,a;const M=(e==null?void 0:e.startDate)||((r=new Date(new Date().setFullYear(1,0,1)))==null?void 0:r.toJSON()),t=(e==null?void 0:e.endDate)||((a=new Date)==null?void 0:a.toJSON()),i=new Date(M),u=new Date(t),N=` '${i==null?void 0:i.toISOString().slice(0,10)}' `,n=` '${u==null?void 0:u.toISOString().slice(0,10)}' `;return{startDate:N,endDate:n}},ZF=(e,M,t)=>{let i=e;const{endDate:u,startDate:N}=$F(M);return t.startVariable&&(i=bz(i,t.startVariable,N)),t.endVariable&&(i=bz(i,t.endVariable,u)),i},V0e=(e,M)=>{let t=e;return M.forEach(i=>{var L,g,c,l,I,z;const u=i.datatype,N=(L=i.filterVariant)==null?void 0:L.value,n=u===Bn&&N,r=i.value,a=(g=i.variableStrings)==null?void 0:g[0],D=(c=i.variableStrings)==null?void 0:c[1],j=[Bn,hP,pP,w5].includes(u),o=u===w5,s=u===Aa;if(a&&(n||j||s)){const O=!r&&!((l=i.selectedVariableValue)!=null&&l.value);if(s&&D)t=ZF(t,i.selectedVariableValue,{startVariable:a,endVariable:D});else if(O){const f=new RegExp(`(\\S+)\\s*['"]?\\S*${a}\\S*['"]?`,"g");t=t.replace(f,RS)}else{let f=` '${(I=i.selectedVariableValue)==null?void 0:I.value}' `;n&&(f=B0e(r,N)),o&&(f=`${Number((z=i.selectedVariableValue)==null?void 0:z.value)||0}`),t=bz(t,a,f)}}}),t},W0e=(e,M)=>{let t=e;return M.forEach(i=>{var g,c,l,I,z,O;const u=i.as,N=u===w5,n=(g=i.variableStrings)==null?void 0:g[0],r=(c=i.variableStrings)==null?void 0:c[1],a=i.value,D=u===Aa,j=(l=i.filterVariant)==null?void 0:l.value,o=u===Bn&&j,s=[Bn,hP,pP].includes(u||""),L=!a;if(N){const f=L?" 0 ":` ${(I=a==null?void 0:a.split(iQ))==null?void 0:I[0]} `,S=L?` ${Number.MAX_SAFE_INTEGER} `:` ${(z=a==null?void 0:a.split(iQ))==null?void 0:z[1]} `;n&&(t=bz(t,n,f)),r&&(t=bz(t,r,S))}else if((o||s)&&n)if(L){const f=new RegExp(`(\\S+)\\s*['"]?\\S*${n}\\S*['"]?`,"g");t=t.replace(f,RS)}else{let f=Array.isArray(i.value)?` (${(O=i==null?void 0:i.value)==null?void 0:O.map(S=>`${S}`).join(", ")}) `:` ${i.value} `;j===_D&&(f=`${f==null?void 0:f.replace(/'/g,"").replace(/%/g,"")}`),t=bz(t,n,f)}else D&&(t=ZF(t,a,{startVariable:n,endVariable:r}))}),t},H0e=({query:e,rlsConditions:M,tenancyLevel:t,clientId:i,values:u,isAllClient:N,globalFilters:n})=>{var j;let r=gs({clientId:i,query:e,tenancyLevel:t,isAllClient:N});const a=M.filter(o=>o.isAddOnMetrics&&o.isVariableFilter);a.length&&(r=V0e(r,a));const D=((j=n==null?void 0:n.filters)==null?void 0:j.filter(o=>o.isVariableFilter))||[];return D.length&&(r=W0e(r,D)),u&&(r=r.replace(/[^']+_variable/g,o=>`${u[o]}`)),r},d1=(e,M)=>{switch(M.toLowerCase()){case PP:case k5:case U5:case jQ:case sQ:case GP:return`"${e}"`;case sse:case DQ:case oQ:case FP:case Lse:return`\`${e}\``;default:return`${e.replace(" ","_")}`}},TE=(e,M,t)=>{const i=t.toLowerCase(),u=M===w5,N=M===Bn,n=M===Aa;let r="";return u?r=i===oQ||i===DQ||i===U5?Woe:Hoe:N?i===PP||i===k5||i===jQ||i===GP?r=$oe:i===oQ||i===DQ||i===U5?r=Zoe:r=Joe:n&&(i===sQ?r="":r=Xoe),r?`${Koe}(${d1(e,i)} ${r})`:d1(e,i)},JF=(e,M,t)=>{var c,l,I,z,O;const i=(t==null?void 0:t.toLowerCase())===sQ,u=(t==null?void 0:t.toLowerCase())===FP;let N=M;const n=i?(I=(l=(c=e.tableName)==null?void 0:c.split("."))==null?void 0:l.slice(1))==null?void 0:I.join("."):e.tableName,r=u?n.split(".").map(f=>`${d1(f,t)}`).join("."):n.split(/\.(?=[^.]*$)/).map(f=>`${d1(f,t)}`).join("."),a=n,D=((z=n==null?void 0:n.split(/\.(?=[^.]*$)/))==null?void 0:z[0])||"",j=((O=n==null?void 0:n.split(/\.(?=[^.]*$)/))==null?void 0:O[1])||"",o=`${u&&(D!=null&&D.includes("."))?`${D.split(".").map(f=>d1(f,t)).join(".")}`:d1(D,t)}.${j}`,s=`${D}.${d1(j,t)}`,g=[r,a,o,s].find(f=>N.includes(f));if(g){const f=new RegExp(`${g}\\s*WHERE`,"gi"),S=`\\s*AS\\s*['"]?[^"'\\s]+['"]?\\s*WHERE`,E=new RegExp(`${g}${S}`,"gi"),p=new RegExp(`FROM\\s*${g}\\s*AS\\s*['"]?[^"'\\s]+['"]?\\s*`,"gi"),Q=new RegExp(`\\s*${g}\\s*AS\\s*['"]?[^"'\\s]+['"]?\\s*(?:\\s*[^"'\\s]+)?\\s*?JOIN`,"gi"),k=new RegExp(`\\s*${g}\\s*(?:\\s*[^"'\\s]+)?\\s*?JOIN`,"gi"),v=new RegExp(`\\s*${g}\\s*AS\\s*['"]?[^"'\\s]+['"]?\\s*ON`,"gi"),h=new RegExp(`\\s*${g}\\s*ON`,"gi"),w=f.test(N),m=E.test(N),Y=p.test(N),R=Q.test(N),P=k.test(N),V=v.test(N),H=h.test(N);if(w||m)N=N.replace(m?E:f,Z=>`${Z} ${e.condition} AND `);else if(R||P||V||H)N=P||H?N.replace(g,Z=>` ( SELECT * from ${Z} WHERE ${e.condition} ) AS ${d1(j,t)} `):N.replace(g,Z=>` ( SELECT * from ${Z} WHERE ${e.condition} ) `);else{const Z=Y?p:g;N=N.replace(Z,G=>` ${G} WHERE ${e.condition} `)}}return N},$0e=(e,M)=>{var r,a,D;const t=e.options||[],i=e.value,u=(r=e.applyOnColumns)==null?void 0:r.length,N=(j,o)=>{var s,L,g,c,l,I,z;return G0e({isTimeColumn:!!e.datatype,timeColumnName:TE(j,Aa,M),timeCount:((s=t==null?void 0:t.find(O=>O.name===i))==null?void 0:s.count)||1,timeGrain:((g=(L=t==null?void 0:t.find(O=>O.name===i))==null?void 0:L.time)==null?void 0:g.toLowerCase())||qoe,timeRangeIndicator:((l=(c=t==null?void 0:t.find(O=>O.name===i))==null?void 0:c.range)==null?void 0:l.toLowerCase())||ese,databaseType:M==null?void 0:M.toLowerCase(),endDate:(I=t==null?void 0:t.find(O=>O.name===i))==null?void 0:I.endDate,startDate:(z=t==null?void 0:t.find(O=>O.name===i))==null?void 0:z.startDate,comparsionOperator:o})},n=u?` ${(a=e.applyOnColumns)==null?void 0:a.map(j=>{var L;const o=j.logicalOperator.value||iQ,s=N(j.columnName.value,(L=j.comparisonOperator)==null?void 0:L.value);return` ${o} ${s} `}).join(" ")} `:"";return` ${N(e.columnName,(D=e.comparisonOperator)==null?void 0:D.value)} ${n}`},XF=(e,M)=>{let t=e.value;const i=Array.isArray(t),u=typeof t===Bn;return i&&(t=` (${t==null?void 0:t.map(N=>typeof N===Bn?`'${N}'`:N).join(", ")}) `),u&&(t=` '${t}' `),` ${TE(e.columnName,e.datatype,M)} ${i?Oa:xa} ${t} `},Z0e=(e,M)=>{var n,r;if(!e.value)return"";const t=TE(e.columnName,e.datatype,M),i=((n=e.filterVariant)==null?void 0:n.value)||"",u=Array.isArray(e.value);let N=e.value;switch(i){case xa:N=u?N==null?void 0:N[0]:` '${N}' `;break;case Oa:N=` ( ${(r=u?N:[N])==null?void 0:r.map(a=>`'${a}'`).join(" , ")} ) `;break;case _D:N=` '%${u?N==null?void 0:N[0]:N}%' `;break;default:N=e.value;break}return` ${t} ${i} ${N} `},J0e=(e,M,t)=>{let i=e;return Object.keys(M).map(N=>{const n=M[N].map(r=>{var a;switch(r.datatype){case Aa:return` ${$0e(r,t)} `;case Bn:return(a=r.filterVariant)!=null&&a.value?`${Z0e(r,t)}`:` ${XF(r,t)} `;default:return` ${XF(r,t)} `}});return{tableName:N,condition:n.join(" AND ")}}).forEach(N=>{i=JF(N,i,t)}),i},X0e=({rlsConditions:e,dbName:M,query:t})=>{const i=HF(e.filter(N=>N.isAddOnMetrics),"tableName");return J0e(t,i,M)},Wl=({query:e,clientId:M="",rlsConditions:t,globalFilters:i={filters:[],tableName:""},dbName:u,tenancyLevel:N,values:n,isAllClient:r})=>{var O;const a=H0e({isAllClient:r,query:e,rlsConditions:t,tenancyLevel:N,clientId:M,values:n,globalFilters:i}),D=t.filter(f=>f.isAddOnMetrics&&!f.isVariableFilter);if(((O=i==null?void 0:i.filters)==null?void 0:O.length)===0&&D.length===0)return a;const j=X0e({rlsConditions:D,dbName:u,query:a}),{filters:o,tableName:s}=i,L=(o==null?void 0:o.filter(f=>!f.isVariableFilter))||[];if(L.length===0)return j;const c=L.map(f=>{var S;return(S=f==null?void 0:f.applyOnTables)!=null&&S.length?f:{...f,applyOnTables:[{tableName:s,columnName:f.column,dataType:f.as}]}}).flatMap(f=>{var S;return(S=f.applyOnTables)==null?void 0:S.map(E=>({...f,tableName:E.tableName,column:E.columnName,dataType:E.dataType}))})||[],l=HF(c==null?void 0:c.filter(f=>f==null?void 0:f.column),"tableName"),I=Object.keys(l).map(f=>({condition:l[f].map(({column:E,operator:p,value:Q,as:k})=>{const v=k===Aa,h=v&&typeof Q===Bn,w=Array.isArray(Q),m=TE(E,k,u);let Y=Q;if(!h){if(w)Y=` (${Q.map(R=>`${R}`).join(", ")}) `;else if(v){const{endDate:R,startDate:P}=$F(Q);Y=` ${P} AND ${R} `}}return k===Aa&&typeof Q===Bn?` ${Q} `:` ${m} ${p} ${Y} `}).join(" AND "),tableName:f}));let z=j;return I.forEach(f=>{z=JF(f,z,u)}),z},K0e=e=>{var M,t,i;if(!(e!=null&&e.filterType)&&!(e!=null&&e.isVariableFilter)){if(!e.value)return!1;if(e.datatype===Bn)return Array.isArray(e.value)&&e.value.length;if(e.datatype===Aa){const u=(M=e==null?void 0:e.options)==null?void 0:M.find(N=>N.name===(e==null?void 0:e.value));if(["Custom","Custom Date"].includes((u==null?void 0:u.range)||""))return(u==null?void 0:u.startDate)&&(u==null?void 0:u.endDate)}}if(e!=null&&e.filterType&&!(e!=null&&e.isVariableFilter)){if(!e.value)return!1;if([_D,"="].includes(((t=e.filterVariant)==null?void 0:t.value)||"")&&e.datatype===Bn)return!!e.value;if(["auto","custom"].includes(e==null?void 0:e.filterType)||(e==null?void 0:e.datatype)!==Aa)return Array.isArray(e.value)&&e.value.length;if(e.datatype===Aa){const u=(i=e==null?void 0:e.options)==null?void 0:i.find(N=>N.name===(e==null?void 0:e.value));if(["Custom","Custom Date","Date Range"].includes((u==null?void 0:u.range)||""))return(u==null?void 0:u.startDate)&&(u==null?void 0:u.endDate)}}return!0},VN=({column:e,setAppliedFilters:M,value:t,operator:i,type:u})=>{const N=e.isVariableFilter,n=!(!N&&!t)&&e.isShowHorizontal;let r="";const a=Array.isArray(t)?"":t==null?void 0:t.label,D=Array.isArray(t)?t:[];switch(u){case os:Array.isArray(t)&&t.length?r=t.map(o=>o.value):r=N?void 0:[];break;case ss:typeof(t==null?void 0:t.value)=="string"&&(t==null?void 0:t.value)?r=t==null?void 0:t.value:r=N?void 0:"";break;case PS:typeof t=="string"&&t?r=t:r=N?void 0:"*";break;case tse:!!t?r=t:r=void 0;break;case FS:(t==null?void 0:t.startDate)&&(t==null?void 0:t.endDate)?r=t:r=void 0;break;default:r=void 0;break}M(j=>{const o={column:e.name,labelColumnName:e.labelColumnName,operator:i,value:r,as:e.as,defaultValues:t,filterType:e.isShowHorizontal?"horizontal":"global",isFilterApplied:n,applyOnTables:e.applyOnTables,isVariableFilter:N,variableStrings:e.variableStrings||[],label:e.label||e.name,filterVariant:e.filterVariant,selectedDropdownValue:Array.isArray(t)?D:{value:r,label:a}},s=j.findIndex(g=>g.label===e.label);if(s===-1)return[...j,o];const L=[...j];return L[s]=o,L})},PD=(e,M)=>{switch(M.toLowerCase()){case k5:return e.toLowerCase();case jQ:return e.toUpperCase();default:return e}},FQ=e=>{const t=e.slice(0,100).flatMap(n=>Object.entries(n)),i={};t.forEach(([n,r])=>{i[n]?i[n][Number(r)||Number(r)===0?"number":"other"]=(i[n][Number(r)||Number(r)===0?"number":"other"]||0)+1:i[n]={[Number(r)||Number(r)===0?"number":"other"]:1}});const u=[],N=[];return Object.entries(i).forEach(([n,r])=>{Object.entries(r).reduce((D,j)=>D[1]>j[1]?D:j)[0]==="number"?u.push(n):N.push(n)}),{numberKeys:u,otherKeys:N}},GQ=e=>{const{numberKeys:M,otherKeys:t}=FQ(e),i=M.length+t.length;if(i===1&&M.length)return[se.singleValue,se.table,se.gauge];if(M.length===0)return[se.table,se.singleValue];if(M.length>=1){const u=Object.values(se);return i<3?u.filter(N=>N!==se.sankey):u}return[]},q0e=({data:e,setChartSettings:M})=>{const{numberKeys:t,otherKeys:i}=FQ(e||[]),u=GQ(e||[]);(t==null?void 0:t.length)===1&&(i==null?void 0:i.length)===0?M(N=>{var n,r,a;return{...N,chartType:u.filter(D=>D!==se.timeSeries).includes(N.chartType)?N.chartType:se.singleValue,singleValue:t.includes(N.singleValue||"")?N.singleValue:t[0],yAxisList:(r=(n=N.yAxisList)==null?void 0:n.filter(D=>t.includes(D)))!=null&&r.length?(a=N.yAxisList)==null?void 0:a.filter(D=>t.includes(D)):t,sankeyValues:[]}}):(t==null?void 0:t.length)===0?M(N=>{var n,r,a;return{...N,chartType:u.filter(D=>D!==se.timeSeries).includes(N.chartType)?N.chartType:"table",yAxisList:(r=(n=N.yAxisList)==null?void 0:n.filter(D=>i.includes(D)))!=null&&r.length?(a=N.yAxisList)==null?void 0:a.filter(D=>i.includes(D)):i,singleValue:i.includes(N.singleValue||"")?N.singleValue:i[0],sankeyValues:[]}}):M(N=>{var n,r,a;return{...N,chartType:u.includes(N.chartType)?N.chartType:"bar",yAxisList:(r=(n=N.yAxisList)==null?void 0:n.filter(D=>t.includes(D)))!=null&&r.length?(a=N.yAxisList)==null?void 0:a.filter(D=>t.includes(D)):t,xAxis:i!=null&&i.includes(N.xAxis||"")||t!=null&&t.includes(N.xAxis||"")?N.xAxis:(i==null?void 0:i[0])||(t==null?void 0:t[0]),sankeyValues:[(t==null?void 0:t[1])||(i==null?void 0:i[0])||"",(t==null?void 0:t[2])||(i==null?void 0:i[1])||"",(t==null?void 0:t[0])||""]}})},ege=(e,M)=>{var u,N,n,r;const t=(N=(u=M==null?void 0:M[e.name])==null?void 0:u.defaultOption)==null?void 0:N.toString(),i=((r=(n=M==null?void 0:M[e.name])==null?void 0:n.options)==null?void 0:r.filter(a=>{if(a==null)return!1;switch(e.datatype){case"string":{if(typeof a!="string"||!a)return!1;break}case"number":{if(typeof a!="number"||!Number(a))return!1;break}case"date":{if(typeof a!="object"||!a.name||!["Last","This","Custom"].includes(a.range)||a.range!=="Custom"&&!a.time&&!["Day","Week","Month","Quarter","Year"].includes(a.time))return!1;break}}return!0}))||[];return t&&i.length?{value:t,options:i}:void 0},f1=(e,M)=>{let t="";if(M)switch(parseInt(e,10).toString().length){case 1:case 2:case 3:t=e;break;case 4:t=`${e.toString().slice(0,1)}.${e.toString().slice(1,3)}k`;break;case 5:t=`${e.toString().slice(0,2)}.${e.toString().slice(2,4)}k`;break;case 6:t=`${e.toString().slice(0,3)}.${e.toString().slice(3,5)}k`;break;case 7:t=`${e.toString().slice(0,1)}.${e.toString().slice(1,3)}M`;break;case 8:t=`${e.toString().slice(0,2)}.${e.toString().slice(2,4)}M`;break;case 9:t=`${e.toString().slice(0,3)}.${e.toString().slice(3,5)}M`;break;case 10:t=`${e.toString().slice(0,1)}.${e.toString().slice(1,3)}B`;break;case 11:t=`${e.toString().slice(0,2)}.${e.toString().slice(2,4)}B`;break;case 12:t=`${e.toString().slice(0,1)}.${e.toString().slice(1,3)}T`;break;case 13:t=`${e.toString().slice(0,2)}.${e.toString().slice(2,4)}T`;break;case 15:t=`${e.toString().slice(0,3)}.${e.toString().slice(3,5)}T`;break;case 16:t=`${e.toString().slice(0,1)}.${e.toString().slice(1,3)}P`;break;case 17:t=`${e.toString().slice(0,2)}.${e.toString().slice(2,4)}P`;break}else switch(parseInt(e,10).toString().length){case 1:case 2:case 3:t=e;break;case 4:t=`${e.toString().slice(0,1)}k`;break;case 5:t=`${e.toString().slice(0,2)}k`;break;case 6:t=`${e.toString().slice(0,3)}k`;break;case 7:t=`${e.toString().slice(0,1)}M`;break;case 8:t=`${e.toString().slice(0,2)}M`;break;case 9:t=`${e.toString().slice(0,3)}M`;break;case 10:t=`${e.toString().slice(0,1)}B`;break;case 11:t=`${e.toString().slice(0,2)}B`;break;case 12:t=`${e.toString().slice(0,1)}T`;break;case 13:t=`${e.toString().slice(0,2)}T`;break;case 15:t=`${e.toString().slice(0,3)}T`;break;case 16:t=`${e.toString().slice(0,1)}P`;break;case 17:t=`${e.toString().slice(0,2)}P`;break}return t},tge=e=>{const M=document.documentElement;e.colors&&Object.entries(e.colors).forEach(([t,i])=>{t&&i&&M.style.setProperty(`--dbn-color-${t}`,`${i}`)}),e.border&&Object.entries(e.border).forEach(([t,i])=>{t&&i&&M.style.setProperty(`--dbn-border-${t}`,`${i}`)}),e.shadow&&Object.entries(e.shadow).forEach(([t,i])=>{t&&i&&M.style.setProperty(`--dbn-shadow-${t}`,`${i}`)}),e.typography&&Object.entries(e.typography).forEach(([t,i])=>{t&&i&&M.style.setProperty(`--dbn-typography-${t}`,`${i}`)}),e.breakpoint&&Object.entries(e.breakpoint).forEach(([t,i])=>{t&&i&&M.style.setProperty(`--dbn-breakpoint-${t}`,`${i}`)})},Mge=["rgb(56, 72, 211)","rgb(251, 208, 98)","rgb(234 88 12)","rgb(245 158 11)","rgb(234 179 8)","rgb(34 197 94)","rgb(4 120 87)","rgb(15 118 110)","rgb(8 145 178)","rgb(219 234 254)","rgb(30 58 138)","rgb(139 92 246)"],C1=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],KF={yearly:e=>e.getFullYear(),monthly:e=>{const M=e.getMonth(),t=e.getFullYear();return`${C1[M]} - ${t}`},weekly:e=>{const M=new Date(e.getTime());return M.setDate(e.getDate()-e.getDay()),M.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})},daily:e=>`${e.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}`,quarterly:e=>{const M=e.getMonth(),t=Math.floor(M/3)+1,i=e.getFullYear();return`Q${t} ${i}`}},FD=({data:e,xAxis:M,isDynamicXaxis:t,isGroupXAxis:i})=>Array.isArray(e)?t||i?[...new Set(e==null?void 0:e.map(u=>M&&u[M]))]:e==null?void 0:e.map(u=>M&&u[M]):[],Jr=({data:e,yAxisList:M,xAxis:t,isDynamicXaxis:i,isCumulativeBar:u,chartType:N,seriesType:n,isGroupXAxis:r})=>{const a=FD({data:e,isDynamicXaxis:i,isGroupXAxis:r,xAxis:t});if(M===void 0)return;let D=M.map((j,o)=>({label:j,data:Array.isArray(e)?i||r?a==null?void 0:a.map(s=>e.filter(g=>g[t||""]===s).reduce((g,c)=>g+Number(c[M[o]])||0,0)):e==null?void 0:e.map(s=>s[M[o]]):[],borderColor:Mge[o]}));return u&&(N===se.bar||N===se.timeSeries&&n==="bar")&&(D=D.map(j=>{var L;let o=0;const s=(L=j==null?void 0:j.data)==null?void 0:L.map(g=>(o+=g,o));return{label:j.label,data:s,borderColor:j.borderColor}})),D},ige=({data:e,measure:M,step:t})=>Array.isArray(e)&&t&&M?e==null?void 0:e.map(i=>({value:i[M],name:i[t]})):[],uge=({data:e,singleValue:M})=>Array.isArray(e)&&M?e==null?void 0:e.map(t=>t[M]):[],qF=({isTimeSeries:e,xAxis:M,data:t,selectedFormat:i,fillXAxis:u})=>{let N,n=Array.from(new Set(t==null?void 0:t.map(r=>{var a;if(e&&r[M||""]){const D=r[M||""],j=typeof D=="string"?(a=D==null?void 0:D.split("T"))==null?void 0:a[0]:D,o=new Date(j),s=KF[i||"monthly"];return s(o)}return r[M||""]})));if(i===Gj.daily&&(n=n.map(r=>new Date(r)).sort((r,a)=>r-a).map(r=>r.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"}))),N=e&&i===Gj.month?n==null?void 0:n.sort((r,a)=>{const[D,j]=r==null?void 0:r.toString().split(" - "),[o,s]=a==null?void 0:a.toString().split(" - ");return j!==s?parseInt(j,10)-parseInt(s,10):C1.indexOf(D)-C1.indexOf(o)}):n,e&&u&&i===Gj.month){const r=Array.from(new Set(N==null?void 0:N.map(s=>s.split(" - ")[1]))).sort(),a=C1.findIndex(s=>N.some(L=>L.startsWith(`${s} - ${r[0]}`))),D=C1.slice().reverse().findIndex(s=>N.some(L=>{const[g,c]=L.split(" - ");return c===r[r.length-1]&&L.endsWith(`${s} - ${c}`)})),j=C1.length-D,o=[];r.length>1?r.forEach(s=>{C1.forEach((L,g)=>{const c=`${L} - ${s}`;(s===r[0]&&g>=a||s===r[r.length-1]&&g<j||s!==r[0]&&s!==r[r.length-1])&&o.push(c)})}):C1.forEach((s,L)=>{const g=`${s} - ${r[0]}`;L>=a&&L<j&&o.push(g)}),N=[...o]}else if(e&&u&&i===Gj.quarter){const r=[];Array.from(new Set(N==null?void 0:N.map(D=>D.split(" ")[0])));const a=Array.from(new Set(N==null?void 0:N.map(D=>D.split(" ")[1]))).sort();for(let D=0;D<a.length;D+=1)for(let j=1;j<=4;j+=1){const o=`Q${j} ${a[D]}`;r.push(o)}N=r}return N},Nge=({data:e,seriesField:M})=>Array.from(new Set(e==null?void 0:e.map(t=>t[M||""]))),_z=({data:e,seriesField:M,isTimeSeries:t,xAxis:i,selectedFormat:u,fillXAxis:N,yAxisList:n,isCumulativeBar:r,chartType:a,seriesType:D})=>{const j=Nge({data:e,seriesField:M}),o=qF({data:e,isTimeSeries:t,xAxis:i,selectedFormat:u,fillXAxis:N});let s=j==null?void 0:j.map(L=>{const g=e==null?void 0:e.filter(l=>l[M||""]===L),c=o==null?void 0:o.map(l=>{var O;if(t&&l){const f=KF[u||"monthly"],S=g==null?void 0:g.filter(Q=>{var w;const k=Q[i||""],v=typeof k=="string"?(w=k==null?void 0:k.split("T"))==null?void 0:w[0]:k,h=new Date(v);return f(h)===l});let E;return S!=null&&S.length&&(E=S==null?void 0:S.reduce((Q,k)=>Q+(Number(k[(n==null?void 0:n[0])||""])||0),0)),(E==null?void 0:E.toString())?E:null}const I=(O=g==null?void 0:g.find(f=>f[i||""]===l))==null?void 0:O[(n==null?void 0:n[0])||""];return(I==null?void 0:I.toString())?I:null});return{name:L,data:c}});return r&&(a===se.bar||a===se.timeSeries&&D==="bar")&&(s=s==null?void 0:s.map(L=>{var l;let g=0;const c=(l=L==null?void 0:L.data)==null?void 0:l.map(I=>(g+=I,g));return{name:L.name,data:c}})),s},nge=({data:e,source:M,target:t,value:i,sankeyColors:u})=>{const N=[],n=[],r=[];e.forEach(s=>{if(s[M]!==s[t]){let L=!0;n==null||n.map(g=>{const[c,l]=g.split("^^^^^^");l===s[M]&&c===s[t]&&(L=!1)}),L&&(n.push(`${s[M]}^^^^^^${s[t]}`),N.push({source:s[M].toString(),target:s[t].toString(),value:s[i]}))}});const a=n==null?void 0:n.map(s=>s.split("^^^^^^")[0]),D=n==null?void 0:n.map(s=>s.split("^^^^^^")[1]);a.forEach(s=>{r.includes(s)||r.push(s)}),D.forEach(s=>{r.includes(s)||r.push(s)});let j=-1;return{nodes:r==null?void 0:r.map(s=>(j===(u==null?void 0:u.length)?j=0:j+=1,{name:s.toString(),...u!=null&&u.length?{itemStyle:{color:u[j]}}:{}})),links:N}},eG=e=>{const M="data:text/csv;charset=utf-8,";if(!e.length)return M;const t=[],i=e[0],u=Object.keys(i);t.push(`S.NO,${u.join(",").toUpperCase()}`),e.forEach((r,a)=>{const D=Object.values(r).map(j=>{if(typeof j=="number")return j;try{if(typeof j=="string"&&(j.includes(",")||j.includes(`
993
993
  `)||j.includes("\r")||j.includes('"')))return`"${j.replace(/"/g,'""')}"`}catch{return j}return j});t.push(`${a+1},${D.join(",")}`)});const N=t.join(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@databrainhq/plugin",
3
- "version": "0.14.67",
3
+ "version": "0.14.68",
4
4
  "description": "Databrain app ui plugin.",
5
5
  "author": "Databrain",
6
6
  "license": "UNLICENSED",