@datarecce/ui 1.39.0-nightly.20260310 → 1.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AuthModal-B_SYkx-_.js.map +1 -1
- package/dist/advanced.js +1 -1
- package/dist/components.js +1 -1
- package/dist/index.js +1 -1
- package/dist/{src-BhdiVCZp.js → src-CCK738Ut.js} +6 -6
- package/dist/src-CCK738Ut.js.map +1 -0
- package/dist/utils-m8zHoMN7.js.map +1 -1
- package/package.json +1 -1
- package/dist/src-BhdiVCZp.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{$ as e,A as t,D as n,G as r,J as i,K as a,M as o,N as s,O as c,R as l,W as u,_t as d,a as f,c as p,d as m,et as h,gt as g,h as _,it as v,j as y,k as b,l as x,lt as S,m as C,mt as w,n as T,nt as E,o as D,p as O,s as k,u as ee,w as te,x as ne}from"./api-CYMr4Sk7.js";import{c as re,f as A}from"./keepAlive-CkKaK4Uw.js";import{C as ie,O as ae,T as j,_ as M,a as oe,b as N,d as se,f as ce,g as P,h as le,j as ue,k as de,l as fe,m as pe,o as me,p as he,s as ge,u as F,v as _e,w as I,y as ve}from"./utils-N_TYdjhL.js";import{i as ye,n as be}from"./colors-BpyRE67g.js";import{$t as xe,A as Se,Bt as Ce,Dn as we,E as Te,Ft as Ee,Gt as De,Ht as Oe,It as ke,L as Ae,Lt as je,M as Me,Nt as Ne,O as Pe,On as L,Qt as R,Rt as Fe,S as Ie,T as Le,Tn as Re,Ut as ze,V as z,Vt as Be,Wt as Ve,Xt as He,Yt as Ue,Zt as We,_t as Ge,an as Ke,bt as qe,c as Je,d as Ye,dn as Xe,dt as Ze,en as Qe,f as $e,fn as et,gn as tt,hn as nt,j as rt,k as it,lt as at,m as ot,mn as st,n as ct,nn as lt,o as ut,on as dt,p as ft,pn as pt,pt as mt,r as ht,rn as gt,s as _t,t as vt,tt as yt,ut as bt,v as xt,w as St,wn as Ct,yn as wt,yt as Tt}from"./AuthModal-B_SYkx-_.js";import{Nt as Et,Pt as Dt,Q as Ot,a as kt,ct as At,dt as jt,i as Mt,m as Nt,n as Pt,o as Ft,r as It,s as Lt,t as Rt}from"./utils-m8zHoMN7.js";import{fetchGitHubAvatar as zt,fetchUser as Bt}from"./lib/api/user.js";import{RECCE_SUPPORT_CALENDAR_URL as Vt}from"./lib/const.js";import{EXPLORE_ACTION as Ht,EXPLORE_FORM_EVENT as Ut,EXPLORE_SOURCE as Wt,trackColumnLevelLineage as Gt,trackCopyToClipboard as Kt,trackEnvironmentConfig as qt,trackExploreAction as Jt,trackExploreActionForm as Yt,trackHistoryAction as Xt,trackInit as Zt,trackLineageSelection as Qt,trackLineageViewRender as $t,trackMultiNodesAction as en,trackNavigation as tn,trackPreviewChange as nn,trackPreviewChangeFeedback as rn,trackShareState as an,trackSingleEnvironment as on,trackStateAction as sn}from"./lib/api/track.js";import{t as cn}from"./constants-DWSSKzi8.js";import{QueryClient as ln,QueryClientProvider as un,useMutation as dn,useQuery as fn,useQueryClient as pn}from"@tanstack/react-query";import{AxiosError as mn,isAxiosError as hn}from"axios";import{Suspense as gn,createContext as _n,forwardRef as vn,memo as yn,useCallback as B,useContext as bn,useEffect as xn,useImperativeHandle as Sn,useLayoutEffect as Cn,useMemo as V,useRef as wn,useState as H}from"react";import{Fragment as U,jsx as W,jsxs as G}from"react/jsx-runtime";import K from"@mui/material/Box";import q from"@mui/material/Button";import Tn from"@mui/material/Dialog";import En from"@mui/material/DialogActions";import Dn from"@mui/material/DialogContent";import On from"@mui/material/DialogTitle";import kn from"@mui/material/Link";import J from"@mui/material/Stack";import Y from"@mui/material/Typography";import{LuExternalLink as An,LuSave as jn}from"react-icons/lu";import{alpha as Mn,useTheme as Nn}from"@mui/material/styles";import{useTheme as Pn}from"next-themes";import X from"@mui/material/IconButton";import Fn from"next/link";import{IoBookmarksOutline as In,IoClose as Ln,IoSync as Rn,IoWarning as zn}from"react-icons/io5";import Bn from"@mui/material/Divider";import Vn from"@mui/material/CircularProgress";import Z from"@mui/material/Tooltip";import{FaCloud as Hn,FaExpandArrowsAlt as Un,FaGithub as Wn,FaQuestionCircle as Gn,FaRegDotCircle as Kn,FaSlack as qn,FaUser as Jn}from"react-icons/fa";import{PiBookmarkSimple as Yn,PiCaretDown as Xn,PiChatText as Zn,PiCheckCircle as Qn,PiCircle as $n,PiCopy as er,PiExport as tr,PiInfo as nr,PiInfoFill as rr,PiMoon as ir,PiNotePencil as ar,PiPencil as or,PiPencilSimple as sr,PiPlusCircle as cr,PiRepeat as lr,PiSun as ur,PiTrashFill as dr,PiTrashSimple as fr,PiX as pr}from"react-icons/pi";import mr from"@mui/material/Chip";import{Background as hr,BackgroundVariant as gr,BaseEdge as _r,ControlButton as vr,Controls as yr,MiniMap as br,Panel as xr,Position as Sr,ReactFlow as Cr,ReactFlowProvider as wr,getBezierPath as Tr,getNodesBounds as Er,useEdgesState as Dr,useNodesState as Or,useReactFlow as kr,useStore as Ar}from"@xyflow/react";import jr from"file-saver";import Mr from"@mui/material/Checkbox";import Nr from"@mui/material/FormControlLabel";import{useCopyToClipboard as Pr,useInterval as Fr}from"usehooks-ts";import Ir from"@mui/material/Alert";import Lr from"@mui/material/Menu";import Q from"@mui/material/MenuItem";import{isEmpty as Rr}from"lodash";import{VscCircleLarge as zr,VscFeedback as Br,VscGitPullRequest as Vr,VscHistory as Hr,VscKebabVertical as Ur}from"react-icons/vsc";import Wr from"@mui/material/ListSubheader";import Gr from"@mui/material/TextField";import Kr from"@mui/material/Tab";import qr from"@mui/material/Tabs";import Jr from"@mui/material/List";import Yr from"@mui/material/ListItem";import"@xyflow/react/dist/style.css";import Xr from"@mui/material/Avatar";import Zr from"@mui/material/Popover";import{format as Qr,formatDistanceToNow as $r,parseISO as ei}from"date-fns";import{usePathname as ti,useRouter as ni,useSearchParams as ri}from"next/navigation";import{TbChecklist as ii,TbCloudUpload as ai,TbEdit as oi}from"react-icons/tb";import si from"@mui/material/ListItemIcon";import ci from"@mui/material/ListItemText";import{FiArrowRight as li,FiCopy as ui,FiInfo as di,FiPackage as fi}from"react-icons/fi";import pi from"@mui/material/Switch";import{RiArrowDownSFill as mi,RiArrowUpSFill as hi,RiMindMap as gi,RiSwapLine as _i,RiTerminalBoxLine as vi}from"react-icons/ri";import{FaBookmark as yi,FaFileImport as bi}from"react-icons/fa6";import{BiArrowFromBottom as xi,BiArrowToBottom as Si}from"react-icons/bi";import Ci from"@dagrejs/dagre";import wi from"@mui/material/Skeleton";import{AiOutlineExperiment as Ti}from"react-icons/ai";import Ei from"@mui/material/Radio";import Di from"@mui/material/RadioGroup";import Oi from"@mui/material/Table";import ki from"@mui/material/TableBody";import $ from"@mui/material/TableCell";import Ai from"@mui/material/TableContainer";import ji from"@mui/material/TableHead";import Mi from"@mui/material/TableRow";import Ni from"@mui/material/Badge";import Pi from"@mui/material/Grid";import{stripIndents as Fi}from"common-tags";import{IoMdCodeWorking as Ii}from"react-icons/io";import{DragDropContext as Li,Draggable as Ri,Droppable as zi}from"@hello-pangea/dnd";import Bi from"@mui/material/Card";import Vi from"@mui/material/CardContent";import Hi from"@mui/material/CardHeader";const Ui=_n(null);Ui.displayName=`RecceRoutingContext`;function Wi(){return bn(Ui)||{basePath:``,buildPath:e=>e,pathname:``,navigate:e=>{typeof window<`u`&&(window.location.href=e)}}}function Gi(){let{pathname:e,navigate:t}=Wi();return[e,t]}function Ki({children:e,config:t}){let n=t?.basePath??``,r=t?.pathname??``,i=t?.onNavigate,a=B(e=>n?`${n}${e.startsWith(`/`)?e:`/${e}`}`:e,[n]),o=B((e,t)=>{i?i(e,t):typeof window<`u`&&(t?.replace?(window.history.replaceState(null,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))):window.location.href=e)},[i]),s=V(()=>({basePath:n,buildPath:a,pathname:r,navigate:o}),[n,a,r,o]);return W(Ui.Provider,{value:s,children:e})}const qi=e=>new ln({defaultOptions:{queries:{staleTime:e?.staleTime??1e3*60,gcTime:e?.gcTime??1e3*60*5,retry:1,refetchOnWindowFocus:!1}}});function Ji({children:e,api:t,theme:n=`system`,routing:r,queryClient:i,runActions:a,lineage:o,checks:s,query:c,features:l={}}){let u=i?.staleTime,d=i?.gcTime,f=V(()=>qi({staleTime:u,gcTime:d}),[u,d]),{enableInstance:p=!0,enableIdleTimeout:m=!0,enableLineage:h=!0,enableRunActions:g=!0,enableChecks:_=!0,enableQuery:v=!0}=l,y=e;return y=W(Ki,{config:r,children:y}),y=W(Dt,{defaultMode:n,children:y}),y=W(re,{config:t,children:y}),y=W(un,{client:f,children:y}),v&&(y=W(Re,{sql:c?.sql,isExecuting:c?.isExecuting,error:c?.error,baseResult:c?.baseResult,currentResult:c?.currentResult,onSqlChange:c?.onSqlChange,onExecute:c?.onExecute,onCancel:c?.onCancel,children:y})),_&&(y=W(we,{checks:s?.checks,isLoading:s?.isLoading,error:s?.error,selectedCheckId:s?.selectedCheckId,onSelectCheck:s?.onSelectCheck,onCreateCheck:s?.onCreateCheck,onUpdateCheck:s?.onUpdateCheck,onDeleteCheck:s?.onDeleteCheck,onReorderChecks:s?.onReorderChecks,refetchChecks:s?.refetchChecks,children:y})),g&&(y=W(ae,{onRunAction:a?.onRunAction,onShowRunId:a?.onShowRunId,initialRunId:a?.initialRunId,initialHistoryOpen:a?.initialHistoryOpen,children:y})),h&&(y=W(P,{lineageGraph:o?.lineageGraph,envInfo:o?.envInfo,reviewMode:o?.reviewMode,cloudMode:o?.cloudMode,fileMode:o?.fileMode,fileName:o?.fileName,isDemoSite:o?.isDemoSite,isCodespace:o?.isCodespace,isLoading:o?.isLoading,error:o?.error,supportTasks:o?.supportTasks,onRefetchLineageGraph:o?.onRefetchLineageGraph,runsAggregated:o?.runsAggregated,onRefetchRunsAggregated:o?.onRefetchRunsAggregated,children:y})),m&&(y=W(ve,{children:y})),p&&(y=W(ie,{children:y})),y}function Yi({actionState:e,onCancel:t,onClose:n}){let r=()=>e.mode===`per_node`?`${e.completed} / ${e.total}`:e.currentRun?.progress?.percentage?`${e.currentRun.progress.percentage*100}%`:e.status===`completed`?`100%`:`0%`,i=e.status===`running`||e.status===`canceling`;return W(K,{sx:{bgcolor:`background.paper`,borderRadius:1,boxShadow:6},children:G(J,{direction:`row`,divider:W(Bn,{orientation:`vertical`,flexItem:!0}),spacing:2,sx:{p:`5px 15px`,mt:2},children:[G(K,{sx:{fontSize:`10pt`},children:[`Progress: `,r(),` `,e.status===`canceled`?` (canceled)`:``]}),i?W(q,{size:`small`,variant:`outlined`,onClick:t,disabled:e.status===`canceling`,children:e.status===`canceling`?`Canceling`:`Cancel`}):W(J,{direction:`row`,children:W(q,{size:`small`,variant:`outlined`,onClick:n,children:`Close`})})]})})}const Xi=({lineageGraph:e,cllInput:t,onCenterNode:n})=>{let r={cursor:`pointer`,fontFamily:`monospace`,bgcolor:Et()?`grey.700`:`grey.100`,px:.5,borderRadius:.5};if(!e)return W(U,{});if(!t)return W(U,{children:`Default View`});if(t.node_id===void 0)return W(Y,{component:`span`,children:`Impact Radius for All Changed Models`});let i=t.node_id in e.nodes?e.nodes[t.node_id].data.name:t.node_id;if(!t.column){let e=t.node_id;return G(U,{children:[W(Y,{component:`span`,sx:{mr:`5px`},children:`Impact Radius for`}),W(K,{component:`code`,onClick:()=>{n(e)},sx:r,children:i})]})}let a=`${t.node_id}_${t.column}`;return G(U,{children:[G(Y,{component:`span`,sx:{mr:`5px`},children:[`Column Lineage for`,` `]}),G(K,{component:`code`,onClick:()=>{n(a)},sx:r,children:[i,`.`,t.column]})]})},Zi=({action:e,interactive:t,viewOptions:n,lineageGraph:r,singleEnvMode:i=!1,changeAnalysisAvailable:a=!0,onShowCll:o,onResetCll:s,onCenterNode:c,setChangeAnalysisMode:l})=>{let u=n.column_level_lineage,d=!r?.catalogMetadata.current;return G(J,{direction:`row`,spacing:`5px`,children:[!i&&W(K,{sx:{borderRadius:1,boxShadow:3},children:W(Z,{enterDelay:50,title:a?d?`Please provide catalog.json to enable Impact Radius`:``:`Requires warehouse connection`,placement:`top`,children:W(`span`,{children:W(q,{size:`small`,variant:`outlined`,color:`neutral`,sx:{whiteSpace:`nowrap`,display:`inline-flex`,bgcolor:`background.paper`},disabled:!t||d||!a,startIcon:W(Kn,{}),onClick:()=>{l?.(!0),o({no_upstream:!0,change_analysis:!0})},children:`Impact Radius`})})})}),u&&G(J,{direction:`row`,alignItems:`center`,sx:{borderRadius:1,boxShadow:3,border:`1px solid`,borderColor:`divider`,bgcolor:`background.paper`,fontSize:`0.8rem`,p:`0 0.625rem`},children:[W(Xi,{lineageGraph:r,cllInput:u,onCenterNode:c}),e.isError&&W(Z,{title:`Error: ${e.error.message}`,placement:`bottom`,children:W(Y,{component:`span`,sx:{color:`error.main`,ml:`2px`,display:`inline-flex`,alignItems:`center`},children:W(K,{component:nr,sx:{color:`error.main`,fontSize:`14px`}})})}),e.isPending?W(Vn,{size:12,sx:{ml:`2px`}}):W(X,{size:`small`,sx:{ml:`2px`},"aria-label":`Reset Column Level Lineage`,onClick:()=>{s()},children:W(pr,{size:`10px`})})]})]})};function Qi({onClose:e}){let{cancel:t,actionState:n}=le();return W(Yi,{actionState:n,onCancel:t,onClose:e})}const $i=({action:e})=>{let{showColumnLevelLineage:t,resetColumnLevelLineage:n,interactive:r,viewOptions:i,centerNode:a,setChangeAnalysisMode:o}=le(),{data:s}=F(),c=s?.single_env_onboarding??!1,{lineageGraph:l,isActionAvailable:u}=M();return W(Zi,{action:e,interactive:r,viewOptions:i,lineageGraph:l,singleEnvMode:c,changeAnalysisAvailable:u(`change_analysis`),onShowCll:t,onResetCll:()=>n(),onCenterNode:a,setChangeAnalysisMode:o})};function ea(e){let{id:t,data:n}=e,{id:r}=n.node,{column:i,type:a,transformationType:o,changeStatus:s}=n,c=Ar(e=>e.transform[2]>.3),{isDark:l}=ct(),{viewOptions:u,showContextMenu:d,isNodeHighlighted:f,isNodeShowingChangeAnalysis:p}=le(),m=u.column_level_lineage?.node_id,h=i===u.column_level_lineage?.column&&r===m,g=f(t),_=p(r);return W(wt,{id:t,data:{column:i,type:a,nodeId:r,transformationType:o,changeStatus:s,isHighlighted:g,isFocused:h},showContent:c,showChangeAnalysis:_,isDark:l,onContextMenu:(t,n)=>{d(t,e)}})}const ta=yn(ea);ta.displayName=`GraphColumnNode`;function na(e){let{source:t,target:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,style:l={},markerEnd:u,data:d,isEdgeHighlighted:f}=e,p={...l};d?.changeStatus&&(p.stroke=nt(d.changeStatus).hexColor,p.strokeDasharray=`5`),!f||f(t,n)||(p.filter=`opacity(0.2) grayscale(50%)`);let[m]=Tr({sourceX:r,sourceY:i,sourcePosition:s,targetX:a,targetY:o,targetPosition:c});return W(U,{children:W(_r,{path:m,markerEnd:u,style:{...p,...l}})})}const ra=yn(na);ra.displayName=`GraphEdge`;function ia(e){let{isEdgeHighlighted:t}=le();return W(ra,{...e,isEdgeHighlighted:t})}const aa=()=>W(`svg`,{stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`,viewBox:`0 0 256 256`,height:`1em`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,children:W(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z`})}),oa=()=>W(`svg`,{stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`,viewBox:`0 0 256 256`,height:`1em`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,children:W(`path`,{d:`M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z`})});function sa({skipReason:e}){return W(mr,{size:`small`,label:G(J,{direction:`row`,sx:{fontSize:`10pt`,color:`grey.500`,alignItems:`center`,gap:`3px`},children:[W(K,{children:`Skipped`}),e&&W(Z,{title:e,children:W(K,{component:`span`,sx:{display:`flex`},children:W(aa,{})})})]}),sx:{bgcolor:`grey.100`}})}function ca({errorMessage:e}){return G(J,{direction:`row`,sx:{fontSize:`10pt`,color:`gray`,alignItems:`center`},children:[W(K,{children:`Error`}),e&&W(Z,{title:e,children:W(K,{component:`span`,sx:{display:`flex`},children:W(oa,{})})})]})}function la({result:e}){let{mismatchedColumns:t}=e,n=t>0;return W(mr,{size:`small`,sx:{bgcolor:n?`error.light`:`success.light`},label:W(J,{direction:`row`,sx:{fontSize:`10pt`,color:n?`error.main`:`success.main`,alignItems:`center`,gap:`3px`},children:n?`${t} columns mismatched`:`All columns match`})})}function ua({result:e}){let{base:t,current:n}=e,r=t===null?`N/A`:t.toLocaleString(),i=n===null?`N/A`:n.toLocaleString(),a=``,o=`grey.500`;return t!==null&&n!==null&&(n>t?(a=`↑`,o=`success.main`):n<t?(a=`↓`,o=`error.main`):a=`=`),W(mr,{size:`small`,sx:{bgcolor:`grey.100`},label:G(J,{direction:`row`,sx:{fontSize:`10pt`,alignItems:`center`,gap:`3px`},children:[W(K,{children:r}),W(K,{children:`→`}),W(K,{children:i}),a&&W(K,{component:`span`,sx:{color:o,ml:.5},children:a})]})})}function da({status:e,skipReason:t,errorMessage:n,progress:r,valueDiffResult:i,rowCountDiffResult:a,runId:o,"data-testid":s}){return e===`pending`?W(Vn,{size:16,"data-testid":s,"data-status":`pending`}):e===`skipped`?W(K,{"data-testid":s,"data-status":`skipped`,children:W(sa,{skipReason:t})}):e===`running`?r?.percentage===void 0?W(Vn,{size:16,"data-testid":s,"data-status":`running`}):W(Vn,{variant:`determinate`,value:r.percentage*100,size:16,"data-testid":s,"data-status":`running`}):e===`error`?W(K,{"data-testid":s,"data-status":`error`,children:W(ca,{errorMessage:n})}):i?W(K,{"data-testid":s,"data-status":`success`,children:W(la,{result:i})}):a?W(K,{"data-testid":s,"data-status":`success`,children:W(ua,{result:a})}):W(K,{"data-testid":s,"data-status":`success`,children:o||`Complete`})}const fa=yn(da);fa.displayName=`ActionTag`;function pa({event:e}){let t=l(e),n={create:cr,comment:Zn,approve:Qn,unapprove:$n,edit:ar,preset:Yn},r={create:`primary.main`,comment:`grey.500`,approve:`success.main`,unapprove:`grey.400`,edit:`warning.main`,preset:`secondary.main`},i=n[t],a=r[t];return W(K,{component:i,sx:{color:a,fontSize:16}})}function ma({event:e}){let{actor:t}=e,{avatarUrl:n}=Be({userId:t.user_id}),r=(t.fullname||t.login||`User`).charAt(0).toUpperCase();return W(Xr,{src:n||void 0,sx:{width:24,height:24,fontSize:`0.75rem`},children:r})}function ha({event:e}){let{actor:t}=e,n=t.fullname||t.login||`Someone`,r=$r(new Date(e.created_at),{addSuffix:!0}),i=``;switch(e.event_type){case`check_created`:i=`created this check`;break;case`approval_change`:i=e.new_value===`true`?`approved this check`:`unapproved this check`;break;case`description_change`:i=`updated the description`;break;case`name_change`:i=`renamed this check`;break;case`preset_applied`:i=`applied a preset`;break;default:i=`made a change`}return G(K,{sx:{display:`flex`,gap:1,alignItems:`flex-start`,py:1},children:[W(K,{sx:{pt:`2px`},children:W(pa,{event:e})}),W(K,{sx:{flex:1},children:G(J,{direction:`row`,spacing:.5,flexWrap:`wrap`,alignItems:`center`,children:[W(ma,{event:e}),W(Y,{variant:`body2`,fontWeight:`500`,children:n}),W(Y,{variant:`body2`,color:`text.secondary`,children:i}),W(Y,{variant:`caption`,color:`text.disabled`,children:r})]})})]})}function ga({event:e,currentUserId:t,onEdit:n,onDelete:r}){let i=Et(),[a,o]=H(!1),[s,c]=H(e.content||``),[l,u]=H(!1),[d,f]=H(!1),[p,m]=H(null),h=!!p,{actor:g}=e,_=g.fullname||g.login||`Someone`,v=$r(new Date(e.created_at),{addSuffix:!0}),y=t&&String(g.user_id)===String(t),b=()=>{c(e.content||``),o(!0)},x=()=>{c(e.content||``),o(!1)},S=async()=>{let t=s.trim();if(!t||t===e.content){x();return}if(n){u(!0);try{await n(e.id,t),o(!1)}finally{u(!1)}}},C=e=>{e.key===`Escape`?x():e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),S())},w=e=>{m(e.currentTarget)},T=()=>{m(null)},E=async()=>{if(r){f(!0);try{await r(e.id),T()}finally{f(!1)}}};return e.is_deleted?G(K,{sx:{display:`flex`,gap:1,alignItems:`center`,py:1},children:[W(K,{sx:{pt:`2px`,display:`flex`,alignItems:`center`},children:W(pa,{event:e})}),W(K,{sx:{display:`flex`,flex:1,alignItems:`center`},children:W(Y,{variant:`body2`,color:`text.disabled`,fontStyle:`italic`,children:`Comment deleted`})})]}):G(K,{sx:{display:`flex`,gap:1,alignItems:`flex-start`,py:1},children:[W(K,{sx:{pt:`2px`},children:W(pa,{event:e})}),G(K,{sx:{flex:1},children:[G(J,{direction:`row`,spacing:.5,sx:{mb:.5},flexWrap:`wrap`,alignItems:`center`,children:[W(ma,{event:e}),G(Y,{variant:`body2`,fontWeight:`500`,children:[_,y&&G(Y,{component:`span`,variant:`body2`,color:`text.secondary`,children:[` `,`(Author)`]})]}),W(Y,{variant:`caption`,color:`text.disabled`,children:v}),e.is_edited&&W(Y,{variant:`caption`,color:`text.disabled`,children:`(edited)`})]}),a?G(K,{children:[W(Gr,{value:s,onChange:e=>c(e.target.value),onKeyDown:C,size:`small`,multiline:!0,minRows:3,fullWidth:!0,disabled:l,autoFocus:!0,sx:{"& .MuiOutlinedInput-root":{bgcolor:`background.paper`,"&:focus-within":{borderColor:`primary.main`}}}}),G(J,{direction:`row`,spacing:1,sx:{mt:1},justifyContent:`flex-end`,children:[W(q,{size:`small`,variant:`text`,onClick:x,disabled:l,children:`Cancel`}),W(q,{size:`small`,variant:`contained`,onClick:S,disabled:!s.trim()||l,children:l?`Saving...`:`Save`})]})]}):G(K,{sx:{bgcolor:i?`grey.800`:`grey.50`,borderRadius:1,p:1,border:`1px solid`,borderColor:i?`grey.700`:`grey.200`,position:`relative`,"&:hover .comment-actions":{opacity:1}},children:[W(mt,{content:e.content||``,fontSize:`sm`}),y&&(n||r)&&G(J,{className:`comment-actions`,direction:`row`,spacing:0,sx:{position:`absolute`,top:4,right:4,opacity:0,transition:`opacity 0.2s`},children:[n&&W(Z,{title:`Edit comment`,children:W(X,{"aria-label":`Edit comment`,size:`small`,onClick:b,children:W(sr,{})})}),r&&G(U,{children:[W(Z,{title:`Delete comment`,children:W(X,{"aria-label":`Delete comment`,size:`small`,color:`error`,onClick:w,children:W(fr,{})})}),W(Zr,{open:h,anchorEl:p,onClose:T,anchorOrigin:{vertical:`bottom`,horizontal:`center`},transformOrigin:{vertical:`top`,horizontal:`center`},children:G(K,{sx:{p:2},children:[W(Y,{variant:`body2`,sx:{mb:2},children:`Delete this comment?`}),G(J,{direction:`row`,spacing:1,justifyContent:`flex-end`,children:[W(q,{size:`small`,variant:`text`,onClick:T,disabled:d,children:`Cancel`}),W(q,{size:`small`,variant:`contained`,color:`error`,onClick:E,disabled:d,children:d?`Deleting...`:`Delete`})]})]})})]})]})]})]})]})}function _a({event:e,currentUserId:t,onEdit:n,onDelete:r}){return e.event_type===`comment`?W(ga,{event:e,currentUserId:t,onEdit:n,onDelete:r}):W(ha,{event:e})}function va({checkId:e}){let t=Et(),{apiClient:n}=Oe(),{events:r,isLoading:i,error:a,createComment:o,isCreatingComment:s,updateComment:c,deleteComment:l}=Ye(e),{data:u}=fn({queryKey:A.user(),queryFn:()=>Bt(n),retry:!1}),d=e=>{o(e)},f=async(e,t)=>{await c({eventId:e,content:t})},p=async e=>{await l(e)};return i?W(K,{sx:{height:`100%`,p:4,display:`flex`,justifyContent:`center`,alignItems:`center`},children:W(Vn,{size:20})}):a?W(K,{sx:{height:`100%`,p:4,display:`flex`,justifyContent:`center`,alignItems:`center`},children:W(Y,{sx:{fontSize:`0.875rem`,color:`error.main`},children:`Failed to load timeline`})}):G(J,{sx:{height:`100%`,alignItems:`stretch`,borderLeft:`1px solid`,borderColor:t?`grey.700`:`grey.200`},spacing:0,children:[W(K,{sx:{px:3,py:2,borderBottom:`1px solid`,borderColor:t?`grey.700`:`grey.200`},children:W(Y,{variant:`subtitle2`,sx:{fontWeight:500},children:`Activity`})}),W(K,{sx:{flex:1,overflowY:`auto`,px:3,py:2},children:r.length===0?W(Y,{sx:{fontSize:`0.875rem`,color:`grey.500`},children:`No activity yet`}):W(J,{sx:{alignItems:`stretch`},spacing:0,children:r.map((e,n)=>G(K,{children:[W(_a,{event:e,currentUserId:u?.id,onEdit:f,onDelete:p}),n<r.length-1&&W(Bn,{sx:{borderColor:t?`grey.700`:`grey.100`}})]},e.id))})}),W(K,{sx:{px:3,py:3,borderTop:`1px solid`,borderColor:t?`grey.700`:`grey.200`,bgcolor:t?`grey.900`:`grey.50`},children:W(Ce,{onSubmit:d,isSubmitting:s})})]})}function ya({color:e}){return W(K,{component:`span`,sx:{display:`inline-block`,width:`10px`,height:`10px`,bgcolor:e,mr:1,borderRadius:`4px`}})}const ba=({defaultPrimaryKeys:e,onPrimaryKeysChange:t,...n})=>{let{lineageGraph:r,isActionAvailable:i}=M(),a=V(()=>{if(!r)return[];let e=new Set;for(let t in r.nodes){let n=r.nodes[t],i={...n.data.data.base?.columns??{},...n.data.data.current?.columns??{}};Object.entries(i).forEach(([t,n])=>{n?.unique&&e.add(t)})}return Array.from(e).sort()},[r]);return W(K,{sx:{display:`flex`},...n,children:G(J,{spacing:0,sx:{m:`0 0.5rem`},children:[G(J,{direction:`row`,alignItems:`center`,spacing:.5,children:[W(Y,{component:`label`,sx:{fontSize:`0.625rem`,color:`text.secondary`},children:`Diff with Primary Key(s) (suggested)`}),W(Z,{title:`Provide a primary key to perform query diff in data warehouse and only return changed rows.`,placement:`bottom-end`,children:W(K,{component:`span`,sx:{display:`flex`,color:`grey.600`,cursor:`help`},children:W(nr,{fontSize:`0.75rem`})})})]}),W(dt,{className:`no-track-pii-safe`,unitName:`key`,defaultValues:e,suggestionList:a,onValuesChange:t,size:`2xs`,width:`240px`,placeholder:`Select or type to add keys`,disabled:!i(`query_diff_with_primary_key`)})]})})};function xa({supportCalendarUrl:e=`https://cal.com/team/recce/chat`}){let{data:t}=j();return W(`div`,{className:`flex flex-1 h-full min-h-0 m-2 p-4 bg-blue-50 rounded-lg shadow-md justify-center`,children:G(`div`,{className:`w-4/5 flex flex-col overflow-y-auto gap-6 px-8 pb-8`,children:[G(J,{alignItems:`center`,spacing:2,children:[W(K,{sx:{p:1,bgcolor:`background.paper`,borderRadius:`50%`,display:`flex`,alignItems:`center`,justifyContent:`center`,boxShadow:2},children:W(K,{component:vi,sx:{fontSize:28,color:`iochmara.500`}})}),W(Y,{variant:`h5`,sx:{mt:2},children:`Wait, there's more!`}),G(Y,{sx:{fontSize:`1rem`,textAlign:`center`},children:[`Query functions disabled without a`,` `,W(Y,{component:`span`,sx:{fontWeight:`bold`},children:`data warehouse connection`})]})]}),W(J,{sx:{width:`50%`,mt:3,mx:`auto`},children:W(q,{color:`iochmara`,variant:`contained`,size:`large`,onClick:()=>{window.open(Rt(t,e),`_blank`)},children:`Connect to Data Warehouse`})})]})})}const Sa=()=>{let{isCustomQueries:e,setCustomQueries:t,sqlQuery:n,setBaseSqlQuery:r}=Ie();return G(K,{children:[G(J,{direction:`row`,spacing:.5,alignItems:`center`,fontSize:`0.75rem`,children:[W(Y,{variant:`body2`,sx:{fontSize:`0.75rem`},children:`Custom Queries`}),W(Z,{title:`Custom queries allow you to use two SQL queries to compare results between current and base environments.`,children:W(K,{component:`span`,sx:{display:`flex`,color:`grey.600`},children:W(rr,{fontSize:`1rem`})})})]}),W(pi,{size:`small`,checked:e,onChange:()=>{!e&&r&&r(n),t(!e)},color:`primary`})]})},Ca=()=>{let{sqlQuery:e,baseSqlQuery:t,setSqlQuery:n,setBaseSqlQuery:i,primaryKeys:o,setPrimaryKeys:s,isCustomQueries:c}=Ie(),{lineageGraph:l,envInfo:d}=M(),{featureToggles:f,singleEnv:p}=I(),m=e;d?.adapterType===`sqlmesh`&&e===`select * from {{ ref("mymodel") }}`&&(m=`select * from db.mymodel`),f.mode===`read only`&&(m=`--- Would like to do query here? Book a demo with us at ${Vt}\n${m}`);let{showRunId:g}=de(),{apiClient:_}=Oe(),{mutate:v,isPending:y}=dn({mutationFn:async e=>{function n(e){switch(e){case`query`:return u;case`query_base`:return r;case`query_diff`:return a;default:throw Error(`Unknown query type: ${e}`)}}let i=e===`query_base`?t??``:m,s=n(e),l={sql_template:i},d={nowait:!0};e===`query_diff`&&(l.primary_keys=o,c&&(l.base_sql_template=t));let{run_id:f}=await s(l,d,_);return g(f),await h(f,void 0,_)}}),b=V(()=>{let e={};if(!l)return`N/A`;for(let t in l.nodes){let n=l.nodes[t].data.data.current?.schema;n&&(e[n]=(e[n]||0)+1)}return Object.keys(e).reduce((t,n)=>e[n]>(e[t]||0)?n:t,`N/A`)},[l]);return p||f.mode===`metadata only`?G(K,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[G(K,{sx:{display:`flex`,justifyContent:`right`,alignItems:`center`,padding:`4pt 8pt`,gap:`5px`,height:`54px`,borderBottom:`1px solid`,borderColor:`divider`},children:[W(Vo,{}),W(K,{sx:{flexGrow:1}}),p?W(Z,{title:`Please configure the base environment before running the diff`,placement:`left`,children:W(`span`,{children:W(q,{variant:`contained`,disabled:!0,size:`small`,sx:{fontSize:`14px`,mt:`16px`},children:`Run Diff`})})}):W(Os,{display:f.mode===`metadata only`,children:W(q,{variant:`contained`,disabled:!0,size:`small`,sx:{fontSize:`14px`,mt:`16px`},children:`Run Diff`})})]}),W(it,{value:m,onChange:n,onRun:()=>{v(`query`)},labels:[`base (production)`,`current (${b})`],SetupGuide:f.mode===`metadata only`?W(xa,{}):W(Io,{})})]}):G(K,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[G(K,{sx:{display:`flex`,justifyContent:`right`,alignItems:`flex-end`,padding:`4pt 8pt`,gap:`5px`,height:`54px`,borderBottom:`1px solid`,borderColor:`divider`,flex:`0 0 54px`},children:[W(Vo,{}),W(Sa,{}),W(K,{sx:{flexGrow:1}}),W(ba,{defaultPrimaryKeys:o,onPrimaryKeysChange:s}),W(q,{variant:`contained`,onClick:()=>{v(`query_diff`)},disabled:y||f.disableDatabaseQuery,size:`small`,children:`Run Diff`})]}),W(K,{sx:{width:`100%`,flex:1,overflowY:`auto`},children:c?W(it,{value:m,baseValue:t,onChange:n,onChangeBase:i,onRun:()=>{v(`query`)},onRunBase:()=>{v(`query_base`)},onRunDiff:()=>{v(`query_diff`)}}):W(Se,{value:m,onChange:n,onRun:()=>{v(`query`)},onRunDiff:()=>{v(`query_diff`)}})})]})};function wa({rowCount:e}){let t=e.base,n=e.curr,r=e.base===null?`N/A`:`${e.base} Rows`,i=e.curr===null?`N/A`:`${e.curr} Rows`,a,o;t===null&&n===null?(a=`Failed to load`,o=`default`):t===null||n===null?(a=`${r} -> ${i}`,o=t===null?`success`:`error`):t===n?(a=`=`,o=`default`):(a=`${Nt(t,n)} Rows`,o=t<n?`success`:`error`);let s=z(`row_count_diff`).icon;return W(mr,{size:`small`,color:o,icon:s?W(s,{}):void 0,label:a,sx:{height:20,fontSize:`0.7rem`}})}function Ta({id:e,inverted:t}){let{lineageGraph:n,runsAggregated:r}=M(),{text:i,isDark:a}=ct(),o=r?.[e],s=n?.nodes[e];if(!o&&!s)return null;let c;if(s?.data.data.base&&s.data.data.current){let e=s.data.data.base.columns,t=s.data.data.current.columns;c=Pt(e,t)}let l;if(o?.row_count_diff){let e=o.row_count_diff.result;l=e.curr!==e.base}let u=t?i.inverted:nt(`modified`).color,d=t?i.secondary:a?`grey.700`:`grey.100`,f=z(`schema_diff`).icon;return G(K,{sx:{display:`flex`,flex:1,alignItems:`center`},children:[c!==void 0&&W(Z,{title:`Schema (${c?`changed`:`no change`})`,enterDelay:500,children:W(K,{sx:{height:16},children:f&&W(K,{component:f,sx:{color:c?u:d}})})}),W(K,{sx:{flexGrow:1}}),o?.row_count_diff&&l!==void 0&&W(Z,{title:`Row count (${l?`changed`:`=`})`,enterDelay:500,children:W(K,{children:W(wa,{rowCount:o.row_count_diff.result})})})]})}function Ea({nodeId:e,nodeName:t}){let{getNodeAction:n}=le(),r=n(e);if(!r)return null;let{status:i,skipReason:a,run:o}=r;if(i===`pending`)return W(fa,{status:`pending`});if(i===`skipped`)return W(fa,{status:`skipped`,skipReason:a});if(!o)return W(fa,{status:`pending`});let{error:s,run_id:c,progress:l}=o;if(i===`running`)return W(fa,{status:`running`,progress:{percentage:l?.percentage}});if(s)return W(fa,{status:`error`,errorMessage:s});if(o.type===`value_diff`&&o.result){let e=o.result,t=0,n=e.data.data.length;for(let n of e.data.data)n[2]<1&&t++;return W(fa,{status:`success`,valueDiffResult:{mismatchedColumns:t,totalColumns:n}})}if(S(o)&&o.result){let e=o.result[t];if(e)return W(wa,{rowCount:e})}if(o.type===`row_count`&&o.result){let e=o.result[t];if(e?.curr!==void 0&&e.curr!==null)return W(mr,{size:`small`,label:`${e.curr.toLocaleString()} Rows`,sx:{height:20,fontSize:`0.7rem`}})}return W(fa,{status:`success`,runId:c})}function Da(e){let{data:t}=e,{id:n,resourceType:r,changeStatus:i,name:a}=t,o=Ar(e=>e.transform[2]>.3),{isDark:s}=ct(),{interactive:c,selectNode:l,selectMode:u,focusedNode:d,getNodeAction:f,getNodeColumnSet:p,isNodeHighlighted:m,isNodeSelected:h,isNodeShowingChangeAnalysis:g,showContextMenu:_,viewOptions:v,cll:y,showColumnLevelLineage:b,setChangeAnalysisMode:x}=le(),{isActionAvailable:S}=M(),C=y?.current.nodes[n]?.change_category,w=m(n),T=h(n),E=v.column_level_lineage?.node_id===n&&v.column_level_lineage.column===void 0,D=d?.id===n||E,O=g(n),k=p(t.id),ee=u===`action_result`?f(t.id):void 0,te=i,ne=u,re=u===`action_result`&&ee?W(Ea,{nodeId:n,nodeName:a}):void 0,A=u!==`action_result`&&t.resourceType===`model`?W(Ta,{id:t.id,inverted:u===`selecting`&&T}):void 0;return W(lt,{id:n,data:{label:a,changeStatus:te,resourceType:r},interactive:c,selectMode:ne,isNodeSelected:T,isFocused:D,isHighlighted:w,showContent:o,actionTag:re,showChangeAnalysis:O,changeCategory:C,runsAggregatedTag:A,hasParents:Object.keys(t.parents).length>0,hasChildren:Object.keys(t.children).length>0,columnCount:k.size,columnHeight:24,isDark:s,onSelect:e=>{l(e)},onContextMenu:(t,n)=>{_(t,e)},onShowImpactRadius:i===`modified`&&S(`change_analysis`)?e=>{x(!0),b({node_id:e,change_analysis:!0,no_upstream:!0})}:void 0})}const Oa=yn(Da);Oa.displayName=`GraphNode`;const ka={lineageGraphNode:Oa,lineageGraphColumnNode:ta},Aa={lineageGraphEdge:ia},ja=[],Ma=e=>e.data.changeStatus?nt(e.data.changeStatus).hexColor:be.neutral[400],Na={ROW_COUNT:`row_count`,ROW_COUNT_DIFF:`row_count_diff`,PROFILE:`profile`,PROFILE_DIFF:`profile_diff`,VALUE_DIFF:`value_diff`,HISTOGRAM_DIFF:`histogram_diff`,TOP_K_DIFF:`top_k_diff`},Pa={LINEAGE_VIEW_CONTEXT_MENU:`lineage_view_context_menu`},Fa={SELECT_PARENT_NODES:`select_parent_nodes`,SELECT_CHILD_NODES:`select_child_nodes`,SELECT_ALL_UPSTREAM:`select_all_upstream`,SELECT_ALL_DOWNSTREAM:`select_all_downstream`},Ia=({menuItems:e,open:t,onClose:n,x:r,y:i,featureToggles:a,DisabledItemWrapper:o})=>{let s=o??(({children:e})=>W(U,{children:e})),c=a?.mode===`metadata only`;return W(Lr,{open:t,onClose:n,anchorReference:`anchorPosition`,anchorPosition:{top:i,left:r},slotProps:{paper:{sx:{fontSize:`0.85rem`,width:`250px`}}},children:e.length===0?W(Q,{disabled:!0,children:`No action available`},`no action`):e.map(({isSeparator:e,label:t,isDisabled:r,action:i,itemIcon:a})=>{if(e)return W(Bn,{},t);let l=G(Q,{disabled:r,onClick:()=>{i&&i(),n()},children:[a,` `,t]},t);return r&&o?W(s,{display:c,children:l},t):l})})},La=({isOpen:e,onClose:t,x:n,y:r,node:i,deps:a={},viewOptions:o={},featureToggles:s={},serverFlags:c={},noCatalogCurrent:l=!1,isActionAvailable:u=()=>!0})=>{let d=[],{runAction:f,onNavigate:p,onTrack:m,findByRunType:h,setSqlQuery:g,setPrimaryKeys:_,getPrimaryKey:v,DisabledItemWrapper:y}=a,{selectMode:b,cll:x,showColumnLevelLineage:S,setChangeAnalysisMode:C,selectParentNodes:w,selectChildNodes:T,getNodeColumnSet:E}=o,D=c.single_env_onboarding??!1,O=s.disableDatabaseQuery??!1;if(!i?.data)return W(U,{});let k=i.data,ee=k.resourceType,te=E?Array.from(E(i.id)):[],ne={source:`lineage_model_node`},re=k.changeStatus,A=v?.(k.name);if(re===`modified`&&d.push({label:`Show Impact Radius`,itemIcon:W(Kn,{}),isDisabled:l||!u(`change_analysis`),action:()=>{C?.(!0),S?.({node_id:i.id,change_analysis:!0,no_upstream:!0})}}),!b&&ee&&[`model`,`seed`,`snapshot`].includes(ee)){d.length>0&&d.push({label:`select group one`,isSeparator:!0});let e=h?.(D?`query`:`query_diff`),t=Ft(Object.keys(k.data.base?.columns??{}),Object.keys(k.data.current?.columns??{})),n=`select * from {{ ref("${k.name}") }}`;if(t.length&&(n=`select \n ${t.join(`
|
|
2
|
+
import{$ as e,A as t,D as n,G as r,J as i,K as a,M as o,N as s,O as c,R as l,W as u,_t as d,a as f,c as p,d as m,et as h,gt as g,h as _,it as v,j as y,k as b,l as x,lt as S,m as C,mt as w,n as T,nt as E,o as D,p as O,s as k,u as ee,w as te,x as ne}from"./api-CYMr4Sk7.js";import{c as re,f as A}from"./keepAlive-CkKaK4Uw.js";import{C as ie,O as ae,T as j,_ as M,a as oe,b as N,d as se,f as ce,g as P,h as le,j as ue,k as de,l as fe,m as pe,o as me,p as he,s as ge,u as F,v as _e,w as I,y as ve}from"./utils-N_TYdjhL.js";import{i as ye,n as be}from"./colors-BpyRE67g.js";import{$t as xe,A as Se,Bt as Ce,Dn as we,E as Te,Ft as Ee,Gt as De,Ht as Oe,It as ke,L as Ae,Lt as je,M as Me,Nt as Ne,O as L,On as R,Qt as Pe,Rt as Fe,S as Ie,T as Le,Tn as Re,Ut as ze,V as z,Vt as Be,Wt as Ve,Xt as He,Yt as Ue,Zt as We,_t as Ge,an as Ke,bt as qe,c as Je,d as Ye,dn as Xe,dt as Ze,en as Qe,f as $e,fn as et,gn as tt,hn as nt,j as rt,k as it,lt as at,m as ot,mn as st,n as ct,nn as lt,o as ut,on as dt,p as ft,pn as pt,pt as mt,r as ht,rn as gt,s as _t,t as vt,tt as yt,ut as bt,v as xt,w as St,wn as Ct,yn as wt,yt as Tt}from"./AuthModal-B_SYkx-_.js";import{Nt as Et,Pt as Dt,Q as Ot,a as kt,ct as At,dt as jt,i as Mt,m as Nt,n as Pt,o as Ft,r as It,s as Lt,t as Rt}from"./utils-m8zHoMN7.js";import{fetchGitHubAvatar as zt,fetchUser as Bt}from"./lib/api/user.js";import{RECCE_SUPPORT_CALENDAR_URL as Vt}from"./lib/const.js";import{EXPLORE_ACTION as Ht,EXPLORE_FORM_EVENT as Ut,EXPLORE_SOURCE as Wt,trackColumnLevelLineage as Gt,trackCopyToClipboard as Kt,trackEnvironmentConfig as qt,trackExploreAction as Jt,trackExploreActionForm as Yt,trackHistoryAction as Xt,trackInit as Zt,trackLineageSelection as Qt,trackLineageViewRender as $t,trackMultiNodesAction as en,trackNavigation as tn,trackPreviewChange as nn,trackPreviewChangeFeedback as rn,trackShareState as an,trackSingleEnvironment as on,trackStateAction as sn}from"./lib/api/track.js";import{t as cn}from"./constants-DWSSKzi8.js";import{QueryClient as ln,QueryClientProvider as un,useMutation as dn,useQuery as fn,useQueryClient as pn}from"@tanstack/react-query";import{AxiosError as mn,isAxiosError as hn}from"axios";import{Suspense as gn,createContext as _n,forwardRef as vn,memo as yn,useCallback as B,useContext as bn,useEffect as xn,useImperativeHandle as Sn,useLayoutEffect as Cn,useMemo as V,useRef as wn,useState as H}from"react";import{Fragment as U,jsx as W,jsxs as G}from"react/jsx-runtime";import K from"@mui/material/Box";import q from"@mui/material/Button";import Tn from"@mui/material/Dialog";import En from"@mui/material/DialogActions";import Dn from"@mui/material/DialogContent";import On from"@mui/material/DialogTitle";import kn from"@mui/material/Link";import J from"@mui/material/Stack";import Y from"@mui/material/Typography";import{LuExternalLink as An,LuSave as jn}from"react-icons/lu";import{alpha as Mn,useTheme as Nn}from"@mui/material/styles";import{useTheme as Pn}from"next-themes";import X from"@mui/material/IconButton";import Fn from"next/link";import{IoBookmarksOutline as In,IoClose as Ln,IoSync as Rn,IoWarning as zn}from"react-icons/io5";import Bn from"@mui/material/Divider";import Vn from"@mui/material/CircularProgress";import Z from"@mui/material/Tooltip";import{FaCloud as Hn,FaExpandArrowsAlt as Un,FaGithub as Wn,FaQuestionCircle as Gn,FaRegDotCircle as Kn,FaSlack as qn,FaUser as Jn}from"react-icons/fa";import{PiBookmarkSimple as Yn,PiCaretDown as Xn,PiChatText as Zn,PiCheckCircle as Qn,PiCircle as $n,PiCopy as er,PiExport as tr,PiInfo as nr,PiInfoFill as rr,PiMoon as ir,PiNotePencil as ar,PiPencil as or,PiPencilSimple as sr,PiPlusCircle as cr,PiRepeat as lr,PiSun as ur,PiTrashFill as dr,PiTrashSimple as fr,PiX as pr}from"react-icons/pi";import mr from"@mui/material/Chip";import{Background as hr,BackgroundVariant as gr,BaseEdge as _r,ControlButton as vr,Controls as yr,MiniMap as br,Panel as xr,Position as Sr,ReactFlow as Cr,ReactFlowProvider as wr,getBezierPath as Tr,getNodesBounds as Er,useEdgesState as Dr,useNodesState as Or,useReactFlow as kr,useStore as Ar}from"@xyflow/react";import jr from"file-saver";import Mr from"@mui/material/Checkbox";import Nr from"@mui/material/FormControlLabel";import{useCopyToClipboard as Pr,useInterval as Fr}from"usehooks-ts";import Ir from"@mui/material/Alert";import Lr from"@mui/material/Menu";import Q from"@mui/material/MenuItem";import{isEmpty as Rr}from"lodash";import{VscCircleLarge as zr,VscFeedback as Br,VscGitPullRequest as Vr,VscHistory as Hr,VscKebabVertical as Ur}from"react-icons/vsc";import Wr from"@mui/material/ListSubheader";import Gr from"@mui/material/TextField";import Kr from"@mui/material/Tab";import qr from"@mui/material/Tabs";import Jr from"@mui/material/List";import Yr from"@mui/material/ListItem";import"@xyflow/react/dist/style.css";import Xr from"@mui/material/Avatar";import Zr from"@mui/material/Popover";import{format as Qr,formatDistanceToNow as $r,parseISO as ei}from"date-fns";import{usePathname as ti,useRouter as ni,useSearchParams as ri}from"next/navigation";import{TbChecklist as ii,TbCloudUpload as ai,TbEdit as oi}from"react-icons/tb";import si from"@mui/material/ListItemIcon";import ci from"@mui/material/ListItemText";import{FiArrowRight as li,FiCopy as ui,FiInfo as di,FiPackage as fi}from"react-icons/fi";import pi from"@mui/material/Switch";import{RiArrowDownSFill as mi,RiArrowUpSFill as hi,RiMindMap as gi,RiSwapLine as _i,RiTerminalBoxLine as vi}from"react-icons/ri";import{FaBookmark as yi,FaFileImport as bi}from"react-icons/fa6";import{BiArrowFromBottom as xi,BiArrowToBottom as Si}from"react-icons/bi";import Ci from"@dagrejs/dagre";import wi from"@mui/material/Skeleton";import{AiOutlineExperiment as Ti}from"react-icons/ai";import Ei from"@mui/material/Radio";import Di from"@mui/material/RadioGroup";import Oi from"@mui/material/Table";import ki from"@mui/material/TableBody";import $ from"@mui/material/TableCell";import Ai from"@mui/material/TableContainer";import ji from"@mui/material/TableHead";import Mi from"@mui/material/TableRow";import Ni from"@mui/material/Badge";import Pi from"@mui/material/Grid";import{stripIndents as Fi}from"common-tags";import{IoMdCodeWorking as Ii}from"react-icons/io";import{DragDropContext as Li,Draggable as Ri,Droppable as zi}from"@hello-pangea/dnd";import Bi from"@mui/material/Card";import Vi from"@mui/material/CardContent";import Hi from"@mui/material/CardHeader";const Ui=_n(null);Ui.displayName=`RecceRoutingContext`;function Wi(){return bn(Ui)||{basePath:``,buildPath:e=>e,pathname:``,navigate:e=>{typeof window<`u`&&(window.location.href=e)}}}function Gi(){let{pathname:e,navigate:t}=Wi();return[e,t]}function Ki({children:e,config:t}){let n=t?.basePath??``,r=t?.pathname??``,i=t?.onNavigate,a=B(e=>n?`${n}${e.startsWith(`/`)?e:`/${e}`}`:e,[n]),o=B((e,t)=>{i?i(e,t):typeof window<`u`&&(t?.replace?(window.history.replaceState(null,``,e),window.dispatchEvent(new PopStateEvent(`popstate`))):window.location.href=e)},[i]),s=V(()=>({basePath:n,buildPath:a,pathname:r,navigate:o}),[n,a,r,o]);return W(Ui.Provider,{value:s,children:e})}const qi=e=>new ln({defaultOptions:{queries:{staleTime:e?.staleTime??1e3*60,gcTime:e?.gcTime??1e3*60*5,retry:1,refetchOnWindowFocus:!1}}});function Ji({children:e,api:t,theme:n=`system`,routing:r,queryClient:i,runActions:a,lineage:o,checks:s,query:c,features:l={}}){let u=i?.staleTime,d=i?.gcTime,f=V(()=>qi({staleTime:u,gcTime:d}),[u,d]),{enableInstance:p=!0,enableIdleTimeout:m=!0,enableLineage:h=!0,enableRunActions:g=!0,enableChecks:_=!0,enableQuery:v=!0}=l,y=e;return y=W(Ki,{config:r,children:y}),y=W(Dt,{defaultMode:n,children:y}),y=W(re,{config:t,children:y}),y=W(un,{client:f,children:y}),v&&(y=W(Re,{sql:c?.sql,isExecuting:c?.isExecuting,error:c?.error,baseResult:c?.baseResult,currentResult:c?.currentResult,onSqlChange:c?.onSqlChange,onExecute:c?.onExecute,onCancel:c?.onCancel,children:y})),_&&(y=W(we,{checks:s?.checks,isLoading:s?.isLoading,error:s?.error,selectedCheckId:s?.selectedCheckId,onSelectCheck:s?.onSelectCheck,onCreateCheck:s?.onCreateCheck,onUpdateCheck:s?.onUpdateCheck,onDeleteCheck:s?.onDeleteCheck,onReorderChecks:s?.onReorderChecks,refetchChecks:s?.refetchChecks,children:y})),g&&(y=W(ae,{onRunAction:a?.onRunAction,onShowRunId:a?.onShowRunId,initialRunId:a?.initialRunId,initialHistoryOpen:a?.initialHistoryOpen,children:y})),h&&(y=W(P,{lineageGraph:o?.lineageGraph,envInfo:o?.envInfo,reviewMode:o?.reviewMode,cloudMode:o?.cloudMode,fileMode:o?.fileMode,fileName:o?.fileName,isDemoSite:o?.isDemoSite,isCodespace:o?.isCodespace,isLoading:o?.isLoading,error:o?.error,supportTasks:o?.supportTasks,onRefetchLineageGraph:o?.onRefetchLineageGraph,runsAggregated:o?.runsAggregated,onRefetchRunsAggregated:o?.onRefetchRunsAggregated,children:y})),m&&(y=W(ve,{children:y})),p&&(y=W(ie,{children:y})),y}function Yi({actionState:e,onCancel:t,onClose:n}){let r=()=>e.mode===`per_node`?`${e.completed} / ${e.total}`:e.currentRun?.progress?.percentage?`${e.currentRun.progress.percentage*100}%`:e.status===`completed`?`100%`:`0%`,i=e.status===`running`||e.status===`canceling`;return W(K,{sx:{bgcolor:`background.paper`,borderRadius:1,boxShadow:6},children:G(J,{direction:`row`,divider:W(Bn,{orientation:`vertical`,flexItem:!0}),spacing:2,sx:{p:`5px 15px`,mt:2},children:[G(K,{sx:{fontSize:`10pt`},children:[`Progress: `,r(),` `,e.status===`canceled`?` (canceled)`:``]}),i?W(q,{size:`small`,variant:`outlined`,onClick:t,disabled:e.status===`canceling`,children:e.status===`canceling`?`Canceling`:`Cancel`}):W(J,{direction:`row`,children:W(q,{size:`small`,variant:`outlined`,onClick:n,children:`Close`})})]})})}const Xi=({lineageGraph:e,cllInput:t,onCenterNode:n})=>{let r={cursor:`pointer`,fontFamily:`monospace`,bgcolor:Et()?`grey.700`:`grey.100`,px:.5,borderRadius:.5};if(!e)return W(U,{});if(!t)return W(U,{children:`Default View`});if(t.node_id===void 0)return W(Y,{component:`span`,children:`Impact Radius for All Changed Models`});let i=t.node_id in e.nodes?e.nodes[t.node_id].data.name:t.node_id;if(!t.column){let e=t.node_id;return G(U,{children:[W(Y,{component:`span`,sx:{mr:`5px`},children:`Impact Radius for`}),W(K,{component:`code`,onClick:()=>{n(e)},sx:r,children:i})]})}let a=`${t.node_id}_${t.column}`;return G(U,{children:[G(Y,{component:`span`,sx:{mr:`5px`},children:[`Column Lineage for`,` `]}),G(K,{component:`code`,onClick:()=>{n(a)},sx:r,children:[i,`.`,t.column]})]})},Zi=({action:e,interactive:t,viewOptions:n,lineageGraph:r,singleEnvMode:i=!1,changeAnalysisAvailable:a=!0,onShowCll:o,onResetCll:s,onCenterNode:c,setChangeAnalysisMode:l})=>{let u=n.column_level_lineage,d=!r?.catalogMetadata.current;return G(J,{direction:`row`,spacing:`5px`,children:[!i&&W(K,{sx:{borderRadius:1,boxShadow:3},children:W(Z,{enterDelay:50,title:a?d?`Please provide catalog.json to enable Impact Radius`:``:`Requires warehouse connection`,placement:`top`,children:W(`span`,{children:W(q,{size:`small`,variant:`outlined`,color:`neutral`,sx:{whiteSpace:`nowrap`,display:`inline-flex`,bgcolor:`background.paper`},disabled:!t||d||!a,startIcon:W(Kn,{}),onClick:()=>{l?.(!0),o({no_upstream:!0,change_analysis:!0})},children:`Impact Radius`})})})}),u&&G(J,{direction:`row`,alignItems:`center`,sx:{borderRadius:1,boxShadow:3,border:`1px solid`,borderColor:`divider`,bgcolor:`background.paper`,fontSize:`0.8rem`,p:`0 0.625rem`},children:[W(Xi,{lineageGraph:r,cllInput:u,onCenterNode:c}),e.isError&&W(Z,{title:`Error: ${e.error.message}`,placement:`bottom`,children:W(Y,{component:`span`,sx:{color:`error.main`,ml:`2px`,display:`inline-flex`,alignItems:`center`},children:W(K,{component:nr,sx:{color:`error.main`,fontSize:`14px`}})})}),e.isPending?W(Vn,{size:12,sx:{ml:`2px`}}):W(X,{size:`small`,sx:{ml:`2px`},"aria-label":`Reset Column Level Lineage`,onClick:()=>{s()},children:W(pr,{size:`10px`})})]})]})};function Qi({onClose:e}){let{cancel:t,actionState:n}=le();return W(Yi,{actionState:n,onCancel:t,onClose:e})}const $i=({action:e})=>{let{showColumnLevelLineage:t,resetColumnLevelLineage:n,interactive:r,viewOptions:i,centerNode:a,setChangeAnalysisMode:o}=le(),{data:s}=F(),c=s?.single_env_onboarding??!1,{lineageGraph:l,isActionAvailable:u}=M();return W(Zi,{action:e,interactive:r,viewOptions:i,lineageGraph:l,singleEnvMode:c,changeAnalysisAvailable:u(`change_analysis`),onShowCll:t,onResetCll:()=>n(),onCenterNode:a,setChangeAnalysisMode:o})};function ea(e){let{id:t,data:n}=e,{id:r}=n.node,{column:i,type:a,transformationType:o,changeStatus:s}=n,c=Ar(e=>e.transform[2]>.3),{isDark:l}=ct(),{viewOptions:u,showContextMenu:d,isNodeHighlighted:f,isNodeShowingChangeAnalysis:p}=le(),m=u.column_level_lineage?.node_id,h=i===u.column_level_lineage?.column&&r===m,g=f(t),_=p(r);return W(wt,{id:t,data:{column:i,type:a,nodeId:r,transformationType:o,changeStatus:s,isHighlighted:g,isFocused:h},showContent:c,showChangeAnalysis:_,isDark:l,onContextMenu:(t,n)=>{d(t,e)}})}const ta=yn(ea);ta.displayName=`GraphColumnNode`;function na(e){let{source:t,target:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,style:l={},markerEnd:u,data:d,isEdgeHighlighted:f}=e,p={...l};d?.changeStatus&&(p.stroke=nt(d.changeStatus).hexColor,p.strokeDasharray=`5`),!f||f(t,n)||(p.filter=`opacity(0.2) grayscale(50%)`);let[m]=Tr({sourceX:r,sourceY:i,sourcePosition:s,targetX:a,targetY:o,targetPosition:c});return W(U,{children:W(_r,{path:m,markerEnd:u,style:{...p,...l}})})}const ra=yn(na);ra.displayName=`GraphEdge`;function ia(e){let{isEdgeHighlighted:t}=le();return W(ra,{...e,isEdgeHighlighted:t})}const aa=()=>W(`svg`,{stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`,viewBox:`0 0 256 256`,height:`1em`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,children:W(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z`})}),oa=()=>W(`svg`,{stroke:`currentColor`,fill:`currentColor`,strokeWidth:`0`,viewBox:`0 0 256 256`,height:`1em`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,children:W(`path`,{d:`M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z`})});function sa({skipReason:e}){return W(mr,{size:`small`,label:G(J,{direction:`row`,sx:{fontSize:`10pt`,color:`grey.500`,alignItems:`center`,gap:`3px`},children:[W(K,{children:`Skipped`}),e&&W(Z,{title:e,children:W(K,{component:`span`,sx:{display:`flex`},children:W(aa,{})})})]}),sx:{bgcolor:`grey.100`}})}function ca({errorMessage:e}){return G(J,{direction:`row`,sx:{fontSize:`10pt`,color:`gray`,alignItems:`center`},children:[W(K,{children:`Error`}),e&&W(Z,{title:e,children:W(K,{component:`span`,sx:{display:`flex`},children:W(oa,{})})})]})}function la({result:e}){let{mismatchedColumns:t}=e,n=t>0;return W(mr,{size:`small`,sx:{bgcolor:n?`error.light`:`success.light`},label:W(J,{direction:`row`,sx:{fontSize:`10pt`,color:n?`error.main`:`success.main`,alignItems:`center`,gap:`3px`},children:n?`${t} columns mismatched`:`All columns match`})})}function ua({result:e}){let{base:t,current:n}=e,r=t===null?`N/A`:t.toLocaleString(),i=n===null?`N/A`:n.toLocaleString(),a=``,o=`grey.500`;return t!==null&&n!==null&&(n>t?(a=`↑`,o=`success.main`):n<t?(a=`↓`,o=`error.main`):a=`=`),W(mr,{size:`small`,sx:{bgcolor:`grey.100`},label:G(J,{direction:`row`,sx:{fontSize:`10pt`,alignItems:`center`,gap:`3px`},children:[W(K,{children:r}),W(K,{children:`→`}),W(K,{children:i}),a&&W(K,{component:`span`,sx:{color:o,ml:.5},children:a})]})})}function da({status:e,skipReason:t,errorMessage:n,progress:r,valueDiffResult:i,rowCountDiffResult:a,runId:o,"data-testid":s}){return e===`pending`?W(Vn,{size:16,"data-testid":s,"data-status":`pending`}):e===`skipped`?W(K,{"data-testid":s,"data-status":`skipped`,children:W(sa,{skipReason:t})}):e===`running`?r?.percentage===void 0?W(Vn,{size:16,"data-testid":s,"data-status":`running`}):W(Vn,{variant:`determinate`,value:r.percentage*100,size:16,"data-testid":s,"data-status":`running`}):e===`error`?W(K,{"data-testid":s,"data-status":`error`,children:W(ca,{errorMessage:n})}):i?W(K,{"data-testid":s,"data-status":`success`,children:W(la,{result:i})}):a?W(K,{"data-testid":s,"data-status":`success`,children:W(ua,{result:a})}):W(K,{"data-testid":s,"data-status":`success`,children:o||`Complete`})}const fa=yn(da);fa.displayName=`ActionTag`;function pa({event:e}){let t=l(e),n={create:cr,comment:Zn,approve:Qn,unapprove:$n,edit:ar,preset:Yn},r={create:`primary.main`,comment:`grey.500`,approve:`success.main`,unapprove:`grey.400`,edit:`warning.main`,preset:`secondary.main`},i=n[t],a=r[t];return W(K,{component:i,sx:{color:a,fontSize:16}})}function ma({event:e}){let{actor:t}=e,{avatarUrl:n}=Be({userId:t.user_id}),r=(t.fullname||t.login||`User`).charAt(0).toUpperCase();return W(Xr,{src:n||void 0,sx:{width:24,height:24,fontSize:`0.75rem`},children:r})}function ha({event:e}){let{actor:t}=e,n=t.fullname||t.login||`Someone`,r=$r(new Date(e.created_at),{addSuffix:!0}),i=``;switch(e.event_type){case`check_created`:i=`created this check`;break;case`approval_change`:i=e.new_value===`true`?`approved this check`:`unapproved this check`;break;case`description_change`:i=`updated the description`;break;case`name_change`:i=`renamed this check`;break;case`preset_applied`:i=`applied a preset`;break;default:i=`made a change`}return G(K,{sx:{display:`flex`,gap:1,alignItems:`flex-start`,py:1},children:[W(K,{sx:{pt:`2px`},children:W(pa,{event:e})}),W(K,{sx:{flex:1},children:G(J,{direction:`row`,spacing:.5,flexWrap:`wrap`,alignItems:`center`,children:[W(ma,{event:e}),W(Y,{variant:`body2`,fontWeight:`500`,children:n}),W(Y,{variant:`body2`,color:`text.secondary`,children:i}),W(Y,{variant:`caption`,color:`text.disabled`,children:r})]})})]})}function ga({event:e,currentUserId:t,onEdit:n,onDelete:r}){let i=Et(),[a,o]=H(!1),[s,c]=H(e.content||``),[l,u]=H(!1),[d,f]=H(!1),[p,m]=H(null),h=!!p,{actor:g}=e,_=g.fullname||g.login||`Someone`,v=$r(new Date(e.created_at),{addSuffix:!0}),y=t&&String(g.user_id)===String(t),b=()=>{c(e.content||``),o(!0)},x=()=>{c(e.content||``),o(!1)},S=async()=>{let t=s.trim();if(!t||t===e.content){x();return}if(n){u(!0);try{await n(e.id,t),o(!1)}finally{u(!1)}}},C=e=>{e.key===`Escape`?x():e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),S())},w=e=>{m(e.currentTarget)},T=()=>{m(null)},E=async()=>{if(r){f(!0);try{await r(e.id),T()}finally{f(!1)}}};return e.is_deleted?G(K,{sx:{display:`flex`,gap:1,alignItems:`center`,py:1},children:[W(K,{sx:{pt:`2px`,display:`flex`,alignItems:`center`},children:W(pa,{event:e})}),W(K,{sx:{display:`flex`,flex:1,alignItems:`center`},children:W(Y,{variant:`body2`,color:`text.disabled`,fontStyle:`italic`,children:`Comment deleted`})})]}):G(K,{sx:{display:`flex`,gap:1,alignItems:`flex-start`,py:1},children:[W(K,{sx:{pt:`2px`},children:W(pa,{event:e})}),G(K,{sx:{flex:1},children:[G(J,{direction:`row`,spacing:.5,sx:{mb:.5},flexWrap:`wrap`,alignItems:`center`,children:[W(ma,{event:e}),G(Y,{variant:`body2`,fontWeight:`500`,children:[_,y&&G(Y,{component:`span`,variant:`body2`,color:`text.secondary`,children:[` `,`(Author)`]})]}),W(Y,{variant:`caption`,color:`text.disabled`,children:v}),e.is_edited&&W(Y,{variant:`caption`,color:`text.disabled`,children:`(edited)`})]}),a?G(K,{children:[W(Gr,{value:s,onChange:e=>c(e.target.value),onKeyDown:C,size:`small`,multiline:!0,minRows:3,fullWidth:!0,disabled:l,autoFocus:!0,sx:{"& .MuiOutlinedInput-root":{bgcolor:`background.paper`,"&:focus-within":{borderColor:`primary.main`}}}}),G(J,{direction:`row`,spacing:1,sx:{mt:1},justifyContent:`flex-end`,children:[W(q,{size:`small`,variant:`text`,onClick:x,disabled:l,children:`Cancel`}),W(q,{size:`small`,variant:`contained`,onClick:S,disabled:!s.trim()||l,children:l?`Saving...`:`Save`})]})]}):G(K,{sx:{bgcolor:i?`grey.800`:`grey.50`,borderRadius:1,p:1,border:`1px solid`,borderColor:i?`grey.700`:`grey.200`,position:`relative`,"&:hover .comment-actions":{opacity:1}},children:[W(mt,{content:e.content||``,fontSize:`sm`}),y&&(n||r)&&G(J,{className:`comment-actions`,direction:`row`,spacing:0,sx:{position:`absolute`,top:4,right:4,opacity:0,transition:`opacity 0.2s`},children:[n&&W(Z,{title:`Edit comment`,children:W(X,{"aria-label":`Edit comment`,size:`small`,onClick:b,children:W(sr,{})})}),r&&G(U,{children:[W(Z,{title:`Delete comment`,children:W(X,{"aria-label":`Delete comment`,size:`small`,color:`error`,onClick:w,children:W(fr,{})})}),W(Zr,{open:h,anchorEl:p,onClose:T,anchorOrigin:{vertical:`bottom`,horizontal:`center`},transformOrigin:{vertical:`top`,horizontal:`center`},children:G(K,{sx:{p:2},children:[W(Y,{variant:`body2`,sx:{mb:2},children:`Delete this comment?`}),G(J,{direction:`row`,spacing:1,justifyContent:`flex-end`,children:[W(q,{size:`small`,variant:`text`,onClick:T,disabled:d,children:`Cancel`}),W(q,{size:`small`,variant:`contained`,color:`error`,onClick:E,disabled:d,children:d?`Deleting...`:`Delete`})]})]})})]})]})]})]})]})}function _a({event:e,currentUserId:t,onEdit:n,onDelete:r}){return e.event_type===`comment`?W(ga,{event:e,currentUserId:t,onEdit:n,onDelete:r}):W(ha,{event:e})}function va({checkId:e}){let t=Et(),{apiClient:n}=Oe(),{events:r,isLoading:i,error:a,createComment:o,isCreatingComment:s,updateComment:c,deleteComment:l}=Ye(e),{data:u}=fn({queryKey:A.user(),queryFn:()=>Bt(n),retry:!1}),d=e=>{o(e)},f=async(e,t)=>{await c({eventId:e,content:t})},p=async e=>{await l(e)};return i?W(K,{sx:{height:`100%`,p:4,display:`flex`,justifyContent:`center`,alignItems:`center`},children:W(Vn,{size:20})}):a?W(K,{sx:{height:`100%`,p:4,display:`flex`,justifyContent:`center`,alignItems:`center`},children:W(Y,{sx:{fontSize:`0.875rem`,color:`error.main`},children:`Failed to load timeline`})}):G(J,{sx:{height:`100%`,alignItems:`stretch`,borderLeft:`1px solid`,borderColor:t?`grey.700`:`grey.200`},spacing:0,children:[W(K,{sx:{px:3,py:2,borderBottom:`1px solid`,borderColor:t?`grey.700`:`grey.200`},children:W(Y,{variant:`subtitle2`,sx:{fontWeight:500},children:`Activity`})}),W(K,{sx:{flex:1,overflowY:`auto`,px:3,py:2},children:r.length===0?W(Y,{sx:{fontSize:`0.875rem`,color:`grey.500`},children:`No activity yet`}):W(J,{sx:{alignItems:`stretch`},spacing:0,children:r.map((e,n)=>G(K,{children:[W(_a,{event:e,currentUserId:u?.id,onEdit:f,onDelete:p}),n<r.length-1&&W(Bn,{sx:{borderColor:t?`grey.700`:`grey.100`}})]},e.id))})}),W(K,{sx:{px:3,py:3,borderTop:`1px solid`,borderColor:t?`grey.700`:`grey.200`,bgcolor:t?`grey.900`:`grey.50`},children:W(Ce,{onSubmit:d,isSubmitting:s})})]})}function ya({color:e}){return W(K,{component:`span`,sx:{display:`inline-block`,width:`10px`,height:`10px`,bgcolor:e,mr:1,borderRadius:`4px`}})}const ba=({defaultPrimaryKeys:e,onPrimaryKeysChange:t,...n})=>{let{lineageGraph:r,isActionAvailable:i}=M(),a=V(()=>{if(!r)return[];let e=new Set;for(let t in r.nodes){let n=r.nodes[t],i={...n.data.data.base?.columns??{},...n.data.data.current?.columns??{}};Object.entries(i).forEach(([t,n])=>{n?.unique&&e.add(t)})}return Array.from(e).sort()},[r]);return W(K,{sx:{display:`flex`},...n,children:G(J,{spacing:0,sx:{m:`0 0.5rem`},children:[G(J,{direction:`row`,alignItems:`center`,spacing:.5,children:[W(Y,{component:`label`,sx:{fontSize:`0.625rem`,color:`text.secondary`},children:`Diff with Primary Key(s) (suggested)`}),W(Z,{title:`Provide a primary key to perform query diff in data warehouse and only return changed rows.`,placement:`bottom-end`,children:W(K,{component:`span`,sx:{display:`flex`,color:`grey.600`,cursor:`help`},children:W(nr,{fontSize:`0.75rem`})})})]}),W(dt,{className:`no-track-pii-safe`,unitName:`key`,defaultValues:e,suggestionList:a,onValuesChange:t,size:`2xs`,width:`240px`,placeholder:`Select or type to add keys`,disabled:!i(`query_diff_with_primary_key`)})]})})};function xa({supportCalendarUrl:e=`https://cal.com/team/recce/chat`}){let{data:t}=j();return W(`div`,{className:`flex flex-1 h-full min-h-0 m-2 p-4 bg-blue-50 rounded-lg shadow-md justify-center`,children:G(`div`,{className:`w-4/5 flex flex-col overflow-y-auto gap-6 px-8 pb-8`,children:[G(J,{alignItems:`center`,spacing:2,children:[W(K,{sx:{p:1,bgcolor:`background.paper`,borderRadius:`50%`,display:`flex`,alignItems:`center`,justifyContent:`center`,boxShadow:2},children:W(K,{component:vi,sx:{fontSize:28,color:`iochmara.500`}})}),W(Y,{variant:`h5`,sx:{mt:2},children:`Wait, there's more!`}),G(Y,{sx:{fontSize:`1rem`,textAlign:`center`},children:[`Query functions disabled without a`,` `,W(Y,{component:`span`,sx:{fontWeight:`bold`},children:`data warehouse connection`})]})]}),W(J,{sx:{width:`50%`,mt:3,mx:`auto`},children:W(q,{color:`iochmara`,variant:`contained`,size:`large`,onClick:()=>{window.open(Rt(t,e),`_blank`)},children:`Connect to Data Warehouse`})})]})})}const Sa=()=>{let{isCustomQueries:e,setCustomQueries:t,sqlQuery:n,setBaseSqlQuery:r}=Ie();return G(K,{children:[G(J,{direction:`row`,spacing:.5,alignItems:`center`,fontSize:`0.75rem`,children:[W(Y,{variant:`body2`,sx:{fontSize:`0.75rem`},children:`Custom Queries`}),W(Z,{title:`Custom queries allow you to use two SQL queries to compare results between current and base environments.`,children:W(K,{component:`span`,sx:{display:`flex`,color:`grey.600`},children:W(rr,{fontSize:`1rem`})})})]}),W(pi,{size:`small`,checked:e,onChange:()=>{!e&&r&&r(n),t(!e)},color:`primary`})]})},Ca=()=>{let{sqlQuery:e,baseSqlQuery:t,setSqlQuery:n,setBaseSqlQuery:i,primaryKeys:o,setPrimaryKeys:s,isCustomQueries:c}=Ie(),{lineageGraph:l,envInfo:d}=M(),{featureToggles:f,singleEnv:p}=I(),m=e;d?.adapterType===`sqlmesh`&&e===`select * from {{ ref("mymodel") }}`&&(m=`select * from db.mymodel`),f.mode===`read only`&&(m=`--- Would like to do query here? Book a demo with us at ${Vt}\n${m}`);let{showRunId:g}=de(),{apiClient:_}=Oe(),{mutate:v,isPending:y}=dn({mutationFn:async e=>{function n(e){switch(e){case`query`:return u;case`query_base`:return r;case`query_diff`:return a;default:throw Error(`Unknown query type: ${e}`)}}let i=e===`query_base`?t??``:m,s=n(e),l={sql_template:i},d={nowait:!0};e===`query_diff`&&(l.primary_keys=o,c&&(l.base_sql_template=t));let{run_id:f}=await s(l,d,_);return g(f),await h(f,void 0,_)}}),b=V(()=>{let e={};if(!l)return`N/A`;for(let t in l.nodes){let n=l.nodes[t].data.data.current?.schema;n&&(e[n]=(e[n]||0)+1)}return Object.keys(e).reduce((t,n)=>e[n]>(e[t]||0)?n:t,`N/A`)},[l]);return p||f.mode===`metadata only`?G(K,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[G(K,{sx:{display:`flex`,justifyContent:`right`,alignItems:`center`,padding:`4pt 8pt`,gap:`5px`,height:`54px`,borderBottom:`1px solid`,borderColor:`divider`},children:[W(Ho,{}),W(K,{sx:{flexGrow:1}}),p?W(Z,{title:`Please configure the base environment before running the diff`,placement:`left`,children:W(`span`,{children:W(q,{variant:`contained`,disabled:!0,size:`small`,sx:{fontSize:`14px`,mt:`16px`},children:`Run Diff`})})}):W(ks,{display:f.mode===`metadata only`,children:W(q,{variant:`contained`,disabled:!0,size:`small`,sx:{fontSize:`14px`,mt:`16px`},children:`Run Diff`})})]}),W(it,{value:m,onChange:n,onRun:()=>{v(`query`)},labels:[`base (production)`,`current (${b})`],SetupGuide:f.mode===`metadata only`?W(xa,{}):W(Lo,{})})]}):G(K,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[G(K,{sx:{display:`flex`,justifyContent:`right`,alignItems:`flex-end`,padding:`4pt 8pt`,gap:`5px`,height:`54px`,borderBottom:`1px solid`,borderColor:`divider`,flex:`0 0 54px`},children:[W(Ho,{}),W(Sa,{}),W(K,{sx:{flexGrow:1}}),W(ba,{defaultPrimaryKeys:o,onPrimaryKeysChange:s}),W(q,{variant:`contained`,onClick:()=>{v(`query_diff`)},disabled:y||f.disableDatabaseQuery,size:`small`,children:`Run Diff`})]}),W(K,{sx:{width:`100%`,flex:1,overflowY:`auto`},children:c?W(it,{value:m,baseValue:t,onChange:n,onChangeBase:i,onRun:()=>{v(`query`)},onRunBase:()=>{v(`query_base`)},onRunDiff:()=>{v(`query_diff`)}}):W(Se,{value:m,onChange:n,onRun:()=>{v(`query`)},onRunDiff:()=>{v(`query_diff`)}})})]})};function wa({rowCount:e}){let t=e.base,n=e.curr,r=e.base===null?`N/A`:`${e.base} Rows`,i=e.curr===null?`N/A`:`${e.curr} Rows`,a,o;t===null&&n===null?(a=`Failed to load`,o=`default`):t===null||n===null?(a=`${r} -> ${i}`,o=t===null?`success`:`error`):t===n?(a=`=`,o=`default`):(a=`${Nt(t,n)} Rows`,o=t<n?`success`:`error`);let s=z(`row_count_diff`).icon;return W(mr,{size:`small`,color:o,icon:s?W(s,{}):void 0,label:a,sx:{height:20,fontSize:`0.7rem`}})}function Ta({id:e,inverted:t}){let{lineageGraph:n,runsAggregated:r}=M(),{text:i,isDark:a}=ct(),o=r?.[e],s=n?.nodes[e];if(!o&&!s)return null;let c;if(s?.data.data.base&&s.data.data.current){let e=s.data.data.base.columns,t=s.data.data.current.columns;c=Pt(e,t)}let l;if(o?.row_count_diff){let e=o.row_count_diff.result;l=e.curr!==e.base}let u=t?i.inverted:nt(`modified`).color,d=t?i.secondary:a?`grey.700`:`grey.100`,f=z(`schema_diff`).icon;return G(K,{sx:{display:`flex`,flex:1,alignItems:`center`},children:[c!==void 0&&W(Z,{title:`Schema (${c?`changed`:`no change`})`,enterDelay:500,children:W(K,{sx:{height:16},children:f&&W(K,{component:f,sx:{color:c?u:d}})})}),W(K,{sx:{flexGrow:1}}),o?.row_count_diff&&l!==void 0&&W(Z,{title:`Row count (${l?`changed`:`=`})`,enterDelay:500,children:W(K,{children:W(wa,{rowCount:o.row_count_diff.result})})})]})}function Ea({nodeId:e,nodeName:t}){let{getNodeAction:n}=le(),r=n(e);if(!r)return null;let{status:i,skipReason:a,run:o}=r;if(i===`pending`)return W(fa,{status:`pending`});if(i===`skipped`)return W(fa,{status:`skipped`,skipReason:a});if(!o)return W(fa,{status:`pending`});let{error:s,run_id:c,progress:l}=o;if(i===`running`)return W(fa,{status:`running`,progress:{percentage:l?.percentage}});if(s)return W(fa,{status:`error`,errorMessage:s});if(o.type===`value_diff`&&o.result){let e=o.result,t=0,n=e.data.data.length;for(let n of e.data.data)n[2]<1&&t++;return W(fa,{status:`success`,valueDiffResult:{mismatchedColumns:t,totalColumns:n}})}if(S(o)&&o.result){let e=o.result[t];if(e)return W(wa,{rowCount:e})}if(o.type===`row_count`&&o.result){let e=o.result[t];if(e?.curr!==void 0&&e.curr!==null)return W(mr,{size:`small`,label:`${e.curr.toLocaleString()} Rows`,sx:{height:20,fontSize:`0.7rem`}})}return W(fa,{status:`success`,runId:c})}function Da(e){let{data:t}=e,{id:n,resourceType:r,changeStatus:i,name:a}=t,o=Ar(e=>e.transform[2]>.3),{isDark:s}=ct(),{interactive:c,selectNode:l,selectMode:u,focusedNode:d,getNodeAction:f,getNodeColumnSet:p,isNodeHighlighted:m,isNodeSelected:h,isNodeShowingChangeAnalysis:g,showContextMenu:_,viewOptions:v,cll:y,showColumnLevelLineage:b,setChangeAnalysisMode:x}=le(),{isActionAvailable:S}=M(),C=y?.current.nodes[n]?.change_category,w=m(n),T=h(n),E=v.column_level_lineage?.node_id===n&&v.column_level_lineage.column===void 0,D=d?.id===n||E,O=g(n),k=p(t.id),ee=u===`action_result`?f(t.id):void 0,te=i,ne=u,re=u===`action_result`&&ee?W(Ea,{nodeId:n,nodeName:a}):void 0,A=u!==`action_result`&&t.resourceType===`model`?W(Ta,{id:t.id,inverted:u===`selecting`&&T}):void 0;return W(lt,{id:n,data:{label:a,changeStatus:te,resourceType:r},interactive:c,selectMode:ne,isNodeSelected:T,isFocused:D,isHighlighted:w,showContent:o,actionTag:re,showChangeAnalysis:O,changeCategory:C,runsAggregatedTag:A,hasParents:Object.keys(t.parents).length>0,hasChildren:Object.keys(t.children).length>0,columnCount:k.size,columnHeight:24,isDark:s,onSelect:e=>{l(e)},onContextMenu:(t,n)=>{_(t,e)},onShowImpactRadius:i===`modified`&&S(`change_analysis`)?e=>{x(!0),b({node_id:e,change_analysis:!0,no_upstream:!0})}:void 0})}const Oa=yn(Da);Oa.displayName=`GraphNode`;const ka={lineageGraphNode:Oa,lineageGraphColumnNode:ta},Aa={lineageGraphEdge:ia},ja=[],Ma=e=>e.data.changeStatus?nt(e.data.changeStatus).hexColor:be.neutral[400],Na={ROW_COUNT:`row_count`,ROW_COUNT_DIFF:`row_count_diff`,PROFILE:`profile`,PROFILE_DIFF:`profile_diff`,VALUE_DIFF:`value_diff`,HISTOGRAM_DIFF:`histogram_diff`,TOP_K_DIFF:`top_k_diff`},Pa={LINEAGE_VIEW_CONTEXT_MENU:`lineage_view_context_menu`},Fa={SELECT_PARENT_NODES:`select_parent_nodes`,SELECT_CHILD_NODES:`select_child_nodes`,SELECT_ALL_UPSTREAM:`select_all_upstream`,SELECT_ALL_DOWNSTREAM:`select_all_downstream`},Ia=({menuItems:e,open:t,onClose:n,x:r,y:i,featureToggles:a,DisabledItemWrapper:o})=>{let s=o??(({children:e})=>W(U,{children:e})),c=a?.mode===`metadata only`;return W(Lr,{open:t,onClose:n,anchorReference:`anchorPosition`,anchorPosition:{top:i,left:r},slotProps:{paper:{sx:{fontSize:`0.85rem`,width:`250px`}}},children:e.length===0?W(Q,{disabled:!0,children:`No action available`},`no action`):e.map(({isSeparator:e,label:t,isDisabled:r,action:i,itemIcon:a})=>{if(e)return W(Bn,{},t);let l=G(Q,{disabled:r,onClick:()=>{i&&i(),n()},children:[a,` `,t]},t);return r&&o?W(s,{display:c,children:l},t):l})})},La=({isOpen:e,onClose:t,x:n,y:r,node:i,deps:a={},viewOptions:o={},featureToggles:s={},serverFlags:c={},noCatalogCurrent:l=!1,isActionAvailable:u=()=>!0})=>{let d=[],{runAction:f,onNavigate:p,onTrack:m,findByRunType:h,setSqlQuery:g,setPrimaryKeys:_,getPrimaryKey:v,DisabledItemWrapper:y}=a,{selectMode:b,cll:x,showColumnLevelLineage:S,setChangeAnalysisMode:C,selectParentNodes:w,selectChildNodes:T,getNodeColumnSet:E}=o,D=c.single_env_onboarding??!1,O=s.disableDatabaseQuery??!1;if(!i?.data)return W(U,{});let k=i.data,ee=k.resourceType,te=E?Array.from(E(i.id)):[],ne={source:`lineage_model_node`},re=k.changeStatus,A=v?.(k.name);if(re===`modified`&&d.push({label:`Show Impact Radius`,itemIcon:W(Kn,{}),isDisabled:l||!u(`change_analysis`),action:()=>{C?.(!0),S?.({node_id:i.id,change_analysis:!0,no_upstream:!0})}}),!b&&ee&&[`model`,`seed`,`snapshot`].includes(ee)){d.length>0&&d.push({label:`select group one`,isSeparator:!0});let e=h?.(D?`query`:`query_diff`),t=Ft(Object.keys(k.data.base?.columns??{}),Object.keys(k.data.current?.columns??{})),n=`select * from {{ ref("${k.name}") }}`;if(t.length&&(n=`select \n ${t.join(`
|
|
3
3
|
`)}\nfrom {{ ref("${k.name}") }}`),e&&d.push({label:`Query`,itemIcon:W(K,{component:e.icon,sx:{display:`inline-flex`}}),isDisabled:O,action:()=>{g?.(n),u(`query_diff_with_primary_key`)&&_?.(A===void 0?void 0:[A]),p?.(`/query`)}}),te.length>0&&e)if(x!==void 0){let t=new Set;A&&t.add(A),te.forEach(e=>{t.add(e)}),d.push({label:`Query Related Columns`,itemIcon:W(K,{component:e.icon,sx:{display:`inline-flex`}}),isDisabled:O,action:()=>{let e=`select \n ${Array.from(t).join(`,
|
|
4
4
|
`)}\nfrom {{ ref("${k.name}") }}`;g?.(e),u(`query_diff_with_primary_key`)&&_?.(A===void 0?void 0:[A]),p?.(`/query`)}})}else{let t=Object.entries(k.change?.columns??{}).filter(([,e])=>e===`modified`).map(([e])=>e);if(t.length>0){let n=new Set;A&&n.add(A),t.forEach(e=>{n.add(e)}),d.push({label:`Query Modified Columns`,itemIcon:W(K,{component:e.icon,sx:{display:`inline-flex`}}),isDisabled:O,action:()=>{let e=`select \n ${Array.from(n).join(`,
|
|
5
|
-
`)}\nfrom {{ ref("${k.name}") }}`;g?.(e),u(`query_diff_with_primary_key`)&&_?.(A===void 0?void 0:[A]),p?.(`/query`)}})}}let r=D?`row_count`:`row_count_diff`,a=h?.(r);a&&d.push({label:a.title,itemIcon:W(K,{component:a.icon,sx:{display:`inline-flex`}}),isDisabled:O,action:()=>{m?.(`explore_action`,{action:D?Na.ROW_COUNT:Na.ROW_COUNT_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),f?.(r,{node_names:[k.name]},{showForm:!1,trackProps:ne})}});let o=D?`profile`:`profile_diff`,s=h?.(o);if(s&&d.push({label:s.title,itemIcon:W(K,{component:s.icon,sx:{display:`inline-flex`}}),isDisabled:O,action:()=>{let e=E?Array.from(E(i.id)):[];m?.(`explore_action`,{action:D?Na.PROFILE:Na.PROFILE_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),f?.(o,{model:k.name,columns:e},{showForm:!0,trackProps:ne})}}),!D){let e=h?.(`value_diff`);e&&d.push({label:e.title,itemIcon:W(K,{component:e.icon,sx:{display:`inline-flex`}}),isDisabled:O,action:()=>{let e=E?Array.from(E(i.id)):[];m?.(`explore_action`,{action:Na.VALUE_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),f?.(`value_diff`,{model:k.name,columns:e},{showForm:!0,trackProps:ne})}})}}return D||(d.length>0&&d.push({label:`select group two`,isSeparator:!0}),d.push({label:`Select Parent Nodes`,itemIcon:W(xi,{}),action:()=>{m?.(`lineage_selection`,{action:Fa.SELECT_PARENT_NODES}),w?.(i.id,1)}}),d.push({label:`Select Child Nodes`,itemIcon:W(Si,{}),action:()=>{m?.(`lineage_selection`,{action:Fa.SELECT_CHILD_NODES}),T?.(i.id,1)}}),d.push({label:`Select All Upstream Nodes`,itemIcon:W(xi,{}),action:()=>{m?.(`lineage_selection`,{action:Fa.SELECT_ALL_UPSTREAM}),w?.(i.id)}}),d.push({label:`Select All Downstream Nodes`,itemIcon:W(Si,{}),action:()=>{m?.(`lineage_selection`,{action:Fa.SELECT_ALL_DOWNSTREAM}),T?.(i.id)}})),W(Ia,{x:n,y:r,menuItems:d,open:e,onClose:t,featureToggles:s,DisabledItemWrapper:y})},Ra=({isOpen:e,onClose:t,x:n,y:r,node:i,deps:a={},featureToggles:o={},serverFlags:s={},isActionAvailable:c=()=>!0})=>{let l=[],{runAction:u,onTrack:d,findByRunType:f,supportsHistogramDiff:p,DisabledItemWrapper:m}=a,h=s.single_env_onboarding??!1,g=o.disableDatabaseQuery??!1;if(i?.data===void 0)return W(U,{});let _=i.data,v=_.node,y=_.column,b=_.type,x={source:`lineage_column_node`},S=()=>{d?.(`explore_action`,{action:Na.PROFILE_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),u?.(`profile_diff`,{model:v.name,columns:[y]},{showForm:!1,trackProps:x})},C=()=>{d?.(`explore_action`,{action:Na.HISTOGRAM_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),u?.(`histogram_diff`,{model:v.name,column_name:y,column_type:b},{showForm:!1,trackProps:x})},w=()=>{d?.(`explore_action`,{action:Na.TOP_K_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),u?.(`top_k_diff`,{model:v.name,column_name:y,k:50},{showForm:!1,trackProps:x})},T=()=>{d?.(`explore_action`,{action:Na.VALUE_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),u?.(`value_diff`,{model:v.name,columns:[y]},{showForm:!0,trackProps:x})},E=v.data.base?.columns?.[y]===void 0||v.data.current?.columns?.[y]===void 0,D=f?.(h?`profile`:`profile_diff`);if(D&&l.push({label:D.title,itemIcon:W(K,{component:D.icon,sx:{display:`inline-flex`}}),action:S,isDisabled:E||!c(`profile_diff`)||g}),!h){let e=f?.(`histogram_diff`);if(e){let t=p?.(b)??!0;l.push({label:e.title,itemIcon:W(K,{component:e.icon,sx:{display:`inline-flex`}}),action:C,isDisabled:E||!t||g})}let t=f?.(`top_k_diff`);t&&l.push({label:t.title,itemIcon:W(K,{component:t.icon,sx:{display:`inline-flex`}}),action:w,isDisabled:E||g});let n=f?.(`value_diff`);n&&l.push({label:n.title,itemIcon:W(K,{component:n.icon,sx:{display:`inline-flex`}}),action:T,isDisabled:E||g})}return W(Ia,{x:n,y:r,menuItems:l,open:e,onClose:t,featureToggles:o,DisabledItemWrapper:m})},za=({isOpen:e,onClose:t,x:n,y:r,node:i,deps:a={},viewOptions:o={},featureToggles:s={},serverFlags:c={},noCatalogCurrent:l=!1,isActionAvailable:u=()=>!0})=>s.disableViewActionDropdown?W(Ia,{menuItems:[],open:e,onClose:t,x:n,y:r,featureToggles:s,DisabledItemWrapper:a.DisabledItemWrapper}):i&&ce(i)?W(La,{x:n,y:r,isOpen:e,onClose:t,node:i,deps:a,viewOptions:o,featureToggles:s,serverFlags:c,noCatalogCurrent:l,isActionAvailable:u}):i&&se(i)?W(Ra,{x:n,y:r,isOpen:e,onClose:t,node:i,deps:a,featureToggles:s,serverFlags:c,isActionAvailable:u}):null,Ba=()=>{let[e,t]=H(!1),n=()=>t(!0),r=()=>t(!1),[i,a]=H({x:0,y:0}),[o,s]=H();return{props:{x:i.x,y:i.y,node:o,isOpen:e,onClose:r},showContextMenu:(e,t,r)=>{a({x:e,y:t}),s(r),n()},closeContextMenu:()=>{a({x:0,y:0}),s(void 0),r()}}},Va=()=>{let{isDark:e}=ct(),{successToast:t,failToast:n}=At();return ft({renderLibrary:`html-to-image`,imageType:`png`,shadowEffect:!0,backgroundColor:e?be.neutral[900]:be.neutral[50],ignoreElements:e=>{try{return e.classList.contains($e)}catch{return e.className?e.className.includes($e):!1}},onSuccess:()=>{t(`Copied the Lineage View as an image to clipboard`)},onError:e=>{console.error(`Error taking screenshot`,e),n(`Failed to copy image to clipboard`,e)}})},Ha=()=>{let e=ni(),{basePath:t}=ue();return B(n=>{n.check_id&&e.push(`${t}/checks/?id=${n.check_id}`)},[e.push,t])},Ua=(e,t)=>{let n=wn({width:0,height:0});xn(()=>{let r=e.current,i=new ResizeObserver(e=>{for(let r of e){let e=r.contentRect.width,i=r.contentRect.height;(Math.abs(i-n.current.height)>10||Math.abs(e-n.current.width)>10)&&n.current.height>0&&i>0&&n.current.width>0&&e>0&&t(),n.current={width:e,height:i}}});return r&&i.observe(r),()=>{r&&i.unobserve(r)}},[t,e])},Wa=()=>B((e,t,n,r,i)=>{let a=e.filter(ce),o=Object.groupBy(a,e=>e.data.changeStatus??`unchanged`),s=Object.fromEntries(Object.entries(o).map(([e,t])=>[`nodes_${e}`,t?.length??0])),c={node_count:a.length,view_mode:t,impact_radius_enabled:n,right_sidebar_open:i,...s};r&&(c.cll_column_active=!0),$t(c)},[]),Ga={row_count:Ht.ROW_COUNT,row_count_diff:Ht.ROW_COUNT_DIFF,value_diff:Ht.VALUE_DIFF},Ka=e=>{let t=Ga[e.action];t&&Jt({action:t,source:Wt.LINEAGE_VIEW_TOP_BAR,node_count:e.node_count})},qa=(e,t)=>Le(e,{...t,onTrackAction:Ka,trackingSource:Wt.LINEAGE_VIEW_TOP_BAR});function Ja(){return St({onConfirm:()=>Yt({action:Ht.VALUE_DIFF,event:Ut.EXECUTE}),onCancel:()=>Yt({action:Ht.VALUE_DIFF,event:Ut.CANCEL})})}function Ya({notification:e,type:t}){let n=D.lineageNotificationDismissed,[r,i]=H(()=>sessionStorage.getItem(n)!==`true`);if(e===null||!r)return null;let a={info:`iochmara.light`,success:`success.light`,warning:`warning.light`,error:`error.light`}[t];return G(K,{sx:{width:`100%`,display:`flex`,flexDirection:`row`,p:`5px 10px`,gap:`5px`,alignItems:`flex-start`,borderRadius:1,boxShadow:4,border:`1px solid`,borderColor:`neutral.light`,bgcolor:a},children:[e,W(K,{sx:{flex:1}}),W(X,{size:`small`,onClick:()=>{sessionStorage.setItem(n,`true`),i(!1)},children:W(Ln,{})})]})}const Xa=e=>{let{runAction:t}=de(),{setSqlQuery:n,setPrimaryKeys:r}=Ie(),i=ni(),{primaryKey:a}=ut(e),{basePath:o}=ue();return{runAction:(e,n,r)=>{t(e,n,r)},onNavigate:e=>{i.push(`${o}${e}`)},onTrack:(e,t)=>{e===`explore_action`?Jt({action:t.action,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:t.node_count}):e===`lineage_selection`&&Qt({action:t.action})},supportsHistogramDiff:Ke,findByRunType:e=>{let t=z(e);return t?{title:t.title,icon:t.icon}:void 0},setSqlQuery:n,setPrimaryKeys:r,getPrimaryKey:()=>a,DisabledItemWrapper:Os}},Za=({isOpen:e,onClose:t,x:n,y:r,node:i})=>{let{selectParentNodes:a,selectChildNodes:o,getNodeColumnSet:s,selectMode:c,cll:l,showColumnLevelLineage:u,setChangeAnalysisMode:d}=le(),{featureToggles:f}=I(),{isActionAvailable:p,lineageGraph:m}=M(),{data:h}=F(),g=!m?.catalogMetadata.current;return W(za,{x:n,y:r,node:i,isOpen:e,onClose:t,deps:Xa(i?.type===`lineageGraphNode`?i.data?.name:i?.type===`lineageGraphColumnNode`?i.data?.node?.name:void 0),viewOptions:{selectMode:c,cll:l,showColumnLevelLineage:u,setChangeAnalysisMode:d,selectParentNodes:a,selectChildNodes:o,getNodeColumnSet:s},featureToggles:{disableDatabaseQuery:f.disableDatabaseQuery,disableViewActionDropdown:f.disableViewActionDropdown,mode:f.mode??void 0},serverFlags:{single_env_onboarding:h?.single_env_onboarding},noCatalogCurrent:g,isActionAvailable:p})},Qa=Ba;function $a(e,t){let n=[],r=[],{selectedNodes:i,cll:a,existingPositions:o}=t??{},s={};function c(e){return e===`base`?0:e===`current`?2:1}function l(e,t){let n=c(e.data?.from),r=c(t.data?.from);return n<r?-1:n>r?1:0}let u=i===void 0?void 0:new Set(i),d=Object.values(e.nodes).sort(l);for(let e of d){if(u&&!u.has(e.id))continue;let t=new Set,i=0;if(a){let o=a.current?.parent_map[e.id]??new Set;for(let t of o){let n=t,i=e.id;r.push({id:`m2c_${n}_${i}`,source:n,target:i,style:{zIndex:9999}})}for(let o of Object.keys(e.data.data.current?.columns??{})){let s=`${e.id}_${o}`,c=a.current,l=c?.columns[s],u=c?.parent_map[s]??new Set;if(l!=null){n.push({id:s,position:{x:10,y:70+i*24},parentId:e.id,extent:`parent`,draggable:!1,className:`no-track-pii-safe`,data:{node:e.data,column:l.name,type:l.type,transformationType:l.transformation_type,changeStatus:l.change_status},style:{zIndex:9999},type:`lineageGraphColumnNode`,targetPosition:Sr.Left,sourcePosition:Sr.Right});for(let e of u){let t=e,n=s;r.push({id:`${t}_${n}`,source:t,target:n,style:{zIndex:9999}})}i++,t.add(l.name)}}}s[e.id]=t;let c=60;i>0&&(c+=20+i*24);let l=o?.get(e.id);n.unshift({id:e.id,position:l??{x:0,y:0},width:300,height:c,className:`no-track-pii-safe`,data:{...e.data},type:`lineageGraphNode`,targetPosition:Sr.Left,sourcePosition:Sr.Right,style:{width:300,height:c}})}let f=Object.values(e.edges).sort(l);for(let e of f)u&&(!u.has(e.source)||!u.has(e.target))||r.push({id:e.id,type:`lineageGraphEdge`,source:e.source,target:e.target,data:{...e.data}});return n.some(e=>e.type===`lineageGraphNode`&&!o?.has(e.id))&&eo(n,r),[n,r,s]}const eo=(e,t,n=`LR`)=>{oe(Ci,e,t,n)};function to(){return G(K,{sx:{display:`flex`,gap:2,px:1,py:.5,fontSize:`0.75rem`,color:`text.secondary`},children:[G(`span`,{children:[W(`span`,{className:`schema-change-badge schema-change-badge-added`,children:`+`}),` `,`added`]}),G(`span`,{children:[W(`span`,{className:`schema-change-badge schema-change-badge-removed`,children:`-`}),` `,`removed`]}),G(`span`,{children:[W(`span`,{className:`schema-change-badge schema-change-badge-changed`,children:`~`}),` `,`changed`]})]})}function no({current:e,showMenu:t=!0},n){let r=pe(),[i,a]=H(null),[o,s]=H(new Map),{columns:c,rows:l}=V(()=>yt({type:`schema_single`,columns:e?.columns},{node:e,cllRunningMap:o,showMenu:t}),[e,o,t]),{lineageGraph:u,isActionAvailable:d}=M(),f=d(`change_analysis`),p=!u?.catalogMetadata.current,m;p&&(m="catalog.json not found. Run `recce debug` to troubleshoot.");let h=e&&e.columns===void 0,g;h&&(g=`Node schema not found in catalog.json. Please regenerate your catalog.json to update.`);let _=async t=>{if(!f)return;Gt({action:`view`,source:`schema_column`}),s(e=>new Map(e).set(t,!0));let n=e?.id;n&&await r?.showColumnLevelLineage({node_id:n,column:t}),s(e=>new Map(e).set(t,!1))},v=B(t=>`${e?.id}-${t.data.name}`,[e?.id]),y=r?.viewOptions.column_level_lineage,b=y?`${y.node_id}-${y.column}`:null;xn(()=>{if(i&&(i.deselectAll(),b)){let e=i.getRowNode(b);e&&e.setSelected(!0)}},[i,b]);let x=B(e=>{a(e.api)},[]);return G(K,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[m?W(Ir,{severity:`warning`,sx:{fontSize:`12px`,p:1},children:m}):g?W(Ir,{severity:`warning`,sx:{fontSize:`12px`,p:1},children:g}):W(U,{}),l.length>0&&W(qe,{style:{blockSize:`auto`,maxHeight:`100%`,overflow:`auto`,fontSize:`10pt`,borderWidth:1},columns:c,rows:l,renderers:{noRowsFallback:W(Tt,{})},ref:n,getRowId:v,getRowClass:e=>r!==void 0&&f?`row-normal row-selectable`:`row-normal`,onCellClicked:async e=>{if((e.event?.target)?.closest(`.row-context-menu`))return;let t=e.data;t&&await _(t.name)},onGridReady:x,rowSelection:{mode:`singleRow`,checkboxes:!1},containerClassName:`no-track-pii-safe`,rowClassName:`no-track-pii-safe`})]})}function ro({base:e,current:t,showMenu:n=!0,columnChanges:r,onViewCode:i},a){let o=pe(),[s,c]=H(null),[l,u]=H(new Map),{columns:d,rows:f}=V(()=>{let a=t?.resource_type??e?.resource_type,o=a&&[`model`,`seed`,`snapshot`,`source`].includes(a)?t??e:void 0;return yt({type:`schema_diff`,base:e?.columns,current:t?.columns},{node:o,cllRunningMap:l,showMenu:n,columnChanges:r,onViewCode:i})},[e,t,l,n,r,i]),{lineageGraph:p,isActionAvailable:m}=M(),h=m(`change_analysis`),g=!p?.catalogMetadata.base,_=!p?.catalogMetadata.current,v;g&&_?v="catalog.json not found on both environments. Run `recce debug` to troubleshoot.":g?v="catalog.json not found on base environment. Run `recce debug` to troubleshoot.":_&&(v="catalog.json not found on current environment. Run `recce debug` to troubleshoot.");let y=e&&e.columns===void 0,b=t&&t.columns===void 0,x;y&&b?x=`Node schema not found in catalog.json on both environments. Please regenerate your catalog.json to update.`:b?x=`Node schema not found in catalog.json on current environment. Please regenerate your catalog.json to update.`:y&&(x=`Node schema not found in catalog.json on base environment. Please regenerate your catalog.json to update.`);let S=async n=>{if(!h)return;Gt({action:`view`,source:`schema_column`}),u(e=>new Map(e).set(n,!0));let r=t?.id??e?.id;r&&await o?.showColumnLevelLineage({node_id:r,column:n}),u(e=>new Map(e).set(n,!1))},C=B(n=>`${t?.id??e?.id}-${n.data.name}`,[t?.id,e?.id]),w=o?.viewOptions.column_level_lineage,T=w?`${w.node_id}-${w.column}`:null;xn(()=>{if(s&&(s.deselectAll(),T)){let e=s.getRowNode(T);e&&e.setSelected(!0)}},[s,T]);let E=B(e=>{c(e.api)},[]);return G(K,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[v?W(Ir,{severity:`warning`,sx:{fontSize:`12px`,p:1},children:v}):x?W(Ir,{severity:`warning`,sx:{fontSize:`12px`,p:1},children:x}):W(U,{}),W(to,{}),f.length>0&&W(qe,{style:{blockSize:`auto`,maxHeight:`100%`,overflow:`auto`,fontSize:`0.8rem`,borderWidth:1},columns:d,rows:f,rowHeight:35,renderers:{noRowsFallback:W(Tt,{})},className:`rdg-light no-track-pii-safe`,ref:a,getRowId:C,getRowClass:e=>{let t=e.data;if(!t)return`row-normal`;let n;if(t.baseIndex===void 0)n=`row-added`;else if(t.currentIndex===void 0)return`row-removed`;else n=t.baseType!==t.currentType||t.reordered===!0||t.definitionChanged===!0?`row-changed`:`row-normal`;return o!==void 0&&h&&(n+=` row-selectable`),n},onCellClicked:async e=>{if((e.event?.target)?.closest(`.row-context-menu`))return;let t=e.data;t&&(t.baseIndex!==void 0&&t.currentIndex===void 0||await S(t.name))},onGridReady:E,rowSelection:{mode:`singleRow`,checkboxes:!1},containerClassName:`no-track-pii-safe`,rowClassName:`no-track-pii-safe`})]})}const io=vn(ro),ao=vn(no),oo=({node:e,isSingleEnv:t,CodeEditor:n,DiffEditor:r,isDark:i=!1})=>{let[a,o]=H(!1),[s,c]=H(!1);if(e.data.resourceType!==`model`&&e.data.resourceType!==`snapshot`)return`Not available`;let l=e.data.data.base?.raw_code,u=e.data.data.current?.raw_code,d=e.data.data.base?.name??e.data.data.current?.name??``;return G(K,{className:`no-track-pii-safe`,sx:{position:`relative`,height:`100%`},onMouseEnter:()=>{c(!0)},onMouseLeave:()=>{c(!1)},children:[t?W(n,{language:`sql`,value:l??``,readOnly:!0,lineNumbers:!0,wordWrap:!1,theme:i?`dark`:`light`}):W(r,{original:l??``,modified:u??``,language:`sql`,readOnly:!0,lineNumbers:!0,sideBySide:!1,theme:i?`dark`:`light`,height:`100%`}),W(X,{onClick:()=>o(!0),size:`medium`,"aria-label":`Expand`,sx:{position:`absolute`,top:`5px`,right:`20px`,opacity:s?.5:.1,transition:`opacity 0.3s ease-in-out`},children:W(Un,{})}),G(Tn,{open:a,onClose:()=>o(!1),maxWidth:`sm`,fullWidth:!0,slotProps:{paper:{sx:{height:`75%`,overflowY:`auto`}}},children:[G(On,{sx:{display:`flex`,alignItems:`center`},children:[t?G(U,{children:[W(`code`,{children:d}),`\xA0Model Code`]}):G(U,{children:[W(`code`,{children:d}),`\xA0Model Code Diff`]}),W(K,{sx:{flex:1}}),W(X,{size:`small`,onClick:()=>o(!1),children:W(Ln,{})})]}),W(Dn,{children:t?W(n,{language:`sql`,value:l??``,fontSize:16,readOnly:!0,lineNumbers:!0,wordWrap:!1,theme:i?`dark`:`light`}):W(r,{original:l??``,modified:u??``,language:`sql`,theme:i?`dark`:`light`,className:`text-base`})})]})]})},so=({node:e})=>{let{data:t,isLoading:n}=F(),r=Et();return n?W(U,{}):W(oo,{node:e,isSingleEnv:t?.single_env_onboarding??!1,CodeEditor:De,DiffEditor:Ge,isDark:r})},co=e=>({display:`inline-flex`,alignItems:`center`,borderRadius:16,px:1,py:.25,fontSize:`0.75rem`,bgcolor:e?`grey.700`:`grey.100`,color:e?`grey.100`:`inherit`}),lo={mr:.5,display:`flex`,alignItems:`center`};function uo({data:e,"data-testid":t}){let n=Et(),{icon:r}=tt(e.resourceType);return W(Z,{arrow:!0,title:`Type of resource`,children:G(K,{component:`span`,sx:co(n),"data-testid":t,children:[r&&W(K,{component:`span`,sx:lo,children:W(r,{})}),e.resourceType]})})}const fo=yn(uo);fo.displayName=`ResourceTypeTag`;function po({rowCount:e}){let t=e.base,n=e.curr,r=e.base===null?`N/A`:`${e.base} rows`,i=e.curr===null?`N/A`:`${e.curr} rows`;return t===null&&n===null?W(U,{children:` Failed to load`}):t===null||n===null?G(J,{direction:`row`,alignItems:`center`,spacing:.5,children:[W(Y,{variant:`body2`,component:`span`,children:r}),W(li,{}),W(Y,{variant:`body2`,component:`span`,children:i})]}):t===n?G(J,{direction:`row`,alignItems:`center`,spacing:.5,children:[W(Y,{variant:`body2`,component:`span`,children:i}),W(K,{component:`span`,sx:{color:`grey.500`,display:`flex`},children:W(_i,{})}),W(Y,{variant:`body2`,component:`span`,sx:{color:`grey.500`},children:`No Change`})]}):t<n?G(J,{direction:`row`,alignItems:`center`,spacing:.5,children:[W(Y,{variant:`body2`,component:`span`,children:i}),W(K,{component:`span`,sx:{color:`success.main`,display:`flex`},children:W(hi,{})}),W(Y,{variant:`body2`,component:`span`,sx:{color:`success.main`},children:Nt(t,n)})]}):G(J,{direction:`row`,alignItems:`center`,spacing:.5,children:[W(Y,{variant:`body2`,component:`span`,children:i}),W(K,{component:`span`,sx:{color:`error.main`,display:`flex`},children:W(mi,{})}),W(Y,{variant:`body2`,component:`span`,sx:{color:`error.main`},children:Nt(t,n)})]})}function mo({rowCount:e,node:t,onRefresh:n,isFetching:r}){let i=Et(),{featureToggles:a}=I(),{runsAggregated:o}=M(),s=o?.[t.id]?.row_count_diff.result,c=z(`row_count_diff`).icon,l=e??s,u=l;return W(Z,{title:l?`${l.base??`N/A`} -> ${l.curr??`N/A`} rows`:``,children:W(Os,{display:a.mode===`metadata only`,children:G(K,{component:`span`,sx:{...co(i),gap:.5},children:[W(c,{}),u!=null||r?r?W(wi,{width:30,height:16}):u==null?W(Y,{variant:`caption`,children:`row count`}):W(po,{rowCount:u}):W(Y,{variant:`caption`,children:`row count`}),n&&W(X,{"aria-label":`Query Row Count`,size:`small`,onClick:n,disabled:a.disableDatabaseQuery,sx:{p:0,ml:.5},children:W(lr,{size:12})})]})})})}function ho({rowCount:e,node:t,onRefresh:n,isFetching:r}){let i=Et(),{runsAggregated:a}=M(),o=a?.[t.id]?.row_count.result,s=z(`row_count`).icon,c,l=e??o;return l&&(c=`${l.curr??`N/A`} rows`),G(K,{component:`span`,sx:co(i),children:[W(K,{component:`span`,sx:lo,children:W(s,{})}),l||r?r?W(wi,{width:30,height:16}):W(Y,{variant:`caption`,children:c}):W(Y,{variant:`caption`,children:`row count`}),n&&W(X,{"aria-label":`Query Row Count`,size:`small`,onClick:n,disabled:t.data.from===`base`,sx:{p:0,ml:.5},children:W(lr,{size:12})})]})}function go({children:e,value:t,index:n}){return t===n?W(U,{children:e}):null}const _o=()=>W(`span`,{}),vo=({children:e})=>W(U,{children:e}),yo=()=>!0;function bo(e,t,n){return e?cn.add_or_remove:n(t)?``:`This action is not supported yet.`}function xo({node:e,actionCallbacks:t,runTypeIcons:n,isActionAvailable:r}){let i=e.data.changeStatus===`added`||e.data.changeStatus===`removed`,a=n?.query??_o,o=n?.row_count??_o,s=n?.profile??_o;return G(J,{direction:`row`,alignItems:`center`,flexWrap:`wrap`,gap:1,children:[W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(a,{fontSize:`small`}),onClick:t?.onQueryClick,sx:{textTransform:`none`},children:`Query`}),W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(o,{fontSize:`small`}),onClick:t?.onRowCountClick,sx:{textTransform:`none`},children:`Row Count`}),W(Z,{title:bo(i,`profile`,r),placement:`top`,children:W(`span`,{children:W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(s,{fontSize:`small`}),onClick:t?.onProfileClick,disabled:i,sx:{textTransform:`none`},children:`Profile`})})})]})}function So({actionCallbacks:e,runTypeIcons:t,featureToggles:n,ConnectionPopoverWrapper:r}){let i=n?.mode===`metadata only`,a=t?.schema_diff??_o,o=t?.sandbox??_o;return G(J,{direction:`row`,alignItems:`center`,sx:{mr:1},flexWrap:`wrap`,gap:1,children:[W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(a,{fontSize:`small`}),onClick:e?.onAddSchemaDiffClick,sx:{textTransform:`none`},children:`Add schema diff to checklist`}),W(r,{display:i,children:W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(o,{fontSize:`small`}),onClick:e?.onSandboxClick,disabled:n?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Sandbox`})})]})}function Co({node:e,actionCallbacks:t,runTypeIcons:n,featureToggles:r,isActionAvailable:i,ConnectionPopoverWrapper:a}){let o=r?.mode===`metadata only`,s=e.data.changeStatus===`added`||e.data.changeStatus===`removed`,c=n?.query_diff??_o,l=n?.row_count_diff??_o,u=n?.profile_diff??_o,d=n?.value_diff??_o,f=n?.top_k_diff??_o,p=n?.histogram_diff??_o,m=(e,t)=>o?W(a,{display:!0,children:e}):W(Z,{title:bo(s,t,i),placement:`top`,children:W(`span`,{children:e})});return G(J,{direction:`row`,alignItems:`center`,flexWrap:`wrap`,gap:2,children:[W(Y,{variant:`caption`,fontWeight:`bold`,children:`Diff`}),G(J,{direction:`row`,alignItems:`center`,flexWrap:`wrap`,gap:1,width:`93%`,children:[W(a,{display:o,children:W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(l,{fontSize:`small`}),onClick:t?.onRowCountDiffClick,disabled:r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Row Count`})}),m(W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(u,{fontSize:`small`}),onClick:t?.onProfileDiffClick,disabled:s||r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Profile`}),`profile_diff`),m(W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(d,{fontSize:`small`}),onClick:t?.onValueDiffClick,disabled:s||r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Value`}),`value_diff`),m(W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(f,{fontSize:`small`}),onClick:t?.onTopKDiffClick,disabled:s||r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Top-K`}),`top_k_diff`),m(W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(p,{fontSize:`small`}),onClick:t?.onHistogramDiffClick,disabled:s||r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Histogram`}),`histogram_diff`),W(a,{display:o,children:W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(c,{fontSize:`small`}),onClick:t?.onQueryDiffClick,disabled:r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Query`})})]})]})}function wo({node:e,onCloseNode:t,isSingleEnv:n,featureToggles:r,SchemaView:i,SingleEnvSchemaView:a,NodeSqlView:o,RowCountDiffTag:s,RowCountTag:c,ResourceTypeTag:l,NotificationComponent:u,ConnectionPopoverWrapper:d=vo,SandboxDialog:f,runTypeIcons:p,actionCallbacks:m,isActionAvailable:h=yo}){let g=e.data.resourceType===`model`||e.data.resourceType===`seed`||e.data.resourceType===`source`||e.data.resourceType===`snapshot`,[_,v]=H(!1),[y,b]=H(!0),[x,S]=H(0),{base:C,current:w}=e.data.data,T=!n&&Pt(C?.columns,w?.columns)===!0,E=!n&&C?.raw_code!=null&&w?.raw_code!=null&&C.raw_code!==w.raw_code,D=e.data.resourceType===`model`||e.data.resourceType===`seed`||e.data.resourceType===`snapshot`,O={...m,onSandboxClick:()=>{m?.onSandboxClick?.(),v(!0)}};return G(K,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[G(J,{direction:`row`,alignItems:`center`,children:[W(K,{sx:{flex:`0 1 20%`,p:2},children:W(Y,{variant:`subtitle1`,fontWeight:600,className:`no-track-pii-safe`,children:e.data.name})}),W(K,{sx:{flexGrow:1}}),!n&&D&&W(So,{node:e,actionCallbacks:O,runTypeIcons:p,featureToggles:r,ConnectionPopoverWrapper:d}),W(K,{sx:{flex:`0 1 1%`},children:W(X,{size:`small`,onClick:t,children:W(Ln,{})})})]}),W(K,{sx:{color:`text.secondary`,pl:2},children:G(J,{direction:`row`,spacing:1,children:[l&&W(l,{node:e}),D&&(n?c&&W(c,{node:e,onRefresh:m?.onRowCountClick}):s&&W(s,{node:e,onRefresh:m?.onRowCountDiffClick}))]})}),D&&W(K,{sx:{pl:2,py:1},children:n?W(xo,{node:e,actionCallbacks:m,runTypeIcons:p,isActionAvailable:h}):W(Co,{node:e,actionCallbacks:O,runTypeIcons:p,featureToggles:r,isActionAvailable:h,ConnectionPopoverWrapper:d})}),g&&G(K,{sx:{overflow:`auto`,display:`flex`,flexDirection:`column`,flex:1,minHeight:0},children:[n&&y&&u&&W(K,{sx:{p:1.5},children:W(u,{onClose:()=>b(!1),children:W(Y,{variant:`body2`,children:`Enable the Recce Checklist and start adding checks for better data validation and review.`})})}),G(qr,{value:x,onChange:(e,t)=>S(t),sx:{borderBottom:1,borderColor:`divider`},children:[W(Kr,{label:G(K,{component:`span`,sx:{display:`flex`,alignItems:`center`,gap:.75},children:[`Columns`,T&&W(K,{component:`span`,sx:{color:`amber.main`,fontSize:`0.5rem`,lineHeight:1},children:`●`})]})}),W(Kr,{label:G(K,{component:`span`,sx:{display:`flex`,alignItems:`center`,gap:.75},children:[`Code`,E&&W(K,{component:`span`,sx:{color:`amber.main`,fontSize:`0.5rem`,lineHeight:1},children:`●`})]})})]}),G(K,{sx:{overflow:`auto`,height:`calc(100% - 48px)`},children:[W(go,{value:x,index:0,children:W(K,{sx:{overflowY:`auto`,height:`100%`},children:n?a&&W(a,{current:e.data.data.current}):i&&W(i,{base:e.data.data.base,current:e.data.data.current,columnChanges:e.data.change?.columns,onViewCode:()=>S(1)})})}),W(go,{value:x,index:1,children:W(K,{sx:{height:`100%`},children:o&&W(o,{node:e})})})]})]}),f&&W(f,{isOpen:_,onClose:()=>v(!1),current:e.data.data.current})]})}function To(e){return Qr(ei(e),`yyyy-MM-dd'T'HH:mm:ss`)}function Eo({current:e,primaryKeys:t,onPrimaryKeysChange:n,onRunResultOpen:r,runQuery:i,isPending:a,QueryForm:o}){return G(J,{direction:`row`,justifyContent:`flex-end`,alignItems:`center`,sx:{p:`4pt 8pt`,gap:`5px`,height:`54px`,borderBottom:`1px solid`,borderBottomColor:`divider`,flex:`0 0 54px`},children:[G(K,{children:[G(Y,{variant:`h6`,component:`h2`,sx:{display:`flex`,alignItems:`center`,gap:`5px`},children:[W(K,{component:Ti,sx:{fontSize:`1.2em`}}),`Sandbox`]}),G(Y,{sx:{fontSize:`0.75rem`,color:`grey.500`},children:[`Compare the run results based on the modified SQL code of model`,` `,W(`b`,{children:e?.name})]})]}),W(K,{sx:{flexGrow:1}}),W(o,{defaultPrimaryKeys:t,onPrimaryKeysChange:n}),W(Z,{title:`Run diff to see the changes`,children:W(q,{size:`small`,sx:{mt:`16px`,fontSize:`14px`},onClick:()=>{r(),i()},color:`iochmara`,variant:`contained`,disabled:a,children:a?`Running...`:`Run Diff`})})]})}function Do({currentModelID:e,height:t=`32px`,flex:n=`0 0 auto`,isDark:r=!1}){let{lineageGraph:i,envInfo:a}=M(),o=`0 16px`,s=$r(To(a?.dbt?.current?.generated_at??``),{addSuffix:!0}),c=`N/A`;if(i?.nodes[e]){let t=i.nodes[e];t.data.data.current?.schema&&(c=t.data.data.current.schema)}return G(J,{direction:`row`,sx:{gap:0,height:t,flex:n,fontSize:`14px`,alignItems:`center`,m:0,bgcolor:Mn(r?be.neutral[700]:be.neutral[100],.5)},children:[W(J,{sx:{width:`50%`},children:G(Y,{sx:{fontWeight:`bold`,margin:o},children:[`ORIGINAL (Schema: `,c,`, Last Updated: `,s,`)`]})}),W(J,{sx:{width:`50%`},children:W(Y,{sx:{fontWeight:`bold`,margin:o},children:`SANDBOX EDITOR`})})]})}function Oo({current:e,onChange:t,isDark:n,DiffEditor:r}){return W(r,{original:e?.raw_code??``,modified:e?.raw_code??``,language:`sql`,readOnly:!1,lineNumbers:!0,sideBySide:!0,theme:n?`dark`:`light`,height:`100%`,onModifiedChange:t})}function ko({isOpen:e,onClose:t,current:n,DiffEditor:r,QueryForm:i,RunResultPane:a,isDark:o=!1,primaryKeys:s=[],onPrimaryKeysChange:c,isPending:l=!1,onRunQuery:u,onRunResultOpen:d,onModifiedCodeChange:f,onShowFeedback:p,tracking:m,logoUrl:h=`/logo/recce-logo-white.png`,brandName:g=`RECCE`}){let[_,v]=H(!1),y=e=>{f?.(e)},b=()=>{v(!0),d?.()},x=()=>{u?.()},S=()=>{t(),v(!1),m?.onPreviewChange?.({action:`close`,node:n?.name})},C=e=>{c?.(e)};return G(Tn,{open:e,onClose:S,maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:`100%`,height:`100%`,maxWidth:`100%`,maxHeight:`100%`,m:0}}},children:[G(K,{sx:{height:`40px`,bgcolor:`cyan.600`,px:0,py:2,display:`flex`,alignItems:`center`},children:[G(J,{direction:`row`,alignItems:`center`,sx:{height:`100%`,gap:`10px`},children:[W(K,{component:`img`,sx:{width:`20px`,height:`20px`,ml:`18px`},src:h,alt:`logo`}),W(Y,{variant:`h6`,component:`h1`,sx:{fontFamily:`"Montserrat", sans-serif`,fontSize:`1.125rem`,color:`common.white`},children:g}),W(mr,{label:`Experiment`,size:`small`,variant:`outlined`,sx:{fontSize:`0.875rem`,color:`common.white`,borderColor:`rgba(255,255,255,0.5)`}})]}),W(X,{"aria-label":`close`,onClick:S,sx:{position:`absolute`,right:8,top:4,color:`common.white`},children:W(Ln,{})})]}),W(Dn,{sx:{p:0},children:G(bt,{sizes:_?[50,50]:[100,0],minSize:0,gutterSize:5,className:_?void 0:`split-gutter-hidden`,style:{flex:`1`,contain:`size`,height:`100%`},children:[G(J,{sx:{height:`100%`,m:0,p:0},children:[W(Eo,{current:n,primaryKeys:s,onPrimaryKeysChange:C,onRunResultOpen:b,runQuery:x,isPending:l,QueryForm:i}),W(Do,{height:`32px`,flex:`0 0 auto`,currentModelID:n?.id??``,isDark:o}),W(Oo,{current:n,onChange:y,isDark:o,DiffEditor:r})]}),_?W(a,{onClose:()=>v(!1),disableAddToChecklist:!0}):W(K,{})]})}),W(K,{sx:{position:`fixed`,bottom:16,right:16,opacity:.5},children:W(Z,{title:`Give us feedback`,children:W(X,{"aria-label":`feedback`,size:`medium`,onClick:()=>{p?.()},children:W(Br,{})})})})]})}function Ao({isOpen:e,onClose:t,current:n}){let[r,i]=H(n?.raw_code??``),[o,s]=H(e),{showRunId:c,clearRunResult:l}=de(),{primaryKeys:u,setPrimaryKeys:d}=Ie(),{data:p,isLoading:m}=F(),{apiClient:g}=Oe(),_=Et();e!==o&&(s(e),e&&i(n?.raw_code??``));let{mutate:v,isPending:y}=dn({mutationFn:async()=>{let e=r,{run_id:t}=await a({current_model:n?.name??``,primary_keys:u,sql_template:e},{nowait:!0},g);return c(t),await h(t,void 0,g)},onSuccess(e){e.error?nn({action:`run`,node:n?.name,status:`failure`}):(nn({action:`run`,node:n?.name,status:`success`}),setTimeout(()=>{b()},1e3),!m&&p?.single_env_onboarding&&setTimeout(()=>{S()},2e3))}}),{feedbackToast:b,closeToast:x}=Je({feedbackId:f.previewChangeFeedbackID,description:`Enjoy preview change?`,onFeedbackSubmit:e=>{switch(e){case`like`:rn({feedback:`like`,node:n?.name});break;case`dislike`:rn({feedback:`dislike`,node:n?.name});break;case`link`:rn({feedback:`form`,node:n?.name});break;default:console.log(`Not support feedback type`)}},externalLink:`https://docs.google.com/forms/d/e/1FAIpQLSd7Lei7Ijwo7MinWaI0K6rzZi_21gV1BKetmiNEX254kDziDA/viewform?usp=header`,externalLinkText:`Give us feedback`}),{guideToast:S,closeGuideToast:C}=_t({guideId:f.prepareEnvGuideID,description:`Want to compare data changes with production data?`,externalLink:`https://docs.reccehq.com/get-started/#prepare-dbt-artifacts`,externalLinkText:`Learn how.`,onExternalLinkClick:()=>{on({action:`external_link`,from:`preview_changes`,node:n?.name})}});return W(ko,{isOpen:e,onClose:()=>{t(),l(),x(),C()},current:n,DiffEditor:Ge,QueryForm:ba,RunResultPane:Pe,isDark:_,primaryKeys:u??[],onPrimaryKeysChange:d,isPending:y,onRunQuery:v,onModifiedCodeChange:i,onShowFeedback:()=>b(!0),tracking:{onPreviewChange:nn}})}const jo=({node:e})=>W(fo,{data:{resourceType:e.data.resourceType}});function Mo({onClose:e}){return W(Me,{onClose:e,align:`flex-start`,children:G(Y,{variant:`body2`,children:[`Enable the Recce Checklist and start adding checks for better data validation and review.`,W(`br`,{}),W(rt,{})]})})}function No({node:e,onCloseNode:t}){let n=ni(),{runAction:r}=de(),{isActionAvailable:i,envInfo:a}=M(),{singleEnv:o,featureToggles:s}=I(),{setSqlQuery:c,setPrimaryKeys:l}=Ie(),{primaryKey:u}=ut(e.data.name),{apiClient:d}=Oe(),{basePath:f}=ue(),p=V(()=>({query:z(`query`).icon,row_count:z(`row_count`).icon,row_count_diff:z(`row_count_diff`).icon,profile:z(`profile`).icon,profile_diff:z(`profile_diff`).icon,query_diff:z(`query_diff`).icon,value_diff:z(`value_diff`).icon,top_k_diff:z(`top_k_diff`).icon,histogram_diff:z(`histogram_diff`).icon,schema_diff:z(`schema_diff`).icon,sandbox:z(`sandbox`).icon}),[]),m=Ft(Object.keys(e.data.data.base?.columns??{}),Object.keys(e.data.data.current?.columns??{})),h=V(()=>m.length?`select \n ${m.join(`
|
|
6
|
-
`)}\nfrom {{ ref("${e.data.name}") }}`:`select * from {{ ref("${e.data.name}") }}`,[m,e.data.name]),g=V(()=>({onQueryClick:()=>{a?.adapterType===`dbt`?c(h):a?.adapterType===`sqlmesh`&&c(`select * from ${e.data.name}`),n.push(`${f}/query`)},onRowCountClick:()=>{Jt({action:Ht.ROW_COUNT,source:Wt.SCHEMA_ROW_COUNT_BUTTON,node_count:1}),r(`row_count`,{node_names:[e.data.name]},{showForm:!1,showLast:!1})},onRowCountDiffClick:()=>{Jt({action:Ht.ROW_COUNT_DIFF,source:Wt.SCHEMA_ROW_COUNT_BUTTON,node_count:1}),r(`row_count_diff`,{node_names:[e.data.name]},{showForm:!1,showLast:!1})},onProfileClick:()=>{Jt({action:Ht.PROFILE,source:Wt.NODE_SIDEBAR_SINGLE_ENV,node_count:1}),r(`profile`,{model:e.data.name},{showForm:!0,showLast:!1})},onProfileDiffClick:()=>{Jt({action:Ht.PROFILE_DIFF,source:Wt.NODE_SIDEBAR_MULTI_ENV,node_count:1}),r(`profile_diff`,{model:e.data.name},{showForm:!0,showLast:!1})},onQueryDiffClick:()=>{a?.adapterType===`dbt`?c(h):a?.adapterType===`sqlmesh`&&c(`select * from ${e.data.name}`),i(`query_diff_with_primary_key`)&&l(u===void 0?void 0:[u]),n.push(`${f}/query`)},onValueDiffClick:()=>{Jt({action:Ht.VALUE_DIFF,source:Wt.NODE_SIDEBAR_MULTI_ENV,node_count:1}),r(`value_diff`,{model:e.data.name},{showForm:!0,showLast:!1})},onTopKDiffClick:()=>{Jt({action:Ht.TOP_K_DIFF,source:Wt.NODE_SIDEBAR_MULTI_ENV,node_count:1}),r(`top_k_diff`,{model:e.data.name,column_name:``,k:50},{showForm:!0})},onHistogramDiffClick:()=>{Jt({action:Ht.HISTOGRAM_DIFF,source:Wt.NODE_SIDEBAR_MULTI_ENV,node_count:1}),r(`histogram_diff`,{model:e.data.name,column_name:``,column_type:``},{showForm:!0})},onAddSchemaDiffClick:async()=>{let t=await _({node_id:e.id},d);n.push(`${f}/checks/?id=${t.check_id}`)},onSandboxClick:()=>{i(`query_diff_with_primary_key`)&&l(u===void 0?void 0:[u]),nn({action:`explore`,node:e.data.name})}}),[e,h,a,c,r,i,l,u,d,n.push,f]);return W(wo,{node:e,onCloseNode:t,isSingleEnv:o??!1,featureToggles:s,SchemaView:io,SingleEnvSchemaView:ao,NodeSqlView:so,ResourceTypeTag:jo,RowCountDiffTag:mo,RowCountTag:ho,NotificationComponent:Mo,ConnectionPopoverWrapper:Os,SandboxDialog:Ao,runTypeIcons:p,actionCallbacks:g,isActionAvailable:i})}function Po({featureToggles:e,settingsUrl:t}){return e.mode===`metadata only`?W(K,{sx:{display:`flex`,alignItems:`center`,width:`100%`,px:1,py:.25,bgcolor:`cyan.50`},children:G(J,{direction:`row`,alignItems:`center`,sx:{flex:1,fontSize:`0.875rem`,color:`cyan.600`},spacing:1,children:[W(K,{component:nr}),W(Y,{sx:{fontSize:`inherit`,color:`inherit`},children:`Query functions disabled without a data warehouse connection.`}),W(q,{sx:{bgcolor:`iochmara.400`},size:`small`,variant:`contained`,onClick:()=>{window.open(t,`_blank`)},children:`Connect to Data Warehouse`})]})}):null}function Fo(e){let{featureToggles:t}=I(),{data:n}=j();return W(Po,{featureToggles:e.featureToggles??t,settingsUrl:e.settingsUrl??Rt(n,Vt)})}function Io({docsUrl:e=`https://docs.reccehq.com/get-started/#prepare-dbt-artifacts`,onStartClick:t}={}){return W(J,{sx:{flex:1,height:`100%`,minHeight:0,m:1,p:2,bgcolor:`iochmara.50`,borderRadius:2,boxShadow:2,justifyContent:`center`},children:G(J,{sx:{width:`80%`,overflowY:`auto`,gap:3,px:4,pb:4},alignSelf:`center`,children:[G(J,{alignItems:`center`,spacing:2,children:[W(K,{sx:{p:1,bgcolor:`background.paper`,borderRadius:`50%`,display:`flex`,alignItems:`center`,justifyContent:`center`,boxShadow:2},children:W(K,{component:vi,sx:{fontSize:28,color:`iochmara.500`}})}),W(Y,{variant:`h5`,sx:{mt:2},children:`Wait, there's more!`}),G(Y,{sx:{textAlign:`center`},children:[`Recce is currently running in`,` `,W(Y,{component:`span`,sx:{fontWeight:`bold`},children:`limited functionality mode`}),` `,`so you can run queries but`,` `,W(Y,{component:`span`,sx:{fontWeight:`bold`},children:`can't diff the results yet!`})]})]}),G(J,{spacing:1,children:[W(Y,{children:`To unlock the full power of Recce, set up a base environment of dbt artifacts for comparison.`}),W(Y,{children:`Once configured, you'll be able to:`}),G(Jr,{sx:{listStyleType:`disc`,pl:2},children:[W(Yr,{sx:{display:`list-item`,p:0},children:W(Y,{children:`Run statistical data diffs`})}),W(Yr,{sx:{display:`list-item`,p:0},children:W(Y,{children:`Run query diffs`})}),W(Yr,{sx:{display:`list-item`,p:0},children:W(Y,{children:`Save checks to your Recce Checklist`})}),W(Yr,{sx:{display:`list-item`,p:0},children:W(Y,{children:`...and more!`})})]}),W(Y,{children:`Take the next step toward better data impact assessment.`})]}),W(J,{sx:{width:`100%`,mt:3},children:W(q,{color:`iochmara`,variant:`contained`,size:`large`,onClick:()=>{t?t():window.open(e,`_blank`)},children:`Start Now`})})]})})}function Lo({docsUrl:e=`https://docs.reccehq.com/configure-diff/`}={}){return G(J,{direction:`row`,spacing:`10px`,alignItems:`flex-start`,children:[W(K,{component:gi,sx:{color:`iochmara.main`,fontSize:20}}),G(J,{spacing:`5px`,children:[G(Y,{sx:{fontWeight:700},children:[`Single Environment Mode`,` `,W(Y,{component:`span`,sx:{color:`error.main`,fontWeight:600},children:`Limited Functionality`})]}),W(Y,{sx:{fontSize:`0.875rem`},children:`Single Environment Mode allows you to explore your dbt project but won't show data comparisons between environments.`}),W(Y,{sx:{fontSize:`0.875rem`},children:`To set up full environment comparison:`}),G(Jr,{sx:{pl:2},children:[W(Yr,{sx:{p:0,display:`list-item`},children:W(Y,{sx:{fontSize:`0.875rem`},children:"Run `recce debug` for setup assistance"})}),W(Yr,{sx:{p:0,display:`list-item`},children:G(Y,{sx:{fontSize:`0.875rem`},children:[`Visit`,` `,W(kn,{sx:{color:`primary.main`,fontWeight:500},target:`_blank`,href:e,children:`docs`}),` `,`for configuration details`]})})]})]})]})}function Ro(){return W(K,{sx:{width:`100%`,height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:W(Vn,{size:48})})}function zo({error:e,onRetry:t}){return W(K,{sx:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:G(J,{alignItems:`center`,spacing:1,children:[W(K,{children:`Failed to load lineage data. This could be because the server has been terminated or there is a network error.`}),G(K,{children:[`[Reason: `,e,`]`]}),W(q,{color:`iochmara`,variant:`contained`,onClick:()=>{t&&t()},children:`Retry`})]})})}function Bo({viewOptions:e,onViewOptionsChanged:t}){return W(K,{sx:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:G(J,{alignItems:`center`,spacing:1,children:[W(U,{children:`No change detected`}),W(q,{color:`iochmara`,variant:`contained`,onClick:async()=>{await t({...e,view_mode:`all`})},children:`Show all nodes`})]})})}function Vo(){let{isHistoryOpen:e,showHistory:t}=de();if(!e)return G(K,{children:[W(K,{sx:{fontSize:`8pt`},children:`History`}),W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(Hr,{}),onClick:()=>{Xt({name:e?`hide`:`show`}),t()},children:`Show`})]})}const Ho=e=>({fontSize:`8pt`,bgcolor:e?`grey.700`:`grey.100`,px:.5,borderRadius:1}),Uo=()=>{let e=Ho(Et());return G(J,{alignItems:`flex-start`,spacing:0,children:[W(Y,{fontSize:`10pt`,color:`text.secondary`,pb:1,children:`Select nodes by dbt node selector syntax`}),G(Y,{fontSize:`8pt`,children:[W(K,{component:`code`,sx:e,children:`model_name`}),` `,`Select a node`]}),G(Y,{fontSize:`8pt`,children:[W(K,{component:`code`,sx:e,children:`model_name+`}),` `,`Select downstream nodes`]}),G(Y,{fontSize:`8pt`,children:[W(K,{component:`code`,sx:e,children:`+model_name`}),` `,`Select upstream nodes`]}),G(Y,{fontSize:`8pt`,children:[W(K,{component:`code`,sx:e,children:`model*`}),` `,`Select by wildcard`]})]})},Wo=({isDisabled:e,viewOptions:t,onViewOptionsChanged:n})=>{let[r,i]=H(null),a=!!r,o=t.view_mode??`changed_models`,s=o===`changed_models`?`Changed Models`:`All`,c=e=>{i(e.currentTarget)},l=()=>{i(null)},u=e=>{n({...t,view_mode:e}),l()},d=tt(`model`).icon;return G(U,{children:[W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,onClick:c,disabled:e,startIcon:d&&W(d,{}),endIcon:W(Xn,{}),sx:{minWidth:100,textTransform:`none`,fontSize:`0.75rem`},children:s}),G(Lr,{anchorEl:r,open:a,onClose:l,children:[W(Wr,{sx:{lineHeight:`32px`,bgcolor:`transparent`},children:`mode`}),G(Di,{value:o,children:[W(Q,{onClick:()=>u(`changed_models`),children:W(Nr,{value:`changed_models`,control:W(Ei,{size:`small`,sx:{py:0}}),label:`Changed Models`,sx:{m:0}})}),W(Q,{onClick:()=>u(`all`),children:W(Nr,{value:`all`,control:W(Ei,{size:`small`,sx:{py:0}}),label:`All`,sx:{m:0}})})]})]})]})},Go=({isDisabled:e,viewOptions:t,onViewOptionsChanged:n,lineageGraph:r})=>{let[i,a]=H(null),o=!!i,s=new Set,c=Object.values(r?.nodes??{});for(let e of c)e.data.packageName&&s.add(e.data.packageName);let l=r?.manifestMetadata.current?.project_name,u=t.packages?new Set(t.packages):l?new Set([l]):s,d=u.size===s.size,f=u.size===0,p=u.size===1?Array.from(u)[0]:d?`All Packages`:f?`No Package`:`${u.size} Packages`,m=e=>{a(e.currentTarget)},h=()=>{a(null)},g=()=>{n(d?{...t,packages:[]}:{...t,packages:Array.from(s)})},_=e=>{let r=new Set(u);r.has(e)?r.delete(e):r.add(e),n({...t,packages:Array.from(r)})};return G(U,{children:[W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,onClick:m,disabled:e,startIcon:W(fi,{}),endIcon:W(Xn,{}),sx:{minWidth:100,textTransform:`none`,fontSize:`0.75rem`},children:p}),G(Lr,{anchorEl:i,open:o,onClose:h,children:[W(Wr,{sx:{lineHeight:`32px`,bgcolor:`transparent`},children:`Select Packages`}),G(Q,{onClick:g,children:[W(Mr,{checked:d,indeterminate:!d&&!f,size:`small`,sx:{py:0}}),W(ci,{children:`Select All`})]}),W(Bn,{}),Array.from(s).map(e=>G(Q,{onClick:()=>_(e),children:[W(Mr,{checked:u.has(e),size:`small`,sx:{py:0}}),W(ci,{className:`no-track-pii-safe`,children:e})]},e))]})]})},Ko=({value:e,onChange:t,isDisabled:n,tooltipComponent:r,showTooltip:i=!0})=>{let[a,o]=H(e),s=wn(null);return xn(()=>{s.current&&(s.current.value=e)},[e]),W(Z,{title:i?r:``,placement:`bottom-start`,slotProps:{tooltip:{sx:{width:`18.75rem`,p:2,boxShadow:3,border:1,borderRadius:1,color:`text.primary`,bgcolor:`background.paper`}}},children:W(Gr,{inputRef:s,size:`small`,placeholder:`with selectors`,disabled:n,value:a,onChange:e=>{o(e.target.value)},onKeyUp:n=>{n.key===`Enter`?t(a):n.key===`Escape`&&(n.preventDefault(),o(e),s.current&&s.current.blur())},onBlur:()=>{o(e)},sx:{"& .MuiInputBase-root":{width:`18.75rem`,height:24,fontSize:`0.75rem`},"& .MuiInputBase-input":{py:.5,px:1}}})})},qo=({isDisabled:e,viewOptions:t,onViewOptionsChanged:n,showTooltip:r})=>W(Ko,{isDisabled:e,value:t.select??``,onChange:e=>{n({...t,select:e||void 0})},tooltipComponent:W(Uo,{}),showTooltip:r}),Jo=({isDisabled:e,viewOptions:t,onViewOptionsChanged:n})=>W(Ko,{isDisabled:e,value:t.exclude??``,onChange:e=>{n({...t,exclude:e||void 0})}}),Yo=({label:e,children:t,style:n})=>G(K,{style:n,sx:{maxWidth:300},children:[W(Y,{fontSize:`8pt`,children:(e??``).trim()||W(U,{children:`\xA0`})}),t]}),Xo=({children:e})=>W(U,{children:e}),Zo=({viewOptions:e,onViewOptionsChanged:t,lineageGraph:n,featureToggles:r,serverFlags:i,focusedNode:a,selectedNodes:o,onDeselect:s,onRunRowCount:c,onRunRowCountDiff:l,onRunValueDiff:u,onAddLineageDiffCheck:d,onAddSchemaDiffCheck:f,runTypeIcons:p,historyToggleSlot:m,SetupConnectionPopoverSlot:h=Xo})=>{let g=i?.single_env_onboarding,[_,v]=H(null),y=!!_,b=o.length>0,x=b,S=e=>{v(e.currentTarget)},C=()=>{v(null)},w=p.rowCountDiff,T=p.valueDiff,E=p.lineageDiff,D=p.schemaDiff;return W(J,{direction:`row`,alignItems:`center`,borderBottom:1,borderColor:`neutral.light`,sx:{width:`100%`,p:`4pt 8pt`,gap:`0.5rem`},children:G(J,{direction:`row`,alignItems:`center`,sx:{flex:1,gap:`0.5rem`},children:[m,W(Yo,{label:`Mode`,style:{flexShrink:1},children:W(Wo,{isDisabled:x,viewOptions:e,onViewOptionsChanged:t})}),W(Yo,{label:`Package`,style:{flexShrink:1},children:W(Go,{isDisabled:x,viewOptions:e,onViewOptionsChanged:t,lineageGraph:n})}),W(Yo,{label:`Select`,style:{flexShrink:1},children:W(qo,{isDisabled:x,viewOptions:e,onViewOptionsChanged:t,showTooltip:g})}),W(Yo,{label:`Exclude`,style:{flexShrink:1},children:W(Jo,{isDisabled:x,viewOptions:e,onViewOptionsChanged:t})}),W(K,{sx:{flexGrow:1}}),b&&G(U,{children:[W(Yo,{label:``,style:{flexShrink:0},children:W(Y,{fontSize:`9pt`,color:`text.secondary`,children:o.length>1?`${o.length} nodes selected`:`${o.length} node selected`})}),W(Yo,{label:``,children:W(q,{variant:`outlined`,color:`neutral`,size:`xsmall`,onClick:()=>{s()},sx:{textTransform:`none`,fontSize:`9pt`},children:`Deselect`})}),g&&W(Yo,{label:`Explore`,children:G(K,{sx:{display:`inline-flex`},children:[W(q,{size:`xsmall`,color:`neutral`,variant:`outlined`,onClick:S,endIcon:W(Xn,{}),sx:{textTransform:`none`,fontSize:`0.75rem`},children:`Actions`}),W(Lr,{anchorEl:_,open:y,onClose:C,anchorOrigin:{vertical:`bottom`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`right`},children:G(Q,{disabled:r.disableDatabaseQuery,onClick:async()=>{await c?.(),C()},children:[W(si,{children:W(w,{fontSize:`small`})}),W(ci,{children:`Row Count`})]})})]})})]}),!g&&W(Yo,{label:`Explore`,children:G(K,{sx:{display:`inline-flex`},children:[W(q,{size:`xsmall`,color:`neutral`,variant:`outlined`,disabled:r.disableViewActionDropdown,onClick:S,endIcon:W(Xn,{}),sx:{textTransform:`none`,fontSize:`0.75rem`},children:`Actions`}),G(Lr,{anchorEl:_,open:y,onClose:C,anchorOrigin:{vertical:`bottom`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`right`},children:[W(Wr,{sx:{lineHeight:`32px`,bgcolor:`transparent`},children:`Diff`}),W(h,{display:r.mode===`metadata only`,children:G(Q,{disabled:r.disableDatabaseQuery,onClick:async()=>{await l?.(),C()},children:[W(si,{children:W(w,{fontSize:`small`})}),W(ci,{children:`Row Count Diff`})]})}),W(h,{display:r.mode===`metadata only`,children:G(Q,{disabled:r.disableDatabaseQuery,onClick:async()=>{await u?.(),C()},children:[W(si,{children:W(T,{fontSize:`small`})}),W(ci,{children:`Value Diff`})]})}),W(Bn,{}),W(Wr,{sx:{lineHeight:`32px`,bgcolor:`transparent`},children:`Add to Checklist`}),G(Q,{onClick:()=>{d?.(e.view_mode),C()},children:[W(si,{children:W(E,{fontSize:`small`})}),W(ci,{children:`Lineage Diff`})]}),G(Q,{onClick:()=>{f?.(),C()},children:[W(si,{children:W(D,{fontSize:`small`})}),W(ci,{children:`Schema Diff`})]})]})]})})]})})},Qo=({display:e,children:t})=>W(Os,{display:e,children:t}),$o=()=>{let{deselect:e,focusedNode:t,selectedNodes:n,viewOptions:r,onViewOptionsChanged:i,runRowCount:a,runRowCountDiff:o,runValueDiff:s,addLineageDiffCheck:c,addSchemaDiffCheck:l}=le(),{lineageGraph:u}=M(),{featureToggles:d}=I(),{data:f}=F();return W(Zo,{viewOptions:r,onViewOptionsChanged:i,lineageGraph:u,featureToggles:d,serverFlags:f,focusedNode:t,selectedNodes:n,onDeselect:e,onRunRowCount:a,onRunRowCountDiff:o,onRunValueDiff:s,onAddLineageDiffCheck:c,onAddSchemaDiffCheck:l,runTypeIcons:{rowCountDiff:z(`row_count_diff`).icon,valueDiff:z(`value_diff`).icon,lineageDiff:z(`lineage_diff`).icon,schemaDiff:z(`schema_diff`).icon},historyToggleSlot:W(Vo,{}),SetupConnectionPopoverSlot:Qo})};function es({interactive:e=!1,...t},n){let{isDark:r}=ct(),{apiClient:i}=Oe(),a=pn(),o=kr(),s=wn(null),{copyToClipboard:c,ImageDownloadModal:l,ref:u}=Va(),[f,p,m]=Or(ja),[h,y,b]=Dr([]),{lineageGraph:x,refetchLineageGraph:S,isLoading:T,error:D,refetchRunsAggregated:O}=M(),{featureToggles:k,singleEnv:ee}=I(),{runId:re,showRunId:ie,closeRunResult:ae,runAction:j,isRunResultOpen:oe}=de(),{run:N}=ht(re),[P,le]=H({...t.viewOptions}),ue=Wa(),pe=wn([]).current,[F,_e]=H(void 0),[ve,ye]=H(!1),xe=wn(!1);xe.current=ve;let Se=wn(new Set),Ce=dn({mutationFn:e=>te(e,i)}),[we,Te]=H({}),Ee=B(e=>{if(!e.change_analysis)return;let t=e.node_id??`__impact_radius__`;Se.current.has(t)||(Se.current.add(t),a.invalidateQueries({queryKey:A.lineage()}))},[a]),De=B(e=>f.filter(ce).find(t=>t.data.name===e),[f]);Sn(n,()=>({copyToClipboard:c}));let ke=V(()=>!!(x&&x.modifiedSet.length>0),[x]),Ae=P.view_mode??`changed_models`,je=V(()=>f.filter(e=>e.type===`lineageGraphNode`).map(e=>e.id),[f]),Me=V(()=>x?je.map(e=>x.nodes[e]):[],[x,je]),[Ne,Pe]=H(),L=Ne?x?.nodes[Ne]:void 0,[R,Fe]=H(),[Ie,Le]=H(new Set),Re=V(()=>x?Array.from(Ie).map(e=>x.nodes[e]):[],[x,Ie]),ze=qa(Re.length>0?Re:Me,{onActionStarted:()=>{Fe(`action_result`)},onActionNodeUpdated:e=>{p(t=>t.map(t=>t.id===e.id?{...t}:t))},onActionCompleted:()=>{}}),z=B(()=>{let e=new Map,t=o.getNodes();for(let n of t)!n.parentId&&n.position&&e.set(n.id,{x:n.position.x,y:n.position.y});return e},[o]),Be=V(()=>{if(!x)return new Set;let e=new Set;if(F){for(let[t,n]of Object.entries(F.current.nodes))n.impacted!==!1&&e.add(t);for(let t of Object.keys(F.current.columns))e.add(t)}else if(R===`action_result`){let t=Object.keys(ze.actionState.actions);e=new Set(t)}else e=L?fe(ge(x,[L.id]),me(x,[L.id])):ke?me(x,x.modifiedSet):new Set(je);return new Set(e)},[x,F,R,L,ke,ze.actionState.actions,je]),Ve=Qa(),He=()=>{Ve.closeContextMenu()};Cn(()=>{(async()=>{let e;if(!x)return;if(P.node_ids)e=P.node_ids;else{let n=x.manifestMetadata.current?.project_name,r={view_mode:P.view_mode??(ke?`changed_models`:`all`),packages:n?[n]:void 0,...t.viewOptions};try{e=(await C({select:r.select,exclude:r.exclude,packages:r.packages,view_mode:r.view_mode},i)).nodes}catch{r.view_mode=`all`,e=(await C({select:r.select,exclude:r.exclude,packages:r.packages,view_mode:r.view_mode},i)).nodes}le(r)}let n;if(P.column_level_lineage){let e={...P.column_level_lineage,change_analysis:P.column_level_lineage.change_analysis??xe.current};try{n=await Ce.mutateAsync(e),Ee(e)}catch(e){if(e instanceof mn){let t=e;jt.create({title:`Column Level Lineage error`,description:t.response?.data.detail??e.message,type:`error`,closable:!0});return}}}let[r,a,o]=await $a(x,{selectedNodes:e,cll:n});p(r),y(a),Te(o),_e(n),ue(r,P.view_mode??`changed_models`,xe.current,!!P.column_level_lineage?.column,!!Ne||!!N)})()},[x]);let Ue=()=>{Pe(void 0)},We=async e=>{let t=f.find(t=>t.id===e);if(t){if(t.parentId){let e=t.parentId;t=f.find(t=>t.id===e)??t}if(t.measured!=null){let{width:e,height:n}=t.measured;if(e&&n){let r=t.position.x+e/2,i=t.position.y+n/2,a=o.getZoom();await o.setCenter(r,i,{zoom:a,duration:200})}}}},Ge=Ha();Ua(s,async()=>{R!==`selecting`&&(Ne?await We(Ne):await o.fitView({nodes:f,duration:200}))});let Ke=async(e,t=!1)=>{let n=P.column_level_lineage;e||ye(!1);let r=n!==void 0;await Ze({...P,column_level_lineage:e},!1,r),t||pe.push(n),e?.node_id?Pe(e.node_id):e||Pe(void 0)},qe=async e=>{if(e){if(pe.length===0)return;let e=pe.pop();e?await Ke(e,!0):await Ke(void 0,!0)}else await Ke(void 0,!0)},Je=(e,t)=>{R||Ke({node_id:t.data.node.id,column:t.data.column})},Ye=(t,n)=>{if(e&&x){if(se(n)){Je(t,n);return}if(He(),!R)Pe(n.id);else if(R===`action_result`){let e=ze.actionState.actions[n.id];e.run?.run_id&&ie(e.run.run_id),Pe(n.id)}else{let e=new Set(Ie);Ie.has(n.id)?e.delete(n.id):e.add(n.id),Le(e),e.size===0&&Fe(void 0)}}},Xe=async e=>{let{viewOptions:t=P}=e,{fitView:n,preservePositions:r=!1}=e,a;if(!x)return;if(P.select!==t.select||P.exclude!==t.exclude||P.packages!==t.packages||P.view_mode!==t.view_mode){try{let e=await C({select:t.select,exclude:t.exclude,packages:t.packages,view_mode:t.view_mode},i);t={...t,column_level_lineage:void 0},a=e.nodes}catch(e){if(e instanceof mn){let t=e;jt.create({title:`Select node error`,description:t.response?.data.detail??e.message,type:`error`,closable:!0})}return}Pe(void 0)}else a=f.map(e=>e.id);let s;if(t.column_level_lineage){let e={...t.column_level_lineage,change_analysis:t.column_level_lineage.change_analysis??ve};try{s=await Ce.mutateAsync(e),Ee(e)}catch(e){if(e instanceof mn){let t=e;jt.create({title:`Column Level Lineage error`,description:t.response?.data.detail??e.message,type:`error`,closable:!0});return}}}else ye(!1);let c;r&&(c=z());let[l,u,m]=await $a(x,{selectedNodes:a,cll:s,existingPositions:c});p(l),y(u),Te(m),_e(s),ue(l,t.view_mode??`changed_models`,ve,!!t.column_level_lineage?.column,!!Ne||!!N),N&&(w(N)||v(N)||E(N)||d(N)||g(N))&&N.params?.model&&!De(N.params.model)&&ae(),n&&(await new Promise(e=>setTimeout(e,1)),o.fitView({nodes:l,duration:200}))},Ze=async(e,t=!0,n=!1)=>{le(e),await Xe({viewOptions:e,fitView:t,preservePositions:n})},Qe=Ja();xn(()=>{let t=N?.type;if(e&&oe&&!(!t||[`query_diff`,`query`,`row_count`,`row_count_diff`].includes(t))&&!R){let e;(w(N)||v(N)||E(N)||d(N)||g(N))&&(e=N.params?.model);let t=new MouseEvent(`click`,{bubbles:!0,cancelable:!0,view:window});if(e){let n=De(e);n?ce(n)&&L!==n.data.data&&Ye(t,n):Ze({...P,view_mode:`all`})}else Ue()}},[N,P,oe,R,De,L,e]);let et=(e,t=1e3)=>{R===`action_result`||x===void 0||(R||(Fe(`selecting`),ze.reset(),P.column_level_lineage&&Ze({...P,column_level_lineage:void 0})),Le(fe(Ie,ge(x,[e],t))))},tt=(e,t=1e3)=>{R===`action_result`||x===void 0||(R||(Fe(`selecting`),ze.reset(),P.column_level_lineage&&Ze({...P,column_level_lineage:void 0})),Le(fe(Ie,me(x,[e],t))))},nt=(t,n)=>{if(!e||R===`action_result`)return;t.preventDefault();let r=u.current,i=r.getBoundingClientRect(),a=t.clientX-i.left,o=t.clientY-i.top+r.offsetTop;Ve.showContextMenu(a,o,n)},rt=e=>{if(!R){if(!x)return;Le(new Set([e])),Fe(`selecting`),Pe(void 0),ze.reset()}else if(R===`selecting`){let t=new Set(Ie);Ie.has(e)?t.delete(e):t.add(e),Le(t),t.size===0&&Fe(void 0)}},it=()=>{Fe(void 0),Le(new Set),Pe(void 0),ae(),O?.()},ot={interactive:e,nodes:f,focusedNode:L,selectedNodes:Re,viewOptions:P,showContextMenu:nt,onViewOptionsChanged:Ze,selectMode:R,selectNode:rt,selectParentNodes:et,selectChildNodes:tt,deselect:it,isNodeHighlighted:e=>Be.has(e),isNodeSelected:e=>Ie.has(e),isEdgeHighlighted:(e,t)=>F?e in F.current.parent_map?t in F.current.parent_map[e]:!1:Be.has(e)&&Be.has(t),isNodeShowingChangeAnalysis:e=>{if(!x||!ve)return!1;let t=e in x.nodes?x.nodes[e]:void 0,n=P.column_level_lineage;return n?.node_id&&!n.column?n.node_id===e&&!!t?.data.changeStatus:!!t?.data.changeStatus},changeAnalysisMode:ve,setChangeAnalysisMode:ye,getNodeAction:e=>ze.actionState.actions[e],getNodeColumnSet:e=>e in we?new Set(we[e]):new Set,runRowCount:async()=>{R===`selecting`?(await ze.runRowCount(),en({type:`row_count`,selected:`multi`})):L?(j(`row_count`,{node_names:[L.data.name]},{showForm:!1,showLast:!1}),en({type:`row_count`,selected:`single`})):(j(`row_count`,{select:P.select,exclude:P.exclude,packages:P.packages,view_mode:P.view_mode}),en({type:`row_count`,selected:`none`}))},runRowCountDiff:async()=>{R===`selecting`?(await ze.runRowCountDiff(),en({type:`row_count_diff`,selected:`multi`})):L?(j(`row_count_diff`,{node_names:[L.data.name]},{showForm:!1,showLast:!1}),en({type:`row_count_diff`,selected:`single`})):(j(`row_count_diff`,{select:P.select,exclude:P.exclude,packages:P.packages,view_mode:P.view_mode}),en({type:`row_count_diff`,selected:`none`}))},runValueDiff:async()=>{if(L)j(`value_diff`,{model:L.data.name},{showForm:!0,showLast:!1}),en({type:`value_diff`,selected:`single`});else{let e=R===`selecting`?Re.length:je.length;await Qe.confirm(e)&&(await ze.runValueDiff(),en({type:`value_diff`,selected:R===`selecting`?`multi`:`none`}))}},addLineageDiffCheck:async()=>{let e=await ne(P,i),t;t=R===`selecting`?`multi`:L?`single`:`none`,en({type:`lineage_diff`,selected:t}),e&&(await a.invalidateQueries({queryKey:A.checks()}),Ge(e))},addSchemaDiffCheck:async()=>{let e;R===`selecting`?Re.length>0&&(e=await ze.addSchemaDiffCheck(),it(),en({type:`schema_diff`,selected:`multi`})):L?(e=await _({node_id:L.id},i),en({type:`schema_diff`,selected:`single`})):(e=await _({select:P.select,exclude:P.exclude,packages:P.packages,view_mode:P.view_mode},i),en({type:`schema_diff`,selected:`none`})),e&&(await a.invalidateQueries({queryKey:A.checks()}),Ge(e))},cancel:ze.cancel,actionState:ze.actionState,centerNode:We,cll:F,showColumnLevelLineage:Ke,resetColumnLevelLineage:qe};return T?W(Ro,{}):D?W(zo,{error:D,onRetry:S}):!x||f==ja?W(U,{}):Ae===`changed_models`&&!x.modifiedSet.length?W(Bo,{viewOptions:P,onViewOptionsChanged:Ze}):G(he.Provider,{value:ot,children:[G(at,{sizes:L?[70,30]:[100,0],minSize:0,gutterSize:5,className:L?void 0:`split-gutter-hidden`,style:{height:`100%`,width:`100%`},children:[G(J,{ref:s,divider:W(Bn,{sx:{borderColor:`grey.200`}}),spacing:0,sx:{contain:`strict`,position:`relative`},children:[e&&G(U,{children:[W($o,{}),k.mode===`metadata only`&&W(Fo,{})]}),G(Cr,{proOptions:{hideAttribution:!0},nodeTypes:ka,edgeTypes:Aa,nodes:f,edges:h,onNodesChange:m,onEdgesChange:b,onNodeClick:Ye,onNodeContextMenu:nt,onClick:He,onInit:async()=>{if(ke)await o.fitView();else{let e=Er(f,{});await o.setCenter(e.x+e.width/2,e.y+e.height/2,{zoom:1})}},maxZoom:1,minZoom:.1,nodesDraggable:e,ref:u,colorMode:r?`dark`:`light`,children:[W(hr,{id:`lineage-bg`,variant:gr.Dots,color:r?be.neutral[700]:be.neutral[300],gap:20,size:2}),W(yr,{showInteractive:!1,position:`top-right`,className:$e,style:{backgroundColor:r?be.neutral[700]:void 0,borderColor:r?be.neutral[600]:void 0},children:W(vr,{title:`copy image`,onClick:async()=>{await c(),Kt({type:Ae,from:`lineage_view`})},style:{backgroundColor:r?be.neutral[700]:void 0,color:r?be.neutral[200]:void 0},children:W(K,{component:ui})})}),W(l,{}),W(xr,{position:`bottom-left`,children:G(J,{spacing:`5px`,children:[ke&&W(gt,{variant:`changeStatus`}),P.column_level_lineage&&W(gt,{variant:`transformation`})]})}),W(xr,{position:`top-center`,children:W(Ya,{notification:ee?W(Lo,{}):null,type:`info`})}),W(xr,{position:`top-left`,children:G(J,{spacing:`5px`,children:[W($i,{action:Ce}),f.length==0&&W(Y,{sx:{fontSize:`1.25rem`,color:`grey`,opacity:.5},children:`No nodes`})]})}),W(br,{nodeColor:Ma,nodeStrokeWidth:3,zoomable:!0,pannable:!0,bgColor:r?be.neutral[800]:void 0,maskColor:r?`${be.neutral[900]}99`:`${be.neutral[100]}99`}),R===`action_result`&&W(xr,{position:`bottom-center`,className:`ignore-screenshot`,children:W(Qi,{onClose:()=>{it()}})})]}),W(Za,{...Ve.props})]}),L?W(K,{sx:{borderLeft:`solid 1px`,borderColor:`divider`,height:`100%`},children:W(No,{node:L,onCloseNode:Ue})}):W(K,{})]}),Qe.AlertDialog]})}const ts=vn(es);function ns(){return W(wr,{children:W(ts,{interactive:!0})})}function rs(){let{apiClient:e}=Oe(),{data:t,isLoading:n,error:r}=fn({queryKey:A.user(),queryFn:()=>Bt(e),retry:!1}),{data:i}=fn({queryKey:[`github-avatar`,t?.id],queryFn:()=>t?zt(t.id):Promise.resolve(null),enabled:!!t?.id&&t.login_type===`github`,retry:!1,staleTime:300*1e3}),[a,o]=H(null),s=!!a,c=e=>{o(e.currentTarget)},l=()=>{o(null)},u=!n&&!r&&t;return G(U,{children:[n?W(K,{onClick:c,sx:{width:32,height:32,borderRadius:`50%`,bgcolor:`background.paper`,color:`primary.main`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`},children:W(Vn,{size:16})}):W(Xr,{onClick:c,src:i||void 0,sx:{width:28,height:28,cursor:`pointer`,outline:`1px solid white`,fontSize:`0.875rem`},children:(e=>e?e.charAt(0).toUpperCase():`U`)(t?.login)}),G(Lr,{anchorEl:a,open:s,onClose:l,slotProps:{paper:{sx:{bgcolor:`background.paper`,borderColor:`divider`,boxShadow:3,minWidth:180}}},children:[G(K,{sx:{px:2,py:1.5},children:[n&&G(K,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[W(Y,{variant:`body2`,color:`text.primary`,children:`Loading...`}),W(Vn,{size:16})]}),r&&W(Y,{variant:`caption`,color:`error`,children:`Failed to load user information`}),u&&G(U,{children:[W(Y,{variant:`body2`,fontWeight:`600`,color:`text.primary`,children:t.login}),t.email&&W(Y,{variant:`caption`,color:`text.secondary`,children:t.email})]})]}),W(Bn,{}),G(Q,{onClick:()=>{window.open(`https://cloud.datarecce.io/`,`_blank`),l()},children:[W(si,{children:W(Hn,{})}),W(ci,{children:`Recce Cloud`})]}),G(Q,{onClick:()=>{window.open(Vt,`_blank`),l()},children:[W(si,{children:W(Jn,{})}),W(ci,{children:`Get live support`})]})]})]})}const is=()=>{let{setTheme:e,resolvedTheme:t}=Pn(),[n,r]=H(!1);xn(()=>{r(!0)},[]);let i=()=>{e(t===`dark`?`light`:`dark`)};if(!n)return W(X,{size:`small`,sx:{color:`rgba(255, 255, 255, 0.8)`,"&:hover":{bgcolor:`rgba(255, 255, 255, 0.1)`}},disabled:!0,children:W(ur,{style:{width:18,height:18}})});let a=t===`dark`;return W(Z,{title:a?`Switch to light mode`:`Switch to dark mode`,children:W(X,{size:`small`,onClick:i,sx:{color:`rgba(255, 255, 255, 0.8)`,"&:hover":{bgcolor:`rgba(255, 255, 255, 0.1)`}},"aria-label":a?`Switch to light mode`:`Switch to dark mode`,children:W(a?ur:ir,{style:{width:18,height:18}})})})};function as(e,t,n,r){let i=e?.git,a=e?.pullRequest,o=e?.dbt?.base,s=e?.dbt?.current,c={review_mode:t||!1,adapter_type:e?.adapterType||null,has_git_info:!Rr(i),has_pr_info:!Rr(a)};return e?.adapterType===`dbt`&&(c.base={schema_count:n.size,dbt_version:o?.dbt_version||null,timestamp:o?.generated_at||null},c.current={schema_count:r.size,dbt_version:s?.dbt_version||null,timestamp:s?.generated_at||null},c.schemas_match=n.size===r.size&&Array.from(n).every(e=>r.has(e))),e?.adapterType===`sqlmesh`&&(c.base={has_env:!!e.sqlmesh?.base_env},c.current={has_env:!!e.sqlmesh?.current_env}),c}function os(e){return Object.values(e).every(e=>e===null)?[W(K,{sx:{ml:`10px`},children:`No information`},`no info`)]:Object.entries(e).filter(([e,t])=>e!==`url`&&t!=null).map(([e,t])=>G(`li`,{style:{marginLeft:`10px`},children:[e,`: `,t]},e))}function ss(){let{envInfo:e,reviewMode:t,lineageGraph:n}=M(),[r,i]=H(!1),a=e?.git,o=e?.pullRequest,s={...a,...o},c=e?.dbt?.base,l=e?.dbt?.current,u=c?.generated_at?kt(c.generated_at):``,d=l?.generated_at?kt(l.generated_at):``,f=``,p=``;c&&(f=c.generated_at?Mt(c.generated_at):``),l&&(p=l.generated_at?Mt(l.generated_at):``);let[m,h]=Lt(n),g=wn(!1);xn(()=>{!g.current&&e&&(g.current=!0,qt(as(e,t,m,h)))},[e,t,m,h]);let _=()=>i(!0),v=()=>i(!1);return G(U,{children:[W(Z,{title:`Environment Info`,placement:`bottom-end`,children:G(K,{sx:{display:`flex`,alignItems:`center`,cursor:`pointer`,"&:hover":{color:`text.primary`}},onClick:_,children:[G(J,{direction:`column`,sx:{display:{xs:`none`,lg:`flex`},fontSize:`0.875rem`},children:[G(K,{sx:{display:`flex`,alignItems:`baseline`,gap:.5},children:[W(Y,{component:`span`,noWrap:!0,sx:{color:`warning.main`,maxWidth:128},className:`no-track-pii-safe`,children:Array.from(m).join(`, `)}),G(Y,{component:`span`,noWrap:!0,children:[`(`,f,`)`]})]}),G(K,{sx:{display:`flex`,alignItems:`baseline`,gap:.5},children:[W(Y,{component:`span`,noWrap:!0,sx:{color:`primary.main`,maxWidth:128},className:`no-track-pii-safe`,children:Array.from(h).join(`, `)}),G(Y,{component:`span`,noWrap:!0,children:[`(`,p,`)`]})]})]}),W(X,{size:`small`,"aria-label":`Environment Info`,children:W(K,{component:nr,sx:{fontSize:16,verticalAlign:`middle`}})})]})}),G(Tn,{open:r,onClose:v,maxWidth:`sm`,fullWidth:!0,children:[G(On,{sx:{display:`flex`,alignItems:`center`},children:[`Environment Information`,W(K,{sx:{flexGrow:1}}),W(X,{size:`small`,onClick:v,children:W(Ln,{})})]}),W(Dn,{children:G(J,{direction:`column`,spacing:1,children:[t?G(J,{direction:`column`,spacing:.5,children:[W(Y,{variant:`h6`,sx:{fontSize:`1rem`},children:`Review Information`}),G(`ul`,{style:{margin:0,paddingLeft:`20px`},children:[s.url&&G(`li`,{style:{marginLeft:`10px`},children:[`url:`,` `,G(kn,{href:s.url,target:`_blank`,sx:{color:`primary.main`},children:[s.url,` `,W(An,{})]})]}),!Rr(s)&&os(s)]})]}):G(J,{direction:`column`,spacing:.5,children:[W(Y,{variant:`h6`,sx:{fontSize:`1rem`},children:`Dev Information`}),W(`ul`,{style:{margin:0,paddingLeft:`20px`},children:a&&os(a)})]}),W(Bn,{}),e?.adapterType===`dbt`&&G(J,{direction:`column`,spacing:.5,children:[W(Y,{variant:`h6`,sx:{fontSize:`1rem`},children:`DBT`}),W(Ai,{sx:{border:1,borderColor:`divider`,maxHeight:`30rem`},children:G(Oi,{size:`small`,stickyHeader:!0,children:[W(ji,{children:G(Mi,{children:[W($,{}),W($,{children:`base`}),W($,{children:`current`})]})}),G(ki,{children:[G(Mi,{children:[W($,{children:`schema`}),W($,{className:`no-track-pii-safe`,children:Array.from(m).map(e=>W(Z,{title:e,placement:`bottom`,children:W(`div`,{className:`max-w-72 truncate`,children:e})},e))}),W($,{className:`no-track-pii-safe`,children:Array.from(h).map(e=>W(Z,{title:e,placement:`bottom`,children:W(`div`,{className:`max-w-72 truncate`,children:e})},e))})]}),G(Mi,{children:[W($,{children:`version`}),W($,{children:c?.dbt_version}),W($,{children:l?.dbt_version})]}),G(Mi,{children:[W($,{children:`timestamp`}),W($,{children:u}),W($,{children:d})]})]})]})})]}),e?.adapterType===`sqlmesh`&&G(J,{direction:`column`,spacing:.5,children:[W(Y,{variant:`h6`,sx:{fontSize:`1rem`},children:`SQLMesh`}),W(Ai,{sx:{border:1,borderColor:`divider`,maxHeight:`30rem`},children:G(Oi,{stickyHeader:!0,children:[W(ji,{children:G(Mi,{children:[W($,{}),W($,{children:`base`}),W($,{children:`current`})]})}),W(ki,{children:G(Mi,{children:[W($,{children:`Environment`}),W($,{className:`no-track-pii-safe`,children:e.sqlmesh?.base_env}),W($,{className:`no-track-pii-safe`,children:e.sqlmesh?.current_env})]})})]})})]})]})}),W(En,{children:W(q,{color:`iochmara`,onClick:v,children:`Close`})})]})]})}const cs=()=>({toastSuccess:e=>{jt.create({description:e,type:`success`,duration:5e3,closable:!0})},toastError:(e,t)=>{let n=e;t!=null&&(n=hn(t)?`${e}. ${String(t.response?.data?.detail)}`:`${e}. ${t}`),jt.create({description:n,type:`error`,duration:5e3,closable:!0})}}),ls=e=>{xn(()=>{let t=e=>{e.preventDefault()};return e&&window.addEventListener(`beforeunload`,t),()=>{e&&window.removeEventListener(`beforeunload`,t)}},[e])},us=()=>{let{featureToggles:e}=I(),{fileName:t,cloudMode:n,isDemoSite:r,envInfo:i}=M(),{apiClient:a}=Oe(),[o,c]=H(!1),[l,u]=H(!1),d=!t&&!n&&!r,{data:p}=s(d),h=p!=null&&p.filter(e=>!e.is_preset).length>0;ls(d&&h);let[{newFileName:g,errorMessage:_,modified:v,overwriteWithMethod:y,bypass:b},x]=H({newFileName:t??`recce_state.json`,bypass:!1}),S=wn(null),{toastSuccess:C,toastError:w}=cs(),T=pn(),E=()=>{x({newFileName:t??`recce_state.json`,modified:!t,bypass:!1}),c(!0)},D=()=>c(!1),O=()=>u(!1),k=async(e,t)=>{if(!g)return;let n=localStorage.getItem(f.bypassSaveOverwrite)===`true`;try{e===`save`?await m({filename:g,overwrite:t??n},a):await ee({filename:g,overwrite:t??n},a),C(e===`save`?`Save file successfully`:`Rename file successfully`),await T.invalidateQueries({queryKey:A.lineage()}),b&&localStorage.setItem(f.bypassSaveOverwrite,`true`)}catch(t){if(hn(t)&&t.response?.status===409){x(t=>({...t,overwriteWithMethod:e})),u(!0);return}w(e===`save`?`Save file failed`:`Rename file failed`,t)}finally{D()}},te=()=>{O(),c(!0),x(e=>({...e,overwriteWithMethod:void 0}))};if(n||r)return W(U,{});let ne=`New Instance`+(h?` (unsaved)`:``),re;if(e.disableSaveToFile&&t){let e=i?.stateMetadata?.generated_at,n=e?Ne(new Date(e)):null;re=n?`${t} (${n})`:null}return G(U,{children:[G(J,{direction:`row`,alignItems:`center`,justifyContent:`center`,children:[W(K,{sx:{fontWeight:600},children:re??t??ne}),!e.disableSaveToFile&&W(Z,{title:t?`Change Filename`:`Save`,enterDelay:1e3,children:W(X,{onClick:E,"aria-label":t?`Change Filename`:`Save`,size:`small`,children:W(K,{component:t?or:jn,sx:{fontSize:16,verticalAlign:`middle`}})})})]}),G(Tn,{open:o,onClose:D,children:[G(On,{sx:{display:`flex`,alignItems:`center`},children:[t?`Change Filename`:`Save File`,W(K,{sx:{flexGrow:1}}),W(X,{size:`small`,onClick:D,children:W(Ln,{})})]}),W(Dn,{onKeyDown:e=>{e.stopPropagation()},children:W(Gr,{inputRef:S,value:g,label:`File name`,placeholder:`Enter filename`,error:!!_,helperText:_,fullWidth:!0,size:`small`,sx:{mt:1},onChange:e=>{let n=e.target.value,r;n?n.endsWith(`.json`)?/^[a-zA-Z0-9 _-]+\.json$/.test(n)?t&&n===t&&(r=`Filename is the same as the current one.`):r=`Invalid filename. Only alphanumeric, space, _ and - are allowed.`:r=`Filename must end with .json.`:r=`Filename cannot be empty.`,x(e=>({...e,modified:!0,newFileName:n,errorMessage:r}))},onKeyDown:e=>{if(e.key===`Enter`){if(_)return;k(t?`rename`:`save`)}else e.key===`Escape`&&D()}})}),G(En,{sx:{gap:`5px`},children:[W(q,{size:`small`,color:t?`inherit`:`iochmara`,variant:`contained`,onClick:async()=>{await k(`save`)},disabled:!g||!!_||!v,children:t?`Save as New File`:`Confirm`}),t&&W(q,{size:`small`,color:`iochmara`,variant:`contained`,onClick:async()=>{await k(`rename`)},disabled:!g||!!_||!v,children:`Rename`})]})]}),G(Tn,{open:l,onClose:O,children:[G(On,{sx:{display:`flex`,alignItems:`center`},children:[`Overwrite File?`,W(K,{sx:{flexGrow:1}}),W(X,{size:`small`,onClick:O,children:W(Ln,{})})]}),G(Dn,{sx:{borderTop:`solid 1px`,borderBottom:`solid 1px`,borderColor:`divider`},onKeyDown:e=>{e.stopPropagation()},children:[W(Y,{sx:{fontSize:`12pt`},children:y===`save`?`Saving a file with this name will overwrite the existing file. Are you sure you wish to continue?`:`Renaming the file with this name will overwrite the existing file. Are you sure you wish to continue?`}),W(Nr,{control:W(Mr,{size:`small`,checked:b,onChange:e=>{x(t=>({...t,bypass:e.target.checked}))}}),label:W(Y,{sx:{fontWeight:`bold`,pt:`8px`},children:`Don't show this again`})})]}),G(En,{sx:{gap:`5px`},children:[W(q,{variant:`outlined`,onClick:te,size:`small`,children:`Back`}),W(q,{size:`small`,color:`iochmara`,variant:`contained`,onClick:()=>{y&&(k(y,!0),O())},children:`Overwrite`})]})]})]})};function ds(){let{featureToggles:e}=I(),{apiClient:t}=Oe(),n=async()=>{try{let e=await k(t),n=JSON.stringify(e,null,2);jr(new Blob([n],{type:`application/json`}),`recce-state-${Qr(new Date,`yyyy-MM-dd-HH-mm-ss`)}.json`)}catch(e){console.error(`Export failed`,e),jt.create({title:`Export failed`,description:String(e),type:`error`,duration:5e3,closable:!0})}};return W(Z,{title:`Export`,children:W(X,{size:`small`,"aria-label":`Export state`,onClick:async()=>{await n(),sn({name:`export`})},disabled:e.disableExportStateFile,children:W(K,{component:tr,sx:{verticalAlign:`middle`,width:`16px`,height:`16px`}})})})}const fs=[`Processing...`,`Still processing, please wait...`,`Almost there, thanks for your patience...`];function ps(){let{successToast:e,failToast:t}=At(),[,n]=Pr(),{authed:r}=I(),{shareUrl:i,isLoading:a,error:o,handleShareClick:s}=xt(),[c,l]=H(!1),[u,d]=H(0),[f,p]=H(a);a!==f&&(p(a),a&&d(0)),Fr(()=>{d(e=>Math.min(e+1,fs.length-1))},a?3e4:null),xn(()=>{o&&t(`Failed to share state`,o)},[o,t]);let m=async()=>{try{await n(String(i)),e(`Copied the link to clipboard`)}catch(e){t(`Failed to copy the link`,e)}};return r?G(J,{direction:`row`,sx:{flex:1,alignItems:`center`,gap:`5px`},children:[W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(ai,{}),endIcon:i?W(K,{component:Qn,sx:{color:`success.main`}}):void 0,onClick:async()=>{await s(),an({name:`create`})},disabled:a,children:a?`Sharing...`:`Share`}),a&&W(Y,{sx:{fontSize:14,color:`grey.500`},children:fs[u]}),W(J,{direction:`row`,spacing:.5,alignItems:`center`,children:i&&G(U,{children:[W(K,{sx:{overflowX:`auto`,whiteSpace:`nowrap`,maxWidth:`350px`},children:W(Y,{sx:{fontSize:14},children:i})}),W(X,{size:`small`,"aria-label":`Copy the share URL`,onClick:async()=>{await m(),an({name:`copy`})},children:W(er,{})})]})})]}):G(J,{direction:`row`,sx:{flex:1,alignItems:`center`},children:[W(q,{size:`xsmall`,color:`neutral`,variant:`outlined`,onClick:()=>{l(!0)},startIcon:W(ai,{}),children:`Share`}),c&&W(vt,{parentOpen:c,handleParentClose:l,ignoreCookie:!0,variant:`enable-share`})]})}function ms(e){return/^\/checks\/([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/.test(e)}function hs(){return W(Z,{title:`Syncing`,children:W(K,{sx:{mx:`10px`},children:W(Vn,{size:20})})})}function gs(){let[e,t]=H(!1),n=pn(),{apiClient:r}=Oe(),i=ni(),a=ti(),{basePath:o}=ue(),[s,c]=H(!1),[l,u]=H(``),{data:d}=j(),f=()=>c(!1),p=B(async e=>{if(c(!1),t(!0),(await O(e,r)).status===`conflict`){c(!0),t(!1);return}for(;await x(r);)await new Promise(e=>setTimeout(e,1e3));jt.create({description:`Sync Completed`,type:`success`,duration:5e3,closable:!0}),t(!1),u(``),await n.invalidateQueries({queryKey:A.lineage()}),await n.invalidateQueries({queryKey:A.checks()}),await n.invalidateQueries({queryKey:A.runs()}),ms(a)&&i.push(`${o}/checks`)},[n,a,r,i.push,o]);return e?W(hs,{}):G(U,{children:[W(Z,{title:`Sync with Cloud`,children:W(X,{size:`small`,"aria-label":`Sync state`,onClick:()=>p(d?.session_id?{method:`merge`}:{}),children:W(K,{component:Rn,sx:{fontSize:16,verticalAlign:`middle`}})})}),G(Tn,{open:s,onClose:f,children:[G(On,{sx:{display:`flex`,alignItems:`center`,fontWeight:`bold`},children:[`Sync with Cloud`,W(K,{sx:{flexGrow:1}}),W(X,{size:`small`,onClick:f,children:W(Ln,{})})]}),G(Dn,{children:[W(Y,{children:`New changes have been detected in the cloud. Please choose a method to sync your state`}),W(K,{sx:{mt:`5px`},children:W(Di,{value:l,onChange:e=>{u(e.target.value)},children:G(J,{direction:`column`,children:[W(Nr,{value:`merge`,control:W(Ei,{}),label:G(J,{direction:`row`,alignItems:`center`,children:[`Merge`,W(Z,{title:`This will merge the local and remote states.`,children:W(K,{component:nr,sx:{ml:2,cursor:`pointer`}})})]})}),W(Nr,{value:`overwrite`,control:W(Ei,{}),label:G(J,{direction:`row`,alignItems:`center`,children:[`Overwrite`,W(Z,{title:`This will overwrite the remote state file with the local state.`,children:W(K,{component:nr,sx:{ml:2,cursor:`pointer`}})})]})}),W(Nr,{value:`revert`,control:W(Ei,{}),label:G(J,{direction:`row`,alignItems:`center`,children:[`Revert`,W(Z,{title:`This will discard local changes and revert to the cloud state.`,children:W(K,{component:nr,sx:{ml:2,cursor:`pointer`}})})]})})]})})})]}),G(En,{children:[W(q,{onClick:f,sx:{mr:1},children:`Cancel`}),W(q,{color:`iochmara`,variant:`contained`,onClick:()=>p({method:l||void 0}),disabled:!l,children:`Sync`})]})]})]})}const _s=[{path:`/lineage`,name:`Lineage`},{path:`/query`,name:`Query`},{path:`/checks`,name:`Checklist`}];function vs({queryKey:e,fetchCallback:t,selectCallback:n}){let{data:r,isLoading:i,error:a}=fn({queryKey:e,queryFn:t,select:n});return i||a||r===0?W(U,{}):W(K,{bgcolor:`brand.main`,display:`flex`,justifyContent:`center`,alignItems:`center`,p:1,borderRadius:`100%`,color:`white`,fontWeight:700,fontSize:`0.75rem`,children:W(`span`,{children:r})})}function ys(){let{apiClient:e}=Oe();return W(vs,{queryKey:A.checks(),fetchCallback:()=>b(e),selectCallback:e=>e.filter(e=>!e.is_checked).length})}const bs=()=>{let e=ti(),{isDemoSite:t,isLoading:n,cloudMode:r}=M(),{featureToggles:i}=I(),{data:a,isLoading:o}=F(),s=wn(null);return xn(()=>{s.current&&s.current!==e&&tn({from:s.current,to:e}),s.current=e},[e]),W(K,{sx:{borderBottom:`1px solid lightgray`,px:`12px`},children:G(K,{sx:{display:`grid`,gridTemplateColumns:`1fr auto 1fr`,width:`100%`,alignItems:`center`},children:[W(qr,{value:V(()=>e.startsWith(`/checks`)?`/checks`:e.startsWith(`/query`)?`/query`:e.startsWith(`/runs`)?`/runs`:`/lineage`,[e]),sx:{borderBottom:`none`,minHeight:`auto`},children:_s.map(({path:e,name:t})=>t===`Query`&&a?.single_env_onboarding?null:t===`Checklist`&&ys?W(Kr,{value:e,disabled:n||o,sx:{p:0},label:W(K,{sx:{display:`flex`,alignItems:`center`,gap:`4px`},children:G(Fn,{href:e,style:{textDecoration:`none`,color:`inherit`,padding:`0.875rem 1.1875rem`,display:`flex`,gap:3,alignItems:`center`},children:[t,` `,W(ys,{})]})})},e):W(Kr,{value:e,disabled:n||o,sx:{p:0},label:W(K,{sx:{display:`flex`,alignItems:`center`,gap:`4px`},children:W(Fn,{href:e,style:{textDecoration:`none`,color:`inherit`,padding:`0.875rem 1.1875rem`},children:t})})},e))}),G(K,{sx:{display:`flex`,alignItems:`center`,gap:`12px`,justifyContent:`center`},children:[!n&&!t&&W(us,{}),!n&&!t&&!a?.single_env_onboarding&&!i.disableShare&&W(ps,{})]}),!n&&G(K,{sx:{display:`flex`,justifyContent:`right`,alignItems:`center`,mr:`8px`},children:[W(ss,{}),r&&W(gs,{}),W(ds,{})]})]})})};function xs(){let{remainingSeconds:e,isEnabled:t}=N();return!t||e===null||e>60?null:G(Ni,{color:`warning`,variant:`standard`,sx:{display:`flex`,alignItems:`center`,gap:1,fontSize:`0.75rem`,mr:2},children:[W(K,{component:zn,sx:{display:`inline-flex`}}),`Idle timeout: `,It(e,`compact`)]})}const Ss=()=>{let{version:e,latestVersion:t}=T(),n=V(()=>RegExp(`^\\d+\\.\\d+\\.\\d+$`),[]);return xn(()=>{if(n.test(e)&&e!==t){let e=`recce-update-toast-shown`;if(sessionStorage.getItem(e))return;setTimeout(()=>{jt.create({id:`recce-update-available`,title:`Update available`,description:G(`span`,{children:[`A new version of Recce (v`,t,`) is available.`,W(`br`,{}),`Please run`,` `,W(K,{component:`code`,sx:{bgcolor:`grey.200`,px:.5,py:.25,borderRadius:.5,fontFamily:`monospace`,fontSize:`0.875em`},children:`pip install --upgrade recce`}),` `,`to update Recce.`,W(`br`,{}),W(kn,{sx:{color:`primary.main`,fontWeight:`bold`,"&:hover":{textDecoration:`underline`}},href:`https://github.com/DataRecce/recce/releases/tag/v${t}`,target:`_blank`,children:`Click here to view the detail of latest release`})]}),duration:60*1e3,closable:!0}),sessionStorage.setItem(e,`true`)},0)}},[e,t,n]),n.test(e)?W(kn,{href:`https://github.com/DataRecce/recce/releases/tag/v${e}`,sx:{"&:hover":{textDecoration:`none`},fontSize:`sm`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75},target:`_blank`,children:e}):W(Y,{component:`span`,sx:{fontSize:`sm`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75},children:e})};function Cs({icon:e,href:t,sx:n,...r}){let i=Nn();return W(kn,{sx:{height:`20px`,color:`common.white`,...n},href:t,target:`_blank`,...r,children:W(e,{style:{color:i.palette.common.white,width:20,height:20}})})}const ws=()=>{let{reviewMode:e,isDemoSite:t,envInfo:n,cloudMode:r}=M(),{featureToggles:i,authed:a}=I(),{url:o,id:s}=n?.pullRequest??{},c=o?o.split(`/`).pop():null,l=r||a?`https://cloud.datarecce.io/`:`https://reccehq.com/`,[u,d]=H(!1);return G(K,{sx:{display:`flex`,gap:`10px`,minHeight:`40px`,alignItems:`center`,bgcolor:be.brand[400]},children:[W(kn,{href:l,target:`_blank`,sx:{"&:hover":{textDecoration:`none`}},children:G(K,{sx:{display:`flex`,gap:`10px`,alignItems:`center`},children:[W(K,{component:`img`,sx:{width:20,height:20,ml:`18px`},src:`/logo/recce-logo-white.png`,alt:`recce-logo-white`}),W(Y,{variant:`h4`,sx:{fontFamily:`"Montserrat", sans-serif`,color:`common.white`,fontSize:`1.25rem`},children:`RECCE`})]})}),W(is,{}),W(Ss,{}),(i.mode??e)&&W(Ni,{sx:{fontSize:`0.875rem`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75,borderColor:`rgba(255,255,255,0.8)`},children:i.mode??`review mode`}),r&&s&&W(Ni,{sx:{fontSize:`0.875rem`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75,borderColor:`rgba(255,255,255,0.8)`},children:G(J,{direction:`row`,spacing:1,alignItems:`center`,children:[W(K,{children:`cloud mode`}),W(K,{sx:{borderLeft:`1px solid rgba(255,255,255,0.8)`,pl:`8px`},children:G(kn,{href:o,sx:{"&:hover":{textDecoration:`none`}},target:`_blank`,children:[W(Vr,{style:{color:`rgba(255,255,255,0.8)`,width:12,height:12,marginRight:2,display:`inline`,verticalAlign:`middle`}}),W(Y,{component:`span`,sx:{color:`rgba(255,255,255,0.8)`,display:`inline`},children:`#${String(s)}`})]})})]})}),t&&o&&c&&W(Ni,{sx:{fontSize:`0.875rem`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75,borderColor:`rgba(255,255,255,0.8)`},children:G(J,{direction:`row`,spacing:1,alignItems:`center`,children:[W(K,{children:`demo mode`}),W(K,{sx:{borderLeft:`1px solid rgba(255,255,255,0.8)`,pl:`8px`},children:G(kn,{href:o,sx:{"&:hover":{textDecoration:`none`}},target:`_blank`,children:[W(Vr,{style:{color:`rgba(255,255,255,0.8)`,width:12,height:12,marginRight:2,display:`inline`,verticalAlign:`middle`}}),W(Y,{component:`span`,sx:{color:`rgba(255,255,255,0.8)`,display:`inline`},children:`#${c}`})]})})]})}),W(K,{sx:{flex:1}}),(t||i.mode===`read only`)&&G(U,{children:[W(Cs,{icon:Wn,href:`https://github.com/DataRecce/recce`}),W(Cs,{icon:qn,href:`https://getdbt.slack.com/archives/C05C28V7CPP`}),W(Cs,{sx:{mr:2},icon:Gn,href:`https://docs.reccehq.com`})]}),!t&&i.mode!==`read only`&&G(U,{children:[W(xs,{}),a||r?W(K,{sx:{mr:2},children:W(rs,{})}):G(U,{children:[W(K,{component:`button`,sx:{color:`common.white`,fontSize:`0.875rem`,fontWeight:600,bgcolor:`brand.700`,borderRadius:1,px:3,py:1,mr:2,cursor:`pointer`,border:`none`},onClick:()=>{d(!0)},children:`Connect to Cloud`}),u&&W(vt,{parentOpen:u,handleParentClose:d,ignoreCookie:!0,variant:`user-profile`})]})]})]})};function Ts(){return W(K,{sx:{display:`flex`,height:`100%`,alignItems:`center`,justifyContent:`center`,contain:`size`},children:W(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:W(Vn,{size:48})})})}function Es({children:e,lineage:t}){let n=ti(),{isDemoSite:r,isLoading:i,isCodespace:a}=M(),{featureToggles:o}=I(),s=n.replace(/\/$/,``)||`/`,c=s===`/lineage`||s===`/`;return xn(()=>{Zt()},[]),G(K,{sx:{display:`flex`,flexDirection:`column`,height:`100vh`,overflow:`hidden`},children:[W(ws,{}),W(bs,{}),W(Ds,{isLineageRoute:c,lineage:t,children:e}),!i&&!r&&!a&&o.mode===null&&W(vt,{})]})}function Ds({children:e,lineage:t,isLineageRoute:n,disableInternalHistory:r=!1}){let{isRunResultOpen:i,isHistoryOpen:a,closeRunResult:o}=de(),{basePath:s}=ue(),{data:c}=F(),l=ti(),u=Et(),d=i&&!l.startsWith(`${s}/checks`),f=r?!1:a&&!l.startsWith(`${s}/checks`);return G(at,{sizes:f?[20,80]:[0,100],minSize:0,gutterSize:5,className:f?void 0:`split-gutter-hidden`,style:{height:`100%`},children:[W(K,{style:{contain:`size`},suppressHydrationWarning:!0,children:f&&W(Ae,{})}),G(bt,{sizes:d?[50,50]:[100,0],minSize:0,gutterSize:5,className:d?void 0:`split-gutter-hidden`,style:{flex:`1`,contain:`size`},children:[W(gn,{fallback:W(Ts,{}),children:G(K,{sx:{p:0,contain:`content`,height:`100%`,position:`relative`},suppressHydrationWarning:!0,children:[W(K,{sx:{display:n?`block`:`none`,height:`100%`,position:n?`relative`:`absolute`,inset:0},children:t}),!n&&e]})}),W(K,{sx:{height:`100%`,bgcolor:u?`grey.900`:`grey.50`},suppressHydrationWarning:!0,children:d?W(Pe,{onClose:o,isSingleEnvironment:!!c?.single_env_onboarding}):null})]})]})}function Os({children:e,display:t}){let[n,r]=H(!1),i=wn(null),a=wn(null),o=B(()=>{i.current&&=(clearTimeout(i.current),null),r(!0)},[]),s=B(()=>{i.current=setTimeout(()=>{r(!1)},100)},[]);return t?G(U,{children:[W(K,{ref:a,onMouseEnter:o,onMouseLeave:s,sx:{display:`contents`},children:e}),G(Zr,{open:n,anchorEl:a.current,onClose:()=>r(!1),anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},disableAutoFocus:!0,disableEnforceFocus:!0,sx:{pointerEvents:`none`},slotProps:{paper:{onMouseEnter:o,onMouseLeave:s,sx:{bgcolor:`grey.600`,color:`white`,p:1.5,pointerEvents:`auto`}}},children:[`Connect to a data warehouse to unlock Diff.`,` `,W(kn,{href:Vt,target:`_blank`,sx:{color:`white`,textDecoration:`underline`},children:`Learn more`}),`.`]})]}):e}function ks({checksOnly:e=!0}){let t=Et(),{featureToggles:n}=I(),r=pn(),{apiClient:i}=Oe(),a=wn(null),o=wn(null),[s,c]=H(null),[l,u]=H(!1),d=ni(),f=ti(),{basePath:m}=ue(),[,h]=_e(),g=B(async()=>{if(s){try{let{runs:t,checks:n}=await p(s,e,i);h?.(),await r.invalidateQueries({queryKey:A.checks()}),await r.invalidateQueries({queryKey:A.runs()}),f.includes(`/checks`)&&d.push(`${m}/checks`);let a=e?`${n} checks imported successfully`:`${t} runs and ${n} checks imported successfully`;jt.create({description:a,type:`info`,duration:5e3,closable:!0})}catch(e){console.error(`Import failed`,e),jt.create({title:`Import failed`,description:String(e),type:`error`,duration:5e3,closable:!0})}u(!1)}},[r,s,f,h,e,i,d.push,m]),_=()=>{a.current&&a.current.click()},v=e=>{e.target.files?.length===1&&(c(e.target.files[0]),u(!0)),a.current&&(a.current.value=``)},y=()=>u(!1),b=e?`checks`:`runs and checks`,{isDemoSite:x}=M();return G(U,{children:[W(Z,{title:`Import Checklist from State File`+(x?` (Disabled in the demo site)`:``),children:W(X,{sx:{pt:`6px`,color:t?`grey.300`:`grey.600`,"&:hover":{color:t?`grey.100`:`grey.800`},fontSize:20},"aria-label":`Import state`,onClick:()=>{_(),sn({name:`import`})},disabled:n.disableImportStateFile||x,children:W(bi,{})})}),W(`input`,{type:`file`,style:{display:`none`},ref:a,onChange:v}),G(Tn,{open:l,onClose:y,maxWidth:`sm`,fullWidth:!0,"aria-labelledby":`import-dialog-title`,children:[G(On,{id:`import-dialog-title`,sx:{display:`flex`,alignItems:`center`,fontWeight:`bold`},children:[`Import state`,W(K,{sx:{flexGrow:1}}),W(X,{size:`small`,onClick:y,children:W(Ln,{})})]}),W(Dn,{children:G(J,{direction:`column`,spacing:1,sx:{px:`5px`,borderRadius:1},children:[G(J,{direction:`row`,alignItems:`center`,spacing:.5,children:[W(K,{component:nr,sx:{color:`error.main`}}),W(Y,{component:`span`,sx:{fontWeight:500,color:`error.main`},children:`Caution!`})]}),G(Y,{children:[`The current `,b,` will be`,` `,W(Y,{component:`span`,sx:{fontWeight:600},children:`merged`}),` `,`with the imported state`]})]})}),G(En,{children:[W(q,{ref:o,onClick:y,children:`Cancel`}),W(q,{color:`iochmara`,variant:`contained`,onClick:g,sx:{ml:`5px`},children:`Import`})]})]})]})}function As({check:e},t){return W(K,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:W(wr,{children:W(ts,{viewOptions:{...e.params,...e.view_options},interactive:!1,ref:t})})})}const js=vn(As),Ms=({node:e,selected:t,onSelect:n,schemaChanged:r,isDark:i})=>{let{icon:a}=tt(e.data.resourceType),{base:o,current:s}=e.data.data,c,l;return r?(c=z(`schema_diff`).icon,l=nt(`modified`).color):!o&&s?(c=nt(`added`).icon,l=nt(`added`).color):o&&!s&&(c=nt(`removed`).icon,l=nt(`removed`).color),W(Yr,{disablePadding:!0,children:G(K,{sx:{display:`flex`,width:`100%`,fontSize:`10pt`,p:`5px 8px`,cursor:`pointer`,"&:hover":{bgcolor:i?`grey.700`:`grey.200`},bgcolor:t?i?`grey.800`:`grey.100`:`inherit`,alignItems:`center`,gap:`5px`},onClick:()=>{n(e.id)},children:[a&&W(K,{component:a}),W(K,{sx:{flex:1,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`},children:e.data.name}),c&&l&&W(K,{component:c,sx:{color:l}})]})})};function Ns({check:e},t){let n=Et(),{apiClient:r}=Oe(),{lineageGraph:i}=M(),a=e.params,{isLoading:o,error:s,data:c}=fn({queryKey:[...A.check(e.check_id),`select`],queryFn:async()=>C({select:a.select,exclude:a.exclude,packages:a.packages,view_mode:a.view_mode},r),refetchOnMount:!0,enabled:!a.node_id}),[l,u]=V(()=>{let e=[],t=[],n=[],r=[];if(a.node_id){let t=a.node_id instanceof Array?a.node_id:[a.node_id];for(let n of t){let t=i?.nodes[n];t&&e.push(t)}}else for(let t of c?.nodes??[]){let n=i?.nodes[t];n&&e.push(n)}let o=e.filter(e=>e.data.resourceType===`model`||e.data.resourceType===`seed`||e.data.resourceType===`source`||e.data.resourceType===`snapshot`);for(let e of o)Pt(e.data.data.base?.columns,e.data.data.current?.columns)?t.push(e.id):!e.data.data.base&&e.data.data.current?n.push(e.id):e.data.data.base&&!e.data.data.current&&r.push(e.id);function s(e){return t.includes(e.id)?3:n.includes(e.id)?2:r.includes(e.id)?1:0}return o.sort((e,t)=>{let n=s(e),r=s(t);return n===r?e.data.name.localeCompare(t.data.name):r-n}),[o,t]},[a.node_id,c?.nodes,i]),[d,f]=H(0);if(o)return W(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:n?`grey.900`:`grey.50`,height:`100%`},children:`Loading...`});if(s)return G(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:n?`grey.900`:`grey.50`,height:`100%`},className:`no-track-pii-safe`,children:[`Error: `,s.message]});if(l.length==0)return W(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:n?`grey.900`:`grey.50`,height:`100%`},children:`No nodes matched`});if(d<l.length){let e=l[d];return G(at,{sizes:[80,20],minSize:30,style:{height:`100%`},children:[W(io,{base:e.data.data.base,current:e.data.data.current,columnChanges:e.data.change?.columns,enableScreenshot:!0,showMenu:!1,ref:t}),W(Jr,{sx:{overflow:`auto`,bgcolor:`background.paper`,listStyle:`none`},children:l.map((e,t)=>W(Ms,{node:e,schemaChanged:u.includes(e.id),selected:t===d,isDark:n,onSelect:()=>{f(t)}},e.id))})]})}return W(U,{})}const Ps=vn(Ns);function Fs({checkId:r,refreshCheckList:a}){let s=Nn(),l=Et(),{apiClient:u}=Oe(),{featureToggles:d,sessionId:f}=I(),{setLatestSelectedCheckId:p}=Ct(),{cloudMode:m}=M(),h=pn(),g=ni(),{basePath:_}=ue(),{setSqlQuery:v,setBaseSqlQuery:y,setCustomQueries:b,setPrimaryKeys:x}=Ie(),{successToast:S,failToast:C}=At(),[w,T]=H(),[E]=H(),[D,O]=H(!1),[k,ee]=H(!1),[te,ne]=H(null),re=!!te,{isLoading:ie,error:ae,data:j}=fn({queryKey:A.check(r),queryFn:async()=>c(r,u),refetchOnMount:!0}),oe=w??j?.last_run?.run_id,{run:N,error:se}=ht(oe),ce=w?!N||N.status===`Running`:N?.status===`Running`,P=j?.type?z(j.type):void 0,le;P&&(le=P.RunResultView);let de=j?.is_preset??!1,fe=wn(null),{mutate:pe}=dn({mutationFn:e=>o(r,e,u),onSuccess:async()=>{await h.invalidateQueries({queryKey:A.check(r)}),await h.invalidateQueries({queryKey:A.checks()})}}),{mutate:me}=dn({mutationFn:()=>n(r,u),onSuccess:async()=>{p(``),await h.invalidateQueries({queryKey:A.checks()}),g.push(`${_}/checks`)}}),{mutate:he,isPending:ge}=dn({mutationFn:async()=>{if(!j)throw Error(`Check not found`);return await t(r,u)},onSuccess:async()=>{S(`Check marked as preset successfully`),await h.invalidateQueries({queryKey:A.check(r)})},onError:e=>{C(`Failed to mark check as preset`,e)}}),F=B(async()=>{j?.type&&(T((await e(r,{nowait:!0},u)).run_id),await h.invalidateQueries({queryKey:A.check(r)}),a&&a())},[j,r,h,a,u]),_e=B(async()=>{if(O(!0),oe)return await i(oe,u)},[oe,u]),ve=async()=>{if(!j)return;let e=Is(j);if(!window.isSecureContext){C(`Failed to copy the check to clipboard`,Error(`Copy to clipboard is available only in secure contexts (HTTPS)`));return}try{await navigator.clipboard.writeText(e),S(`Copied the check to the clipboard`)}catch(e){C(`Failed to copy the check to clipboard`,e)}},ye=B(()=>{let e=j?.is_checked;pe({is_checked:!e}),e||jt.create({title:`Marked as approved`,type:`success`,duration:2e3})},[j?.is_checked,pe]),be=e=>{pe({view_options:e})},xe=e=>{pe({description:e})},Ce=e=>{ne(e.currentTarget)},we=()=>{ne(null)},Ee=B(()=>{if(!j)return;let e=j.params;v(e?.sql_template||``),`base_sql_template`in e&&e.base_sql_template?(y(e.base_sql_template),b(!0)):(y(``),b(!1)),`primary_keys`in e&&e.primary_keys?x(e.primary_keys):x(void 0),g.push(`${_}/query`)},[j,g,_,v,y,b,x]),[De,ke]=H(`result`),{ref:Ae,onCopyToClipboard:je,onMouseEnter:Me,onMouseLeave:Ne}=ot(),Pe=Ve({name:j?.name??``,description:j?.description??``,type:j?.type??``,params:j?.params,viewOptions:j?.view_options});if(ie)return W(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:`Loading`});if(ae)return G(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:[`Error: `,W(`span`,{className:`no-track-pii-safe`,children:ae.message})]});if(!j)return W(bt,{minSize:100,sizes:[30,70],style:{height:`100%`,width:`100%`,maxHeight:`100%`},children:W(K,{style:{contain:`strict`},sx:{display:`flex`,flexDirection:`column`},children:W(K,{sx:{display:`flex`,p:`0px 16px`,alignItems:`center`,height:40},children:W(Qe,{name:`Check not found`,disabled:!0})})})});let L=N?.run_at?$r(new Date(N.run_at),{addSuffix:!0}):null,Le=P?.icon;return G(Pi,{spacing:0,container:!0,sx:{height:`100%`,width:`100%`},children:[W(Pi,{size:{xs:12,md:m?9:12},sx:{height:`100%`},children:G(bt,{minSize:100,sizes:[40,60],style:{height:`100%`,width:`100%`,maxHeight:`100%`},children:[W(K,{sx:{height:`100%`,contain:`strict`,display:`flex`,flexDirection:`row`},children:G(K,{sx:{flex:1,height:`100%`,display:`flex`,flexDirection:`column`,overflow:`hidden`,minWidth:0},children:[G(K,{sx:{display:`flex`,p:`0px 16px`,alignItems:`center`,height:40,borderBottom:`2px solid`,borderColor:l?`grey.700`:`grey.300`},children:[Le&&W(K,{component:Le,sx:{fontSize:20,mr:1,flexShrink:0}}),W(Qe,{name:j.name,onNameChange:e=>{pe({name:e})}}),W(K,{sx:{flexGrow:1}}),G(J,{direction:`row`,spacing:2,sx:{mr:`10px`},children:[L&&W(K,{sx:{textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,fontSize:`0.75rem`,display:`flex`,alignItems:`center`},children:L}),de&&W(Z,{title:`This is a preset check`,children:W(K,{display:`flex`,alignItems:`center`,justifyContent:`center`,children:W(yi,{size:`1rem`,color:s.palette.iochmara.dark})})}),W(X,{size:`small`,onClick:Ce,children:W(Ur,{})}),G(Lr,{anchorEl:te,open:re,onClose:we,children:[f&&G(Q,{onClick:()=>{he(),we()},disabled:ge||de,children:[W(si,{children:W(In,{})}),W(ci,{children:`Mark as Preset Check`})]}),G(Q,{onClick:()=>{ee(!0),we()},children:[W(si,{children:W(Ii,{})}),W(ci,{children:`Get Preset Check Template`})]}),G(Q,{onClick:()=>{ve(),we()},children:[W(si,{children:W(er,{})}),W(ci,{children:`Copy Markdown`})]}),W(Bn,{}),G(Q,{onClick:()=>{me(),we()},disabled:d.disableUpdateChecklist,sx:{color:`error.main`},children:[W(si,{sx:{color:`error.main`},children:W(dr,{})}),W(ci,{children:`Delete`})]})]}),W(Z,{title:Fe({type:j.type,hasResult:!!N?.result,hasError:!!N?.error})?`Run the check first`:j.is_checked?`Remove approval`:`Mark as approved`,placement:`bottom-end`,children:W(q,{size:`small`,color:j.is_checked?`success`:`neutral`,variant:j.is_checked?`contained`:`outlined`,onClick:()=>{ye()},disabled:Fe({type:j.type,hasResult:!!N?.result,hasError:!!N?.error})||d.disableUpdateChecklist,startIcon:j.is_checked?W(Qn,{}):W(zr,{style:{color:l?s.palette.grey[600]:s.palette.grey[400]}}),sx:{flex:`0 0 auto`,textTransform:`none`},children:j.is_checked?`Approved`:`Pending`})})]})]}),W(K,{sx:{flex:1,p:`8px 16px`,minHeight:100},children:W(R,{value:j.description,onChange:xe,disabled:d.disableUpdateChecklist},j.check_id)})]})}),W(K,{style:{contain:`strict`},children:G(K,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[G(K,{sx:{display:`flex`,alignItems:`center`,borderBottom:1,borderColor:`divider`,height:50},children:[G(qr,{value:De,onChange:(e,t)=>ke(t),children:[W(Kr,{label:`Result`,value:`result`,sx:{fontSize:`0.75rem`,textTransform:`none`}}),(j.type===`query`||j.type===`query_diff`)&&W(Kr,{label:`Query`,value:`query`,sx:{fontSize:`0.75rem`,textTransform:`none`}})]}),W(K,{sx:{flexGrow:1}}),G(J,{direction:`row`,spacing:1,sx:{mr:`10px`},children:[(j.type===`query`||j.type===`query_base`||j.type===`query_diff`)&&W(Z,{title:`Open in Query tab`,children:W(q,{variant:`outlined`,color:`neutral`,size:`small`,onClick:Ee,disabled:d.disableDatabaseQuery,startIcon:W(oi,{}),sx:{textTransform:`none`},children:`Open Query`})}),le&&W(Z,{title:`Rerun`,children:W(q,{variant:`outlined`,color:`neutral`,size:`small`,onClick:()=>F(),disabled:d.disableDatabaseQuery||ce,startIcon:W(lr,{}),sx:{textTransform:`none`},children:ce?`Running...`:`Rerun`})}),W(q,{variant:`outlined`,color:`neutral`,disabled:Fe({type:j.type,hasResult:!!N?.result,hasError:!!N?.error})||De!==`result`,onMouseEnter:Me,onMouseLeave:Ne,size:`small`,onClick:async()=>{j.type===`lineage_diff`?fe.current?.copyToClipboard():await je(),Kt({type:j.type,from:`check`})},startIcon:W(er,{}),sx:{textTransform:`none`},children:`Copy to Clipboard`})]})]}),G(K,{sx:{flex:1,contain:`strict`},children:[De===`result`&&G(K,{sx:{width:`100%`,height:`100%`},children:[le&&(j.last_run||oe?W(Te,{ref:Ae,isRunning:ce,isAborting:D,run:oe?N:j.last_run,error:se,progress:E,RunResultView:le,viewOptions:j.view_options,onViewOptionsChanged:be,onCancel:_e,onExecuteRun:F}):W(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:l?`grey.900`:`grey.50`,height:`100%`},children:G(J,{spacing:2,alignItems:`center`,children:[W(K,{children:`This action is part of the initial preset and has not been performed yet. Once performed, the result will be shown here.`}),W(Os,{display:d.mode===`metadata only`,children:W(q,{onClick:F,variant:`contained`,size:`small`,disabled:d.disableDatabaseQuery,children:`Run Query`})})]})})),j.type===`schema_diff`&&W(Ps,{check:j,ref:Ae},j.check_id),j.type===`lineage_diff`&&W(js,{check:j,ref:fe},j.check_id)]}),De===`query`&&(j.type===`query`||j.type===`query_diff`||j.type===`query_base`)&&W(K,{sx:{height:`100%`,width:`100%`},children:j.params.base_sql_template?W(it,{value:j.params.sql_template||``,baseValue:j.params.base_sql_template??``,options:{readOnly:!0}}):W(Se,{value:j.params.sql_template||``,options:{readOnly:!0}})})]})]})}),G(Tn,{open:k,onClose:()=>ee(!1),maxWidth:`md`,fullWidth:!0,children:[W(On,{children:`Preset Check Template`}),G(Dn,{children:[G(Y,{variant:`subtitle2`,fontWeight:`bold`,sx:{mb:2},children:[`Please`,` `,W(Y,{component:`span`,sx:{cursor:`pointer`,"&:hover":{textDecoration:`underline`},color:`primary.main`},onClick:async()=>{await navigator.clipboard.writeText(Pe),S(`Copied the template to the clipboard`)},children:`copy`}),` `,`the following template and paste it into the`,` `,W(K,{component:`span`,sx:{px:.5,bgcolor:`error.light`,borderRadius:.5},children:`recce.yml`}),` `,`file.`]}),W(ze,{yamlTemplate:Pe})]}),W(En,{children:W(X,{size:`small`,onClick:()=>ee(!1),sx:{position:`absolute`,top:8,right:8},children:W(Ln,{})})})]})]})}),m&&W(Pi,{size:3,sx:{height:`100%`,overflow:`hidden`,flexShrink:0,display:{xs:`none`,md:`block`}},children:W(va,{checkId:r})})]})}function Is(e){return Fi`
|
|
5
|
+
`)}\nfrom {{ ref("${k.name}") }}`;g?.(e),u(`query_diff_with_primary_key`)&&_?.(A===void 0?void 0:[A]),p?.(`/query`)}})}}let r=D?`row_count`:`row_count_diff`,a=h?.(r);a&&d.push({label:a.title,itemIcon:W(K,{component:a.icon,sx:{display:`inline-flex`}}),isDisabled:O,action:()=>{m?.(`explore_action`,{action:D?Na.ROW_COUNT:Na.ROW_COUNT_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),f?.(r,{node_names:[k.name]},{showForm:!1,trackProps:ne})}});let o=D?`profile`:`profile_diff`,s=h?.(o);if(s&&d.push({label:s.title,itemIcon:W(K,{component:s.icon,sx:{display:`inline-flex`}}),isDisabled:O,action:()=>{let e=E?Array.from(E(i.id)):[];m?.(`explore_action`,{action:D?Na.PROFILE:Na.PROFILE_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),f?.(o,{model:k.name,columns:e},{showForm:!0,trackProps:ne})}}),!D){let e=h?.(`value_diff`);e&&d.push({label:e.title,itemIcon:W(K,{component:e.icon,sx:{display:`inline-flex`}}),isDisabled:O,action:()=>{let e=E?Array.from(E(i.id)):[];m?.(`explore_action`,{action:Na.VALUE_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),f?.(`value_diff`,{model:k.name,columns:e},{showForm:!0,trackProps:ne})}})}}return D||(d.length>0&&d.push({label:`select group two`,isSeparator:!0}),d.push({label:`Select Parent Nodes`,itemIcon:W(xi,{}),action:()=>{m?.(`lineage_selection`,{action:Fa.SELECT_PARENT_NODES}),w?.(i.id,1)}}),d.push({label:`Select Child Nodes`,itemIcon:W(Si,{}),action:()=>{m?.(`lineage_selection`,{action:Fa.SELECT_CHILD_NODES}),T?.(i.id,1)}}),d.push({label:`Select All Upstream Nodes`,itemIcon:W(xi,{}),action:()=>{m?.(`lineage_selection`,{action:Fa.SELECT_ALL_UPSTREAM}),w?.(i.id)}}),d.push({label:`Select All Downstream Nodes`,itemIcon:W(Si,{}),action:()=>{m?.(`lineage_selection`,{action:Fa.SELECT_ALL_DOWNSTREAM}),T?.(i.id)}})),W(Ia,{x:n,y:r,menuItems:d,open:e,onClose:t,featureToggles:s,DisabledItemWrapper:y})},Ra=({isOpen:e,onClose:t,x:n,y:r,node:i,deps:a={},featureToggles:o={},serverFlags:s={},isActionAvailable:c=()=>!0})=>{let l=[],{runAction:u,onTrack:d,findByRunType:f,supportsHistogramDiff:p,DisabledItemWrapper:m}=a,h=s.single_env_onboarding??!1,g=o.disableDatabaseQuery??!1;if(i?.data===void 0)return W(U,{});let _=i.data,v=_.node,y=_.column,b=_.type,x={source:`lineage_column_node`},S=()=>{d?.(`explore_action`,{action:Na.PROFILE_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),u?.(`profile_diff`,{model:v.name,columns:[y]},{showForm:!1,trackProps:x})},C=()=>{d?.(`explore_action`,{action:Na.HISTOGRAM_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),u?.(`histogram_diff`,{model:v.name,column_name:y,column_type:b},{showForm:!1,trackProps:x})},w=()=>{d?.(`explore_action`,{action:Na.TOP_K_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),u?.(`top_k_diff`,{model:v.name,column_name:y,k:50},{showForm:!1,trackProps:x})},T=()=>{d?.(`explore_action`,{action:Na.VALUE_DIFF,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:1}),u?.(`value_diff`,{model:v.name,columns:[y]},{showForm:!0,trackProps:x})},E=v.data.base?.columns?.[y]===void 0||v.data.current?.columns?.[y]===void 0,D=f?.(h?`profile`:`profile_diff`);if(D&&l.push({label:D.title,itemIcon:W(K,{component:D.icon,sx:{display:`inline-flex`}}),action:S,isDisabled:E||!c(`profile_diff`)||g}),!h){let e=f?.(`histogram_diff`);if(e){let t=p?.(b)??!0;l.push({label:e.title,itemIcon:W(K,{component:e.icon,sx:{display:`inline-flex`}}),action:C,isDisabled:E||!t||g})}let t=f?.(`top_k_diff`);t&&l.push({label:t.title,itemIcon:W(K,{component:t.icon,sx:{display:`inline-flex`}}),action:w,isDisabled:E||g});let n=f?.(`value_diff`);n&&l.push({label:n.title,itemIcon:W(K,{component:n.icon,sx:{display:`inline-flex`}}),action:T,isDisabled:E||g})}return W(Ia,{x:n,y:r,menuItems:l,open:e,onClose:t,featureToggles:o,DisabledItemWrapper:m})},za=({isOpen:e,onClose:t,x:n,y:r,node:i,deps:a={},viewOptions:o={},featureToggles:s={},serverFlags:c={},noCatalogCurrent:l=!1,isActionAvailable:u=()=>!0})=>s.disableViewActionDropdown?W(Ia,{menuItems:[],open:e,onClose:t,x:n,y:r,featureToggles:s,DisabledItemWrapper:a.DisabledItemWrapper}):i&&ce(i)?W(La,{x:n,y:r,isOpen:e,onClose:t,node:i,deps:a,viewOptions:o,featureToggles:s,serverFlags:c,noCatalogCurrent:l,isActionAvailable:u}):i&&se(i)?W(Ra,{x:n,y:r,isOpen:e,onClose:t,node:i,deps:a,featureToggles:s,serverFlags:c,isActionAvailable:u}):null,Ba=()=>{let[e,t]=H(!1),n=()=>t(!0),r=()=>t(!1),[i,a]=H({x:0,y:0}),[o,s]=H();return{props:{x:i.x,y:i.y,node:o,isOpen:e,onClose:r},showContextMenu:(e,t,r)=>{a({x:e,y:t}),s(r),n()},closeContextMenu:()=>{a({x:0,y:0}),s(void 0),r()}}},Va=()=>{let{isDark:e}=ct(),{successToast:t,failToast:n}=At();return ft({renderLibrary:`html-to-image`,imageType:`png`,shadowEffect:!0,backgroundColor:e?be.neutral[900]:be.neutral[50],ignoreElements:e=>{try{return e.classList.contains($e)}catch{return e.className?e.className.includes($e):!1}},onSuccess:()=>{t(`Copied the Lineage View as an image to clipboard`)},onError:e=>{console.error(`Error taking screenshot`,e),n(`Failed to copy image to clipboard`,e)}})},Ha=()=>{let e=ni(),{basePath:t}=ue();return B(n=>{n.check_id&&e.push(`${t}/checks/?id=${n.check_id}`)},[e.push,t])},Ua=(e,t)=>{let n=wn({width:0,height:0});xn(()=>{let r=e.current,i=new ResizeObserver(e=>{for(let r of e){let e=r.contentRect.width,i=r.contentRect.height;(Math.abs(i-n.current.height)>10||Math.abs(e-n.current.width)>10)&&n.current.height>0&&i>0&&n.current.width>0&&e>0&&t(),n.current={width:e,height:i}}});return r&&i.observe(r),()=>{r&&i.unobserve(r)}},[t,e])},Wa=()=>B((e,t,n,r,i)=>{let a=e.filter(ce),o=Object.groupBy(a,e=>e.data.changeStatus??`unchanged`),s=Object.fromEntries(Object.entries(o).map(([e,t])=>[`nodes_${e}`,t?.length??0])),c={node_count:a.length,view_mode:t,impact_radius_enabled:n,right_sidebar_open:i,...s};r&&(c.cll_column_active=!0),$t(c)},[]),Ga={row_count:Ht.ROW_COUNT,row_count_diff:Ht.ROW_COUNT_DIFF,value_diff:Ht.VALUE_DIFF},Ka=e=>{let t=Ga[e.action];t&&Jt({action:t,source:Wt.LINEAGE_VIEW_TOP_BAR,node_count:e.node_count})},qa=(e,t)=>Le(e,{...t,onTrackAction:Ka,trackingSource:Wt.LINEAGE_VIEW_TOP_BAR});function Ja(){return St({onConfirm:()=>Yt({action:Ht.VALUE_DIFF,event:Ut.EXECUTE}),onCancel:()=>Yt({action:Ht.VALUE_DIFF,event:Ut.CANCEL})})}function Ya({notification:e,type:t}){let n=D.lineageNotificationDismissed,[r,i]=H(()=>sessionStorage.getItem(n)!==`true`);if(e===null||!r)return null;let a={info:`iochmara.light`,success:`success.light`,warning:`warning.light`,error:`error.light`}[t];return G(K,{sx:{width:`100%`,display:`flex`,flexDirection:`row`,p:`5px 10px`,gap:`5px`,alignItems:`flex-start`,borderRadius:1,boxShadow:4,border:`1px solid`,borderColor:`neutral.light`,bgcolor:a},children:[e,W(K,{sx:{flex:1}}),W(X,{size:`small`,onClick:()=>{sessionStorage.setItem(n,`true`),i(!1)},children:W(Ln,{})})]})}const Xa=e=>{let{runAction:t}=de(),{setSqlQuery:n,setPrimaryKeys:r}=Ie(),i=ni(),{primaryKey:a}=ut(e),{basePath:o}=ue();return{runAction:(e,n,r)=>{t(e,n,r)},onNavigate:e=>{i.push(`${o}${e}`)},onTrack:(e,t)=>{e===`explore_action`?Jt({action:t.action,source:Pa.LINEAGE_VIEW_CONTEXT_MENU,node_count:t.node_count}):e===`lineage_selection`&&Qt({action:t.action})},supportsHistogramDiff:Ke,findByRunType:e=>{let t=z(e);return t?{title:t.title,icon:t.icon}:void 0},setSqlQuery:n,setPrimaryKeys:r,getPrimaryKey:()=>a,DisabledItemWrapper:ks}},Za=({isOpen:e,onClose:t,x:n,y:r,node:i})=>{let{selectParentNodes:a,selectChildNodes:o,getNodeColumnSet:s,selectMode:c,cll:l,showColumnLevelLineage:u,setChangeAnalysisMode:d}=le(),{featureToggles:f}=I(),{isActionAvailable:p,lineageGraph:m}=M(),{data:h}=F(),g=!m?.catalogMetadata.current;return W(za,{x:n,y:r,node:i,isOpen:e,onClose:t,deps:Xa(i?.type===`lineageGraphNode`?i.data?.name:i?.type===`lineageGraphColumnNode`?i.data?.node?.name:void 0),viewOptions:{selectMode:c,cll:l,showColumnLevelLineage:u,setChangeAnalysisMode:d,selectParentNodes:a,selectChildNodes:o,getNodeColumnSet:s},featureToggles:{disableDatabaseQuery:f.disableDatabaseQuery,disableViewActionDropdown:f.disableViewActionDropdown,mode:f.mode??void 0},serverFlags:{single_env_onboarding:h?.single_env_onboarding},noCatalogCurrent:g,isActionAvailable:p})},Qa=Ba;function $a(e,t){let n=[],r=[],{selectedNodes:i,cll:a,existingPositions:o}=t??{},s={};function c(e){return e===`base`?0:e===`current`?2:1}function l(e,t){let n=c(e.data?.from),r=c(t.data?.from);return n<r?-1:n>r?1:0}let u=i===void 0?void 0:new Set(i),d=Object.values(e.nodes).sort(l);for(let e of d){if(u&&!u.has(e.id))continue;let t=new Set,i=0;if(a){let o=a.current?.parent_map[e.id]??new Set;for(let t of o){let n=t,i=e.id;r.push({id:`m2c_${n}_${i}`,source:n,target:i,style:{zIndex:9999}})}for(let o of Object.keys(e.data.data.current?.columns??{})){let s=`${e.id}_${o}`,c=a.current,l=c?.columns[s],u=c?.parent_map[s]??new Set;if(l!=null){n.push({id:s,position:{x:10,y:70+i*24},parentId:e.id,extent:`parent`,draggable:!1,className:`no-track-pii-safe`,data:{node:e.data,column:l.name,type:l.type,transformationType:l.transformation_type,changeStatus:l.change_status},style:{zIndex:9999},type:`lineageGraphColumnNode`,targetPosition:Sr.Left,sourcePosition:Sr.Right});for(let e of u){let t=e,n=s;r.push({id:`${t}_${n}`,source:t,target:n,style:{zIndex:9999}})}i++,t.add(l.name)}}}s[e.id]=t;let c=60;i>0&&(c+=20+i*24);let l=o?.get(e.id);n.unshift({id:e.id,position:l??{x:0,y:0},width:300,height:c,className:`no-track-pii-safe`,data:{...e.data},type:`lineageGraphNode`,targetPosition:Sr.Left,sourcePosition:Sr.Right,style:{width:300,height:c}})}let f=Object.values(e.edges).sort(l);for(let e of f)u&&(!u.has(e.source)||!u.has(e.target))||r.push({id:e.id,type:`lineageGraphEdge`,source:e.source,target:e.target,data:{...e.data}});return n.some(e=>e.type===`lineageGraphNode`&&!o?.has(e.id))&&eo(n,r),[n,r,s]}const eo=(e,t,n=`LR`)=>{oe(Ci,e,t,n)};function to(){return G(K,{sx:{display:`flex`,gap:2,px:1,py:.5,fontSize:`0.75rem`,color:`text.secondary`},children:[G(`span`,{children:[W(`span`,{className:`schema-change-badge schema-change-badge-added`,children:`+`}),` `,`added`]}),G(`span`,{children:[W(`span`,{className:`schema-change-badge schema-change-badge-removed`,children:`-`}),` `,`removed`]}),G(`span`,{children:[W(`span`,{className:`schema-change-badge schema-change-badge-changed`,children:`~`}),` `,`changed`]})]})}function no({current:e,showMenu:t=!0},n){let r=pe(),[i,a]=H(null),[o,s]=H(new Map),{columns:c,rows:l}=V(()=>yt({type:`schema_single`,columns:e?.columns},{node:e,cllRunningMap:o,showMenu:t}),[e,o,t]),{lineageGraph:u,isActionAvailable:d}=M(),f=d(`change_analysis`),p=!u?.catalogMetadata.current,m;p&&(m="catalog.json not found. Run `recce debug` to troubleshoot.");let h=e&&e.columns===void 0,g;h&&(g=`Node schema not found in catalog.json. Please regenerate your catalog.json to update.`);let _=async t=>{if(!f)return;Gt({action:`view`,source:`schema_column`}),s(e=>new Map(e).set(t,!0));let n=e?.id;n&&await r?.showColumnLevelLineage({node_id:n,column:t}),s(e=>new Map(e).set(t,!1))},v=B(t=>`${e?.id}-${t.data.name}`,[e?.id]),y=r?.viewOptions.column_level_lineage,b=y?`${y.node_id}-${y.column}`:null;xn(()=>{if(i&&(i.deselectAll(),b)){let e=i.getRowNode(b);e&&e.setSelected(!0)}},[i,b]);let x=B(e=>{a(e.api)},[]);return G(K,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[m?W(Ir,{severity:`warning`,sx:{fontSize:`12px`,p:1},children:m}):g?W(Ir,{severity:`warning`,sx:{fontSize:`12px`,p:1},children:g}):W(U,{}),l.length>0&&W(qe,{style:{blockSize:`auto`,maxHeight:`100%`,overflow:`auto`,fontSize:`10pt`,borderWidth:1},columns:c,rows:l,renderers:{noRowsFallback:W(Tt,{})},ref:n,getRowId:v,getRowClass:e=>r!==void 0&&f?`row-normal row-selectable`:`row-normal`,onCellClicked:async e=>{if((e.event?.target)?.closest(`.row-context-menu`))return;let t=e.data;t&&await _(t.name)},onGridReady:x,rowSelection:{mode:`singleRow`,checkboxes:!1},containerClassName:`no-track-pii-safe`,rowClassName:`no-track-pii-safe`})]})}function ro({base:e,current:t,showMenu:n=!0,columnChanges:r,onViewCode:i},a){let o=pe(),[s,c]=H(null),[l,u]=H(new Map),{columns:d,rows:f}=V(()=>{let a=t?.resource_type??e?.resource_type,o=a&&[`model`,`seed`,`snapshot`,`source`].includes(a)?t??e:void 0;return yt({type:`schema_diff`,base:e?.columns,current:t?.columns},{node:o,cllRunningMap:l,showMenu:n,columnChanges:r,onViewCode:i})},[e,t,l,n,r,i]),{lineageGraph:p,isActionAvailable:m}=M(),h=m(`change_analysis`),g=!p?.catalogMetadata.base,_=!p?.catalogMetadata.current,v;g&&_?v="catalog.json not found on both environments. Run `recce debug` to troubleshoot.":g?v="catalog.json not found on base environment. Run `recce debug` to troubleshoot.":_&&(v="catalog.json not found on current environment. Run `recce debug` to troubleshoot.");let y=e&&e.columns===void 0,b=t&&t.columns===void 0,x;y&&b?x=`Node schema not found in catalog.json on both environments. Please regenerate your catalog.json to update.`:b?x=`Node schema not found in catalog.json on current environment. Please regenerate your catalog.json to update.`:y&&(x=`Node schema not found in catalog.json on base environment. Please regenerate your catalog.json to update.`);let S=async n=>{if(!h)return;Gt({action:`view`,source:`schema_column`}),u(e=>new Map(e).set(n,!0));let r=t?.id??e?.id;r&&await o?.showColumnLevelLineage({node_id:r,column:n}),u(e=>new Map(e).set(n,!1))},C=B(n=>`${t?.id??e?.id}-${n.data.name}`,[t?.id,e?.id]),w=o?.viewOptions.column_level_lineage,T=w?`${w.node_id}-${w.column}`:null;xn(()=>{if(s&&(s.deselectAll(),T)){let e=s.getRowNode(T);e&&e.setSelected(!0)}},[s,T]);let E=B(e=>{c(e.api)},[]);return G(K,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:[v?W(Ir,{severity:`warning`,sx:{fontSize:`12px`,p:1},children:v}):x?W(Ir,{severity:`warning`,sx:{fontSize:`12px`,p:1},children:x}):W(U,{}),W(to,{}),f.length>0&&W(qe,{style:{blockSize:`auto`,maxHeight:`100%`,overflow:`auto`,fontSize:`0.8rem`,borderWidth:1},columns:d,rows:f,rowHeight:35,renderers:{noRowsFallback:W(Tt,{})},className:`rdg-light no-track-pii-safe`,ref:a,getRowId:C,getRowClass:e=>{let t=e.data;if(!t)return`row-normal`;let n;if(t.baseIndex===void 0)n=`row-added`;else if(t.currentIndex===void 0)return`row-removed`;else n=t.baseType!==t.currentType||t.reordered===!0||t.definitionChanged===!0?`row-changed`:`row-normal`;return o!==void 0&&h&&(n+=` row-selectable`),n},onCellClicked:async e=>{if((e.event?.target)?.closest(`.row-context-menu`))return;let t=e.data;t&&(t.baseIndex!==void 0&&t.currentIndex===void 0||await S(t.name))},onGridReady:E,rowSelection:{mode:`singleRow`,checkboxes:!1},containerClassName:`no-track-pii-safe`,rowClassName:`no-track-pii-safe`})]})}const io=vn(ro),ao=vn(no),oo=({node:e,isSingleEnv:t,CodeEditor:n,DiffEditor:r,isDark:i=!1})=>{let[a,o]=H(!1),[s,c]=H(!1);if(e.data.resourceType!==`model`&&e.data.resourceType!==`snapshot`)return`Not available`;let l=e.data.data.base?.raw_code,u=e.data.data.current?.raw_code,d=e.data.data.base?.name??e.data.data.current?.name??``;return G(K,{className:`no-track-pii-safe`,sx:{position:`relative`,height:`100%`},onMouseEnter:()=>{c(!0)},onMouseLeave:()=>{c(!1)},children:[t?W(n,{language:`sql`,value:l??``,readOnly:!0,lineNumbers:!0,wordWrap:!1,theme:i?`dark`:`light`}):W(r,{original:l??``,modified:u??``,language:`sql`,readOnly:!0,lineNumbers:!0,sideBySide:!1,theme:i?`dark`:`light`,height:`100%`}),W(X,{onClick:()=>o(!0),size:`medium`,"aria-label":`Expand`,sx:{position:`absolute`,top:`5px`,right:`20px`,opacity:s?.5:.1,transition:`opacity 0.3s ease-in-out`},children:W(Un,{})}),G(Tn,{open:a,onClose:()=>o(!1),maxWidth:`sm`,fullWidth:!0,slotProps:{paper:{sx:{height:`75%`,overflowY:`auto`}}},children:[G(On,{sx:{display:`flex`,alignItems:`center`},children:[t?G(U,{children:[W(`code`,{children:d}),`\xA0Model Code`]}):G(U,{children:[W(`code`,{children:d}),`\xA0Model Code Diff`]}),W(K,{sx:{flex:1}}),W(X,{size:`small`,onClick:()=>o(!1),children:W(Ln,{})})]}),W(Dn,{children:t?W(n,{language:`sql`,value:l??``,fontSize:16,readOnly:!0,lineNumbers:!0,wordWrap:!1,theme:i?`dark`:`light`}):W(r,{original:l??``,modified:u??``,language:`sql`,theme:i?`dark`:`light`,className:`text-base`})})]})]})},so=({node:e})=>{let{data:t,isLoading:n}=F(),r=Et();return n?W(U,{}):W(oo,{node:e,isSingleEnv:t?.single_env_onboarding??!1,CodeEditor:De,DiffEditor:Ge,isDark:r})},co=e=>({display:`inline-flex`,alignItems:`center`,borderRadius:16,px:1,py:.25,fontSize:`0.75rem`,bgcolor:e?`grey.700`:`grey.100`,color:e?`grey.100`:`inherit`}),lo={mr:.5,display:`flex`,alignItems:`center`};function uo({data:e,"data-testid":t}){let n=Et(),{icon:r}=tt(e.resourceType);return W(Z,{arrow:!0,title:`Type of resource`,children:G(K,{component:`span`,sx:co(n),"data-testid":t,children:[r&&W(K,{component:`span`,sx:lo,children:W(r,{})}),e.resourceType]})})}const fo=yn(uo);fo.displayName=`ResourceTypeTag`;function po({rowCount:e}){let t=e.base,n=e.curr,r=e.base===null?`N/A`:`${e.base} rows`,i=e.curr===null?`N/A`:`${e.curr} rows`;return t===null&&n===null?W(U,{children:` Failed to load`}):t===null||n===null?G(J,{direction:`row`,alignItems:`center`,spacing:.5,children:[W(Y,{variant:`body2`,component:`span`,children:r}),W(li,{}),W(Y,{variant:`body2`,component:`span`,children:i})]}):t===n?G(J,{direction:`row`,alignItems:`center`,spacing:.5,children:[W(Y,{variant:`body2`,component:`span`,children:i}),W(K,{component:`span`,sx:{color:`grey.500`,display:`flex`},children:W(_i,{})}),W(Y,{variant:`body2`,component:`span`,sx:{color:`grey.500`},children:`No Change`})]}):t<n?G(J,{direction:`row`,alignItems:`center`,spacing:.5,children:[W(Y,{variant:`body2`,component:`span`,children:i}),W(K,{component:`span`,sx:{color:`success.main`,display:`flex`},children:W(hi,{})}),W(Y,{variant:`body2`,component:`span`,sx:{color:`success.main`},children:Nt(t,n)})]}):G(J,{direction:`row`,alignItems:`center`,spacing:.5,children:[W(Y,{variant:`body2`,component:`span`,children:i}),W(K,{component:`span`,sx:{color:`error.main`,display:`flex`},children:W(mi,{})}),W(Y,{variant:`body2`,component:`span`,sx:{color:`error.main`},children:Nt(t,n)})]})}function mo({rowCount:e,node:t,onRefresh:n,isFetching:r}){let i=Et(),{featureToggles:a}=I(),{runsAggregated:o}=M(),s=o?.[t.id]?.row_count_diff.result,c=z(`row_count_diff`).icon,l=e??s,u=l;return W(Z,{title:l?`${l.base??`N/A`} -> ${l.curr??`N/A`} rows`:``,children:W(ks,{display:a.mode===`metadata only`,children:G(K,{component:`span`,sx:{...co(i),gap:.5},children:[W(c,{}),u!=null||r?r?W(wi,{width:30,height:16}):u==null?W(Y,{variant:`caption`,children:`row count`}):W(po,{rowCount:u}):W(Y,{variant:`caption`,children:`row count`}),n&&W(X,{"aria-label":`Query Row Count`,size:`small`,onClick:n,disabled:a.disableDatabaseQuery,sx:{p:0,ml:.5},children:W(lr,{size:12})})]})})})}function ho({rowCount:e,node:t,onRefresh:n,isFetching:r}){let i=Et(),{runsAggregated:a}=M(),o=a?.[t.id]?.row_count.result,s=z(`row_count`).icon,c,l=e??o;return l&&(c=`${l.curr??`N/A`} rows`),G(K,{component:`span`,sx:co(i),children:[W(K,{component:`span`,sx:lo,children:W(s,{})}),l||r?r?W(wi,{width:30,height:16}):W(Y,{variant:`caption`,children:c}):W(Y,{variant:`caption`,children:`row count`}),n&&W(X,{"aria-label":`Query Row Count`,size:`small`,onClick:n,disabled:t.data.from===`base`,sx:{p:0,ml:.5},children:W(lr,{size:12})})]})}function go({children:e,value:t,index:n}){return t===n?W(U,{children:e}):null}const _o=()=>W(`span`,{}),vo=({children:e})=>W(U,{children:e}),yo=()=>!0;function bo(e,t,n){return e?cn.add_or_remove:n(t)?``:`This action is not supported yet.`}function xo({node:e,actionCallbacks:t,runTypeIcons:n,isActionAvailable:r}){let i=e.data.changeStatus===`added`||e.data.changeStatus===`removed`,a=n?.query??_o,o=n?.row_count??_o,s=n?.profile??_o;return G(J,{direction:`row`,alignItems:`center`,flexWrap:`wrap`,gap:1,children:[W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(a,{fontSize:`small`}),onClick:t?.onQueryClick,sx:{textTransform:`none`},children:`Query`}),W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(o,{fontSize:`small`}),onClick:t?.onRowCountClick,sx:{textTransform:`none`},children:`Row Count`}),W(Z,{title:bo(i,`profile`,r),placement:`top`,children:W(`span`,{children:W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(s,{fontSize:`small`}),onClick:t?.onProfileClick,disabled:i,sx:{textTransform:`none`},children:`Profile`})})})]})}function So({actionCallbacks:e,runTypeIcons:t,featureToggles:n,ConnectionPopoverWrapper:r}){let i=n?.mode===`metadata only`,a=t?.schema_diff??_o,o=t?.sandbox??_o;return G(J,{direction:`row`,alignItems:`center`,sx:{mr:1},flexWrap:`wrap`,gap:1,children:[W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(a,{fontSize:`small`}),onClick:e?.onAddSchemaDiffClick,sx:{textTransform:`none`},children:`Add schema diff to checklist`}),W(r,{display:i,children:W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(o,{fontSize:`small`}),onClick:e?.onSandboxClick,disabled:n?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Sandbox`})})]})}function Co({node:e,actionCallbacks:t,runTypeIcons:n,featureToggles:r,isActionAvailable:i,ConnectionPopoverWrapper:a}){let o=r?.mode===`metadata only`,s=e.data.changeStatus===`added`||e.data.changeStatus===`removed`,c=n?.query_diff??_o,l=n?.row_count_diff??_o,u=n?.profile_diff??_o,d=n?.value_diff??_o,f=n?.top_k_diff??_o,p=n?.histogram_diff??_o,m=(e,t)=>o?W(a,{display:!0,children:e}):W(Z,{title:bo(s,t,i),placement:`top`,children:W(`span`,{children:e})});return G(J,{direction:`row`,alignItems:`center`,flexWrap:`wrap`,gap:2,children:[W(Y,{variant:`caption`,fontWeight:`bold`,children:`Diff`}),G(J,{direction:`row`,alignItems:`center`,flexWrap:`wrap`,gap:1,width:`93%`,children:[W(a,{display:o,children:W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(l,{fontSize:`small`}),onClick:t?.onRowCountDiffClick,disabled:r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Row Count`})}),m(W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(u,{fontSize:`small`}),onClick:t?.onProfileDiffClick,disabled:s||r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Profile`}),`profile_diff`),m(W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(d,{fontSize:`small`}),onClick:t?.onValueDiffClick,disabled:s||r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Value`}),`value_diff`),m(W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(f,{fontSize:`small`}),onClick:t?.onTopKDiffClick,disabled:s||r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Top-K`}),`top_k_diff`),m(W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(p,{fontSize:`small`}),onClick:t?.onHistogramDiffClick,disabled:s||r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Histogram`}),`histogram_diff`),W(a,{display:o,children:W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(c,{fontSize:`small`}),onClick:t?.onQueryDiffClick,disabled:r?.disableDatabaseQuery,sx:{textTransform:`none`},children:`Query`})})]})]})}function wo({node:e,onCloseNode:t,isSingleEnv:n,featureToggles:r,SchemaView:i,SingleEnvSchemaView:a,NodeSqlView:o,RowCountDiffTag:s,RowCountTag:c,ResourceTypeTag:l,NotificationComponent:u,ConnectionPopoverWrapper:d=vo,SandboxDialog:f,runTypeIcons:p,actionCallbacks:m,isActionAvailable:h=yo}){let g=e.data.resourceType===`model`||e.data.resourceType===`seed`||e.data.resourceType===`source`||e.data.resourceType===`snapshot`,[_,v]=H(!1),[y,b]=H(!0),[x,S]=H(0),{base:C,current:w}=e.data.data,T=!n&&Pt(C?.columns,w?.columns)===!0,E=!n&&C?.raw_code!=null&&w?.raw_code!=null&&C.raw_code!==w.raw_code,D=e.data.resourceType===`model`||e.data.resourceType===`seed`||e.data.resourceType===`snapshot`,O={...m,onSandboxClick:()=>{m?.onSandboxClick?.(),v(!0)}};return G(K,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[G(J,{direction:`row`,alignItems:`center`,children:[W(K,{sx:{flex:`0 1 20%`,p:2},children:W(Y,{variant:`subtitle1`,fontWeight:600,className:`no-track-pii-safe`,children:e.data.name})}),W(K,{sx:{flexGrow:1}}),!n&&D&&W(So,{node:e,actionCallbacks:O,runTypeIcons:p,featureToggles:r,ConnectionPopoverWrapper:d}),W(K,{sx:{flex:`0 1 1%`},children:W(X,{size:`small`,onClick:t,children:W(Ln,{})})})]}),W(K,{sx:{color:`text.secondary`,pl:2},children:G(J,{direction:`row`,spacing:1,children:[l&&W(l,{node:e}),D&&(n?c&&W(c,{node:e,onRefresh:m?.onRowCountClick}):s&&W(s,{node:e,onRefresh:m?.onRowCountDiffClick}))]})}),D&&W(K,{sx:{pl:2,py:1},children:n?W(xo,{node:e,actionCallbacks:m,runTypeIcons:p,isActionAvailable:h}):W(Co,{node:e,actionCallbacks:O,runTypeIcons:p,featureToggles:r,isActionAvailable:h,ConnectionPopoverWrapper:d})}),g&&G(K,{sx:{overflow:`auto`,display:`flex`,flexDirection:`column`,flex:1,minHeight:0},children:[n&&y&&u&&W(K,{sx:{p:1.5},children:W(u,{onClose:()=>b(!1),children:W(Y,{variant:`body2`,children:`Enable the Recce Checklist and start adding checks for better data validation and review.`})})}),G(qr,{value:x,onChange:(e,t)=>S(t),sx:{borderBottom:1,borderColor:`divider`},children:[W(Kr,{label:G(K,{component:`span`,sx:{display:`flex`,alignItems:`center`,gap:.75},children:[`Columns`,T&&W(K,{component:`span`,sx:{color:`amber.main`,fontSize:`0.5rem`,lineHeight:1},children:`●`})]})}),W(Kr,{label:G(K,{component:`span`,sx:{display:`flex`,alignItems:`center`,gap:.75},children:[`Code`,E&&W(K,{component:`span`,sx:{color:`amber.main`,fontSize:`0.5rem`,lineHeight:1},children:`●`})]})})]}),G(K,{sx:{overflow:`auto`,height:`calc(100% - 48px)`},children:[W(go,{value:x,index:0,children:W(K,{sx:{overflowY:`auto`,height:`100%`},children:n?a&&W(a,{current:e.data.data.current}):i&&W(i,{base:e.data.data.base,current:e.data.data.current,columnChanges:e.data.change?.columns,onViewCode:()=>S(1)})})}),W(go,{value:x,index:1,children:W(K,{sx:{height:`100%`},children:o&&W(o,{node:e})})})]})]}),f&&W(f,{isOpen:_,onClose:()=>v(!1),current:e.data.data.current})]})}function To(e){return Qr(ei(e),`yyyy-MM-dd'T'HH:mm:ss`)}function Eo({current:e,primaryKeys:t,onPrimaryKeysChange:n,onRunResultOpen:r,runQuery:i,isPending:a,QueryForm:o}){return G(J,{direction:`row`,justifyContent:`flex-end`,alignItems:`center`,sx:{p:`4pt 8pt`,gap:`5px`,height:`54px`,borderBottom:`1px solid`,borderBottomColor:`divider`,flex:`0 0 54px`},children:[G(K,{children:[G(Y,{variant:`h6`,component:`h2`,sx:{display:`flex`,alignItems:`center`,gap:`5px`},children:[W(K,{component:Ti,sx:{fontSize:`1.2em`}}),`Sandbox`]}),G(Y,{sx:{fontSize:`0.75rem`,color:`grey.500`},children:[`Compare the run results based on the modified SQL code of model`,` `,W(`b`,{children:e?.name})]})]}),W(K,{sx:{flexGrow:1}}),W(o,{defaultPrimaryKeys:t,onPrimaryKeysChange:n}),W(Z,{title:`Run diff to see the changes`,children:W(q,{size:`small`,sx:{mt:`16px`,fontSize:`14px`},onClick:()=>{r(),i()},color:`iochmara`,variant:`contained`,disabled:a,children:a?`Running...`:`Run Diff`})})]})}function Do({currentModelID:e,height:t=`32px`,flex:n=`0 0 auto`,isDark:r=!1}){let{lineageGraph:i,envInfo:a}=M(),o=`0 16px`,s=$r(To(a?.dbt?.current?.generated_at??``),{addSuffix:!0}),c=`N/A`;if(i?.nodes[e]){let t=i.nodes[e];t.data.data.current?.schema&&(c=t.data.data.current.schema)}return G(J,{direction:`row`,sx:{gap:0,height:t,flex:n,fontSize:`14px`,alignItems:`center`,m:0,bgcolor:Mn(r?be.neutral[700]:be.neutral[100],.5)},children:[W(J,{sx:{width:`50%`},children:G(Y,{sx:{fontWeight:`bold`,margin:o},children:[`ORIGINAL (Schema: `,c,`, Last Updated: `,s,`)`]})}),W(J,{sx:{width:`50%`},children:W(Y,{sx:{fontWeight:`bold`,margin:o},children:`SANDBOX EDITOR`})})]})}function Oo({current:e,onChange:t,isDark:n,DiffEditor:r}){return W(r,{original:e?.raw_code??``,modified:e?.raw_code??``,language:`sql`,readOnly:!1,lineNumbers:!0,sideBySide:!0,theme:n?`dark`:`light`,height:`100%`,onModifiedChange:t})}function ko({isOpen:e,onClose:t,current:n,DiffEditor:r,QueryForm:i,RunResultPane:a,isDark:o=!1,primaryKeys:s=[],onPrimaryKeysChange:c,isPending:l=!1,onRunQuery:u,onRunResultOpen:d,onModifiedCodeChange:f,onShowFeedback:p,tracking:m,logoUrl:h=`/logo/recce-logo-white.png`,brandName:g=`RECCE`}){let[_,v]=H(!1),y=e=>{f?.(e)},b=()=>{v(!0),d?.()},x=()=>{u?.()},S=()=>{t(),v(!1),m?.onPreviewChange?.({action:`close`,node:n?.name})},C=e=>{c?.(e)};return G(Tn,{open:e,onClose:S,maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:`100%`,height:`100%`,maxWidth:`100%`,maxHeight:`100%`,m:0}}},children:[G(K,{sx:{height:`40px`,bgcolor:`cyan.600`,px:0,py:2,display:`flex`,alignItems:`center`},children:[G(J,{direction:`row`,alignItems:`center`,sx:{height:`100%`,gap:`10px`},children:[W(K,{component:`img`,sx:{width:`20px`,height:`20px`,ml:`18px`},src:h,alt:`logo`}),W(Y,{variant:`h6`,component:`h1`,sx:{fontFamily:`"Montserrat", sans-serif`,fontSize:`1.125rem`,color:`common.white`},children:g}),W(mr,{label:`Experiment`,size:`small`,variant:`outlined`,sx:{fontSize:`0.875rem`,color:`common.white`,borderColor:`rgba(255,255,255,0.5)`}})]}),W(X,{"aria-label":`close`,onClick:S,sx:{position:`absolute`,right:8,top:4,color:`common.white`},children:W(Ln,{})})]}),W(Dn,{sx:{p:0},children:G(bt,{sizes:_?[50,50]:[100,0],minSize:0,gutterSize:5,className:_?void 0:`split-gutter-hidden`,style:{flex:`1`,contain:`size`,height:`100%`},children:[G(J,{sx:{height:`100%`,m:0,p:0},children:[W(Eo,{current:n,primaryKeys:s,onPrimaryKeysChange:C,onRunResultOpen:b,runQuery:x,isPending:l,QueryForm:i}),W(Do,{height:`32px`,flex:`0 0 auto`,currentModelID:n?.id??``,isDark:o}),W(Oo,{current:n,onChange:y,isDark:o,DiffEditor:r})]}),_?W(a,{onClose:()=>v(!1),disableAddToChecklist:!0}):W(K,{})]})}),W(K,{sx:{position:`fixed`,bottom:16,right:16,opacity:.5},children:W(Z,{title:`Give us feedback`,children:W(X,{"aria-label":`feedback`,size:`medium`,onClick:()=>{p?.()},children:W(Br,{})})})})]})}function Ao({isOpen:e,onClose:t,current:n}){let[r,i]=H(n?.raw_code??``),[o,s]=H(e),{showRunId:c,clearRunResult:l}=de(),{primaryKeys:u,setPrimaryKeys:d}=Ie(),{data:p,isLoading:m}=F(),{apiClient:g}=Oe(),_=Et();e!==o&&(s(e),e&&i(n?.raw_code??``));let{mutate:v,isPending:y}=dn({mutationFn:async()=>{let e=r,{run_id:t}=await a({current_model:n?.name??``,primary_keys:u,sql_template:e},{nowait:!0},g);return c(t),await h(t,void 0,g)},onSuccess(e){e.error?nn({action:`run`,node:n?.name,status:`failure`}):(nn({action:`run`,node:n?.name,status:`success`}),setTimeout(()=>{b()},1e3),!m&&p?.single_env_onboarding&&setTimeout(()=>{S()},2e3))}}),{feedbackToast:b,closeToast:x}=Je({feedbackId:f.previewChangeFeedbackID,description:`Enjoy preview change?`,onFeedbackSubmit:e=>{switch(e){case`like`:rn({feedback:`like`,node:n?.name});break;case`dislike`:rn({feedback:`dislike`,node:n?.name});break;case`link`:rn({feedback:`form`,node:n?.name});break;default:console.log(`Not support feedback type`)}},externalLink:`https://docs.google.com/forms/d/e/1FAIpQLSd7Lei7Ijwo7MinWaI0K6rzZi_21gV1BKetmiNEX254kDziDA/viewform?usp=header`,externalLinkText:`Give us feedback`}),{guideToast:S,closeGuideToast:C}=_t({guideId:f.prepareEnvGuideID,description:`Want to compare data changes with production data?`,externalLink:`https://docs.reccehq.com/get-started/#prepare-dbt-artifacts`,externalLinkText:`Learn how.`,onExternalLinkClick:()=>{on({action:`external_link`,from:`preview_changes`,node:n?.name})}});return W(ko,{isOpen:e,onClose:()=>{t(),l(),x(),C()},current:n,DiffEditor:Ge,QueryForm:ba,RunResultPane:L,isDark:_,primaryKeys:u??[],onPrimaryKeysChange:d,isPending:y,onRunQuery:v,onModifiedCodeChange:i,onShowFeedback:()=>b(!0),tracking:{onPreviewChange:nn}})}const jo=({node:e})=>W(fo,{data:{resourceType:e.data.resourceType}});function Mo({onClose:e}){return W(Me,{onClose:e,align:`flex-start`,children:G(Y,{variant:`body2`,children:[`Enable the Recce Checklist and start adding checks for better data validation and review.`,W(`br`,{}),W(rt,{})]})})}function No({node:e,onCloseNode:t}){let n=ni(),{runAction:r}=de(),{isActionAvailable:i,envInfo:a}=M(),{singleEnv:o,featureToggles:s}=I(),{setSqlQuery:c,setPrimaryKeys:l}=Ie(),{primaryKey:u}=ut(e.data.name),{apiClient:d}=Oe(),{basePath:f}=ue(),p=V(()=>({query:z(`query`).icon,row_count:z(`row_count`).icon,row_count_diff:z(`row_count_diff`).icon,profile:z(`profile`).icon,profile_diff:z(`profile_diff`).icon,query_diff:z(`query_diff`).icon,value_diff:z(`value_diff`).icon,top_k_diff:z(`top_k_diff`).icon,histogram_diff:z(`histogram_diff`).icon,schema_diff:z(`schema_diff`).icon,sandbox:z(`sandbox`).icon}),[]),m=Ft(Object.keys(e.data.data.base?.columns??{}),Object.keys(e.data.data.current?.columns??{})),h=V(()=>m.length?`select \n ${m.join(`
|
|
6
|
+
`)}\nfrom {{ ref("${e.data.name}") }}`:`select * from {{ ref("${e.data.name}") }}`,[m,e.data.name]),g=V(()=>({onQueryClick:()=>{a?.adapterType===`dbt`?c(h):a?.adapterType===`sqlmesh`&&c(`select * from ${e.data.name}`),n.push(`${f}/query`)},onRowCountClick:()=>{Jt({action:Ht.ROW_COUNT,source:Wt.SCHEMA_ROW_COUNT_BUTTON,node_count:1}),r(`row_count`,{node_names:[e.data.name]},{showForm:!1,showLast:!1})},onRowCountDiffClick:()=>{Jt({action:Ht.ROW_COUNT_DIFF,source:Wt.SCHEMA_ROW_COUNT_BUTTON,node_count:1}),r(`row_count_diff`,{node_names:[e.data.name]},{showForm:!1,showLast:!1})},onProfileClick:()=>{Jt({action:Ht.PROFILE,source:Wt.NODE_SIDEBAR_SINGLE_ENV,node_count:1}),r(`profile`,{model:e.data.name},{showForm:!0,showLast:!1})},onProfileDiffClick:()=>{Jt({action:Ht.PROFILE_DIFF,source:Wt.NODE_SIDEBAR_MULTI_ENV,node_count:1}),r(`profile_diff`,{model:e.data.name},{showForm:!0,showLast:!1})},onQueryDiffClick:()=>{a?.adapterType===`dbt`?c(h):a?.adapterType===`sqlmesh`&&c(`select * from ${e.data.name}`),i(`query_diff_with_primary_key`)&&l(u===void 0?void 0:[u]),n.push(`${f}/query`)},onValueDiffClick:()=>{Jt({action:Ht.VALUE_DIFF,source:Wt.NODE_SIDEBAR_MULTI_ENV,node_count:1}),r(`value_diff`,{model:e.data.name},{showForm:!0,showLast:!1})},onTopKDiffClick:()=>{Jt({action:Ht.TOP_K_DIFF,source:Wt.NODE_SIDEBAR_MULTI_ENV,node_count:1}),r(`top_k_diff`,{model:e.data.name,column_name:``,k:50},{showForm:!0})},onHistogramDiffClick:()=>{Jt({action:Ht.HISTOGRAM_DIFF,source:Wt.NODE_SIDEBAR_MULTI_ENV,node_count:1}),r(`histogram_diff`,{model:e.data.name,column_name:``,column_type:``},{showForm:!0})},onAddSchemaDiffClick:async()=>{let t=await _({node_id:e.id},d);n.push(`${f}/checks/?id=${t.check_id}`)},onSandboxClick:()=>{i(`query_diff_with_primary_key`)&&l(u===void 0?void 0:[u]),nn({action:`explore`,node:e.data.name})}}),[e,h,a,c,r,i,l,u,d,n.push,f]);return W(wo,{node:e,onCloseNode:t,isSingleEnv:o??!1,featureToggles:s,SchemaView:io,SingleEnvSchemaView:ao,NodeSqlView:so,ResourceTypeTag:jo,RowCountDiffTag:mo,RowCountTag:ho,NotificationComponent:Mo,ConnectionPopoverWrapper:ks,SandboxDialog:Ao,runTypeIcons:p,actionCallbacks:g,isActionAvailable:i})}function Po(e,t){let n={...e};for(let[e,r]of Object.entries(t.current.nodes)){if(!r.change_status)continue;let t=null;if(r.columns){let e={},n=!1;for(let t of Object.values(r.columns))t.change_status&&(e[t.name]=t.change_status,n=!0);n&&(t=e)}n[e]={change_status:r.change_status,change:r.change_category?{category:r.change_category,columns:t}:null}}return n}function Fo({featureToggles:e,settingsUrl:t}){return e.mode===`metadata only`?W(K,{sx:{display:`flex`,alignItems:`center`,width:`100%`,px:1,py:.25,bgcolor:`cyan.50`},children:G(J,{direction:`row`,alignItems:`center`,sx:{flex:1,fontSize:`0.875rem`,color:`cyan.600`},spacing:1,children:[W(K,{component:nr}),W(Y,{sx:{fontSize:`inherit`,color:`inherit`},children:`Query functions disabled without a data warehouse connection.`}),W(q,{sx:{bgcolor:`iochmara.400`},size:`small`,variant:`contained`,onClick:()=>{window.open(t,`_blank`)},children:`Connect to Data Warehouse`})]})}):null}function Io(e){let{featureToggles:t}=I(),{data:n}=j();return W(Fo,{featureToggles:e.featureToggles??t,settingsUrl:e.settingsUrl??Rt(n,Vt)})}function Lo({docsUrl:e=`https://docs.reccehq.com/get-started/#prepare-dbt-artifacts`,onStartClick:t}={}){return W(J,{sx:{flex:1,height:`100%`,minHeight:0,m:1,p:2,bgcolor:`iochmara.50`,borderRadius:2,boxShadow:2,justifyContent:`center`},children:G(J,{sx:{width:`80%`,overflowY:`auto`,gap:3,px:4,pb:4},alignSelf:`center`,children:[G(J,{alignItems:`center`,spacing:2,children:[W(K,{sx:{p:1,bgcolor:`background.paper`,borderRadius:`50%`,display:`flex`,alignItems:`center`,justifyContent:`center`,boxShadow:2},children:W(K,{component:vi,sx:{fontSize:28,color:`iochmara.500`}})}),W(Y,{variant:`h5`,sx:{mt:2},children:`Wait, there's more!`}),G(Y,{sx:{textAlign:`center`},children:[`Recce is currently running in`,` `,W(Y,{component:`span`,sx:{fontWeight:`bold`},children:`limited functionality mode`}),` `,`so you can run queries but`,` `,W(Y,{component:`span`,sx:{fontWeight:`bold`},children:`can't diff the results yet!`})]})]}),G(J,{spacing:1,children:[W(Y,{children:`To unlock the full power of Recce, set up a base environment of dbt artifacts for comparison.`}),W(Y,{children:`Once configured, you'll be able to:`}),G(Jr,{sx:{listStyleType:`disc`,pl:2},children:[W(Yr,{sx:{display:`list-item`,p:0},children:W(Y,{children:`Run statistical data diffs`})}),W(Yr,{sx:{display:`list-item`,p:0},children:W(Y,{children:`Run query diffs`})}),W(Yr,{sx:{display:`list-item`,p:0},children:W(Y,{children:`Save checks to your Recce Checklist`})}),W(Yr,{sx:{display:`list-item`,p:0},children:W(Y,{children:`...and more!`})})]}),W(Y,{children:`Take the next step toward better data impact assessment.`})]}),W(J,{sx:{width:`100%`,mt:3},children:W(q,{color:`iochmara`,variant:`contained`,size:`large`,onClick:()=>{t?t():window.open(e,`_blank`)},children:`Start Now`})})]})})}function Ro({docsUrl:e=`https://docs.reccehq.com/configure-diff/`}={}){return G(J,{direction:`row`,spacing:`10px`,alignItems:`flex-start`,children:[W(K,{component:gi,sx:{color:`iochmara.main`,fontSize:20}}),G(J,{spacing:`5px`,children:[G(Y,{sx:{fontWeight:700},children:[`Single Environment Mode`,` `,W(Y,{component:`span`,sx:{color:`error.main`,fontWeight:600},children:`Limited Functionality`})]}),W(Y,{sx:{fontSize:`0.875rem`},children:`Single Environment Mode allows you to explore your dbt project but won't show data comparisons between environments.`}),W(Y,{sx:{fontSize:`0.875rem`},children:`To set up full environment comparison:`}),G(Jr,{sx:{pl:2},children:[W(Yr,{sx:{p:0,display:`list-item`},children:W(Y,{sx:{fontSize:`0.875rem`},children:"Run `recce debug` for setup assistance"})}),W(Yr,{sx:{p:0,display:`list-item`},children:G(Y,{sx:{fontSize:`0.875rem`},children:[`Visit`,` `,W(kn,{sx:{color:`primary.main`,fontWeight:500},target:`_blank`,href:e,children:`docs`}),` `,`for configuration details`]})})]})]})]})}function zo(){return W(K,{sx:{width:`100%`,height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:W(Vn,{size:48})})}function Bo({error:e,onRetry:t}){return W(K,{sx:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:G(J,{alignItems:`center`,spacing:1,children:[W(K,{children:`Failed to load lineage data. This could be because the server has been terminated or there is a network error.`}),G(K,{children:[`[Reason: `,e,`]`]}),W(q,{color:`iochmara`,variant:`contained`,onClick:()=>{t&&t()},children:`Retry`})]})})}function Vo({viewOptions:e,onViewOptionsChanged:t}){return W(K,{sx:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:G(J,{alignItems:`center`,spacing:1,children:[W(U,{children:`No change detected`}),W(q,{color:`iochmara`,variant:`contained`,onClick:async()=>{await t({...e,view_mode:`all`})},children:`Show all nodes`})]})})}function Ho(){let{isHistoryOpen:e,showHistory:t}=de();if(!e)return G(K,{children:[W(K,{sx:{fontSize:`8pt`},children:`History`}),W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(Hr,{}),onClick:()=>{Xt({name:e?`hide`:`show`}),t()},children:`Show`})]})}const Uo=e=>({fontSize:`8pt`,bgcolor:e?`grey.700`:`grey.100`,px:.5,borderRadius:1}),Wo=()=>{let e=Uo(Et());return G(J,{alignItems:`flex-start`,spacing:0,children:[W(Y,{fontSize:`10pt`,color:`text.secondary`,pb:1,children:`Select nodes by dbt node selector syntax`}),G(Y,{fontSize:`8pt`,children:[W(K,{component:`code`,sx:e,children:`model_name`}),` `,`Select a node`]}),G(Y,{fontSize:`8pt`,children:[W(K,{component:`code`,sx:e,children:`model_name+`}),` `,`Select downstream nodes`]}),G(Y,{fontSize:`8pt`,children:[W(K,{component:`code`,sx:e,children:`+model_name`}),` `,`Select upstream nodes`]}),G(Y,{fontSize:`8pt`,children:[W(K,{component:`code`,sx:e,children:`model*`}),` `,`Select by wildcard`]})]})},Go=({isDisabled:e,viewOptions:t,onViewOptionsChanged:n})=>{let[r,i]=H(null),a=!!r,o=t.view_mode??`changed_models`,s=o===`changed_models`?`Changed Models`:`All`,c=e=>{i(e.currentTarget)},l=()=>{i(null)},u=e=>{n({...t,view_mode:e}),l()},d=tt(`model`).icon;return G(U,{children:[W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,onClick:c,disabled:e,startIcon:d&&W(d,{}),endIcon:W(Xn,{}),sx:{minWidth:100,textTransform:`none`,fontSize:`0.75rem`},children:s}),G(Lr,{anchorEl:r,open:a,onClose:l,children:[W(Wr,{sx:{lineHeight:`32px`,bgcolor:`transparent`},children:`mode`}),G(Di,{value:o,children:[W(Q,{onClick:()=>u(`changed_models`),children:W(Nr,{value:`changed_models`,control:W(Ei,{size:`small`,sx:{py:0}}),label:`Changed Models`,sx:{m:0}})}),W(Q,{onClick:()=>u(`all`),children:W(Nr,{value:`all`,control:W(Ei,{size:`small`,sx:{py:0}}),label:`All`,sx:{m:0}})})]})]})]})},Ko=({isDisabled:e,viewOptions:t,onViewOptionsChanged:n,lineageGraph:r})=>{let[i,a]=H(null),o=!!i,s=new Set,c=Object.values(r?.nodes??{});for(let e of c)e.data.packageName&&s.add(e.data.packageName);let l=r?.manifestMetadata.current?.project_name,u=t.packages?new Set(t.packages):l?new Set([l]):s,d=u.size===s.size,f=u.size===0,p=u.size===1?Array.from(u)[0]:d?`All Packages`:f?`No Package`:`${u.size} Packages`,m=e=>{a(e.currentTarget)},h=()=>{a(null)},g=()=>{n(d?{...t,packages:[]}:{...t,packages:Array.from(s)})},_=e=>{let r=new Set(u);r.has(e)?r.delete(e):r.add(e),n({...t,packages:Array.from(r)})};return G(U,{children:[W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,onClick:m,disabled:e,startIcon:W(fi,{}),endIcon:W(Xn,{}),sx:{minWidth:100,textTransform:`none`,fontSize:`0.75rem`},children:p}),G(Lr,{anchorEl:i,open:o,onClose:h,children:[W(Wr,{sx:{lineHeight:`32px`,bgcolor:`transparent`},children:`Select Packages`}),G(Q,{onClick:g,children:[W(Mr,{checked:d,indeterminate:!d&&!f,size:`small`,sx:{py:0}}),W(ci,{children:`Select All`})]}),W(Bn,{}),Array.from(s).map(e=>G(Q,{onClick:()=>_(e),children:[W(Mr,{checked:u.has(e),size:`small`,sx:{py:0}}),W(ci,{className:`no-track-pii-safe`,children:e})]},e))]})]})},qo=({value:e,onChange:t,isDisabled:n,tooltipComponent:r,showTooltip:i=!0})=>{let[a,o]=H(e),s=wn(null);return xn(()=>{s.current&&(s.current.value=e)},[e]),W(Z,{title:i?r:``,placement:`bottom-start`,slotProps:{tooltip:{sx:{width:`18.75rem`,p:2,boxShadow:3,border:1,borderRadius:1,color:`text.primary`,bgcolor:`background.paper`}}},children:W(Gr,{inputRef:s,size:`small`,placeholder:`with selectors`,disabled:n,value:a,onChange:e=>{o(e.target.value)},onKeyUp:n=>{n.key===`Enter`?t(a):n.key===`Escape`&&(n.preventDefault(),o(e),s.current&&s.current.blur())},onBlur:()=>{o(e)},sx:{"& .MuiInputBase-root":{width:`18.75rem`,height:24,fontSize:`0.75rem`},"& .MuiInputBase-input":{py:.5,px:1}}})})},Jo=({isDisabled:e,viewOptions:t,onViewOptionsChanged:n,showTooltip:r})=>W(qo,{isDisabled:e,value:t.select??``,onChange:e=>{n({...t,select:e||void 0})},tooltipComponent:W(Wo,{}),showTooltip:r}),Yo=({isDisabled:e,viewOptions:t,onViewOptionsChanged:n})=>W(qo,{isDisabled:e,value:t.exclude??``,onChange:e=>{n({...t,exclude:e||void 0})}}),Xo=({label:e,children:t,style:n})=>G(K,{style:n,sx:{maxWidth:300},children:[W(Y,{fontSize:`8pt`,children:(e??``).trim()||W(U,{children:`\xA0`})}),t]}),Zo=({children:e})=>W(U,{children:e}),Qo=({viewOptions:e,onViewOptionsChanged:t,lineageGraph:n,featureToggles:r,serverFlags:i,focusedNode:a,selectedNodes:o,onDeselect:s,onRunRowCount:c,onRunRowCountDiff:l,onRunValueDiff:u,onAddLineageDiffCheck:d,onAddSchemaDiffCheck:f,runTypeIcons:p,historyToggleSlot:m,SetupConnectionPopoverSlot:h=Zo})=>{let g=i?.single_env_onboarding,[_,v]=H(null),y=!!_,b=o.length>0,x=b,S=e=>{v(e.currentTarget)},C=()=>{v(null)},w=p.rowCountDiff,T=p.valueDiff,E=p.lineageDiff,D=p.schemaDiff;return W(J,{direction:`row`,alignItems:`center`,borderBottom:1,borderColor:`neutral.light`,sx:{width:`100%`,p:`4pt 8pt`,gap:`0.5rem`},children:G(J,{direction:`row`,alignItems:`center`,sx:{flex:1,gap:`0.5rem`},children:[m,W(Xo,{label:`Mode`,style:{flexShrink:1},children:W(Go,{isDisabled:x,viewOptions:e,onViewOptionsChanged:t})}),W(Xo,{label:`Package`,style:{flexShrink:1},children:W(Ko,{isDisabled:x,viewOptions:e,onViewOptionsChanged:t,lineageGraph:n})}),W(Xo,{label:`Select`,style:{flexShrink:1},children:W(Jo,{isDisabled:x,viewOptions:e,onViewOptionsChanged:t,showTooltip:g})}),W(Xo,{label:`Exclude`,style:{flexShrink:1},children:W(Yo,{isDisabled:x,viewOptions:e,onViewOptionsChanged:t})}),W(K,{sx:{flexGrow:1}}),b&&G(U,{children:[W(Xo,{label:``,style:{flexShrink:0},children:W(Y,{fontSize:`9pt`,color:`text.secondary`,children:o.length>1?`${o.length} nodes selected`:`${o.length} node selected`})}),W(Xo,{label:``,children:W(q,{variant:`outlined`,color:`neutral`,size:`xsmall`,onClick:()=>{s()},sx:{textTransform:`none`,fontSize:`9pt`},children:`Deselect`})}),g&&W(Xo,{label:`Explore`,children:G(K,{sx:{display:`inline-flex`},children:[W(q,{size:`xsmall`,color:`neutral`,variant:`outlined`,onClick:S,endIcon:W(Xn,{}),sx:{textTransform:`none`,fontSize:`0.75rem`},children:`Actions`}),W(Lr,{anchorEl:_,open:y,onClose:C,anchorOrigin:{vertical:`bottom`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`right`},children:G(Q,{disabled:r.disableDatabaseQuery,onClick:async()=>{await c?.(),C()},children:[W(si,{children:W(w,{fontSize:`small`})}),W(ci,{children:`Row Count`})]})})]})})]}),!g&&W(Xo,{label:`Explore`,children:G(K,{sx:{display:`inline-flex`},children:[W(q,{size:`xsmall`,color:`neutral`,variant:`outlined`,disabled:r.disableViewActionDropdown,onClick:S,endIcon:W(Xn,{}),sx:{textTransform:`none`,fontSize:`0.75rem`},children:`Actions`}),G(Lr,{anchorEl:_,open:y,onClose:C,anchorOrigin:{vertical:`bottom`,horizontal:`right`},transformOrigin:{vertical:`top`,horizontal:`right`},children:[W(Wr,{sx:{lineHeight:`32px`,bgcolor:`transparent`},children:`Diff`}),W(h,{display:r.mode===`metadata only`,children:G(Q,{disabled:r.disableDatabaseQuery,onClick:async()=>{await l?.(),C()},children:[W(si,{children:W(w,{fontSize:`small`})}),W(ci,{children:`Row Count Diff`})]})}),W(h,{display:r.mode===`metadata only`,children:G(Q,{disabled:r.disableDatabaseQuery,onClick:async()=>{await u?.(),C()},children:[W(si,{children:W(T,{fontSize:`small`})}),W(ci,{children:`Value Diff`})]})}),W(Bn,{}),W(Wr,{sx:{lineHeight:`32px`,bgcolor:`transparent`},children:`Add to Checklist`}),G(Q,{onClick:()=>{d?.(e.view_mode),C()},children:[W(si,{children:W(E,{fontSize:`small`})}),W(ci,{children:`Lineage Diff`})]}),G(Q,{onClick:()=>{f?.(),C()},children:[W(si,{children:W(D,{fontSize:`small`})}),W(ci,{children:`Schema Diff`})]})]})]})})]})})},$o=({display:e,children:t})=>W(ks,{display:e,children:t}),es=()=>{let{deselect:e,focusedNode:t,selectedNodes:n,viewOptions:r,onViewOptionsChanged:i,runRowCount:a,runRowCountDiff:o,runValueDiff:s,addLineageDiffCheck:c,addSchemaDiffCheck:l}=le(),{lineageGraph:u}=M(),{featureToggles:d}=I(),{data:f}=F();return W(Qo,{viewOptions:r,onViewOptionsChanged:i,lineageGraph:u,featureToggles:d,serverFlags:f,focusedNode:t,selectedNodes:n,onDeselect:e,onRunRowCount:a,onRunRowCountDiff:o,onRunValueDiff:s,onAddLineageDiffCheck:c,onAddSchemaDiffCheck:l,runTypeIcons:{rowCountDiff:z(`row_count_diff`).icon,valueDiff:z(`value_diff`).icon,lineageDiff:z(`lineage_diff`).icon,schemaDiff:z(`schema_diff`).icon},historyToggleSlot:W(Ho,{}),SetupConnectionPopoverSlot:$o})};function ts({interactive:e=!1,...t},n){let{isDark:r}=ct(),{apiClient:i}=Oe(),a=pn(),o=kr(),s=wn(null),{copyToClipboard:c,ImageDownloadModal:l,ref:u}=Va(),[f,p,m]=Or(ja),[h,y,b]=Dr([]),{lineageGraph:x,refetchLineageGraph:S,isLoading:T,error:D,refetchRunsAggregated:O}=M(),{featureToggles:k,singleEnv:ee}=I(),{runId:re,showRunId:ie,closeRunResult:ae,runAction:j,isRunResultOpen:oe}=de(),{run:N}=ht(re),[P,le]=H({...t.viewOptions}),ue=Wa(),pe=wn([]).current,[F,_e]=H(void 0),[ve,ye]=H(!1),xe=wn(!1);xe.current=ve;let Se=dn({mutationFn:e=>te(e,i)}),Ce=wn({pending:!1}),[we,Te]=H({}),Ee=B(e=>f.filter(ce).find(t=>t.data.name===e),[f]);Sn(n,()=>({copyToClipboard:c}));let De=V(()=>!!(x&&x.modifiedSet.length>0),[x]),ke=P.view_mode??`changed_models`,Ae=V(()=>f.filter(e=>e.type===`lineageGraphNode`).map(e=>e.id),[f]),je=V(()=>x?Ae.map(e=>x.nodes[e]):[],[x,Ae]),[Me,Ne]=H(),L=Me?x?.nodes[Me]:void 0,[R,Pe]=H(),[Fe,Ie]=H(new Set),Le=V(()=>x?Array.from(Fe).map(e=>x.nodes[e]):[],[x,Fe]),Re=qa(Le.length>0?Le:je,{onActionStarted:()=>{Pe(`action_result`)},onActionNodeUpdated:e=>{p(t=>t.map(t=>t.id===e.id?{...t}:t))},onActionCompleted:()=>{}}),ze=B(()=>{let e=new Map,t=o.getNodes();for(let n of t)!n.parentId&&n.position&&e.set(n.id,{x:n.position.x,y:n.position.y});return e},[o]),z=V(()=>{if(!x)return new Set;let e=new Set;if(F){for(let[t,n]of Object.entries(F.current.nodes))n.impacted!==!1&&e.add(t);for(let t of Object.keys(F.current.columns))e.add(t)}else if(R===`action_result`){let t=Object.keys(Re.actionState.actions);e=new Set(t)}else e=L?fe(ge(x,[L.id]),me(x,[L.id])):De?me(x,x.modifiedSet):new Set(Ae);return new Set(e)},[x,F,R,L,De,Re.actionState.actions,Ae]),Be=Qa(),Ve=()=>{Be.closeContextMenu()};Cn(()=>{(async()=>{let e;if(!x)return;if(P.node_ids)e=P.node_ids;else{let n=x.manifestMetadata.current?.project_name,r={view_mode:P.view_mode??(De?`changed_models`:`all`),packages:n?[n]:void 0,...t.viewOptions};try{e=(await C({select:r.select,exclude:r.exclude,packages:r.packages,view_mode:r.view_mode},i)).nodes}catch{r.view_mode=`all`,e=(await C({select:r.select,exclude:r.exclude,packages:r.packages,view_mode:r.view_mode},i)).nodes}le(r)}let n;if(P.column_level_lineage)if(Ce.current.pending)n=Ce.current.cllData,Ce.current={pending:!1};else{let e={...P.column_level_lineage,change_analysis:P.column_level_lineage.change_analysis??xe.current};try{n=await Se.mutateAsync(e);let t=n;e.change_analysis&&t&&(Ce.current={pending:!0,cllData:t},a.setQueryData(A.lineage(),e=>e&&{...e,lineage:{...e.lineage,diff:Po(e.lineage.diff,t)}}))}catch(e){if(e instanceof mn){let t=e;jt.create({title:`Column Level Lineage error`,description:t.response?.data.detail??e.message,type:`error`,closable:!0});return}}}else Ce.current={pending:!1};let[r,o,s]=await $a(x,{selectedNodes:e,cll:n});p(r),y(o),Te(s),_e(n),ue(r,P.view_mode??`changed_models`,xe.current,!!P.column_level_lineage?.column,!!Me||!!N)})()},[x]);let He=()=>{Ne(void 0)},Ue=async e=>{let t=f.find(t=>t.id===e);if(t){if(t.parentId){let e=t.parentId;t=f.find(t=>t.id===e)??t}if(t.measured!=null){let{width:e,height:n}=t.measured;if(e&&n){let r=t.position.x+e/2,i=t.position.y+n/2,a=o.getZoom();await o.setCenter(r,i,{zoom:a,duration:200})}}}},We=Ha();Ua(s,async()=>{R!==`selecting`&&(Me?await Ue(Me):await o.fitView({nodes:f,duration:200}))});let Ge=async(e,t=!1)=>{let n=P.column_level_lineage;e||ye(!1);let r=n!==void 0;await Xe({...P,column_level_lineage:e},!1,r),t||pe.push(n),e?.node_id?Ne(e.node_id):e||Ne(void 0)},Ke=async e=>{if(e){if(pe.length===0)return;let e=pe.pop();e?await Ge(e,!0):await Ge(void 0,!0)}else await Ge(void 0,!0)},qe=(e,t)=>{R||Ge({node_id:t.data.node.id,column:t.data.column})},Je=(t,n)=>{if(e&&x){if(se(n)){qe(t,n);return}if(Ve(),!R)Ne(n.id);else if(R===`action_result`){let e=Re.actionState.actions[n.id];e.run?.run_id&&ie(e.run.run_id),Ne(n.id)}else{let e=new Set(Fe);Fe.has(n.id)?e.delete(n.id):e.add(n.id),Ie(e),e.size===0&&Pe(void 0)}}},Ye=async e=>{let{viewOptions:t=P}=e,{fitView:n,preservePositions:r=!1}=e,s;if(!x)return;if(P.select!==t.select||P.exclude!==t.exclude||P.packages!==t.packages||P.view_mode!==t.view_mode){try{let e=await C({select:t.select,exclude:t.exclude,packages:t.packages,view_mode:t.view_mode},i);t={...t,column_level_lineage:void 0},s=e.nodes}catch(e){if(e instanceof mn){let t=e;jt.create({title:`Select node error`,description:t.response?.data.detail??e.message,type:`error`,closable:!0})}return}Ne(void 0)}else s=f.map(e=>e.id);let c;if(t.column_level_lineage){let e={...t.column_level_lineage,change_analysis:t.column_level_lineage.change_analysis??ve};try{c=await Se.mutateAsync(e);let t=c;e.change_analysis&&t&&(Ce.current={pending:!0,cllData:t},a.setQueryData(A.lineage(),e=>e&&{...e,lineage:{...e.lineage,diff:Po(e.lineage.diff,t)}}))}catch(e){if(e instanceof mn){let t=e;jt.create({title:`Column Level Lineage error`,description:t.response?.data.detail??e.message,type:`error`,closable:!0});return}}}else ye(!1);let l;r&&(l=ze());let[u,m,h]=await $a(x,{selectedNodes:s,cll:c,existingPositions:l});p(u),y(m),Te(h),_e(c),ue(u,t.view_mode??`changed_models`,ve,!!t.column_level_lineage?.column,!!Me||!!N),N&&(w(N)||v(N)||E(N)||d(N)||g(N))&&N.params?.model&&!Ee(N.params.model)&&ae(),n&&(await new Promise(e=>setTimeout(e,1)),o.fitView({nodes:u,duration:200}))},Xe=async(e,t=!0,n=!1)=>{le(e),await Ye({viewOptions:e,fitView:t,preservePositions:n})},Ze=Ja();xn(()=>{let t=N?.type;if(e&&oe&&!(!t||[`query_diff`,`query`,`row_count`,`row_count_diff`].includes(t))&&!R){let e;(w(N)||v(N)||E(N)||d(N)||g(N))&&(e=N.params?.model);let t=new MouseEvent(`click`,{bubbles:!0,cancelable:!0,view:window});if(e){let n=Ee(e);n?ce(n)&&L!==n.data.data&&Je(t,n):Xe({...P,view_mode:`all`})}else He()}},[N,P,oe,R,Ee,L,e]);let Qe=(e,t=1e3)=>{R===`action_result`||x===void 0||(R||(Pe(`selecting`),Re.reset(),P.column_level_lineage&&Xe({...P,column_level_lineage:void 0})),Ie(fe(Fe,ge(x,[e],t))))},et=(e,t=1e3)=>{R===`action_result`||x===void 0||(R||(Pe(`selecting`),Re.reset(),P.column_level_lineage&&Xe({...P,column_level_lineage:void 0})),Ie(fe(Fe,me(x,[e],t))))},tt=(t,n)=>{if(!e||R===`action_result`)return;t.preventDefault();let r=u.current,i=r.getBoundingClientRect(),a=t.clientX-i.left,o=t.clientY-i.top+r.offsetTop;Be.showContextMenu(a,o,n)},nt=e=>{if(!R){if(!x)return;Ie(new Set([e])),Pe(`selecting`),Ne(void 0),Re.reset()}else if(R===`selecting`){let t=new Set(Fe);Fe.has(e)?t.delete(e):t.add(e),Ie(t),t.size===0&&Pe(void 0)}},rt=()=>{Pe(void 0),Ie(new Set),Ne(void 0),ae(),O?.()},it={interactive:e,nodes:f,focusedNode:L,selectedNodes:Le,viewOptions:P,showContextMenu:tt,onViewOptionsChanged:Xe,selectMode:R,selectNode:nt,selectParentNodes:Qe,selectChildNodes:et,deselect:rt,isNodeHighlighted:e=>z.has(e),isNodeSelected:e=>Fe.has(e),isEdgeHighlighted:(e,t)=>F?e in F.current.parent_map?t in F.current.parent_map[e]:!1:z.has(e)&&z.has(t),isNodeShowingChangeAnalysis:e=>{if(!x||!ve)return!1;let t=e in x.nodes?x.nodes[e]:void 0,n=P.column_level_lineage;return n?.node_id&&!n.column?n.node_id===e&&!!t?.data.changeStatus:!!t?.data.changeStatus},changeAnalysisMode:ve,setChangeAnalysisMode:ye,getNodeAction:e=>Re.actionState.actions[e],getNodeColumnSet:e=>e in we?new Set(we[e]):new Set,runRowCount:async()=>{R===`selecting`?(await Re.runRowCount(),en({type:`row_count`,selected:`multi`})):L?(j(`row_count`,{node_names:[L.data.name]},{showForm:!1,showLast:!1}),en({type:`row_count`,selected:`single`})):(j(`row_count`,{select:P.select,exclude:P.exclude,packages:P.packages,view_mode:P.view_mode}),en({type:`row_count`,selected:`none`}))},runRowCountDiff:async()=>{R===`selecting`?(await Re.runRowCountDiff(),en({type:`row_count_diff`,selected:`multi`})):L?(j(`row_count_diff`,{node_names:[L.data.name]},{showForm:!1,showLast:!1}),en({type:`row_count_diff`,selected:`single`})):(j(`row_count_diff`,{select:P.select,exclude:P.exclude,packages:P.packages,view_mode:P.view_mode}),en({type:`row_count_diff`,selected:`none`}))},runValueDiff:async()=>{if(L)j(`value_diff`,{model:L.data.name},{showForm:!0,showLast:!1}),en({type:`value_diff`,selected:`single`});else{let e=R===`selecting`?Le.length:Ae.length;await Ze.confirm(e)&&(await Re.runValueDiff(),en({type:`value_diff`,selected:R===`selecting`?`multi`:`none`}))}},addLineageDiffCheck:async()=>{let e=await ne(P,i),t;t=R===`selecting`?`multi`:L?`single`:`none`,en({type:`lineage_diff`,selected:t}),e&&(await a.invalidateQueries({queryKey:A.checks()}),We(e))},addSchemaDiffCheck:async()=>{let e;R===`selecting`?Le.length>0&&(e=await Re.addSchemaDiffCheck(),rt(),en({type:`schema_diff`,selected:`multi`})):L?(e=await _({node_id:L.id},i),en({type:`schema_diff`,selected:`single`})):(e=await _({select:P.select,exclude:P.exclude,packages:P.packages,view_mode:P.view_mode},i),en({type:`schema_diff`,selected:`none`})),e&&(await a.invalidateQueries({queryKey:A.checks()}),We(e))},cancel:Re.cancel,actionState:Re.actionState,centerNode:Ue,cll:F,showColumnLevelLineage:Ge,resetColumnLevelLineage:Ke};return T?W(zo,{}):D?W(Bo,{error:D,onRetry:S}):!x||f==ja?W(U,{}):ke===`changed_models`&&!x.modifiedSet.length?W(Vo,{viewOptions:P,onViewOptionsChanged:Xe}):G(he.Provider,{value:it,children:[G(at,{sizes:L?[70,30]:[100,0],minSize:0,gutterSize:5,className:L?void 0:`split-gutter-hidden`,style:{height:`100%`,width:`100%`},children:[G(J,{ref:s,divider:W(Bn,{sx:{borderColor:`grey.200`}}),spacing:0,sx:{contain:`strict`,position:`relative`},children:[e&&G(U,{children:[W(es,{}),k.mode===`metadata only`&&W(Io,{})]}),G(Cr,{proOptions:{hideAttribution:!0},nodeTypes:ka,edgeTypes:Aa,nodes:f,edges:h,onNodesChange:m,onEdgesChange:b,onNodeClick:Je,onNodeContextMenu:tt,onClick:Ve,onInit:async()=>{if(De)await o.fitView();else{let e=Er(f,{});await o.setCenter(e.x+e.width/2,e.y+e.height/2,{zoom:1})}},maxZoom:1,minZoom:.1,nodesDraggable:e,ref:u,colorMode:r?`dark`:`light`,children:[W(hr,{id:`lineage-bg`,variant:gr.Dots,color:r?be.neutral[700]:be.neutral[300],gap:20,size:2}),W(yr,{showInteractive:!1,position:`top-right`,className:$e,style:{backgroundColor:r?be.neutral[700]:void 0,borderColor:r?be.neutral[600]:void 0},children:W(vr,{title:`copy image`,onClick:async()=>{await c(),Kt({type:ke,from:`lineage_view`})},style:{backgroundColor:r?be.neutral[700]:void 0,color:r?be.neutral[200]:void 0},children:W(K,{component:ui})})}),W(l,{}),W(xr,{position:`bottom-left`,children:G(J,{spacing:`5px`,children:[De&&W(gt,{variant:`changeStatus`}),P.column_level_lineage&&W(gt,{variant:`transformation`})]})}),W(xr,{position:`top-center`,children:W(Ya,{notification:ee?W(Ro,{}):null,type:`info`})}),W(xr,{position:`top-left`,children:G(J,{spacing:`5px`,children:[W($i,{action:Se}),f.length==0&&W(Y,{sx:{fontSize:`1.25rem`,color:`grey`,opacity:.5},children:`No nodes`})]})}),W(br,{nodeColor:Ma,nodeStrokeWidth:3,zoomable:!0,pannable:!0,bgColor:r?be.neutral[800]:void 0,maskColor:r?`${be.neutral[900]}99`:`${be.neutral[100]}99`}),R===`action_result`&&W(xr,{position:`bottom-center`,className:`ignore-screenshot`,children:W(Qi,{onClose:()=>{rt()}})})]}),W(Za,{...Be.props})]}),L?W(K,{sx:{borderLeft:`solid 1px`,borderColor:`divider`,height:`100%`},children:W(No,{node:L,onCloseNode:He})}):W(K,{})]}),Ze.AlertDialog]})}const ns=vn(ts);function rs(){return W(wr,{children:W(ns,{interactive:!0})})}function is(){let{apiClient:e}=Oe(),{data:t,isLoading:n,error:r}=fn({queryKey:A.user(),queryFn:()=>Bt(e),retry:!1}),{data:i}=fn({queryKey:[`github-avatar`,t?.id],queryFn:()=>t?zt(t.id):Promise.resolve(null),enabled:!!t?.id&&t.login_type===`github`,retry:!1,staleTime:300*1e3}),[a,o]=H(null),s=!!a,c=e=>{o(e.currentTarget)},l=()=>{o(null)},u=!n&&!r&&t;return G(U,{children:[n?W(K,{onClick:c,sx:{width:32,height:32,borderRadius:`50%`,bgcolor:`background.paper`,color:`primary.main`,display:`flex`,alignItems:`center`,justifyContent:`center`,cursor:`pointer`},children:W(Vn,{size:16})}):W(Xr,{onClick:c,src:i||void 0,sx:{width:28,height:28,cursor:`pointer`,outline:`1px solid white`,fontSize:`0.875rem`},children:(e=>e?e.charAt(0).toUpperCase():`U`)(t?.login)}),G(Lr,{anchorEl:a,open:s,onClose:l,slotProps:{paper:{sx:{bgcolor:`background.paper`,borderColor:`divider`,boxShadow:3,minWidth:180}}},children:[G(K,{sx:{px:2,py:1.5},children:[n&&G(K,{sx:{display:`flex`,alignItems:`center`,gap:1},children:[W(Y,{variant:`body2`,color:`text.primary`,children:`Loading...`}),W(Vn,{size:16})]}),r&&W(Y,{variant:`caption`,color:`error`,children:`Failed to load user information`}),u&&G(U,{children:[W(Y,{variant:`body2`,fontWeight:`600`,color:`text.primary`,children:t.login}),t.email&&W(Y,{variant:`caption`,color:`text.secondary`,children:t.email})]})]}),W(Bn,{}),G(Q,{onClick:()=>{window.open(`https://cloud.datarecce.io/`,`_blank`),l()},children:[W(si,{children:W(Hn,{})}),W(ci,{children:`Recce Cloud`})]}),G(Q,{onClick:()=>{window.open(Vt,`_blank`),l()},children:[W(si,{children:W(Jn,{})}),W(ci,{children:`Get live support`})]})]})]})}const as=()=>{let{setTheme:e,resolvedTheme:t}=Pn(),[n,r]=H(!1);xn(()=>{r(!0)},[]);let i=()=>{e(t===`dark`?`light`:`dark`)};if(!n)return W(X,{size:`small`,sx:{color:`rgba(255, 255, 255, 0.8)`,"&:hover":{bgcolor:`rgba(255, 255, 255, 0.1)`}},disabled:!0,children:W(ur,{style:{width:18,height:18}})});let a=t===`dark`;return W(Z,{title:a?`Switch to light mode`:`Switch to dark mode`,children:W(X,{size:`small`,onClick:i,sx:{color:`rgba(255, 255, 255, 0.8)`,"&:hover":{bgcolor:`rgba(255, 255, 255, 0.1)`}},"aria-label":a?`Switch to light mode`:`Switch to dark mode`,children:W(a?ur:ir,{style:{width:18,height:18}})})})};function os(e,t,n,r){let i=e?.git,a=e?.pullRequest,o=e?.dbt?.base,s=e?.dbt?.current,c={review_mode:t||!1,adapter_type:e?.adapterType||null,has_git_info:!Rr(i),has_pr_info:!Rr(a)};return e?.adapterType===`dbt`&&(c.base={schema_count:n.size,dbt_version:o?.dbt_version||null,timestamp:o?.generated_at||null},c.current={schema_count:r.size,dbt_version:s?.dbt_version||null,timestamp:s?.generated_at||null},c.schemas_match=n.size===r.size&&Array.from(n).every(e=>r.has(e))),e?.adapterType===`sqlmesh`&&(c.base={has_env:!!e.sqlmesh?.base_env},c.current={has_env:!!e.sqlmesh?.current_env}),c}function ss(e){return Object.values(e).every(e=>e===null)?[W(K,{sx:{ml:`10px`},children:`No information`},`no info`)]:Object.entries(e).filter(([e,t])=>e!==`url`&&t!=null).map(([e,t])=>G(`li`,{style:{marginLeft:`10px`},children:[e,`: `,t]},e))}function cs(){let{envInfo:e,reviewMode:t,lineageGraph:n}=M(),[r,i]=H(!1),a=e?.git,o=e?.pullRequest,s={...a,...o},c=e?.dbt?.base,l=e?.dbt?.current,u=c?.generated_at?kt(c.generated_at):``,d=l?.generated_at?kt(l.generated_at):``,f=``,p=``;c&&(f=c.generated_at?Mt(c.generated_at):``),l&&(p=l.generated_at?Mt(l.generated_at):``);let[m,h]=Lt(n),g=wn(!1);xn(()=>{!g.current&&e&&(g.current=!0,qt(os(e,t,m,h)))},[e,t,m,h]);let _=()=>i(!0),v=()=>i(!1);return G(U,{children:[W(Z,{title:`Environment Info`,placement:`bottom-end`,children:G(K,{sx:{display:`flex`,alignItems:`center`,cursor:`pointer`,"&:hover":{color:`text.primary`}},onClick:_,children:[G(J,{direction:`column`,sx:{display:{xs:`none`,lg:`flex`},fontSize:`0.875rem`},children:[G(K,{sx:{display:`flex`,alignItems:`baseline`,gap:.5},children:[W(Y,{component:`span`,noWrap:!0,sx:{color:`warning.main`,maxWidth:128},className:`no-track-pii-safe`,children:Array.from(m).join(`, `)}),G(Y,{component:`span`,noWrap:!0,children:[`(`,f,`)`]})]}),G(K,{sx:{display:`flex`,alignItems:`baseline`,gap:.5},children:[W(Y,{component:`span`,noWrap:!0,sx:{color:`primary.main`,maxWidth:128},className:`no-track-pii-safe`,children:Array.from(h).join(`, `)}),G(Y,{component:`span`,noWrap:!0,children:[`(`,p,`)`]})]})]}),W(X,{size:`small`,"aria-label":`Environment Info`,children:W(K,{component:nr,sx:{fontSize:16,verticalAlign:`middle`}})})]})}),G(Tn,{open:r,onClose:v,maxWidth:`sm`,fullWidth:!0,children:[G(On,{sx:{display:`flex`,alignItems:`center`},children:[`Environment Information`,W(K,{sx:{flexGrow:1}}),W(X,{size:`small`,onClick:v,children:W(Ln,{})})]}),W(Dn,{children:G(J,{direction:`column`,spacing:1,children:[t?G(J,{direction:`column`,spacing:.5,children:[W(Y,{variant:`h6`,sx:{fontSize:`1rem`},children:`Review Information`}),G(`ul`,{style:{margin:0,paddingLeft:`20px`},children:[s.url&&G(`li`,{style:{marginLeft:`10px`},children:[`url:`,` `,G(kn,{href:s.url,target:`_blank`,sx:{color:`primary.main`},children:[s.url,` `,W(An,{})]})]}),!Rr(s)&&ss(s)]})]}):G(J,{direction:`column`,spacing:.5,children:[W(Y,{variant:`h6`,sx:{fontSize:`1rem`},children:`Dev Information`}),W(`ul`,{style:{margin:0,paddingLeft:`20px`},children:a&&ss(a)})]}),W(Bn,{}),e?.adapterType===`dbt`&&G(J,{direction:`column`,spacing:.5,children:[W(Y,{variant:`h6`,sx:{fontSize:`1rem`},children:`DBT`}),W(Ai,{sx:{border:1,borderColor:`divider`,maxHeight:`30rem`},children:G(Oi,{size:`small`,stickyHeader:!0,children:[W(ji,{children:G(Mi,{children:[W($,{}),W($,{children:`base`}),W($,{children:`current`})]})}),G(ki,{children:[G(Mi,{children:[W($,{children:`schema`}),W($,{className:`no-track-pii-safe`,children:Array.from(m).map(e=>W(Z,{title:e,placement:`bottom`,children:W(`div`,{className:`max-w-72 truncate`,children:e})},e))}),W($,{className:`no-track-pii-safe`,children:Array.from(h).map(e=>W(Z,{title:e,placement:`bottom`,children:W(`div`,{className:`max-w-72 truncate`,children:e})},e))})]}),G(Mi,{children:[W($,{children:`version`}),W($,{children:c?.dbt_version}),W($,{children:l?.dbt_version})]}),G(Mi,{children:[W($,{children:`timestamp`}),W($,{children:u}),W($,{children:d})]})]})]})})]}),e?.adapterType===`sqlmesh`&&G(J,{direction:`column`,spacing:.5,children:[W(Y,{variant:`h6`,sx:{fontSize:`1rem`},children:`SQLMesh`}),W(Ai,{sx:{border:1,borderColor:`divider`,maxHeight:`30rem`},children:G(Oi,{stickyHeader:!0,children:[W(ji,{children:G(Mi,{children:[W($,{}),W($,{children:`base`}),W($,{children:`current`})]})}),W(ki,{children:G(Mi,{children:[W($,{children:`Environment`}),W($,{className:`no-track-pii-safe`,children:e.sqlmesh?.base_env}),W($,{className:`no-track-pii-safe`,children:e.sqlmesh?.current_env})]})})]})})]})]})}),W(En,{children:W(q,{color:`iochmara`,onClick:v,children:`Close`})})]})]})}const ls=()=>({toastSuccess:e=>{jt.create({description:e,type:`success`,duration:5e3,closable:!0})},toastError:(e,t)=>{let n=e;t!=null&&(n=hn(t)?`${e}. ${String(t.response?.data?.detail)}`:`${e}. ${t}`),jt.create({description:n,type:`error`,duration:5e3,closable:!0})}}),us=e=>{xn(()=>{let t=e=>{e.preventDefault()};return e&&window.addEventListener(`beforeunload`,t),()=>{e&&window.removeEventListener(`beforeunload`,t)}},[e])},ds=()=>{let{featureToggles:e}=I(),{fileName:t,cloudMode:n,isDemoSite:r,envInfo:i}=M(),{apiClient:a}=Oe(),[o,c]=H(!1),[l,u]=H(!1),d=!t&&!n&&!r,{data:p}=s(d),h=p!=null&&p.filter(e=>!e.is_preset).length>0;us(d&&h);let[{newFileName:g,errorMessage:_,modified:v,overwriteWithMethod:y,bypass:b},x]=H({newFileName:t??`recce_state.json`,bypass:!1}),S=wn(null),{toastSuccess:C,toastError:w}=ls(),T=pn(),E=()=>{x({newFileName:t??`recce_state.json`,modified:!t,bypass:!1}),c(!0)},D=()=>c(!1),O=()=>u(!1),k=async(e,t)=>{if(!g)return;let n=localStorage.getItem(f.bypassSaveOverwrite)===`true`;try{e===`save`?await m({filename:g,overwrite:t??n},a):await ee({filename:g,overwrite:t??n},a),C(e===`save`?`Save file successfully`:`Rename file successfully`),await T.invalidateQueries({queryKey:A.lineage()}),b&&localStorage.setItem(f.bypassSaveOverwrite,`true`)}catch(t){if(hn(t)&&t.response?.status===409){x(t=>({...t,overwriteWithMethod:e})),u(!0);return}w(e===`save`?`Save file failed`:`Rename file failed`,t)}finally{D()}},te=()=>{O(),c(!0),x(e=>({...e,overwriteWithMethod:void 0}))};if(n||r)return W(U,{});let ne=`New Instance`+(h?` (unsaved)`:``),re;if(e.disableSaveToFile&&t){let e=i?.stateMetadata?.generated_at,n=e?Ne(new Date(e)):null;re=n?`${t} (${n})`:null}return G(U,{children:[G(J,{direction:`row`,alignItems:`center`,justifyContent:`center`,children:[W(K,{sx:{fontWeight:600},children:re??t??ne}),!e.disableSaveToFile&&W(Z,{title:t?`Change Filename`:`Save`,enterDelay:1e3,children:W(X,{onClick:E,"aria-label":t?`Change Filename`:`Save`,size:`small`,children:W(K,{component:t?or:jn,sx:{fontSize:16,verticalAlign:`middle`}})})})]}),G(Tn,{open:o,onClose:D,children:[G(On,{sx:{display:`flex`,alignItems:`center`},children:[t?`Change Filename`:`Save File`,W(K,{sx:{flexGrow:1}}),W(X,{size:`small`,onClick:D,children:W(Ln,{})})]}),W(Dn,{onKeyDown:e=>{e.stopPropagation()},children:W(Gr,{inputRef:S,value:g,label:`File name`,placeholder:`Enter filename`,error:!!_,helperText:_,fullWidth:!0,size:`small`,sx:{mt:1},onChange:e=>{let n=e.target.value,r;n?n.endsWith(`.json`)?/^[a-zA-Z0-9 _-]+\.json$/.test(n)?t&&n===t&&(r=`Filename is the same as the current one.`):r=`Invalid filename. Only alphanumeric, space, _ and - are allowed.`:r=`Filename must end with .json.`:r=`Filename cannot be empty.`,x(e=>({...e,modified:!0,newFileName:n,errorMessage:r}))},onKeyDown:e=>{if(e.key===`Enter`){if(_)return;k(t?`rename`:`save`)}else e.key===`Escape`&&D()}})}),G(En,{sx:{gap:`5px`},children:[W(q,{size:`small`,color:t?`inherit`:`iochmara`,variant:`contained`,onClick:async()=>{await k(`save`)},disabled:!g||!!_||!v,children:t?`Save as New File`:`Confirm`}),t&&W(q,{size:`small`,color:`iochmara`,variant:`contained`,onClick:async()=>{await k(`rename`)},disabled:!g||!!_||!v,children:`Rename`})]})]}),G(Tn,{open:l,onClose:O,children:[G(On,{sx:{display:`flex`,alignItems:`center`},children:[`Overwrite File?`,W(K,{sx:{flexGrow:1}}),W(X,{size:`small`,onClick:O,children:W(Ln,{})})]}),G(Dn,{sx:{borderTop:`solid 1px`,borderBottom:`solid 1px`,borderColor:`divider`},onKeyDown:e=>{e.stopPropagation()},children:[W(Y,{sx:{fontSize:`12pt`},children:y===`save`?`Saving a file with this name will overwrite the existing file. Are you sure you wish to continue?`:`Renaming the file with this name will overwrite the existing file. Are you sure you wish to continue?`}),W(Nr,{control:W(Mr,{size:`small`,checked:b,onChange:e=>{x(t=>({...t,bypass:e.target.checked}))}}),label:W(Y,{sx:{fontWeight:`bold`,pt:`8px`},children:`Don't show this again`})})]}),G(En,{sx:{gap:`5px`},children:[W(q,{variant:`outlined`,onClick:te,size:`small`,children:`Back`}),W(q,{size:`small`,color:`iochmara`,variant:`contained`,onClick:()=>{y&&(k(y,!0),O())},children:`Overwrite`})]})]})]})};function fs(){let{featureToggles:e}=I(),{apiClient:t}=Oe(),n=async()=>{try{let e=await k(t),n=JSON.stringify(e,null,2);jr(new Blob([n],{type:`application/json`}),`recce-state-${Qr(new Date,`yyyy-MM-dd-HH-mm-ss`)}.json`)}catch(e){console.error(`Export failed`,e),jt.create({title:`Export failed`,description:String(e),type:`error`,duration:5e3,closable:!0})}};return W(Z,{title:`Export`,children:W(X,{size:`small`,"aria-label":`Export state`,onClick:async()=>{await n(),sn({name:`export`})},disabled:e.disableExportStateFile,children:W(K,{component:tr,sx:{verticalAlign:`middle`,width:`16px`,height:`16px`}})})})}const ps=[`Processing...`,`Still processing, please wait...`,`Almost there, thanks for your patience...`];function ms(){let{successToast:e,failToast:t}=At(),[,n]=Pr(),{authed:r}=I(),{shareUrl:i,isLoading:a,error:o,handleShareClick:s}=xt(),[c,l]=H(!1),[u,d]=H(0),[f,p]=H(a);a!==f&&(p(a),a&&d(0)),Fr(()=>{d(e=>Math.min(e+1,ps.length-1))},a?3e4:null),xn(()=>{o&&t(`Failed to share state`,o)},[o,t]);let m=async()=>{try{await n(String(i)),e(`Copied the link to clipboard`)}catch(e){t(`Failed to copy the link`,e)}};return r?G(J,{direction:`row`,sx:{flex:1,alignItems:`center`,gap:`5px`},children:[W(q,{size:`xsmall`,variant:`outlined`,color:`neutral`,startIcon:W(ai,{}),endIcon:i?W(K,{component:Qn,sx:{color:`success.main`}}):void 0,onClick:async()=>{await s(),an({name:`create`})},disabled:a,children:a?`Sharing...`:`Share`}),a&&W(Y,{sx:{fontSize:14,color:`grey.500`},children:ps[u]}),W(J,{direction:`row`,spacing:.5,alignItems:`center`,children:i&&G(U,{children:[W(K,{sx:{overflowX:`auto`,whiteSpace:`nowrap`,maxWidth:`350px`},children:W(Y,{sx:{fontSize:14},children:i})}),W(X,{size:`small`,"aria-label":`Copy the share URL`,onClick:async()=>{await m(),an({name:`copy`})},children:W(er,{})})]})})]}):G(J,{direction:`row`,sx:{flex:1,alignItems:`center`},children:[W(q,{size:`xsmall`,color:`neutral`,variant:`outlined`,onClick:()=>{l(!0)},startIcon:W(ai,{}),children:`Share`}),c&&W(vt,{parentOpen:c,handleParentClose:l,ignoreCookie:!0,variant:`enable-share`})]})}function hs(e){return/^\/checks\/([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/.test(e)}function gs(){return W(Z,{title:`Syncing`,children:W(K,{sx:{mx:`10px`},children:W(Vn,{size:20})})})}function _s(){let[e,t]=H(!1),n=pn(),{apiClient:r}=Oe(),i=ni(),a=ti(),{basePath:o}=ue(),[s,c]=H(!1),[l,u]=H(``),{data:d}=j(),f=()=>c(!1),p=B(async e=>{if(c(!1),t(!0),(await O(e,r)).status===`conflict`){c(!0),t(!1);return}for(;await x(r);)await new Promise(e=>setTimeout(e,1e3));jt.create({description:`Sync Completed`,type:`success`,duration:5e3,closable:!0}),t(!1),u(``),await n.invalidateQueries({queryKey:A.lineage()}),await n.invalidateQueries({queryKey:A.checks()}),await n.invalidateQueries({queryKey:A.runs()}),hs(a)&&i.push(`${o}/checks`)},[n,a,r,i.push,o]);return e?W(gs,{}):G(U,{children:[W(Z,{title:`Sync with Cloud`,children:W(X,{size:`small`,"aria-label":`Sync state`,onClick:()=>p(d?.session_id?{method:`merge`}:{}),children:W(K,{component:Rn,sx:{fontSize:16,verticalAlign:`middle`}})})}),G(Tn,{open:s,onClose:f,children:[G(On,{sx:{display:`flex`,alignItems:`center`,fontWeight:`bold`},children:[`Sync with Cloud`,W(K,{sx:{flexGrow:1}}),W(X,{size:`small`,onClick:f,children:W(Ln,{})})]}),G(Dn,{children:[W(Y,{children:`New changes have been detected in the cloud. Please choose a method to sync your state`}),W(K,{sx:{mt:`5px`},children:W(Di,{value:l,onChange:e=>{u(e.target.value)},children:G(J,{direction:`column`,children:[W(Nr,{value:`merge`,control:W(Ei,{}),label:G(J,{direction:`row`,alignItems:`center`,children:[`Merge`,W(Z,{title:`This will merge the local and remote states.`,children:W(K,{component:nr,sx:{ml:2,cursor:`pointer`}})})]})}),W(Nr,{value:`overwrite`,control:W(Ei,{}),label:G(J,{direction:`row`,alignItems:`center`,children:[`Overwrite`,W(Z,{title:`This will overwrite the remote state file with the local state.`,children:W(K,{component:nr,sx:{ml:2,cursor:`pointer`}})})]})}),W(Nr,{value:`revert`,control:W(Ei,{}),label:G(J,{direction:`row`,alignItems:`center`,children:[`Revert`,W(Z,{title:`This will discard local changes and revert to the cloud state.`,children:W(K,{component:nr,sx:{ml:2,cursor:`pointer`}})})]})})]})})})]}),G(En,{children:[W(q,{onClick:f,sx:{mr:1},children:`Cancel`}),W(q,{color:`iochmara`,variant:`contained`,onClick:()=>p({method:l||void 0}),disabled:!l,children:`Sync`})]})]})]})}const vs=[{path:`/lineage`,name:`Lineage`},{path:`/query`,name:`Query`},{path:`/checks`,name:`Checklist`}];function ys({queryKey:e,fetchCallback:t,selectCallback:n}){let{data:r,isLoading:i,error:a}=fn({queryKey:e,queryFn:t,select:n});return i||a||r===0?W(U,{}):W(K,{bgcolor:`brand.main`,display:`flex`,justifyContent:`center`,alignItems:`center`,p:1,borderRadius:`100%`,color:`white`,fontWeight:700,fontSize:`0.75rem`,children:W(`span`,{children:r})})}function bs(){let{apiClient:e}=Oe();return W(ys,{queryKey:A.checks(),fetchCallback:()=>b(e),selectCallback:e=>e.filter(e=>!e.is_checked).length})}const xs=()=>{let e=ti(),{isDemoSite:t,isLoading:n,cloudMode:r}=M(),{featureToggles:i}=I(),{data:a,isLoading:o}=F(),s=wn(null);return xn(()=>{s.current&&s.current!==e&&tn({from:s.current,to:e}),s.current=e},[e]),W(K,{sx:{borderBottom:`1px solid lightgray`,px:`12px`},children:G(K,{sx:{display:`grid`,gridTemplateColumns:`1fr auto 1fr`,width:`100%`,alignItems:`center`},children:[W(qr,{value:V(()=>e.startsWith(`/checks`)?`/checks`:e.startsWith(`/query`)?`/query`:e.startsWith(`/runs`)?`/runs`:`/lineage`,[e]),sx:{borderBottom:`none`,minHeight:`auto`},children:vs.map(({path:e,name:t})=>t===`Query`&&a?.single_env_onboarding?null:t===`Checklist`&&bs?W(Kr,{value:e,disabled:n||o,sx:{p:0},label:W(K,{sx:{display:`flex`,alignItems:`center`,gap:`4px`},children:G(Fn,{href:e,style:{textDecoration:`none`,color:`inherit`,padding:`0.875rem 1.1875rem`,display:`flex`,gap:3,alignItems:`center`},children:[t,` `,W(bs,{})]})})},e):W(Kr,{value:e,disabled:n||o,sx:{p:0},label:W(K,{sx:{display:`flex`,alignItems:`center`,gap:`4px`},children:W(Fn,{href:e,style:{textDecoration:`none`,color:`inherit`,padding:`0.875rem 1.1875rem`},children:t})})},e))}),G(K,{sx:{display:`flex`,alignItems:`center`,gap:`12px`,justifyContent:`center`},children:[!n&&!t&&W(ds,{}),!n&&!t&&!a?.single_env_onboarding&&!i.disableShare&&W(ms,{})]}),!n&&G(K,{sx:{display:`flex`,justifyContent:`right`,alignItems:`center`,mr:`8px`},children:[W(cs,{}),r&&W(_s,{}),W(fs,{})]})]})})};function Ss(){let{remainingSeconds:e,isEnabled:t}=N();return!t||e===null||e>60?null:G(Ni,{color:`warning`,variant:`standard`,sx:{display:`flex`,alignItems:`center`,gap:1,fontSize:`0.75rem`,mr:2},children:[W(K,{component:zn,sx:{display:`inline-flex`}}),`Idle timeout: `,It(e,`compact`)]})}const Cs=()=>{let{version:e,latestVersion:t}=T(),n=V(()=>RegExp(`^\\d+\\.\\d+\\.\\d+$`),[]);return xn(()=>{if(n.test(e)&&e!==t){let e=`recce-update-toast-shown`;if(sessionStorage.getItem(e))return;setTimeout(()=>{jt.create({id:`recce-update-available`,title:`Update available`,description:G(`span`,{children:[`A new version of Recce (v`,t,`) is available.`,W(`br`,{}),`Please run`,` `,W(K,{component:`code`,sx:{bgcolor:`grey.200`,px:.5,py:.25,borderRadius:.5,fontFamily:`monospace`,fontSize:`0.875em`},children:`pip install --upgrade recce`}),` `,`to update Recce.`,W(`br`,{}),W(kn,{sx:{color:`primary.main`,fontWeight:`bold`,"&:hover":{textDecoration:`underline`}},href:`https://github.com/DataRecce/recce/releases/tag/v${t}`,target:`_blank`,children:`Click here to view the detail of latest release`})]}),duration:60*1e3,closable:!0}),sessionStorage.setItem(e,`true`)},0)}},[e,t,n]),n.test(e)?W(kn,{href:`https://github.com/DataRecce/recce/releases/tag/v${e}`,sx:{"&:hover":{textDecoration:`none`},fontSize:`sm`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75},target:`_blank`,children:e}):W(Y,{component:`span`,sx:{fontSize:`sm`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75},children:e})};function ws({icon:e,href:t,sx:n,...r}){let i=Nn();return W(kn,{sx:{height:`20px`,color:`common.white`,...n},href:t,target:`_blank`,...r,children:W(e,{style:{color:i.palette.common.white,width:20,height:20}})})}const Ts=()=>{let{reviewMode:e,isDemoSite:t,envInfo:n,cloudMode:r}=M(),{featureToggles:i,authed:a}=I(),{url:o,id:s}=n?.pullRequest??{},c=o?o.split(`/`).pop():null,l=r||a?`https://cloud.datarecce.io/`:`https://reccehq.com/`,[u,d]=H(!1);return G(K,{sx:{display:`flex`,gap:`10px`,minHeight:`40px`,alignItems:`center`,bgcolor:be.brand[400]},children:[W(kn,{href:l,target:`_blank`,sx:{"&:hover":{textDecoration:`none`}},children:G(K,{sx:{display:`flex`,gap:`10px`,alignItems:`center`},children:[W(K,{component:`img`,sx:{width:20,height:20,ml:`18px`},src:`/logo/recce-logo-white.png`,alt:`recce-logo-white`}),W(Y,{variant:`h4`,sx:{fontFamily:`"Montserrat", sans-serif`,color:`common.white`,fontSize:`1.25rem`},children:`RECCE`})]})}),W(as,{}),W(Cs,{}),(i.mode??e)&&W(Ni,{sx:{fontSize:`0.875rem`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75,borderColor:`rgba(255,255,255,0.8)`},children:i.mode??`review mode`}),r&&s&&W(Ni,{sx:{fontSize:`0.875rem`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75,borderColor:`rgba(255,255,255,0.8)`},children:G(J,{direction:`row`,spacing:1,alignItems:`center`,children:[W(K,{children:`cloud mode`}),W(K,{sx:{borderLeft:`1px solid rgba(255,255,255,0.8)`,pl:`8px`},children:G(kn,{href:o,sx:{"&:hover":{textDecoration:`none`}},target:`_blank`,children:[W(Vr,{style:{color:`rgba(255,255,255,0.8)`,width:12,height:12,marginRight:2,display:`inline`,verticalAlign:`middle`}}),W(Y,{component:`span`,sx:{color:`rgba(255,255,255,0.8)`,display:`inline`},children:`#${String(s)}`})]})})]})}),t&&o&&c&&W(Ni,{sx:{fontSize:`0.875rem`,color:`rgba(255,255,255,0.8)`,textTransform:`uppercase`,borderWidth:1,px:1,borderRadius:.75,borderColor:`rgba(255,255,255,0.8)`},children:G(J,{direction:`row`,spacing:1,alignItems:`center`,children:[W(K,{children:`demo mode`}),W(K,{sx:{borderLeft:`1px solid rgba(255,255,255,0.8)`,pl:`8px`},children:G(kn,{href:o,sx:{"&:hover":{textDecoration:`none`}},target:`_blank`,children:[W(Vr,{style:{color:`rgba(255,255,255,0.8)`,width:12,height:12,marginRight:2,display:`inline`,verticalAlign:`middle`}}),W(Y,{component:`span`,sx:{color:`rgba(255,255,255,0.8)`,display:`inline`},children:`#${c}`})]})})]})}),W(K,{sx:{flex:1}}),(t||i.mode===`read only`)&&G(U,{children:[W(ws,{icon:Wn,href:`https://github.com/DataRecce/recce`}),W(ws,{icon:qn,href:`https://getdbt.slack.com/archives/C05C28V7CPP`}),W(ws,{sx:{mr:2},icon:Gn,href:`https://docs.reccehq.com`})]}),!t&&i.mode!==`read only`&&G(U,{children:[W(Ss,{}),a||r?W(K,{sx:{mr:2},children:W(is,{})}):G(U,{children:[W(K,{component:`button`,sx:{color:`common.white`,fontSize:`0.875rem`,fontWeight:600,bgcolor:`brand.700`,borderRadius:1,px:3,py:1,mr:2,cursor:`pointer`,border:`none`},onClick:()=>{d(!0)},children:`Connect to Cloud`}),u&&W(vt,{parentOpen:u,handleParentClose:d,ignoreCookie:!0,variant:`user-profile`})]})]})]})};function Es(){return W(K,{sx:{display:`flex`,height:`100%`,alignItems:`center`,justifyContent:`center`,contain:`size`},children:W(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:W(Vn,{size:48})})})}function Ds({children:e,lineage:t}){let n=ti(),{isDemoSite:r,isLoading:i,isCodespace:a}=M(),{featureToggles:o}=I(),s=n.replace(/\/$/,``)||`/`,c=s===`/lineage`||s===`/`;return xn(()=>{Zt()},[]),G(K,{sx:{display:`flex`,flexDirection:`column`,height:`100vh`,overflow:`hidden`},children:[W(Ts,{}),W(xs,{}),W(Os,{isLineageRoute:c,lineage:t,children:e}),!i&&!r&&!a&&o.mode===null&&W(vt,{})]})}function Os({children:e,lineage:t,isLineageRoute:n,disableInternalHistory:r=!1}){let{isRunResultOpen:i,isHistoryOpen:a,closeRunResult:o}=de(),{basePath:s}=ue(),{data:c}=F(),l=ti(),u=Et(),d=i&&!l.startsWith(`${s}/checks`),f=r?!1:a&&!l.startsWith(`${s}/checks`);return G(at,{sizes:f?[20,80]:[0,100],minSize:0,gutterSize:5,className:f?void 0:`split-gutter-hidden`,style:{height:`100%`},children:[W(K,{style:{contain:`size`},suppressHydrationWarning:!0,children:f&&W(Ae,{})}),G(bt,{sizes:d?[50,50]:[100,0],minSize:0,gutterSize:5,className:d?void 0:`split-gutter-hidden`,style:{flex:`1`,contain:`size`},children:[W(gn,{fallback:W(Es,{}),children:G(K,{sx:{p:0,contain:`content`,height:`100%`,position:`relative`},suppressHydrationWarning:!0,children:[W(K,{sx:{display:n?`block`:`none`,height:`100%`,position:n?`relative`:`absolute`,inset:0},children:t}),!n&&e]})}),W(K,{sx:{height:`100%`,bgcolor:u?`grey.900`:`grey.50`},suppressHydrationWarning:!0,children:d?W(L,{onClose:o,isSingleEnvironment:!!c?.single_env_onboarding}):null})]})]})}function ks({children:e,display:t}){let[n,r]=H(!1),i=wn(null),a=wn(null),o=B(()=>{i.current&&=(clearTimeout(i.current),null),r(!0)},[]),s=B(()=>{i.current=setTimeout(()=>{r(!1)},100)},[]);return t?G(U,{children:[W(K,{ref:a,onMouseEnter:o,onMouseLeave:s,sx:{display:`contents`},children:e}),G(Zr,{open:n,anchorEl:a.current,onClose:()=>r(!1),anchorOrigin:{vertical:`bottom`,horizontal:`left`},transformOrigin:{vertical:`top`,horizontal:`left`},disableAutoFocus:!0,disableEnforceFocus:!0,sx:{pointerEvents:`none`},slotProps:{paper:{onMouseEnter:o,onMouseLeave:s,sx:{bgcolor:`grey.600`,color:`white`,p:1.5,pointerEvents:`auto`}}},children:[`Connect to a data warehouse to unlock Diff.`,` `,W(kn,{href:Vt,target:`_blank`,sx:{color:`white`,textDecoration:`underline`},children:`Learn more`}),`.`]})]}):e}function As({checksOnly:e=!0}){let t=Et(),{featureToggles:n}=I(),r=pn(),{apiClient:i}=Oe(),a=wn(null),o=wn(null),[s,c]=H(null),[l,u]=H(!1),d=ni(),f=ti(),{basePath:m}=ue(),[,h]=_e(),g=B(async()=>{if(s){try{let{runs:t,checks:n}=await p(s,e,i);h?.(),await r.invalidateQueries({queryKey:A.checks()}),await r.invalidateQueries({queryKey:A.runs()}),f.includes(`/checks`)&&d.push(`${m}/checks`);let a=e?`${n} checks imported successfully`:`${t} runs and ${n} checks imported successfully`;jt.create({description:a,type:`info`,duration:5e3,closable:!0})}catch(e){console.error(`Import failed`,e),jt.create({title:`Import failed`,description:String(e),type:`error`,duration:5e3,closable:!0})}u(!1)}},[r,s,f,h,e,i,d.push,m]),_=()=>{a.current&&a.current.click()},v=e=>{e.target.files?.length===1&&(c(e.target.files[0]),u(!0)),a.current&&(a.current.value=``)},y=()=>u(!1),b=e?`checks`:`runs and checks`,{isDemoSite:x}=M();return G(U,{children:[W(Z,{title:`Import Checklist from State File`+(x?` (Disabled in the demo site)`:``),children:W(X,{sx:{pt:`6px`,color:t?`grey.300`:`grey.600`,"&:hover":{color:t?`grey.100`:`grey.800`},fontSize:20},"aria-label":`Import state`,onClick:()=>{_(),sn({name:`import`})},disabled:n.disableImportStateFile||x,children:W(bi,{})})}),W(`input`,{type:`file`,style:{display:`none`},ref:a,onChange:v}),G(Tn,{open:l,onClose:y,maxWidth:`sm`,fullWidth:!0,"aria-labelledby":`import-dialog-title`,children:[G(On,{id:`import-dialog-title`,sx:{display:`flex`,alignItems:`center`,fontWeight:`bold`},children:[`Import state`,W(K,{sx:{flexGrow:1}}),W(X,{size:`small`,onClick:y,children:W(Ln,{})})]}),W(Dn,{children:G(J,{direction:`column`,spacing:1,sx:{px:`5px`,borderRadius:1},children:[G(J,{direction:`row`,alignItems:`center`,spacing:.5,children:[W(K,{component:nr,sx:{color:`error.main`}}),W(Y,{component:`span`,sx:{fontWeight:500,color:`error.main`},children:`Caution!`})]}),G(Y,{children:[`The current `,b,` will be`,` `,W(Y,{component:`span`,sx:{fontWeight:600},children:`merged`}),` `,`with the imported state`]})]})}),G(En,{children:[W(q,{ref:o,onClick:y,children:`Cancel`}),W(q,{color:`iochmara`,variant:`contained`,onClick:g,sx:{ml:`5px`},children:`Import`})]})]})]})}function js({check:e},t){return W(K,{sx:{display:`flex`,flexDirection:`column`,height:`100%`},children:W(wr,{children:W(ns,{viewOptions:{...e.params,...e.view_options},interactive:!1,ref:t})})})}const Ms=vn(js),Ns=({node:e,selected:t,onSelect:n,schemaChanged:r,isDark:i})=>{let{icon:a}=tt(e.data.resourceType),{base:o,current:s}=e.data.data,c,l;return r?(c=z(`schema_diff`).icon,l=nt(`modified`).color):!o&&s?(c=nt(`added`).icon,l=nt(`added`).color):o&&!s&&(c=nt(`removed`).icon,l=nt(`removed`).color),W(Yr,{disablePadding:!0,children:G(K,{sx:{display:`flex`,width:`100%`,fontSize:`10pt`,p:`5px 8px`,cursor:`pointer`,"&:hover":{bgcolor:i?`grey.700`:`grey.200`},bgcolor:t?i?`grey.800`:`grey.100`:`inherit`,alignItems:`center`,gap:`5px`},onClick:()=>{n(e.id)},children:[a&&W(K,{component:a}),W(K,{sx:{flex:1,textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`},children:e.data.name}),c&&l&&W(K,{component:c,sx:{color:l}})]})})};function Ps({check:e},t){let n=Et(),{apiClient:r}=Oe(),{lineageGraph:i}=M(),a=e.params,{isLoading:o,error:s,data:c}=fn({queryKey:[...A.check(e.check_id),`select`],queryFn:async()=>C({select:a.select,exclude:a.exclude,packages:a.packages,view_mode:a.view_mode},r),refetchOnMount:!0,enabled:!a.node_id}),[l,u]=V(()=>{let e=[],t=[],n=[],r=[];if(a.node_id){let t=a.node_id instanceof Array?a.node_id:[a.node_id];for(let n of t){let t=i?.nodes[n];t&&e.push(t)}}else for(let t of c?.nodes??[]){let n=i?.nodes[t];n&&e.push(n)}let o=e.filter(e=>e.data.resourceType===`model`||e.data.resourceType===`seed`||e.data.resourceType===`source`||e.data.resourceType===`snapshot`);for(let e of o)Pt(e.data.data.base?.columns,e.data.data.current?.columns)?t.push(e.id):!e.data.data.base&&e.data.data.current?n.push(e.id):e.data.data.base&&!e.data.data.current&&r.push(e.id);function s(e){return t.includes(e.id)?3:n.includes(e.id)?2:r.includes(e.id)?1:0}return o.sort((e,t)=>{let n=s(e),r=s(t);return n===r?e.data.name.localeCompare(t.data.name):r-n}),[o,t]},[a.node_id,c?.nodes,i]),[d,f]=H(0);if(o)return W(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:n?`grey.900`:`grey.50`,height:`100%`},children:`Loading...`});if(s)return G(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:n?`grey.900`:`grey.50`,height:`100%`},className:`no-track-pii-safe`,children:[`Error: `,s.message]});if(l.length==0)return W(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:n?`grey.900`:`grey.50`,height:`100%`},children:`No nodes matched`});if(d<l.length){let e=l[d];return G(at,{sizes:[80,20],minSize:30,style:{height:`100%`},children:[W(io,{base:e.data.data.base,current:e.data.data.current,columnChanges:e.data.change?.columns,enableScreenshot:!0,showMenu:!1,ref:t}),W(Jr,{sx:{overflow:`auto`,bgcolor:`background.paper`,listStyle:`none`},children:l.map((e,t)=>W(Ns,{node:e,schemaChanged:u.includes(e.id),selected:t===d,isDark:n,onSelect:()=>{f(t)}},e.id))})]})}return W(U,{})}const Fs=vn(Ps);function Is({checkId:r,refreshCheckList:a}){let s=Nn(),l=Et(),{apiClient:u}=Oe(),{featureToggles:d,sessionId:f}=I(),{setLatestSelectedCheckId:p}=Ct(),{cloudMode:m}=M(),h=pn(),g=ni(),{basePath:_}=ue(),{setSqlQuery:v,setBaseSqlQuery:y,setCustomQueries:b,setPrimaryKeys:x}=Ie(),{successToast:S,failToast:C}=At(),[w,T]=H(),[E]=H(),[D,O]=H(!1),[k,ee]=H(!1),[te,ne]=H(null),re=!!te,{isLoading:ie,error:ae,data:j}=fn({queryKey:A.check(r),queryFn:async()=>c(r,u),refetchOnMount:!0}),oe=w??j?.last_run?.run_id,{run:N,error:se}=ht(oe),ce=w?!N||N.status===`Running`:N?.status===`Running`,P=j?.type?z(j.type):void 0,le;P&&(le=P.RunResultView);let de=j?.is_preset??!1,fe=wn(null),{mutate:pe}=dn({mutationFn:e=>o(r,e,u),onSuccess:async()=>{await h.invalidateQueries({queryKey:A.check(r)}),await h.invalidateQueries({queryKey:A.checks()})}}),{mutate:me}=dn({mutationFn:()=>n(r,u),onSuccess:async()=>{p(``),await h.invalidateQueries({queryKey:A.checks()}),g.push(`${_}/checks`)}}),{mutate:he,isPending:ge}=dn({mutationFn:async()=>{if(!j)throw Error(`Check not found`);return await t(r,u)},onSuccess:async()=>{S(`Check marked as preset successfully`),await h.invalidateQueries({queryKey:A.check(r)})},onError:e=>{C(`Failed to mark check as preset`,e)}}),F=B(async()=>{j?.type&&(T((await e(r,{nowait:!0},u)).run_id),await h.invalidateQueries({queryKey:A.check(r)}),a&&a())},[j,r,h,a,u]),_e=B(async()=>{if(O(!0),oe)return await i(oe,u)},[oe,u]),ve=async()=>{if(!j)return;let e=Ls(j);if(!window.isSecureContext){C(`Failed to copy the check to clipboard`,Error(`Copy to clipboard is available only in secure contexts (HTTPS)`));return}try{await navigator.clipboard.writeText(e),S(`Copied the check to the clipboard`)}catch(e){C(`Failed to copy the check to clipboard`,e)}},ye=B(()=>{let e=j?.is_checked;pe({is_checked:!e}),e||jt.create({title:`Marked as approved`,type:`success`,duration:2e3})},[j?.is_checked,pe]),be=e=>{pe({view_options:e})},xe=e=>{pe({description:e})},Ce=e=>{ne(e.currentTarget)},we=()=>{ne(null)},Ee=B(()=>{if(!j)return;let e=j.params;v(e?.sql_template||``),`base_sql_template`in e&&e.base_sql_template?(y(e.base_sql_template),b(!0)):(y(``),b(!1)),`primary_keys`in e&&e.primary_keys?x(e.primary_keys):x(void 0),g.push(`${_}/query`)},[j,g,_,v,y,b,x]),[De,ke]=H(`result`),{ref:Ae,onCopyToClipboard:je,onMouseEnter:Me,onMouseLeave:Ne}=ot(),L=Ve({name:j?.name??``,description:j?.description??``,type:j?.type??``,params:j?.params,viewOptions:j?.view_options});if(ie)return W(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:`Loading`});if(ae)return G(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,height:`100%`},children:[`Error: `,W(`span`,{className:`no-track-pii-safe`,children:ae.message})]});if(!j)return W(bt,{minSize:100,sizes:[30,70],style:{height:`100%`,width:`100%`,maxHeight:`100%`},children:W(K,{style:{contain:`strict`},sx:{display:`flex`,flexDirection:`column`},children:W(K,{sx:{display:`flex`,p:`0px 16px`,alignItems:`center`,height:40},children:W(Qe,{name:`Check not found`,disabled:!0})})})});let R=N?.run_at?$r(new Date(N.run_at),{addSuffix:!0}):null,Le=P?.icon;return G(Pi,{spacing:0,container:!0,sx:{height:`100%`,width:`100%`},children:[W(Pi,{size:{xs:12,md:m?9:12},sx:{height:`100%`},children:G(bt,{minSize:100,sizes:[40,60],style:{height:`100%`,width:`100%`,maxHeight:`100%`},children:[W(K,{sx:{height:`100%`,contain:`strict`,display:`flex`,flexDirection:`row`},children:G(K,{sx:{flex:1,height:`100%`,display:`flex`,flexDirection:`column`,overflow:`hidden`,minWidth:0},children:[G(K,{sx:{display:`flex`,p:`0px 16px`,alignItems:`center`,height:40,borderBottom:`2px solid`,borderColor:l?`grey.700`:`grey.300`},children:[Le&&W(K,{component:Le,sx:{fontSize:20,mr:1,flexShrink:0}}),W(Qe,{name:j.name,onNameChange:e=>{pe({name:e})}}),W(K,{sx:{flexGrow:1}}),G(J,{direction:`row`,spacing:2,sx:{mr:`10px`},children:[R&&W(K,{sx:{textOverflow:`ellipsis`,whiteSpace:`nowrap`,overflow:`hidden`,fontSize:`0.75rem`,display:`flex`,alignItems:`center`},children:R}),de&&W(Z,{title:`This is a preset check`,children:W(K,{display:`flex`,alignItems:`center`,justifyContent:`center`,children:W(yi,{size:`1rem`,color:s.palette.iochmara.dark})})}),W(X,{size:`small`,onClick:Ce,children:W(Ur,{})}),G(Lr,{anchorEl:te,open:re,onClose:we,children:[f&&G(Q,{onClick:()=>{he(),we()},disabled:ge||de,children:[W(si,{children:W(In,{})}),W(ci,{children:`Mark as Preset Check`})]}),G(Q,{onClick:()=>{ee(!0),we()},children:[W(si,{children:W(Ii,{})}),W(ci,{children:`Get Preset Check Template`})]}),G(Q,{onClick:()=>{ve(),we()},children:[W(si,{children:W(er,{})}),W(ci,{children:`Copy Markdown`})]}),W(Bn,{}),G(Q,{onClick:()=>{me(),we()},disabled:d.disableUpdateChecklist,sx:{color:`error.main`},children:[W(si,{sx:{color:`error.main`},children:W(dr,{})}),W(ci,{children:`Delete`})]})]}),W(Z,{title:Fe({type:j.type,hasResult:!!N?.result,hasError:!!N?.error})?`Run the check first`:j.is_checked?`Remove approval`:`Mark as approved`,placement:`bottom-end`,children:W(q,{size:`small`,color:j.is_checked?`success`:`neutral`,variant:j.is_checked?`contained`:`outlined`,onClick:()=>{ye()},disabled:Fe({type:j.type,hasResult:!!N?.result,hasError:!!N?.error})||d.disableUpdateChecklist,startIcon:j.is_checked?W(Qn,{}):W(zr,{style:{color:l?s.palette.grey[600]:s.palette.grey[400]}}),sx:{flex:`0 0 auto`,textTransform:`none`},children:j.is_checked?`Approved`:`Pending`})})]})]}),W(K,{sx:{flex:1,p:`8px 16px`,minHeight:100},children:W(Pe,{value:j.description,onChange:xe,disabled:d.disableUpdateChecklist},j.check_id)})]})}),W(K,{style:{contain:`strict`},children:G(K,{sx:{height:`100%`,display:`flex`,flexDirection:`column`},children:[G(K,{sx:{display:`flex`,alignItems:`center`,borderBottom:1,borderColor:`divider`,height:50},children:[G(qr,{value:De,onChange:(e,t)=>ke(t),children:[W(Kr,{label:`Result`,value:`result`,sx:{fontSize:`0.75rem`,textTransform:`none`}}),(j.type===`query`||j.type===`query_diff`)&&W(Kr,{label:`Query`,value:`query`,sx:{fontSize:`0.75rem`,textTransform:`none`}})]}),W(K,{sx:{flexGrow:1}}),G(J,{direction:`row`,spacing:1,sx:{mr:`10px`},children:[(j.type===`query`||j.type===`query_base`||j.type===`query_diff`)&&W(Z,{title:`Open in Query tab`,children:W(q,{variant:`outlined`,color:`neutral`,size:`small`,onClick:Ee,disabled:d.disableDatabaseQuery,startIcon:W(oi,{}),sx:{textTransform:`none`},children:`Open Query`})}),le&&W(Z,{title:`Rerun`,children:W(q,{variant:`outlined`,color:`neutral`,size:`small`,onClick:()=>F(),disabled:d.disableDatabaseQuery||ce,startIcon:W(lr,{}),sx:{textTransform:`none`},children:ce?`Running...`:`Rerun`})}),W(q,{variant:`outlined`,color:`neutral`,disabled:Fe({type:j.type,hasResult:!!N?.result,hasError:!!N?.error})||De!==`result`,onMouseEnter:Me,onMouseLeave:Ne,size:`small`,onClick:async()=>{j.type===`lineage_diff`?fe.current?.copyToClipboard():await je(),Kt({type:j.type,from:`check`})},startIcon:W(er,{}),sx:{textTransform:`none`},children:`Copy to Clipboard`})]})]}),G(K,{sx:{flex:1,contain:`strict`},children:[De===`result`&&G(K,{sx:{width:`100%`,height:`100%`},children:[le&&(j.last_run||oe?W(Te,{ref:Ae,isRunning:ce,isAborting:D,run:oe?N:j.last_run,error:se,progress:E,RunResultView:le,viewOptions:j.view_options,onViewOptionsChanged:be,onCancel:_e,onExecuteRun:F}):W(K,{sx:{display:`flex`,alignItems:`center`,justifyContent:`center`,bgcolor:l?`grey.900`:`grey.50`,height:`100%`},children:G(J,{spacing:2,alignItems:`center`,children:[W(K,{children:`This action is part of the initial preset and has not been performed yet. Once performed, the result will be shown here.`}),W(ks,{display:d.mode===`metadata only`,children:W(q,{onClick:F,variant:`contained`,size:`small`,disabled:d.disableDatabaseQuery,children:`Run Query`})})]})})),j.type===`schema_diff`&&W(Fs,{check:j,ref:Ae},j.check_id),j.type===`lineage_diff`&&W(Ms,{check:j,ref:fe},j.check_id)]}),De===`query`&&(j.type===`query`||j.type===`query_diff`||j.type===`query_base`)&&W(K,{sx:{height:`100%`,width:`100%`},children:j.params.base_sql_template?W(it,{value:j.params.sql_template||``,baseValue:j.params.base_sql_template??``,options:{readOnly:!0}}):W(Se,{value:j.params.sql_template||``,options:{readOnly:!0}})})]})]})}),G(Tn,{open:k,onClose:()=>ee(!1),maxWidth:`md`,fullWidth:!0,children:[W(On,{children:`Preset Check Template`}),G(Dn,{children:[G(Y,{variant:`subtitle2`,fontWeight:`bold`,sx:{mb:2},children:[`Please`,` `,W(Y,{component:`span`,sx:{cursor:`pointer`,"&:hover":{textDecoration:`underline`},color:`primary.main`},onClick:async()=>{await navigator.clipboard.writeText(L),S(`Copied the template to the clipboard`)},children:`copy`}),` `,`the following template and paste it into the`,` `,W(K,{component:`span`,sx:{px:.5,bgcolor:`error.light`,borderRadius:.5},children:`recce.yml`}),` `,`file.`]}),W(ze,{yamlTemplate:L})]}),W(En,{children:W(X,{size:`small`,onClick:()=>ee(!1),sx:{position:`absolute`,top:8,right:8},children:W(Ln,{})})})]})]})}),m&&W(Pi,{size:3,sx:{height:`100%`,overflow:`hidden`,flexShrink:0,display:{xs:`none`,md:`block`}},children:W(va,{checkId:r})})]})}function Ls(e){return Fi`
|
|
7
7
|
<details><summary>${ke({name:e.name,isChecked:e.is_checked})}</summary>
|
|
8
8
|
|
|
9
|
-
${
|
|
9
|
+
${Rs(e)}
|
|
10
10
|
|
|
11
|
-
</details>`}function Ls(e){let t=Ee({description:e.description});if(e.type===`query`||e.type===`query_diff`){let n=e.params;return`${t}\n\n${je({sql:n&&`sql_template`in n?n.sql_template:``})}`}return t}const Rs=()=>{let e=pn(),t=ni(),{apiClient:n}=Oe(),{basePath:r}=ue(),{mutate:i,isPending:a}=dn({mutationFn:()=>_({select:`state:modified`},n),onSuccess:async n=>{await e.invalidateQueries({queryKey:A.checks()}),t.push(`${r}/checks/?id=${n.check_id}`)}});return W(He,{title:`No checks yet`,description:`Checks help you validate data quality and catch issues.`,icon:W(ii,{size:48}),actionText:`Create Schema Diff Check`,onAction:()=>{i()},isLoading:a,helperText:`The schema checks compare modified models between environments to detect changes, additions, or removals.`})},zs=({check:e,selected:t,onSelect:n,onApprovalChange:r})=>{let{featureToggles:i}=I(),a=e.last_run?.run_id,{run:o}=ht(a),s=Fe({type:e.type,hasResult:!!o?.result,hasError:!!o?.error}),c=s||i.disableUpdateChecklist;return W(xe,{check:{id:e.check_id,name:e.name,type:e.type,isApproved:e.is_checked,runStatus:(()=>{if(o){if(o.error)return`error`;if(o.result)return`success`}})(),isPreset:e.is_preset},isSelected:t,onClick:n,onApprovalChange:r,disableApproval:c,disabledApprovalTooltip:s?`Run the check first`:void 0})},Bs=({checks:e,selectedItem:t,onCheckSelected:n,onChecksReordered:r})=>{let[i,a]=H(!1),[s,c]=H(!1),[l,u]=H(null),d=pn(),{apiClient:f}=Oe(),{mutate:p}=dn({mutationFn:({checkId:e,isChecked:t})=>o(e,{is_checked:t},f),onSuccess:async(e,{checkId:t})=>{await d.invalidateQueries({queryKey:A.check(t)}),await d.invalidateQueries({queryKey:A.checks()})}}),m=e=>{e.destination&&r(e.source.index,e.destination.index)},h=()=>c(!0),g=()=>{c(!1),u(null)},_=()=>{jt.create({title:`Marked as approved`,type:`success`,duration:2e3})},v=(e,t)=>{t?localStorage.getItem(`bypassMarkAsApprovedWarning`)===`true`?(p({checkId:e,isChecked:!0}),_()):(u(e),h()):p({checkId:e,isChecked:!1})};return G(U,{children:[W(Li,{onDragEnd:m,children:W(zi,{droppableId:`checklist`,children:r=>G(J,{...r.droppableProps,ref:r.innerRef,className:`no-track-pii-safe`,sx:{width:`100%`,flex:1,overflow:`auto`},spacing:0,children:[e.map((e,r)=>W(Ri,{draggableId:e.check_id,index:r,children:(r,i)=>{let a=r.draggableProps.style;if(i.isDragging&&a&&`left`in a){let e={x:0,y:80};a={...a,left:a.left-e.x,top:a.top-e.y}}return W(K,{ref:r.innerRef,...r.draggableProps,...r.dragHandleProps,style:a,sx:{width:`100%`},borderBottom:`1px solid`,borderColor:`divider`,children:W(zs,{check:e,selected:e.check_id===t,onSelect:n,onApprovalChange:v},e.check_id)})}},e.check_id)),r.placeholder]})})}),G(Tn,{open:s,onClose:g,maxWidth:`xs`,fullWidth:!0,children:[G(On,{sx:{display:`flex`,alignItems:`center`},children:[`Mark as Approved?`,W(K,{sx:{flexGrow:1}}),W(X,{size:`small`,onClick:g,children:W(Ln,{})})]}),W(Bn,{}),G(Dn,{sx:{fontSize:`0.875rem`},children:[W(Y,{children:`Please ensure you have reviewed the contents of this check before marking it as approved.`}),W(Nr,{control:W(Mr,{checked:i,onChange:e=>{a(e.target.checked)},size:`small`}),label:W(Y,{sx:{fontWeight:`bold`,pt:`8px`},children:`Don't show this again`})})]}),W(Bn,{}),G(En,{sx:{gap:0},children:[W(q,{variant:`outlined`,size:`small`,onClick:g,children:`Cancel`}),W(q,{color:`iochmara`,variant:`contained`,size:`small`,onClick:()=>{l&&(p({checkId:l,isChecked:!0}),i&&localStorage.setItem(`bypassMarkAsApprovedWarning`,`true`),_(),g(),u(null))},children:`Mark as approved`})]})]})]})},Vs=()=>{let e=Nn().palette.mode===`dark`?`grey.700`:`grey.300`,t=ni(),n=ri().get(`id`),{latestSelectedCheckId:r,setLatestSelectedCheckId:i}=Ct(),a=pn(),{apiClient:o}=Oe(),{basePath:s}=ue(),c=n;xn(()=>{c&&i(c)},[c,i]);let{isLoading:l,error:u,data:d,status:f,refetch:p}=fn({queryKey:A.checks(),queryFn:()=>b(o),refetchOnMount:!0}),m=B(e=>{t.push(`${s}/checks/?id=${e}`)},[t.push,s]),[h,g]=H(d??[]),[_,v]=H(d);d!==_&&(v(d),g(d??[]));let{mutate:x}=dn({mutationFn:e=>y(e,o),onSuccess:async()=>{await a.invalidateQueries({queryKey:A.checks()})}}),S=B((e,t)=>{let n=[...h],[r]=n.splice(e,1);n.splice(t,0,r),x({source:e,destination:t}),g(n)},[h,x]),C=V(()=>!!(c&&d?.some(e=>e.check_id===c)),[c,d]);return xn(()=>{f!==`success`||d.length===0||C||(r&&d.some(e=>e.check_id===r)?t.replace(`${s}/checks/?id=${r}`):t.replace(`${s}/checks/?id=${d[0].check_id}`))},[f,C,d,r,t.replace,s]),l?null:u?G(K,{children:[`Error: `,W(`span`,{className:`no-track-pii-safe`,children:u.message})]}):d?.length?G(at,{style:{height:`100%`},minSize:50,sizes:[20,80],children:[W(K,{sx:{height:`100%`},style:{contain:`size`},children:G(J,{sx:{height:`100%`,alignItems:`stretch`},style:{contain:`strict`},spacing:0,children:[W(K,{sx:{display:`flex`,justifyContent:`flex-end`,p:`0px 10px`},children:W(ks,{checksOnly:!0})}),W(Bn,{}),W(Bs,{checks:h,selectedItem:c,onCheckSelected:m,onChecksReordered:S})]})}),W(K,{sx:{height:`100%`},children:C&&c&&W(Fs,{checkId:c,refreshCheckList:p},c)})]}):G(at,{style:{height:`100%`},minSize:50,sizes:[20,80],children:[W(K,{sx:{borderRight:`1px solid`,borderRightColor:e,height:`100%`},style:{contain:`size`},children:G(J,{sx:{height:`100%`,alignItems:`stretch`},style:{contain:`strict`},spacing:0,children:[W(K,{sx:{display:`flex`,justifyContent:`flex-end`,p:`0px 10px`},children:W(ks,{checksOnly:!0})}),W(Bn,{}),W(K,{sx:{height:`100%`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:W(K,{sx:{textAlign:`center`,color:`grey.500`},children:`No checks`})})]})}),W(K,{children:W(K,{sx:{height:`100%`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:W(Rs,{})})})]})},Hs=()=>G(at,{style:{height:`100%`},minSize:50,sizes:[20,80],children:[W(K,{sx:{borderRight:`1px solid`,borderRightColor:Nn().palette.mode===`dark`?`grey.700`:`grey.300`,height:`100%`},style:{contain:`size`},children:W(K,{sx:{height:`100%`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:W(Vn,{size:20})})}),W(K,{children:W(K,{sx:{height:`100%`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:W(Vn,{size:20})})})]}),Us={added:[`Model Added`,`Added resource`],removed:[`Model Removed`,`Removed resource`],modified:[`Model Modified`,`Modified resource`],col_added:[`Column Added`,`Added column`],col_removed:[`Column Removed`,`Removed column`],col_changed:[`Column Modified`,`Modified column`],folder_changed:[`Modified`,`Modified folder`]};function Ws(e){let t=String(ye(`colors.green.solid`)),n=String(ye(`colors.red.solid`)),r=String(ye(`colors.amber.emphasized`));return e===`added`?{color:t,icon:Xe}:e===`removed`?{color:n,icon:st}:e===`modified`?{color:r,icon:pt}:e===`col_added`?{color:t,icon:Xe}:e===`col_removed`?{color:n,icon:st}:e===`col_changed`?{color:r,icon:pt}:e===`folder_changed`?{color:r,icon:et}:{color:`inherit`,icon:void 0}}function Gs(e,t){let n=0,r=0,i=0;return!e&&!t?{adds:n,removes:r,modifies:i}:(t&&Object.keys(t.columns??{}).forEach(t=>{e?.columns?.[t]||n++}),e&&Object.keys(e.columns??{}).forEach(e=>{t?.columns?.[e]||r++}),t&&e&&Object.keys(t.columns??{}).forEach(n=>{e.columns&&t.columns?.[n]&&e.columns[n]&&e.columns[n].type!==t.columns[n].type&&i++}),{adds:n,removes:r,modifies:i})}function Ks(e){let t=e.modifiedSet,n=0,r=0,i=0,a=0,o=0,s=0;return t.forEach(t=>{e.nodes[t].data.changeStatus===`added`?n++:e.nodes[t].data.changeStatus===`removed`?r++:e.nodes[t].data.changeStatus===`modified`&&i++;let c=e.nodes[t].data.data.base,l=e.nodes[t].data.data.current,u=Gs(c,l);a+=u.adds,o+=u.removes,s+=u.modifies}),{adds:n,removes:r,modifies:i,col_added:a,col_removed:o,col_changed:s}}function qs({name:e,value:t,tip:n}){return G(J,{alignItems:`stretch`,children:[G(Y,{sx:{fontSize:`0.875rem`,color:`grey.600`},children:[e,n&&W(Z,{title:n,children:W(K,{sx:{display:`inline-block`},children:W(K,{component:di,sx:{mx:`2px`,fontSize:12,verticalAlign:`middle`}})})})]}),t]})}function Js({changeStatus:e,value:t}){let[n]=e?Us[e]:[``],{icon:r,color:i}=Ws(e);return G(J,{alignItems:`stretch`,children:[G(J,{direction:`row`,alignItems:`center`,sx:{fontSize:`0.875rem`,color:`grey.600`},children:[r&&W(K,{component:r,sx:{mr:`5px`,color:i,fontSize:`1rem`}}),n]}),W(Y,{sx:{fontSize:`0.875rem`},children:t})]})}function Ys({lineageGraph:e}){let{adds:t,removes:n,modifies:r,col_added:i,col_removed:a,col_changed:o}=Ks(e);return G(Pi,{container:!0,sx:{mb:`10px`,borderTop:`1px solid`,borderColor:`divider`,p:`2.5vw`},children:[W(Pi,{size:6,sx:{borderColor:`divider`},children:W(qs,{name:`Code Changes`,value:G(Pi,{container:!0,sx:{width:`100%`},children:[W(Pi,{size:4,children:W(Js,{changeStatus:`added`,value:t})}),W(Pi,{size:4,children:W(Js,{changeStatus:`removed`,value:n})}),W(Pi,{size:4,children:W(Js,{changeStatus:`modified`,value:r})})]})})}),W(Pi,{size:6,sx:{borderLeft:`1px solid`,borderLeftColor:`divider`,pl:`12px`},children:W(qs,{name:`Column Changes`,value:G(Pi,{container:!0,sx:{width:`100%`},children:[W(Pi,{size:4,children:W(Js,{changeStatus:`col_added`,value:i})}),W(Pi,{size:4,children:W(Js,{changeStatus:`col_removed`,value:a})}),W(Pi,{size:4,children:W(Js,{changeStatus:`col_changed`,value:o})})]})})})]})}function Xs({node:e,...t}){return G(Bi,{sx:{maxWidth:500},children:[W(Hi,{title:W(Y,{sx:{fontSize:18,fontWeight:`bold`},children:t.title}),subheader:G(J,{direction:`row`,spacing:`8px`,sx:{p:`16px`},children:[W(fo,{data:{resourceType:e.data.resourceType}}),e.data.resourceType===`model`&&W(mo,{node:e})]})}),W(Vi,{children:W(K,{sx:{display:`flex`},children:W(io,{base:e.data.data.base,current:e.data.data.current,columnChanges:e.data.change?.columns})})})]})}function Zs(e){let t=[],n=e.nodes;return e.modifiedSet.forEach(e=>{let r=n[e],i=Ot(Object.keys(r.data.data.base?.columns??{}),Object.keys(r.data.data.current?.columns??{}));!Object.values(i).every(e=>e===void 0)&&r.data.data.base&&r.data.data.current&&t.push(r)}),t}function Qs({lineageGraph:e}){let[t,n]=H([]);return xn(()=>{n(Zs(e))},[e]),G(U,{children:[W(K,{sx:{width:`100%`,pb:`10px`,mb:`20px`,mt:`20px`},children:W(Y,{variant:`h5`,sx:{fontSize:24},children:`Schema Summary`})}),W(K,{sx:{width:`100%`,pb:`10px`,mb:`20px`},children:t.length===0?W(Y,{sx:{fontSize:18,color:`grey.600`},children:`No schema changes detected.`}):W(K,{sx:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(400px, 1fr))`,gap:`2vw`,p:`2.5vw`,width:`100%`,bgcolor:`lightgray`},children:t.map(e=>W(Xs,{title:e.data.name,node:e},e.id))})})]})}function $s({checks:e,isLoading:t,error:n,selectedCheckId:r,onCheckSelect:i,onApprovalChange:a,onAction:o,onReorder:s,onDescriptionChange:c,onNameChange:l,onCreateCheck:u,getCheckTabs:d,getPrimaryActions:f,getSecondaryActions:p,disableApproval:m=!1,disabledApprovalTooltip:h,height:g=`100%`,listPaneSize:_=30,minListSize:v=200,maxListSize:y=500,listTitle:b,className:x}){let S=L(),C=e??S.checks,w=t===void 0?S.isLoading:t,T=n??S.error,E=r??S.selectedCheckId,D=i??S.onSelectCheck,O=V(()=>C.map(e=>({id:e.check_id,name:e.name,type:e.type,description:e.description,isApproved:e.is_checked})),[C]),k=V(()=>C.find(e=>e.check_id===E),[C,E]),ee=B(e=>{D?.(e)},[D]),te=B((e,t)=>{o?.(e,t)},[o]),ne=B(e=>{E&&c?.(E,e)},[E,c]),re=B(e=>{E&&l?.(E,e)},[E,l]);if(w)return W(K,{className:x,sx:{width:`100%`,height:g,display:`flex`,alignItems:`center`,justifyContent:`center`},children:W(Vn,{})});if(T)return W(K,{className:x,sx:{width:`100%`,height:g,display:`flex`,alignItems:`center`,justifyContent:`center`},children:W(Y,{color:`error`,children:T})});if(C.length===0)return W(K,{className:x,sx:{width:`100%`,height:g,display:`flex`,alignItems:`center`,justifyContent:`center`},children:W(He,{title:`No checks yet`,description:`Create your first check to start validating your data.`,actionText:`Create Check`,onAction:u})});let A=k?d?.(k):void 0,ie=k?f?.(k):void 0,ae=k?p?.(k):void 0;return W(K,{className:x,sx:{width:`100%`,height:g},children:G(Ze,{direction:`horizontal`,sizes:[_,100-_],minSizes:[v,200],maxSizes:[y,1/0],children:[W(K,{sx:{height:`100%`,overflow:`auto`},children:W(Ue,{checks:O,selectedId:E,onCheckSelect:ee,onApprovalChange:a,onReorder:s,disableApproval:m,disabledApprovalTooltip:h,title:b})}),W(K,{sx:{height:`100%`,overflow:`auto`},children:k?W(We,{checkId:k.check_id,name:k.name,type:k.type,description:k.description,isApproved:k.is_checked,tabs:A,primaryActions:ie,secondaryActions:ae,onAction:te,onDescriptionChange:ne,onNameChange:re}):W(K,{sx:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:W(Y,{color:`text.secondary`,children:`Select a check from the list to view details`})})})]})})}const ec=yn($s);ec.displayName=`ChecksView`;const tc=`0.2.0`;export{ya as A,ao as C,Ca as D,Ya as E,Gi as M,Wi as N,xa as O,io as S,$a as T,ss as _,Ks as a,wo as b,Us as c,Bs as d,Rs as f,xs as g,Es as h,Ys as i,Ji as j,ba as k,Hs as l,Ds as m,ec as n,Gs as o,Fs as p,Qs as r,Ws as s,tc as t,Vs as u,ns as v,eo as w,to as x,Vo as y};
|
|
12
|
-
//# sourceMappingURL=src-
|
|
11
|
+
</details>`}function Rs(e){let t=Ee({description:e.description});if(e.type===`query`||e.type===`query_diff`){let n=e.params;return`${t}\n\n${je({sql:n&&`sql_template`in n?n.sql_template:``})}`}return t}const zs=()=>{let e=pn(),t=ni(),{apiClient:n}=Oe(),{basePath:r}=ue(),{mutate:i,isPending:a}=dn({mutationFn:()=>_({select:`state:modified`},n),onSuccess:async n=>{await e.invalidateQueries({queryKey:A.checks()}),t.push(`${r}/checks/?id=${n.check_id}`)}});return W(He,{title:`No checks yet`,description:`Checks help you validate data quality and catch issues.`,icon:W(ii,{size:48}),actionText:`Create Schema Diff Check`,onAction:()=>{i()},isLoading:a,helperText:`The schema checks compare modified models between environments to detect changes, additions, or removals.`})},Bs=({check:e,selected:t,onSelect:n,onApprovalChange:r})=>{let{featureToggles:i}=I(),a=e.last_run?.run_id,{run:o}=ht(a),s=Fe({type:e.type,hasResult:!!o?.result,hasError:!!o?.error}),c=s||i.disableUpdateChecklist;return W(xe,{check:{id:e.check_id,name:e.name,type:e.type,isApproved:e.is_checked,runStatus:(()=>{if(o){if(o.error)return`error`;if(o.result)return`success`}})(),isPreset:e.is_preset},isSelected:t,onClick:n,onApprovalChange:r,disableApproval:c,disabledApprovalTooltip:s?`Run the check first`:void 0})},Vs=({checks:e,selectedItem:t,onCheckSelected:n,onChecksReordered:r})=>{let[i,a]=H(!1),[s,c]=H(!1),[l,u]=H(null),d=pn(),{apiClient:f}=Oe(),{mutate:p}=dn({mutationFn:({checkId:e,isChecked:t})=>o(e,{is_checked:t},f),onSuccess:async(e,{checkId:t})=>{await d.invalidateQueries({queryKey:A.check(t)}),await d.invalidateQueries({queryKey:A.checks()})}}),m=e=>{e.destination&&r(e.source.index,e.destination.index)},h=()=>c(!0),g=()=>{c(!1),u(null)},_=()=>{jt.create({title:`Marked as approved`,type:`success`,duration:2e3})},v=(e,t)=>{t?localStorage.getItem(`bypassMarkAsApprovedWarning`)===`true`?(p({checkId:e,isChecked:!0}),_()):(u(e),h()):p({checkId:e,isChecked:!1})};return G(U,{children:[W(Li,{onDragEnd:m,children:W(zi,{droppableId:`checklist`,children:r=>G(J,{...r.droppableProps,ref:r.innerRef,className:`no-track-pii-safe`,sx:{width:`100%`,flex:1,overflow:`auto`},spacing:0,children:[e.map((e,r)=>W(Ri,{draggableId:e.check_id,index:r,children:(r,i)=>{let a=r.draggableProps.style;if(i.isDragging&&a&&`left`in a){let e={x:0,y:80};a={...a,left:a.left-e.x,top:a.top-e.y}}return W(K,{ref:r.innerRef,...r.draggableProps,...r.dragHandleProps,style:a,sx:{width:`100%`},borderBottom:`1px solid`,borderColor:`divider`,children:W(Bs,{check:e,selected:e.check_id===t,onSelect:n,onApprovalChange:v},e.check_id)})}},e.check_id)),r.placeholder]})})}),G(Tn,{open:s,onClose:g,maxWidth:`xs`,fullWidth:!0,children:[G(On,{sx:{display:`flex`,alignItems:`center`},children:[`Mark as Approved?`,W(K,{sx:{flexGrow:1}}),W(X,{size:`small`,onClick:g,children:W(Ln,{})})]}),W(Bn,{}),G(Dn,{sx:{fontSize:`0.875rem`},children:[W(Y,{children:`Please ensure you have reviewed the contents of this check before marking it as approved.`}),W(Nr,{control:W(Mr,{checked:i,onChange:e=>{a(e.target.checked)},size:`small`}),label:W(Y,{sx:{fontWeight:`bold`,pt:`8px`},children:`Don't show this again`})})]}),W(Bn,{}),G(En,{sx:{gap:0},children:[W(q,{variant:`outlined`,size:`small`,onClick:g,children:`Cancel`}),W(q,{color:`iochmara`,variant:`contained`,size:`small`,onClick:()=>{l&&(p({checkId:l,isChecked:!0}),i&&localStorage.setItem(`bypassMarkAsApprovedWarning`,`true`),_(),g(),u(null))},children:`Mark as approved`})]})]})]})},Hs=()=>{let e=Nn().palette.mode===`dark`?`grey.700`:`grey.300`,t=ni(),n=ri().get(`id`),{latestSelectedCheckId:r,setLatestSelectedCheckId:i}=Ct(),a=pn(),{apiClient:o}=Oe(),{basePath:s}=ue(),c=n;xn(()=>{c&&i(c)},[c,i]);let{isLoading:l,error:u,data:d,status:f,refetch:p}=fn({queryKey:A.checks(),queryFn:()=>b(o),refetchOnMount:!0}),m=B(e=>{t.push(`${s}/checks/?id=${e}`)},[t.push,s]),[h,g]=H(d??[]),[_,v]=H(d);d!==_&&(v(d),g(d??[]));let{mutate:x}=dn({mutationFn:e=>y(e,o),onSuccess:async()=>{await a.invalidateQueries({queryKey:A.checks()})}}),S=B((e,t)=>{let n=[...h],[r]=n.splice(e,1);n.splice(t,0,r),x({source:e,destination:t}),g(n)},[h,x]),C=V(()=>!!(c&&d?.some(e=>e.check_id===c)),[c,d]);return xn(()=>{f!==`success`||d.length===0||C||(r&&d.some(e=>e.check_id===r)?t.replace(`${s}/checks/?id=${r}`):t.replace(`${s}/checks/?id=${d[0].check_id}`))},[f,C,d,r,t.replace,s]),l?null:u?G(K,{children:[`Error: `,W(`span`,{className:`no-track-pii-safe`,children:u.message})]}):d?.length?G(at,{style:{height:`100%`},minSize:50,sizes:[20,80],children:[W(K,{sx:{height:`100%`},style:{contain:`size`},children:G(J,{sx:{height:`100%`,alignItems:`stretch`},style:{contain:`strict`},spacing:0,children:[W(K,{sx:{display:`flex`,justifyContent:`flex-end`,p:`0px 10px`},children:W(As,{checksOnly:!0})}),W(Bn,{}),W(Vs,{checks:h,selectedItem:c,onCheckSelected:m,onChecksReordered:S})]})}),W(K,{sx:{height:`100%`},children:C&&c&&W(Is,{checkId:c,refreshCheckList:p},c)})]}):G(at,{style:{height:`100%`},minSize:50,sizes:[20,80],children:[W(K,{sx:{borderRight:`1px solid`,borderRightColor:e,height:`100%`},style:{contain:`size`},children:G(J,{sx:{height:`100%`,alignItems:`stretch`},style:{contain:`strict`},spacing:0,children:[W(K,{sx:{display:`flex`,justifyContent:`flex-end`,p:`0px 10px`},children:W(As,{checksOnly:!0})}),W(Bn,{}),W(K,{sx:{height:`100%`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:W(K,{sx:{textAlign:`center`,color:`grey.500`},children:`No checks`})})]})}),W(K,{children:W(K,{sx:{height:`100%`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:W(zs,{})})})]})},Us=()=>G(at,{style:{height:`100%`},minSize:50,sizes:[20,80],children:[W(K,{sx:{borderRight:`1px solid`,borderRightColor:Nn().palette.mode===`dark`?`grey.700`:`grey.300`,height:`100%`},style:{contain:`size`},children:W(K,{sx:{height:`100%`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:W(Vn,{size:20})})}),W(K,{children:W(K,{sx:{height:`100%`,display:`flex`,justifyContent:`center`,alignItems:`center`},children:W(Vn,{size:20})})})]}),Ws={added:[`Model Added`,`Added resource`],removed:[`Model Removed`,`Removed resource`],modified:[`Model Modified`,`Modified resource`],col_added:[`Column Added`,`Added column`],col_removed:[`Column Removed`,`Removed column`],col_changed:[`Column Modified`,`Modified column`],folder_changed:[`Modified`,`Modified folder`]};function Gs(e){let t=String(ye(`colors.green.solid`)),n=String(ye(`colors.red.solid`)),r=String(ye(`colors.amber.emphasized`));return e===`added`?{color:t,icon:Xe}:e===`removed`?{color:n,icon:st}:e===`modified`?{color:r,icon:pt}:e===`col_added`?{color:t,icon:Xe}:e===`col_removed`?{color:n,icon:st}:e===`col_changed`?{color:r,icon:pt}:e===`folder_changed`?{color:r,icon:et}:{color:`inherit`,icon:void 0}}function Ks(e,t){let n=0,r=0,i=0;return!e&&!t?{adds:n,removes:r,modifies:i}:(t&&Object.keys(t.columns??{}).forEach(t=>{e?.columns?.[t]||n++}),e&&Object.keys(e.columns??{}).forEach(e=>{t?.columns?.[e]||r++}),t&&e&&Object.keys(t.columns??{}).forEach(n=>{e.columns&&t.columns?.[n]&&e.columns[n]&&e.columns[n].type!==t.columns[n].type&&i++}),{adds:n,removes:r,modifies:i})}function qs(e){let t=e.modifiedSet,n=0,r=0,i=0,a=0,o=0,s=0;return t.forEach(t=>{e.nodes[t].data.changeStatus===`added`?n++:e.nodes[t].data.changeStatus===`removed`?r++:e.nodes[t].data.changeStatus===`modified`&&i++;let c=e.nodes[t].data.data.base,l=e.nodes[t].data.data.current,u=Ks(c,l);a+=u.adds,o+=u.removes,s+=u.modifies}),{adds:n,removes:r,modifies:i,col_added:a,col_removed:o,col_changed:s}}function Js({name:e,value:t,tip:n}){return G(J,{alignItems:`stretch`,children:[G(Y,{sx:{fontSize:`0.875rem`,color:`grey.600`},children:[e,n&&W(Z,{title:n,children:W(K,{sx:{display:`inline-block`},children:W(K,{component:di,sx:{mx:`2px`,fontSize:12,verticalAlign:`middle`}})})})]}),t]})}function Ys({changeStatus:e,value:t}){let[n]=e?Ws[e]:[``],{icon:r,color:i}=Gs(e);return G(J,{alignItems:`stretch`,children:[G(J,{direction:`row`,alignItems:`center`,sx:{fontSize:`0.875rem`,color:`grey.600`},children:[r&&W(K,{component:r,sx:{mr:`5px`,color:i,fontSize:`1rem`}}),n]}),W(Y,{sx:{fontSize:`0.875rem`},children:t})]})}function Xs({lineageGraph:e}){let{adds:t,removes:n,modifies:r,col_added:i,col_removed:a,col_changed:o}=qs(e);return G(Pi,{container:!0,sx:{mb:`10px`,borderTop:`1px solid`,borderColor:`divider`,p:`2.5vw`},children:[W(Pi,{size:6,sx:{borderColor:`divider`},children:W(Js,{name:`Code Changes`,value:G(Pi,{container:!0,sx:{width:`100%`},children:[W(Pi,{size:4,children:W(Ys,{changeStatus:`added`,value:t})}),W(Pi,{size:4,children:W(Ys,{changeStatus:`removed`,value:n})}),W(Pi,{size:4,children:W(Ys,{changeStatus:`modified`,value:r})})]})})}),W(Pi,{size:6,sx:{borderLeft:`1px solid`,borderLeftColor:`divider`,pl:`12px`},children:W(Js,{name:`Column Changes`,value:G(Pi,{container:!0,sx:{width:`100%`},children:[W(Pi,{size:4,children:W(Ys,{changeStatus:`col_added`,value:i})}),W(Pi,{size:4,children:W(Ys,{changeStatus:`col_removed`,value:a})}),W(Pi,{size:4,children:W(Ys,{changeStatus:`col_changed`,value:o})})]})})})]})}function Zs({node:e,...t}){return G(Bi,{sx:{maxWidth:500},children:[W(Hi,{title:W(Y,{sx:{fontSize:18,fontWeight:`bold`},children:t.title}),subheader:G(J,{direction:`row`,spacing:`8px`,sx:{p:`16px`},children:[W(fo,{data:{resourceType:e.data.resourceType}}),e.data.resourceType===`model`&&W(mo,{node:e})]})}),W(Vi,{children:W(K,{sx:{display:`flex`},children:W(io,{base:e.data.data.base,current:e.data.data.current,columnChanges:e.data.change?.columns})})})]})}function Qs(e){let t=[],n=e.nodes;return e.modifiedSet.forEach(e=>{let r=n[e],i=Ot(Object.keys(r.data.data.base?.columns??{}),Object.keys(r.data.data.current?.columns??{}));!Object.values(i).every(e=>e===void 0)&&r.data.data.base&&r.data.data.current&&t.push(r)}),t}function $s({lineageGraph:e}){let[t,n]=H([]);return xn(()=>{n(Qs(e))},[e]),G(U,{children:[W(K,{sx:{width:`100%`,pb:`10px`,mb:`20px`,mt:`20px`},children:W(Y,{variant:`h5`,sx:{fontSize:24},children:`Schema Summary`})}),W(K,{sx:{width:`100%`,pb:`10px`,mb:`20px`},children:t.length===0?W(Y,{sx:{fontSize:18,color:`grey.600`},children:`No schema changes detected.`}):W(K,{sx:{display:`grid`,gridTemplateColumns:`repeat(auto-fill, minmax(400px, 1fr))`,gap:`2vw`,p:`2.5vw`,width:`100%`,bgcolor:`lightgray`},children:t.map(e=>W(Zs,{title:e.data.name,node:e},e.id))})})]})}function ec({checks:e,isLoading:t,error:n,selectedCheckId:r,onCheckSelect:i,onApprovalChange:a,onAction:o,onReorder:s,onDescriptionChange:c,onNameChange:l,onCreateCheck:u,getCheckTabs:d,getPrimaryActions:f,getSecondaryActions:p,disableApproval:m=!1,disabledApprovalTooltip:h,height:g=`100%`,listPaneSize:_=30,minListSize:v=200,maxListSize:y=500,listTitle:b,className:x}){let S=R(),C=e??S.checks,w=t===void 0?S.isLoading:t,T=n??S.error,E=r??S.selectedCheckId,D=i??S.onSelectCheck,O=V(()=>C.map(e=>({id:e.check_id,name:e.name,type:e.type,description:e.description,isApproved:e.is_checked})),[C]),k=V(()=>C.find(e=>e.check_id===E),[C,E]),ee=B(e=>{D?.(e)},[D]),te=B((e,t)=>{o?.(e,t)},[o]),ne=B(e=>{E&&c?.(E,e)},[E,c]),re=B(e=>{E&&l?.(E,e)},[E,l]);if(w)return W(K,{className:x,sx:{width:`100%`,height:g,display:`flex`,alignItems:`center`,justifyContent:`center`},children:W(Vn,{})});if(T)return W(K,{className:x,sx:{width:`100%`,height:g,display:`flex`,alignItems:`center`,justifyContent:`center`},children:W(Y,{color:`error`,children:T})});if(C.length===0)return W(K,{className:x,sx:{width:`100%`,height:g,display:`flex`,alignItems:`center`,justifyContent:`center`},children:W(He,{title:`No checks yet`,description:`Create your first check to start validating your data.`,actionText:`Create Check`,onAction:u})});let A=k?d?.(k):void 0,ie=k?f?.(k):void 0,ae=k?p?.(k):void 0;return W(K,{className:x,sx:{width:`100%`,height:g},children:G(Ze,{direction:`horizontal`,sizes:[_,100-_],minSizes:[v,200],maxSizes:[y,1/0],children:[W(K,{sx:{height:`100%`,overflow:`auto`},children:W(Ue,{checks:O,selectedId:E,onCheckSelect:ee,onApprovalChange:a,onReorder:s,disableApproval:m,disabledApprovalTooltip:h,title:b})}),W(K,{sx:{height:`100%`,overflow:`auto`},children:k?W(We,{checkId:k.check_id,name:k.name,type:k.type,description:k.description,isApproved:k.is_checked,tabs:A,primaryActions:ie,secondaryActions:ae,onAction:te,onDescriptionChange:ne,onNameChange:re}):W(K,{sx:{height:`100%`,display:`flex`,alignItems:`center`,justifyContent:`center`},children:W(Y,{color:`text.secondary`,children:`Select a check from the list to view details`})})})]})})}const tc=yn(ec);tc.displayName=`ChecksView`;const nc=`0.2.0`;export{ya as A,ao as C,Ca as D,Ya as E,Gi as M,Wi as N,xa as O,io as S,$a as T,cs as _,qs as a,wo as b,Ws as c,Vs as d,zs as f,Ss as g,Ds as h,Xs as i,Ji as j,ba as k,Us as l,Os as m,tc as n,Ks as o,Is as p,$s as r,Gs as s,nc as t,Hs as u,rs as v,eo as w,to as x,Ho as y};
|
|
12
|
+
//# sourceMappingURL=src-CCK738Ut.js.map
|