diff --git a/recce/data/404.html b/recce/data/404.html
index 0cd5409a..c271176b 100644
--- a/recce/data/404.html
+++ b/recce/data/404.html
@@ -1 +1 @@
-
404: This page could not be found.recce404
This page could not be found.
\ No newline at end of file
+404: This page could not be found.recce404
This page could not be found.
\ No newline at end of file
diff --git a/recce/data/_next/static/gcxyLnQSBft1cQVXkjSYp/_buildManifest.js b/recce/data/_next/static/TbVabVw2HRfNH_Y-Gelvr/_buildManifest.js
similarity index 100%
rename from recce/data/_next/static/gcxyLnQSBft1cQVXkjSYp/_buildManifest.js
rename to recce/data/_next/static/TbVabVw2HRfNH_Y-Gelvr/_buildManifest.js
diff --git a/recce/data/_next/static/gcxyLnQSBft1cQVXkjSYp/_ssgManifest.js b/recce/data/_next/static/TbVabVw2HRfNH_Y-Gelvr/_ssgManifest.js
similarity index 100%
rename from recce/data/_next/static/gcxyLnQSBft1cQVXkjSYp/_ssgManifest.js
rename to recce/data/_next/static/TbVabVw2HRfNH_Y-Gelvr/_ssgManifest.js
diff --git a/recce/data/_next/static/chunks/app/page-3ea9f3f299446118.js b/recce/data/_next/static/chunks/app/page-3ea9f3f299446118.js
deleted file mode 100644
index 36afe894..00000000
--- a/recce/data/_next/static/chunks/app/page-3ea9f3f299446118.js
+++ /dev/null
@@ -1 +0,0 @@
-(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{17812:function(e,n,t){Promise.resolve().then(t.bind(t,22046))},22046:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return rc}});var i=t(60088),l=t(95523),r=t(1401),s=t(51269),o=t(84185),a=t(26883),c=t(8539),d=t(62752),u=t(11801),h=t(32060),x=t(79698),m=t(65452),p=t(99345),f=t(84739),g=t(98459),v=t(27180),j=t(40843),y=t(16341),b=t(25658);let w='select * from {{ ref("mymodel") }}',k=(0,j.createContext)({sqlQuery:w,setSqlQuery:()=>{},primaryKeys:void 0,setPrimaryKeys:()=>{},isCustomQueries:!1,setCustomQueries:()=>{},baseSqlQuery:w,setBaseSqlQuery:()=>{}});function C(e){let{children:n}=e,[t,l]=j.useState(w),[r,s]=j.useState(w),[o,a]=j.useState(!1),[c,d]=j.useState();return(0,i.jsx)(k.Provider,{value:{setSqlQuery:l,sqlQuery:t,setPrimaryKeys:d,primaryKeys:c,isCustomQueries:o,setCustomQueries:a,baseSqlQuery:r,setBaseSqlQuery:s},children:n})}let _=()=>(0,j.useContext)(k),S=(0,j.createContext)({isNodesFetching:[],setIsNodesFetching:()=>{}});function z(e){let{children:n}=e,[t,l]=j.useState([]);return(0,i.jsx)(S.Provider,{value:{isNodesFetching:t,setIsNodesFetching:l},children:n})}var R=t(13943);function E(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=new Set,l={},r=(e,t)=>{if(!(t<0)&&(void 0===l[e]||!(l[e]>=t))){for(let i of(l[e]=t,n(e)))r(i,t-1);i.add(e)}};for(let n of e)r(n,t);return i}function T(){for(var e=arguments.length,n=Array(e),t=0;t{e.forEach(e=>{i.add(e)})}),i}var D=t(67407),L=t.n(D);function I(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;return E(n,n=>void 0===e.nodes[n]?[]:Object.keys(e.nodes[n].parents),t)}function M(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;return E(n,n=>void 0===e.nodes[n]?[]:Object.keys(e.nodes[n].children),t)}function O(e,n){let t=[],i=[];function l(e){return"base"===e?0:"current"===e?2:1}function r(e,n){let t=l(e.from),i=l(n.from);return ti?1:0}let s=null!=n?new Set(n):void 0;for(let n of Object.values(e.nodes).sort(r))(!s||s.has(n.id))&&t.push({id:n.id,position:{x:0,y:0},data:n,type:"customNode",targetPosition:R.Ly.Left,sourcePosition:R.Ly.Right});for(let n of Object.values(e.edges).sort(r))(!s||s.has(n.parent.id)&&s.has(n.child.id))&&i.push({id:n.id,type:"customEdge",source:n.parent.id,target:n.child.id,data:n});return A(t,i),F(Array.from(M(e,e.modifiedSet)),t,i)}let A=function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"LR",i=new(L()).graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:t}),e.forEach(e=>{i.setNode(e.id,{width:300,height:36})}),n.forEach(e=>{i.setEdge(e.source,e.target)}),L().layout(i),e.forEach(e=>{let n=i.node(e.id);return e.position={x:n.x-150,y:n.y-18},e})};function F(e,n,t){let i=new Set(e),l=new Set(t.filter(e=>i.has(e.source)&&i.has(e.target)).map(e=>e.id));return[n.map(e=>({...e,data:{...e.data,isHighlighted:i.has(e.id)}})),t.map(e=>({...e,data:{...e.data,isHighlighted:l.has(e.id)}}))]}function N(e,n){return n.map(n=>{let t=n.id===e;return{...n,data:{...n.data,isSelected:t}}})}function q(e,n){return n.map(n=>{let t=n.id===e;return{...n,data:{...n.data,isSelected:n.data.isSelected!==t}}})}function V(e,n){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return n.map(n=>{let i=e.includes(n.id);return{...n,data:{...n.data,isSelected:t?i:n.data.isSelected||i}}})}function H(e,n){return e.map(e=>({...e,data:{...e.data,isSelected:!1,isActionMode:n,action:void 0}}))}let P={lineage:()=>["lineage"],checks:()=>["checks","list"],check:e=>["checks",e],runs:()=>["runs"],run:e=>["runs",e],runsAggregated:()=>["runs_aggregated"]};var W=t(93677),K=t(38674);let J=K.env.NEXT_PUBLIC_API_URL?K.env.NEXT_PUBLIC_API_URL:window.location.origin;var B=t(22386);let U=W.default.create({baseURL:J}),Z=new B.S;async function Q(){return(await U.get("/api/info")).data}async function X(e){return(await U.get("/api/model/".concat(e))).data}var G=t(85259),Y=t(34743),$=t(69666),ee=t(14720),en=t(36778),et=t(84078),ei=t(84387),el=t(11126),er=t(92556),es=t(58540),eo=t.n(es);async function ea(e,n,t){return(await U.post("/api/runs",{type:e,params:n,nowait:null==t?void 0:t.nowait})).data}async function ec(e,n){return(await U.get("/api/runs/".concat(e,"/wait"),{params:{timeout:n}})).data}async function ed(e){return await U.post("/api/runs/".concat(e,"/cancel"))}async function eu(e,n){return(await U.post("/api/checks/".concat(e,"/run"),{nowait:null==n?void 0:n.nowait})).data}async function eh(e,n,t){return(await U.post("/api/runs/search",{type:e,params:n,limit:t})).data}async function ex(){return(await U.get("/api/runs")).data}async function em(){return(await U.post("/api/runs/aggregate",{})).data}let ep=(0,j.createContext)({isActionAvailable:()=>!0});function ef(e){var n,t,l;let{children:r}=e,s=(0,y.a)({queryKey:P.lineage(),queryFn:Q}),o=(0,y.a)({queryKey:P.runsAggregated(),queryFn:em}),a=(0,j.useMemo)(()=>{var e;let n=null===(e=s.data)||void 0===e?void 0:e.lineage;if(n&&n.base&&n.current)return function(e,n){let t={},i={},l=(e,n)=>({id:e,name:e,data:{},from:n,parents:{},children:{},isSelected:!1});for(let[n,i]of Object.entries(e.nodes))t[n]=l(n,"base"),i&&(t[n].data.base=i,t[n].name=null==i?void 0:i.name,t[n].resourceType=null==i?void 0:i.resource_type,t[n].packageName=null==i?void 0:i.package_name);for(let[e,i]of Object.entries(n.nodes))t[e]?t[e].from="both":t[e]=l(e,"current"),i&&(t[e].data.current=n.nodes&&n.nodes[e],t[e].name=null==i?void 0:i.name,t[e].resourceType=null==i?void 0:i.resource_type,t[e].packageName=null==i?void 0:i.package_name);for(let[n,l]of Object.entries(e.parent_map))for(let e of l){let l=t[n],r=t[e],s="".concat(e,"_").concat(n);if(!l||!r)continue;i[s]={id:s,from:"base",parent:r,child:l};let o=i[s];l.parents[e]=o,r.children[n]=o}for(let[e,l]of Object.entries(n.parent_map))for(let n of l){let l=t[e],r=t[n],s="".concat(n,"_").concat(e);if(!l||!r)continue;i[s]?i[s].from="both":i[s]={id:s,from:"current",parent:r,child:l};let o=i[s];l.parents[n]=o,r.children[e]=o}let r=[];for(let[e,n]of Object.entries(t))if("base"===n.from)n.changeStatus="removed",r.push(n.id);else if("current"===n.from)n.changeStatus="added",r.push(n.id);else{var s,o,a,c,d,u;let e=null==n?void 0:null===(a=n.data)||void 0===a?void 0:null===(o=a.base)||void 0===o?void 0:null===(s=o.checksum)||void 0===s?void 0:s.checksum,t=null==n?void 0:null===(u=n.data)||void 0===u?void 0:null===(d=u.current)||void 0===d?void 0:null===(c=d.checksum)||void 0===c?void 0:c.checksum;e&&t&&e!==t&&(n.changeStatus="modified",r.push(n.id))}for(let[e,n]of Object.entries(i))"base"===n.from?n.changeStatus="removed":"current"===n.from&&(n.changeStatus="added");return{nodes:t,edges:i,modifiedSet:r,manifestMetadata:{base:e.manifest_metadata||void 0,current:n.manifest_metadata||void 0},catalogMetadata:{base:e.catalog_metadata||void 0,current:n.catalog_metadata||void 0}}}(n.base,n.current)},[s.data]),c=null===(n=s.error)||void 0===n?void 0:n.message,{lineage:d,sqlmesh:u,demo:h,review_mode:x,cloud_mode:m,file_mode:p,filename:f,adapter_type:g,git:v,pull_request:w,support_tasks:k}=s.data||{},C=null==d?void 0:null===(t=d.base)||void 0===t?void 0:t.manifest_metadata,_=null==d?void 0:null===(l=d.current)||void 0===l?void 0:l.manifest_metadata,{connectionStatus:S,connect:z}=function(){let e=(0,G.p)(),n=(0,j.useRef)({ws:void 0,status:"pending"}),[t,i]=(0,j.useState)("pending");n.current.status=t;let l=(0,b.NL)(),r=()=>{l.invalidateQueries({queryKey:P.lineage()}),l.invalidateQueries({queryKey:P.checks()}),l.invalidateQueries({queryKey:P.runs()})},s=()=>{let t=new WebSocket("".concat(J.replace(/(http)(s)?\:\/\//,"ws$2://"),"/api/ws"));n.current.ws=t,t.onopen=()=>{t.send("ping")},t.onmessage=t=>{if("pong"===t.data){"disconnected"===n.current.status&&r(),i("connected");return}try{let n=JSON.parse(t.data);if("refresh"===n.command){let{eventType:t,srcPath:i}=n.event,[l,s]=i.split("/").slice(-2),o=eo().parse(s).name;e({description:"Detected ".concat(l," ").concat(o," ").concat(t),status:"info",variant:"left-accent",position:"bottom-right",duration:5e3,isClosable:!0}),r()}}catch(e){console.error(e)}},t.onerror=e=>{console.error(e)},t.onclose=()=>{i(e=>"connected"===e?"disconnected":e),n.current.ws=void 0}};return(0,j.useEffect)(()=>{let e=n.current;return s(),()=>{e.ws&&e.ws.close()}},[]),{connectionStatus:t,connect:s}}(),R=(0,j.useCallback)(e=>{if(k){var n;return null===(n=k[e])||void 0===n||n}return!0},[k]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ep.Provider,{value:{lineageGraph:a,retchLineageGraph:()=>{o.refetch()},envInfo:{adapterType:g,git:v,pullRequest:w,dbt:{base:C,current:_},sqlmesh:u},reviewMode:x,cloudMode:m,fileMode:p,fileName:f,isDemoSite:h,error:c,supportTasks:k,isActionAvailable:R,isLoading:s.isLoading,runsAggregated:o.data,refetchRunsAggregated:()=>{o.refetch()}},children:r}),(0,i.jsxs)(Y.u_,{isOpen:"disconnected"===S,onClose:()=>{},isCentered:!0,children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{children:[(0,i.jsx)(en.x,{children:"Server Disconnected"}),(0,i.jsx)(et.f,{children:(0,i.jsx)(ei.x,{children:"The server connection has been lost. Please restart the Recce server and try again."})}),(0,i.jsx)(el.m,{children:(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>{z()},children:"Retry"})})]})]})]})}let eg=()=>(0,j.useContext)(ep),ev=()=>{let{runsAggregated:e,refetchRunsAggregated:n}=eg();return[e,n]};var ej=t(65050);let ey=e=>{let{isOpen:n,onClose:t,onExecute:r,type:s,title:a,params:c,RunForm:d}=e,[u,h]=(0,j.useState)(c),[x,m]=(0,j.useState)(!1);return(0,i.jsxs)(Y.u_,{isOpen:n,onClose:t,size:"6xl",scrollBehavior:"inside",children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{overflowY:"auto",height:"75%",children:[(0,i.jsx)(en.x,{children:a}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(et.f,{p:"0px",h:"100%",overflow:"auto",borderY:"1px solid lightgray",children:(0,i.jsx)(l.x,{style:{contain:"layout"},children:d&&(0,i.jsx)(d,{params:u,onParamsChanged:h,setIsReadyToExecute:m})})}),(0,i.jsx)(el.m,{children:(0,i.jsx)(o.k,{gap:"10px",children:(0,i.jsx)(er.z,{isDisabled:!x,colorScheme:"blue",onClick:()=>{r(s,u)},children:"Execute"})})})]})]})};var eb=t(6604),ew=t(78473),ek=t(20413),eC=t(94134),e_=t(61381),eS=t(90788),ez=t(82821),eR=t.n(ez);function eE(e,n){let t=[];return e.forEach(e=>{t.some(n=>n.name===e.name)||t.push(e)}),n.forEach(e=>{t.some(n=>n.name===e.name)||t.push(e)}),t}var eT=e=>{var n;let{lineageGraph:t}=eg(),[i,l]=(0,j.useState)([]),[r,s]=(0,j.useState)(),[o,a]=(0,j.useState)(!0),[c,d]=(0,j.useState)(null),u=eR().find(null==t?void 0:t.nodes,{name:e}),h=(0,j.useMemo)(()=>u?function(e){function n(e){return e&&e.columns?Object.values(e.columns):[]}return eE(n(e.data.base),n(e.data.current))}(u):[],[u]),x=u?null===(n=u.data.current)||void 0===n?void 0:n.primary_key:void 0;return(0,j.useEffect)(()=>{let e=async()=>{try{let e=(await X(null==u?void 0:u.id)).model;if(!e||!e.base.columns||!e.current.columns){l([]);return}s(e.current.primary_key);let n=Object.values(e.base.columns),t=Object.values(e.current.columns);l(eE(n,t))}catch(e){d(e)}};h.length>0?(l(h),s(x)):(null==u?void 0:u.id)===void 0?l([]):e(),a(!1)},[null==u?void 0:u.id,h,x]),{columns:i,primaryKey:r,isLoading:o,error:c}};function eD(e){return["CHAR","VARCHAR","TINYTEXT","TEXT","MEDIUMTEXT","LONGTEXT","NCHAR","NVARCHAR","VARCHAR2","NVARCHAR2","CLOB","NCLOB","VARCHAR(MAX)","XML","JSON","BOOLEAN","TINYINT(1)","BIT","NUMBER(1)","BOOL"].includes(e.toUpperCase())}function eL(e){return["DATE","DATETIME","TIMESTAMP","TIME","YEAR","DATETIME2","SMALLDATETIME","DATETIMEOFFSET","INTERVAL","TIMESTAMPTZ","TIMETZ","TIMESTAMP WITH TIME ZONE","TIMESTAMP WITH LOCAL TIME ZONE","TIMESTAMP_LTZ","TIMESTAMP_NTZ","TIMESTAMP_TZ"].includes(e.toUpperCase())}var eI=t(77125),eM=t(94659),eO=t(42921);function eA(e){let n=e>0&&e<=.001,t=e<1&&e>=.999,i=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e;return function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US",t=arguments.length>2?arguments[2]:void 0;return"number"!=typeof e?e:new Intl.NumberFormat(n,t).format(e)}(n,"en-US",{style:"percent",minimumFractionDigits:1})};if(n){let e=i(.001);return"<".concat(e)}if(t){let e=i(.999);return">".concat(e)}return i()}function eF(e){if("number"!=typeof e)return e;{let n=Math.abs(e),t=n>=.01,i=n>=1e6,l=n>=1e9,r=n>=1e15;if(r||n>=1e12)return new Intl.NumberFormat("en-US",{style:"unit",unit:"liter",unitDisplay:"narrow",maximumFractionDigits:r?0:2}).format(e/1e12).replace("L","T");if(l||i||n>=1e3){let n={base:l?1e9:i?1e6:1e3,unit:l?"B":i?"M":"K"};return new Intl.NumberFormat("en-US",{style:"unit",unit:"liter",unitDisplay:"narrow",maximumFractionDigits:1}).format(e/n.base).replace("L",n.unit)}return n>=1?new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(e):new Intl.NumberFormat("en-US",{maximumFractionDigits:t?3:2,notation:t||0===n?"standard":"scientific"}).format(e)}}let eN="#63B3ED",eq="#F6AD55",eV="".concat(eN,"A5"),eH="".concat(eq,"A5");function eP(e){let{color:n}=e;return(0,i.jsx)(l.x,{display:"inline-block",w:"10px",h:"10px",bgColor:n,mr:"2",borderRadius:"sm"})}function eW(e){let{data:n,hideAxis:t=!1,animation:l=!1}=e;eM.kL.register(eM.ZL,eM.RM,eM.f$,eM.uw,eM.Dx,eM.De,eM.u);let r=function(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{...t}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{title:i,datasets:l,type:r,samples:s=0,binEdges:o}=e,[a,c]=l,d="datetime"===r;return{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{reverse:!0},title:{display:!0,text:i,font:{size:20}},tooltip:{mode:"index",intersect:!1,callbacks:{title(e){let[{dataIndex:n,datasetIndex:t}]=e,i=eJ(o,n);return"".concat(d?"Date Range":"string"===r?"Text Length":"Value Range","\n").concat(i)},label(e){let{datasetIndex:n,dataIndex:t,dataset:{label:i}}=e,l=0===n?c.counts:a.counts,r=eA(l[t]/s),o=l[t];return"".concat(i,": ").concat(o," (").concat(r,")")}}}},scales:function(e){let{datasets:n,min:t=0,max:i=0,type:l,binEdges:r}=e,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],[o,a]=n,c=Math.max(...a.counts,...o.counts),d=r.map((e,n)=>eJ(r,n)).slice(0,-1);return{x:"datetime"===l?{display:!s,type:"timeseries",min:t,max:i,adapters:{date:{}},time:{minUnit:"day"},grid:{display:!1},ticks:{minRotation:30,maxRotation:30,maxTicksLimit:8}}:{display:!s,type:"category",grid:{display:!1},ticks:{callback:(e,n)=>d[n]},stacked:!0},y:{display:!s,type:"linear",max:c,border:{dash:[2,2]},grid:{color:"lightgray"},ticks:{maxTicksLimit:8,callback:function(e,n){return eF(e)}},beginAtZero:!0}}}(e,n),...t}}(n,t,{animation:l}),s=function(e){let{datasets:n,type:t,binEdges:i}=e,[l,r]=n,s=eK(t,i,"Current",eV,r),o=eK(t,i,"Base",eH,l);return{labels:i.map((e,n)=>eJ(i,n)).slice(0,-1),datasets:[s,o]}}(n);return(0,i.jsx)(eO.kL,{type:"bar",options:r,data:s,plugins:[]})}function eK(e,n,t,i,l){let{counts:r=[]}=l;return{label:t,data:"datetime"===e?r.map((e,t)=>({x:n[t],y:e})):r,backgroundColor:i,borderColor:i,hoverBackgroundColor:i,borderWidth:0,categoryPercentage:1,barPercentage:1,xAxisID:"x"}}function eJ(e,n){let t=e[n],i=e[n+1],l=eF(t),r=eF(i);return"".concat(l," - ").concat(r)}let eB=(0,eI.G)((e,n)=>{let{backgroundColor:t="white",blockSize:r,children:s,...o}=e;return(0,i.jsx)(l.x,{ref:n,...o,overflowY:"auto",overflowX:"hidden",children:(0,i.jsx)(l.x,{backgroundColor:t,height:"100%",blockSize:r,children:s})})}),eU=(0,eI.G)(function(e,n){var t,r,s,a,c,d;let{run:x}=e,m=x.params,p=null===(t=x.result)||void 0===t?void 0:t.base,f=null===(r=x.result)||void 0===r?void 0:r.current,g=null===(s=x.result)||void 0===s?void 0:s.min,v=null===(a=x.result)||void 0===a?void 0:a.max,j=null===(c=x.result)||void 0===c?void 0:c.bin_edges;return p&&f?(0,i.jsx)(o.k,{direction:"column",height:"100%",children:(0,i.jsx)(eB,{ref:n,height:"100%",children:(0,i.jsxs)(u.U,{children:[(0,i.jsx)(h.L,{}),(0,i.jsx)(l.x,{w:"80%",h:"35vh",m:"4",children:(0,i.jsx)(eW,{data:{title:"Model ".concat(m.model,".").concat(m.column_name),type:(null===(d=x.params)||void 0===d?void 0:d.column_type)||"",datasets:[f,p],min:g,max:v,samples:p.total,binEdges:j}})}),(0,i.jsx)(h.L,{})]})})}):(0,i.jsx)("div",{children:"Loading..."})});var eZ=t(21129);t(91751);var eQ=t(30614);let eX=(0,eI.G)((e,n)=>{let{...t}=e;return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(eQ.ZP,{ref:n,...t})})});function eG(){return(0,i.jsx)(o.k,{h:"35px",alignItems:"center",justifyContent:"center",bg:"gray.100",style:{textAlign:"center",gridColumn:"1/-1"},children:(0,i.jsx)(ei.x,{fontWeight:"600",children:" No rows"})})}t(24550);var eY=t(8);function e$(e,n){let t=function(e,n){let t=[...e],i=[...n],l=[];for(;t.length>0&&i.length>0;)if(l.includes(t[0]))t.shift();else if(l.includes(i[0]))i.shift();else if(t[0]===i[0])l.push(t[0]),t.shift(),i.shift();else if(i.includes(t[0])){let e=i.indexOf(t[0]);for(let n=0;n{l.includes(e)||l.push(e)}),i.forEach(e=>{l.includes(e)||l.push(e)}),l}(e,n),i={};for(let l of t)e.includes(l)?n.includes(l)?i[l]=void 0:i[l]="removed":i[l]="added";let l={};e.forEach((e,n)=>{l[e]=n});let r=-1;for(let e of t){let n=l[e];void 0!==n&&(n>r?r=n:i[e]="reordered")}return i}function e0(e,n){let t=[];for(let i of n){let n=e.findIndex(e=>e.name===i);if(n<0)throw Error("Column ".concat(i," not found"));t.push(n)}return t}function e1(e,n,t){let i={};if(0===n.length)return JSON.stringify({_index:t._index});for(let l of n)i[e[l].name]=t[l];return JSON.stringify(i)}function e5(e){let{name:n,columnStatus:t,onPrimaryKeyChange:r,onPinnedColumnsChange:a,...c}=e,d=c.primaryKeys||[],u=c.pinnedColumns||[],h=d.includes(n),x=u.includes(n);return"index"===n?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(o.k,{alignItems:"center",gap:"10px",className:"grid-header",children:[(0,i.jsx)(l.x,{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:n}),"added"!==t&&"removed"!==t&&r&&(0,i.jsx)(s.J,{className:h?"close-icon":"key-icon",display:h?"block":"none",cursor:"pointer",as:h?eY.ven:eY.MhP,onClick:h?()=>{let e=d.filter(e=>e!==n);r&&r(e)}:()=>{let e=[...d.filter(e=>"index"!==e),n];r&&r(e)}}),!h&&a&&(0,i.jsx)(s.J,{className:x?"unpin-icon":"pin-icon",display:x?"block":"none",cursor:"pointer",as:x?eY.$kI:eY.oJP,onClick:x?()=>{let e=u.filter(e=>e!==n);a&&a(e)}:()=>{let e=[...u,n];a&&a(e)}})]})}let e2=e=>{let n;let t=!1;return"boolean"==typeof e?n=e.toString():""===e?(n="(empty)",t=!0):null==e?(n="(null)",t=!0):n=e,[n,t]},e4=e=>{let{row:n,column:t}=e;if(!n.hasOwnProperty(t.key))return(0,i.jsx)(ei.x,{style:{color:"gray"},children:"-"});let[l,r]=e2(n[t.key]);return(0,i.jsx)(ei.x,{style:{color:r?"gray":"inherit"},children:l})};function e6(e,n,t){let l=e||{columns:[],data:[]},r=n||{columns:[],data:[]},s=(null==t?void 0:t.primaryKeys)||[],o=(null==t?void 0:t.pinnedColumns)||[],a=(null==t?void 0:t.changedOnly)||!1,c=[],d=function(e,n){let t={};return Object.entries(e$(e.columns.map(e=>e.name),n.columns.map(e=>e.name))).map(i=>{let[l,r]=i;t[l]={status:r,baseColumnIndex:e.columns.findIndex(e=>e.name===l),currentColumnIndex:n.columns.findIndex(e=>e.name===l)}}),t}(l,r),u={},h={},x=!1,m=!1;if(0===s.length)l.data.forEach((e,n)=>{e._index=n+1,u[JSON.stringify({_index:n+1})]=e}),r.data.forEach((e,n)=>{e._index=n+1,h[JSON.stringify({_index:n+1})]=e});else{let e=e0(l.columns,s);l.data.forEach((n,t)=>{let i=e1(l.columns,e,n);i in u&&(x=!0),u[i]=n}),e=e0(r.columns,s),r.data.forEach((n,t)=>{let i=e1(r.columns,e,n);i in h&&(m=!0),h[i]=n})}let p=e$(Object.keys(u),Object.keys(h)),f={added:0,removed:0,modified:0},g=Object.entries(p).map(e=>{let[n,t]=e,i=u[n],o=h[n],a=JSON.parse(n);if(i&&l.columns.forEach((e,n)=>{s.includes(e.name)||(a["base__".concat(e.name)]=i[n])}),o&&r.columns.forEach((e,n)=>{s.includes(e.name)||(a["current__".concat(e.name)]=o[n])}),i){if(o){for(let[e,n]of Object.entries(d))"index"===e||s.includes(e)||n.baseColumnIndex<0||n.currentColumnIndex<0||eR().isEqual(i[n.baseColumnIndex],o[n.currentColumnIndex])||(a.__status="modified",n.status="modified");"modified"===a.__status&&f.modified++}else a.__status="removed",f.removed++}else a.__status="added",f.added++;return a});a&&(g=g.filter(e=>"added"===e.__status||"removed"===e.__status||"modified"===e.__status));let v=(e,n)=>{let l="added"===n?"diff-header-added":"removed"===n?"diff-header-removed":void 0,r=t=>{let i=t.__status;if("removed"===i)return"diff-cell-removed";if("added"===i)return"diff-cell-added";if("added"===n);else if("removed"===n);else if(!eR().isEqual(t["base__".concat(e)],t["current__".concat(e)]))return"diff-cell-modified"};return{headerCellClass:l,name:(0,i.jsx)(e5,{name:e,columnStatus:n,...t}),children:[{key:"base__".concat(e),name:"Base",renderEditCell:eQ.Ug,headerCellClass:l,cellClass:r,renderCell:e4,size:"auto"},{key:"current__".concat(e),name:"Current",renderEditCell:eQ.Ug,headerCellClass:l,cellClass:r,renderCell:e4,size:"auto"}]}};return 0===s.length?c.push({key:"_index",width:50,maxWidth:100,name:"",cellClass:"index-column"}):s.forEach(e=>{let n=d[e].status||"";c.push({key:"".concat(e),name:(0,i.jsx)(e5,{name:e,columnStatus:n,...t}),frozen:!0,cellClass:e=>{if(e.__status)return"diff-header-".concat(e.__status)},renderCell:e4})}),o.forEach(e=>{let n=d[e].status||"";"index"===e||s.includes(e)||c.push(v(e,n))}),Object.entries(d).forEach(e=>{let[n,t]=e,i=t.status||"";"index"===n||s.includes(n)||o.includes(n)||a&&f.modified>0&&"added"!==i&&"removed"!==i&&"modified"!==i||c.push(v(n,i))}),{columns:c,rows:g,invalidPKeyBase:x,invalidPKeyCurrent:m}}let e3=(0,eI.G)((e,n)=>{var t;let{run:l,viewOptions:r,onViewOptionsChanged:s}=e,o=l.result;l.params;let a=(0,j.useMemo)(()=>(null==r?void 0:r.pinned_columns)||[],[r]),c=((null==o?void 0:null===(t=o.current)||void 0===t?void 0:t.columns)||[]).find(e=>"column_name"===e.name.toLowerCase()),d=(null==c?void 0:c.name)||"column_name",u=(0,j.useMemo)(()=>e6(null==o?void 0:o.base,null==o?void 0:o.current,{primaryKeys:[d],pinnedColumns:a,onPinnedColumnsChange:e=>{s&&s({...r,pinned_columns:e})}}),[o,d,a,r,s]);return 0===u.columns.length?(0,i.jsx)(eZ.M,{height:"100%",children:"No data"}):(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:u.columns,rows:u.rows,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})})});function e9(e){let{name:n,columnStatus:t,onPrimaryKeyChange:r,onPinnedColumnsChange:a,...c}=e,d=c.primaryKeys||[],u=c.pinnedColumns||[],h=d.includes(n),x=u.includes(n);return"index"===n?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(o.k,{alignItems:"center",gap:"10px",className:"grid-header",children:[(0,i.jsx)(l.x,{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:n}),!h&&a&&(0,i.jsx)(s.J,{className:x?"unpin-icon":"pin-icon",display:x?"block":"none",cursor:"pointer",as:x?eY.$kI:eY.oJP,onClick:x?()=>{let e=u.filter(e=>e!==n);a&&a(e)}:()=>{let e=[...u,n];a&&a(e)}})]})}function e8(e,n,t){let l=(null==t?void 0:t.pinnedColumns)||[],r=(null==t?void 0:t.changedOnly)||!1,s=[],o=function(e){let n={};return e.columns.map((e,t)=>{n[e.name]={index:t}}),n}(e),a={},c={};if(0===n.length)throw Error("Primary keys are required");let d=function(e,n){let t=[];for(let i of n){let n=e.findIndex(e=>e.name===i);if(n<0)throw Error("Column ".concat(i," not found"));t.push(n)}return t}(e.columns,n),u=(o.in_a||o.IN_A).index,h=(o.in_b||o.IN_B).index;e.data.forEach((n,t)=>{let i=function(e,n,t){let i={};if(0===n.length)return JSON.stringify({_index:t._index});for(let l of n)i[e[l].name]=t[l];return JSON.stringify(i)}(e.columns,d,n);n[u]&&(a[i]=n),n[h]&&(c[i]=n)});let x=e$(Object.keys(a),Object.keys(c)),m={added:0,removed:0,modified:0},p=Object.entries(x).map(t=>{let[i,l]=t,r=a[i],s=c[i],d=JSON.parse(i);if(r&&e.columns.forEach((e,t)=>{n.includes(e.name)||(d["base__".concat(e.name)]=r[t])}),s&&e.columns.forEach((e,t)=>{n.includes(e.name)||(d["current__".concat(e.name)]=s[t])}),r){if(s)for(let[e,t]of Object.entries(o))!("index"===e||n.includes(e))&&(eR().isEqual(r[t.index],s[t.index])||(d.__status="modified",t.status="modified"));else d.__status="removed",m.removed++}else d.__status="added",m.added++;return"modified"===d.__status&&m.modified++,d});r&&(p=p.filter(e=>"added"===e.__status||"removed"===e.__status||"modified"===e.__status));let f=(e,n)=>{let l="added"===n?"diff-header-added":"removed"===n?"diff-header-removed":void 0,r=t=>{let i=t.__status;if("removed"===i)return"diff-cell-removed";if("added"===i)return"diff-cell-added";if("added"===n);else if("removed"===n);else if(!eR().isEqual(t["base__".concat(e)],t["current__".concat(e)]))return"diff-cell-modified"};return{headerCellClass:l,name:(0,i.jsx)(e9,{name:e,columnStatus:n,...t}),children:[{key:"base__".concat(e),name:"Base",renderEditCell:eQ.Ug,headerCellClass:l,cellClass:r,renderCell:e4,size:"auto"},{key:"current__".concat(e),name:"Current",renderEditCell:eQ.Ug,headerCellClass:l,cellClass:r,renderCell:e4,size:"auto"}]}};return n.forEach(e=>{let n=o[e].status||"";s.push({key:"".concat(e),name:(0,i.jsx)(e9,{name:e,columnStatus:n,...t}),frozen:!0,cellClass:e=>{if(e.__status)return"diff-header-".concat(e.__status)},renderCell:e4})}),l.forEach(e=>{let t=o[e].status||"";n.includes(e)||s.push(f(e,t))}),Object.entries(o).forEach(e=>{let[t,i]=e,o=i.status||"";"in_a"===t||"in_b"===t||n.includes(t)||l.includes(t)||r&&m.modified>0&&"added"!==o&&"removed"!==o&&"modified"!==o||s.push(f(t,o))}),{columns:s,rows:p}}var e7=t(80906),ne=t(89494),nn=t(13329);let nt=e=>{let{run:n,warnings:t,viewOptions:r,onAddToChecklist:s,onViewOptionsChanged:a}=e;return(0,i.jsxs)(o.k,{borderBottom:"1px solid lightgray",justifyContent:"flex-end",gap:"5px",alignItems:"center",px:"10px",bg:t&&t.length>0?"orange.100":"inherit",children:[(0,i.jsx)(ne.g,{alignItems:"flex-start",spacing:0,children:t&&t.map((e,n)=>(0,i.jsxs)(l.x,{children:[(0,i.jsx)(e7.a,{color:"orange.600"})," ",e]},n))}),(0,i.jsx)(h.L,{minHeight:"32px"}),(0,i.jsx)(nn.X,{isChecked:null==r?void 0:r.changed_only,onChange:()=>{let e=!(null==r?void 0:r.changed_only);a&&a({...r,changed_only:e})},children:"Changed only"}),s&&(0,i.jsx)(er.z,{marginBlock:"5px",size:"sm",colorScheme:"blue",onClick:()=>s(n),children:"Add to Checklist"})]})},ni=(e,n)=>{var t,l,r,s,a,c;let{run:d,onAddToChecklist:u,viewOptions:h,onViewOptionsChanged:x}=e,m=(0,j.useMemo)(()=>(null==h?void 0:h.primary_keys)||[],[h]),p=(0,j.useMemo)(()=>(null==h?void 0:h.changed_only)||!1,[h]),f=(0,j.useMemo)(()=>(null==h?void 0:h.pinned_columns)||[],[h]),g=(0,j.useMemo)(()=>{var e,n;return e6(null==d?void 0:null===(e=d.result)||void 0===e?void 0:e.base,null==d?void 0:null===(n=d.result)||void 0===n?void 0:n.current,{changedOnly:p,primaryKeys:m,onPrimaryKeyChange:e=>{x&&x({...h,primary_keys:e})},pinnedColumns:f,onPinnedColumnsChange:e=>{x&&x({...h,pinned_columns:e})}})},[d,h,p,m,f,x]),v=(0,j.useMemo)(()=>{let e=m.join(", ");return g.invalidPKeyBase&&g.invalidPKeyCurrent?"Warning: The primary key '".concat(e,"' is not unique in the base and current environments"):g.invalidPKeyBase?"Warning: The primary key '".concat(e,"' is not unique in the base environment"):g.invalidPKeyCurrent?"Warning: The primary key '".concat(e,"' is not unique in the current environment"):void 0},[g.invalidPKeyBase,g.invalidPKeyCurrent,m]),y=(null===(l=d.result)||void 0===l?void 0:null===(t=l.current)||void 0===t?void 0:t.limit)||0,b=y>0&&((null==d?void 0:null===(s=d.result)||void 0===s?void 0:null===(r=s.current)||void 0===r?void 0:r.more)||(null==d?void 0:null===(c=d.result)||void 0===c?void 0:null===(a=c.base)||void 0===a?void 0:a.more))?"Warning: Displayed results are limited to ".concat(y.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null,w=[];return(v&&w.push(v),b&&w.push(b),0===g.columns.length)?(0,i.jsx)(eZ.M,{height:"100%",children:"No data"}):p&&0===g.rows.length?(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsx)(nt,{run:d,viewOptions:h,onAddToChecklist:u,onViewOptionsChanged:x,warnings:w}),(0,i.jsx)(eZ.M,{height:"100%",children:"No change"}),";"]}):(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsx)(nt,{run:d,viewOptions:h,onAddToChecklist:u,onViewOptionsChanged:x,warnings:w}),(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:g.columns,rows:g.rows,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})},nl=(e,n)=>{var t,l,r,s;let{run:a,onAddToChecklist:c,viewOptions:d,onViewOptionsChanged:u}=e,h=(0,j.useMemo)(()=>(null==d?void 0:d.changed_only)||!1,[d]),x=(0,j.useMemo)(()=>(null==d?void 0:d.pinned_columns)||[],[d]),m=(0,j.useMemo)(()=>{var e,n;if(!(null===(e=a.result)||void 0===e?void 0:e.diff)||!(null==a?void 0:null===(n=a.params)||void 0===n?void 0:n.primary_keys))return{columns:[],rows:[]};let t=a.params.primary_keys;return e8(null==a?void 0:a.result.diff,t,{changedOnly:h,pinnedColumns:x,onPinnedColumnsChange:e=>{u&&u({...d,pinned_columns:e})}})},[a,d,h,x,u]),p=(null===(l=a.result)||void 0===l?void 0:null===(t=l.diff)||void 0===t?void 0:t.limit)||0,f=p>0&&(null==a?void 0:null===(s=a.result)||void 0===s?void 0:null===(r=s.diff)||void 0===r?void 0:r.more)?"Warning: Displayed results are limited to ".concat(p.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null,g=[];return(f&&g.push(f),0===m.columns.length)?(0,i.jsx)(eZ.M,{height:"100%",children:"No data"}):h&&0===m.rows.length?(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsx)(nt,{run:a,viewOptions:d,onAddToChecklist:c,onViewOptionsChanged:u,warnings:g}),(0,i.jsx)(eZ.M,{height:"100%",children:"No change"})]}):(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsx)(nt,{run:a,viewOptions:d,onAddToChecklist:c,onViewOptionsChanged:u,warnings:g}),(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:m.columns,rows:m.rows,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})},nr=(0,eI.G)((e,n)=>{var t;if((null===(t=e.run)||void 0===t?void 0:t.result)!==void 0&&null!==e.run.result.diff&&void 0!==e.run.result.diff){let t=(0,eI.G)(nl);return(0,i.jsx)(t,{...e,ref:n})}{let t=(0,eI.G)(ni);return(0,i.jsx)(t,{...e,ref:n})}});function ns(e){let{name:n,pinnedColumns:t=[],onPinnedColumnsChange:r=()=>{}}=e,a=t.includes(n);return(0,i.jsxs)(o.k,{className:"grid-header",alignItems:"center",children:[(0,i.jsx)(l.x,{flex:1,children:n}),(0,i.jsx)(s.J,{className:a?"unpin-icon":"pin-icon",display:a?"block":"none",cursor:"pointer",as:a?eY.$kI:eY.oJP,onClick:a?()=>{r(t.filter(e=>e!==n))}:()=>{r([...t,n])}})]})}let no=(0,eI.G)((e,n)=>{let{run:t,viewOptions:r,onViewOptionsChanged:s,onAddToChecklist:a}=e,c=(0,j.useMemo)(()=>(null==r?void 0:r.pinned_columns)||[],[r]),d=null==t?void 0:t.result,u=(0,j.useMemo)(()=>d?function(e,n){let t=[],l=n.pinnedColumns||[],r=(e,t)=>({key:String(e),name:(0,i.jsx)(ns,{name:t,...n}),width:"auto",renderCell:e4});return t.push({key:"_index",name:"",width:50,cellClass:"index-column"}),l.forEach(n=>{let i=eR().findIndex(e.columns,e=>e.name===n);i<0||t.push(r(i,n))}),e.columns.forEach((e,n)=>{l.includes(e.name)||t.push(r(n,e.name))}),e.data.forEach((e,n)=>{e._index=n+1}),{columns:t,rows:e.data}}(d,{pinnedColumns:c,onPinnedColumnsChange:e=>{s&&s({...r,pinned_columns:e})}}):{rows:[],columns:[]},[d,c,r,s]);if(0===u.columns.length)return(0,i.jsx)(eZ.M,{height:"100%",children:"No data"});let x=(null==d?void 0:d.limit)||0,m=x>0&&(null==d?void 0:d.more)?"Warning: Displayed results are limited to ".concat(x.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null,p=a||m;return(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[p&&(0,i.jsxs)(o.k,{borderBottom:"1px solid lightgray",alignItems:"center",gap:"5px",px:"10px",bg:m?"orange.100":"inherit",children:[m&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e7.a,{color:"orange.600",alignSelf:"center"})," ",(0,i.jsx)(l.x,{children:m})]}),(0,i.jsx)(h.L,{minHeight:"32px"}),a&&(0,i.jsx)(er.z,{marginBlock:"5px",size:"sm",colorScheme:"blue",onClick:()=>a(t),children:"Add to Checklist"})]}),(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:u.columns,rows:u.rows,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})});function na(e,n){if(e=.1?t.toFixed(1):" <0.1 ","%")}if(!(e>n))return"0 %";{let t=(e-n)/e*100;return"-".concat(t>=.1?t.toFixed(1):" <0.1 ","%")}}var nc=t(22442),nd=t.n(nc);let nu=(0,eI.G)(function(e,n){let{run:t}=e;function l(e){if(e.base===e.current);else if(e.basee.current||"N/A"===e.current)return"column-body-removed";return"column-body-normal"}let r=t.result||{},s=Object.keys(t.result||{}).map(e=>{let n=r[e],t=nd()(null==n?void 0:n.base)?null==n?void 0:n.base:null,i=nd()(null==n?void 0:n.curr)?null==n?void 0:n.curr:null,l="No Change";return null!==t&&null!==i?l=t!==i?na(t,i):"No Change":t===i?l="N/A":null===t?l="Added":null===i&&(l="Removed"),{name:e,base:null===t?"N/A":Number(t),current:null===i?"N/A":Number(i),delta:l}});return 0===s.length?(0,i.jsx)(eZ.M,{bg:"rgb(249,249,249)",height:"100%",children:"No nodes matched"}):(0,i.jsx)(o.k,{direction:"column",children:Object.keys(r).length>0&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",fontSize:"10pt",borderWidth:1},columns:[{key:"name",name:"Name",cellClass:l},{key:"base",name:"Base Rows",cellClass:l},{key:"current",name:"Current Rows",cellClass:l},{key:"delta",name:"Delta",cellClass:l}],rows:s,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},className:"rdg-light",enableScreenshot:!0})})})});var nh=t(62019),nx=t(429);let nm="#63B3ED";function np(e,n){let t=n?10:e.counts.length,i=e.counts.slice(0,t),l=e.valids-i.reduce((e,n)=>e+n,0);return e.values.slice(0,t).concat([l]).map((n,t)=>{let r;let s=t===i.length,o=s?l:i[t],a=!1;return s?(r="(others)",a=!0):null==n?(r="(null)",a=!0):"string"==typeof n&&0===n.length?(r="(empty)",a=!0):r=String(n),{isLastItemOthers:s,isSpecialLabel:a,label:r,count:o,displayCount:eF(o),displayRatio:eA(o/e.valids)||"N/A"}})}function nf(e){let{base:n,current:t,children:r}=e;return(0,i.jsx)(nh.u,{label:(0,i.jsxs)(l.x,{children:[(0,i.jsxs)(ei.x,{children:[(0,i.jsx)(eP,{color:eN}),"Current: ",t.count," (",t.displayRatio,")"]}),(0,i.jsxs)(ei.x,{children:[(0,i.jsx)(eP,{color:eq}),"Base: ",n.count," (",n.displayRatio,")"]})]}),placement:"auto",hasArrow:!0,children:r})}function ng(e){let{topKDiff:n,isDisplayTopTen:t}=e,r=np(n.current,t),s=np(n.base,t);return(0,i.jsxs)(l.x,{w:"100%",px:20,py:4,children:[(0,i.jsxs)(o.k,{alignItems:"center",direction:"row",children:[(0,i.jsx)(h.L,{}),(0,i.jsxs)(ei.x,{as:"h3",size:"sm",p:"2",color:"gray",children:[(0,i.jsx)(eP,{color:eq})," Base"]}),(0,i.jsxs)(ei.x,{as:"h3",size:"sm",p:"2",color:"gray",children:[(0,i.jsx)(eP,{color:eN})," Current"]}),(0,i.jsx)(h.L,{})]}),r.map((e,t)=>{let l=s[t];return e.isLastItemOthers&&0===e.count&&0===l.count?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(j.Fragment,{children:[(0,i.jsx)(nf,{base:l,current:e,children:(0,i.jsxs)(o.k,{alignItems:"center",width:"100%",_hover:{bg:"blackAlpha.300"},px:4,children:[(0,i.jsx)(ei.x,{noOfLines:1,width:"10em",fontSize:"sm",color:e.isSpecialLabel?"gray.400":"inherit",children:e.label}),(0,i.jsxs)(o.k,{width:"70%",direction:"column",children:[(0,i.jsxs)(o.k,{height:"1em",children:[(0,i.jsx)(nv,{topkCount:e.count,topkLabel:e.label,valids:n.current.valids,color:eN}),(0,i.jsx)(ei.x,{ml:5,mr:2,fontSize:"sm",width:"6em",children:e.displayCount}),(0,i.jsx)(ei.x,{color:"gray.400",fontSize:"sm",width:"4em",children:e.displayRatio})]}),(0,i.jsxs)(o.k,{height:"1em",children:[(0,i.jsx)(nv,{topkCount:l.count,topkLabel:l.label,valids:n.base.valids,color:eq}),(0,i.jsx)(ei.x,{ml:5,mr:2,fontSize:"sm",width:"6em",children:l.displayCount}),(0,i.jsx)(ei.x,{color:"gray.400",fontSize:"sm",width:"4em",children:l.displayRatio})]})]})]})}),(0,i.jsx)(nx.i,{})]},t)})]})}function nv(e){let{topkCount:n,topkLabel:t,valids:l,animation:r=!1,color:s=nm}=e;eM.kL.register(eM.uw,eM.ZL,eM.f$);let o=function(e,n){let{...t}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{responsive:!0,maintainAspectRatio:!1,indexAxis:"y",scales:{x:{display:!1,max:n,grid:{display:!1}},y:{display:!1}},plugins:{tooltip:{enabled:!1}},...t}}(n,l,{animation:r}),a=function(e){let{topkLabel:n,topkCount:t,color:i=nm}=e;return{labels:[n],datasets:[{indexAxis:"y",data:[t],backgroundColor:i,hoverBackgroundColor:i,borderWidth:0,borderColor:i,barPercentage:1,categoryPercentage:.6}]}}({topkCount:n,topkLabel:t,color:s});return(0,i.jsx)(eO.$Q,{data:a,options:o,plugins:[]})}let nj=(0,eI.G)((e,n)=>{let{run:t}=e,[l,s]=(0,j.useState)(!0),a=t.result,d=t.params,x=a.base,m=a.current;return(0,i.jsxs)(o.k,{direction:"column",height:"100%",children:[(0,i.jsxs)(eB,{ref:n,blockSize:"auto",children:[(0,i.jsxs)(c.X,{as:"h1",size:"md",paddingTop:4,textAlign:"center",color:"gray.600",children:["Model ",d.model,".",d.column_name]}),(0,i.jsxs)(u.U,{children:[(0,i.jsx)(h.L,{}),(0,i.jsx)(ng,{topKDiff:a,valids:m.valids||0,isDisplayTopTen:l}),(0,i.jsx)(h.L,{})]})]}),(0,i.jsx)(h.L,{}),(x.values.length>10||m.values.length>10)&&(0,i.jsx)(o.k,{p:5,justify:"start",children:(0,i.jsx)(r.r,{onClick:()=>s(e=>!e),textColor:"blue.500",children:l?"View More Items":"View Only Top-10"})})]})}),ny=(0,eI.G)((e,n)=>{var t,l;let{run:r,onAddToChecklist:s,viewOptions:a,onViewOptionsChanged:c}=e,d=(0,j.useMemo)(()=>(null==a?void 0:a.changed_only)||!1,[a]),u=(0,j.useMemo)(()=>(null==a?void 0:a.pinned_columns)||[],[a]),h=(0,j.useMemo)(()=>{var e;if(!r.result||!(null==r?void 0:null===(e=r.params)||void 0===e?void 0:e.primary_key))return{columns:[],rows:[]};let n=r.params.primary_key,t=Array.isArray(n)?n:[n];return e8(null==r?void 0:r.result,t,{changedOnly:d,pinnedColumns:u,onPinnedColumnsChange:e=>{c&&c({...a,pinned_columns:e})}})},[r,a,d,u,c]),x=(null===(t=r.result)||void 0===t?void 0:t.limit)||0,m=x>0&&(null==r?void 0:null===(l=r.result)||void 0===l?void 0:l.more)?"Warning: Displayed results are limited to ".concat(x.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null,p=[];return(m&&p.push(m),0===h.columns.length)?(0,i.jsx)(eZ.M,{height:"100%",children:"No data"}):d&&0===h.rows.length?(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsx)(nt,{run:r,viewOptions:a,onAddToChecklist:s,onViewOptionsChanged:c,warnings:p}),(0,i.jsx)(eZ.M,{height:"100%",children:"No change"}),";"]}):(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsx)(nt,{run:r,viewOptions:a,onAddToChecklist:s,onViewOptionsChanged:c,warnings:p}),(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:h.columns,rows:h.rows,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})});var nb=t(95021),nw=t(62347);function nk(e){let{params:n,onParamsChanged:t,setIsReadyToExecute:r}=e,[s,o]=(0,j.useState)(!n.columns||0===n.columns.length),a=null==n?void 0:n.model,c=null==n?void 0:n.primary_key,{columns:d,primaryKey:u,isLoading:h,error:x}=eT(n.model);(0,j.useEffect)(()=>{!c&&u&&t({...n,primary_key:u})},[c,u,n,t]),(0,j.useEffect)(()=>{r(!!c&&!!a)},[c,a,r]);let m=d.map(e=>e.name),p=Array.isArray(c)?c:c?[c]:void 0;return h?(0,i.jsx)(l.x,{children:"Loading..."}):0===m.length||x?(0,i.jsx)(l.x,{children:"Error: Please provide the 'catalog.json' to list column candidates"}):(0,i.jsxs)(ne.g,{gap:5,m:"8px 24px",paddingBottom:"200px",children:[(0,i.jsxs)(eC.NI,{children:[(0,i.jsx)(e_.l,{children:"Model"}),(0,i.jsx)(nb.I,{isReadOnly:!0,value:null==n?void 0:n.model})]}),(0,i.jsxs)(eC.NI,{children:[(0,i.jsx)(e_.l,{children:"Primary key"}),(0,i.jsx)(nw.Ph,{placeholder:"Select primary key",isMulti:!0,closeMenuOnSelect:!1,options:(m||[]).map(e=>({label:e,value:e})),value:(p||[]).map(e=>({label:e,value:e})),onChange:e=>{t({...n,primary_key:1==e.length?e[0].value:e.map(e=>e.value)})}})]}),(0,i.jsxs)(eC.NI,{children:[(0,i.jsx)(e_.l,{children:"Columns"}),(0,i.jsx)(nn.X,{marginBottom:"10px",isChecked:s,onChange:e=>{o(e.target.checked),t({...n,columns:void 0})},children:"All columns"}),!s&&(0,i.jsx)(nw.Ph,{isMulti:!0,closeMenuOnSelect:!1,options:(m||[]).map(e=>({label:e,value:e})),value:(n.columns||[]).map(e=>({label:e,value:e})),onChange:e=>{t({...n,columns:(e||[]).map(e=>e.value)})}})]})]})}var nC=t(13994),n_=t(54627),nS=t(53254),nz=t(66791),nR=t(57334),nE=t(15405);function nT(e){let{params:n,column:t}=e,{runAction:r}=nq(),a=(e,t)=>{r("value_diff_detail",{...n,...e},t)};return(0,i.jsxs)(o.k,{children:[(0,i.jsx)(l.x,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:t}),(0,i.jsx)(h.L,{}),(0,i.jsx)(nC.v,{isLazy:!0,children:e=>{let{isOpen:n}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n_.j,{className:"row-context-menu",visibility:n?"visible":"hidden",width:n?"auto":"0px",minWidth:n?"auto":"0px",as:nS.h,icon:(0,i.jsx)(s.J,{as:eY.D_A}),variant:"unstyled",size:"sm"}),(0,i.jsx)(nz.q,{lineHeight:"20px",children:(0,i.jsxs)(nR.k,{title:"Action",as:l.x,fontSize:"8pt",children:[(0,i.jsx)(nE.s,{fontSize:"10pt",onClick:()=>a({},{showForm:!0}),children:"Show mismatched values..."}),(0,i.jsxs)(nE.s,{fontSize:"10pt",onClick:()=>a({columns:[t]},{showForm:!1}),children:["Show mismatched values for '",t,"'"]})]})})]})}})]})}let nD=(0,eI.G)(function(e,n){let{run:t}=e,r=t.result,a=t.params,c=e=>{let n=e[2];return null!=n&&n<1?"diff-cell-modified":""},d=Array.isArray(a.primary_key)?a.primary_key:[a.primary_key],u=[{key:"__is_pk__",name:"",width:30,maxWidth:30,renderCell:e=>{let{row:n}=e;return(0,i.jsx)(eZ.M,{height:"100%",children:d.includes(n[0])&&(0,i.jsx)(s.J,{as:eY.MhP})})}},{key:"0",name:"Column",resizable:!0,renderCell:e=>{let{row:n,column:t}=e;return(0,i.jsx)(nT,{column:n[t.key],params:a})},cellClass:"cell-show-context-menu"},{key:"1",name:"Matched",resizable:!0,cellClass:c},{key:"2",name:"Matched %",resizable:!0,renderCell:e=>{let{column:n,row:t}=e,r=t[n.key];return(0,i.jsx)(l.x,{textAlign:"end",children:void 0!=r&&null!==r?"".concat((100*r).toFixed(2)," %"):"N/A"})},cellClass:c}];return(0,i.jsxs)(o.k,{direction:"column",gap:"5px",pt:"5px",height:"100%",children:[(0,i.jsxs)(l.x,{px:"16px",children:["Model: ",a.model,", ",r.summary.total," total (",r.summary.total-r.summary.added-r.summary.removed," ","common, ",r.summary.added," added, ",r.summary.removed," removed)"]}),(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",borderBlock:"1px solid lightgray"},columns:u,rows:r.data.data,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},defaultColumnOptions:{resizable:!0},className:"rdg-light",enableScreenshot:!0})]})});var nL=t(46970),nI=t(7600);let nM={lineage_diff:{title:"Lineage Diff",icon:ek.Ks7},schema_diff:{title:"Schema Diff",icon:nI.C8A},query:{title:"Query",icon:ek.r2i,RunResultView:no},query_base:{title:"Query Base",icon:ek.r2i,RunResultView:no},query_diff:{title:"Query Diff",icon:ek.r2i,RunResultView:nr},row_count_diff:{title:"Row Count Diff",icon:nI.QUK,RunResultView:nu},profile_diff:{title:"Profile Diff",icon:ek.KA6,RunResultView:e3},value_diff:{title:"Value Diff",icon:ek.pRi,RunResultView:nD,RunForm:nk},value_diff_detail:{title:"Value Diff Detail",icon:ek.pRi,RunResultView:ny,RunForm:nk},top_k_diff:{title:"Top-K Diff",icon:nL.Pkc,RunResultView:nj,RunForm:function(e){let{params:n,onParamsChanged:t,setIsReadyToExecute:r}=e,{columns:s,isLoading:o,error:a}=eT(n.model),c=s.map(e=>e.name);return((0,j.useEffect)(()=>{r(!!n.column_name)},[n,r]),o)?(0,i.jsx)(l.x,{children:"Loading..."}):0===c.length||a?(0,i.jsx)(l.x,{children:"Error: Please provide the 'catalog.json' to list column candidates"}):(0,i.jsx)(l.x,{m:"16px",children:(0,i.jsxs)(eC.NI,{children:[(0,i.jsx)(e_.l,{children:"Pick a column to show top-k"}),(0,i.jsx)(eS.P,{placeholder:"Select column",value:null==n?void 0:n.column_name,onChange:e=>{let i=e.target.value;t({...n,column_name:i})},children:c.map(e=>(0,i.jsx)("option",{value:e,children:e},e))})]})})}},histogram_diff:{title:"Histogram Diff",icon:ek.dku,RunResultView:eU,RunForm:function(e){let{params:n,onParamsChanged:t,setIsReadyToExecute:r}=e,{columns:s,isLoading:o,error:a}=eT(n.model),c=s.filter(e=>!eD(e.type)&&!eL(e.type));return o?(0,i.jsx)(l.x,{children:"Loading..."}):0===s.length||a?(0,i.jsx)(l.x,{children:"Error: Please provide the 'catalog.json' to list column candidates"}):(0,i.jsx)(l.x,{m:"16px",children:(0,i.jsxs)(eC.NI,{children:[(0,i.jsx)(e_.l,{children:"Pick a column to show Histogram Diff"}),(0,i.jsx)(eS.P,{placeholder:0!==c.length?"Select column":"No numeric column is available",isDisabled:0===c.length,value:null==n?void 0:n.column_name,onChange:e=>{var i;let l=e.target.value;r(!!l);let s=(null===(i=c.find(e=>e.name===l))||void 0===i?void 0:i.type)||"";t({...n,column_name:l,column_type:s})},children:c.map(e=>(0,i.jsxs)("option",{value:e.name,children:[e.name," : ",e.type]},e.name))})]})})}},preview_change:{title:"Preview Change",icon:ek.iQd,RunResultView:nr}},nO=e=>nM[e],nA=(0,j.createContext)({runAction:()=>{},showRunId:e=>{},isRunResultOpen:!1,closeRunResult:()=>{},isHistoryOpen:!1,closeHistory:()=>{},showHistory:()=>{},clearRunResult:()=>{}}),nF=e=>{let[n]=(0,ew.TH)();(0,j.useEffect)(()=>{e()},[e,n])};function nN(e){var n;let{children:t}=e,[l,r]=(0,j.useState)(),{isOpen:s,onOpen:o,onClose:a}=(0,eb.q)(),{isOpen:c,onOpen:d,onClose:u}=(0,eb.q)(),{isOpen:h,onOpen:x,onClose:m}=(0,eb.q)(),p=(0,G.p)(),[f,g]=(0,j.useState)(),[v,y]=(0,ew.TH)(),w=(0,b.NL)(),k=(0,j.useCallback)((e,n)=>{g(e),d(),!1!==n&&w.invalidateQueries({queryKey:P.runs()})},[g,d,w]),C=(0,j.useCallback)(()=>{g(void 0),u()},[u,g]),_=(0,j.useCallback)(async(e,n,t)=>{try{let i;let l=new Date().getTime().toString();if(null==t?void 0:t.showLast){let t=await eh(e,n,1);1===t.length&&(i=t[0])}let s=nO(e);if(void 0===s)throw Error("Unknown run type: ".concat(e));let{title:a,RunResultView:c,RunForm:d}=s;if(void 0===c)throw Error("Run type ".concat(e," does not have a result view"));if(void 0!==d&&(null==t?void 0:t.showForm))r({session:l,title:a,type:e,params:n,lastRun:i,options:t,RunForm:d}),o();else{let{run_id:t}=await ea(e,n,{nowait:!0});k(t),w.invalidateQueries({queryKey:P.runs()}),v.startsWith("/lineage")&&y("/lineage")}}catch(e){p({title:"Failed to submit a run",description:null==e?void 0:e.message,position:"bottom-right",status:"error",duration:5e3,isClosable:!0})}},[r,o,k,p,v,y,w]);nF(a);let S=async(e,n)=>{try{a();let{run_id:t}=await ea(e,n,{nowait:!0});k(t)}catch(e){p({title:"Failed to submit a run",description:null==e?void 0:e.message,position:"bottom-right",status:"error",duration:5e3,isClosable:!0})}};return(0,j.useEffect)(()=>{f&&v.startsWith("/checks")&&y("/lineage")},[f]),(0,i.jsxs)(nA.Provider,{value:{runAction:_,runId:f,showRunId:k,isRunResultOpen:c,closeRunResult:u,isHistoryOpen:h,closeHistory:m,showHistory:x,clearRunResult:C},children:[l&&(0,i.jsx)(ey,{isOpen:s,onClose:a,onExecute:S,title:l.title,type:l.type,params:l.params,initialRun:l.lastRun,RunForm:(null===(n=l.options)||void 0===n?void 0:n.showForm)&&l.RunForm?l.RunForm:void 0},l.session),t]})}let nq=()=>(0,j.useContext)(nA);function nV(e){let{children:n}=e;return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(C,{children:(0,i.jsx)(ef,{children:(0,i.jsx)(z,{children:(0,i.jsx)(nN,{children:n})})})})})}async function nH(){return(await U.post("/api/checks",{type:"simple"})).data}async function nP(e,n){return(await U.post("/api/checks",{run_id:e,view_options:n})).data}async function nW(){return(await U.get("/api/checks")).data}async function nK(e){return(await U.get("/api/checks/".concat(e))).data}async function nJ(e,n){return(await U.patch("/api/checks/".concat(e),n)).data}async function nB(e){return(await U.delete("/api/checks/".concat(e))).data}async function nU(e){return await U.post("/api/checks/reorder",e)}var nZ=t(6706),nQ=t(96288),nX=t(38597),nG=t(63770),nY=t(15893),n$=t(46919),n0=t(40451),n1=t(52878),n5=t(91425),n2=t(21567),n4=t(19612),n6=t(14968),n3=t(81417),n9=t(89633),n8=t(14257);function n7(e){let{name:n,setName:t}=e,[r,s]=(0,j.useState)(!1),[o,a]=(0,j.useState)(n),c=(0,j.useRef)(null),d=(0,j.useCallback)(()=>{t(o),s(!1)},[t,s,o]);return(0,j.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&d()};return r&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[r,c,d]),(0,i.jsxs)(n3.a,{flex:"0 1 auto",fontSize:"12pt",fontWeight:"500",separator:(0,i.jsx)(n8.X,{color:"gray.500"}),overflow:"hidden",children:[(0,i.jsx)(n9.g,{children:(0,i.jsx)(l.x,{children:"Checklist"})}),(0,i.jsx)(n9.g,{cursor:"pointer",flex:"0 1 auto",overflow:"hidden",children:r?(0,i.jsx)(nb.I,{ref:c,value:o,onChange:e=>{a(e.target.value)},onKeyDown:e=>{"Enter"===e.key?(t(o),s(!1)):"Escape"===e.key&&(a(n),s(!1))},size:"sm",w:"100%"}):(0,i.jsx)(l.x,{flex:"0 1 auto",onClick:()=>{a(n),s(!0)},textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",children:n})})]})}var te=t(50674);t(50394);var tn=t(20125);function tt(e){let{model:n,name:t,baseType:r,currentType:a}=e,{runAction:c}=nq(),d=a||r,u=()=>{c("histogram_diff",{model:n,column_name:t,column_type:d},{showForm:!1})},x=()=>{c("top_k_diff",{model:n,column_name:t,k:50},{showForm:!1})},m=!r||!a;return(0,i.jsxs)(o.k,{children:[(0,i.jsx)(l.x,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:t}),(0,i.jsx)(h.L,{}),(0,i.jsx)(nC.v,{children:e=>{let{isOpen:n}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n_.j,{className:"row-context-menu",visibility:n?"visible":"hidden",width:n?"auto":"0px",minWidth:n?"auto":"0px",as:nS.h,icon:(0,i.jsx)(s.J,{as:eY.D_A}),variant:"unstyled",size:"sm"}),(0,i.jsx)(tn.h,{children:(0,i.jsx)(nz.q,{lineHeight:"20px",children:(0,i.jsxs)(nR.k,{title:"Diff",m:"0",p:"4px 12px",children:[(0,i.jsx)(nE.s,{fontSize:"10pt",onClick:u,isDisabled:m||!d||!(!eD(d)&&!eL(d)),children:"Histogram Diff"}),(0,i.jsx)(nE.s,{fontSize:"10pt",onClick:x,isDisabled:m,children:"Top-k Diff"})]})})})]})}})]})}function ti(e,n){function t(e){return void 0===e.baseIndex?"column-index-added":void 0===e.currentIndex?"column-index-removed":!0===e.reordered?"column-index-reordered":"column-index-normal"}function l(e){return void 0===e.baseIndex?"column-body-added":void 0===e.currentIndex?"column-body-removed":e.baseType!==e.currentType?"column-body-type-changed":!0===e.reordered?"column-body-reordered":"column-body-normal"}return{columns:[{key:"baseIndex",name:"",resizable:!0,minWidth:35,width:35,cellClass:t},{key:"currentIndex",name:"",resizable:!0,minWidth:35,width:35,cellClass:t},{key:"name",name:"Name",resizable:!0,renderCell:e=>{let{row:t,column:l}=e;return n?(0,i.jsx)(tt,{model:n,name:t.name,baseType:t.baseType,currentType:t.currentType}):t.name},cellClass:function(e){return void 0===e.baseIndex?"column-body-added":void 0===e.currentIndex?"column-body-removed":!0===e.reordered?"column-body-reordered":"column-body-normal"}},{key:"baseType",name:"Base Type",resizable:!0,cellClass:l},{key:"currentType",name:"Current Type",resizable:!0,cellClass:l}],rows:Object.values(e)}}var tl=t(57765),tr=t(27322);let ts=(0,j.forwardRef)(function(e,n){let t,l,{base:r,current:s,enableScreenshot:a=!1}=e,{columns:c,rows:d}=(0,j.useMemo)(()=>{let e=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t={};return Object.entries(e$(Object.keys(e),Object.keys(n))).forEach(e=>{let[n,i]=e;t[n]={name:n,reordered:"reordered"===i}}),Object.entries(e).map((e,n)=>{let[i,l]=e;t[i].baseIndex=n+1,t[i].baseType=l.type}),Object.entries(n).map((e,n)=>{let[i,l]=e;t[i].currentIndex=n+1,t[i].currentType=l.type}),t}(null==r?void 0:r.columns,null==s?void 0:s.columns),n=(null==s?void 0:s.resource_type)||(null==r?void 0:r.resource_type);return n&&["model","seed","snapshot"].includes(n)?ti(e,(null==s?void 0:s.name)||(null==r?void 0:r.name)):ti(e)},[r,s]),{lineageGraph:u}=eg(),h=!(null==u?void 0:u.catalogMetadata.base),x=!(null==u?void 0:u.catalogMetadata.current);h&&x?t="catalog.json is missing on both current and base environments.":h?t="catalog.json is missing on base environment.":x&&(t="catalog.json is missing on current environment.");let m=r&&void 0===r.columns,p=s&&void 0===s.columns;return m&&p?l="Schema information is missing on both current and base environments.":m?l="Schema information is missing on base environment.":p&&(l="Schema information is missing on current environment."),(0,i.jsxs)(o.k,{direction:"column",children:[t?(0,i.jsxs)(tl.b,{status:"warning",fontSize:"12px",p:"8px",children:[(0,i.jsx)(tr.z,{}),t]}):l?(0,i.jsxs)(tl.b,{status:"warning",fontSize:"12px",p:"8px",children:[(0,i.jsx)(tr.z,{}),l]}):(0,i.jsx)(i.Fragment,{}),d.length>0&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(eX,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",fontSize:"10pt",borderWidth:1},columns:c,rows:d,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},className:"rdg-light",enableScreenshot:a,ref:n})})]})});async function to(e){return(await U.post("/api/select",e)).data}var ta=t(3072);t(5637);let tc=e=>{let{style:n,children:t,gutterSize:l=5,...r}=e;return(0,i.jsx)(ta.Z,{style:{display:"flex",flexDirection:"row",...n},direction:"horizontal",gutterSize:l,...r,children:t})},td=e=>{let{style:n,children:t,gutterSize:l=5,...r}=e;return(0,i.jsx)(ta.Z,{style:{display:"flex",flexDirection:"column",...n},gutterSize:l,direction:"vertical",...r,children:t})};var tu=t(34135),th=t(55726),tx=t(98640);let tm=eY.Nbv,tp=eY.sFB,tf=eY.UGs;function tg(e){return"added"===e?{color:"#1dce00",backgroundColor:"#e8fce5",icon:tm}:"removed"===e?{color:"#ff4444",backgroundColor:"#ffdbdb",icon:tp}:"modified"===e?{color:"#ffa502",backgroundColor:"#fff2dd",icon:tf}:{color:"inherit",backgroundColor:"white",icon:void 0}}function tv(e){if("model"===e)return{color:"#c0eafd",icon:th.Fn3};if("metric"===e)return{color:"#ffe6ee",icon:tx._MV};if("source"===e)return{color:"#a6dda6",icon:th.i1q};if("exposure"===e)return{color:"#ffe6ee",icon:tx.n8P};if("semantic_model"===e)return{color:"#fb8caf",icon:tx.R1C};if("seed"===e)return{color:"#a6dda6",icon:th.tWi};if("snapshot"===e)return{color:"#a6dda6",icon:th.Dmm};else return{color:"inherit",icon:void 0}}function tj(e,n){if(!e||!n)return;let t=Object.keys(e),i=Object.keys(n);if(t.length!==i.length)return!0;for(let e=0;e{let n,t,{node:r,selected:a,onSelect:c,schemaChanged:d}=e,{icon:u}=tv(r.resourceType),{base:h,current:x}=r.data;if(d){var m;n=null===(m=nO("schema_diff"))||void 0===m?void 0:m.icon,t=tg("modified").color}else!h&&x?(n=tg("added").icon,t=tg("added").color):h&&!x&&(n=tg("removed").icon,t=tg("removed").color);return(0,i.jsxs)(o.k,{width:"100%",fontSize:"10pt",p:"5px 8px",cursor:"pointer",_hover:{bg:"gray.200"},bg:a?"gray.100":"inherit",onClick:()=>c(r.id),alignItems:"center",gap:"5px",children:[(0,i.jsx)(s.J,{as:u}),(0,i.jsx)(l.x,{flex:"1",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",children:r.name}),n&&t&&(0,i.jsx)(s.J,{as:n,color:t})]})},tb=(0,j.forwardRef)(function(e,n){let{check:t}=e,{lineageGraph:l}=eg(),r=t.params,s=[...P.check(t.check_id),"select"],{isLoading:o,error:a,refetch:c,data:d}=(0,y.a)({queryKey:s,queryFn:async()=>to({select:null==r?void 0:r.select,exclude:null==r?void 0:r.exclude,packages:null==r?void 0:r.packages,view_mode:null==r?void 0:r.view_mode}),refetchOnMount:!0,enabled:!(null==r?void 0:r.node_id)}),[u,h]=(0,j.useMemo)(()=>{let e=[],n=[],t=[],i=[];if(null==r?void 0:r.node_id)for(let n of r.node_id instanceof Array?r.node_id:[r.node_id]){let t=null==l?void 0:l.nodes[n];t&&e.push(t)}else for(let n of(null==d?void 0:d.nodes)||[]){let t=null==l?void 0:l.nodes[n];t&&e.push(t)}let s=e.filter(e=>"model"===e.resourceType||"seed"===e.resourceType||"source"===e.resourceType||"snapshot"===e.resourceType);for(let e of s){var o,a;tj(null===(o=e.data.base)||void 0===o?void 0:o.columns,null===(a=e.data.current)||void 0===a?void 0:a.columns)?n.push(e.id):!e.data.base&&e.data.current?t.push(e.id):e.data.base&&!e.data.current&&i.push(e.id)}function c(e){return n.includes(e.id)?3:t.includes(e.id)?2:i.includes(e.id)?1:0}return s.sort((e,n)=>{let t=c(e),i=c(n);return t!==i?i-t:e.name.localeCompare(n.name)}),[s,n]},[null==r?void 0:r.node_id,null==d?void 0:d.nodes,l]),[x,m]=(0,j.useState)(0);if(o)return(0,i.jsx)(eZ.M,{bg:"rgb(249,249,249)",height:"100%",children:"Loading..."});if(a)return(0,i.jsxs)(eZ.M,{bg:"rgb(249,249,249)",height:"100%",children:["Error: ",null==a?void 0:a.message]});if(0==u.length)return(0,i.jsx)(eZ.M,{bg:"rgb(249,249,249)",height:"100%",children:"No nodes matched"});if(x(0,i.jsx)(ty,{node:e,schemaChanged:h.includes(e.id),selected:n===x,onSelect:()=>{m(n)}},n))})]})}return(0,i.jsx)(i.Fragment,{})});var tw=t(29589);function tk(e){let{value:n,onChange:t}=e,[l,s]=(0,j.useState)(!1),[a,c]=(0,j.useState)(),d=(0,j.useRef)(null),u=()=>{t&&(t(a),s(!1))};return((0,j.useEffect)(()=>{if(l&&d.current){let e=d.current;e.focus(),e.setSelectionRange(e.value.length,e.value.length)}},[l]),l)?(0,i.jsxs)(o.k,{direction:"column",align:"flex-end",height:"100%",children:[(0,i.jsx)(tw.g,{value:a,onChange:e=>{c(e.target.value)},onKeyDown:e=>{"Escape"===e.key&&s(!1),(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),u())},ref:d,flex:1}),(0,i.jsxs)(o.k,{gap:"12px",alignItems:"flex-end",children:[(0,i.jsx)(r.r,{onClick:()=>{setTimeout(()=>{s(!1)},100)},colorScheme:"blue",children:"cancel"}),(0,i.jsx)(er.z,{mt:"8px",size:"sm",colorScheme:"blue",onClick:u,children:"Update"})]})]}):(0,i.jsx)(ei.x,{height:"100%",overflow:"auto",fontSize:"11pt",onClick:()=>{c(n||""),s(!0)},whiteSpace:"pre-wrap",wordBreak:"break-word",color:n?"inherit":"lightgray",children:n||"Add description here"})}var tC=t(68306);function t_(){let e=(0,G.p)();return{successToast:function(n){e({description:n,status:"info",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})},failToast:function(n,t){e({title:n,description:"".concat(t),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}}}function tS(){let e=(0,nZ._)(["\n **SQL**\n ```sql\n ","\n ```\n "],["\n **SQL**\n \\`\\`\\`sql\n ","\n \\`\\`\\`\n "]);return tS=function(){return e},e}function tz(e){return e.description?e.description:"_(no description)_"}var tR=t(21114),tE=t(52777);let tT=e=>{let{value:n,onChange:t,onRun:l,onRunBase:r,onRunDiff:a,label:c,options:d={},...u}=e;return(0,i.jsxs)(i.Fragment,{children:[(c||l||r)&&(0,i.jsxs)(o.k,{backgroundColor:"#EDF2F880",height:"40px",fontSize:"14px",align:"center",margin:"0",padding:"0px 16px",children:[(0,i.jsx)(ei.x,{as:"b",children:c?c.toUpperCase():""}),(0,i.jsx)(h.L,{}),(l||r)&&(0,i.jsx)(er.z,{size:"sm",variant:"outline",onClick:l||r,backgroundColor:"white",leftIcon:(0,i.jsx)(s.J,{as:tx.gmG}),padding:"6px 12px",children:"Run Query"})]}),(0,i.jsx)(tE.ML,{language:"sql",theme:"vs",value:n,onChange:e=>{void 0!==e&&t&&t(e)},onMount:(e,n)=>{l&&e.addCommand(n.KeyMod.CtrlCmd|n.KeyCode.Enter,l),r&&e.addCommand(n.KeyMod.Alt|n.KeyCode.Enter,r),a&&e.addCommand(n.KeyMod.CtrlCmd|n.KeyMod.Shift|n.KeyCode.Enter,a)},options:{tabSize:2,fontSize:16,lineNumbers:"on",automaticLayout:!0,minimap:{enabled:!1},wordWrap:"on",wrappingIndent:"indent",...d}})]})},tD=e=>{let{value:n,baseValue:t,onChange:l,onChangeBase:r,onRun:s,onRunBase:a,onRunDiff:c,options:d={},...u}=e;return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(o.k,{height:"100%",gap:0,children:[(0,i.jsx)(tR.K,{height:"100%",width:"50%",gap:0,borderRight:"1px",borderColor:"#D4DBE4",children:(0,i.jsx)(tT,{label:"Base",value:t||"",onChange:r,onRunBase:a,options:d,...u})}),(0,i.jsx)(tR.K,{height:"100%",width:"50%",gap:0,children:(0,i.jsx)(tT,{label:"Current",value:n,onChange:l,onRun:s,options:d,...u})})]})})};var tL=t(13601),tI=t(51418);let tM=(0,eI.G)((e,n)=>{var t,r,s,a;let{isRunning:c,isAborting:d,progress:u,error:h,run:x,onCancel:m,viewOptions:p,onViewOptionsChanged:f,RunResultView:g,children:v,onExecuteRun:j}=e,y=(null==h?void 0:null===(r=h.response)||void 0===r?void 0:null===(t=r.data)||void 0===t?void 0:t.detail)||(null==x?void 0:x.error);if(y)return(0,i.jsxs)(tl.b,{status:"error",children:[(0,i.jsx)(tr.z,{}),"Error: ",y]});if(void 0!==c?c:(null==x?void 0:x.status)==="running"){let e=(null==u?void 0:u.message)?null==u?void 0:u.message:(null==x?void 0:null===(s=x.progress)||void 0===s?void 0:s.message)?null==x?void 0:null===(a=x.progress)||void 0===a?void 0:a.message:"Loading...";return(0,i.jsx)(eZ.M,{p:"16px",height:"100%",bg:"rgb(249,249,249)",children:(0,i.jsxs)(ne.g,{children:[(0,i.jsxs)(o.k,{alignItems:"center",children:[(null==u?void 0:u.percentage)===void 0||(null==u?void 0:u.percentage)===null?(0,i.jsx)(tL.D,{isIndeterminate:!0,size:"20px",mr:"8px"}):(0,i.jsx)(tL.D,{size:"20px",value:100*u.percentage,mr:"8px"}),d?(0,i.jsx)(i.Fragment,{children:"Aborting..."}):(0,i.jsx)(i.Fragment,{children:e})]}),!d&&(0,i.jsx)(er.z,{onClick:m,colorScheme:"blue",size:"sm",children:"Cancel"})]})})}if(!x)return(0,i.jsx)(eZ.M,{bg:"rgb(249,249,249)",height:"100%",children:"Loading..."});if(v&&g)throw Error("RunView requires either a children or a RunResultView prop, but not both.");if(!v&&!g)throw Error("RunView requires at least one of children or RunResultView prop.");return(0,i.jsxs)(l.x,{h:"100%",style:{contain:"size layout"},overflow:"auto",children:[g&&(x.error||x.result)&&(0,i.jsx)(tI.SV,{children:(0,i.jsx)(g,{ref:n,run:x,viewOptions:p,onViewOptionsChanged:f})}),v&&v({run:x,viewOptions:p,onViewOptionsChanged:f})]})});var tO=t(27066),tA=t(13587),tF=t(9312),tN=t(94945),tq=t(52811),tV=t(14033);t(94254),t(76890);var tH=t(47691),tP=t(34433),tW=t(73676),tK=t(84492);function tJ(e){let{node:n}=e,{icon:t}=tv(n.resourceType);return(0,i.jsx)(nh.u,{hasArrow:!0,label:"Type of resource",children:(0,i.jsxs)(nQ.Vp,{children:[(0,i.jsx)(nQ.AD,{as:t}),(0,i.jsx)(nQ.Sn,{children:n.resourceType})]})})}function tB(e){let{rowCount:n}=e,t=n.base,l=n.curr,r=null===n.base?"N/A":"".concat(n.base," rows"),o=null===n.curr?"N/A":"".concat(n.curr," rows");return null===t&&null===l?(0,i.jsx)(i.Fragment,{children:" Failed to load"}):null===t||null===l?(0,i.jsxs)(u.U,{children:[(0,i.jsx)(ei.x,{children:r}),(0,i.jsx)(s.J,{as:tW.Rgz}),(0,i.jsx)(ei.x,{children:o})]}):t===l?(0,i.jsxs)(u.U,{children:[(0,i.jsx)(ei.x,{children:o}),(0,i.jsx)(s.J,{as:tK.lxc,color:"gray.500"}),(0,i.jsx)(ei.x,{color:"gray.500",children:"No Change"})]}):t ").concat(n," rows")}return(0,i.jsx)(nh.u,{label:r,children:(0,i.jsxs)(nQ.Vp,{children:[(0,i.jsx)(nQ.AD,{as:x}),(0,i.jsx)(nQ.Sn,{children:m||c?(0,i.jsx)(tP.N,{isLoaded:!c,noOfLines:1,skeletonHeight:2,minWidth:"30px",children:m?(0,i.jsx)(tB,{rowCount:m}):"row count"}):(0,i.jsx)(i.Fragment,{children:"row count"})}),a&&(0,i.jsx)(nQ.bq,{as:nS.h,isLoading:c,"aria-label":"Query Row Count",icon:(0,i.jsx)(n5.n,{}),size:"xs",onClick:a})]})})}let tZ=e=>{let{node:n,action:t}=e,{status:r,skipReason:s,run:a}=t;if("pending"===r)return(0,i.jsx)(tL.D,{size:"20px",value:0});if("skipped"===r)return(0,i.jsx)(nQ.Vp,{backgroundColor:"gray.100",children:(0,i.jsxs)(o.k,{fontSize:"10pt",color:"gray.500",alignItems:"center",gap:"3px",children:[(0,i.jsx)(l.x,{children:"Skipped"}),s&&(0,i.jsx)(nh.u,{label:s,children:(0,i.jsx)(tH.s,{})})]})});if(!a)return(0,i.jsx)(tL.D,{isIndeterminate:!0,size:"20px"});let{error:c,result:d,run_id:u,progress:h}=a;if("running"===r)return(null==h?void 0:h.percentage)===void 0?(0,i.jsx)(tL.D,{isIndeterminate:!0,size:"20px"}):(0,i.jsx)(tL.D,{size:"20px",value:(null==h?void 0:h.percentage)*100});if(c)return(0,i.jsxs)(o.k,{fontSize:"10pt",color:"gray",children:[(0,i.jsx)(l.x,{children:"Error"}),s&&(0,i.jsx)(nh.u,{label:c,children:(0,i.jsx)(e7.a,{})})]});if("value_diff"===a.type){let e=0;for(let n of d.data.data)n[2]<1&&e++;return(0,i.jsx)(nQ.Vp,{backgroundColor:e>0?"red.100":"green.100",children:(0,i.jsx)(nQ.Sn,{children:(0,i.jsx)(o.k,{fontSize:"10pt",color:e>0?"red":"green",alignItems:"center",gap:"3px",children:e>0?"".concat(e," columns mismatched"):"All columns match"})})})}if("row_count_diff"===a.type){let e=a.result;return(0,i.jsx)(tU,{rowCount:e[n.name],node:n})}return(0,i.jsx)(i.Fragment,{children:u})},tQ=(0,j.createContext)(void 0),tX=()=>{let e=(0,j.useContext)(tQ);if(!e)throw Error("useLineageViewContext must be used within a LineageViewProvider");return e},tG=e=>{var n,t,r,a;let c,d,{id:u,inverted:h}=e,{lineageGraph:x,runsAggregated:m}=eg(),p=null==m?void 0:m[u],f=null==x?void 0:x.nodes[u];if(!p&&!f)return(0,i.jsx)(i.Fragment,{});if((null==f?void 0:f.data.base)&&(null==f?void 0:f.data.current)&&(c=tj(null===(r=f.data.base)||void 0===r?void 0:r.columns,null===(a=f.data.current)||void 0===a?void 0:a.columns)),p&&p.row_count_diff){let e=p.row_count_diff;d=e.result.curr!==e.result.base}let g=h?"white":tg("modified").color,v=h?"gray":"lightgray";return(0,i.jsxs)(o.k,{gap:"5px",children:[void 0!==c&&(0,i.jsx)(nh.u,{label:"Schema (".concat(c?"changed":"no change",")"),openDelay:500,children:(0,i.jsx)(l.x,{height:"16px",children:(0,i.jsx)(s.J,{as:null===(n=nO("schema_diff"))||void 0===n?void 0:n.icon,color:c?g:v})})}),void 0!==d&&(0,i.jsx)(nh.u,{label:"Row count (".concat(d?"changed":"no change",")"),openDelay:500,children:(0,i.jsx)(l.x,{height:"16px",children:(0,i.jsx)(s.J,{as:null===(t=nO("row_count_diff"))||void 0===t?void 0:t.icon,color:d?g:v})})})]})},tY=e=>{let{checked:n,onClick:t}=e;return(0,i.jsx)(o.k,{onClick:t,alignSelf:"center",alignItems:"center",children:n?(0,i.jsx)(s.J,{boxSize:"20px",as:th.xik}):(0,i.jsx)(s.J,{boxSize:"20px",as:th.hGI})})};var t$=t(70952),t0=t(44549),t1=t(27739);function t5(e){let{base:n,current:t}=e;return(0,i.jsx)(tE.SV,{height:"100%",language:"sql",theme:"vs",original:null==n?void 0:n.raw_code,modified:null==t?void 0:t.raw_code,options:{readOnly:!0,fontSize:14,lineNumbers:"on",automaticLayout:!0,minimap:{enabled:!1},wordWrap:"on",wrappingIndent:"same"}})}function t2(e){let{current:n,onChange:t}=e,r=function(e,n){let t=(0,j.useRef)(null);return(0,j.useEffect)(()=>{t.current&&e!==t.current.getValue()&&t.current.setValue(e)},[e]),{onMount(e){let i=e.getModifiedEditor();t.current=i,i.onDidChangeModelContent(()=>{n(i.getValue())})}}}((null==n?void 0:n.raw_code)||"",t);return(0,i.jsx)(l.x,{flex:1,overflowY:"auto",children:(0,i.jsx)(tE.SV,{language:"sql",theme:"vs",original:null==n?void 0:n.raw_code,modified:null==n?void 0:n.raw_code,options:{readOnly:!1,fontSize:14,lineNumbers:"on",automaticLayout:!0,wordWrap:"on",wrappingIndent:"same",renderOverviewRuler:!1,minimap:{enabled:!0}},onMount:r.onMount})})}async function t4(e){return(await U.post("/api/checks",{type:"schema_diff",params:e})).data}let t6={audit_helper:"Require the dbt package 'dbt-labs/audit_helper'. Please install it and re-run dbt to activate this feature.",dbt_profiler:"Require the dbt package 'data-mie/dbt_profiler'. Please install it and re-run dbt to activate this feature.",add_or_remove:"Unavailable for added or removed resources."},t3=e=>{var n;let[t,i]=(0,j.useState)(!1),[l,r]=(0,j.useState)(!1),[,s]=ev(),{error:o,data:a}=(0,y.a)({queryKey:P.run(e||""),queryFn:async()=>ec(e||"",t?2:0),enabled:!!e,refetchInterval:!!t&&50,retry:!1});(0,j.useEffect)(()=>{(o||(null==a?void 0:a.result)||(null==a?void 0:a.error))&&(t&&i(!1),(null==a?void 0:a.type)==="row_count_diff"&&s()),(null==a?void 0:a.status)==="running"&&i(!0)},[a,o,t,s]);let c=(0,j.useCallback)(async()=>{if(r(!0),e)return await ed(e)},[e,r]),d=(null==a?void 0:a.type)?null===(n=nO(a.type))||void 0===n?void 0:n.RunResultView:void 0;return{run:a,isRunning:t,aborting:l,error:o,onCancel:c,RunResultView:d}};var t9=t(30671),t8=t(33686),t7=t(32717),ie=t.n(t7),it=t(21467),ii=t(93779),il=t(30745),ir=t.n(il);let is="ignore-screenshot";function io(e){let{renderLibrary:n="html2canvas",imageType:t="png",backgroundColor:l=null,boardEffect:r=!0,shadowEffect:s=!1,borderStyle:c="solid 1px #ccc",borderRadius:d="10px",onSuccess:u,onError:h,ignoreElements:x}=e,[m,p]=(0,j.useState)("idle"),f=(0,j.useRef)(null),{onOpen:g,setImgBlob:v,ImageDownloadModal:y}=function(){let{isOpen:e,onOpen:n,onClose:t}=(0,eb.q)(),[l,r]=(0,j.useState)();return{onOpen:n,setImgBlob:r,ImageDownloadModal:function(){let[n,r]=(0,j.useState)();return(0,j.useEffect)(()=>{if(!l)return;let e=new FileReader;e.readAsDataURL(l),e.onloadend=e=>{var n,t;(null===(n=e.target)||void 0===n?void 0:n.result)&&(null===(t=e.target)||void 0===t?void 0:t.result)!==null&&r(e.target.result)}},[r]),(0,i.jsxs)(Y.u_,{size:"3xl",isOpen:e,onClose:t,children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{children:[(0,i.jsx)(en.x,{children:"Screenshot Preview"}),(0,i.jsx)(ej.o,{}),(0,i.jsxs)(et.f,{children:[(0,i.jsxs)(o.k,{px:"10px",gap:"10px",direction:"column",children:[(0,i.jsxs)(o.k,{alignItems:"center",gap:"5px",children:[(0,i.jsx)(tH.s,{color:"red.600"}),(0,i.jsx)(ei.x,{fontWeight:"500",display:"inline",children:"Copy to the Clipboard"})," ","is not supported in the current browser"]}),(0,i.jsx)(ei.x,{children:"Please download it directly"})]}),(0,i.jsx)(a.E,{src:n,alt:"screenshot"})]}),(0,i.jsxs)(el.m,{children:[(0,i.jsx)(er.z,{mr:3,onClick:t,children:"Close"}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>{if(!l)return;let e=new Date,n="recce-screenshot-".concat((0,ii.WU)(e,"yyyy-MM-dd-HH-mm-ss"),".png");ir()(l,n),t()},children:"Download"})]})]})]})}}}(),b=async()=>{if(!f.current)throw console.error("No node to use for screenshot"),Error("No node to use for screenshot");let e=f.current.element||f.current,t=e.style.overflow,i=e.style.border,o=e.style.borderRadius,a=e.style.backgroundColor,u=e.style.height;try{var h;e.style.overflow="hidden",e.style.border=r?c:"",e.style.borderRadius=r?d:"",e.style.backgroundColor=l||"",e.style.height=e.offsetHeight+"px";let t=document.createElement("style");document.head.appendChild(t),null===(h=t.sheet)||void 0===h||h.insertRule("body > div:last-child img { display: inline-block; }"),p("loading");let i="html2canvas"===n?await ie()(e,{logging:!1,backgroundColor:null,ignoreElements:x}):await (0,it.rT)(e,{filter:x?e=>!x(e):void 0});t.remove();let o=s?document.createElement("canvas"):i;if(s){o.width=i.width+80,o.height=i.height+80;let e=o.getContext("2d");if(e)e.shadowColor="rgba(0, 0, 0, 0.5)",e.shadowBlur=20,e.shadowOffsetX=10,e.shadowOffsetY=10,e.drawImage(i,40,40);else throw console.error("Error getting canvas context"),Error("Error getting canvas context to add shadow effect")}let a=await fetch(o.toDataURL());return await a.blob()}catch(e){throw console.error("Error converting to image",e),e}finally{e.style.overflow=t,e.style.border=i,e.style.borderRadius=o,e.style.backgroundColor=a,e.style.height=u}};return{status:m,isLoading:"loading"===m,isErrored:"error"===m,isSuccess:"success"===m,copyToClipboard:async()=>{try{await navigator.clipboard.write([new ClipboardItem({["image/".concat(t)]:b()})]),p("success"),u&&u()}catch(e){"ClipboardItem is not defined"===e.message?(v(await b()),g(),p("success")):(p("error"),console.error("Error copying to clipboard",e),h&&h(e))}},ImageDownloadModal:y,ref:f}}function ia(e){let{successToast:n,failToast:t}=t_(),{isLoading:l,copyToClipboard:r,ImageDownloadModal:s,ref:o}=io({imageType:"png",shadowEffect:!0,backgroundColor:(null==e?void 0:e.backgroundColor)||null,onSuccess:()=>{n("Copied the query result as an image to clipboard")},onError:e=>{console.error("Error taking screenshot",e),t("Failed to copy image to clipboard",e)}}),a=(0,j.useCallback)(()=>{if(o.current){let e=o.current.element||o.current;e.style.boxShadow="rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px",e.style.transition="box-shadow 0.5s ease-in-out"}},[o]),c=(0,j.useCallback)(()=>{o.current&&((o.current.element||o.current).style.boxShadow="")},[o]),d=(0,j.useCallback)(async()=>{o.current?(await r(),(o.current.element||o.current).style.boxShadow=""):t("Failed to copy image to clipboard","No content to copy")},[o,r,t]);return{ref:o,CopyToClipboardButton:function(e){let{imageType:n="png",...t}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(er.z,{size:"sm",leftIcon:(0,i.jsx)(n0.T,{}),style:{position:"absolute",bottom:"16px",right:"16px"},isLoading:l,onMouseEnter:a,onMouseLeave:c,onClick:d,children:"Copy to Clipboard"}),(0,i.jsx)(s,{})]})},onMouseEnter:a,onMouseLeave:c,onCopyToClipboard:d}}let ic=e=>{let{run:n}=e,t=(null==n?void 0:n.status)==="running",l=null==n?void 0:n.status;!l&&(n.result?l="finished":n.error&&(l="failed"));let r="",s="";"successful"===l||"finished"===l?(r="green",s="Finished"):"failed"===l?(r="red",s="Failed"):"cancelled"===l?(r="gray",s="Cancelled"):"running"===l?(r="blue",s="Running"):(r="green",s="Finished");let a=(null==n?void 0:n.run_at)?function(e){let n=new Date,t=new Date;return(t.setDate(n.getDate()-1),null==e)?null:n.toDateString()===e.toDateString()?"Today, "+(0,ii.WU)(e,"HH:mm"):t.toDateString()===e.toDateString()?"Yesterday, "+(0,ii.WU)(e,"HH:mm"):(0,ii.WU)(e,"MMM d, HH:mm")}(new Date(n.run_at)):null;return(0,i.jsxs)(o.k,{justifyContent:"start",fontSize:"11pt",color:"gray.500",gap:"3px",alignItems:"center",overflow:"hidden",children:[t&&(0,i.jsx)(tA.$,{size:"xs",color:"".concat(r,".400")}),(0,i.jsx)(ei.x,{fontWeight:500,color:"".concat(r,".400"),children:s}),(0,i.jsx)(ei.x,{children:"•"}),(0,i.jsx)(ei.x,{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",children:a})]})},id=e=>{let n=t9.ZP.stringify(e,null,2);return(0,i.jsx)(tE.ML,{height:"100%",language:"yaml",theme:"vs",value:n,options:{readOnly:!0,fontSize:14,lineNumbers:"off",automaticLayout:!0,minimap:{enabled:!1},wordWrap:"on",wrappingIndent:"same",scrollBeyondLastLine:!1}})},iu=e=>{var n,t,l;let{runId:r,onClose:s,disableAddToChecklist:a}=e,{runAction:c}=nq(),{error:d,run:f,onCancel:g,isRunning:v}=t3(r),[y,w]=(0,j.useState)(),k=(0,b.NL)(),[,C]=(0,ew.TH)(),[_,S]=(0,j.useState)(0),z=(null==f?void 0:f.type)?null===(n=nO(f.type))||void 0===n?void 0:n.RunResultView:void 0,R=(0,j.useCallback)(()=>{c((null==f?void 0:f.type)||"",null==f?void 0:f.params)},[f,c]),E=null==f?void 0:f.check_id,T=(0,j.useCallback)(async()=>{E&&C("/checks/".concat(E))},[E,C]),D=(0,j.useCallback)(async()=>{if(!r)return;let e=await nP(r,y);k.invalidateQueries({queryKey:P.checks()}),C("/checks/".concat(e.check_id))},[r,C,k,y]),L=(null==f?void 0:f.type)==="query"||(null==f?void 0:f.type)==="query_diff"||(null==f?void 0:f.type)==="query_base",{ref:I,onCopyToClipboard:M,onMouseEnter:O,onMouseLeave:A}=ia();return(0,i.jsxs)(o.k,{direction:"column",children:[(0,i.jsx)(x.m,{tabIndex:_,onChange:S,flexDirection:"column",mb:"1px",children:(0,i.jsxs)(m.t,{height:"50px",children:[(0,i.jsx)(p.O,{children:"Result"}),(0,i.jsx)(p.O,{children:"Params"}),L&&(0,i.jsx)(p.O,{children:"Query"}),(0,i.jsx)(h.L,{}),(0,i.jsxs)(u.U,{overflow:"hidden",children:[f&&(0,i.jsx)(ic,{run:f}),(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(n5.n,{}),variant:"outline",isDisabled:!r||v,size:"sm",onClick:R,children:"Rerun"}),(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(n0.T,{}),variant:"outline",isDisabled:!r||!(null==f?void 0:f.result)||!!d||0!==_,onMouseEnter:O,onMouseLeave:A,size:"sm",onClick:M,children:"Copy to Clipboard"}),(0,i.jsx)(function(){return a?(0,i.jsx)(i.Fragment,{}):(null==f?void 0:f.check_id)?(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(t8.n,{}),isDisabled:!r||!(null==f?void 0:f.result)||!!d,size:"sm",colorScheme:"blue",onClick:T,children:"Go to Check"}):(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(t8.n,{}),isDisabled:!r||!(null==f?void 0:f.result)||!!d,size:"sm",colorScheme:"blue",onClick:D,children:"Add to Checklist"})},{}),(0,i.jsx)(t1.P,{onClick:()=>{s&&s()}})]})]})}),0===_&&(0,i.jsx)(tM,{ref:I,error:d,run:f,onCancel:g,viewOptions:y,onViewOptionsChanged:w,RunResultView:z}),1===_&&f&&(0,i.jsx)(id,{type:f.type,params:f.params}),2===_&&f&&((null===(t=f.params)||void 0===t?void 0:t.base_sql_template)?(0,i.jsx)(tD,{value:f.params.sql_template,baseValue:f.params.base_sql_template,options:{readOnly:!0}}):(0,i.jsx)(tT,{value:(null==f?void 0:null===(l=f.params)||void 0===l?void 0:l.sql_template)||"",options:{readOnly:!0}}))]})},ih=e=>{let{onClose:n,disableAddToChecklist:t}=e,{runId:l}=nq();return(0,i.jsx)(iu,{runId:l,onClose:n,disableAddToChecklist:t})};async function ix(e,n){return await ea("query",e,n)}async function im(e,n){return await ea("query_base",e,n)}async function ip(e,n){return await ea("query_diff",e,n)}var ig=t(98834),iv=t(43800),ij=t(33517);let iy=e=>{var n;let{defaultValues:t,suggestionList:l,onValuesChange:r,isDisabled:s}=e,[o,a]=(0,j.useState)(t||[]),[c,d]=(0,j.useState)(""),[u,h]=(0,j.useState)(!1),x=(0,j.useRef)(null),m=e=>{o.includes(e)||(d(""),a([...o,e]),r([...o,e]))};return s?(0,i.jsx)(nh.u,{label:t6.audit_helper,children:(0,i.jsx)(nb.I,{size:"xs",disabled:!0,placeholder:"Unavailable"})}):(0,i.jsxs)(ig.B,{size:e.size,width:e.width,children:[(0,i.jsxs)(nC.v,{isLazy:!0,closeOnSelect:!1,onOpen:()=>{var e;return null==x?void 0:null===(e=x.current)||void 0===e?void 0:e.focus()},children:[(0,i.jsx)(n_.j,{width:"100%",children:(0,i.jsx)(nb.I,{placeholder:e.placeholder,size:e.size,borderRadius:"4px",value:o.length>1?"".concat(o.length," ").concat(e.unitName,"s selected"):1===o.length?"".concat(o[0]):"",onChange:()=>{},backgroundColor:"white"})}),(0,i.jsx)(tn.h,{children:(0,i.jsxs)(nz.q,{zIndex:"popover",fontSize:e.size,width:e.width,children:[(0,i.jsx)(nR.k,{children:(0,i.jsxs)(iv.E,{border:"1px solid #e2e8f0",borderRadius:"4px",width:"calc(100% - 8px)",marginX:"4px",padding:"4px",children:[o.map((n,t)=>(0,i.jsx)(iv.U,{children:(0,i.jsxs)(nQ.Vp,{size:e.size,children:[(0,i.jsx)(nQ.Sn,{paddingLeft:"8px",children:n}),(0,i.jsx)(nQ.SD,{paddingRight:"8px",onClick:()=>{a(o.filter(e=>e!==n)),r(o.filter(e=>e!==n))}})]},n)},"tag-".concat(t))),(0,i.jsx)(iv.U,{width:"100%",children:(0,i.jsx)(nb.I,{ref:x,placeholder:"Filter keys or add custom",variant:"unstyled",size:e.size,value:c,onChange:e=>{d(e.target.value),h(!0)},onKeyDown:e=>{let n=e.currentTarget.value.trim().replace(",","");switch(e.key){case",":case"Enter":m(n),d("");break;case"Backspace":""===e.currentTarget.value&&o.length>0&&(a(o.slice(0,-1)),r(o.slice(0,-1)))}},onBlur:()=>{var e;x&&u&&(null==x||null===(e=x.current)||void 0===e||e.focus())}})})]})}),(0,i.jsx)(nX.R,{}),(0,i.jsxs)(nR.k,{children:[""!==c&&!(null==l?void 0:l.includes(c))&&(0,i.jsxs)(nE.s,{onClick:()=>{m(c),h(!1)},children:["Add '",c,"' to the list"]},"custom-value-by-filter"),null==l?void 0:null===(n=l.filter(e=>""===c||e.includes(c)).filter(e=>!o.includes(e)))||void 0===n?void 0:n.map((e,n)=>(0,i.jsx)(nE.s,{onClick:()=>m(e),children:e},"option-".concat(n)))]})]})})]}),(0,i.jsx)(ij.x,{children:(0,i.jsx)(er.z,{variant:"link",color:"#3182CE",fontSize:e.size,paddingTop:"4px",paddingRight:"24px",hidden:0===o.length,onClick:()=>{d(""),a([]),r([])},children:"Clear"})})]})},ib=e=>{let{defaultPrimaryKeys:n,onPrimaryKeysChange:t,...l}=e,{lineageGraph:r,isActionAvailable:s}=eg(),a=(0,j.useMemo)(()=>{if(!r)return[];let e=new Set;for(let i in r.nodes){var n,t;let l=r.nodes[i],s=null===(n=l.data.base)||void 0===n?void 0:n.columns,o=null===(t=l.data.current)||void 0===t?void 0:t.columns;for(let n in s)e.add(n);for(let n in o)e.add(n)}return Array.from(e).sort()},[r]);return(0,i.jsx)(o.k,{...l,children:(0,i.jsxs)(eC.NI,{m:"4px 8px",children:[(0,i.jsxs)(e_.l,{fontSize:"8pt",margin:"0",children:["Diff with Primary Key(s) (suggested)"," ",(0,i.jsx)(nh.u,{label:"Provide a primary key to perform query diff in data warehouse and only return changed rows.",placement:"bottom-end",children:(0,i.jsx)(tH.s,{color:"gray.600",boxSize:"3"})})]}),(0,i.jsx)(iy,{unitName:"key",defaultValues:n,suggestionList:a,onValuesChange:t,size:"xs",width:"240px",placeholder:"Start by typing key name...",isDisabled:!s("query_diff_with_primary_key")})]})})};var iw=t(58631),ik=t(26969);function iC(e){let{description:n,onLike:t,onDislike:l,onClickLink:s,externalLink:c,externalLinkText:d}=e;return(0,i.jsxs)(o.k,{gap:4,justifyContent:"center",alignContent:"center",alignItems:"center",children:[n,(0,i.jsx)(nS.h,{"aria-label":"thumbs up",variant:"ghost",icon:(0,i.jsx)(a.E,{src:"/imgs/feedback/thumbs-up.png",alt:"like"}),width:"32px",height:"32px",onClick:t}),(0,i.jsx)(nS.h,{"aria-label":"thumbs down",variant:"ghost",icon:(0,i.jsx)(a.E,{src:"/imgs/feedback/thumbs-down.png",alt:"dislike"}),width:"32px",height:"32px",onClick:l}),c&&d&&(0,i.jsx)(r.r,{href:c,isExternal:!0,textDecoration:"underline",onClick:s,children:d})]})}let i_="recce-",iS={bypassSaveOverwrite:"".concat(i_,"-bypass-save-overwrite"),previewChangeFeedbackID:"".concat(i_,"-preview-change-feedback")};var iz=t(16564),iR=t(38674);function iE(e){iz.j("[Web] multi_nodes_action",e)}function iT(e){iz.j("[Web] history_action",e)}function iD(e){iz.j("[Experiment] preview_change",e)}function iL(e){iz.j("[Experiment] preview_change",e)}function iI(e){let{current:n,primaryKeys:t,setPrimaryKeys:r,onRunResultOpen:a,runQuery:d,isPending:u,feedbackToast:x}=e;return(0,i.jsxs)(o.k,{justifyContent:"right",alignItems:"center",padding:"4pt 8pt",gap:"5px",height:"54px",borderBottom:"1px solid lightgray",flex:"0 0 54px",children:[(0,i.jsxs)(l.x,{children:[(0,i.jsxs)(c.X,{as:"h2",size:"md",display:"flex",alignItems:"center",gap:"5px",children:[(0,i.jsx)(s.J,{as:iw.vc4,boxSize:"1.2em"}),"Preview Changes"]}),(0,i.jsxs)(ei.x,{fontSize:"xs",color:"gray.500",children:["Compare the run results based on the modified SQL code of model"," ",(0,i.jsx)("b",{children:null==n?void 0:n.name})]})]}),(0,i.jsx)(h.L,{}),(0,i.jsx)(ib,{defaultPrimaryKeys:t,onPrimaryKeysChange:r}),(0,i.jsx)(nh.u,{label:"Run diff to see the changes",children:(0,i.jsx)(er.z,{size:"xs",marginTop:"16px",fontSize:"14px",onClick:()=>{a(),d(),setTimeout(()=>x(),3e3)},colorScheme:"blue",isLoading:u,children:"Run Diff"})})]})}function iM(e){let{height:n="32px",flex:t="0 0 auto"}=e,l="0 16px";return(0,i.jsxs)(o.k,{gap:0,height:n,flex:t,fontSize:"14px",align:"center",margin:"0",backgroundColor:"#EDF2F880",children:[(0,i.jsx)(tR.K,{width:"50%",children:(0,i.jsx)(ei.x,{as:"b",margin:l,children:"CURRENT"})}),(0,i.jsx)(tR.K,{width:"50%",children:(0,i.jsx)(ei.x,{as:"b",margin:l,children:"PREVIEW EDITOR"})})]})}function iO(e){let{isOpen:n,onClose:t,current:r}=e,{isOpen:s,onClose:h,onOpen:x}=(0,eb.q)(),[m,p]=(0,j.useState)((null==r?void 0:r.raw_code)||""),{showRunId:f,clearRunResult:g}=nq(),{primaryKeys:v,setPrimaryKeys:y}=_(),b=async()=>{let e={current_model:(null==r?void 0:r.name)||"",primary_keys:v,sql_template:m},{run_id:n}=await ip(e,{nowait:!0});return f(n),await ec(n)},{mutate:w,isPending:k}=(0,te.D)({mutationFn:b,onSuccess(e,n){e.error?iD({action:"run",node:null==r?void 0:r.name,status:"failure"}):iD({action:"run",node:null==r?void 0:r.name,status:"success"})}}),{feedbackToast:C,closeToast:S}=function(e){let n=(0,G.p)(),{feedbackId:t,description:l,onFeedbackSubmit:r,externalLink:s,externalLinkText:o}=e;return{feedbackToast:function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=localStorage.getItem(t);n.isActive(t)||"true"===a&&!1===e||n({id:t,position:"bottom-right",duration:null,render:e=>{let{id:a,onClose:c}=e;return(0,i.jsx)(tl.b,{status:"success",variant:"subtle",zIndex:"toast",borderColor:"gray.200",borderWidth:3,borderRadius:"md",backgroundColor:"white",opacity:1,children:(0,i.jsx)(ik.X,{fontSize:"md",children:(0,i.jsxs)(u.U,{children:[(0,i.jsx)(iC,{description:l,onLike:()=>{r("like"),n.closeAll(),localStorage.setItem(t,"true")},onDislike:()=>{r("dislike"),n.closeAll(),localStorage.setItem(t,"true")},externalLink:s,externalLinkText:o,onClickLink:()=>{r("link")}}),(0,i.jsx)(t1.P,{onClick:c})]})})})}})},closeToast:()=>n.closeAll()}}({feedbackId:iS.previewChangeFeedbackID,description:"Enjoy preview change?",onFeedbackSubmit:e=>{switch(e){case"like":iL({feedback:"like",node:null==r?void 0:r.name});break;case"dislike":iL({feedback:"dislike",node:null==r?void 0:r.name});break;case"link":iL({feedback:"form",node:null==r?void 0:r.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"});return(0,j.useEffect)(()=>{n&&p((null==r?void 0:r.raw_code)||"")},[n,r]),(0,i.jsx)(Y.u_,{isOpen:n,size:"full",onClose:()=>{t(),h(),g(),S(),iD({action:"close",node:null==r?void 0:r.name})},children:(0,i.jsxs)(ee.h,{height:"100%",children:[(0,i.jsx)(en.x,{height:"40px",bg:"rgb(77, 209, 176)",px:0,py:4,children:(0,i.jsxs)(o.k,{alignItems:"center",height:"100%",gap:"10px",children:[(0,i.jsx)(a.E,{boxSize:"20px",ml:"18px",src:"/logo/recce-logo-white.png",alt:"recce-logo-white"}),(0,i.jsx)(c.X,{as:"h1",fontFamily:'"Montserrat", sans-serif',fontSize:"lg",color:"white",children:"RECCE"}),(0,i.jsx)(d.C,{fontSize:"sm",color:"white",colorScheme:"whiteAlpha",variant:"outline",children:"Experiment"})]})}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(et.f,{p:0,children:(0,i.jsxs)(td,{sizes:s?[50,50]:[100,0],minSize:s?100:0,gutterSize:s?5:0,style:{flex:"1",contain:"size",height:"100%"},children:[(0,i.jsxs)(o.k,{direction:"column",height:"100%",m:0,p:0,children:[(0,i.jsx)(iI,{current:r,primaryKeys:null!=v?v:[],setPrimaryKeys:y,onRunResultOpen:x,runQuery:w,isPending:k,feedbackToast:C}),(0,i.jsx)(iM,{height:"32pxs",flex:"0 0 auto"}),(0,i.jsx)(t2,{current:r,onChange:p})]}),s?(0,i.jsx)(ih,{onClose:h,disableAddToChecklist:!0}):(0,i.jsx)(l.x,{})]})}),(0,i.jsx)(l.x,{position:"fixed",bottom:"4",right:"4",opacity:.5,children:(0,i.jsx)(nh.u,{label:"Give us feedback",children:(0,i.jsx)(nS.h,{"aria-label":"feedback",icon:(0,i.jsx)(eY.xJq,{}),variant:"ghost",size:"md",onClick:()=>C(!0)})})})]})})}function iA(e){var n,t,r,a,d,f,g,v;let{node:y,onCloseNode:b}=e,[,w]=(0,ew.TH)(),{setSqlQuery:k,setPrimaryKeys:C}=_(),S="model"===y.resourceType||"seed"===y.resourceType||"source"===y.resourceType||"snapshot"===y.resourceType,{isOpen:z,onOpen:R,onClose:E}=(0,eb.q)(),{isOpen:T,onOpen:D,onClose:L}=(0,eb.q)(),{runAction:I}=nq(),{envInfo:M,isActionAvailable:O}=eg(),{primaryKey:A}=eT(y.name),F=()=>{I("row_count_diff",{node_names:[y.name]},{showForm:!1,showLast:!1})},N=(0,j.useCallback)(async()=>{let e=y.id,n=await t4({node_id:e});w("/checks/".concat(n.check_id))},[y,w]),q=(e,n)=>e?t6.add_or_remove:O(n)?"":"value_diff"===n?t6.audit_helper:"profile_diff"===n?t6.dbt_profiler:"This action is not supported yet.",V="added"===y.changeStatus||"removed"===y.changeStatus;return(0,i.jsxs)(t0.r,{height:"100%",templateRows:"auto auto 1fr",children:[(0,i.jsxs)(u.U,{children:[(0,i.jsx)(l.x,{flex:"0 1 20%",p:"16px",children:(0,i.jsx)(c.X,{size:"sm",children:y.name})}),(0,i.jsx)(h.L,{}),("model"===y.resourceType||"seed"===y.resourceType||"snapshot"===y.resourceType)&&(0,i.jsxs)(nC.v,{children:[(0,i.jsx)(n_.j,{as:er.z,size:"sm",colorScheme:"blue",children:"Explore Change"}),(0,i.jsxs)(nz.q,{children:[(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(n=nO("query_diff"))||void 0===n?void 0:n.icon}),fontSize:"14px",onClick:()=>{(null==M?void 0:M.adapterType)==="dbt"?k('select * from {{ ref("'.concat(y.name,'") }}')):(null==M?void 0:M.adapterType)==="sqlmesh"&&k("select * from ".concat(y.name)),O("query_diff_with_primary_key")&&C(void 0!==A?[A]:void 0),w("/query")},children:"Query"}),(0,i.jsx)(nE.s,{fontSize:"14px",icon:(0,i.jsx)(s.J,{as:null===(t=nO("preview_change"))||void 0===t?void 0:t.icon}),onClick:()=>{O("query_diff_with_primary_key")&&C(void 0!==A?[A]:void 0),D(),iD({action:"explore",node:y.name})},children:"Preview Change (Experiment)"}),(0,i.jsx)(nX.R,{}),(0,i.jsxs)(nR.k,{title:"Diff",m:"0",p:"4px 12px",children:[("model"===y.resourceType||"snapshot"===y.resourceType)&&(0,i.jsx)(nE.s,{onClick:R,icon:(0,i.jsx)(th.tvD,{}),fontSize:"14px",children:"Code Diff"}),(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(r=nO("row_count_diff"))||void 0===r?void 0:r.icon}),fontSize:"14px",onClick:()=>F(),children:"Row Count Diff"}),(0,i.jsx)(nh.u,{label:q(V,"profile_diff"),placement:"left",children:(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(a=nO("profile_diff"))||void 0===a?void 0:a.icon}),fontSize:"14px",isDisabled:V||!O("profile_diff"),onClick:()=>{I("profile_diff",{model:y.name},{showForm:!1,showLast:!1})},children:"Profile Diff"})}),(0,i.jsx)(nh.u,{label:q(V,"value_diff"),placement:"left",children:(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(d=nO("value_diff"))||void 0===d?void 0:d.icon}),fontSize:"14px",isDisabled:V||!O("value_diff"),onClick:()=>{I("value_diff",{model:y.name},{showForm:!0,showLast:!1})},children:"Value Diff"})}),(0,i.jsx)(nh.u,{label:q(V,"top_k_diff"),placement:"left",children:(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(f=nO("top_k_diff"))||void 0===f?void 0:f.icon}),fontSize:"14px",isDisabled:V,onClick:()=>{I("top_k_diff",{model:y.name,column_name:"",k:50},{showForm:!0})},children:"Top-K Diff"})}),(0,i.jsx)(nh.u,{label:q(V,"histogram_diff"),placement:"left",children:(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(g=nO("histogram_diff"))||void 0===g?void 0:g.icon}),fontSize:"14px",isDisabled:V,onClick:()=>{I("histogram_diff",{model:y.name,column_name:"",column_type:""},{showForm:!0})},children:"Histogram Diff"})})]}),(0,i.jsx)(nX.R,{}),(0,i.jsx)(nR.k,{title:"Add to Checklist",m:"0",p:"4px 12px",children:(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(v=nO("schema_diff"))||void 0===v?void 0:v.icon}),fontSize:"14px",onClick:N,children:"Schema Diff"})})]})]}),(0,i.jsx)(l.x,{flex:"0 1 1%",children:(0,i.jsx)(t1.P,{onClick:b})})]}),(0,i.jsx)(l.x,{color:"gray",paddingLeft:"16px",children:(0,i.jsxs)(u.U,{spacing:"8px",children:[(0,i.jsx)(tJ,{node:y}),("model"===y.resourceType||"snapshot"===y.resourceType||"seed"===y.resourceType)&&(0,i.jsx)(tU,{node:y,onRefresh:F})]})}),S&&(0,i.jsxs)(x.m,{overflow:"auto",as:o.k,children:[(0,i.jsx)(m.t,{children:(0,i.jsx)(p.O,{children:"Columns"})}),(0,i.jsx)(nG.n,{overflow:"auto",height:"calc(100% - 42px)",children:(0,i.jsx)(nY.x,{p:0,overflowY:"auto",height:"100%",children:(0,i.jsx)(ts,{base:y.data.base,current:y.data.current})})})]}),(0,i.jsxs)(Y.u_,{isOpen:z,onClose:E,size:"6xl",children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{overflowY:"auto",height:"75%",children:[(0,i.jsx)(en.x,{children:"Model Raw Code Diff"}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(et.f,{children:(0,i.jsx)(t5,{base:y.data.base,current:y.data.current})})]})]}),(0,i.jsx)(iO,{isOpen:T,onClose:L,current:y.data.current})]})}function iF(e){var n,t;let{onClose:r}=e,{cancel:s,actionState:o}=tX();return(0,i.jsx)(l.x,{bg:"white",rounded:"md",shadow:"dark-lg",children:(0,i.jsxs)(u.U,{p:"5px 15px",mt:"4",divider:(0,i.jsx)(tF.c,{borderColor:"gray.200"}),spacing:4,children:[(0,i.jsxs)(l.x,{fontSize:"10pt",children:["Progress: ","per_node"===o.mode?"".concat(o.completed," / ").concat(o.total):(null===(t=o.currentRun)||void 0===t?void 0:null===(n=t.progress)||void 0===n?void 0:n.percentage)?"".concat(100*o.currentRun.progress.percentage,"%"):"completed"===o.status?"100%":"0%"," ","canceled"===o.status?" (canceled)":""]}),"running"===o.status||"canceling"===o.status?(0,i.jsx)(er.z,{size:"xs",variant:"outline",onClick:s,isLoading:"canceling"===o.status,loadingText:"Canceling",children:"Cancel"}):(0,i.jsx)(u.U,{children:(0,i.jsx)(er.z,{size:"xs",variant:"outline",onClick:r,children:"Close"})})]})})}var iN=t(53388),iq=t(52346);let iV=()=>{let{isHistoryOpen:e,showHistory:n,closeHistory:t}=nq();return(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(s.J,{as:eY.M1Q}),size:"xs",variant:"outline",onClick:()=>{e?(iT({name:"hide"}),t()):(iT({name:"show"}),n())},children:e?"Hide":"Show"})},iH=e=>{let{isDisabled:n}=e,{viewOptions:t,onViewOptionsChanged:l,selectMode:r}=tX(),o=t.view_mode||"changed_models",a=e=>{l({...t,view_mode:e})};return(0,i.jsxs)(nC.v,{children:[(0,i.jsx)(n_.j,{as:er.z,minWidth:"100px",leftIcon:(0,i.jsx)(s.J,{as:tv("model").icon}),size:"xs",variant:"outline",isDisabled:n,children:"changed_models"===o?"Changed Models":"All"}),(0,i.jsxs)(nz.q,{title:"packages",children:[(0,i.jsx)(nE.s,{as:nn.X,size:"sm",isChecked:"changed_models"===o,onChange:()=>a("changed_models"),children:"Changed Models"}),(0,i.jsx)(nE.s,{as:nn.X,size:"sm",isChecked:"all"===o,onChange:()=>a("all"),children:"All"})]})]})},iP=e=>{var n,t;let{isDisabled:l}=e,{lineageGraph:r}=eg(),{viewOptions:o,onViewOptionsChanged:a}=tX(),c=new Set;for(let e of Object.values((null==r?void 0:r.nodes)||{}))e.packageName&&c.add(e.packageName);let d=null==r?void 0:null===(t=r.manifestMetadata)||void 0===t?void 0:null===(n=t.current)||void 0===n?void 0:n.project_name,u=o.packages?new Set(o.packages):d?new Set([d]):c,h=u.size===c.size,x=0===u.size,m=1===u.size?Array.from(u)[0]:h?"All Packages":x?"No Package":"".concat(u.size," Packages"),p=e=>{let n=new Set(u);n.has(e)?n.delete(e):n.add(e),a({...o,packages:Array.from(n)})};return(0,i.jsxs)(nC.v,{closeOnSelect:!1,children:[(0,i.jsx)(n_.j,{as:er.z,minWidth:"100px",leftIcon:(0,i.jsx)(s.J,{as:tW.zFh}),size:"xs",variant:"outline",isDisabled:l,children:m}),(0,i.jsx)(nz.q,{title:"packages",children:(0,i.jsxs)(nR.k,{title:"Select Packages",children:[(0,i.jsx)(nE.s,{as:nn.X,size:"sm",isIndeterminate:!h&&!x,isChecked:h,onChange:()=>{h?a({...o,packages:[]}):a({...o,packages:Array.from(c)})},children:"Select All"}),(0,i.jsx)(nX.R,{}),Array.from(c).map(e=>(0,i.jsx)(nE.s,{as:nn.X,size:"sm",isChecked:u.has(e),onChange:()=>{p(e)},children:e},e))]})})]})},iW=e=>{let[n,t]=(0,j.useState)(e.value),l=(0,j.useRef)(null);return(0,j.useEffect)(()=>{l.current&&(l.current.value=e.value)},[e.value]),(0,i.jsx)(nb.I,{ref:l,height:"24px",fontSize:"10pt",placeholder:"with selectors",isDisabled:e.isDisabled,value:n,onChange:e=>{t(e.target.value)},onKeyUp:i=>{"Enter"===i.key?e.onChange(n):"Escape"===i.key&&(i.preventDefault(),t(e.value),l.current&&l.current.blur())},onBlur:()=>t(e.value)})},iK=e=>{let{isDisabled:n}=e,{viewOptions:t,onViewOptionsChanged:l}=tX();return(0,i.jsx)(iW,{isDisabled:n,value:t.select||"",onChange:e=>{l({...t,select:e||void 0})}})},iJ=e=>{let{isDisabled:n}=e,{viewOptions:t,onViewOptionsChanged:l}=tX();return(0,i.jsx)(iW,{isDisabled:n,value:t.exclude||"",onChange:e=>{l({...t,exclude:e||void 0})}})},iB=e=>(0,i.jsxs)(l.x,{style:e.style,maxWidth:"300px",children:[(0,i.jsx)(l.x,{fontSize:"8pt",children:(null==e?void 0:e.label)||(0,i.jsx)(i.Fragment,{children:"\xa0"})}),e.children]}),iU=()=>{var e,n,t,l;let{nodes:r,deselect:o,selectMode:a,...c}=tX(),{isActionAvailable:d}=eg(),x=(0,j.useMemo)(()=>r.filter(e=>e.data.isSelected),[r]),m="single"===a&&1===x.length,p="multi"===a&&x.length>=1,f="single"===a&&0===x.length,g="single"!==a;return(0,i.jsx)(u.U,{width:"100%",padding:"4pt 8pt",children:(0,i.jsxs)(u.U,{flex:"1",children:[(0,i.jsx)(iB,{label:"History",style:{flexShrink:"1"},children:(0,i.jsx)(iV,{})}),(0,i.jsx)(iB,{label:"Mode",style:{flexShrink:"1"},children:(0,i.jsx)(iH,{isDisabled:g})}),(0,i.jsx)(iB,{label:"Package",style:{flexShrink:"1"},children:(0,i.jsx)(iP,{isDisabled:g})}),(0,i.jsx)(iB,{label:"Select",style:{flex:"100 1 auto"},children:(0,i.jsx)(iK,{isDisabled:g})}),(0,i.jsx)(iB,{label:"Exclude",style:{flex:"100 1 auto"},children:(0,i.jsx)(iJ,{isDisabled:g})}),(0,i.jsx)(h.L,{}),"multi"===a&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(iB,{label:"",style:{flexShrink:"0"},children:(0,i.jsx)(ei.x,{fontSize:"9pt",color:"gray.500",children:x.length>1?"".concat(x.length," nodes selected"):"".concat(x.length," node selected")})}),(0,i.jsx)(iB,{label:"",children:(0,i.jsx)(er.z,{variant:"outline",size:"xs",fontSize:"9pt",isDisabled:"multi"!==a,onClick:()=>{o()},children:"Deselect"})})]}),(0,i.jsx)(iB,{label:"Explore",children:(0,i.jsx)(iN.h,{isAttached:!0,variant:"outline",children:(0,i.jsxs)(nC.v,{placement:"bottom-end",children:[(0,i.jsx)(n_.j,{as:er.z,size:"xs",rightIcon:(0,i.jsx)(iq.v,{}),children:"Actions"}),(0,i.jsxs)(nz.q,{children:[(0,i.jsxs)(nR.k,{title:"Diff",m:"0",p:"4px 12px",children:[(0,i.jsx)(nE.s,{as:ei.x,size:"sm",fontSize:"10pt",isDisabled:!(f||m||p),icon:(0,i.jsx)(s.J,{as:null===(e=nO("row_count_diff"))||void 0===e?void 0:e.icon}),onClick:()=>{c.runRowCountDiff()},children:"Row Count Diff"}),(0,i.jsx)(nh.u,{label:d("value_diff")?null:t6.audit_helper,placement:"left",children:(0,i.jsx)(nE.s,{as:ei.x,size:"sm",fontSize:"10pt",isDisabled:!(f||m||p)||!d("value_diff"),icon:(0,i.jsx)(s.J,{as:null===(n=nO("value_diff"))||void 0===n?void 0:n.icon}),onClick:()=>{c.runValueDiff()},children:"Value Diff"})})]}),(0,i.jsx)(nX.R,{}),(0,i.jsxs)(nR.k,{title:"Add to Checklist",m:"0",px:"12px",children:[(0,i.jsx)(nE.s,{as:ei.x,size:"sm",fontSize:"10pt",isDisabled:!(f||p&&x.length>1),icon:(0,i.jsx)(s.J,{as:null===(t=nO("lineage_diff"))||void 0===t?void 0:t.icon}),onClick:()=>{c.addLineageDiffCheck(c.viewOptions.view_mode)},children:"Lineage Diff"}),(0,i.jsx)(nE.s,{as:ei.x,size:"sm",fontSize:"10pt",isDisabled:!(f||m||p),icon:(0,i.jsx)(s.J,{as:null===(l=nO("schema_diff"))||void 0===l?void 0:l.icon}),onClick:()=>{c.addSchemaDiffCheck()},children:"Schema Diff"})]})]})]})})})]})})};async function iZ(e){return(await U.post("/api/checks",{type:"lineage_diff",params:{},view_options:e})).data}function iQ(){return(0,i.jsx)(l.x,{bg:"white",padding:"12px",borderWidth:"1px",borderColor:"gray.200",fontSize:"sm",children:Object.entries({added:["Added","Added resource"],removed:["Removed","Removed resource"],modified:["Modified","Modified resource"]}).map(e=>{let[n,[t,l]]=e,{icon:r,color:a}=tg(n);return(0,i.jsx)(nh.u,{label:l,children:(0,i.jsxs)(o.k,{alignItems:"center",gap:"6px",marginBottom:"2px",children:[(0,i.jsx)(s.J,{color:a,as:r})," ",t]})},n)})})}var iX=t(9690);let iG={mode:"per_node",status:"pending",completed:0,total:0},iY=(e,n)=>{let{onActionStarted:t,onActionNodeUpdated:i,onActionCompleted:l}=n,r=(0,j.useRef)({...iG}).current,{showRunId:s}=nq(),o=async(n,o,a)=>{let c="multi_nodes";r.mode=c,t(),r.status="running";let d=[];for(let n of e){let e=o(n);n.isActionMode=!0,e?(n.action={mode:c,status:"skipped",skipReason:e},i(n)):(n.action={mode:c,status:"pending"},d.push(n))}let u=a(d);try{let{run_id:e}=await ea(n,u,{nowait:!0});for(s(e),r.currentRun={run_id:e},r.total=1;;){let n=await ec(e,2);r.currentRun=n;let t=n.error?"failure":n.result?"success":"running";for(let e of d)e.action={mode:c,status:t,run:n},i(e);if(n.error||n.result)break}}catch(e){}if(r.completed=1,"canceling"===r.status){r.status="canceled",l();return}r.status="completed",l()},a=async(n,s)=>{let o="per_node";for(let n of(r.mode=o,t(),r.status="running",e))n.action={mode:o,status:"pending"},i(n);for(let t of(r.completed=0,r.total=e.length,e)){let{params:e,skipReason:a}=s(t);if(t.isActionMode=!0,a)t.action={mode:o,status:"skipped",skipReason:a},i(t);else try{let{run_id:l}=await ea(n,e,{nowait:!0});for(r.currentRun={run_id:l},t.action={mode:o,status:"running"},i(t);;){let e=await ec(l,2);r.currentRun=e;let n=e.error?"failure":e.result?"success":"running";if(t.action={mode:o,status:n,run:e},i(t),e.error||e.result)break}}catch(e){}finally{r.currentRun=void 0}if(r.completed++,"canceling"===r.status){r.status="canceled",l();return}}r.status="completed",l()},c=async()=>{var e;r.status="canceling",(null===(e=r.currentRun)||void 0===e?void 0:e.run_id)&&await ed(r.currentRun.run_id)};return{actionState:r,runRowCountDiff:async()=>{let n=[];for(let t of e)"model"!==t.resourceType?(t.action={mode:"multi_nodes",status:"skipped",skipReason:"Not a model"},i(t)):n.push(t.name);await o("row_count_diff",e=>{if("model"!==e.resourceType)return"Not a model"},e=>({node_names:e.map(e=>e.name)}))},runValueDiff:async()=>{a("value_diff",e=>{var n,t;let i=null===(t=e.data)||void 0===t?void 0:null===(n=t.current)||void 0===n?void 0:n.primary_key;return i?{params:{model:e.name,primary_key:i}}:{skipReason:"No primary key found. The first unique column is used as primary key."}})},addLineageDiffCheck:async()=>{let n=e.map(e=>e.id);return await iZ({node_ids:n})},addSchemaDiffCheck:async()=>{let n;if(1===e.length)n=await t4({node_id:e[0].id});else{let t=e.map(e=>e.id);n=await t4({node_id:t})}return n},cancel:c,reset:()=>{Object.assign(r,iG)}}};var i$=t(41798),i0=function(){let{isOpen:e,onOpen:n,onClose:t}=(0,eb.q)(),[r,s]=(0,j.useState)(0),[a,c]=(0,j.useState)(),d=(0,j.useRef)(),u=(0,j.useCallback)(e=>(s(e),new Promise(e=>{c(()=>e),n()})),[n]),h=()=>{null==a||a(!1),t()};return{confirm:u,AlertDialog:(0,i.jsx)(i$.aR,{size:"xl",isOpen:e,leastDestructiveRef:d,onClose:h,children:(0,i.jsx)($.Z,{children:(0,i.jsxs)(i$._T,{children:[(0,i.jsxs)(en.x,{fontSize:"lg",fontWeight:"bold",children:["Value Diff on ",r," nodes"]}),(0,i.jsx)(et.f,{gap:"20px",as:o.k,direction:"column",children:(0,i.jsxs)(l.x,{children:["Value diff will be executed on ",r," nodes in the Lineage, which can add extra costs to your bill."]})}),(0,i.jsxs)(el.m,{children:[(0,i.jsx)(er.z,{ref:d,onClick:h,children:"Cancel"}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>{null==a||a(!0),t()},ml:3,children:"Execute"})]})]})})})}};let i1={customNode:function(e){var n,t;let{data:r}=e,{isHighlighted:a,isSelected:c,resourceType:d,changeStatus:x}=r,m=(0,R.oR)(e=>e.transform[2]>.3),{icon:p}=tv(d),[f,g]=(0,j.useState)(!1),{interactive:v,selectNodeMulti:y,selectMode:b}=tX(),{icon:w,color:k,backgroundColor:C}=x?tg(x):{icon:void 0,color:"gray.400",backgroundColor:"gray.100"},_="solid";r.isSelected;let S=null==r?void 0:r.name;return(0,i.jsx)(nh.u,{label:"model"===d?S:"".concat(S," (").concat(d,")"),placement:"top",children:(0,i.jsxs)(o.k,{width:"300px",borderColor:k,borderWidth:1,borderStyle:_,backgroundColor:m?"multi"===b?c?k:"white":"action_result"!==b?c?C:"white":r.action?c?C:k:"white":c?k:C,borderRadius:3,transition:"box-shadow 0.2s ease-in-out",padding:0,filter:"action_result"===b?(null==r?void 0:r.action)?"none":"opacity(0.2) grayscale(50%)":a||c?"none":"opacity(0.2) grayscale(50%)",onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[(0,i.jsx)(o.k,{backgroundColor:k,padding:v?"8px":"2px",borderRightWidth:1,borderColor:"multi"===b?"#00000020":k,borderStyle:_,alignItems:"top",visibility:m?"inherit":"hidden",children:v&&(0,i.jsx)(tY,{checked:"multi"===b&&c||"action_result"===b&&!!r.action,onClick:e=>{"action_result"!==b&&(e.stopPropagation(),y(r.id))}})}),(0,i.jsxs)(o.k,{flex:"1 0 auto",mx:"1",width:"100px",direction:"column",height:"60px",children:[(0,i.jsxs)(o.k,{width:"100%",textAlign:"left",fontWeight:"600",flex:"1",p:1,gap:"5px",alignItems:"center",visibility:m?"inherit":"hidden",children:[(0,i.jsx)(l.x,{flex:"1",color:"multi"===b?c?"white":"inherit":"action_result"===b&&r.action&&!c?"white":"inherit",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:S}),(0,i.jsx)(s.J,{boxSize:"16px",color:"multi"===b?c?"white":"inherit":"action_result"===b&&r.action&&!c?"white":"inherit",as:p}),w&&(0,i.jsx)(s.J,{color:"multi"===b?c?"white":k:"action_result"===b?r.action&&!c?"white":"inherit":k,as:w})]}),(0,i.jsx)(o.k,{flex:"1 0 auto",mx:"1",direction:"column",paddingBottom:"1",visibility:m?"inherit":"hidden",children:(0,i.jsxs)(u.U,{spacing:"8px",children:["action_result"!==b&&"model"===r.resourceType&&(0,i.jsx)(tG,{id:r.id,inverted:"multi"===b&&!!c}),(0,i.jsx)(h.L,{}),r.isActionMode&&(r.action?(0,i.jsx)(tZ,{node:r,action:r.action}):(0,i.jsx)(i.Fragment,{}))]})})]}),Object.keys(null!==(n=null==r?void 0:r.parents)&&void 0!==n?n:{}).length>0&&(0,i.jsx)(R.HH,{type:"target",position:R.Ly.Left,isConnectable:!1}),Object.keys(null!==(t=null==r?void 0:r.children)&&void 0!==t?t:{}).length>0&&(0,i.jsx)(R.HH,{type:"source",position:R.Ly.Right,isConnectable:!1})]})})}},i5={customEdge:function(e){let{sourceX:n,sourceY:t,targetX:l,targetY:r,sourcePosition:s,targetPosition:o,style:a={},markerEnd:c,data:d}=e,u={...a};(null==d?void 0:d.changeStatus)&&(u.stroke=tg(null==d?void 0:d.changeStatus).color,u.strokeDasharray="5"),(null==d?void 0:d.isHighlighted)===!1&&(u.filter="opacity(0.2) grayscale(50%)");let[h]=(0,R.OQ)({sourceX:n,sourceY:t,sourcePosition:s,targetX:l,targetY:r,targetPosition:o});return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(R.u5,{path:h,markerEnd:c,style:{...u,...a}})})}},i2=e=>{var n,t;return(null==e?void 0:null===(n=e.data)||void 0===n?void 0:n.changeStatus)?tg(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.changeStatus).color:"lightgray"},i4=(e,n)=>{let t=null==e?void 0:e.current,i=(0,j.useRef)({width:0,height:0});(0,j.useEffect)(()=>{let e=new ResizeObserver(e=>{for(let t of e){let e=t.contentRect.width,l=t.contentRect.height;(Math.abs(l-i.current.height)>10||Math.abs(e-i.current.width)>10)&&i.current.height>0&&l>0&&i.current.width>0&&e>0&&n(),i.current={width:e,height:l}}});return t&&e.observe(t),()=>{t&&e.unobserve(t)}},[t,i,n])},i6=()=>{let[,e]=(0,ew.TH)();return(0,j.useCallback)(n=>{n.check_id&&e("/checks/".concat(n.check_id))},[e])},i3=(0,j.forwardRef)(function(e,n){var t,r;let{interactive:a=!1,...c}=e,d=(0,R._K)(),h=(0,j.useRef)(null),{successToast:x,failToast:m}=t_(),{copyToClipboard:p,ImageDownloadModal:f,ref:g}=io({renderLibrary:"html-to-image",imageType:"png",shadowEffect:!0,backgroundColor:"white",ignoreElements:e=>{let n=e.className;return!!("string"==typeof n&&n.includes(is))},onSuccess:()=>{x("Copied the Lineage View as an image to clipboard")},onError:e=>{console.error("Error taking screenshot",e),m("Failed to copy image to clipboard",e)}}),[v,y,b]=(0,R.Rr)([]),[w,k,C]=(0,R.ll)([]),{lineageGraph:_,retchLineageGraph:S,isLoading:z,error:E,refetchRunsAggregated:D}=eg(),{showRunId:L,closeRunResult:P,runAction:W}=nq(),K=_&&(null==_?void 0:null===(t=_.modifiedSet)||void 0===t?void 0:t.length)>0,[J,B]=(0,j.useState)({view_mode:K?"changed_models":"all",...c.viewOptions});(0,j.useImperativeHandle)(n,()=>({copyToClipboard:p}));let U=J.view_mode||"changed_models",[Z,Q]=(0,j.useState)("single"),X=(0,j.useMemo)(()=>{var e;if("single"===Z)return null===(e=v.find(e=>e.data.isSelected))||void 0===e?void 0:e.data},[Z,v]),Y=(0,j.useMemo)(()=>v.filter(e=>e.data.isSelected).map(e=>e.data),[v]),$=(0,j.useMemo)(()=>v.map(e=>e.data),[v]),[ee,en]=(0,j.useState)(!1),[et,el]=(0,j.useState)({x:0,y:0}),es=(0,G.p)();(0,j.useLayoutEffect)(()=>{(async()=>{let e;if(!_)return;if(J.node_ids)e=J.node_ids;else{var n;let t=null===(n=_.manifestMetadata.current)||void 0===n?void 0:n.project_name,i={view_mode:J.view_mode,packages:t?[t]:void 0,...c.viewOptions};B(i),e=(await to({select:i.select,exclude:i.exclude,packages:i.packages,view_mode:i.view_mode})).nodes}let[t,i]=O(_,e);A(t,i),y(t),k(i)})()},[_]);let eo=async e=>{if(e.width&&e.height){let n=e.position.x+e.width/2,t=e.position.y+e.height/2,i=d.getZoom();d.setCenter(n,t,{zoom:i,duration:200})}},ea=i6();i4(h,async()=>{if("single"===Z||"action_result"===Z){let e=v.find(e=>e.data.isSelected);e?eo(e):d.fitView({nodes:v,duration:200})}});let ec=(0,j.useCallback)(e=>{y(n=>n.map(n=>n.id===e.id?{...n,data:e}:n))},[y]),ed=async e=>{let n;if(!_)return;try{n=(await to({select:e.select,exclude:e.exclude,packages:e.packages,view_mode:e.view_mode})).nodes}catch(e){if(e instanceof iX.d7){var t,i;es({title:"Select node error",description:(null===(i=e.response)||void 0===i?void 0:null===(t=i.data)||void 0===t?void 0:t.detail)||e.message,status:"error",isClosable:!0,position:"bottom-right"})}return}let[l,r]=O(_,n);A(l,r),y(l),k(r),B(e),await new Promise(e=>setTimeout(e,1)),await (async()=>{d.fitView({nodes:l,duration:200})})()},eu=iY("multi"===Z?Y:$,{onActionStarted:()=>{Q("action_result")},onActionNodeUpdated:ec,onActionCompleted:()=>{}}),eh=i0();if(z)return(0,i.jsx)(o.k,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",children:(0,i.jsx)(tA.$,{size:"xl"})});let ex=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3,n=et.selectedNode;"action_result"!==Z&&void 0!==n&&void 0!==_&&("single"===Z&&(y(H(v,!0)),Q("multi"),eu.reset()),y(V([...I(_,[n.id],e)],v,"single"===Z)))},em=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3,n=et.selectedNode;"action_result"!==Z&&void 0!==n&&void 0!==_&&("single"===Z&&(y(H(v,!0)),Q("multi"),eu.reset()),y(V([...M(_,[n.id],e)],v,"single"===Z)))},ep=()=>{en(!1),el({x:0,y:0})};if(E)return(0,i.jsx)(eZ.M,{h:"100%",children:(0,i.jsxs)(ne.g,{children:[(0,i.jsx)(l.x,{children:"Failed to load lineage data. This could be because the server has been terminated or there is a network error."}),(0,i.jsxs)(l.x,{children:["[Reason: ",E,"]"]}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>{S&&S()},children:"Retry"})]})});if("changed_models"===U&&!(null==_?void 0:null===(r=_.modifiedSet)||void 0===r?void 0:r.length))return(0,i.jsx)(eZ.M,{h:"100%",children:(0,i.jsxs)(ne.g,{children:[(0,i.jsx)(i.Fragment,{children:"No change detected"}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>{ed({...J,view_mode:"all"})},children:"Show all nodes"})]})});let ef=()=>{Q("single"),y(H(v)),P(),null==D||D()},ev={interactive:a,selectMode:Z,nodes:v,viewOptions:J,onViewOptionsChanged:ed,selectNodeMulti:e=>{if("multi"!==Z){if(!_)return;let[n,t]=F(Array.from(M(_,_.modifiedSet)),v,w);y(n=N(e,n=H(n,!0))),k(t),Q("multi"),eu.reset()}else{let n=q(e,v);n.find(e=>e.data.isSelected)||(Q("single"),n=H(n)),y(n)}},deselect:ef,runRowCountDiff:async()=>{"multi"===Z?(await eu.runRowCountDiff(),iE({type:"row_count_diff",selected:"multi"})):X?(await W("row_count_diff",{node_names:[X.name]},{showForm:!1,showLast:!1}),iE({type:"row_count_diff",selected:"single"})):(await W("row_count_diff",{select:J.select,exclude:J.exclude,packages:J.packages,view_mode:J.view_mode}),iE({type:"row_count_diff",selected:"none"}))},runValueDiff:async()=>{if(X)await W("value_diff",{model:X.name},{showForm:!0,showLast:!1}),iE({type:"value_diff",selected:"single"});else{let e="multi"===Z?Y.length:$.length;await eh.confirm(e)&&(await eu.runValueDiff(),iE({type:"value_diff",selected:"multi"===Z?"multi":"none"}))}},addLineageDiffCheck:async()=>{let e;"multi"===Z?(e=await eu.addLineageDiffCheck(),ef(),iE({type:"lineage_diff",selected:"multi"})):X||(e=await iZ(J),iE({type:"lineage_diff",selected:"none"})),e&&ea(e)},addSchemaDiffCheck:async()=>{let e;"multi"===Z?Y.length>0&&(e=await eu.addSchemaDiffCheck(),ef(),iE({type:"schema_diff",selected:"multi"})):X?(e=await t4({node_id:X.id}),iE({type:"schema_diff",selected:"single"})):(e=await t4({select:J.select,exclude:J.exclude,packages:J.packages,view_mode:J.view_mode}),iE({type:"schema_diff",selected:"none"})),e&&ea(e)},cancel:eu.cancel,actionState:eu.actionState};return(0,i.jsxs)(tQ.Provider,{value:ev,children:[(0,i.jsxs)(tc,{sizes:X?[70,30]:[100,0],minSize:X?400:0,gutterSize:X?5:0,style:{height:"100%",width:"100%"},children:[(0,i.jsxs)(ne.g,{ref:h,divider:(0,i.jsx)(tF.c,{borderColor:"gray.200"}),spacing:0,style:{contain:"strict"},position:"relative",children:[a&&(0,i.jsx)(iU,{}),(0,i.jsxs)(R.x$,{nodeTypes:i1,edgeTypes:i5,nodes:v,edges:w,onNodesChange:b,onEdgesChange:C,onNodeClick:(e,n)=>{if(!1!==a&&_){if(ep(),"single"===Z){X||eo(n);let[e,t]=F(Array.from(T(I(_,[n.id]),M(_,[n.id]))),v,w);y(N(n.id,e)),k(t)}else if("action_result"===Z){var t,i,l,r;(null===(i=n.data.action)||void 0===i?void 0:null===(t=i.run)||void 0===t?void 0:t.run_id)&&L(null===(r=n.data.action)||void 0===r?void 0:null===(l=r.run)||void 0===l?void 0:l.run_id),eo(n),y(N(n.id,v))}else{let e=q(n.id,v);e.find(e=>e.data.isSelected)||(Q("single"),e=H(e)),y(e)}}},onNodeMouseEnter:(e,n)=>{if(!_||X||"single"!==Z)return;let[t,i]=F(Array.from(T(I(_,[n.id]),M(_,[n.id]))),v,w);y(t),k(i)},onNodeMouseLeave:(e,n)=>{if(!_||X)return;let[t,i]=F(Array.from(M(_,_.modifiedSet)),v,w);y(t),k(i)},onNodeContextMenu:(e,n)=>{if(!a||"action_result"===Z)return;e.preventDefault();let t=g.current.getBoundingClientRect(),i=g.current.offsetTop;el({x:e.clientX-t.left,y:e.clientY-t.top+i,selectedNode:n}),en(!0)},onClick:ep,maxZoom:1,minZoom:.1,fitView:!0,nodesDraggable:a,ref:g,children:[(0,i.jsx)(tN.A,{color:"#ccc"}),(0,i.jsx)(tq.Z,{showInteractive:!1,position:"top-right",className:is,children:(0,i.jsx)(tq.B,{title:"copy image",onClick:async()=>{p()},children:(0,i.jsx)(s.J,{as:tW.C3L})})}),(0,i.jsx)(f,{}),(0,i.jsx)(R.s_,{position:"bottom-left",children:(0,i.jsx)(u.U,{children:(0,i.jsx)(iQ,{})})}),(0,i.jsx)(R.s_,{position:"top-left",children:(0,i.jsx)(ei.x,{fontSize:"xl",color:"grey",opacity:.5,children:v.length>0?"":"No nodes"})}),(0,i.jsx)(tV.a,{nodeColor:i2,nodeStrokeWidth:3,zoomable:!0,pannable:!0}),"action_result"===Z&&(0,i.jsx)(R.s_,{position:"bottom-center",className:is,children:(0,i.jsx)(iF,{onClose:()=>{ef()}})})]}),ee&&(0,i.jsx)(nC.v,{isOpen:!0,onClose:ep,children:(0,i.jsxs)(nz.q,{fontSize:"11pt",position:"absolute",width:"250px",style:{left:"".concat(et.x,"px"),top:"".concat(et.y,"px")},children:[(0,i.jsx)(nE.s,{icon:(0,i.jsx)(t$.Cv2,{}),onClick:()=>{ex(1)},children:"Select parent nodes"}),(0,i.jsx)(nE.s,{icon:(0,i.jsx)(t$.IMj,{}),onClick:()=>{em(1)},children:"Select child nodes"}),(0,i.jsx)(nX.R,{}),(0,i.jsx)(nE.s,{icon:(0,i.jsx)(t$.Cv2,{}),onClick:()=>{ex()},children:"Select all upstream nodes"}),(0,i.jsx)(nE.s,{icon:(0,i.jsx)(t$.IMj,{}),onClick:()=>{em()},children:"Select all downstream nodes"})]})})]}),"single"===Z&&X?(0,i.jsx)(l.x,{borderLeft:"solid 1px lightgray",height:"100%",children:(0,i.jsx)(iA,{node:X,onCloseNode:()=>{if(!_)return;let[e,n]=F(Array.from(M(_,_.modifiedSet)),v,w);y(H(e)),k(n)}})}):(0,i.jsx)(l.x,{})]}),eh.AlertDialog]})}),i9=(0,j.forwardRef)(function(e,n){let{check:t}=e,l={...t.params,...t.view_options};return(0,i.jsx)(o.k,{direction:"column",height:"100%",children:(0,i.jsx)(R.tV,{children:(0,i.jsx)(i3,{viewOptions:l,interactive:!1,ref:n})})})});function i8(e){let{name:n,description:t,type:l,params:r,viewOptions:s}=e,o={name:n,description:t,type:l,params:r};s&&(o.view_options=s);let a=t9.ZP.stringify({checks:[o]});return(0,i.jsx)(tE.ML,{height:"300px",language:"yaml",theme:"vs",value:a,options:{readOnly:!0,fontSize:14,lineNumbers:"off",automaticLayout:!0,minimap:{enabled:!1},wordWrap:"on",wrappingIndent:"same",scrollBeyondLastLine:!1}})}function i7(){let e=(0,G.p)();return{markedAsApprovedToast:function(){e({title:"Marked as approved",position:"bottom-right",status:"success",containerStyle:{fontSize:"sm"},duration:2e3})}}}function le(){let e=(0,nZ._)(["\n ","
\n\n ","\n\n "]);return le=function(){return e},e}let ln=e=>{var n,t,r,a,d,f,g;let{checkId:v}=e,w=(0,b.NL)(),[,k]=(0,ew.TH)(),{successToast:C,failToast:_}=t_(),{markedAsApprovedToast:S}=i7(),[z,R]=(0,j.useState)(),[E,T]=(0,j.useState)(),[D,L]=(0,j.useState)(!1),{isOpen:I,onOpen:M,onClose:O}=(0,eb.q)(),A=()=>(0,i.jsx)($.Z,{bg:"blackAlpha.300",backdropFilter:"blur(10px) "}),[F,N]=(0,j.useState)((0,i.jsx)(A,{})),{isLoading:q,error:V,data:H}=(0,y.a)({queryKey:P.check(v),queryFn:async()=>nK(v),refetchOnMount:!0}),W=z||(null==H?void 0:null===(n=H.last_run)||void 0===n?void 0:n.run_id),{run:K,error:J}=t3(W),B=z?!K||"running"===K.status:(null==K?void 0:K.status)==="running",U=(null==H?void 0:H.type)?nO(null==H?void 0:H.type):void 0,Z=(null==H?void 0:H.is_preset)||!1,Q=(0,j.useRef)(null),{mutate:X}=(0,te.D)({mutationFn:e=>nJ(v,e),onSuccess:()=>{w.invalidateQueries({queryKey:P.check(v)}),w.invalidateQueries({queryKey:P.checks()})}}),{mutate:G}=(0,te.D)({mutationFn:()=>nB(v),onSuccess:()=>{w.invalidateQueries({queryKey:P.checks()}),k("/checks")}}),el=(0,j.useCallback)(async()=>{(null==H?void 0:H.type)&&R((await eu(v,{nowait:!0})).run_id)},[H,v,R]),es=(0,j.useCallback)(async()=>{if(L(!0),W)return await ed(W)},[W]),eo=async()=>{var e;if(!H)return;let n=(e=H,(0,tC.RI)(le(),"".concat(e.is_checked?"✅ ":"").concat(e.name),function(e){if("query"===e.type||"query_diff"===e.type){var n;return"".concat(tz(e),"\n\n").concat((0,tC.Pn)(tS(),null===(n=e.params)||void 0===n?void 0:n.sql_template))}return tz(e)}(e)));if(!navigator.clipboard){_("Failed to copy the check to clipboard",Error("Copy to clipboard is available only in secure contexts (HTTPS)"));return}try{await navigator.clipboard.writeText(n),C("Copied the check to the clipboard")}catch(e){_("Failed to copy the check to clipboard",e)}},ea=(0,j.useCallback)(()=>{let e=null==H?void 0:H.is_checked;X({is_checked:!e}),!0==!e&&S()},[null==H?void 0:H.is_checked,X,S]),[ec,eh]=(0,j.useState)(0),{ref:ex,onCopyToClipboard:em,onMouseEnter:ep,onMouseLeave:ef}=ia();if(q)return(0,i.jsx)(eZ.M,{h:"100%",children:"Loading"});if(V)return(0,i.jsxs)(eZ.M,{h:"100%",children:["Error: ",V.message]});let eg=(null==K?void 0:K.run_at)?(0,tO.Q)(new Date(K.run_at),{addSuffix:!0}):null;return(0,i.jsxs)(td,{minSize:100,sizes:[30,70],style:{height:"100%",width:"100%",maxHeight:"100%"},children:[(0,i.jsxs)(l.x,{style:{contain:"strict"},display:"flex",flexDirection:"column",children:[(0,i.jsxs)(o.k,{p:"0px 16px",alignItems:"center",h:"40px",children:[(0,i.jsx)(n7,{name:(null==H?void 0:H.name)||"",setName:e=>{X({name:e})}}),(0,i.jsx)(h.L,{}),Z&&(0,i.jsx)(nh.u,{label:"Preset Check defined in recce config",children:(0,i.jsxs)(nQ.Vp,{size:"sm",flex:"0 0 auto",children:[(0,i.jsx)(nQ.AD,{boxSize:"14px",as:n4.bX4}),"Preset"]})}),(0,i.jsxs)(nC.v,{children:[(0,i.jsx)(n_.j,{isRound:!0,as:nS.h,icon:(0,i.jsx)(s.J,{as:eY.D_A}),variant:"ghost",size:"sm"}),(0,i.jsxs)(nz.q,{children:[(0,i.jsx)(nE.s,{as:ei.x,fontSize:"10pt",icon:(0,i.jsx)(n6.ovA,{}),onClick:()=>{N((0,i.jsx)(A,{})),M()},children:"Get Preset Check Template"}),(0,i.jsx)(nE.s,{as:ei.x,fontSize:"10pt",icon:(0,i.jsx)(n0.T,{}),onClick:()=>eo(),children:"Copy Markdown"}),(0,i.jsx)(nX.R,{}),(0,i.jsx)(nE.s,{as:ei.x,fontSize:"10pt",icon:(0,i.jsx)(n1.p,{}),color:"red",onClick:()=>G(),children:"Delete"})]})]}),eg&&(0,i.jsx)(l.x,{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",fontSize:"10pt",children:eg}),(null==U?void 0:U.RunResultView)&&(0,i.jsx)(nh.u,{label:"Rerun",children:(0,i.jsx)(nS.h,{isRound:!0,isLoading:B,variant:"ghost","aria-label":"Rerun",icon:(0,i.jsx)(n5.n,{}),onClick:()=>el()})}),(0,i.jsx)(nh.u,{label:(null==H?void 0:H.is_checked)?"Mark as Pending":"Mark as Approved",placement:"bottom-end",children:(0,i.jsx)(er.z,{flex:"0 0 auto",size:"sm",colorScheme:(null==H?void 0:H.is_checked)?"green":"gray",variant:(null==H?void 0:H.is_checked)?"solid":"outline",leftIcon:(null==H?void 0:H.is_checked)?(0,i.jsx)(n2.r,{}):(0,i.jsx)(s.J,{as:eY.Rbx,color:"lightgray"}),onClick:()=>ea(),children:(null==H?void 0:H.is_checked)?"Approved":"Mark as Approved"})})]}),(0,i.jsx)(l.x,{flex:"1",p:"8px 16px",minHeight:"100px",children:(0,i.jsx)(tk,{value:null==H?void 0:H.description,onChange:e=>{X({description:e})}},null==H?void 0:H.check_id)})]}),(0,i.jsx)(l.x,{style:{contain:"strict"},children:(0,i.jsxs)(x.m,{height:"100%",display:"flex",flexDirection:"column",tabIndex:ec,onChange:eh,children:[(0,i.jsxs)(m.t,{height:"50px",children:[(0,i.jsx)(p.O,{fontSize:"10pt",children:"Result"}),((null==H?void 0:H.type)==="query"||(null==H?void 0:H.type)==="query_diff")&&(0,i.jsx)(p.O,{fontSize:"10pt",children:"Query"}),(0,i.jsx)(h.L,{}),(0,i.jsx)(u.U,{mr:"10px",children:(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(n0.T,{}),variant:"outline",isDisabled:"schema_diff"!==(g=null!==(f=null==H?void 0:H.type)&&void 0!==f?f:"")&&"lineage_diff"!==g&&(!(null==K?void 0:K.result)||!!(null==K?void 0:K.error))||0!==ec,onMouseEnter:ep,onMouseLeave:ef,size:"sm",onClick:()=>{if((null==H?void 0:H.type)==="lineage_diff"){var e;null===(e=Q.current)||void 0===e||e.copyToClipboard()}else em()},children:"Copy to Clipboard"})})]}),(0,i.jsxs)(nG.n,{height:"100%",flex:"1",style:{contain:"strict"},children:[(0,i.jsxs)(nY.x,{p:0,width:"100%",height:"100%",children:[(null==U?void 0:U.RunResultView)&&((null==H?void 0:H.last_run)||W?(0,i.jsx)(tM,{ref:ex,isRunning:B,isAborting:D,run:W?K:null==H?void 0:H.last_run,error:J,progress:E,RunResultView:U.RunResultView,viewOptions:null==H?void 0:H.view_options,onViewOptionsChanged:e=>{X({view_options:e})},onCancel:es,onExecuteRun:el}):(0,i.jsx)(eZ.M,{bg:"rgb(249,249,249)",height:"100%",children:(0,i.jsx)(er.z,{onClick:el,colorScheme:"blue",size:"sm",children:"Run Query"})})),H&&"schema_diff"===H.type&&(0,i.jsx)(tb,{check:H,ref:ex}),H&&"lineage_diff"===H.type&&(0,i.jsx)(i9,{check:H,ref:Q})]}),((null==H?void 0:H.type)==="query"||(null==H?void 0:H.type)==="query_diff"||(null==H?void 0:H.type)==="query_base")&&(0,i.jsx)(nY.x,{p:0,height:"100%",width:"100%",children:(null===(t=H.params)||void 0===t?void 0:t.base_sql_template)?(0,i.jsx)(tD,{value:(null==H?void 0:null===(r=H.params)||void 0===r?void 0:r.sql_template)||"",baseValue:(null==H?void 0:null===(a=H.params)||void 0===a?void 0:a.base_sql_template)||"",options:{readOnly:!0}}):(0,i.jsx)(tT,{value:(null==H?void 0:null===(d=H.params)||void 0===d?void 0:d.sql_template)||"",options:{readOnly:!0}})})]})]})}),(0,i.jsxs)(Y.u_,{isOpen:I,onClose:O,isCentered:!0,size:"6xl",children:[F,(0,i.jsxs)(ee.h,{overflowY:"auto",height:"40%",width:"60%",children:[(0,i.jsx)(en.x,{children:"Preset Check Template"}),(0,i.jsx)(ej.o,{}),(0,i.jsxs)(et.f,{children:[(0,i.jsx)(c.X,{size:"sm",fontWeight:"bold",children:(0,i.jsx)(n$.y,{query:"recce.yml",styles:{px:"1",py:"0",bg:"red.100"},children:"Please copy the following template and paste it into the recce.yml file."})}),(0,i.jsx)("br",{}),(0,i.jsx)(i8,{name:(null==H?void 0:H.name)||"",description:(null==H?void 0:H.description)||"",type:(null==H?void 0:H.type)||"",params:null==H?void 0:H.params,viewOptions:null==H?void 0:H.view_options})]})]})]})]})};var lt=t(34872);let li=e=>{var n;let{check:t,selected:r,onSelect:a,onMarkAsApproved:c}=e,d=(0,b.NL)(),u=t.check_id,{mutate:h}=(0,te.D)({mutationFn:e=>nJ(u,e),onSuccess:()=>{d.invalidateQueries({queryKey:P.check(u)}),d.invalidateQueries({queryKey:P.checks()})}}),x=(null===(n=nO(t.type))||void 0===n?void 0:n.icon)||ek.WzH;return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(o.k,{width:"100%",p:"10px 20px",cursor:"pointer",_hover:{bg:"Cornsilk"},bg:r?"Floralwhite":"inherit",borderBlockEndWidth:"1px",borderLeftWidth:"3px",borderLeftColor:r?"orange":"transparent",onClick:()=>a(t.check_id),alignItems:"center",gap:"5px",children:[(0,i.jsx)(s.J,{as:x}),(0,i.jsx)(l.x,{flex:"1",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",children:t.name}),(0,i.jsx)(nh.u,{label:"Click to mark as approved",placement:"top",hasArrow:!0,children:(0,i.jsx)(o.k,{children:(0,i.jsx)(nn.X,{isChecked:t.is_checked,variant:"circular",colorScheme:"green",size:"xs",onChange:e=>{let n=e.target.checked;!1===n?h({is_checked:n}):c()}})})})]})})},ll=e=>{let{checks:n,selectedItem:t,onCheckSelected:r,onChecksReordered:s}=e,[a,c]=(0,j.useState)(!1),d=(0,b.NL)(),{mutate:u}=(0,te.D)({mutationFn:e=>nJ(e,{is_checked:!0}),onSuccess:(e,n)=>{d.invalidateQueries({queryKey:P.check(n)}),d.invalidateQueries({queryKey:P.checks()})}}),{isOpen:h,onOpen:x,onClose:m}=(0,eb.q)(),{markedAsApprovedToast:p}=i7(),f=()=>{"true"===localStorage.getItem("bypassMarkAsApprovedWarning")?(u(t),p()):x()};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(lt.Z5,{onDragEnd:e=>{e.destination&&s(e.source.index,e.destination.index)},children:(0,i.jsx)(lt.bK,{droppableId:"checklist",children:e=>(0,i.jsxs)(ne.g,{...e.droppableProps,ref:e.innerRef,w:"full",spacing:"0",flex:"1",overflow:"auto",children:[n.map((e,n)=>(0,i.jsx)(lt._l,{draggableId:e.check_id,index:n,children:(n,l)=>{if(l.isDragging){let e=n.draggableProps,t={x:0,y:80},i=e.style.left-t.x,l=e.style.top-t.y;e.style.left=i,e.style.top=l}return(0,i.jsx)(o.k,{ref:n.innerRef,...n.draggableProps,...n.dragHandleProps,w:"full",children:(0,i.jsx)(li,{check:e,selected:e.check_id===t,onSelect:r,onMarkAsApproved:f},e.check_id)})}},e.check_id)),e.placeholder]})})}),(0,i.jsxs)(Y.u_,{isOpen:h,onClose:m,isCentered:!0,children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{width:"400px",children:[(0,i.jsx)(en.x,{children:"Mark as Approved?"}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(nx.i,{}),(0,i.jsxs)(l.x,{p:"16px",fontSize:"sm",gap:"16px",children:[(0,i.jsx)("p",{children:"Please ensure you have reviewed the contents of this check before marking it as approved."}),(0,i.jsx)(nn.X,{isChecked:a,onChange:e=>c(e.target.checked),fontWeight:"bold",size:"sm",pt:"8px",children:"Don't show this again"})]}),(0,i.jsx)(nx.i,{}),(0,i.jsxs)(el.m,{children:[(0,i.jsx)(er.z,{variant:"outline",size:"xs",mr:2,onClick:m,children:"Cancel"}),(0,i.jsx)(er.z,{colorScheme:"blue",size:"xs",onClick:()=>{u(t),!0===a&&localStorage.setItem("bypassMarkAsApprovedWarning","true"),p(),m()},children:"Mark as approved"})]})]})]})]})};async function lr(e){return(await U.post("/api/save-as",e)).data}async function ls(e){return(await U.post("/api/rename",e)).data}async function lo(){return(await U.post("/api/export")).data}async function la(e,n){let t=new FormData;return t.append("file",e),t.append("checks_only",(!!n).toString()),(await U.post("/api/import",t)).data}async function lc(){return 208===(await U.get("/api/sync")).status}async function ld(e){try{let n=await U.post("/api/sync",e);if(202===n.status)return{status:"accepted"};if(208===n.status)return{status:"syncing"}}catch(e){if((0,iX.IZ)(e)&&e.response&&409===e.response.status)return{status:"conflict"}}throw Error("Failed to sync state")}let lu=e=>(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,i.jsx)("g",{"clip-path":"url(#clip0_1479_25070)",children:(0,i.jsx)("path",{d:"M15.625 0.25H14.759C14.5484 0.25 14.3791 0.423375 14.3841 0.633937L14.4575 3.71441C13.0691 1.62634 10.6955 0.25 8 0.25C4.21291 0.25 1.06041 2.96638 0.38425 6.557C0.340875 6.78728 0.518875 7 0.753219 7H1.64622C1.82353 7 1.97566 6.87556 2.013 6.70222C2.60753 3.9415 5.05991 1.875 8 1.875C10.4858 1.875 12.6232 3.35256 13.5836 5.47819L9.63394 5.38416C9.42341 5.37916 9.25 5.54844 9.25 5.75906V6.625C9.25 6.83209 9.41791 7 9.625 7H15.625C15.8321 7 16 6.83209 16 6.625V0.625C16 0.417906 15.8321 0.25 15.625 0.25ZM15.2468 9H14.3538C14.1765 9 14.0243 9.12444 13.987 9.29778C13.3925 12.0585 10.9401 14.125 8 14.125C5.51419 14.125 3.37681 12.6474 2.41637 10.5218L6.36606 10.6158C6.57659 10.6208 6.75 10.4516 6.75 10.2409V9.375C6.75 9.16791 6.58209 9 6.375 9H0.375C0.167906 9 0 9.16791 0 9.375V15.375C0 15.5821 0.167906 15.75 0.375 15.75H1.24097C1.45156 15.75 1.62088 15.5766 1.61588 15.3661L1.54253 12.2856C2.93087 14.3737 5.3045 15.75 8 15.75C11.7871 15.75 14.9396 13.0336 15.6158 9.443C15.6591 9.21272 15.4811 9 15.2468 9Z",fill:"currentColor"})}),(0,i.jsx)("defs",{children:(0,i.jsx)("clipPath",{id:"clip0_1479_25070",children:(0,i.jsx)("rect",{width:"16",height:"16",fill:"white"})})})]}),lh=e=>(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,i.jsx)("g",{"clip-path":"url(#clip0_1479_25102)",children:(0,i.jsx)("path",{d:"M-1.88399 8.72062L0.358816 6.46094C0.594752 6.22344 1.00006 6.39031 1.00006 6.725V8.2525H4.00005V4.12438C4.00005 3.7275 4.16161 3.34313 4.44286 3.06219L7.06441 0.440625C7.34566 0.159375 7.72691 0 8.12347 0H14.5003C15.3281 0.003125 16 0.675 16 1.50281V14.5003C16 15.3281 15.3281 16 14.5003 16H5.50223C4.67411 16 4.00005 15.3281 4.00005 14.5003V11.2522H5.50005V14.5003H14.5003V1.50281H9.50128V4.75219C9.50128 5.16781 9.1669 5.50187 8.75128 5.50187H5.50005V8.25219H10.625C10.8322 8.25219 11 8.42 11 8.62719V9.37719C11 9.58438 10.8322 9.75219 10.625 9.75219H1.00006V11.2797C1.00006 11.6144 0.594752 11.7813 0.358816 11.5438L-1.88399 9.28406C-2.03867 9.12813 -2.03867 8.87656 -1.88399 8.72062ZM8.0016 4.00219V1.62469L5.62379 4.00219H8.0016Z",fill:"currentColor"})}),(0,i.jsx)("g",{"clip-path":"url(#clip1_1479_25102)",children:(0,i.jsx)("path",{d:"M0.103056 8.72062L2.09667 6.46094C2.30639 6.22344 2.66667 6.39031 2.66667 6.725V8.2525H5.33333V4.12438C5.33333 3.7275 5.47694 3.34313 5.72694 3.06219L8.05722 0.440625C8.30722 0.159375 8.64611 0 8.99861 0H14.6669C15.4028 0.003125 16 0.675 16 1.50281V14.5003C16 15.3281 15.4028 16 14.6669 16H6.66861C5.9325 16 5.33333 15.3281 5.33333 14.5003V11.2522H6.66667V14.5003H14.6669V1.50281H10.2233V4.75219C10.2233 5.16781 9.92611 5.50187 9.55667 5.50187H6.66667V8.25219H11.2222C11.4064 8.25219 11.5556 8.42 11.5556 8.62719V9.37719C11.5556 9.58438 11.4064 9.75219 11.2222 9.75219H2.66667V11.2797C2.66667 11.6144 2.30639 11.7813 2.09667 11.5438L0.103056 9.28406C-0.0344448 9.12813 -0.0344448 8.87656 0.103056 8.72062ZM8.89028 4.00219V1.62469L6.77666 4.00219H8.89028Z",fill:"currentColor"})}),(0,i.jsxs)("defs",{children:[(0,i.jsx)("clipPath",{id:"clip0_1479_25102",children:(0,i.jsx)("rect",{width:"13",height:"16",fill:"white",transform:"matrix(-1 0 0 1 16 0)"})}),(0,i.jsx)("clipPath",{id:"clip1_1479_25102",children:(0,i.jsx)("rect",{width:"3",height:"16",fill:"white"})})]})]}),lx=e=>(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,i.jsx)("g",{"clip-path":"url(#clip0_1426_8619)",children:(0,i.jsx)("path",{d:"M15.5572 3.06188L12.9356 0.440625C12.6544 0.159375 12.2731 0 11.8766 0H5.49969C4.67188 0.003125 4 0.675 4 1.50281V8.25219H0.375C0.167812 8.25219 0 8.42 0 8.62719V9.37719C0 9.58438 0.167812 9.75219 0.375 9.75219H9V11.2797C9 11.6144 9.40531 11.7812 9.64125 11.5437L11.8841 9.28406C12.0388 9.12813 12.0388 8.87656 11.8841 8.72062L9.64125 6.46094C9.40531 6.22344 9 6.39031 9 6.725V8.2525H5.49969V1.50281H10.4987V4.75219C10.4987 5.16781 10.8331 5.50187 11.2487 5.50187H14.5V14.5003H5.49969V11.2522H4V14.5003C4 15.3281 4.67188 16 5.49969 16H14.4978C15.3259 16 16 15.3281 16 14.5003V4.12406C16 3.7275 15.8384 3.34313 15.5572 3.06188ZM11.9984 4.00219V1.62469L14.3763 4.00219H11.9984Z",fill:"black"})}),(0,i.jsx)("defs",{children:(0,i.jsx)("clipPath",{id:"clip0_1426_8619",children:(0,i.jsx)("rect",{width:"16",height:"16",fill:"white"})})})]}),lm=e=>(0,i.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,i.jsx)("path",{d:"M14.5607 4.06066L11.9393 1.43934C11.658 1.15804 11.2765 1 10.8787 1H2.5C1.67156 1 1 1.67156 1 2.5V13.5C1 14.3284 1.67156 15 2.5 15H13.5C14.3284 15 15 14.3284 15 13.5V5.12131C15 4.72349 14.842 4.34196 14.5607 4.06066ZM9.5 2.5V5H5.5V2.5H9.5ZM13.3125 13.5H2.6875C2.63777 13.5 2.59008 13.4802 2.55492 13.4451C2.51975 13.4099 2.5 13.3622 2.5 13.3125V2.6875C2.5 2.63777 2.51975 2.59008 2.55492 2.55492C2.59008 2.51975 2.63777 2.5 2.6875 2.5H4V5.75C4 6.16422 4.33578 6.5 4.75 6.5H10.25C10.6642 6.5 11 6.16422 11 5.75V2.62131L13.4451 5.06641C13.4625 5.08382 13.4763 5.10449 13.4857 5.12724C13.4952 5.14999 13.5 5.17438 13.5 5.199V13.3125C13.5 13.3622 13.4802 13.4099 13.4451 13.4451C13.4099 13.4802 13.3622 13.5 13.3125 13.5ZM8 7.25C6.48366 7.25 5.25 8.48366 5.25 10C5.25 11.5163 6.48366 12.75 8 12.75C9.51634 12.75 10.75 11.5163 10.75 10C10.75 8.48366 9.51634 7.25 8 7.25ZM8 11.25C7.31075 11.25 6.75 10.6892 6.75 10C6.75 9.31075 7.31075 8.75 8 8.75C8.68925 8.75 9.25 9.31075 9.25 10C9.25 10.6892 8.68925 11.25 8 11.25Z",fill:"currentColor"})}),lp=e=>(0,i.jsx)("svg",{width:"17",height:"16",viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,i.jsx)("path",{d:"M15.9143 1.75812L14.7422 0.585938C14.3515 0.195312 13.8397 0 13.3278 0C12.8159 0 12.304 0.195312 11.9137 0.585625L9.58593 2.91344L8.5 3.99938L0.901592 11.5975L0.504719 15.1669C0.454719 15.6163 0.80878 16 1.24847 16C1.27628 16 1.3044 15.9984 1.33253 15.9953L4.89939 15.6012L12.5006 8L13.5862 6.91437L15.914 4.58656C16.6953 3.80531 16.6953 2.53906 15.9143 1.75812ZM4.21095 14.1684L2.09909 14.4016L2.3344 12.2863L9.56062 5.06L10.53 4.09062L12.4094 5.97L11.44 6.93937L4.21095 14.1684ZM14.8534 3.52562L13.4697 4.90938L11.5906 3.03L12.9744 1.64625C13.1019 1.51875 13.2506 1.49969 13.3278 1.49969C13.405 1.49969 13.554 1.51875 13.6812 1.64625L14.8534 2.81844C15.0484 3.01375 15.0484 3.33094 14.8534 3.52562Z",fill:"currentColor"})}),lf=e=>(0,i.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,i.jsx)("path",{d:"M7.26326 6.5462H8.71794V12.3642H7.26326V6.5462ZM7.9906 3.1102C7.43278 3.1102 6.97888 3.5641 6.97888 4.12192C6.97888 4.67974 7.43278 5.13364 7.9906 5.13364C8.54842 5.13364 9.00232 4.67974 9.00232 4.12192C9.00232 3.5641 8.54842 3.1102 7.9906 3.1102ZM16 8C16 12.411 12.411 16 8 16C3.589 16 0 12.411 0 8C0 3.589 3.589 0 8 0C12.411 0 16 3.589 16 8ZM14.5453 8C14.5453 4.3906 11.6093 1.4546 7.99992 1.4546C4.39052 1.4546 1.45452 4.3914 1.45452 8.0006C1.45452 11.6098 4.39052 14.546 7.99992 14.546C11.6093 14.546 14.5453 11.6092 14.5453 8.0006V8Z",fill:"currentColor"})});function lg(e){let{checksOnly:n=!0}=e,t=(0,G.p)(),l=(0,b.NL)(),r=(0,j.useRef)(null),a=(0,j.useRef)(null),[c,d]=(0,j.useState)(null),{isOpen:u,onOpen:h,onClose:x}=(0,eb.q)(),[m,p]=(0,ew.TH)(),[,f]=ev(),g=(0,j.useCallback)(async()=>{if(c){try{let{runs:e,checks:i}=await la(c,n);f(),await l.invalidateQueries({queryKey:P.checks()}),await l.invalidateQueries({queryKey:P.runs()}),m.includes("/checks")&&p("/checks");let r=n?"".concat(i," checks imported successfully"):"".concat(e," runs and ").concat(i," checks imported successfully");t({description:r,status:"info",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}catch(e){console.error("Import failed",e),t({title:"Import failed",description:"".concat(e),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}x()}},[l,c,t,x,m,p,f,n]),v=n?"checks":"runs and checks",{isDemoSite:y}=eg();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(nh.u,{label:"Import Checklist from State File"+(y?" (Disabled in the demo site)":""),children:(0,i.jsx)(nS.h,{pt:"6px",variant:"unstyled","aria-label":"Import state",onClick:()=>{r.current&&r.current.click()},icon:(0,i.jsx)(s.J,{as:lx}),isDisabled:y})}),(0,i.jsx)("input",{type:"file",style:{display:"none"},ref:r,onChange:e=>{var n;(null===(n=e.target.files)||void 0===n?void 0:n.length)===1&&(d(e.target.files[0]),h()),r.current&&(r.current.value="")}}),(0,i.jsx)(i$.aR,{isOpen:u,leastDestructiveRef:a,onClose:x,size:"xl",children:(0,i.jsx)($.Z,{children:(0,i.jsxs)(i$._T,{children:[(0,i.jsx)(en.x,{fontSize:"lg",fontWeight:"bold",children:"Import state"}),(0,i.jsx)(et.f,{children:(0,i.jsxs)(o.k,{px:"5px",gap:"5px",rounded:"md",direction:"column",children:[(0,i.jsxs)(o.k,{alignItems:"center",gap:"5px",children:[(0,i.jsx)(tH.s,{color:"red.600"}),(0,i.jsx)(ei.x,{as:"span",fontWeight:"500",color:"red.600",children:"Caution!"})]}),(0,i.jsx)(o.k,{children:(0,i.jsxs)(ei.x,{children:["The current ",v," will be"," ",(0,i.jsx)(ei.x,{as:"span",fontWeight:"600",children:"merged"})," ","with the imported state"]})})]})}),(0,i.jsxs)(el.m,{children:[(0,i.jsx)(er.z,{ref:a,onClick:x,children:"Cancel"}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:g,ml:"5px",children:"Import"})]})]})})})]})}let lv=()=>{let[,e]=(0,ew.TH)(),[,n]=(0,ew.yj)("/checks/:checkId"),t=(0,b.NL)(),{successToast:r,failToast:s}=t_(),a=null==n?void 0:n.checkId,{isLoading:c,error:d,data:u,status:h}=(0,y.a)({queryKey:P.checks(),queryFn:nW,refetchOnMount:!0}),x=(0,j.useCallback)(n=>{e("/checks/".concat(n))},[e]),[m,p]=(0,j.useState)(u||[]),{mutate:f}=(0,te.D)({mutationFn:e=>nU(e),onSuccess:()=>{t.invalidateQueries({queryKey:P.checks()})}}),g=(0,j.useCallback)((e,n)=>{let t=[...m],[i]=t.splice(e,1);t.splice(n,0,i),f({source:e,destination:n}),p(t)},[m,p,f]);return((0,j.useCallback)(async()=>{let e=await nH();t.invalidateQueries({queryKey:P.checks()}),x(e.check_id)},[t,x]),(0,j.useEffect)(()=>{"success"===h&&(!a&&u.length>0&&e("/checks/".concat(u[0].check_id)),p(u))},[h,a,u,p,e]),c)?(0,i.jsx)(i.Fragment,{}):d?(0,i.jsxs)(i.Fragment,{children:["Error: ",d.message]}):(null==u?void 0:u.length)?(0,i.jsxs)(tc,{style:{height:"100%"},minSize:50,sizes:[20,80],children:[(0,i.jsx)(l.x,{borderRight:"lightgray solid 1px",height:"100%",style:{contain:"size"},children:(0,i.jsxs)(ne.g,{spacing:0,h:"100%",style:{contain:"strict"},alignItems:"stretch",children:[(0,i.jsx)(o.k,{justifyContent:"right",padding:"0px 10px",children:(0,i.jsx)(lg,{checksOnly:!0})}),(0,i.jsx)(nx.i,{}),(0,i.jsx)(ll,{checks:m,selectedItem:a,onCheckSelected:x,onChecksReordered:g})]})}),(0,i.jsx)(l.x,{height:"100%",children:(0,i.jsx)(ew.rs,{children:(0,i.jsx)(ew.AW,{path:"/checks/:checkId",children:e=>(0,i.jsx)(ln,{checkId:e.checkId},e.checkId)})})})]}):(0,i.jsx)(eZ.M,{h:"100%",children:(0,i.jsx)(l.x,{children:"No checks"})})};var lj=t(21297);let ly=()=>{let{isHistoryOpen:e,showHistory:n,closeHistory:t}=nq();return(0,i.jsxs)(l.x,{children:[(0,i.jsx)(l.x,{fontSize:"8pt",children:"History"}),(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(s.J,{as:eY.M1Q}),size:"xs",variant:"outline",onClick:()=>{e?(iT({name:"hide"}),t()):(iT({name:"show"}),n())},children:e?"Hide":"Show"})]})},lb=()=>{let{isCustomQueries:e,setCustomQueries:n,sqlQuery:t,setBaseSqlQuery:r}=_();return(0,i.jsxs)(l.x,{children:[(0,i.jsxs)(l.x,{fontSize:"8pt",children:["Custom Queries ","",(0,i.jsx)(nh.u,{label:"Custom queries allow you to use two SQL queries to compare results between current and base environments.",children:(0,i.jsx)(tH.s,{color:"gray.600",boxSize:"3"})})]}),(0,i.jsx)(lj.r,{size:"sm",isChecked:e,onChange:()=>{!1===e&&r&&r(t),n(!e)}})]})},lw=()=>{let{sqlQuery:e,baseSqlQuery:n,setSqlQuery:t,setBaseSqlQuery:r,primaryKeys:s,setPrimaryKeys:a,isCustomQueries:c}=_(),{envInfo:d}=eg(),u=e;(null==d?void 0:d.adapterType)==="sqlmesh"&&e===w&&(u="select * from db.mymodel");let{showRunId:x}=nq(),m=async e=>{let t="query_base"===e?n||"":u,i=function(e){switch(e){case"query":return ix;case"query_base":return im;case"query_diff":return ip;default:throw Error("Unknown query type: ".concat(e))}}(e),l={sql_template:t};"query_diff"===e&&(l.primary_keys=s,c&&(l.base_sql_template=n));let{run_id:r}=await i(l,{nowait:!0});return x(r),await ec(r)},{mutate:p,isPending:f}=(0,te.D)({mutationFn:m});return(0,i.jsxs)(o.k,{direction:"column",height:"100%",children:[(0,i.jsxs)(o.k,{justifyContent:"right",alignItems:"center",padding:"4pt 8pt",gap:"5px",height:"54px",borderBottom:"1px solid lightgray",flex:"0 0 54px",children:[(0,i.jsx)(ly,{}),(0,i.jsx)(lb,{}),(0,i.jsx)(h.L,{}),(0,i.jsx)(ib,{defaultPrimaryKeys:s,onPrimaryKeysChange:a}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>p("query_diff"),isDisabled:f,size:"xs",fontSize:"14px",marginTop:"16px",children:"Run Diff"})]}),(0,i.jsx)(l.x,{width:"100%",flex:"1",children:c?(0,i.jsx)(tD,{value:u,baseValue:n,onChange:t,onChangeBase:r,onRun:()=>p("query"),onRunBase:()=>p("query_base"),onRunDiff:()=>p("query_diff")}):(0,i.jsx)(tT,{value:u,onChange:t,onRun:()=>p("query"),onRunDiff:()=>p("query_diff")})})]})};var lk=t(26143);let lC=e=>(0,lk.c4)("#!"+e),l_=()=>[(0,lk.LD)(()=>window.location.hash.replace(/^#!/,"")||"/",()=>"/ssr"),lC];var lS=t(35653),lz=t(38222);let lR=e=>{var n;let{runId:t}=e,{isPending:l,error:r,data:s}=(0,y.a)({queryKey:P.run(t),queryFn:async()=>ec(t)}),o=(null==s?void 0:s.type)?null===(n=nO(s.type))||void 0===n?void 0:n.RunResultView:void 0;return(0,i.jsx)(tM,{isPending:l,error:r,run:s,RunResultView:o})},lE=e=>{let{error:n,resetError:t}=e;return(0,i.jsx)(eZ.M,{height:"100%",backgroundColor:"gray.50",children:(0,i.jsxs)(o.k,{p:4,direction:"column",justifyContent:"flex-start",backgroundColor:"white",border:"solid lightgray 1px",minHeight:"200px",children:[(0,i.jsx)(c.X,{width:"800px",size:"md",children:"You have encountered an error"}),(0,i.jsx)(l.x,{flex:"1",fontSize:"10pt",children:n.toString()}),(0,i.jsx)(er.z,{justifySelf:"center",alignSelf:"center",mt:"20px",colorScheme:"blue",size:"sm",onClick:()=>{t()},children:"Reset"})]})})},lT=e=>{let{children:n}=e;return(0,i.jsx)(tI.SV,{fallback:lE,children:n})};function lD(){let e=(0,G.p)(),n=async()=>{try{let e=await lo(),n=JSON.stringify(e,null,2),t=new Blob([n],{type:"application/json"}),i=new Date,l="recce-state-".concat((0,ii.WU)(i,"yyyy-MM-dd-HH-mm-ss"),".json");ir()(t,l)}catch(n){console.error("Export failed",n),e({title:"Export failed",description:"".concat(n),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}};return(0,i.jsx)(nh.u,{label:"Export",children:(0,i.jsx)(nS.h,{size:"sm",variant:"unstyled","aria-label":"Export state",onClick:n,icon:(0,i.jsx)(s.J,{as:lh,verticalAlign:"middle",boxSize:"16px"})})})}t(58923);var lL=t(71651),lI=t(87202),lM=t(9783),lO=t(34889),lA=t(33246),lF=t(67192),lN=t(37854),lq=t(31617);function lV(e){let n=(0,lq.D)(e);return(0,ii.WU)(n,"yyyy-MM-dd'T'HH:mm:ss")}function lH(e){return Object.values(e).every(e=>null===e)?[(0,i.jsx)(o.k,{ml:"10px",children:"No information"},"no info")]:Object.entries(e).filter(e=>{let[n,t]=e;return"url"!==n&&null!=t}).map(e=>{let[n,t]=e;return(0,i.jsxs)(tu.HC,{ml:"10px",children:[n,": ",t]},n)})}function lP(){var e,n,t,l,a,d;let{envInfo:u,reviewMode:h,lineageGraph:x}=eg(),{isOpen:m,onOpen:p,onClose:f}=(0,eb.q)(),g=null==u?void 0:u.git,v=null==u?void 0:u.pullRequest,j={...g,...v},y=null==u?void 0:null===(e=u.dbt)||void 0===e?void 0:e.base,b=null==u?void 0:null===(n=u.dbt)||void 0===n?void 0:n.current,w=(null==y?void 0:y.generated_at)?lV(null==y?void 0:y.generated_at):"",k=(null==b?void 0:b.generated_at)?lV(null==b?void 0:b.generated_at):"",C=new Set,_=new Set;if(null==x?void 0:x.nodes)for(let e of Object.values(null==x?void 0:x.nodes))(null===(a=e.data.base)||void 0===a?void 0:a.schema)&&C.add(e.data.base.schema),(null===(d=e.data.current)||void 0===d?void 0:d.schema)&&_.add(e.data.current.schema);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(nh.u,{label:"Environment Info",placement:"bottom-end",children:(0,i.jsx)(nS.h,{size:"sm",variant:"unstyled","aria-label":"Export state",onClick:p,icon:(0,i.jsx)(s.J,{verticalAlign:"middle",as:lf,boxSize:"16px"})})}),(0,i.jsxs)(Y.u_,{isOpen:m,onClose:f,size:"3xl",children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{children:[(0,i.jsx)(en.x,{children:"Environment Information"}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(et.f,{children:(0,i.jsxs)(o.k,{direction:"column",gap:"5px",children:[h?(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(o.k,{justifyContent:"left",gap:"5px",direction:"column",children:[(0,i.jsx)(c.X,{size:"sm",children:"Review Information"}),(0,i.jsxs)(tu.QI,{spacing:1,children:[(null==j?void 0:j.url)&&(0,i.jsxs)(tu.HC,{ml:"10px",children:["url:"," ",(0,i.jsx)(r.r,{href:j.url,color:"blue.500",isExternal:!0,children:j.url})]}),j&&lH(j)]})]})}):(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(o.k,{justifyContent:"left",gap:"5px",direction:"column",children:[(0,i.jsx)(c.X,{size:"sm",children:"Dev Information"}),(0,i.jsx)(tu.QI,{spacing:1,children:g&&lH(g)})]})}),(0,i.jsx)(nx.i,{}),(null==u?void 0:u.adapterType)==="dbt"&&(0,i.jsxs)(o.k,{justifyContent:"left",gap:"5px",direction:"column",children:[(0,i.jsx)(c.X,{size:"sm",children:"DBT"}),(0,i.jsx)(lL.x,{children:(0,i.jsxs)(lI.i,{variant:"simple",children:[(0,i.jsx)(lM.h,{children:(0,i.jsxs)(lO.Tr,{children:[(0,i.jsx)(lA.Th,{}),(0,i.jsx)(lA.Th,{children:"base"}),(0,i.jsx)(lA.Th,{children:"current"})]})}),(0,i.jsxs)(lF.p,{children:[(0,i.jsxs)(lO.Tr,{children:[(0,i.jsx)(lN.Td,{children:"schema"}),(0,i.jsx)(lN.Td,{children:JSON.stringify(Array.from(C))}),(0,i.jsx)(lN.Td,{children:JSON.stringify(Array.from(_))})]}),(0,i.jsxs)(lO.Tr,{children:[(0,i.jsx)(lN.Td,{children:"version"}),(0,i.jsx)(lN.Td,{children:null==y?void 0:y.dbt_version}),(0,i.jsx)(lN.Td,{children:null==b?void 0:b.dbt_version})]}),(0,i.jsxs)(lO.Tr,{children:[(0,i.jsx)(lN.Td,{children:"timestamp"}),(0,i.jsx)(lN.Td,{children:w}),(0,i.jsx)(lN.Td,{children:k})]})]})]})})]}),(null==u?void 0:u.adapterType)==="sqlmesh"&&(0,i.jsxs)(o.k,{justifyContent:"left",gap:"5px",direction:"column",children:[(0,i.jsx)(c.X,{size:"sm",children:"SQLMesh"}),(0,i.jsx)(lL.x,{children:(0,i.jsxs)(lI.i,{variant:"simple",children:[(0,i.jsx)(lM.h,{children:(0,i.jsxs)(lO.Tr,{children:[(0,i.jsx)(lA.Th,{}),(0,i.jsx)(lA.Th,{children:"base"}),(0,i.jsx)(lA.Th,{children:"current"})]})}),(0,i.jsx)(lF.p,{children:(0,i.jsxs)(lO.Tr,{children:[(0,i.jsx)(lN.Td,{children:"Environment"}),(0,i.jsx)(lN.Td,{children:null==u?void 0:null===(t=u.sqlmesh)||void 0===t?void 0:t.base_env}),(0,i.jsx)(lN.Td,{children:null==u?void 0:null===(l=u.sqlmesh)||void 0===l?void 0:l.current_env})]})})]})})]})]})}),(0,i.jsx)(el.m,{children:(0,i.jsx)(er.z,{colorScheme:"blue",mr:3,onClick:f,children:"Close"})})]})]})]})}function lW(){return(0,i.jsx)(R.tV,{children:(0,i.jsx)(i3,{interactive:!0})})}async function lK(){return(await U.get("/api/flag")).data}async function lJ(){try{await U.post("/api/onboarding/completed")}catch(e){}}var lB=()=>{let[e,n]=(0,j.useState)(!1);(0,j.useEffect)(()=>{lK().then(e=>{let t=e.show_onboarding_guide;!localStorage.getItem("hasVisited")&&t&&(n(!0),localStorage.setItem("hasVisited","true"))})},[]);let t=()=>{n(!1),lJ()};return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(Y.u_,{isOpen:e,onClose:t,scrollBehavior:"inside",children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{maxW:"80vw",h:"80vh",children:[(0,i.jsx)(en.x,{children:"Welcome to Recce: 3 Steps to Begin"}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(et.f,{children:(0,i.jsxs)(tR.K,{spacing:4,children:[(0,i.jsxs)(tu.aV,{spacing:2,children:[(0,i.jsx)(tu.HC,{children:"Step 1: Click the model you want to check"}),(0,i.jsx)(tu.HC,{children:'Step 2: Click "Explore Change"'}),(0,i.jsx)(tu.HC,{children:'Step 3: Click "Add to Checklist"'})]}),(0,i.jsx)(nx.i,{}),(0,i.jsx)(a.E,{src:"https://datarecce.io/assets/images/onboarding/material.svg",alt:"placeholder"})]})}),(0,i.jsx)(el.m,{children:(0,i.jsx)(er.z,{colorScheme:"blue",onClick:t,children:"Got it!"})})]})]})})},lU=t(39502);t(28269);let lZ=e=>{var n;let{run:t,isSelected:r,onSelectRun:a,onAddToChecklist:c,onGoToCheck:d}=e,{data:u}=(0,y.a)({queryKey:P.run(t.run_id),queryFn:async()=>await ec(t.run_id),enabled:(null==t?void 0:t.status)==="running",retry:!1}),h=(null===(n=nO(t.type))||void 0===n?void 0:n.icon)||ek.WzH,x=t.check_id;return(0,i.jsxs)(o.k,{minWidth:"200px",direction:"column",width:"100%",p:"5px 20px",cursor:"pointer",borderBottom:"solid 1px lightgray",borderLeft:"4px",borderLeftColor:r?"orange.400":"transparent",backgroundColor:r?"orange.50":"transparent",onClick:()=>{a(t.run_id)},_hover:{bg:r?"orange.50":"gray.200"},children:[(0,i.jsxs)(o.k,{onClick:()=>{},alignItems:"center",gap:"12px",children:[(0,i.jsx)(s.J,{as:h}),(0,i.jsx)(l.x,{flex:"1",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",color:t.name?"inherit":"gray.500",fontSize:"11pt",fontWeight:"500",children:t.name||""}),x?(0,i.jsx)(nh.u,{label:"Go to Check","aria-label":"Go to Check",children:(0,i.jsx)(ei.x,{onClick:e=>{e.preventDefault(),e.stopPropagation(),d(x)},children:(0,i.jsx)(s.J,{color:"green",as:th.FJM})})}):(0,i.jsx)(nh.u,{label:"Add to Checklist","aria-label":"Add to Checklist",children:(0,i.jsx)(ei.x,{onClick:e=>{e.preventDefault(),e.stopPropagation(),iT({name:"add_to_checklist"}),c(t.run_id)},children:(0,i.jsx)(s.J,{as:th.wO})})})]}),(0,i.jsx)(o.k,{justifyContent:"start",fontSize:"11pt",color:"gray.500",gap:"3px",alignItems:"center",children:(0,i.jsx)(ic,{run:u||t})})]})},lQ=e=>{let{runAt:n}=e,t=n?function(e){let n=new Date,t=new Date;return(t.setDate(n.getDate()-1),null==e)?null:n.toDateString()===e.toDateString()?"Today":t.toDateString()===e.toDateString()?"Yesterday":(0,ii.WU)(e,"MMM d")}(new Date(n)):null;return(0,i.jsx)(o.k,{minWidth:"200px",width:"100%",p:"5px 20px",borderBottom:"solid 1px lightgray",color:"gray.500",fontSize:"11pt",children:t})},lX=()=>{let{data:e,isLoading:n,isFetching:t,error:r,refetch:s}=(0,y.a)({queryKey:P.runs(),queryFn:async()=>await ex(),retry:!1}),{showRunId:a,runId:d}=nq(),x=e=>{iT({name:"click_run"}),a(e,!1)},[,m]=(0,ew.TH)(),p=(0,b.NL)(),f=(0,j.useCallback)(async()=>{if(!d)return;let e=await nP(d);p.invalidateQueries({queryKey:P.checks()}),m("/checks/".concat(e.check_id))},[d,m,p]),g=(0,j.useCallback)(e=>{iT({name:"go_to_check"}),m("/checks/".concat(e))},[m]),v=null;return(0,i.jsxs)(o.k,{direction:"column",height:"100%",children:[(0,i.jsxs)(u.U,{width:"100%",flex:"0 0 54px",paddingInline:"24px 8px",borderBottom:"solid 1px lightgray",children:[(0,i.jsx)(c.X,{size:"md",children:"History"}),(0,i.jsx)(h.L,{}),(0,i.jsx)(nS.h,{variant:"unstyled",icon:(0,i.jsx)(n5.n,{}),"aria-label":"Search database",onClick:()=>{s()}})]}),(0,i.jsx)(l.x,{flex:"1 1 auto",children:n?"Loading...":(null==e?void 0:e.length)===0?(0,i.jsx)(eZ.M,{height:"100%",color:"gray.400",children:"No runs"}):(0,i.jsx)(lU.Z,{style:{minHeight:"100%",height:0},children:(e||[]).map((e,n)=>{let t=new Date(e.run_at).toDateString(),l=null!=v&&v!==t;return v=t,(0,i.jsxs)(i.Fragment,{children:[l&&(0,i.jsx)(lQ,{runAt:e.run_at},t),(0,i.jsx)(lZ,{run:e,isSelected:e.run_id===d,onSelectRun:x,onGoToCheck:g,onAddToChecklist:f},e.run_id)]})})})})]})};var lG=t(5552),lY=t(34533);let{definePartsStyle:l$,defineMultiStyleConfig:l0}=(0,lY.D)(lG.TB.keys),l1=l0({variants:{circular:l$({control:(0,lY.k0)({rounded:"full"})})},sizes:{xs:l$({icon:(0,lY.k0)({fontSize:"8px"}),control:(0,lY.k0)({boxSize:"16px",padding:"4px"}),label:(0,lY.k0)({fontSize:"xs"})})}}),l5=(0,t(86907).fj)({baseStyle:{borderRadius:"4px"}});var l2=t(35051);let l4=()=>{let e=(0,G.p)();return{toastSuccess:n=>{e({description:n,status:"success",variant:"left-accent",position:"bottom-right",duration:5e3,isClosable:!0})},toastError:(n,t)=>{var i,l;e({description:t?t instanceof iX.d7?"".concat(n,". ").concat(null==t?void 0:null===(l=t.response)||void 0===l?void 0:null===(i=l.data)||void 0===i?void 0:i.detail):"".concat(n,". ").concat(t):"".concat(n),status:"error",variant:"left-accent",position:"bottom-right",duration:5e3,isClosable:!0})}}},l6=e=>{(0,j.useEffect)(()=>{let n=e=>{e.preventDefault()};return e&&window.addEventListener("beforeunload",n),()=>{e&&window.removeEventListener("beforeunload",n)}},[e])},l3=()=>{let{fileName:e,cloudMode:n,isDemoSite:t,isLoading:r}=eg(),a=(0,eb.q)(),c=(0,eb.q)(),d=!e&&!n&&!t,{data:u}=(0,y.a)({queryKey:P.checks(),queryFn:nW,enabled:d}),h=void 0!=u&&u.filter(e=>!e.is_preset).length>0;l6(d&&h);let[{newFileName:x,errorMessage:m,modified:p,overwriteWithMethod:f,bypass:g},v]=(0,j.useState)({newFileName:e||"recce_state.json"}),w=(0,j.useRef)(null),{toastSuccess:k,toastError:C}=l4(),_=(0,b.NL)(),S=async(e,n)=>{if(!x)return;let t="true"===localStorage.getItem(iS.bypassSaveOverwrite);try{"save"===e?await lr({filename:x,overwrite:n||t}):await ls({filename:x,overwrite:n||t}),k("save"===e?"Save file successfully":"Rename file successfully"),_.invalidateQueries({queryKey:P.lineage()}),g&&localStorage.setItem(iS.bypassSaveOverwrite,"true")}catch(n){if(n instanceof iX.d7){var i;if((null===(i=n.response)||void 0===i?void 0:i.status)===409){v(n=>({...n,overwriteWithMethod:e})),c.onOpen();return}}C("save"===e?"Save file failed":"Rename file failed",n)}finally{a.onClose()}};return n||t?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(o.k,{flex:"1",justifyContent:"center",alignItems:"center",children:[(0,i.jsx)(l.x,{fontWeight:"600",children:e||(n?"cloud":"New Instance"+(h?" (unsaved)":""))}),(0,i.jsx)(nh.u,{label:e?"Change Filename":"Save",openDelay:1e3,children:(0,i.jsx)(nS.h,{onClick:()=>{v({newFileName:e||"recce_state.json",modified:!e}),a.onOpen()},"aria-label":"",variant:"unstyled",size:"sm",children:(0,i.jsx)(s.J,{as:e?lp:lm,boxSize:"16px",verticalAlign:"middle"})})})]}),(0,i.jsxs)(Y.u_,{isOpen:a.isOpen,onClose:a.onClose,isCentered:!0,children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{children:[(0,i.jsx)(en.x,{children:e?"Change Filename":"Save File"}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(et.f,{onKeyDown:e=>{e.stopPropagation()},children:(0,i.jsxs)(eC.NI,{isInvalid:!!m,children:[(0,i.jsx)(e_.l,{children:"File name:"}),(0,i.jsx)(nb.I,{ref:w,value:x,placeholder:"Enter filename",onChange:n=>{let t;let i=n.target.value;i?i.endsWith(".json")?/^[a-zA-Z0-9 _-]+\.json$/.test(i)?e&&i===e&&(t="Filename is the same as the current one."):t="Invalid filename. Only alphanumeric, space, _ and - are allowed.":t="Filename must end with .json.":t="Filename cannot be empty.",v(e=>({...e,modified:!0,newFileName:i,errorMessage:t}))},onKeyDown:n=>{"Enter"===n.key?m||(e?S("rename"):S("save")):"Escape"===n.key&&a.onClose()}}),(0,i.jsx)(l2.J1,{children:m})]})}),(0,i.jsxs)(el.m,{gap:"5px",children:[(0,i.jsx)(er.z,{size:"sm",colorScheme:e?void 0:"blue",onClick:()=>{S("save")},isDisabled:!x||!!m||!p,children:e?"Save as New File":"Confirm"}),e&&(0,i.jsx)(er.z,{size:"sm",colorScheme:"blue",onClick:()=>{S("rename")},isDisabled:!x||!!m||!p,children:"Rename"})]})]})]}),(0,i.jsxs)(Y.u_,{isOpen:c.isOpen,onClose:c.onClose,initialFocusRef:w,isCentered:!0,children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{children:[(0,i.jsx)(en.x,{children:"Overwrite File?"}),(0,i.jsx)(ej.o,{}),(0,i.jsxs)(et.f,{borderTop:"solid 1px lightgray",borderBottom:"solid 1px lightgray",onKeyDown:e=>{e.stopPropagation()},children:[(0,i.jsx)(l.x,{fontSize:"12pt",children:"save"===f?"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?"}),(0,i.jsx)(nn.X,{isChecked:g,onChange:e=>v(n=>({...n,bypass:e.target.checked})),fontWeight:"bold",size:"sm",pt:"8px",children:"Don't show this again"})]}),(0,i.jsxs)(el.m,{gap:"5px",children:[(0,i.jsx)(er.z,{variant:"outline",onClick:()=>{c.onClose(),a.onOpen(),v(e=>({...e,overwriteWithMethod:void 0}))},size:"sm",children:"Back"}),(0,i.jsx)(er.z,{size:"sm",colorScheme:"blue",onClick:()=>{f&&(S(f,!0),c.onClose())},children:"Overwrite"})]})]})]})]})};var l9=t(2842),l8=t(49624),l7=t(97530);function re(){return(0,i.jsx)(nh.u,{label:"Syncing",children:(0,i.jsx)(er.z,{pt:"6px",variant:"unstyled",boxSize:"1em",children:(0,i.jsx)(tA.$,{})})})}function rn(){let[e,n]=(0,j.useState)(!1),t=(0,b.NL)(),[r,o]=(0,ew.TH)(),{isOpen:a,onOpen:c,onClose:d}=(0,eb.q)(),[u,h]=(0,j.useState)(""),x=(0,G.p)(),m=(0,j.useCallback)(async e=>{if(d(),n(!0),"conflict"===(await ld(e)).status){c(),n(!1);return}for(;await lc();)await new Promise(e=>setTimeout(e,1e3));x({description:"Sync Completed",status:"success",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0}),n(!1),h(""),t.invalidateQueries({queryKey:P.lineage()}),t.invalidateQueries({queryKey:P.checks()}),t.invalidateQueries({queryKey:P.runs()}),/^\/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(r)&&o("/checks")},[t,r,o,x,c,d]);return e?(0,i.jsx)(re,{}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(nh.u,{label:"Sync with Cloud",children:(0,i.jsx)(nS.h,{size:"sm",variant:"unstyled","aria-label":"Sync state",onClick:()=>m({}),icon:(0,i.jsx)(s.J,{as:lu,verticalAlign:"middle",boxSize:"16px"})})}),(0,i.jsxs)(Y.u_,{isOpen:a,onClose:d,children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{children:[(0,i.jsx)(en.x,{fontSize:"lg",fontWeight:"bold",children:"Sync with Cloud"}),(0,i.jsxs)(et.f,{children:[(0,i.jsx)(l.x,{children:"New changes have been detected in the cloud. Please choose a method to sync your state"}),(0,i.jsx)(l.x,{mt:"5px",children:(0,i.jsx)(l9.E,{onChange:h,value:u,children:(0,i.jsxs)(tR.K,{direction:"column",children:[(0,i.jsxs)(l8.Y,{value:"merge",children:["Merge",(0,i.jsx)(nh.u,{label:"This will merge the local and remote states.",children:(0,i.jsx)("span",{children:(0,i.jsx)(s.J,{as:l7.h,ml:2,cursor:"pointer"})})})]}),(0,i.jsxs)(l8.Y,{value:"overwrite",children:["Overwrite",(0,i.jsx)(nh.u,{label:"This will overwrite the remote state file with the local state.",children:(0,i.jsx)("span",{children:(0,i.jsx)(s.J,{as:l7.h,ml:2,cursor:"pointer"})})})]}),(0,i.jsxs)(l8.Y,{value:"revert",children:["Revert",(0,i.jsx)(nh.u,{label:"This will discard local changes and revert to the cloud state.",children:(0,i.jsx)("span",{children:(0,i.jsx)(s.J,{as:l7.h,ml:2,cursor:"pointer"})})})]})]})})})]}),(0,i.jsxs)(el.m,{children:[(0,i.jsx)(er.z,{onClick:d,mr:3,children:"Cancel"}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>m({method:u}),isDisabled:!u,children:"Sync"})]})]})]})]})}let rt=e=>{let{children:n,path:t}=e,[r]=(0,ew.yj)(t);return(0,i.jsx)(l.x,{display:r?"block":"none",height:"100%",children:n})};function ri(e){let{icon:n,href:t,...l}=e;return(0,i.jsx)(r.r,{height:"20px",color:"white",href:t,isExternal:!0,...l,children:(0,i.jsx)(s.J,{color:"white",boxSize:"20px",as:n})})}function rl(){let{reviewMode:e,isDemoSite:n,envInfo:t,cloudMode:x,isLoading:m}=eg(),p=function(){let[e,n]=(0,j.useState)("");return(0,j.useEffect)(()=>{(async function(){try{let e=await U.get("/api/version");n(e.data)}catch(e){console.error("Error fetching version number:",e)}})()},[]),e}(),{url:f,id:g}=(null==t?void 0:t.pullRequest)||{},v=f?f.split("/").pop():null;return(0,i.jsxs)(o.k,{gap:"10px",minHeight:"40px",alignItems:"center",bg:"rgb(255, 110, 66)",children:[(0,i.jsx)(a.E,{boxSize:"20px",ml:"18px",src:"/logo/recce-logo-white.png",alt:"recce-logo-white"}),(0,i.jsx)(c.X,{as:"h1",fontFamily:'"Montserrat", sans-serif',fontSize:"lg",color:"white",children:"RECCE"}),(0,i.jsx)(d.C,{fontSize:"sm",color:"white",colorScheme:"whiteAlpha",variant:"outline",children:p}),e&&(0,i.jsx)(d.C,{fontSize:"sm",color:"white",colorScheme:"whiteAlpha",variant:"outline",children:"review mode"}),x&&(0,i.jsx)(d.C,{fontSize:"sm",color:"white",colorScheme:"whiteAlpha",variant:"outline",children:(0,i.jsxs)(u.U,{children:[(0,i.jsx)(l.x,{children:"cloud mode"}),(0,i.jsx)(l.x,{borderLeft:"1px",borderLeftColor:"whiteAlpha.500",paddingLeft:"8px",children:(0,i.jsxs)(r.r,{href:f,_hover:{textDecoration:"none"},isExternal:!0,children:[(0,i.jsx)(s.J,{as:eY.X9P,boxSize:"3",fontWeight:"extrabold",strokeWidth:"1"})," #".concat(g)]})})]})}),n&&f&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(d.C,{fontSize:"sm",color:"white",colorScheme:"whiteAlpha",variant:"outline",children:(0,i.jsxs)(u.U,{children:[(0,i.jsx)(l.x,{children:"demo mode"}),(0,i.jsx)(l.x,{borderLeft:"1px",borderLeftColor:"whiteAlpha.500",paddingLeft:"8px",children:(0,i.jsxs)(r.r,{href:f,_hover:{textDecoration:"none"},isExternal:!0,children:[(0,i.jsx)(s.J,{as:eY.X9P,boxSize:"3",fontWeight:"extrabold",strokeWidth:"1"})," #".concat(v)]})})]})})}),(0,i.jsx)(h.L,{}),(0,i.jsx)(ri,{icon:th.hJX,href:"https://github.com/DataRecce/recce"}),(0,i.jsx)(ri,{icon:th.w5k,href:"https://getdbt.slack.com/archives/C05C28V7CPP"}),(0,i.jsx)(ri,{mr:"18px",icon:th.MXt,href:"https://datarecce.io/docs"})]})}function rr(e){let{queryKey:n,fetchCallback:t,selectCallback:r}=e,{data:s,isLoading:o,error:a}=(0,y.a)({queryKey:n,queryFn:t,select:r});return o||a||0===s?(0,i.jsx)(i.Fragment,{}):(0,i.jsx)(l.x,{ml:"2px",height:"80%",aspectRatio:1,borderRadius:"full",bg:"tomato",alignContent:"center",color:"white",fontSize:"xs",children:s})}function rs(){let{isDemoSite:e,reviewMode:n,fileMode:t,cloudMode:r,isLoading:s}=eg(),[a,c]=(0,ew.TH)(),d=[{name:"Lineage",href:"/lineage"},{name:"Query",href:"/query"},{name:"Checklist",href:"/checks",badge:(0,i.jsx)(rr,{queryKey:P.checks(),fetchCallback:nW,selectCallback:e=>e.filter(e=>!e.is_checked).length})}],u=eR().findIndex(d,e=>{let{href:n}=e;return a.startsWith(n)});return(0,i.jsx)(x.m,{index:u,children:(0,i.jsxs)(m.t,{children:[(0,i.jsx)(l.x,{flex:"1",display:"flex",children:d.map(e=>{let{name:n,href:t,badge:l}=e;return(0,i.jsxs)(p.O,{onClick:()=>{c(t)},children:[n,l]},n)})}),!s&&!e&&(0,i.jsx)(l3,{}),!s&&(0,i.jsxs)(o.k,{flex:"1",justifyContent:"right",alignItems:"center",mr:"8px",children:[r&&(0,i.jsx)(rn,{}),(0,i.jsx)(lD,{}),(0,i.jsx)(lP,{})]})]})})}function ro(){let{isRunResultOpen:e,isHistoryOpen:n,closeRunResult:t}=nq(),[r]=(0,ew.TH)(),s=e&&!r.startsWith("/checks"),o=n&&!r.startsWith("/checks");return(0,i.jsxs)(tc,{sizes:[0,100],minSize:o?300:0,gutterSize:o?5:0,style:{height:"100%"},children:[(0,i.jsx)(l.x,{style:{contain:"size"},children:o&&(0,i.jsx)(lX,{})}),(0,i.jsxs)(td,{sizes:s?[50,50]:[100,0],minSize:s?100:0,gutterSize:s?5:0,style:{flex:"1",contain:"size"},children:[(0,i.jsx)(l.x,{p:0,style:{contain:"content"},children:(0,i.jsxs)(lT,{children:[(0,i.jsx)(rt,{path:"/lineage",children:(0,i.jsx)(lW,{})}),(0,i.jsxs)(ew.rs,{children:[(0,i.jsx)(ew.AW,{path:"/query",children:(0,i.jsx)(lw,{})}),(0,i.jsx)(ew.AW,{path:"/checks/:slug*",children:(0,i.jsx)(lv,{})}),(0,i.jsx)(ew.AW,{path:"/runs/:runId",children:e=>{let{runId:n}=e;return(0,i.jsx)(lR,{runId:n})}}),(0,i.jsx)(ew.AW,{path:"/ssr",children:(0,i.jsx)(f.E,{size:"xs",isIndeterminate:!0})}),(0,i.jsx)(ew.AW,{children:(0,i.jsx)(ew.l_,{to:"/lineage"})})]})]})}),s?(0,i.jsx)(ih,{onClose:t}):(0,i.jsx)(l.x,{})]})]})}let ra=(0,g.B1)({components:{Checkbox:l1,Tooltip:l5}});function rc(){(0,j.useLayoutEffect)(()=>{!function(){var e;let n=(e=document.cookie.match("(^|;)\\s*recce_user_id\\s*=\\s*([^;]+)"))?e.pop():"",t=iR.env.AMPLITUDE_API_KEY;if(n&&t)try{iz.S1(t,n,{defaultTracking:!0})}catch(e){console.error(e)}}()},[]);let e=(0,lS.Z)({components:{MuiTooltip:{styleOverrides:{tooltip:{zIndex:1500}}}}});return(0,i.jsx)(lz.Z,{theme:e,children:(0,i.jsx)(v.x,{theme:ra,children:(0,i.jsx)(b.aH,{client:Z,children:(0,i.jsx)(ew.F0,{hook:l_,children:(0,i.jsx)(nV,{children:(0,i.jsxs)(o.k,{direction:"column",height:"100vh",overflow:"hidden",children:[(0,i.jsx)(rl,{}),(0,i.jsx)(rs,{}),(0,i.jsx)(lB,{}),(0,i.jsx)(ro,{})]})})})})})})}},76890:function(){},24550:function(){},50394:function(){},5637:function(){}},function(e){e.O(0,[887,524,434,678,509,648,989,147,995,739,283,303,22,25,355,495,599,852,67,868,986,744],function(){return e(e.s=17812)}),_N_E=e.O()}]);
\ No newline at end of file
diff --git a/recce/data/_next/static/chunks/app/page-e13293d65ae39e95.js b/recce/data/_next/static/chunks/app/page-e13293d65ae39e95.js
new file mode 100644
index 00000000..440dff23
--- /dev/null
+++ b/recce/data/_next/static/chunks/app/page-e13293d65ae39e95.js
@@ -0,0 +1 @@
+(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[931],{17812:function(e,n,t){Promise.resolve().then(t.bind(t,72643))},72643:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return rh}});var i=t(60088),l=t(95523),r=t(1401),s=t(51269),o=t(84185),a=t(26883),c=t(8539),d=t(62752),u=t(11801),h=t(32060),x=t(79698),m=t(65452),p=t(99345),f=t(84739),g=t(98459),v=t(27180),j=t(40843),y=t(16341),b=t(25658);let w='select * from {{ ref("mymodel") }}',k=(0,j.createContext)({sqlQuery:w,setSqlQuery:()=>{},primaryKeys:void 0,setPrimaryKeys:()=>{},isCustomQueries:!1,setCustomQueries:()=>{},baseSqlQuery:w,setBaseSqlQuery:()=>{}});function C(e){let{children:n}=e,[t,l]=j.useState(w),[r,s]=j.useState(w),[o,a]=j.useState(!1),[c,d]=j.useState();return(0,i.jsx)(k.Provider,{value:{setSqlQuery:l,sqlQuery:t,setPrimaryKeys:d,primaryKeys:c,isCustomQueries:o,setCustomQueries:a,baseSqlQuery:r,setBaseSqlQuery:s},children:n})}let _=()=>(0,j.useContext)(k),S=(0,j.createContext)({isNodesFetching:[],setIsNodesFetching:()=>{}});function z(e){let{children:n}=e,[t,l]=j.useState([]);return(0,i.jsx)(S.Provider,{value:{isNodesFetching:t,setIsNodesFetching:l},children:n})}var R=t(13943);function E(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3,i=new Set,l={},r=(e,t)=>{if(!(t<0)&&(void 0===l[e]||!(l[e]>=t))){for(let i of(l[e]=t,n(e)))r(i,t-1);i.add(e)}};for(let n of e)r(n,t);return i}function T(){for(var e=arguments.length,n=Array(e),t=0;t{e.forEach(e=>{i.add(e)})}),i}var D=t(67407),L=t.n(D);function I(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;return E(n,n=>void 0===e.nodes[n]?[]:Object.keys(e.nodes[n].parents),t)}function M(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1e3;return E(n,n=>void 0===e.nodes[n]?[]:Object.keys(e.nodes[n].children),t)}function O(e,n){let t=[],i=[];function l(e){return"base"===e?0:"current"===e?2:1}function r(e,n){let t=l(e.from),i=l(n.from);return ti?1:0}let s=null!=n?new Set(n):void 0;for(let n of Object.values(e.nodes).sort(r))(!s||s.has(n.id))&&t.push({id:n.id,position:{x:0,y:0},data:n,type:"customNode",targetPosition:R.Ly.Left,sourcePosition:R.Ly.Right});for(let n of Object.values(e.edges).sort(r))(!s||s.has(n.parent.id)&&s.has(n.child.id))&&i.push({id:n.id,type:"customEdge",source:n.parent.id,target:n.child.id,data:n});return A(t,i),F(Array.from(M(e,e.modifiedSet)),t,i)}let A=function(e,n){let t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"LR",i=new(L()).graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:t}),e.forEach(e=>{i.setNode(e.id,{width:300,height:36})}),n.forEach(e=>{i.setEdge(e.source,e.target)}),L().layout(i),e.forEach(e=>{let n=i.node(e.id);return e.position={x:n.x-150,y:n.y-18},e})};function F(e,n,t){let i=new Set(e),l=new Set(t.filter(e=>i.has(e.source)&&i.has(e.target)).map(e=>e.id));return[n.map(e=>({...e,data:{...e.data,isHighlighted:i.has(e.id)}})),t.map(e=>({...e,data:{...e.data,isHighlighted:l.has(e.id)}}))]}function N(e,n){return n.map(n=>{let t=n.id===e;return{...n,data:{...n.data,isSelected:t}}})}function q(e,n){return n.map(n=>{let t=n.id===e;return{...n,data:{...n.data,isSelected:n.data.isSelected!==t}}})}function V(e,n){let t=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return n.map(n=>{let i=e.includes(n.id);return{...n,data:{...n.data,isSelected:t?i:n.data.isSelected||i}}})}function H(e,n){return e.map(e=>({...e,data:{...e.data,isSelected:!1,isActionMode:n,action:void 0}}))}let P={lineage:()=>["lineage"],checks:()=>["checks","list"],check:e=>["checks",e],runs:()=>["runs"],run:e=>["runs",e],runsAggregated:()=>["runs_aggregated"],flag:()=>["flag"]};var W=t(93677),K=t(38674);let J=K.env.NEXT_PUBLIC_API_URL?K.env.NEXT_PUBLIC_API_URL:window.location.origin;var B=t(22386);let U=W.default.create({baseURL:J}),Z=new B.S;async function Q(){return(await U.get("/api/info")).data}async function X(e){return(await U.get("/api/model/".concat(e))).data}var G=t(85259),Y=t(34743),$=t(69666),ee=t(14720),en=t(36778),et=t(84078),ei=t(84387),el=t(11126),er=t(92556),es=t(58540),eo=t.n(es);async function ea(e,n,t){return(await U.post("/api/runs",{type:e,params:n,nowait:null==t?void 0:t.nowait})).data}async function ec(e,n){return(await U.get("/api/runs/".concat(e,"/wait"),{params:{timeout:n}})).data}async function ed(e){return await U.post("/api/runs/".concat(e,"/cancel"))}async function eu(e,n){return(await U.post("/api/checks/".concat(e,"/run"),{nowait:null==n?void 0:n.nowait})).data}async function eh(e,n,t){return(await U.post("/api/runs/search",{type:e,params:n,limit:t})).data}async function ex(){return(await U.get("/api/runs")).data}async function em(){return(await U.post("/api/runs/aggregate",{})).data}let ep=(0,j.createContext)({isActionAvailable:()=>!0});function ef(e){var n,t,l;let{children:r}=e,s=(0,y.a)({queryKey:P.lineage(),queryFn:Q}),o=(0,y.a)({queryKey:P.runsAggregated(),queryFn:em}),a=(0,j.useMemo)(()=>{var e;let n=null===(e=s.data)||void 0===e?void 0:e.lineage;if(n&&n.base&&n.current)return function(e,n){let t={},i={},l=(e,n)=>({id:e,name:e,data:{},from:n,parents:{},children:{},isSelected:!1});for(let[n,i]of Object.entries(e.nodes))t[n]=l(n,"base"),i&&(t[n].data.base=i,t[n].name=null==i?void 0:i.name,t[n].resourceType=null==i?void 0:i.resource_type,t[n].packageName=null==i?void 0:i.package_name);for(let[e,i]of Object.entries(n.nodes))t[e]?t[e].from="both":t[e]=l(e,"current"),i&&(t[e].data.current=n.nodes&&n.nodes[e],t[e].name=null==i?void 0:i.name,t[e].resourceType=null==i?void 0:i.resource_type,t[e].packageName=null==i?void 0:i.package_name);for(let[n,l]of Object.entries(e.parent_map))for(let e of l){let l=t[n],r=t[e],s="".concat(e,"_").concat(n);if(!l||!r)continue;i[s]={id:s,from:"base",parent:r,child:l};let o=i[s];l.parents[e]=o,r.children[n]=o}for(let[e,l]of Object.entries(n.parent_map))for(let n of l){let l=t[e],r=t[n],s="".concat(n,"_").concat(e);if(!l||!r)continue;i[s]?i[s].from="both":i[s]={id:s,from:"current",parent:r,child:l};let o=i[s];l.parents[n]=o,r.children[e]=o}let r=[];for(let[e,n]of Object.entries(t))if("base"===n.from)n.changeStatus="removed",r.push(n.id);else if("current"===n.from)n.changeStatus="added",r.push(n.id);else{var s,o,a,c,d,u;let e=null==n?void 0:null===(a=n.data)||void 0===a?void 0:null===(o=a.base)||void 0===o?void 0:null===(s=o.checksum)||void 0===s?void 0:s.checksum,t=null==n?void 0:null===(u=n.data)||void 0===u?void 0:null===(d=u.current)||void 0===d?void 0:null===(c=d.checksum)||void 0===c?void 0:c.checksum;e&&t&&e!==t&&(n.changeStatus="modified",r.push(n.id))}for(let[e,n]of Object.entries(i))"base"===n.from?n.changeStatus="removed":"current"===n.from&&(n.changeStatus="added");return{nodes:t,edges:i,modifiedSet:r,manifestMetadata:{base:e.manifest_metadata||void 0,current:n.manifest_metadata||void 0},catalogMetadata:{base:e.catalog_metadata||void 0,current:n.catalog_metadata||void 0}}}(n.base,n.current)},[s.data]),c=null===(n=s.error)||void 0===n?void 0:n.message,{lineage:d,sqlmesh:u,demo:h,review_mode:x,cloud_mode:m,file_mode:p,filename:f,adapter_type:g,git:v,pull_request:w,support_tasks:k}=s.data||{},C=null==d?void 0:null===(t=d.base)||void 0===t?void 0:t.manifest_metadata,_=null==d?void 0:null===(l=d.current)||void 0===l?void 0:l.manifest_metadata,{connectionStatus:S,connect:z}=function(){let e=(0,G.p)(),n=(0,j.useRef)({ws:void 0,status:"pending"}),[t,i]=(0,j.useState)("pending");n.current.status=t;let l=(0,b.NL)(),r=()=>{l.invalidateQueries({queryKey:P.lineage()}),l.invalidateQueries({queryKey:P.checks()}),l.invalidateQueries({queryKey:P.runs()})},s=()=>{let t=new WebSocket("".concat(J.replace(/(http)(s)?\:\/\//,"ws$2://"),"/api/ws"));n.current.ws=t,t.onopen=()=>{t.send("ping")},t.onmessage=t=>{if("pong"===t.data){"disconnected"===n.current.status&&r(),i("connected");return}try{let n=JSON.parse(t.data);if("refresh"===n.command){let{eventType:t,srcPath:i}=n.event,[l,s]=i.split("/").slice(-2),o=eo().parse(s).name;e({description:"Detected ".concat(l," ").concat(o," ").concat(t),status:"info",variant:"left-accent",position:"bottom-right",duration:5e3,isClosable:!0}),r()}}catch(e){console.error(e)}},t.onerror=e=>{console.error(e)},t.onclose=()=>{i(e=>"connected"===e?"disconnected":e),n.current.ws=void 0}};return(0,j.useEffect)(()=>{let e=n.current;return s(),()=>{e.ws&&e.ws.close()}},[]),{connectionStatus:t,connect:s}}(),R=(0,j.useCallback)(e=>{if(k){var n;return null===(n=k[e])||void 0===n||n}return!0},[k]);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(ep.Provider,{value:{lineageGraph:a,retchLineageGraph:()=>{o.refetch()},envInfo:{adapterType:g,git:v,pullRequest:w,dbt:{base:C,current:_},sqlmesh:u},reviewMode:x,cloudMode:m,fileMode:p,fileName:f,isDemoSite:h,error:c,supportTasks:k,isActionAvailable:R,isLoading:s.isLoading,runsAggregated:o.data,refetchRunsAggregated:()=>{o.refetch()}},children:r}),(0,i.jsxs)(Y.u_,{isOpen:"disconnected"===S,onClose:()=>{},isCentered:!0,children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{children:[(0,i.jsx)(en.x,{children:"Server Disconnected"}),(0,i.jsx)(et.f,{children:(0,i.jsx)(ei.x,{children:"The server connection has been lost. Please restart the Recce server and try again."})}),(0,i.jsx)(el.m,{children:(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>{z()},children:"Retry"})})]})]})]})}let eg=()=>(0,j.useContext)(ep),ev=()=>{let{runsAggregated:e,refetchRunsAggregated:n}=eg();return[e,n]};var ej=t(65050);let ey=e=>{let{isOpen:n,onClose:t,onExecute:r,type:s,title:a,params:c,RunForm:d}=e,[u,h]=(0,j.useState)(c),[x,m]=(0,j.useState)(!1);return(0,i.jsxs)(Y.u_,{isOpen:n,onClose:t,size:"6xl",scrollBehavior:"inside",children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{overflowY:"auto",height:"75%",children:[(0,i.jsx)(en.x,{children:a}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(et.f,{p:"0px",h:"100%",overflow:"auto",borderY:"1px solid lightgray",children:(0,i.jsx)(l.x,{style:{contain:"layout"},children:d&&(0,i.jsx)(d,{params:u,onParamsChanged:h,setIsReadyToExecute:m})})}),(0,i.jsx)(el.m,{children:(0,i.jsx)(o.k,{gap:"10px",children:(0,i.jsx)(er.z,{isDisabled:!x,colorScheme:"blue",onClick:()=>{r(s,u)},children:"Execute"})})})]})]})};var eb=t(6604),ew=t(78473),ek=t(20413),eC=t(94134),e_=t(61381),eS=t(90788),ez=t(82821),eR=t.n(ez);function eE(e,n){let t=[];return e.forEach(e=>{t.some(n=>n.name===e.name)||t.push(e)}),n.forEach(e=>{t.some(n=>n.name===e.name)||t.push(e)}),t}var eT=e=>{var n;let{lineageGraph:t}=eg(),[i,l]=(0,j.useState)([]),[r,s]=(0,j.useState)(),[o,a]=(0,j.useState)(!0),[c,d]=(0,j.useState)(null),u=eR().find(null==t?void 0:t.nodes,{name:e}),h=(0,j.useMemo)(()=>u?function(e){function n(e){return e&&e.columns?Object.values(e.columns):[]}return eE(n(e.data.base),n(e.data.current))}(u):[],[u]),x=u?null===(n=u.data.current)||void 0===n?void 0:n.primary_key:void 0;return(0,j.useEffect)(()=>{let e=async()=>{try{let e=(await X(null==u?void 0:u.id)).model;if(!e||!e.base.columns||!e.current.columns){l([]);return}s(e.current.primary_key);let n=Object.values(e.base.columns),t=Object.values(e.current.columns);l(eE(n,t))}catch(e){d(e)}};h.length>0?(l(h),s(x)):(null==u?void 0:u.id)===void 0?l([]):e(),a(!1)},[null==u?void 0:u.id,h,x]),{columns:i,primaryKey:r,isLoading:o,error:c}};function eD(e){return["CHAR","VARCHAR","TINYTEXT","TEXT","MEDIUMTEXT","LONGTEXT","NCHAR","NVARCHAR","VARCHAR2","NVARCHAR2","CLOB","NCLOB","VARCHAR(MAX)","XML","JSON","BOOLEAN","TINYINT(1)","BIT","NUMBER(1)","BOOL"].includes(e.toUpperCase())}function eL(e){return["DATE","DATETIME","TIMESTAMP","TIME","YEAR","DATETIME2","SMALLDATETIME","DATETIMEOFFSET","INTERVAL","TIMESTAMPTZ","TIMETZ","TIMESTAMP WITH TIME ZONE","TIMESTAMP WITH LOCAL TIME ZONE","TIMESTAMP_LTZ","TIMESTAMP_NTZ","TIMESTAMP_TZ"].includes(e.toUpperCase())}var eI=t(77125),eM=t(94659),eO=t(42921);function eA(e){let n=e>0&&e<=.001,t=e<1&&e>=.999,i=function(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:e;return function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"en-US",t=arguments.length>2?arguments[2]:void 0;return"number"!=typeof e?e:new Intl.NumberFormat(n,t).format(e)}(n,"en-US",{style:"percent",minimumFractionDigits:1})};if(n){let e=i(.001);return"<".concat(e)}if(t){let e=i(.999);return">".concat(e)}return i()}function eF(e){if("number"!=typeof e)return e;{let n=Math.abs(e),t=n>=.01,i=n>=1e6,l=n>=1e9,r=n>=1e15;if(r||n>=1e12)return new Intl.NumberFormat("en-US",{style:"unit",unit:"liter",unitDisplay:"narrow",maximumFractionDigits:r?0:2}).format(e/1e12).replace("L","T");if(l||i||n>=1e3){let n={base:l?1e9:i?1e6:1e3,unit:l?"B":i?"M":"K"};return new Intl.NumberFormat("en-US",{style:"unit",unit:"liter",unitDisplay:"narrow",maximumFractionDigits:1}).format(e/n.base).replace("L",n.unit)}return n>=1?new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(e):new Intl.NumberFormat("en-US",{maximumFractionDigits:t?3:2,notation:t||0===n?"standard":"scientific"}).format(e)}}let eN="#63B3ED",eq="#F6AD55",eV="".concat(eN,"A5"),eH="".concat(eq,"A5");function eP(e){let{color:n}=e;return(0,i.jsx)(l.x,{display:"inline-block",w:"10px",h:"10px",bgColor:n,mr:"2",borderRadius:"sm"})}function eW(e){let{data:n,hideAxis:t=!1,animation:l=!1}=e;eM.kL.register(eM.ZL,eM.RM,eM.f$,eM.uw,eM.Dx,eM.De,eM.u);let r=function(e){let n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],{...t}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},{title:i,datasets:l,type:r,samples:s=0,binEdges:o}=e,[a,c]=l,d="datetime"===r;return{responsive:!0,maintainAspectRatio:!1,plugins:{legend:{reverse:!0},title:{display:!0,text:i,font:{size:20}},tooltip:{mode:"index",intersect:!1,callbacks:{title(e){let[{dataIndex:n,datasetIndex:t}]=e,i=eJ(o,n);return"".concat(d?"Date Range":"string"===r?"Text Length":"Value Range","\n").concat(i)},label(e){let{datasetIndex:n,dataIndex:t,dataset:{label:i}}=e,l=0===n?c.counts:a.counts,r=eA(l[t]/s),o=l[t];return"".concat(i,": ").concat(o," (").concat(r,")")}}}},scales:function(e){let{datasets:n,min:t=0,max:i=0,type:l,binEdges:r}=e,s=arguments.length>1&&void 0!==arguments[1]&&arguments[1],[o,a]=n,c=Math.max(...a.counts,...o.counts),d=r.map((e,n)=>eJ(r,n)).slice(0,-1);return{x:"datetime"===l?{display:!s,type:"timeseries",min:t,max:i,adapters:{date:{}},time:{minUnit:"day"},grid:{display:!1},ticks:{minRotation:30,maxRotation:30,maxTicksLimit:8}}:{display:!s,type:"category",grid:{display:!1},ticks:{callback:(e,n)=>d[n]},stacked:!0},y:{display:!s,type:"linear",max:c,border:{dash:[2,2]},grid:{color:"lightgray"},ticks:{maxTicksLimit:8,callback:function(e,n){return eF(e)}},beginAtZero:!0}}}(e,n),...t}}(n,t,{animation:l}),s=function(e){let{datasets:n,type:t,binEdges:i}=e,[l,r]=n,s=eK(t,i,"Current",eV,r),o=eK(t,i,"Base",eH,l);return{labels:i.map((e,n)=>eJ(i,n)).slice(0,-1),datasets:[s,o]}}(n);return(0,i.jsx)(eO.kL,{type:"bar",options:r,data:s,plugins:[]})}function eK(e,n,t,i,l){let{counts:r=[]}=l;return{label:t,data:"datetime"===e?r.map((e,t)=>({x:n[t],y:e})):r,backgroundColor:i,borderColor:i,hoverBackgroundColor:i,borderWidth:0,categoryPercentage:1,barPercentage:1,xAxisID:"x"}}function eJ(e,n){let t=e[n],i=e[n+1],l=eF(t),r=eF(i);return"".concat(l," - ").concat(r)}let eB=(0,eI.G)((e,n)=>{let{backgroundColor:t="white",blockSize:r,children:s,...o}=e;return(0,i.jsx)(l.x,{ref:n,...o,overflowY:"auto",overflowX:"hidden",children:(0,i.jsx)(l.x,{backgroundColor:t,height:"100%",blockSize:r,children:s})})}),eU=(0,eI.G)(function(e,n){var t,r,s,a,c,d;let{run:x}=e,m=x.params,p=null===(t=x.result)||void 0===t?void 0:t.base,f=null===(r=x.result)||void 0===r?void 0:r.current,g=null===(s=x.result)||void 0===s?void 0:s.min,v=null===(a=x.result)||void 0===a?void 0:a.max,j=null===(c=x.result)||void 0===c?void 0:c.bin_edges;return p&&f?(0,i.jsx)(o.k,{direction:"column",height:"100%",children:(0,i.jsx)(eB,{ref:n,height:"100%",children:(0,i.jsxs)(u.U,{children:[(0,i.jsx)(h.L,{}),(0,i.jsx)(l.x,{w:"80%",h:"35vh",m:"4",children:(0,i.jsx)(eW,{data:{title:"Model ".concat(m.model,".").concat(m.column_name),type:(null===(d=x.params)||void 0===d?void 0:d.column_type)||"",datasets:[f,p],min:g,max:v,samples:p.total,binEdges:j}})}),(0,i.jsx)(h.L,{})]})})}):(0,i.jsx)("div",{children:"Loading..."})});var eZ=t(21129);t(91751);var eQ=t(30614);let eX=(0,eI.G)((e,n)=>{let{...t}=e;return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(eQ.ZP,{ref:n,...t})})});function eG(){return(0,i.jsx)(o.k,{h:"35px",alignItems:"center",justifyContent:"center",bg:"gray.100",style:{textAlign:"center",gridColumn:"1/-1"},children:(0,i.jsx)(ei.x,{fontWeight:"600",children:" No rows"})})}t(24550);var eY=t(8);function e$(e,n){let t=function(e,n){let t=[...e],i=[...n],l=[];for(;t.length>0&&i.length>0;)if(l.includes(t[0]))t.shift();else if(l.includes(i[0]))i.shift();else if(t[0]===i[0])l.push(t[0]),t.shift(),i.shift();else if(i.includes(t[0])){let e=i.indexOf(t[0]);for(let n=0;n{l.includes(e)||l.push(e)}),i.forEach(e=>{l.includes(e)||l.push(e)}),l}(e,n),i={};for(let l of t)e.includes(l)?n.includes(l)?i[l]=void 0:i[l]="removed":i[l]="added";let l={};e.forEach((e,n)=>{l[e]=n});let r=-1;for(let e of t){let n=l[e];void 0!==n&&(n>r?r=n:i[e]="reordered")}return i}function e0(e,n){let t=[];for(let i of n){let n=e.findIndex(e=>e.name===i);if(n<0)throw Error("Column ".concat(i," not found"));t.push(n)}return t}function e1(e,n,t){let i={};if(0===n.length)return JSON.stringify({_index:t._index});for(let l of n)i[e[l].name]=t[l];return JSON.stringify(i)}function e5(e){let{name:n,columnStatus:t,onPrimaryKeyChange:r,onPinnedColumnsChange:a,...c}=e,d=c.primaryKeys||[],u=c.pinnedColumns||[],h=d.includes(n),x=u.includes(n);return"index"===n?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(o.k,{alignItems:"center",gap:"10px",className:"grid-header",children:[(0,i.jsx)(l.x,{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:n}),"added"!==t&&"removed"!==t&&r&&(0,i.jsx)(s.J,{className:h?"close-icon":"key-icon",display:h?"block":"none",cursor:"pointer",as:h?eY.ven:eY.MhP,onClick:h?()=>{let e=d.filter(e=>e!==n);r&&r(e)}:()=>{let e=[...d.filter(e=>"index"!==e),n];r&&r(e)}}),!h&&a&&(0,i.jsx)(s.J,{className:x?"unpin-icon":"pin-icon",display:x?"block":"none",cursor:"pointer",as:x?eY.$kI:eY.oJP,onClick:x?()=>{let e=u.filter(e=>e!==n);a&&a(e)}:()=>{let e=[...u,n];a&&a(e)}})]})}let e2=e=>{let n;let t=!1;return"boolean"==typeof e?n=e.toString():""===e?(n="(empty)",t=!0):null==e?(n="(null)",t=!0):n=e,[n,t]},e4=e=>{let{row:n,column:t}=e;if(!n.hasOwnProperty(t.key))return(0,i.jsx)(ei.x,{style:{color:"gray"},children:"-"});let[l,r]=e2(n[t.key]);return(0,i.jsx)(ei.x,{style:{color:r?"gray":"inherit"},children:l})};function e6(e,n,t){let l=e||{columns:[],data:[]},r=n||{columns:[],data:[]},s=(null==t?void 0:t.primaryKeys)||[],o=(null==t?void 0:t.pinnedColumns)||[],a=(null==t?void 0:t.changedOnly)||!1,c=[],d=function(e,n){let t={};return Object.entries(e$(e.columns.map(e=>e.name),n.columns.map(e=>e.name))).map(i=>{let[l,r]=i;t[l]={status:r,baseColumnIndex:e.columns.findIndex(e=>e.name===l),currentColumnIndex:n.columns.findIndex(e=>e.name===l)}}),t}(l,r),u={},h={},x=!1,m=!1;if(0===s.length)l.data.forEach((e,n)=>{e._index=n+1,u[JSON.stringify({_index:n+1})]=e}),r.data.forEach((e,n)=>{e._index=n+1,h[JSON.stringify({_index:n+1})]=e});else{let e=e0(l.columns,s);l.data.forEach((n,t)=>{let i=e1(l.columns,e,n);i in u&&(x=!0),u[i]=n}),e=e0(r.columns,s),r.data.forEach((n,t)=>{let i=e1(r.columns,e,n);i in h&&(m=!0),h[i]=n})}let p=e$(Object.keys(u),Object.keys(h)),f={added:0,removed:0,modified:0},g=Object.entries(p).map(e=>{let[n,t]=e,i=u[n],o=h[n],a=JSON.parse(n);if(i&&l.columns.forEach((e,n)=>{s.includes(e.name)||(a["base__".concat(e.name)]=i[n])}),o&&r.columns.forEach((e,n)=>{s.includes(e.name)||(a["current__".concat(e.name)]=o[n])}),i){if(o){for(let[e,n]of Object.entries(d))"index"===e||s.includes(e)||n.baseColumnIndex<0||n.currentColumnIndex<0||eR().isEqual(i[n.baseColumnIndex],o[n.currentColumnIndex])||(a.__status="modified",n.status="modified");"modified"===a.__status&&f.modified++}else a.__status="removed",f.removed++}else a.__status="added",f.added++;return a});a&&(g=g.filter(e=>"added"===e.__status||"removed"===e.__status||"modified"===e.__status));let v=(e,n)=>{let l="added"===n?"diff-header-added":"removed"===n?"diff-header-removed":void 0,r=t=>{let i=t.__status;if("removed"===i)return"diff-cell-removed";if("added"===i)return"diff-cell-added";if("added"===n);else if("removed"===n);else if(!eR().isEqual(t["base__".concat(e)],t["current__".concat(e)]))return"diff-cell-modified"};return{headerCellClass:l,name:(0,i.jsx)(e5,{name:e,columnStatus:n,...t}),children:[{key:"base__".concat(e),name:"Base",renderEditCell:eQ.Ug,headerCellClass:l,cellClass:r,renderCell:e4,size:"auto"},{key:"current__".concat(e),name:"Current",renderEditCell:eQ.Ug,headerCellClass:l,cellClass:r,renderCell:e4,size:"auto"}]}};return 0===s.length?c.push({key:"_index",width:50,maxWidth:100,name:"",cellClass:"index-column"}):s.forEach(e=>{let n=d[e].status||"";c.push({key:"".concat(e),name:(0,i.jsx)(e5,{name:e,columnStatus:n,...t}),frozen:!0,cellClass:e=>{if(e.__status)return"diff-header-".concat(e.__status)},renderCell:e4})}),o.forEach(e=>{let n=d[e].status||"";"index"===e||s.includes(e)||c.push(v(e,n))}),Object.entries(d).forEach(e=>{let[n,t]=e,i=t.status||"";"index"===n||s.includes(n)||o.includes(n)||a&&f.modified>0&&"added"!==i&&"removed"!==i&&"modified"!==i||c.push(v(n,i))}),{columns:c,rows:g,invalidPKeyBase:x,invalidPKeyCurrent:m}}let e3=(0,eI.G)((e,n)=>{var t;let{run:l,viewOptions:r,onViewOptionsChanged:s}=e,o=l.result;l.params;let a=(0,j.useMemo)(()=>(null==r?void 0:r.pinned_columns)||[],[r]),c=((null==o?void 0:null===(t=o.current)||void 0===t?void 0:t.columns)||[]).find(e=>"column_name"===e.name.toLowerCase()),d=(null==c?void 0:c.name)||"column_name",u=(0,j.useMemo)(()=>e6(null==o?void 0:o.base,null==o?void 0:o.current,{primaryKeys:[d],pinnedColumns:a,onPinnedColumnsChange:e=>{s&&s({...r,pinned_columns:e})}}),[o,d,a,r,s]);return 0===u.columns.length?(0,i.jsx)(eZ.M,{height:"100%",children:"No data"}):(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:u.columns,rows:u.rows,defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})})});function e9(e){let{name:n,columnStatus:t,onPrimaryKeyChange:r,onPinnedColumnsChange:a,...c}=e,d=c.primaryKeys||[],u=c.pinnedColumns||[],h=d.includes(n),x=u.includes(n);return"index"===n?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(o.k,{alignItems:"center",gap:"10px",className:"grid-header",children:[(0,i.jsx)(l.x,{flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:n}),!h&&a&&(0,i.jsx)(s.J,{className:x?"unpin-icon":"pin-icon",display:x?"block":"none",cursor:"pointer",as:x?eY.$kI:eY.oJP,onClick:x?()=>{let e=u.filter(e=>e!==n);a&&a(e)}:()=>{let e=[...u,n];a&&a(e)}})]})}function e8(e,n,t){let l=(null==t?void 0:t.pinnedColumns)||[],r=(null==t?void 0:t.changedOnly)||!1,s=[],o=function(e){let n={};return e.columns.map((e,t)=>{n[e.name]={index:t}}),n}(e),a={},c={};if(0===n.length)throw Error("Primary keys are required");let d=function(e,n){let t=[];for(let i of n){let n=e.findIndex(e=>e.name===i);if(n<0)throw Error("Column ".concat(i," not found"));t.push(n)}return t}(e.columns,n),u=(o.in_a||o.IN_A).index,h=(o.in_b||o.IN_B).index;e.data.forEach((n,t)=>{let i=function(e,n,t){let i={};if(0===n.length)return JSON.stringify({_index:t._index});for(let l of n)i[e[l].name]=t[l];return JSON.stringify(i)}(e.columns,d,n);n[u]&&(a[i]=n),n[h]&&(c[i]=n)});let x=e$(Object.keys(a),Object.keys(c)),m={added:0,removed:0,modified:0},p=Object.entries(x).map(t=>{let[i,l]=t,r=a[i],s=c[i],d=JSON.parse(i);if(r&&e.columns.forEach((e,t)=>{n.includes(e.name)||(d["base__".concat(e.name)]=r[t])}),s&&e.columns.forEach((e,t)=>{n.includes(e.name)||(d["current__".concat(e.name)]=s[t])}),r){if(s)for(let[e,t]of Object.entries(o))!("index"===e||n.includes(e))&&(eR().isEqual(r[t.index],s[t.index])||(d.__status="modified",t.status="modified"));else d.__status="removed",m.removed++}else d.__status="added",m.added++;return"modified"===d.__status&&m.modified++,d});r&&(p=p.filter(e=>"added"===e.__status||"removed"===e.__status||"modified"===e.__status));let f=(e,n)=>{let l="added"===n?"diff-header-added":"removed"===n?"diff-header-removed":void 0,r=t=>{let i=t.__status;if("removed"===i)return"diff-cell-removed";if("added"===i)return"diff-cell-added";if("added"===n);else if("removed"===n);else if(!eR().isEqual(t["base__".concat(e)],t["current__".concat(e)]))return"diff-cell-modified"};return{headerCellClass:l,name:(0,i.jsx)(e9,{name:e,columnStatus:n,...t}),children:[{key:"base__".concat(e),name:"Base",renderEditCell:eQ.Ug,headerCellClass:l,cellClass:r,renderCell:e4,size:"auto"},{key:"current__".concat(e),name:"Current",renderEditCell:eQ.Ug,headerCellClass:l,cellClass:r,renderCell:e4,size:"auto"}]}};return n.forEach(e=>{let n=o[e].status||"";s.push({key:"".concat(e),name:(0,i.jsx)(e9,{name:e,columnStatus:n,...t}),frozen:!0,cellClass:e=>{if(e.__status)return"diff-header-".concat(e.__status)},renderCell:e4})}),l.forEach(e=>{let t=o[e].status||"";n.includes(e)||s.push(f(e,t))}),Object.entries(o).forEach(e=>{let[t,i]=e,o=i.status||"";"in_a"===t||"in_b"===t||n.includes(t)||l.includes(t)||r&&m.modified>0&&"added"!==o&&"removed"!==o&&"modified"!==o||s.push(f(t,o))}),{columns:s,rows:p}}var e7=t(80906),ne=t(89494),nn=t(13329);let nt=e=>{let{run:n,warnings:t,viewOptions:r,onAddToChecklist:s,onViewOptionsChanged:a}=e;return(0,i.jsxs)(o.k,{borderBottom:"1px solid lightgray",justifyContent:"flex-end",gap:"5px",alignItems:"center",px:"10px",bg:t&&t.length>0?"orange.100":"inherit",children:[(0,i.jsx)(ne.g,{alignItems:"flex-start",spacing:0,children:t&&t.map((e,n)=>(0,i.jsxs)(l.x,{children:[(0,i.jsx)(e7.a,{color:"orange.600"})," ",e]},n))}),(0,i.jsx)(h.L,{minHeight:"32px"}),(0,i.jsx)(nn.X,{isChecked:null==r?void 0:r.changed_only,onChange:()=>{let e=!(null==r?void 0:r.changed_only);a&&a({...r,changed_only:e})},children:"Changed only"}),s&&(0,i.jsx)(er.z,{marginBlock:"5px",size:"sm",colorScheme:"blue",onClick:()=>s(n),children:"Add to Checklist"})]})},ni=(e,n)=>{var t,l,r,s,a,c;let{run:d,onAddToChecklist:u,viewOptions:h,onViewOptionsChanged:x}=e,m=(0,j.useMemo)(()=>(null==h?void 0:h.primary_keys)||[],[h]),p=(0,j.useMemo)(()=>(null==h?void 0:h.changed_only)||!1,[h]),f=(0,j.useMemo)(()=>(null==h?void 0:h.pinned_columns)||[],[h]),g=(0,j.useMemo)(()=>{var e,n;return e6(null==d?void 0:null===(e=d.result)||void 0===e?void 0:e.base,null==d?void 0:null===(n=d.result)||void 0===n?void 0:n.current,{changedOnly:p,primaryKeys:m,onPrimaryKeyChange:e=>{x&&x({...h,primary_keys:e})},pinnedColumns:f,onPinnedColumnsChange:e=>{x&&x({...h,pinned_columns:e})}})},[d,h,p,m,f,x]),v=(0,j.useMemo)(()=>{let e=m.join(", ");return g.invalidPKeyBase&&g.invalidPKeyCurrent?"Warning: The primary key '".concat(e,"' is not unique in the base and current environments"):g.invalidPKeyBase?"Warning: The primary key '".concat(e,"' is not unique in the base environment"):g.invalidPKeyCurrent?"Warning: The primary key '".concat(e,"' is not unique in the current environment"):void 0},[g.invalidPKeyBase,g.invalidPKeyCurrent,m]),y=(null===(l=d.result)||void 0===l?void 0:null===(t=l.current)||void 0===t?void 0:t.limit)||0,b=y>0&&((null==d?void 0:null===(s=d.result)||void 0===s?void 0:null===(r=s.current)||void 0===r?void 0:r.more)||(null==d?void 0:null===(c=d.result)||void 0===c?void 0:null===(a=c.base)||void 0===a?void 0:a.more))?"Warning: Displayed results are limited to ".concat(y.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null,w=[];return(v&&w.push(v),b&&w.push(b),0===g.columns.length)?(0,i.jsx)(eZ.M,{height:"100%",children:"No data"}):p&&0===g.rows.length?(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsx)(nt,{run:d,viewOptions:h,onAddToChecklist:u,onViewOptionsChanged:x,warnings:w}),(0,i.jsx)(eZ.M,{height:"100%",children:"No change"}),";"]}):(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsx)(nt,{run:d,viewOptions:h,onAddToChecklist:u,onViewOptionsChanged:x,warnings:w}),(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:g.columns,rows:g.rows,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})},nl=(e,n)=>{var t,l,r,s;let{run:a,onAddToChecklist:c,viewOptions:d,onViewOptionsChanged:u}=e,h=(0,j.useMemo)(()=>(null==d?void 0:d.changed_only)||!1,[d]),x=(0,j.useMemo)(()=>(null==d?void 0:d.pinned_columns)||[],[d]),m=(0,j.useMemo)(()=>{var e,n;if(!(null===(e=a.result)||void 0===e?void 0:e.diff)||!(null==a?void 0:null===(n=a.params)||void 0===n?void 0:n.primary_keys))return{columns:[],rows:[]};let t=a.params.primary_keys;return e8(null==a?void 0:a.result.diff,t,{changedOnly:h,pinnedColumns:x,onPinnedColumnsChange:e=>{u&&u({...d,pinned_columns:e})}})},[a,d,h,x,u]),p=(null===(l=a.result)||void 0===l?void 0:null===(t=l.diff)||void 0===t?void 0:t.limit)||0,f=p>0&&(null==a?void 0:null===(s=a.result)||void 0===s?void 0:null===(r=s.diff)||void 0===r?void 0:r.more)?"Warning: Displayed results are limited to ".concat(p.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null,g=[];return(f&&g.push(f),0===m.columns.length)?(0,i.jsx)(eZ.M,{height:"100%",children:"No data"}):h&&0===m.rows.length?(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsx)(nt,{run:a,viewOptions:d,onAddToChecklist:c,onViewOptionsChanged:u,warnings:g}),(0,i.jsx)(eZ.M,{height:"100%",children:"No change"})]}):(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsx)(nt,{run:a,viewOptions:d,onAddToChecklist:c,onViewOptionsChanged:u,warnings:g}),(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:m.columns,rows:m.rows,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})},nr=(0,eI.G)((e,n)=>{var t;if((null===(t=e.run)||void 0===t?void 0:t.result)!==void 0&&null!==e.run.result.diff&&void 0!==e.run.result.diff){let t=(0,eI.G)(nl);return(0,i.jsx)(t,{...e,ref:n})}{let t=(0,eI.G)(ni);return(0,i.jsx)(t,{...e,ref:n})}});function ns(e){let{name:n,pinnedColumns:t=[],onPinnedColumnsChange:r=()=>{}}=e,a=t.includes(n);return(0,i.jsxs)(o.k,{className:"grid-header",alignItems:"center",children:[(0,i.jsx)(l.x,{flex:1,children:n}),(0,i.jsx)(s.J,{className:a?"unpin-icon":"pin-icon",display:a?"block":"none",cursor:"pointer",as:a?eY.$kI:eY.oJP,onClick:a?()=>{r(t.filter(e=>e!==n))}:()=>{r([...t,n])}})]})}let no=(0,eI.G)((e,n)=>{let{run:t,viewOptions:r,onViewOptionsChanged:s,onAddToChecklist:a}=e,c=(0,j.useMemo)(()=>(null==r?void 0:r.pinned_columns)||[],[r]),d=null==t?void 0:t.result,u=(0,j.useMemo)(()=>d?function(e,n){let t=[],l=n.pinnedColumns||[],r=(e,t)=>({key:String(e),name:(0,i.jsx)(ns,{name:t,...n}),width:"auto",renderCell:e4});return t.push({key:"_index",name:"",width:50,cellClass:"index-column"}),l.forEach(n=>{let i=eR().findIndex(e.columns,e=>e.name===n);i<0||t.push(r(i,n))}),e.columns.forEach((e,n)=>{l.includes(e.name)||t.push(r(n,e.name))}),e.data.forEach((e,n)=>{e._index=n+1}),{columns:t,rows:e.data}}(d,{pinnedColumns:c,onPinnedColumnsChange:e=>{s&&s({...r,pinned_columns:e})}}):{rows:[],columns:[]},[d,c,r,s]);if(0===u.columns.length)return(0,i.jsx)(eZ.M,{height:"100%",children:"No data"});let x=(null==d?void 0:d.limit)||0,m=x>0&&(null==d?void 0:d.more)?"Warning: Displayed results are limited to ".concat(x.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null,p=a||m;return(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[p&&(0,i.jsxs)(o.k,{borderBottom:"1px solid lightgray",alignItems:"center",gap:"5px",px:"10px",bg:m?"orange.100":"inherit",children:[m&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(e7.a,{color:"orange.600",alignSelf:"center"})," ",(0,i.jsx)(l.x,{children:m})]}),(0,i.jsx)(h.L,{minHeight:"32px"}),a&&(0,i.jsx)(er.z,{marginBlock:"5px",size:"sm",colorScheme:"blue",onClick:()=>a(t),children:"Add to Checklist"})]}),(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:u.columns,rows:u.rows,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})});function na(e,n){if(e=.1?t.toFixed(1):" <0.1 ","%")}if(!(e>n))return"0 %";{let t=(e-n)/e*100;return"-".concat(t>=.1?t.toFixed(1):" <0.1 ","%")}}var nc=t(22442),nd=t.n(nc);let nu=(0,eI.G)(function(e,n){let{run:t}=e;function l(e){if(e.base===e.current);else if(e.basee.current||"N/A"===e.current)return"column-body-removed";return"column-body-normal"}let r=t.result||{},s=Object.keys(t.result||{}).map(e=>{let n=r[e],t=nd()(null==n?void 0:n.base)?null==n?void 0:n.base:null,i=nd()(null==n?void 0:n.curr)?null==n?void 0:n.curr:null,l="No Change";return null!==t&&null!==i?l=t!==i?na(t,i):"No Change":t===i?l="N/A":null===t?l="Added":null===i&&(l="Removed"),{name:e,base:null===t?"N/A":Number(t),current:null===i?"N/A":Number(i),delta:l}});return 0===s.length?(0,i.jsx)(eZ.M,{bg:"rgb(249,249,249)",height:"100%",children:"No nodes matched"}):(0,i.jsx)(o.k,{direction:"column",children:Object.keys(r).length>0&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",fontSize:"10pt",borderWidth:1},columns:[{key:"name",name:"Name",cellClass:l},{key:"base",name:"Base Rows",cellClass:l},{key:"current",name:"Current Rows",cellClass:l},{key:"delta",name:"Delta",cellClass:l}],rows:s,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},className:"rdg-light",enableScreenshot:!0})})})});var nh=t(62019),nx=t(429);let nm="#63B3ED";function np(e,n){let t=n?10:e.counts.length,i=e.counts.slice(0,t),l=e.valids-i.reduce((e,n)=>e+n,0);return e.values.slice(0,t).concat([l]).map((n,t)=>{let r;let s=t===i.length,o=s?l:i[t],a=!1;return s?(r="(others)",a=!0):null==n?(r="(null)",a=!0):"string"==typeof n&&0===n.length?(r="(empty)",a=!0):r=String(n),{isLastItemOthers:s,isSpecialLabel:a,label:r,count:o,displayCount:eF(o),displayRatio:eA(o/e.valids)||"N/A"}})}function nf(e){let{base:n,current:t,children:r}=e;return(0,i.jsx)(nh.u,{label:(0,i.jsxs)(l.x,{children:[(0,i.jsxs)(ei.x,{children:[(0,i.jsx)(eP,{color:eN}),"Current: ",t.count," (",t.displayRatio,")"]}),(0,i.jsxs)(ei.x,{children:[(0,i.jsx)(eP,{color:eq}),"Base: ",n.count," (",n.displayRatio,")"]})]}),placement:"auto",hasArrow:!0,children:r})}function ng(e){let{topKDiff:n,isDisplayTopTen:t}=e,r=np(n.current,t),s=np(n.base,t);return(0,i.jsxs)(l.x,{w:"100%",px:20,py:4,children:[(0,i.jsxs)(o.k,{alignItems:"center",direction:"row",children:[(0,i.jsx)(h.L,{}),(0,i.jsxs)(ei.x,{as:"h3",size:"sm",p:"2",color:"gray",children:[(0,i.jsx)(eP,{color:eq})," Base"]}),(0,i.jsxs)(ei.x,{as:"h3",size:"sm",p:"2",color:"gray",children:[(0,i.jsx)(eP,{color:eN})," Current"]}),(0,i.jsx)(h.L,{})]}),r.map((e,t)=>{let l=s[t];return e.isLastItemOthers&&0===e.count&&0===l.count?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(j.Fragment,{children:[(0,i.jsx)(nf,{base:l,current:e,children:(0,i.jsxs)(o.k,{alignItems:"center",width:"100%",_hover:{bg:"blackAlpha.300"},px:4,children:[(0,i.jsx)(ei.x,{noOfLines:1,width:"10em",fontSize:"sm",color:e.isSpecialLabel?"gray.400":"inherit",children:e.label}),(0,i.jsxs)(o.k,{width:"70%",direction:"column",children:[(0,i.jsxs)(o.k,{height:"1em",children:[(0,i.jsx)(nv,{topkCount:e.count,topkLabel:e.label,valids:n.current.valids,color:eN}),(0,i.jsx)(ei.x,{ml:5,mr:2,fontSize:"sm",width:"6em",children:e.displayCount}),(0,i.jsx)(ei.x,{color:"gray.400",fontSize:"sm",width:"4em",children:e.displayRatio})]}),(0,i.jsxs)(o.k,{height:"1em",children:[(0,i.jsx)(nv,{topkCount:l.count,topkLabel:l.label,valids:n.base.valids,color:eq}),(0,i.jsx)(ei.x,{ml:5,mr:2,fontSize:"sm",width:"6em",children:l.displayCount}),(0,i.jsx)(ei.x,{color:"gray.400",fontSize:"sm",width:"4em",children:l.displayRatio})]})]})]})}),(0,i.jsx)(nx.i,{})]},t)})]})}function nv(e){let{topkCount:n,topkLabel:t,valids:l,animation:r=!1,color:s=nm}=e;eM.kL.register(eM.uw,eM.ZL,eM.f$);let o=function(e,n){let{...t}=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return{responsive:!0,maintainAspectRatio:!1,indexAxis:"y",scales:{x:{display:!1,max:n,grid:{display:!1}},y:{display:!1}},plugins:{tooltip:{enabled:!1}},...t}}(n,l,{animation:r}),a=function(e){let{topkLabel:n,topkCount:t,color:i=nm}=e;return{labels:[n],datasets:[{indexAxis:"y",data:[t],backgroundColor:i,hoverBackgroundColor:i,borderWidth:0,borderColor:i,barPercentage:1,categoryPercentage:.6}]}}({topkCount:n,topkLabel:t,color:s});return(0,i.jsx)(eO.$Q,{data:a,options:o,plugins:[]})}let nj=(0,eI.G)((e,n)=>{let{run:t}=e,[l,s]=(0,j.useState)(!0),a=t.result,d=t.params,x=a.base,m=a.current;return(0,i.jsxs)(o.k,{direction:"column",height:"100%",children:[(0,i.jsxs)(eB,{ref:n,blockSize:"auto",children:[(0,i.jsxs)(c.X,{as:"h1",size:"md",paddingTop:4,textAlign:"center",color:"gray.600",children:["Model ",d.model,".",d.column_name]}),(0,i.jsxs)(u.U,{children:[(0,i.jsx)(h.L,{}),(0,i.jsx)(ng,{topKDiff:a,valids:m.valids||0,isDisplayTopTen:l}),(0,i.jsx)(h.L,{})]})]}),(0,i.jsx)(h.L,{}),(x.values.length>10||m.values.length>10)&&(0,i.jsx)(o.k,{p:5,justify:"start",children:(0,i.jsx)(r.r,{onClick:()=>s(e=>!e),textColor:"blue.500",children:l?"View More Items":"View Only Top-10"})})]})}),ny=(0,eI.G)((e,n)=>{var t,l;let{run:r,onAddToChecklist:s,viewOptions:a,onViewOptionsChanged:c}=e,d=(0,j.useMemo)(()=>(null==a?void 0:a.changed_only)||!1,[a]),u=(0,j.useMemo)(()=>(null==a?void 0:a.pinned_columns)||[],[a]),h=(0,j.useMemo)(()=>{var e;if(!r.result||!(null==r?void 0:null===(e=r.params)||void 0===e?void 0:e.primary_key))return{columns:[],rows:[]};let n=r.params.primary_key,t=Array.isArray(n)?n:[n];return e8(null==r?void 0:r.result,t,{changedOnly:d,pinnedColumns:u,onPinnedColumnsChange:e=>{c&&c({...a,pinned_columns:e})}})},[r,a,d,u,c]),x=(null===(t=r.result)||void 0===t?void 0:t.limit)||0,m=x>0&&(null==r?void 0:null===(l=r.result)||void 0===l?void 0:l.more)?"Warning: Displayed results are limited to ".concat(x.toLocaleString()," records. To ensure complete data retrieval, consider applying a LIMIT or WHERE clause to constrain the result set."):null,p=[];return(m&&p.push(m),0===h.columns.length)?(0,i.jsx)(eZ.M,{height:"100%",children:"No data"}):d&&0===h.rows.length?(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsx)(nt,{run:r,viewOptions:a,onAddToChecklist:s,onViewOptionsChanged:c,warnings:p}),(0,i.jsx)(eZ.M,{height:"100%",children:"No change"}),";"]}):(0,i.jsxs)(o.k,{direction:"column",backgroundColor:"rgb(249, 249, 249)",height:"100%",children:[(0,i.jsx)(nt,{run:r,viewOptions:a,onAddToChecklist:s,onViewOptionsChanged:c,warnings:p}),(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto"},columns:h.columns,rows:h.rows,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},defaultColumnOptions:{resizable:!0,maxWidth:800,minWidth:35},className:"rdg-light",enableScreenshot:!0})]})});var nb=t(95021),nw=t(62347);function nk(e){let{params:n,onParamsChanged:t,setIsReadyToExecute:r}=e,[s,o]=(0,j.useState)(!n.columns||0===n.columns.length),a=null==n?void 0:n.model,c=null==n?void 0:n.primary_key,{columns:d,primaryKey:u,isLoading:h,error:x}=eT(n.model);(0,j.useEffect)(()=>{!c&&u&&t({...n,primary_key:u})},[c,u,n,t]),(0,j.useEffect)(()=>{r(!!c&&!!a)},[c,a,r]);let m=d.map(e=>e.name),p=Array.isArray(c)?c:c?[c]:void 0;return h?(0,i.jsx)(l.x,{children:"Loading..."}):0===m.length||x?(0,i.jsx)(l.x,{children:"Error: Please provide the 'catalog.json' to list column candidates"}):(0,i.jsxs)(ne.g,{gap:5,m:"8px 24px",paddingBottom:"200px",children:[(0,i.jsxs)(eC.NI,{children:[(0,i.jsx)(e_.l,{children:"Model"}),(0,i.jsx)(nb.I,{isReadOnly:!0,value:null==n?void 0:n.model})]}),(0,i.jsxs)(eC.NI,{children:[(0,i.jsx)(e_.l,{children:"Primary key"}),(0,i.jsx)(nw.Ph,{placeholder:"Select primary key",isMulti:!0,closeMenuOnSelect:!1,options:(m||[]).map(e=>({label:e,value:e})),value:(p||[]).map(e=>({label:e,value:e})),onChange:e=>{t({...n,primary_key:1==e.length?e[0].value:e.map(e=>e.value)})}})]}),(0,i.jsxs)(eC.NI,{children:[(0,i.jsx)(e_.l,{children:"Columns"}),(0,i.jsx)(nn.X,{marginBottom:"10px",isChecked:s,onChange:e=>{o(e.target.checked),t({...n,columns:void 0})},children:"All columns"}),!s&&(0,i.jsx)(nw.Ph,{isMulti:!0,closeMenuOnSelect:!1,options:(m||[]).map(e=>({label:e,value:e})),value:(n.columns||[]).map(e=>({label:e,value:e})),onChange:e=>{t({...n,columns:(e||[]).map(e=>e.value)})}})]})]})}var nC=t(13994),n_=t(54627),nS=t(53254),nz=t(66791),nR=t(57334),nE=t(15405);function nT(e){let{params:n,column:t}=e,{runAction:r}=nq(),a=(e,t)=>{r("value_diff_detail",{...n,...e},t)};return(0,i.jsxs)(o.k,{children:[(0,i.jsx)(l.x,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:t}),(0,i.jsx)(h.L,{}),(0,i.jsx)(nC.v,{isLazy:!0,children:e=>{let{isOpen:n}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n_.j,{className:"row-context-menu",visibility:n?"visible":"hidden",width:n?"auto":"0px",minWidth:n?"auto":"0px",as:nS.h,icon:(0,i.jsx)(s.J,{as:eY.D_A}),variant:"unstyled",size:"sm"}),(0,i.jsx)(nz.q,{lineHeight:"20px",children:(0,i.jsxs)(nR.k,{title:"Action",as:l.x,fontSize:"8pt",children:[(0,i.jsx)(nE.s,{fontSize:"10pt",onClick:()=>a({},{showForm:!0}),children:"Show mismatched values..."}),(0,i.jsxs)(nE.s,{fontSize:"10pt",onClick:()=>a({columns:[t]},{showForm:!1}),children:["Show mismatched values for '",t,"'"]})]})})]})}})]})}let nD=(0,eI.G)(function(e,n){let{run:t}=e,r=t.result,a=t.params,c=e=>{let n=e[2];return null!=n&&n<1?"diff-cell-modified":""},d=Array.isArray(a.primary_key)?a.primary_key:[a.primary_key],u=[{key:"__is_pk__",name:"",width:30,maxWidth:30,renderCell:e=>{let{row:n}=e;return(0,i.jsx)(eZ.M,{height:"100%",children:d.includes(n[0])&&(0,i.jsx)(s.J,{as:eY.MhP})})}},{key:"0",name:"Column",resizable:!0,renderCell:e=>{let{row:n,column:t}=e;return(0,i.jsx)(nT,{column:n[t.key],params:a})},cellClass:"cell-show-context-menu"},{key:"1",name:"Matched",resizable:!0,cellClass:c},{key:"2",name:"Matched %",resizable:!0,renderCell:e=>{let{column:n,row:t}=e,r=t[n.key];return(0,i.jsx)(l.x,{textAlign:"end",children:void 0!=r&&null!==r?"".concat((100*r).toFixed(2)," %"):"N/A"})},cellClass:c}];return(0,i.jsxs)(o.k,{direction:"column",gap:"5px",pt:"5px",height:"100%",children:[(0,i.jsxs)(l.x,{px:"16px",children:["Model: ",a.model,", ",r.summary.total," total (",r.summary.total-r.summary.added-r.summary.removed," ","common, ",r.summary.added," added, ",r.summary.removed," removed)"]}),(0,i.jsx)(eX,{ref:n,style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",borderBlock:"1px solid lightgray"},columns:u,rows:r.data.data,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},defaultColumnOptions:{resizable:!0},className:"rdg-light",enableScreenshot:!0})]})});var nL=t(46970),nI=t(7600);let nM={lineage_diff:{title:"Lineage Diff",icon:ek.Ks7},schema_diff:{title:"Schema Diff",icon:nI.C8A},query:{title:"Query",icon:ek.r2i,RunResultView:no},query_base:{title:"Query Base",icon:ek.r2i,RunResultView:no},query_diff:{title:"Query Diff",icon:ek.r2i,RunResultView:nr},row_count_diff:{title:"Row Count Diff",icon:nI.QUK,RunResultView:nu},profile_diff:{title:"Profile Diff",icon:ek.KA6,RunResultView:e3},value_diff:{title:"Value Diff",icon:ek.pRi,RunResultView:nD,RunForm:nk},value_diff_detail:{title:"Value Diff Detail",icon:ek.pRi,RunResultView:ny,RunForm:nk},top_k_diff:{title:"Top-K Diff",icon:nL.Pkc,RunResultView:nj,RunForm:function(e){let{params:n,onParamsChanged:t,setIsReadyToExecute:r}=e,{columns:s,isLoading:o,error:a}=eT(n.model),c=s.map(e=>e.name);return((0,j.useEffect)(()=>{r(!!n.column_name)},[n,r]),o)?(0,i.jsx)(l.x,{children:"Loading..."}):0===c.length||a?(0,i.jsx)(l.x,{children:"Error: Please provide the 'catalog.json' to list column candidates"}):(0,i.jsx)(l.x,{m:"16px",children:(0,i.jsxs)(eC.NI,{children:[(0,i.jsx)(e_.l,{children:"Pick a column to show top-k"}),(0,i.jsx)(eS.P,{placeholder:"Select column",value:null==n?void 0:n.column_name,onChange:e=>{let i=e.target.value;t({...n,column_name:i})},children:c.map(e=>(0,i.jsx)("option",{value:e,children:e},e))})]})})}},histogram_diff:{title:"Histogram Diff",icon:ek.dku,RunResultView:eU,RunForm:function(e){let{params:n,onParamsChanged:t,setIsReadyToExecute:r}=e,{columns:s,isLoading:o,error:a}=eT(n.model),c=s.filter(e=>!eD(e.type)&&!eL(e.type));return o?(0,i.jsx)(l.x,{children:"Loading..."}):0===s.length||a?(0,i.jsx)(l.x,{children:"Error: Please provide the 'catalog.json' to list column candidates"}):(0,i.jsx)(l.x,{m:"16px",children:(0,i.jsxs)(eC.NI,{children:[(0,i.jsx)(e_.l,{children:"Pick a column to show Histogram Diff"}),(0,i.jsx)(eS.P,{placeholder:0!==c.length?"Select column":"No numeric column is available",isDisabled:0===c.length,value:null==n?void 0:n.column_name,onChange:e=>{var i;let l=e.target.value;r(!!l);let s=(null===(i=c.find(e=>e.name===l))||void 0===i?void 0:i.type)||"";t({...n,column_name:l,column_type:s})},children:c.map(e=>(0,i.jsxs)("option",{value:e.name,children:[e.name," : ",e.type]},e.name))})]})})}},preview_change:{title:"Preview Change",icon:ek.iQd,RunResultView:nr}},nO=e=>nM[e],nA=(0,j.createContext)({runAction:()=>{},showRunId:e=>{},isRunResultOpen:!1,closeRunResult:()=>{},isHistoryOpen:!1,closeHistory:()=>{},showHistory:()=>{},clearRunResult:()=>{}}),nF=e=>{let[n]=(0,ew.TH)();(0,j.useEffect)(()=>{e()},[e,n])};function nN(e){var n;let{children:t}=e,[l,r]=(0,j.useState)(),{isOpen:s,onOpen:o,onClose:a}=(0,eb.q)(),{isOpen:c,onOpen:d,onClose:u}=(0,eb.q)(),{isOpen:h,onOpen:x,onClose:m}=(0,eb.q)(),p=(0,G.p)(),[f,g]=(0,j.useState)(),[v,y]=(0,ew.TH)(),w=(0,b.NL)(),k=(0,j.useCallback)((e,n)=>{g(e),d(),!1!==n&&w.invalidateQueries({queryKey:P.runs()})},[g,d,w]),C=(0,j.useCallback)(()=>{g(void 0),u()},[u,g]),_=(0,j.useCallback)(async(e,n,t)=>{try{let i;let l=new Date().getTime().toString();if(null==t?void 0:t.showLast){let t=await eh(e,n,1);1===t.length&&(i=t[0])}let s=nO(e);if(void 0===s)throw Error("Unknown run type: ".concat(e));let{title:a,RunResultView:c,RunForm:d}=s;if(void 0===c)throw Error("Run type ".concat(e," does not have a result view"));if(void 0!==d&&(null==t?void 0:t.showForm))r({session:l,title:a,type:e,params:n,lastRun:i,options:t,RunForm:d}),o();else{let{run_id:t}=await ea(e,n,{nowait:!0});k(t),w.invalidateQueries({queryKey:P.runs()}),v.startsWith("/lineage")&&y("/lineage")}}catch(e){p({title:"Failed to submit a run",description:null==e?void 0:e.message,position:"bottom-right",status:"error",duration:5e3,isClosable:!0})}},[r,o,k,p,v,y,w]);nF(a);let S=async(e,n)=>{try{a();let{run_id:t}=await ea(e,n,{nowait:!0});k(t)}catch(e){p({title:"Failed to submit a run",description:null==e?void 0:e.message,position:"bottom-right",status:"error",duration:5e3,isClosable:!0})}};return(0,j.useEffect)(()=>{f&&v.startsWith("/checks")&&y("/lineage")},[f]),(0,i.jsxs)(nA.Provider,{value:{runAction:_,runId:f,showRunId:k,isRunResultOpen:c,closeRunResult:u,isHistoryOpen:h,closeHistory:m,showHistory:x,clearRunResult:C},children:[l&&(0,i.jsx)(ey,{isOpen:s,onClose:a,onExecute:S,title:l.title,type:l.type,params:l.params,initialRun:l.lastRun,RunForm:(null===(n=l.options)||void 0===n?void 0:n.showForm)&&l.RunForm?l.RunForm:void 0},l.session),t]})}let nq=()=>(0,j.useContext)(nA);function nV(e){let{children:n}=e;return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(C,{children:(0,i.jsx)(ef,{children:(0,i.jsx)(z,{children:(0,i.jsx)(nN,{children:n})})})})})}async function nH(){return(await U.post("/api/checks",{type:"simple"})).data}async function nP(e,n){return(await U.post("/api/checks",{run_id:e,view_options:n})).data}async function nW(){return(await U.get("/api/checks")).data}async function nK(e){return(await U.get("/api/checks/".concat(e))).data}async function nJ(e,n){return(await U.patch("/api/checks/".concat(e),n)).data}async function nB(e){return(await U.delete("/api/checks/".concat(e))).data}async function nU(e){return await U.post("/api/checks/reorder",e)}var nZ=t(6706),nQ=t(96288),nX=t(38597),nG=t(63770),nY=t(15893),n$=t(46919),n0=t(40451),n1=t(52878),n5=t(91425),n2=t(21567),n4=t(19612),n6=t(14968),n3=t(81417),n9=t(89633),n8=t(14257);function n7(e){let{name:n,setName:t}=e,[r,s]=(0,j.useState)(!1),[o,a]=(0,j.useState)(n),c=(0,j.useRef)(null),d=(0,j.useCallback)(()=>{t(o),s(!1)},[t,s,o]);return(0,j.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&d()};return r&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[r,c,d]),(0,i.jsxs)(n3.a,{flex:"0 1 auto",fontSize:"12pt",fontWeight:"500",separator:(0,i.jsx)(n8.X,{color:"gray.500"}),overflow:"hidden",children:[(0,i.jsx)(n9.g,{children:(0,i.jsx)(l.x,{children:"Checklist"})}),(0,i.jsx)(n9.g,{cursor:"pointer",flex:"0 1 auto",overflow:"hidden",children:r?(0,i.jsx)(nb.I,{ref:c,value:o,onChange:e=>{a(e.target.value)},onKeyDown:e=>{"Enter"===e.key?(t(o),s(!1)):"Escape"===e.key&&(a(n),s(!1))},size:"sm",w:"100%"}):(0,i.jsx)(l.x,{flex:"0 1 auto",onClick:()=>{a(n),s(!0)},textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",children:n})})]})}var te=t(50674);t(50394);var tn=t(20125);function tt(e){let{model:n,name:t,baseType:r,currentType:a}=e,{runAction:c}=nq(),d=a||r,u=()=>{c("histogram_diff",{model:n,column_name:t,column_type:d},{showForm:!1})},x=()=>{c("top_k_diff",{model:n,column_name:t,k:50},{showForm:!1})},m=!r||!a;return(0,i.jsxs)(o.k,{children:[(0,i.jsx)(l.x,{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:t}),(0,i.jsx)(h.L,{}),(0,i.jsx)(nC.v,{children:e=>{let{isOpen:n}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(n_.j,{className:"row-context-menu",visibility:n?"visible":"hidden",width:n?"auto":"0px",minWidth:n?"auto":"0px",as:nS.h,icon:(0,i.jsx)(s.J,{as:eY.D_A}),variant:"unstyled",size:"sm"}),(0,i.jsx)(tn.h,{children:(0,i.jsx)(nz.q,{lineHeight:"20px",children:(0,i.jsxs)(nR.k,{title:"Diff",m:"0",p:"4px 12px",children:[(0,i.jsx)(nE.s,{fontSize:"10pt",onClick:u,isDisabled:m||!d||!(!eD(d)&&!eL(d)),children:"Histogram Diff"}),(0,i.jsx)(nE.s,{fontSize:"10pt",onClick:x,isDisabled:m,children:"Top-k Diff"})]})})})]})}})]})}function ti(e,n){function t(e){return void 0===e.baseIndex?"column-index-added":void 0===e.currentIndex?"column-index-removed":!0===e.reordered?"column-index-reordered":"column-index-normal"}function l(e){return void 0===e.baseIndex?"column-body-added":void 0===e.currentIndex?"column-body-removed":e.baseType!==e.currentType?"column-body-type-changed":!0===e.reordered?"column-body-reordered":"column-body-normal"}return{columns:[{key:"baseIndex",name:"",resizable:!0,minWidth:35,width:35,cellClass:t},{key:"currentIndex",name:"",resizable:!0,minWidth:35,width:35,cellClass:t},{key:"name",name:"Name",resizable:!0,renderCell:e=>{let{row:t,column:l}=e;return n?(0,i.jsx)(tt,{model:n,name:t.name,baseType:t.baseType,currentType:t.currentType}):t.name},cellClass:function(e){return void 0===e.baseIndex?"column-body-added":void 0===e.currentIndex?"column-body-removed":!0===e.reordered?"column-body-reordered":"column-body-normal"}},{key:"baseType",name:"Base Type",resizable:!0,cellClass:l},{key:"currentType",name:"Current Type",resizable:!0,cellClass:l}],rows:Object.values(e)}}var tl=t(57765),tr=t(27322);let ts=(0,j.forwardRef)(function(e,n){let t,l,{base:r,current:s,enableScreenshot:a=!1}=e,{columns:c,rows:d}=(0,j.useMemo)(()=>{let e=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t={};return Object.entries(e$(Object.keys(e),Object.keys(n))).forEach(e=>{let[n,i]=e;t[n]={name:n,reordered:"reordered"===i}}),Object.entries(e).map((e,n)=>{let[i,l]=e;t[i].baseIndex=n+1,t[i].baseType=l.type}),Object.entries(n).map((e,n)=>{let[i,l]=e;t[i].currentIndex=n+1,t[i].currentType=l.type}),t}(null==r?void 0:r.columns,null==s?void 0:s.columns),n=(null==s?void 0:s.resource_type)||(null==r?void 0:r.resource_type);return n&&["model","seed","snapshot"].includes(n)?ti(e,(null==s?void 0:s.name)||(null==r?void 0:r.name)):ti(e)},[r,s]),{lineageGraph:u}=eg(),h=!(null==u?void 0:u.catalogMetadata.base),x=!(null==u?void 0:u.catalogMetadata.current);h&&x?t="catalog.json is missing on both current and base environments.":h?t="catalog.json is missing on base environment.":x&&(t="catalog.json is missing on current environment.");let m=r&&void 0===r.columns,p=s&&void 0===s.columns;return m&&p?l="Schema information is missing on both current and base environments.":m?l="Schema information is missing on base environment.":p&&(l="Schema information is missing on current environment."),(0,i.jsxs)(o.k,{direction:"column",children:[t?(0,i.jsxs)(tl.b,{status:"warning",fontSize:"12px",p:"8px",children:[(0,i.jsx)(tr.z,{}),t]}):l?(0,i.jsxs)(tl.b,{status:"warning",fontSize:"12px",p:"8px",children:[(0,i.jsx)(tr.z,{}),l]}):(0,i.jsx)(i.Fragment,{}),d.length>0&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(eX,{style:{blockSize:"auto",maxHeight:"100%",overflow:"auto",fontSize:"10pt",borderWidth:1},columns:c,rows:d,renderers:{noRowsFallback:(0,i.jsx)(eG,{})},className:"rdg-light",enableScreenshot:a,ref:n})})]})});async function to(e){return(await U.post("/api/select",e)).data}var ta=t(3072);t(5637);let tc=e=>{let{style:n,children:t,gutterSize:l=5,...r}=e;return(0,i.jsx)(ta.Z,{style:{display:"flex",flexDirection:"row",...n},direction:"horizontal",gutterSize:l,...r,children:t})},td=e=>{let{style:n,children:t,gutterSize:l=5,...r}=e;return(0,i.jsx)(ta.Z,{style:{display:"flex",flexDirection:"column",...n},gutterSize:l,direction:"vertical",...r,children:t})};var tu=t(34135),th=t(55726),tx=t(98640);let tm=eY.Nbv,tp=eY.sFB,tf=eY.UGs;function tg(e){return"added"===e?{color:"#1dce00",backgroundColor:"#e8fce5",icon:tm}:"removed"===e?{color:"#ff4444",backgroundColor:"#ffdbdb",icon:tp}:"modified"===e?{color:"#ffa502",backgroundColor:"#fff2dd",icon:tf}:{color:"inherit",backgroundColor:"white",icon:void 0}}function tv(e){if("model"===e)return{color:"#c0eafd",icon:th.Fn3};if("metric"===e)return{color:"#ffe6ee",icon:tx._MV};if("source"===e)return{color:"#a6dda6",icon:th.i1q};if("exposure"===e)return{color:"#ffe6ee",icon:tx.n8P};if("semantic_model"===e)return{color:"#fb8caf",icon:tx.R1C};if("seed"===e)return{color:"#a6dda6",icon:th.tWi};if("snapshot"===e)return{color:"#a6dda6",icon:th.Dmm};else return{color:"inherit",icon:void 0}}function tj(e,n){if(!e||!n)return;let t=Object.keys(e),i=Object.keys(n);if(t.length!==i.length)return!0;for(let e=0;e{let n,t,{node:r,selected:a,onSelect:c,schemaChanged:d}=e,{icon:u}=tv(r.resourceType),{base:h,current:x}=r.data;if(d){var m;n=null===(m=nO("schema_diff"))||void 0===m?void 0:m.icon,t=tg("modified").color}else!h&&x?(n=tg("added").icon,t=tg("added").color):h&&!x&&(n=tg("removed").icon,t=tg("removed").color);return(0,i.jsxs)(o.k,{width:"100%",fontSize:"10pt",p:"5px 8px",cursor:"pointer",_hover:{bg:"gray.200"},bg:a?"gray.100":"inherit",onClick:()=>c(r.id),alignItems:"center",gap:"5px",children:[(0,i.jsx)(s.J,{as:u}),(0,i.jsx)(l.x,{flex:"1",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",children:r.name}),n&&t&&(0,i.jsx)(s.J,{as:n,color:t})]})},tb=(0,j.forwardRef)(function(e,n){let{check:t}=e,{lineageGraph:l}=eg(),r=t.params,s=[...P.check(t.check_id),"select"],{isLoading:o,error:a,refetch:c,data:d}=(0,y.a)({queryKey:s,queryFn:async()=>to({select:null==r?void 0:r.select,exclude:null==r?void 0:r.exclude,packages:null==r?void 0:r.packages,view_mode:null==r?void 0:r.view_mode}),refetchOnMount:!0,enabled:!(null==r?void 0:r.node_id)}),[u,h]=(0,j.useMemo)(()=>{let e=[],n=[],t=[],i=[];if(null==r?void 0:r.node_id)for(let n of r.node_id instanceof Array?r.node_id:[r.node_id]){let t=null==l?void 0:l.nodes[n];t&&e.push(t)}else for(let n of(null==d?void 0:d.nodes)||[]){let t=null==l?void 0:l.nodes[n];t&&e.push(t)}let s=e.filter(e=>"model"===e.resourceType||"seed"===e.resourceType||"source"===e.resourceType||"snapshot"===e.resourceType);for(let e of s){var o,a;tj(null===(o=e.data.base)||void 0===o?void 0:o.columns,null===(a=e.data.current)||void 0===a?void 0:a.columns)?n.push(e.id):!e.data.base&&e.data.current?t.push(e.id):e.data.base&&!e.data.current&&i.push(e.id)}function c(e){return n.includes(e.id)?3:t.includes(e.id)?2:i.includes(e.id)?1:0}return s.sort((e,n)=>{let t=c(e),i=c(n);return t!==i?i-t:e.name.localeCompare(n.name)}),[s,n]},[null==r?void 0:r.node_id,null==d?void 0:d.nodes,l]),[x,m]=(0,j.useState)(0);if(o)return(0,i.jsx)(eZ.M,{bg:"rgb(249,249,249)",height:"100%",children:"Loading..."});if(a)return(0,i.jsxs)(eZ.M,{bg:"rgb(249,249,249)",height:"100%",children:["Error: ",null==a?void 0:a.message]});if(0==u.length)return(0,i.jsx)(eZ.M,{bg:"rgb(249,249,249)",height:"100%",children:"No nodes matched"});if(x(0,i.jsx)(ty,{node:e,schemaChanged:h.includes(e.id),selected:n===x,onSelect:()=>{m(n)}},n))})]})}return(0,i.jsx)(i.Fragment,{})});var tw=t(29589);function tk(e){let{value:n,onChange:t}=e,[l,s]=(0,j.useState)(!1),[a,c]=(0,j.useState)(),d=(0,j.useRef)(null),u=()=>{t&&(t(a),s(!1))};return((0,j.useEffect)(()=>{if(l&&d.current){let e=d.current;e.focus(),e.setSelectionRange(e.value.length,e.value.length)}},[l]),l)?(0,i.jsxs)(o.k,{direction:"column",align:"flex-end",height:"100%",children:[(0,i.jsx)(tw.g,{value:a,onChange:e=>{c(e.target.value)},onKeyDown:e=>{"Escape"===e.key&&s(!1),(e.metaKey||e.ctrlKey)&&"Enter"===e.key&&(e.preventDefault(),u())},ref:d,flex:1}),(0,i.jsxs)(o.k,{gap:"12px",alignItems:"flex-end",children:[(0,i.jsx)(r.r,{onClick:()=>{setTimeout(()=>{s(!1)},100)},colorScheme:"blue",children:"cancel"}),(0,i.jsx)(er.z,{mt:"8px",size:"sm",colorScheme:"blue",onClick:u,children:"Update"})]})]}):(0,i.jsx)(ei.x,{height:"100%",overflow:"auto",fontSize:"11pt",onClick:()=>{c(n||""),s(!0)},whiteSpace:"pre-wrap",wordBreak:"break-word",color:n?"inherit":"lightgray",children:n||"Add description here"})}var tC=t(68306);function t_(){let e=(0,G.p)();return{successToast:function(n){e({description:n,status:"info",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})},failToast:function(n,t){e({title:n,description:"".concat(t),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}}}function tS(){let e=(0,nZ._)(["\n **SQL**\n ```sql\n ","\n ```\n "],["\n **SQL**\n \\`\\`\\`sql\n ","\n \\`\\`\\`\n "]);return tS=function(){return e},e}function tz(e){return e.description?e.description:"_(no description)_"}var tR=t(21114),tE=t(52777);let tT=e=>{let{value:n,onChange:t,onRun:l,onRunBase:r,onRunDiff:a,label:c,options:d={},...u}=e;return(0,i.jsxs)(i.Fragment,{children:[(c||l||r)&&(0,i.jsxs)(o.k,{backgroundColor:"#EDF2F880",height:"40px",fontSize:"14px",align:"center",margin:"0",padding:"0px 16px",children:[(0,i.jsx)(ei.x,{as:"b",children:c?c.toUpperCase():""}),(0,i.jsx)(h.L,{}),(l||r)&&(0,i.jsx)(er.z,{size:"sm",variant:"outline",onClick:l||r,backgroundColor:"white",leftIcon:(0,i.jsx)(s.J,{as:tx.gmG}),padding:"6px 12px",children:"Run Query"})]}),(0,i.jsx)(tE.ML,{language:"sql",theme:"vs",value:n,onChange:e=>{void 0!==e&&t&&t(e)},onMount:(e,n)=>{l&&e.addCommand(n.KeyMod.CtrlCmd|n.KeyCode.Enter,l),r&&e.addCommand(n.KeyMod.Alt|n.KeyCode.Enter,r),a&&e.addCommand(n.KeyMod.CtrlCmd|n.KeyMod.Shift|n.KeyCode.Enter,a)},options:{tabSize:2,fontSize:16,lineNumbers:"on",automaticLayout:!0,minimap:{enabled:!1},wordWrap:"on",wrappingIndent:"indent",...d}})]})},tD=e=>{let{value:n,baseValue:t,onChange:l,onChangeBase:r,onRun:s,onRunBase:a,onRunDiff:c,options:d={},...u}=e;return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(o.k,{height:"100%",gap:0,children:[(0,i.jsx)(tR.K,{height:"100%",width:"50%",gap:0,borderRight:"1px",borderColor:"#D4DBE4",children:(0,i.jsx)(tT,{label:"Base",value:t||"",onChange:r,onRunBase:a,options:d,...u})}),(0,i.jsx)(tR.K,{height:"100%",width:"50%",gap:0,children:(0,i.jsx)(tT,{label:"Current",value:n,onChange:l,onRun:s,options:d,...u})})]})})};var tL=t(13601),tI=t(51418);let tM=(0,eI.G)((e,n)=>{var t,r,s,a;let{isRunning:c,isAborting:d,progress:u,error:h,run:x,onCancel:m,viewOptions:p,onViewOptionsChanged:f,RunResultView:g,children:v,onExecuteRun:j}=e,y=(null==h?void 0:null===(r=h.response)||void 0===r?void 0:null===(t=r.data)||void 0===t?void 0:t.detail)||(null==x?void 0:x.error);if(y)return(0,i.jsxs)(tl.b,{status:"error",children:[(0,i.jsx)(tr.z,{}),"Error: ",y]});if(void 0!==c?c:(null==x?void 0:x.status)==="running"){let e=(null==u?void 0:u.message)?null==u?void 0:u.message:(null==x?void 0:null===(s=x.progress)||void 0===s?void 0:s.message)?null==x?void 0:null===(a=x.progress)||void 0===a?void 0:a.message:"Loading...";return(0,i.jsx)(eZ.M,{p:"16px",height:"100%",bg:"rgb(249,249,249)",children:(0,i.jsxs)(ne.g,{children:[(0,i.jsxs)(o.k,{alignItems:"center",children:[(null==u?void 0:u.percentage)===void 0||(null==u?void 0:u.percentage)===null?(0,i.jsx)(tL.D,{isIndeterminate:!0,size:"20px",mr:"8px"}):(0,i.jsx)(tL.D,{size:"20px",value:100*u.percentage,mr:"8px"}),d?(0,i.jsx)(i.Fragment,{children:"Aborting..."}):(0,i.jsx)(i.Fragment,{children:e})]}),!d&&(0,i.jsx)(er.z,{onClick:m,colorScheme:"blue",size:"sm",children:"Cancel"})]})})}if(!x)return(0,i.jsx)(eZ.M,{bg:"rgb(249,249,249)",height:"100%",children:"Loading..."});if(v&&g)throw Error("RunView requires either a children or a RunResultView prop, but not both.");if(!v&&!g)throw Error("RunView requires at least one of children or RunResultView prop.");return(0,i.jsxs)(l.x,{h:"100%",style:{contain:"size layout"},overflow:"auto",children:[g&&(x.error||x.result)&&(0,i.jsx)(tI.SV,{children:(0,i.jsx)(g,{ref:n,run:x,viewOptions:p,onViewOptionsChanged:f})}),v&&v({run:x,viewOptions:p,onViewOptionsChanged:f})]})});var tO=t(27066),tA=t(13587),tF=t(9312),tN=t(94945),tq=t(52811),tV=t(14033);t(94254),t(76890);var tH=t(47691),tP=t(34433),tW=t(73676),tK=t(84492);function tJ(e){let{node:n}=e,{icon:t}=tv(n.resourceType);return(0,i.jsx)(nh.u,{hasArrow:!0,label:"Type of resource",children:(0,i.jsxs)(nQ.Vp,{children:[(0,i.jsx)(nQ.AD,{as:t}),(0,i.jsx)(nQ.Sn,{children:n.resourceType})]})})}function tB(e){let{rowCount:n}=e,t=n.base,l=n.curr,r=null===n.base?"N/A":"".concat(n.base," rows"),o=null===n.curr?"N/A":"".concat(n.curr," rows");return null===t&&null===l?(0,i.jsx)(i.Fragment,{children:" Failed to load"}):null===t||null===l?(0,i.jsxs)(u.U,{children:[(0,i.jsx)(ei.x,{children:r}),(0,i.jsx)(s.J,{as:tW.Rgz}),(0,i.jsx)(ei.x,{children:o})]}):t===l?(0,i.jsxs)(u.U,{children:[(0,i.jsx)(ei.x,{children:o}),(0,i.jsx)(s.J,{as:tK.lxc,color:"gray.500"}),(0,i.jsx)(ei.x,{color:"gray.500",children:"No Change"})]}):t ").concat(n," rows")}return(0,i.jsx)(nh.u,{label:r,children:(0,i.jsxs)(nQ.Vp,{children:[(0,i.jsx)(nQ.AD,{as:x}),(0,i.jsx)(nQ.Sn,{children:m||c?(0,i.jsx)(tP.N,{isLoaded:!c,noOfLines:1,skeletonHeight:2,minWidth:"30px",children:m?(0,i.jsx)(tB,{rowCount:m}):"row count"}):(0,i.jsx)(i.Fragment,{children:"row count"})}),a&&(0,i.jsx)(nQ.bq,{as:nS.h,isLoading:c,"aria-label":"Query Row Count",icon:(0,i.jsx)(n5.n,{}),size:"xs",onClick:a})]})})}let tZ=e=>{let{node:n,action:t}=e,{status:r,skipReason:s,run:a}=t;if("pending"===r)return(0,i.jsx)(tL.D,{size:"20px",value:0});if("skipped"===r)return(0,i.jsx)(nQ.Vp,{backgroundColor:"gray.100",children:(0,i.jsxs)(o.k,{fontSize:"10pt",color:"gray.500",alignItems:"center",gap:"3px",children:[(0,i.jsx)(l.x,{children:"Skipped"}),s&&(0,i.jsx)(nh.u,{label:s,children:(0,i.jsx)(tH.s,{})})]})});if(!a)return(0,i.jsx)(tL.D,{isIndeterminate:!0,size:"20px"});let{error:c,result:d,run_id:u,progress:h}=a;if("running"===r)return(null==h?void 0:h.percentage)===void 0?(0,i.jsx)(tL.D,{isIndeterminate:!0,size:"20px"}):(0,i.jsx)(tL.D,{size:"20px",value:(null==h?void 0:h.percentage)*100});if(c)return(0,i.jsxs)(o.k,{fontSize:"10pt",color:"gray",children:[(0,i.jsx)(l.x,{children:"Error"}),s&&(0,i.jsx)(nh.u,{label:c,children:(0,i.jsx)(e7.a,{})})]});if("value_diff"===a.type){let e=0;for(let n of d.data.data)n[2]<1&&e++;return(0,i.jsx)(nQ.Vp,{backgroundColor:e>0?"red.100":"green.100",children:(0,i.jsx)(nQ.Sn,{children:(0,i.jsx)(o.k,{fontSize:"10pt",color:e>0?"red":"green",alignItems:"center",gap:"3px",children:e>0?"".concat(e," columns mismatched"):"All columns match"})})})}if("row_count_diff"===a.type){let e=a.result;return(0,i.jsx)(tU,{rowCount:e[n.name],node:n})}return(0,i.jsx)(i.Fragment,{children:u})},tQ=(0,j.createContext)(void 0),tX=()=>{let e=(0,j.useContext)(tQ);if(!e)throw Error("useLineageViewContext must be used within a LineageViewProvider");return e},tG=e=>{var n,t,r,a;let c,d,{id:u,inverted:h}=e,{lineageGraph:x,runsAggregated:m}=eg(),p=null==m?void 0:m[u],f=null==x?void 0:x.nodes[u];if(!p&&!f)return(0,i.jsx)(i.Fragment,{});if((null==f?void 0:f.data.base)&&(null==f?void 0:f.data.current)&&(c=tj(null===(r=f.data.base)||void 0===r?void 0:r.columns,null===(a=f.data.current)||void 0===a?void 0:a.columns)),p&&p.row_count_diff){let e=p.row_count_diff;d=e.result.curr!==e.result.base}let g=h?"white":tg("modified").color,v=h?"gray":"lightgray";return(0,i.jsxs)(o.k,{gap:"5px",children:[void 0!==c&&(0,i.jsx)(nh.u,{label:"Schema (".concat(c?"changed":"no change",")"),openDelay:500,children:(0,i.jsx)(l.x,{height:"16px",children:(0,i.jsx)(s.J,{as:null===(n=nO("schema_diff"))||void 0===n?void 0:n.icon,color:c?g:v})})}),void 0!==d&&(0,i.jsx)(nh.u,{label:"Row count (".concat(d?"changed":"no change",")"),openDelay:500,children:(0,i.jsx)(l.x,{height:"16px",children:(0,i.jsx)(s.J,{as:null===(t=nO("row_count_diff"))||void 0===t?void 0:t.icon,color:d?g:v})})})]})},tY=e=>{let{checked:n,onClick:t}=e;return(0,i.jsx)(o.k,{onClick:t,alignSelf:"center",alignItems:"center",children:n?(0,i.jsx)(s.J,{boxSize:"20px",as:th.xik}):(0,i.jsx)(s.J,{boxSize:"20px",as:th.hGI})})};var t$=t(70952),t0=t(44549),t1=t(27739);function t5(e){let{base:n,current:t}=e;return(0,i.jsx)(tE.SV,{height:"100%",language:"sql",theme:"vs",original:null==n?void 0:n.raw_code,modified:null==t?void 0:t.raw_code,options:{readOnly:!0,fontSize:14,lineNumbers:"on",automaticLayout:!0,minimap:{enabled:!1},wordWrap:"on",wrappingIndent:"same"}})}function t2(e){let{current:n,onChange:t}=e,r=function(e,n){let t=(0,j.useRef)(null);return(0,j.useEffect)(()=>{t.current&&e!==t.current.getValue()&&t.current.setValue(e)},[e]),{onMount(e){let i=e.getModifiedEditor();t.current=i,i.onDidChangeModelContent(()=>{n(i.getValue())})}}}((null==n?void 0:n.raw_code)||"",t);return(0,i.jsx)(l.x,{flex:1,overflowY:"auto",children:(0,i.jsx)(tE.SV,{language:"sql",theme:"vs",original:null==n?void 0:n.raw_code,modified:null==n?void 0:n.raw_code,options:{readOnly:!1,fontSize:14,lineNumbers:"on",automaticLayout:!0,wordWrap:"on",wrappingIndent:"same",renderOverviewRuler:!1,minimap:{enabled:!0}},onMount:r.onMount})})}async function t4(e){return(await U.post("/api/checks",{type:"schema_diff",params:e})).data}let t6={audit_helper:"Require the dbt package 'dbt-labs/audit_helper'. Please install it and re-run dbt to activate this feature.",dbt_profiler:"Require the dbt package 'data-mie/dbt_profiler'. Please install it and re-run dbt to activate this feature.",add_or_remove:"Unavailable for added or removed resources."},t3=e=>{var n;let[t,i]=(0,j.useState)(!1),[l,r]=(0,j.useState)(!1),[,s]=ev(),{error:o,data:a}=(0,y.a)({queryKey:P.run(e||""),queryFn:async()=>ec(e||"",t?2:0),enabled:!!e,refetchInterval:!!t&&50,retry:!1});(0,j.useEffect)(()=>{(o||(null==a?void 0:a.result)||(null==a?void 0:a.error))&&(t&&i(!1),(null==a?void 0:a.type)==="row_count_diff"&&s()),(null==a?void 0:a.status)==="running"&&i(!0)},[a,o,t,s]);let c=(0,j.useCallback)(async()=>{if(r(!0),e)return await ed(e)},[e,r]),d=(null==a?void 0:a.type)?null===(n=nO(a.type))||void 0===n?void 0:n.RunResultView:void 0;return{run:a,isRunning:t,aborting:l,error:o,onCancel:c,RunResultView:d}};var t9=t(30671),t8=t(33686),t7=t(32717),ie=t.n(t7),it=t(21467),ii=t(93779),il=t(30745),ir=t.n(il);let is="ignore-screenshot";function io(e){let{renderLibrary:n="html2canvas",imageType:t="png",backgroundColor:l=null,boardEffect:r=!0,shadowEffect:s=!1,borderStyle:c="solid 1px #ccc",borderRadius:d="10px",onSuccess:u,onError:h,ignoreElements:x}=e,[m,p]=(0,j.useState)("idle"),f=(0,j.useRef)(null),{onOpen:g,setImgBlob:v,ImageDownloadModal:y}=function(){let{isOpen:e,onOpen:n,onClose:t}=(0,eb.q)(),[l,r]=(0,j.useState)();return{onOpen:n,setImgBlob:r,ImageDownloadModal:function(){let[n,r]=(0,j.useState)();return(0,j.useEffect)(()=>{if(!l)return;let e=new FileReader;e.readAsDataURL(l),e.onloadend=e=>{var n,t;(null===(n=e.target)||void 0===n?void 0:n.result)&&(null===(t=e.target)||void 0===t?void 0:t.result)!==null&&r(e.target.result)}},[r]),(0,i.jsxs)(Y.u_,{size:"3xl",isOpen:e,onClose:t,children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{children:[(0,i.jsx)(en.x,{children:"Screenshot Preview"}),(0,i.jsx)(ej.o,{}),(0,i.jsxs)(et.f,{children:[(0,i.jsxs)(o.k,{px:"10px",gap:"10px",direction:"column",children:[(0,i.jsxs)(o.k,{alignItems:"center",gap:"5px",children:[(0,i.jsx)(tH.s,{color:"red.600"}),(0,i.jsx)(ei.x,{fontWeight:"500",display:"inline",children:"Copy to the Clipboard"})," ","is not supported in the current browser"]}),(0,i.jsx)(ei.x,{children:"Please download it directly"})]}),(0,i.jsx)(a.E,{src:n,alt:"screenshot"})]}),(0,i.jsxs)(el.m,{children:[(0,i.jsx)(er.z,{mr:3,onClick:t,children:"Close"}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>{if(!l)return;let e=new Date,n="recce-screenshot-".concat((0,ii.WU)(e,"yyyy-MM-dd-HH-mm-ss"),".png");ir()(l,n),t()},children:"Download"})]})]})]})}}}(),b=async()=>{if(!f.current)throw console.error("No node to use for screenshot"),Error("No node to use for screenshot");let e=f.current.element||f.current,t=e.style.overflow,i=e.style.border,o=e.style.borderRadius,a=e.style.backgroundColor,u=e.style.height;try{var h;e.style.overflow="hidden",e.style.border=r?c:"",e.style.borderRadius=r?d:"",e.style.backgroundColor=l||"",e.style.height=e.offsetHeight+"px";let t=document.createElement("style");document.head.appendChild(t),null===(h=t.sheet)||void 0===h||h.insertRule("body > div:last-child img { display: inline-block; }"),p("loading");let i="html2canvas"===n?await ie()(e,{logging:!1,backgroundColor:null,ignoreElements:x}):await (0,it.rT)(e,{filter:x?e=>!x(e):void 0});t.remove();let o=s?document.createElement("canvas"):i;if(s){o.width=i.width+80,o.height=i.height+80;let e=o.getContext("2d");if(e)e.shadowColor="rgba(0, 0, 0, 0.5)",e.shadowBlur=20,e.shadowOffsetX=10,e.shadowOffsetY=10,e.drawImage(i,40,40);else throw console.error("Error getting canvas context"),Error("Error getting canvas context to add shadow effect")}let a=await fetch(o.toDataURL());return await a.blob()}catch(e){throw console.error("Error converting to image",e),e}finally{e.style.overflow=t,e.style.border=i,e.style.borderRadius=o,e.style.backgroundColor=a,e.style.height=u}};return{status:m,isLoading:"loading"===m,isErrored:"error"===m,isSuccess:"success"===m,copyToClipboard:async()=>{try{await navigator.clipboard.write([new ClipboardItem({["image/".concat(t)]:b()})]),p("success"),u&&u()}catch(e){"ClipboardItem is not defined"===e.message?(v(await b()),g(),p("success")):(p("error"),console.error("Error copying to clipboard",e),h&&h(e))}},ImageDownloadModal:y,ref:f}}function ia(e){let{successToast:n,failToast:t}=t_(),{isLoading:l,copyToClipboard:r,ImageDownloadModal:s,ref:o}=io({imageType:"png",shadowEffect:!0,backgroundColor:(null==e?void 0:e.backgroundColor)||null,onSuccess:()=>{n("Copied the query result as an image to clipboard")},onError:e=>{console.error("Error taking screenshot",e),t("Failed to copy image to clipboard",e)}}),a=(0,j.useCallback)(()=>{if(o.current){let e=o.current.element||o.current;e.style.boxShadow="rgba(0, 0, 0, 0.25) 0px 54px 55px, rgba(0, 0, 0, 0.12) 0px -12px 30px, rgba(0, 0, 0, 0.12) 0px 4px 6px, rgba(0, 0, 0, 0.17) 0px 12px 13px, rgba(0, 0, 0, 0.09) 0px -3px 5px",e.style.transition="box-shadow 0.5s ease-in-out"}},[o]),c=(0,j.useCallback)(()=>{o.current&&((o.current.element||o.current).style.boxShadow="")},[o]),d=(0,j.useCallback)(async()=>{o.current?(await r(),(o.current.element||o.current).style.boxShadow=""):t("Failed to copy image to clipboard","No content to copy")},[o,r,t]);return{ref:o,CopyToClipboardButton:function(e){let{imageType:n="png",...t}=e;return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(er.z,{size:"sm",leftIcon:(0,i.jsx)(n0.T,{}),style:{position:"absolute",bottom:"16px",right:"16px"},isLoading:l,onMouseEnter:a,onMouseLeave:c,onClick:d,children:"Copy to Clipboard"}),(0,i.jsx)(s,{})]})},onMouseEnter:a,onMouseLeave:c,onCopyToClipboard:d}}let ic=e=>{let{run:n}=e,t=(null==n?void 0:n.status)==="running",l=null==n?void 0:n.status;!l&&(n.result?l="finished":n.error&&(l="failed"));let r="",s="";"successful"===l||"finished"===l?(r="green",s="Finished"):"failed"===l?(r="red",s="Failed"):"cancelled"===l?(r="gray",s="Cancelled"):"running"===l?(r="blue",s="Running"):(r="green",s="Finished");let a=(null==n?void 0:n.run_at)?function(e){let n=new Date,t=new Date;return(t.setDate(n.getDate()-1),null==e)?null:n.toDateString()===e.toDateString()?"Today, "+(0,ii.WU)(e,"HH:mm"):t.toDateString()===e.toDateString()?"Yesterday, "+(0,ii.WU)(e,"HH:mm"):(0,ii.WU)(e,"MMM d, HH:mm")}(new Date(n.run_at)):null;return(0,i.jsxs)(o.k,{justifyContent:"start",fontSize:"11pt",color:"gray.500",gap:"3px",alignItems:"center",overflow:"hidden",children:[t&&(0,i.jsx)(tA.$,{size:"xs",color:"".concat(r,".400")}),(0,i.jsx)(ei.x,{fontWeight:500,color:"".concat(r,".400"),children:s}),(0,i.jsx)(ei.x,{children:"•"}),(0,i.jsx)(ei.x,{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",children:a})]})},id=e=>{let n=t9.ZP.stringify(e,null,2);return(0,i.jsx)(tE.ML,{height:"100%",language:"yaml",theme:"vs",value:n,options:{readOnly:!0,fontSize:14,lineNumbers:"off",automaticLayout:!0,minimap:{enabled:!1},wordWrap:"on",wrappingIndent:"same",scrollBeyondLastLine:!1}})},iu=e=>{var n,t,l;let{runId:r,onClose:s,disableAddToChecklist:a}=e,{runAction:c}=nq(),{error:d,run:f,onCancel:g,isRunning:v}=t3(r),[y,w]=(0,j.useState)(),k=(0,b.NL)(),[,C]=(0,ew.TH)(),[_,S]=(0,j.useState)(0),z=(null==f?void 0:f.type)?null===(n=nO(f.type))||void 0===n?void 0:n.RunResultView:void 0,R=(0,j.useCallback)(()=>{c((null==f?void 0:f.type)||"",null==f?void 0:f.params)},[f,c]),E=null==f?void 0:f.check_id,T=(0,j.useCallback)(async()=>{E&&C("/checks/".concat(E))},[E,C]),D=(0,j.useCallback)(async()=>{if(!r)return;let e=await nP(r,y);k.invalidateQueries({queryKey:P.checks()}),C("/checks/".concat(e.check_id))},[r,C,k,y]),L=(null==f?void 0:f.type)==="query"||(null==f?void 0:f.type)==="query_diff"||(null==f?void 0:f.type)==="query_base",{ref:I,onCopyToClipboard:M,onMouseEnter:O,onMouseLeave:A}=ia();return(0,i.jsxs)(o.k,{direction:"column",children:[(0,i.jsx)(x.m,{tabIndex:_,onChange:S,flexDirection:"column",mb:"1px",children:(0,i.jsxs)(m.t,{height:"50px",children:[(0,i.jsx)(p.O,{children:"Result"}),(0,i.jsx)(p.O,{children:"Params"}),L&&(0,i.jsx)(p.O,{children:"Query"}),(0,i.jsx)(h.L,{}),(0,i.jsxs)(u.U,{overflow:"hidden",children:[f&&(0,i.jsx)(ic,{run:f}),(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(n5.n,{}),variant:"outline",isDisabled:!r||v,size:"sm",onClick:R,children:"Rerun"}),(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(n0.T,{}),variant:"outline",isDisabled:!r||!(null==f?void 0:f.result)||!!d||0!==_,onMouseEnter:O,onMouseLeave:A,size:"sm",onClick:M,children:"Copy to Clipboard"}),(0,i.jsx)(function(){return a?(0,i.jsx)(i.Fragment,{}):(null==f?void 0:f.check_id)?(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(t8.n,{}),isDisabled:!r||!(null==f?void 0:f.result)||!!d,size:"sm",colorScheme:"blue",onClick:T,children:"Go to Check"}):(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(t8.n,{}),isDisabled:!r||!(null==f?void 0:f.result)||!!d,size:"sm",colorScheme:"blue",onClick:D,children:"Add to Checklist"})},{}),(0,i.jsx)(t1.P,{onClick:()=>{s&&s()}})]})]})}),0===_&&(0,i.jsx)(tM,{ref:I,error:d,run:f,onCancel:g,viewOptions:y,onViewOptionsChanged:w,RunResultView:z}),1===_&&f&&(0,i.jsx)(id,{type:f.type,params:f.params}),2===_&&f&&((null===(t=f.params)||void 0===t?void 0:t.base_sql_template)?(0,i.jsx)(tD,{value:f.params.sql_template,baseValue:f.params.base_sql_template,options:{readOnly:!0}}):(0,i.jsx)(tT,{value:(null==f?void 0:null===(l=f.params)||void 0===l?void 0:l.sql_template)||"",options:{readOnly:!0}}))]})},ih=e=>{let{onClose:n,disableAddToChecklist:t}=e,{runId:l}=nq();return(0,i.jsx)(iu,{runId:l,onClose:n,disableAddToChecklist:t})};async function ix(e,n){return await ea("query",e,n)}async function im(e,n){return await ea("query_base",e,n)}async function ip(e,n){return await ea("query_diff",e,n)}var ig=t(98834),iv=t(43800),ij=t(33517);let iy=e=>{var n;let{defaultValues:t,suggestionList:l,onValuesChange:r,isDisabled:s}=e,[o,a]=(0,j.useState)(t||[]),[c,d]=(0,j.useState)(""),[u,h]=(0,j.useState)(!1),x=(0,j.useRef)(null),m=e=>{o.includes(e)||(d(""),a([...o,e]),r([...o,e]))};return s?(0,i.jsx)(nh.u,{label:t6.audit_helper,children:(0,i.jsx)(nb.I,{size:"xs",disabled:!0,placeholder:"Unavailable"})}):(0,i.jsxs)(ig.B,{size:e.size,width:e.width,children:[(0,i.jsxs)(nC.v,{isLazy:!0,closeOnSelect:!1,onOpen:()=>{var e;return null==x?void 0:null===(e=x.current)||void 0===e?void 0:e.focus()},children:[(0,i.jsx)(n_.j,{width:"100%",children:(0,i.jsx)(nb.I,{placeholder:e.placeholder,size:e.size,borderRadius:"4px",value:o.length>1?"".concat(o.length," ").concat(e.unitName,"s selected"):1===o.length?"".concat(o[0]):"",onChange:()=>{},backgroundColor:"white"})}),(0,i.jsx)(tn.h,{children:(0,i.jsxs)(nz.q,{zIndex:"popover",fontSize:e.size,width:e.width,children:[(0,i.jsx)(nR.k,{children:(0,i.jsxs)(iv.E,{border:"1px solid #e2e8f0",borderRadius:"4px",width:"calc(100% - 8px)",marginX:"4px",padding:"4px",children:[o.map((n,t)=>(0,i.jsx)(iv.U,{children:(0,i.jsxs)(nQ.Vp,{size:e.size,children:[(0,i.jsx)(nQ.Sn,{paddingLeft:"8px",children:n}),(0,i.jsx)(nQ.SD,{paddingRight:"8px",onClick:()=>{a(o.filter(e=>e!==n)),r(o.filter(e=>e!==n))}})]},n)},"tag-".concat(t))),(0,i.jsx)(iv.U,{width:"100%",children:(0,i.jsx)(nb.I,{ref:x,placeholder:"Filter keys or add custom",variant:"unstyled",size:e.size,value:c,onChange:e=>{d(e.target.value),h(!0)},onKeyDown:e=>{let n=e.currentTarget.value.trim().replace(",","");switch(e.key){case",":case"Enter":m(n),d("");break;case"Backspace":""===e.currentTarget.value&&o.length>0&&(a(o.slice(0,-1)),r(o.slice(0,-1)))}},onBlur:()=>{var e;x&&u&&(null==x||null===(e=x.current)||void 0===e||e.focus())}})})]})}),(0,i.jsx)(nX.R,{}),(0,i.jsxs)(nR.k,{children:[""!==c&&!(null==l?void 0:l.includes(c))&&(0,i.jsxs)(nE.s,{onClick:()=>{m(c),h(!1)},children:["Add '",c,"' to the list"]},"custom-value-by-filter"),null==l?void 0:null===(n=l.filter(e=>""===c||e.includes(c)).filter(e=>!o.includes(e)))||void 0===n?void 0:n.map((e,n)=>(0,i.jsx)(nE.s,{onClick:()=>m(e),children:e},"option-".concat(n)))]})]})})]}),(0,i.jsx)(ij.x,{children:(0,i.jsx)(er.z,{variant:"link",color:"#3182CE",fontSize:e.size,paddingTop:"4px",paddingRight:"24px",hidden:0===o.length,onClick:()=>{d(""),a([]),r([])},children:"Clear"})})]})},ib=e=>{let{defaultPrimaryKeys:n,onPrimaryKeysChange:t,...l}=e,{lineageGraph:r,isActionAvailable:s}=eg(),a=(0,j.useMemo)(()=>{if(!r)return[];let e=new Set;for(let i in r.nodes){var n,t;let l=r.nodes[i],s=null===(n=l.data.base)||void 0===n?void 0:n.columns,o=null===(t=l.data.current)||void 0===t?void 0:t.columns;for(let n in s)e.add(n);for(let n in o)e.add(n)}return Array.from(e).sort()},[r]);return(0,i.jsx)(o.k,{...l,children:(0,i.jsxs)(eC.NI,{m:"4px 8px",children:[(0,i.jsxs)(e_.l,{fontSize:"8pt",margin:"0",children:["Diff with Primary Key(s) (suggested)"," ",(0,i.jsx)(nh.u,{label:"Provide a primary key to perform query diff in data warehouse and only return changed rows.",placement:"bottom-end",children:(0,i.jsx)(tH.s,{color:"gray.600",boxSize:"3"})})]}),(0,i.jsx)(iy,{unitName:"key",defaultValues:n,suggestionList:a,onValuesChange:t,size:"xs",width:"240px",placeholder:"Start by typing key name...",isDisabled:!s("query_diff_with_primary_key")})]})})};var iw=t(58631),ik=t(26969);function iC(e){let{description:n,onLike:t,onDislike:l,onClickLink:s,externalLink:c,externalLinkText:d}=e;return(0,i.jsxs)(o.k,{gap:4,justifyContent:"center",alignContent:"center",alignItems:"center",children:[n,(0,i.jsx)(nS.h,{"aria-label":"thumbs up",variant:"ghost",icon:(0,i.jsx)(a.E,{src:"/imgs/feedback/thumbs-up.png",alt:"like"}),width:"32px",height:"32px",onClick:t}),(0,i.jsx)(nS.h,{"aria-label":"thumbs down",variant:"ghost",icon:(0,i.jsx)(a.E,{src:"/imgs/feedback/thumbs-down.png",alt:"dislike"}),width:"32px",height:"32px",onClick:l}),c&&d&&(0,i.jsx)(r.r,{href:c,isExternal:!0,textDecoration:"underline",onClick:s,children:d})]})}let i_="recce-",iS={bypassSaveOverwrite:"".concat(i_,"-bypass-save-overwrite"),previewChangeFeedbackID:"".concat(i_,"-preview-change-feedback")};var iz=t(16564),iR=t(38674);function iE(e){iz.j("[Web] multi_nodes_action",e)}function iT(e){iz.j("[Web] history_action",e)}function iD(e){iz.j("[Experiment] preview_change",e)}function iL(e){iz.j("[Experiment] preview_change",e)}function iI(e){let{current:n,primaryKeys:t,setPrimaryKeys:r,onRunResultOpen:a,runQuery:d,isPending:u,feedbackToast:x}=e;return(0,i.jsxs)(o.k,{justifyContent:"right",alignItems:"center",padding:"4pt 8pt",gap:"5px",height:"54px",borderBottom:"1px solid lightgray",flex:"0 0 54px",children:[(0,i.jsxs)(l.x,{children:[(0,i.jsxs)(c.X,{as:"h2",size:"md",display:"flex",alignItems:"center",gap:"5px",children:[(0,i.jsx)(s.J,{as:iw.vc4,boxSize:"1.2em"}),"Preview Changes"]}),(0,i.jsxs)(ei.x,{fontSize:"xs",color:"gray.500",children:["Compare the run results based on the modified SQL code of model"," ",(0,i.jsx)("b",{children:null==n?void 0:n.name})]})]}),(0,i.jsx)(h.L,{}),(0,i.jsx)(ib,{defaultPrimaryKeys:t,onPrimaryKeysChange:r}),(0,i.jsx)(nh.u,{label:"Run diff to see the changes",children:(0,i.jsx)(er.z,{size:"xs",marginTop:"16px",fontSize:"14px",onClick:()=>{a(),d(),setTimeout(()=>x(),3e3)},colorScheme:"blue",isLoading:u,children:"Run Diff"})})]})}function iM(e){let{height:n="32px",flex:t="0 0 auto"}=e,l="0 16px";return(0,i.jsxs)(o.k,{gap:0,height:n,flex:t,fontSize:"14px",align:"center",margin:"0",backgroundColor:"#EDF2F880",children:[(0,i.jsx)(tR.K,{width:"50%",children:(0,i.jsx)(ei.x,{as:"b",margin:l,children:"CURRENT"})}),(0,i.jsx)(tR.K,{width:"50%",children:(0,i.jsx)(ei.x,{as:"b",margin:l,children:"PREVIEW EDITOR"})})]})}function iO(e){let{isOpen:n,onClose:t,current:r}=e,{isOpen:s,onClose:h,onOpen:x}=(0,eb.q)(),[m,p]=(0,j.useState)((null==r?void 0:r.raw_code)||""),{showRunId:f,clearRunResult:g}=nq(),{primaryKeys:v,setPrimaryKeys:y}=_(),b=async()=>{let e={current_model:(null==r?void 0:r.name)||"",primary_keys:v,sql_template:m},{run_id:n}=await ip(e,{nowait:!0});return f(n),await ec(n)},{mutate:w,isPending:k}=(0,te.D)({mutationFn:b,onSuccess(e,n){e.error?iD({action:"run",node:null==r?void 0:r.name,status:"failure"}):iD({action:"run",node:null==r?void 0:r.name,status:"success"})}}),{feedbackToast:C,closeToast:S}=function(e){let n=(0,G.p)(),{feedbackId:t,description:l,onFeedbackSubmit:r,externalLink:s,externalLinkText:o}=e;return{feedbackToast:function(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],a=localStorage.getItem(t);n.isActive(t)||"true"===a&&!1===e||n({id:t,position:"bottom-right",duration:null,render:e=>{let{id:a,onClose:c}=e;return(0,i.jsx)(tl.b,{status:"success",variant:"subtle",zIndex:"toast",borderColor:"gray.200",borderWidth:3,borderRadius:"md",backgroundColor:"white",opacity:1,children:(0,i.jsx)(ik.X,{fontSize:"md",children:(0,i.jsxs)(u.U,{children:[(0,i.jsx)(iC,{description:l,onLike:()=>{r("like"),n.closeAll(),localStorage.setItem(t,"true")},onDislike:()=>{r("dislike"),n.closeAll(),localStorage.setItem(t,"true")},externalLink:s,externalLinkText:o,onClickLink:()=>{r("link")}}),(0,i.jsx)(t1.P,{onClick:c})]})})})}})},closeToast:()=>n.closeAll()}}({feedbackId:iS.previewChangeFeedbackID,description:"Enjoy preview change?",onFeedbackSubmit:e=>{switch(e){case"like":iL({feedback:"like",node:null==r?void 0:r.name});break;case"dislike":iL({feedback:"dislike",node:null==r?void 0:r.name});break;case"link":iL({feedback:"form",node:null==r?void 0:r.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"});return(0,j.useEffect)(()=>{n&&p((null==r?void 0:r.raw_code)||"")},[n,r]),(0,i.jsx)(Y.u_,{isOpen:n,size:"full",onClose:()=>{t(),h(),g(),S(),iD({action:"close",node:null==r?void 0:r.name})},children:(0,i.jsxs)(ee.h,{height:"100%",children:[(0,i.jsx)(en.x,{height:"40px",bg:"rgb(77, 209, 176)",px:0,py:4,children:(0,i.jsxs)(o.k,{alignItems:"center",height:"100%",gap:"10px",children:[(0,i.jsx)(a.E,{boxSize:"20px",ml:"18px",src:"/logo/recce-logo-white.png",alt:"recce-logo-white"}),(0,i.jsx)(c.X,{as:"h1",fontFamily:'"Montserrat", sans-serif',fontSize:"lg",color:"white",children:"RECCE"}),(0,i.jsx)(d.C,{fontSize:"sm",color:"white",colorScheme:"whiteAlpha",variant:"outline",children:"Experiment"})]})}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(et.f,{p:0,children:(0,i.jsxs)(td,{sizes:s?[50,50]:[100,0],minSize:s?100:0,gutterSize:s?5:0,style:{flex:"1",contain:"size",height:"100%"},children:[(0,i.jsxs)(o.k,{direction:"column",height:"100%",m:0,p:0,children:[(0,i.jsx)(iI,{current:r,primaryKeys:null!=v?v:[],setPrimaryKeys:y,onRunResultOpen:x,runQuery:w,isPending:k,feedbackToast:C}),(0,i.jsx)(iM,{height:"32pxs",flex:"0 0 auto"}),(0,i.jsx)(t2,{current:r,onChange:p})]}),s?(0,i.jsx)(ih,{onClose:h,disableAddToChecklist:!0}):(0,i.jsx)(l.x,{})]})}),(0,i.jsx)(l.x,{position:"fixed",bottom:"4",right:"4",opacity:.5,children:(0,i.jsx)(nh.u,{label:"Give us feedback",children:(0,i.jsx)(nS.h,{"aria-label":"feedback",icon:(0,i.jsx)(eY.xJq,{}),variant:"ghost",size:"md",onClick:()=>C(!0)})})})]})})}function iA(e){var n,t,r,a,d,f,g,v;let{node:y,onCloseNode:b}=e,[,w]=(0,ew.TH)(),{setSqlQuery:k,setPrimaryKeys:C}=_(),S="model"===y.resourceType||"seed"===y.resourceType||"source"===y.resourceType||"snapshot"===y.resourceType,{isOpen:z,onOpen:R,onClose:E}=(0,eb.q)(),{isOpen:T,onOpen:D,onClose:L}=(0,eb.q)(),{runAction:I}=nq(),{envInfo:M,isActionAvailable:O}=eg(),{primaryKey:A}=eT(y.name),F=()=>{I("row_count_diff",{node_names:[y.name]},{showForm:!1,showLast:!1})},N=(0,j.useCallback)(async()=>{let e=y.id,n=await t4({node_id:e});w("/checks/".concat(n.check_id))},[y,w]),q=(e,n)=>e?t6.add_or_remove:O(n)?"":"value_diff"===n?t6.audit_helper:"profile_diff"===n?t6.dbt_profiler:"This action is not supported yet.",V="added"===y.changeStatus||"removed"===y.changeStatus;return(0,i.jsxs)(t0.r,{height:"100%",templateRows:"auto auto 1fr",children:[(0,i.jsxs)(u.U,{children:[(0,i.jsx)(l.x,{flex:"0 1 20%",p:"16px",children:(0,i.jsx)(c.X,{size:"sm",children:y.name})}),(0,i.jsx)(h.L,{}),("model"===y.resourceType||"seed"===y.resourceType||"snapshot"===y.resourceType)&&(0,i.jsxs)(nC.v,{children:[(0,i.jsx)(n_.j,{as:er.z,size:"sm",colorScheme:"blue",children:"Explore Change"}),(0,i.jsxs)(nz.q,{children:[(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(n=nO("query_diff"))||void 0===n?void 0:n.icon}),fontSize:"14px",onClick:()=>{(null==M?void 0:M.adapterType)==="dbt"?k('select * from {{ ref("'.concat(y.name,'") }}')):(null==M?void 0:M.adapterType)==="sqlmesh"&&k("select * from ".concat(y.name)),O("query_diff_with_primary_key")&&C(void 0!==A?[A]:void 0),w("/query")},children:"Query"}),(0,i.jsx)(nE.s,{fontSize:"14px",icon:(0,i.jsx)(s.J,{as:null===(t=nO("preview_change"))||void 0===t?void 0:t.icon}),onClick:()=>{O("query_diff_with_primary_key")&&C(void 0!==A?[A]:void 0),D(),iD({action:"explore",node:y.name})},children:"Preview Change (Experiment)"}),(0,i.jsx)(nX.R,{}),(0,i.jsxs)(nR.k,{title:"Diff",m:"0",p:"4px 12px",children:[("model"===y.resourceType||"snapshot"===y.resourceType)&&(0,i.jsx)(nE.s,{onClick:R,icon:(0,i.jsx)(th.tvD,{}),fontSize:"14px",children:"Code Diff"}),(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(r=nO("row_count_diff"))||void 0===r?void 0:r.icon}),fontSize:"14px",onClick:()=>F(),children:"Row Count Diff"}),(0,i.jsx)(nh.u,{label:q(V,"profile_diff"),placement:"left",children:(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(a=nO("profile_diff"))||void 0===a?void 0:a.icon}),fontSize:"14px",isDisabled:V||!O("profile_diff"),onClick:()=>{I("profile_diff",{model:y.name},{showForm:!1,showLast:!1})},children:"Profile Diff"})}),(0,i.jsx)(nh.u,{label:q(V,"value_diff"),placement:"left",children:(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(d=nO("value_diff"))||void 0===d?void 0:d.icon}),fontSize:"14px",isDisabled:V||!O("value_diff"),onClick:()=>{I("value_diff",{model:y.name},{showForm:!0,showLast:!1})},children:"Value Diff"})}),(0,i.jsx)(nh.u,{label:q(V,"top_k_diff"),placement:"left",children:(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(f=nO("top_k_diff"))||void 0===f?void 0:f.icon}),fontSize:"14px",isDisabled:V,onClick:()=>{I("top_k_diff",{model:y.name,column_name:"",k:50},{showForm:!0})},children:"Top-K Diff"})}),(0,i.jsx)(nh.u,{label:q(V,"histogram_diff"),placement:"left",children:(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(g=nO("histogram_diff"))||void 0===g?void 0:g.icon}),fontSize:"14px",isDisabled:V,onClick:()=>{I("histogram_diff",{model:y.name,column_name:"",column_type:""},{showForm:!0})},children:"Histogram Diff"})})]}),(0,i.jsx)(nX.R,{}),(0,i.jsx)(nR.k,{title:"Add to Checklist",m:"0",p:"4px 12px",children:(0,i.jsx)(nE.s,{icon:(0,i.jsx)(s.J,{as:null===(v=nO("schema_diff"))||void 0===v?void 0:v.icon}),fontSize:"14px",onClick:N,children:"Schema Diff"})})]})]}),(0,i.jsx)(l.x,{flex:"0 1 1%",children:(0,i.jsx)(t1.P,{onClick:b})})]}),(0,i.jsx)(l.x,{color:"gray",paddingLeft:"16px",children:(0,i.jsxs)(u.U,{spacing:"8px",children:[(0,i.jsx)(tJ,{node:y}),("model"===y.resourceType||"snapshot"===y.resourceType||"seed"===y.resourceType)&&(0,i.jsx)(tU,{node:y,onRefresh:F})]})}),S&&(0,i.jsxs)(x.m,{overflow:"auto",as:o.k,children:[(0,i.jsx)(m.t,{children:(0,i.jsx)(p.O,{children:"Columns"})}),(0,i.jsx)(nG.n,{overflow:"auto",height:"calc(100% - 42px)",children:(0,i.jsx)(nY.x,{p:0,overflowY:"auto",height:"100%",children:(0,i.jsx)(ts,{base:y.data.base,current:y.data.current})})})]}),(0,i.jsxs)(Y.u_,{isOpen:z,onClose:E,size:"6xl",children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{overflowY:"auto",height:"75%",children:[(0,i.jsx)(en.x,{children:"Model Raw Code Diff"}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(et.f,{children:(0,i.jsx)(t5,{base:y.data.base,current:y.data.current})})]})]}),(0,i.jsx)(iO,{isOpen:T,onClose:L,current:y.data.current})]})}function iF(e){var n,t;let{onClose:r}=e,{cancel:s,actionState:o}=tX();return(0,i.jsx)(l.x,{bg:"white",rounded:"md",shadow:"dark-lg",children:(0,i.jsxs)(u.U,{p:"5px 15px",mt:"4",divider:(0,i.jsx)(tF.c,{borderColor:"gray.200"}),spacing:4,children:[(0,i.jsxs)(l.x,{fontSize:"10pt",children:["Progress: ","per_node"===o.mode?"".concat(o.completed," / ").concat(o.total):(null===(t=o.currentRun)||void 0===t?void 0:null===(n=t.progress)||void 0===n?void 0:n.percentage)?"".concat(100*o.currentRun.progress.percentage,"%"):"completed"===o.status?"100%":"0%"," ","canceled"===o.status?" (canceled)":""]}),"running"===o.status||"canceling"===o.status?(0,i.jsx)(er.z,{size:"xs",variant:"outline",onClick:s,isLoading:"canceling"===o.status,loadingText:"Canceling",children:"Cancel"}):(0,i.jsx)(u.U,{children:(0,i.jsx)(er.z,{size:"xs",variant:"outline",onClick:r,children:"Close"})})]})})}var iN=t(53388),iq=t(52346);let iV=()=>{let{isHistoryOpen:e,showHistory:n,closeHistory:t}=nq();return(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(s.J,{as:eY.M1Q}),size:"xs",variant:"outline",onClick:()=>{e?(iT({name:"hide"}),t()):(iT({name:"show"}),n())},children:e?"Hide":"Show"})},iH=e=>{let{isDisabled:n}=e,{viewOptions:t,onViewOptionsChanged:l,selectMode:r}=tX(),o=t.view_mode||"changed_models",a=e=>{l({...t,view_mode:e})};return(0,i.jsxs)(nC.v,{children:[(0,i.jsx)(n_.j,{as:er.z,minWidth:"100px",leftIcon:(0,i.jsx)(s.J,{as:tv("model").icon}),size:"xs",variant:"outline",isDisabled:n,children:"changed_models"===o?"Changed Models":"All"}),(0,i.jsxs)(nz.q,{title:"packages",children:[(0,i.jsx)(nE.s,{as:nn.X,size:"sm",isChecked:"changed_models"===o,onChange:()=>a("changed_models"),children:"Changed Models"}),(0,i.jsx)(nE.s,{as:nn.X,size:"sm",isChecked:"all"===o,onChange:()=>a("all"),children:"All"})]})]})},iP=e=>{var n,t;let{isDisabled:l}=e,{lineageGraph:r}=eg(),{viewOptions:o,onViewOptionsChanged:a}=tX(),c=new Set;for(let e of Object.values((null==r?void 0:r.nodes)||{}))e.packageName&&c.add(e.packageName);let d=null==r?void 0:null===(t=r.manifestMetadata)||void 0===t?void 0:null===(n=t.current)||void 0===n?void 0:n.project_name,u=o.packages?new Set(o.packages):d?new Set([d]):c,h=u.size===c.size,x=0===u.size,m=1===u.size?Array.from(u)[0]:h?"All Packages":x?"No Package":"".concat(u.size," Packages"),p=e=>{let n=new Set(u);n.has(e)?n.delete(e):n.add(e),a({...o,packages:Array.from(n)})};return(0,i.jsxs)(nC.v,{closeOnSelect:!1,children:[(0,i.jsx)(n_.j,{as:er.z,minWidth:"100px",leftIcon:(0,i.jsx)(s.J,{as:tW.zFh}),size:"xs",variant:"outline",isDisabled:l,children:m}),(0,i.jsx)(nz.q,{title:"packages",children:(0,i.jsxs)(nR.k,{title:"Select Packages",children:[(0,i.jsx)(nE.s,{as:nn.X,size:"sm",isIndeterminate:!h&&!x,isChecked:h,onChange:()=>{h?a({...o,packages:[]}):a({...o,packages:Array.from(c)})},children:"Select All"}),(0,i.jsx)(nX.R,{}),Array.from(c).map(e=>(0,i.jsx)(nE.s,{as:nn.X,size:"sm",isChecked:u.has(e),onChange:()=>{p(e)},children:e},e))]})})]})},iW=e=>{let[n,t]=(0,j.useState)(e.value),l=(0,j.useRef)(null);return(0,j.useEffect)(()=>{l.current&&(l.current.value=e.value)},[e.value]),(0,i.jsx)(nb.I,{ref:l,height:"24px",fontSize:"10pt",placeholder:"with selectors",isDisabled:e.isDisabled,value:n,onChange:e=>{t(e.target.value)},onKeyUp:i=>{"Enter"===i.key?e.onChange(n):"Escape"===i.key&&(i.preventDefault(),t(e.value),l.current&&l.current.blur())},onBlur:()=>t(e.value)})},iK=e=>{let{isDisabled:n}=e,{viewOptions:t,onViewOptionsChanged:l}=tX();return(0,i.jsx)(iW,{isDisabled:n,value:t.select||"",onChange:e=>{l({...t,select:e||void 0})}})},iJ=e=>{let{isDisabled:n}=e,{viewOptions:t,onViewOptionsChanged:l}=tX();return(0,i.jsx)(iW,{isDisabled:n,value:t.exclude||"",onChange:e=>{l({...t,exclude:e||void 0})}})},iB=e=>(0,i.jsxs)(l.x,{style:e.style,maxWidth:"300px",children:[(0,i.jsx)(l.x,{fontSize:"8pt",children:(null==e?void 0:e.label)||(0,i.jsx)(i.Fragment,{children:"\xa0"})}),e.children]}),iU=()=>{var e,n,t,l;let{nodes:r,deselect:o,selectMode:a,...c}=tX(),{isActionAvailable:d}=eg(),x=(0,j.useMemo)(()=>r.filter(e=>e.data.isSelected),[r]),m="single"===a&&1===x.length,p="multi"===a&&x.length>=1,f="single"===a&&0===x.length,g="single"!==a;return(0,i.jsx)(u.U,{width:"100%",padding:"4pt 8pt",children:(0,i.jsxs)(u.U,{flex:"1",children:[(0,i.jsx)(iB,{label:"History",style:{flexShrink:"1"},children:(0,i.jsx)(iV,{})}),(0,i.jsx)(iB,{label:"Mode",style:{flexShrink:"1"},children:(0,i.jsx)(iH,{isDisabled:g})}),(0,i.jsx)(iB,{label:"Package",style:{flexShrink:"1"},children:(0,i.jsx)(iP,{isDisabled:g})}),(0,i.jsx)(iB,{label:"Select",style:{flex:"100 1 auto"},children:(0,i.jsx)(iK,{isDisabled:g})}),(0,i.jsx)(iB,{label:"Exclude",style:{flex:"100 1 auto"},children:(0,i.jsx)(iJ,{isDisabled:g})}),(0,i.jsx)(h.L,{}),"multi"===a&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(iB,{label:"",style:{flexShrink:"0"},children:(0,i.jsx)(ei.x,{fontSize:"9pt",color:"gray.500",children:x.length>1?"".concat(x.length," nodes selected"):"".concat(x.length," node selected")})}),(0,i.jsx)(iB,{label:"",children:(0,i.jsx)(er.z,{variant:"outline",size:"xs",fontSize:"9pt",isDisabled:"multi"!==a,onClick:()=>{o()},children:"Deselect"})})]}),(0,i.jsx)(iB,{label:"Explore",children:(0,i.jsx)(iN.h,{isAttached:!0,variant:"outline",children:(0,i.jsxs)(nC.v,{placement:"bottom-end",children:[(0,i.jsx)(n_.j,{as:er.z,size:"xs",rightIcon:(0,i.jsx)(iq.v,{}),children:"Actions"}),(0,i.jsxs)(nz.q,{children:[(0,i.jsxs)(nR.k,{title:"Diff",m:"0",p:"4px 12px",children:[(0,i.jsx)(nE.s,{as:ei.x,size:"sm",fontSize:"10pt",isDisabled:!(f||m||p),icon:(0,i.jsx)(s.J,{as:null===(e=nO("row_count_diff"))||void 0===e?void 0:e.icon}),onClick:()=>{c.runRowCountDiff()},children:"Row Count Diff"}),(0,i.jsx)(nh.u,{label:d("value_diff")?null:t6.audit_helper,placement:"left",children:(0,i.jsx)(nE.s,{as:ei.x,size:"sm",fontSize:"10pt",isDisabled:!(f||m||p)||!d("value_diff"),icon:(0,i.jsx)(s.J,{as:null===(n=nO("value_diff"))||void 0===n?void 0:n.icon}),onClick:()=>{c.runValueDiff()},children:"Value Diff"})})]}),(0,i.jsx)(nX.R,{}),(0,i.jsxs)(nR.k,{title:"Add to Checklist",m:"0",px:"12px",children:[(0,i.jsx)(nE.s,{as:ei.x,size:"sm",fontSize:"10pt",isDisabled:!(f||p&&x.length>1),icon:(0,i.jsx)(s.J,{as:null===(t=nO("lineage_diff"))||void 0===t?void 0:t.icon}),onClick:()=>{c.addLineageDiffCheck(c.viewOptions.view_mode)},children:"Lineage Diff"}),(0,i.jsx)(nE.s,{as:ei.x,size:"sm",fontSize:"10pt",isDisabled:!(f||m||p),icon:(0,i.jsx)(s.J,{as:null===(l=nO("schema_diff"))||void 0===l?void 0:l.icon}),onClick:()=>{c.addSchemaDiffCheck()},children:"Schema Diff"})]})]})]})})})]})})};async function iZ(e){return(await U.post("/api/checks",{type:"lineage_diff",params:{},view_options:e})).data}function iQ(){return(0,i.jsx)(l.x,{bg:"white",padding:"12px",borderWidth:"1px",borderColor:"gray.200",fontSize:"sm",children:Object.entries({added:["Added","Added resource"],removed:["Removed","Removed resource"],modified:["Modified","Modified resource"]}).map(e=>{let[n,[t,l]]=e,{icon:r,color:a}=tg(n);return(0,i.jsx)(nh.u,{label:l,children:(0,i.jsxs)(o.k,{alignItems:"center",gap:"6px",marginBottom:"2px",children:[(0,i.jsx)(s.J,{color:a,as:r})," ",t]})},n)})})}var iX=t(9690);let iG={mode:"per_node",status:"pending",completed:0,total:0},iY=(e,n)=>{let{onActionStarted:t,onActionNodeUpdated:i,onActionCompleted:l}=n,r=(0,j.useRef)({...iG}).current,{showRunId:s}=nq(),o=async(n,o,a)=>{let c="multi_nodes";r.mode=c,t(),r.status="running";let d=[];for(let n of e){let e=o(n);n.isActionMode=!0,e?(n.action={mode:c,status:"skipped",skipReason:e},i(n)):(n.action={mode:c,status:"pending"},d.push(n))}let u=a(d);try{let{run_id:e}=await ea(n,u,{nowait:!0});for(s(e),r.currentRun={run_id:e},r.total=1;;){let n=await ec(e,2);r.currentRun=n;let t=n.error?"failure":n.result?"success":"running";for(let e of d)e.action={mode:c,status:t,run:n},i(e);if(n.error||n.result)break}}catch(e){}if(r.completed=1,"canceling"===r.status){r.status="canceled",l();return}r.status="completed",l()},a=async(n,s)=>{let o="per_node";for(let n of(r.mode=o,t(),r.status="running",e))n.action={mode:o,status:"pending"},i(n);for(let t of(r.completed=0,r.total=e.length,e)){let{params:e,skipReason:a}=s(t);if(t.isActionMode=!0,a)t.action={mode:o,status:"skipped",skipReason:a},i(t);else try{let{run_id:l}=await ea(n,e,{nowait:!0});for(r.currentRun={run_id:l},t.action={mode:o,status:"running"},i(t);;){let e=await ec(l,2);r.currentRun=e;let n=e.error?"failure":e.result?"success":"running";if(t.action={mode:o,status:n,run:e},i(t),e.error||e.result)break}}catch(e){}finally{r.currentRun=void 0}if(r.completed++,"canceling"===r.status){r.status="canceled",l();return}}r.status="completed",l()},c=async()=>{var e;r.status="canceling",(null===(e=r.currentRun)||void 0===e?void 0:e.run_id)&&await ed(r.currentRun.run_id)};return{actionState:r,runRowCountDiff:async()=>{let n=[];for(let t of e)"model"!==t.resourceType?(t.action={mode:"multi_nodes",status:"skipped",skipReason:"Not a model"},i(t)):n.push(t.name);await o("row_count_diff",e=>{if("model"!==e.resourceType)return"Not a model"},e=>({node_names:e.map(e=>e.name)}))},runValueDiff:async()=>{a("value_diff",e=>{var n,t;let i=null===(t=e.data)||void 0===t?void 0:null===(n=t.current)||void 0===n?void 0:n.primary_key;return i?{params:{model:e.name,primary_key:i}}:{skipReason:"No primary key found. The first unique column is used as primary key."}})},addLineageDiffCheck:async()=>{let n=e.map(e=>e.id);return await iZ({node_ids:n})},addSchemaDiffCheck:async()=>{let n;if(1===e.length)n=await t4({node_id:e[0].id});else{let t=e.map(e=>e.id);n=await t4({node_id:t})}return n},cancel:c,reset:()=>{Object.assign(r,iG)}}};var i$=t(41798),i0=function(){let{isOpen:e,onOpen:n,onClose:t}=(0,eb.q)(),[r,s]=(0,j.useState)(0),[a,c]=(0,j.useState)(),d=(0,j.useRef)(),u=(0,j.useCallback)(e=>(s(e),new Promise(e=>{c(()=>e),n()})),[n]),h=()=>{null==a||a(!1),t()};return{confirm:u,AlertDialog:(0,i.jsx)(i$.aR,{size:"xl",isOpen:e,leastDestructiveRef:d,onClose:h,children:(0,i.jsx)($.Z,{children:(0,i.jsxs)(i$._T,{children:[(0,i.jsxs)(en.x,{fontSize:"lg",fontWeight:"bold",children:["Value Diff on ",r," nodes"]}),(0,i.jsx)(et.f,{gap:"20px",as:o.k,direction:"column",children:(0,i.jsxs)(l.x,{children:["Value diff will be executed on ",r," nodes in the Lineage, which can add extra costs to your bill."]})}),(0,i.jsxs)(el.m,{children:[(0,i.jsx)(er.z,{ref:d,onClick:h,children:"Cancel"}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>{null==a||a(!0),t()},ml:3,children:"Execute"})]})]})})})}};let i1={customNode:function(e){var n,t;let{data:r}=e,{isHighlighted:a,isSelected:c,resourceType:d,changeStatus:x}=r,m=(0,R.oR)(e=>e.transform[2]>.3),{icon:p}=tv(d),[f,g]=(0,j.useState)(!1),{interactive:v,selectNodeMulti:y,selectMode:b}=tX(),{icon:w,color:k,backgroundColor:C}=x?tg(x):{icon:void 0,color:"gray.400",backgroundColor:"gray.100"},_="solid";r.isSelected;let S=null==r?void 0:r.name;return(0,i.jsx)(nh.u,{label:"model"===d?S:"".concat(S," (").concat(d,")"),placement:"top",children:(0,i.jsxs)(o.k,{width:"300px",borderColor:k,borderWidth:1,borderStyle:_,backgroundColor:m?"multi"===b?c?k:"white":"action_result"!==b?c?C:"white":r.action?c?C:k:"white":c?k:C,borderRadius:3,transition:"box-shadow 0.2s ease-in-out",padding:0,filter:"action_result"===b?(null==r?void 0:r.action)?"none":"opacity(0.2) grayscale(50%)":a||c?"none":"opacity(0.2) grayscale(50%)",onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[(0,i.jsx)(o.k,{backgroundColor:k,padding:v?"8px":"2px",borderRightWidth:1,borderColor:"multi"===b?"#00000020":k,borderStyle:_,alignItems:"top",visibility:m?"inherit":"hidden",children:v&&(0,i.jsx)(tY,{checked:"multi"===b&&c||"action_result"===b&&!!r.action,onClick:e=>{"action_result"!==b&&(e.stopPropagation(),y(r.id))}})}),(0,i.jsxs)(o.k,{flex:"1 0 auto",mx:"1",width:"100px",direction:"column",height:"60px",children:[(0,i.jsxs)(o.k,{width:"100%",textAlign:"left",fontWeight:"600",flex:"1",p:1,gap:"5px",alignItems:"center",visibility:m?"inherit":"hidden",children:[(0,i.jsx)(l.x,{flex:"1",color:"multi"===b?c?"white":"inherit":"action_result"===b&&r.action&&!c?"white":"inherit",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:S}),(0,i.jsx)(s.J,{boxSize:"16px",color:"multi"===b?c?"white":"inherit":"action_result"===b&&r.action&&!c?"white":"inherit",as:p}),w&&(0,i.jsx)(s.J,{color:"multi"===b?c?"white":k:"action_result"===b?r.action&&!c?"white":"inherit":k,as:w})]}),(0,i.jsx)(o.k,{flex:"1 0 auto",mx:"1",direction:"column",paddingBottom:"1",visibility:m?"inherit":"hidden",children:(0,i.jsxs)(u.U,{spacing:"8px",children:["action_result"!==b&&"model"===r.resourceType&&(0,i.jsx)(tG,{id:r.id,inverted:"multi"===b&&!!c}),(0,i.jsx)(h.L,{}),r.isActionMode&&(r.action?(0,i.jsx)(tZ,{node:r,action:r.action}):(0,i.jsx)(i.Fragment,{}))]})})]}),Object.keys(null!==(n=null==r?void 0:r.parents)&&void 0!==n?n:{}).length>0&&(0,i.jsx)(R.HH,{type:"target",position:R.Ly.Left,isConnectable:!1}),Object.keys(null!==(t=null==r?void 0:r.children)&&void 0!==t?t:{}).length>0&&(0,i.jsx)(R.HH,{type:"source",position:R.Ly.Right,isConnectable:!1})]})})}},i5={customEdge:function(e){let{sourceX:n,sourceY:t,targetX:l,targetY:r,sourcePosition:s,targetPosition:o,style:a={},markerEnd:c,data:d}=e,u={...a};(null==d?void 0:d.changeStatus)&&(u.stroke=tg(null==d?void 0:d.changeStatus).color,u.strokeDasharray="5"),(null==d?void 0:d.isHighlighted)===!1&&(u.filter="opacity(0.2) grayscale(50%)");let[h]=(0,R.OQ)({sourceX:n,sourceY:t,sourcePosition:s,targetX:l,targetY:r,targetPosition:o});return(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(R.u5,{path:h,markerEnd:c,style:{...u,...a}})})}},i2=e=>{var n,t;return(null==e?void 0:null===(n=e.data)||void 0===n?void 0:n.changeStatus)?tg(null==e?void 0:null===(t=e.data)||void 0===t?void 0:t.changeStatus).color:"lightgray"},i4=(e,n)=>{let t=null==e?void 0:e.current,i=(0,j.useRef)({width:0,height:0});(0,j.useEffect)(()=>{let e=new ResizeObserver(e=>{for(let t of e){let e=t.contentRect.width,l=t.contentRect.height;(Math.abs(l-i.current.height)>10||Math.abs(e-i.current.width)>10)&&i.current.height>0&&l>0&&i.current.width>0&&e>0&&n(),i.current={width:e,height:l}}});return t&&e.observe(t),()=>{t&&e.unobserve(t)}},[t,i,n])},i6=()=>{let[,e]=(0,ew.TH)();return(0,j.useCallback)(n=>{n.check_id&&e("/checks/".concat(n.check_id))},[e])},i3=(0,j.forwardRef)(function(e,n){var t,r;let{interactive:a=!1,...c}=e,d=(0,R._K)(),h=(0,j.useRef)(null),{successToast:x,failToast:m}=t_(),{copyToClipboard:p,ImageDownloadModal:f,ref:g}=io({renderLibrary:"html-to-image",imageType:"png",shadowEffect:!0,backgroundColor:"white",ignoreElements:e=>{let n=e.className;return!!("string"==typeof n&&n.includes(is))},onSuccess:()=>{x("Copied the Lineage View as an image to clipboard")},onError:e=>{console.error("Error taking screenshot",e),m("Failed to copy image to clipboard",e)}}),[v,y,b]=(0,R.Rr)([]),[w,k,C]=(0,R.ll)([]),{lineageGraph:_,retchLineageGraph:S,isLoading:z,error:E,refetchRunsAggregated:D}=eg(),{showRunId:L,closeRunResult:P,runAction:W}=nq(),K=_&&(null==_?void 0:null===(t=_.modifiedSet)||void 0===t?void 0:t.length)>0,[J,B]=(0,j.useState)({view_mode:K?"changed_models":"all",...c.viewOptions});(0,j.useImperativeHandle)(n,()=>({copyToClipboard:p}));let U=J.view_mode||"changed_models",[Z,Q]=(0,j.useState)("single"),X=(0,j.useMemo)(()=>{var e;if("single"===Z)return null===(e=v.find(e=>e.data.isSelected))||void 0===e?void 0:e.data},[Z,v]),Y=(0,j.useMemo)(()=>v.filter(e=>e.data.isSelected).map(e=>e.data),[v]),$=(0,j.useMemo)(()=>v.map(e=>e.data),[v]),[ee,en]=(0,j.useState)(!1),[et,el]=(0,j.useState)({x:0,y:0}),es=(0,G.p)();(0,j.useLayoutEffect)(()=>{(async()=>{let e;if(!_)return;if(J.node_ids)e=J.node_ids;else{var n;let t=null===(n=_.manifestMetadata.current)||void 0===n?void 0:n.project_name,i={view_mode:J.view_mode,packages:t?[t]:void 0,...c.viewOptions};B(i),e=(await to({select:i.select,exclude:i.exclude,packages:i.packages,view_mode:i.view_mode})).nodes}let[t,i]=O(_,e);A(t,i),y(t),k(i)})()},[_]);let eo=async e=>{if(e.width&&e.height){let n=e.position.x+e.width/2,t=e.position.y+e.height/2,i=d.getZoom();d.setCenter(n,t,{zoom:i,duration:200})}},ea=i6();i4(h,async()=>{if("single"===Z||"action_result"===Z){let e=v.find(e=>e.data.isSelected);e?eo(e):d.fitView({nodes:v,duration:200})}});let ec=(0,j.useCallback)(e=>{y(n=>n.map(n=>n.id===e.id?{...n,data:e}:n))},[y]),ed=async e=>{let n;if(!_)return;try{n=(await to({select:e.select,exclude:e.exclude,packages:e.packages,view_mode:e.view_mode})).nodes}catch(e){if(e instanceof iX.d7){var t,i;es({title:"Select node error",description:(null===(i=e.response)||void 0===i?void 0:null===(t=i.data)||void 0===t?void 0:t.detail)||e.message,status:"error",isClosable:!0,position:"bottom-right"})}return}let[l,r]=O(_,n);A(l,r),y(l),k(r),B(e),await new Promise(e=>setTimeout(e,1)),await (async()=>{d.fitView({nodes:l,duration:200})})()},eu=iY("multi"===Z?Y:$,{onActionStarted:()=>{Q("action_result")},onActionNodeUpdated:ec,onActionCompleted:()=>{}}),eh=i0();if(z)return(0,i.jsx)(o.k,{width:"100%",height:"100%",alignItems:"center",justifyContent:"center",children:(0,i.jsx)(tA.$,{size:"xl"})});let ex=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3,n=et.selectedNode;"action_result"!==Z&&void 0!==n&&void 0!==_&&("single"===Z&&(y(H(v,!0)),Q("multi"),eu.reset()),y(V([...I(_,[n.id],e)],v,"single"===Z)))},em=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1e3,n=et.selectedNode;"action_result"!==Z&&void 0!==n&&void 0!==_&&("single"===Z&&(y(H(v,!0)),Q("multi"),eu.reset()),y(V([...M(_,[n.id],e)],v,"single"===Z)))},ep=()=>{en(!1),el({x:0,y:0})};if(E)return(0,i.jsx)(eZ.M,{h:"100%",children:(0,i.jsxs)(ne.g,{children:[(0,i.jsx)(l.x,{children:"Failed to load lineage data. This could be because the server has been terminated or there is a network error."}),(0,i.jsxs)(l.x,{children:["[Reason: ",E,"]"]}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>{S&&S()},children:"Retry"})]})});if("changed_models"===U&&!(null==_?void 0:null===(r=_.modifiedSet)||void 0===r?void 0:r.length))return(0,i.jsx)(eZ.M,{h:"100%",children:(0,i.jsxs)(ne.g,{children:[(0,i.jsx)(i.Fragment,{children:"No change detected"}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>{ed({...J,view_mode:"all"})},children:"Show all nodes"})]})});let ef=()=>{Q("single"),y(H(v)),P(),null==D||D()},ev={interactive:a,selectMode:Z,nodes:v,viewOptions:J,onViewOptionsChanged:ed,selectNodeMulti:e=>{if("multi"!==Z){if(!_)return;let[n,t]=F(Array.from(M(_,_.modifiedSet)),v,w);y(n=N(e,n=H(n,!0))),k(t),Q("multi"),eu.reset()}else{let n=q(e,v);n.find(e=>e.data.isSelected)||(Q("single"),n=H(n)),y(n)}},deselect:ef,runRowCountDiff:async()=>{"multi"===Z?(await eu.runRowCountDiff(),iE({type:"row_count_diff",selected:"multi"})):X?(await W("row_count_diff",{node_names:[X.name]},{showForm:!1,showLast:!1}),iE({type:"row_count_diff",selected:"single"})):(await W("row_count_diff",{select:J.select,exclude:J.exclude,packages:J.packages,view_mode:J.view_mode}),iE({type:"row_count_diff",selected:"none"}))},runValueDiff:async()=>{if(X)await W("value_diff",{model:X.name},{showForm:!0,showLast:!1}),iE({type:"value_diff",selected:"single"});else{let e="multi"===Z?Y.length:$.length;await eh.confirm(e)&&(await eu.runValueDiff(),iE({type:"value_diff",selected:"multi"===Z?"multi":"none"}))}},addLineageDiffCheck:async()=>{let e;"multi"===Z?(e=await eu.addLineageDiffCheck(),ef(),iE({type:"lineage_diff",selected:"multi"})):X||(e=await iZ(J),iE({type:"lineage_diff",selected:"none"})),e&&ea(e)},addSchemaDiffCheck:async()=>{let e;"multi"===Z?Y.length>0&&(e=await eu.addSchemaDiffCheck(),ef(),iE({type:"schema_diff",selected:"multi"})):X?(e=await t4({node_id:X.id}),iE({type:"schema_diff",selected:"single"})):(e=await t4({select:J.select,exclude:J.exclude,packages:J.packages,view_mode:J.view_mode}),iE({type:"schema_diff",selected:"none"})),e&&ea(e)},cancel:eu.cancel,actionState:eu.actionState};return(0,i.jsxs)(tQ.Provider,{value:ev,children:[(0,i.jsxs)(tc,{sizes:X?[70,30]:[100,0],minSize:X?400:0,gutterSize:X?5:0,style:{height:"100%",width:"100%"},children:[(0,i.jsxs)(ne.g,{ref:h,divider:(0,i.jsx)(tF.c,{borderColor:"gray.200"}),spacing:0,style:{contain:"strict"},position:"relative",children:[a&&(0,i.jsx)(iU,{}),(0,i.jsxs)(R.x$,{nodeTypes:i1,edgeTypes:i5,nodes:v,edges:w,onNodesChange:b,onEdgesChange:C,onNodeClick:(e,n)=>{if(!1!==a&&_){if(ep(),"single"===Z){X||eo(n);let[e,t]=F(Array.from(T(I(_,[n.id]),M(_,[n.id]))),v,w);y(N(n.id,e)),k(t)}else if("action_result"===Z){var t,i,l,r;(null===(i=n.data.action)||void 0===i?void 0:null===(t=i.run)||void 0===t?void 0:t.run_id)&&L(null===(r=n.data.action)||void 0===r?void 0:null===(l=r.run)||void 0===l?void 0:l.run_id),eo(n),y(N(n.id,v))}else{let e=q(n.id,v);e.find(e=>e.data.isSelected)||(Q("single"),e=H(e)),y(e)}}},onNodeMouseEnter:(e,n)=>{if(!_||X||"single"!==Z)return;let[t,i]=F(Array.from(T(I(_,[n.id]),M(_,[n.id]))),v,w);y(t),k(i)},onNodeMouseLeave:(e,n)=>{if(!_||X)return;let[t,i]=F(Array.from(M(_,_.modifiedSet)),v,w);y(t),k(i)},onNodeContextMenu:(e,n)=>{if(!a||"action_result"===Z)return;e.preventDefault();let t=g.current.getBoundingClientRect(),i=g.current.offsetTop;el({x:e.clientX-t.left,y:e.clientY-t.top+i,selectedNode:n}),en(!0)},onClick:ep,maxZoom:1,minZoom:.1,fitView:!0,nodesDraggable:a,ref:g,children:[(0,i.jsx)(tN.A,{color:"#ccc"}),(0,i.jsx)(tq.Z,{showInteractive:!1,position:"top-right",className:is,children:(0,i.jsx)(tq.B,{title:"copy image",onClick:async()=>{p()},children:(0,i.jsx)(s.J,{as:tW.C3L})})}),(0,i.jsx)(f,{}),(0,i.jsx)(R.s_,{position:"bottom-left",children:(0,i.jsx)(u.U,{children:(0,i.jsx)(iQ,{})})}),(0,i.jsx)(R.s_,{position:"top-left",children:(0,i.jsx)(ei.x,{fontSize:"xl",color:"grey",opacity:.5,children:v.length>0?"":"No nodes"})}),(0,i.jsx)(tV.a,{nodeColor:i2,nodeStrokeWidth:3,zoomable:!0,pannable:!0}),"action_result"===Z&&(0,i.jsx)(R.s_,{position:"bottom-center",className:is,children:(0,i.jsx)(iF,{onClose:()=>{ef()}})})]}),ee&&(0,i.jsx)(nC.v,{isOpen:!0,onClose:ep,children:(0,i.jsxs)(nz.q,{fontSize:"11pt",position:"absolute",width:"250px",style:{left:"".concat(et.x,"px"),top:"".concat(et.y,"px")},children:[(0,i.jsx)(nE.s,{icon:(0,i.jsx)(t$.Cv2,{}),onClick:()=>{ex(1)},children:"Select parent nodes"}),(0,i.jsx)(nE.s,{icon:(0,i.jsx)(t$.IMj,{}),onClick:()=>{em(1)},children:"Select child nodes"}),(0,i.jsx)(nX.R,{}),(0,i.jsx)(nE.s,{icon:(0,i.jsx)(t$.Cv2,{}),onClick:()=>{ex()},children:"Select all upstream nodes"}),(0,i.jsx)(nE.s,{icon:(0,i.jsx)(t$.IMj,{}),onClick:()=>{em()},children:"Select all downstream nodes"})]})})]}),"single"===Z&&X?(0,i.jsx)(l.x,{borderLeft:"solid 1px lightgray",height:"100%",children:(0,i.jsx)(iA,{node:X,onCloseNode:()=>{if(!_)return;let[e,n]=F(Array.from(M(_,_.modifiedSet)),v,w);y(H(e)),k(n)}})}):(0,i.jsx)(l.x,{})]}),eh.AlertDialog]})}),i9=(0,j.forwardRef)(function(e,n){let{check:t}=e,l={...t.params,...t.view_options};return(0,i.jsx)(o.k,{direction:"column",height:"100%",children:(0,i.jsx)(R.tV,{children:(0,i.jsx)(i3,{viewOptions:l,interactive:!1,ref:n})})})});function i8(e){let{name:n,description:t,type:l,params:r,viewOptions:s}=e,o={name:n,description:t,type:l,params:r};s&&(o.view_options=s);let a=t9.ZP.stringify({checks:[o]});return(0,i.jsx)(tE.ML,{height:"300px",language:"yaml",theme:"vs",value:a,options:{readOnly:!0,fontSize:14,lineNumbers:"off",automaticLayout:!0,minimap:{enabled:!1},wordWrap:"on",wrappingIndent:"same",scrollBeyondLastLine:!1}})}function i7(){let e=(0,G.p)();return{markedAsApprovedToast:function(){e({title:"Marked as approved",position:"bottom-right",status:"success",containerStyle:{fontSize:"sm"},duration:2e3})}}}function le(){let e=(0,nZ._)(["\n ","
\n\n ","\n\n "]);return le=function(){return e},e}let ln=e=>{var n,t,r,a,d,f,g;let{checkId:v}=e,w=(0,b.NL)(),[,k]=(0,ew.TH)(),{successToast:C,failToast:_}=t_(),{markedAsApprovedToast:S}=i7(),[z,R]=(0,j.useState)(),[E,T]=(0,j.useState)(),[D,L]=(0,j.useState)(!1),{isOpen:I,onOpen:M,onClose:O}=(0,eb.q)(),A=()=>(0,i.jsx)($.Z,{bg:"blackAlpha.300",backdropFilter:"blur(10px) "}),[F,N]=(0,j.useState)((0,i.jsx)(A,{})),{isLoading:q,error:V,data:H}=(0,y.a)({queryKey:P.check(v),queryFn:async()=>nK(v),refetchOnMount:!0}),W=z||(null==H?void 0:null===(n=H.last_run)||void 0===n?void 0:n.run_id),{run:K,error:J}=t3(W),B=z?!K||"running"===K.status:(null==K?void 0:K.status)==="running",U=(null==H?void 0:H.type)?nO(null==H?void 0:H.type):void 0,Z=(null==H?void 0:H.is_preset)||!1,Q=(0,j.useRef)(null),{mutate:X}=(0,te.D)({mutationFn:e=>nJ(v,e),onSuccess:()=>{w.invalidateQueries({queryKey:P.check(v)}),w.invalidateQueries({queryKey:P.checks()})}}),{mutate:G}=(0,te.D)({mutationFn:()=>nB(v),onSuccess:()=>{w.invalidateQueries({queryKey:P.checks()}),k("/checks")}}),el=(0,j.useCallback)(async()=>{(null==H?void 0:H.type)&&R((await eu(v,{nowait:!0})).run_id)},[H,v,R]),es=(0,j.useCallback)(async()=>{if(L(!0),W)return await ed(W)},[W]),eo=async()=>{var e;if(!H)return;let n=(e=H,(0,tC.RI)(le(),"".concat(e.is_checked?"✅ ":"").concat(e.name),function(e){if("query"===e.type||"query_diff"===e.type){var n;return"".concat(tz(e),"\n\n").concat((0,tC.Pn)(tS(),null===(n=e.params)||void 0===n?void 0:n.sql_template))}return tz(e)}(e)));if(!navigator.clipboard){_("Failed to copy the check to clipboard",Error("Copy to clipboard is available only in secure contexts (HTTPS)"));return}try{await navigator.clipboard.writeText(n),C("Copied the check to the clipboard")}catch(e){_("Failed to copy the check to clipboard",e)}},ea=(0,j.useCallback)(()=>{let e=null==H?void 0:H.is_checked;X({is_checked:!e}),!0==!e&&S()},[null==H?void 0:H.is_checked,X,S]),[ec,eh]=(0,j.useState)(0),{ref:ex,onCopyToClipboard:em,onMouseEnter:ep,onMouseLeave:ef}=ia();if(q)return(0,i.jsx)(eZ.M,{h:"100%",children:"Loading"});if(V)return(0,i.jsxs)(eZ.M,{h:"100%",children:["Error: ",V.message]});let eg=(null==K?void 0:K.run_at)?(0,tO.Q)(new Date(K.run_at),{addSuffix:!0}):null;return(0,i.jsxs)(td,{minSize:100,sizes:[30,70],style:{height:"100%",width:"100%",maxHeight:"100%"},children:[(0,i.jsxs)(l.x,{style:{contain:"strict"},display:"flex",flexDirection:"column",children:[(0,i.jsxs)(o.k,{p:"0px 16px",alignItems:"center",h:"40px",children:[(0,i.jsx)(n7,{name:(null==H?void 0:H.name)||"",setName:e=>{X({name:e})}}),(0,i.jsx)(h.L,{}),Z&&(0,i.jsx)(nh.u,{label:"Preset Check defined in recce config",children:(0,i.jsxs)(nQ.Vp,{size:"sm",flex:"0 0 auto",children:[(0,i.jsx)(nQ.AD,{boxSize:"14px",as:n4.bX4}),"Preset"]})}),(0,i.jsxs)(nC.v,{children:[(0,i.jsx)(n_.j,{isRound:!0,as:nS.h,icon:(0,i.jsx)(s.J,{as:eY.D_A}),variant:"ghost",size:"sm"}),(0,i.jsxs)(nz.q,{children:[(0,i.jsx)(nE.s,{as:ei.x,fontSize:"10pt",icon:(0,i.jsx)(n6.ovA,{}),onClick:()=>{N((0,i.jsx)(A,{})),M()},children:"Get Preset Check Template"}),(0,i.jsx)(nE.s,{as:ei.x,fontSize:"10pt",icon:(0,i.jsx)(n0.T,{}),onClick:()=>eo(),children:"Copy Markdown"}),(0,i.jsx)(nX.R,{}),(0,i.jsx)(nE.s,{as:ei.x,fontSize:"10pt",icon:(0,i.jsx)(n1.p,{}),color:"red",onClick:()=>G(),children:"Delete"})]})]}),eg&&(0,i.jsx)(l.x,{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",fontSize:"10pt",children:eg}),(null==U?void 0:U.RunResultView)&&(0,i.jsx)(nh.u,{label:"Rerun",children:(0,i.jsx)(nS.h,{isRound:!0,isLoading:B,variant:"ghost","aria-label":"Rerun",icon:(0,i.jsx)(n5.n,{}),onClick:()=>el()})}),(0,i.jsx)(nh.u,{label:(null==H?void 0:H.is_checked)?"Mark as Pending":"Mark as Approved",placement:"bottom-end",children:(0,i.jsx)(er.z,{flex:"0 0 auto",size:"sm",colorScheme:(null==H?void 0:H.is_checked)?"green":"gray",variant:(null==H?void 0:H.is_checked)?"solid":"outline",leftIcon:(null==H?void 0:H.is_checked)?(0,i.jsx)(n2.r,{}):(0,i.jsx)(s.J,{as:eY.Rbx,color:"lightgray"}),onClick:()=>ea(),children:(null==H?void 0:H.is_checked)?"Approved":"Mark as Approved"})})]}),(0,i.jsx)(l.x,{flex:"1",p:"8px 16px",minHeight:"100px",children:(0,i.jsx)(tk,{value:null==H?void 0:H.description,onChange:e=>{X({description:e})}},null==H?void 0:H.check_id)})]}),(0,i.jsx)(l.x,{style:{contain:"strict"},children:(0,i.jsxs)(x.m,{height:"100%",display:"flex",flexDirection:"column",tabIndex:ec,onChange:eh,children:[(0,i.jsxs)(m.t,{height:"50px",children:[(0,i.jsx)(p.O,{fontSize:"10pt",children:"Result"}),((null==H?void 0:H.type)==="query"||(null==H?void 0:H.type)==="query_diff")&&(0,i.jsx)(p.O,{fontSize:"10pt",children:"Query"}),(0,i.jsx)(h.L,{}),(0,i.jsx)(u.U,{mr:"10px",children:(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(n0.T,{}),variant:"outline",isDisabled:"schema_diff"!==(g=null!==(f=null==H?void 0:H.type)&&void 0!==f?f:"")&&"lineage_diff"!==g&&(!(null==K?void 0:K.result)||!!(null==K?void 0:K.error))||0!==ec,onMouseEnter:ep,onMouseLeave:ef,size:"sm",onClick:()=>{if((null==H?void 0:H.type)==="lineage_diff"){var e;null===(e=Q.current)||void 0===e||e.copyToClipboard()}else em()},children:"Copy to Clipboard"})})]}),(0,i.jsxs)(nG.n,{height:"100%",flex:"1",style:{contain:"strict"},children:[(0,i.jsxs)(nY.x,{p:0,width:"100%",height:"100%",children:[(null==U?void 0:U.RunResultView)&&((null==H?void 0:H.last_run)||W?(0,i.jsx)(tM,{ref:ex,isRunning:B,isAborting:D,run:W?K:null==H?void 0:H.last_run,error:J,progress:E,RunResultView:U.RunResultView,viewOptions:null==H?void 0:H.view_options,onViewOptionsChanged:e=>{X({view_options:e})},onCancel:es,onExecuteRun:el}):(0,i.jsx)(eZ.M,{bg:"rgb(249,249,249)",height:"100%",children:(0,i.jsx)(er.z,{onClick:el,colorScheme:"blue",size:"sm",children:"Run Query"})})),H&&"schema_diff"===H.type&&(0,i.jsx)(tb,{check:H,ref:ex}),H&&"lineage_diff"===H.type&&(0,i.jsx)(i9,{check:H,ref:Q})]}),((null==H?void 0:H.type)==="query"||(null==H?void 0:H.type)==="query_diff"||(null==H?void 0:H.type)==="query_base")&&(0,i.jsx)(nY.x,{p:0,height:"100%",width:"100%",children:(null===(t=H.params)||void 0===t?void 0:t.base_sql_template)?(0,i.jsx)(tD,{value:(null==H?void 0:null===(r=H.params)||void 0===r?void 0:r.sql_template)||"",baseValue:(null==H?void 0:null===(a=H.params)||void 0===a?void 0:a.base_sql_template)||"",options:{readOnly:!0}}):(0,i.jsx)(tT,{value:(null==H?void 0:null===(d=H.params)||void 0===d?void 0:d.sql_template)||"",options:{readOnly:!0}})})]})]})}),(0,i.jsxs)(Y.u_,{isOpen:I,onClose:O,isCentered:!0,size:"6xl",children:[F,(0,i.jsxs)(ee.h,{overflowY:"auto",height:"40%",width:"60%",children:[(0,i.jsx)(en.x,{children:"Preset Check Template"}),(0,i.jsx)(ej.o,{}),(0,i.jsxs)(et.f,{children:[(0,i.jsx)(c.X,{size:"sm",fontWeight:"bold",children:(0,i.jsx)(n$.y,{query:"recce.yml",styles:{px:"1",py:"0",bg:"red.100"},children:"Please copy the following template and paste it into the recce.yml file."})}),(0,i.jsx)("br",{}),(0,i.jsx)(i8,{name:(null==H?void 0:H.name)||"",description:(null==H?void 0:H.description)||"",type:(null==H?void 0:H.type)||"",params:null==H?void 0:H.params,viewOptions:null==H?void 0:H.view_options})]})]})]})]})};var lt=t(34872);let li=e=>{var n;let{check:t,selected:r,onSelect:a,onMarkAsApproved:c}=e,d=(0,b.NL)(),u=t.check_id,{mutate:h}=(0,te.D)({mutationFn:e=>nJ(u,e),onSuccess:()=>{d.invalidateQueries({queryKey:P.check(u)}),d.invalidateQueries({queryKey:P.checks()})}}),x=(null===(n=nO(t.type))||void 0===n?void 0:n.icon)||ek.WzH;return(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(o.k,{width:"100%",p:"10px 20px",cursor:"pointer",_hover:{bg:"Cornsilk"},bg:r?"Floralwhite":"inherit",borderBlockEndWidth:"1px",borderLeftWidth:"3px",borderLeftColor:r?"orange":"transparent",onClick:()=>a(t.check_id),alignItems:"center",gap:"5px",children:[(0,i.jsx)(s.J,{as:x}),(0,i.jsx)(l.x,{flex:"1",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",children:t.name}),(0,i.jsx)(nh.u,{label:"Click to mark as approved",placement:"top",hasArrow:!0,children:(0,i.jsx)(o.k,{children:(0,i.jsx)(nn.X,{isChecked:t.is_checked,variant:"circular",colorScheme:"green",size:"xs",onChange:e=>{let n=e.target.checked;!1===n?h({is_checked:n}):c()}})})})]})})},ll=e=>{let{checks:n,selectedItem:t,onCheckSelected:r,onChecksReordered:s}=e,[a,c]=(0,j.useState)(!1),d=(0,b.NL)(),{mutate:u}=(0,te.D)({mutationFn:e=>nJ(e,{is_checked:!0}),onSuccess:(e,n)=>{d.invalidateQueries({queryKey:P.check(n)}),d.invalidateQueries({queryKey:P.checks()})}}),{isOpen:h,onOpen:x,onClose:m}=(0,eb.q)(),{markedAsApprovedToast:p}=i7(),f=()=>{"true"===localStorage.getItem("bypassMarkAsApprovedWarning")?(u(t),p()):x()};return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(lt.Z5,{onDragEnd:e=>{e.destination&&s(e.source.index,e.destination.index)},children:(0,i.jsx)(lt.bK,{droppableId:"checklist",children:e=>(0,i.jsxs)(ne.g,{...e.droppableProps,ref:e.innerRef,w:"full",spacing:"0",flex:"1",overflow:"auto",children:[n.map((e,n)=>(0,i.jsx)(lt._l,{draggableId:e.check_id,index:n,children:(n,l)=>{if(l.isDragging){let e=n.draggableProps,t={x:0,y:80},i=e.style.left-t.x,l=e.style.top-t.y;e.style.left=i,e.style.top=l}return(0,i.jsx)(o.k,{ref:n.innerRef,...n.draggableProps,...n.dragHandleProps,w:"full",children:(0,i.jsx)(li,{check:e,selected:e.check_id===t,onSelect:r,onMarkAsApproved:f},e.check_id)})}},e.check_id)),e.placeholder]})})}),(0,i.jsxs)(Y.u_,{isOpen:h,onClose:m,isCentered:!0,children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{width:"400px",children:[(0,i.jsx)(en.x,{children:"Mark as Approved?"}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(nx.i,{}),(0,i.jsxs)(l.x,{p:"16px",fontSize:"sm",gap:"16px",children:[(0,i.jsx)("p",{children:"Please ensure you have reviewed the contents of this check before marking it as approved."}),(0,i.jsx)(nn.X,{isChecked:a,onChange:e=>c(e.target.checked),fontWeight:"bold",size:"sm",pt:"8px",children:"Don't show this again"})]}),(0,i.jsx)(nx.i,{}),(0,i.jsxs)(el.m,{children:[(0,i.jsx)(er.z,{variant:"outline",size:"xs",mr:2,onClick:m,children:"Cancel"}),(0,i.jsx)(er.z,{colorScheme:"blue",size:"xs",onClick:()=>{u(t),!0===a&&localStorage.setItem("bypassMarkAsApprovedWarning","true"),p(),m()},children:"Mark as approved"})]})]})]})]})};async function lr(e){return(await U.post("/api/save-as",e)).data}async function ls(e){return(await U.post("/api/rename",e)).data}async function lo(){return(await U.post("/api/export")).data}async function la(e,n){let t=new FormData;return t.append("file",e),t.append("checks_only",(!!n).toString()),(await U.post("/api/import",t)).data}async function lc(){return 208===(await U.get("/api/sync")).status}async function ld(e){try{let n=await U.post("/api/sync",e);if(202===n.status)return{status:"accepted"};if(208===n.status)return{status:"syncing"}}catch(e){if((0,iX.IZ)(e)&&e.response&&409===e.response.status)return{status:"conflict"}}throw Error("Failed to sync state")}let lu=e=>(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,i.jsx)("g",{"clip-path":"url(#clip0_1479_25070)",children:(0,i.jsx)("path",{d:"M15.625 0.25H14.759C14.5484 0.25 14.3791 0.423375 14.3841 0.633937L14.4575 3.71441C13.0691 1.62634 10.6955 0.25 8 0.25C4.21291 0.25 1.06041 2.96638 0.38425 6.557C0.340875 6.78728 0.518875 7 0.753219 7H1.64622C1.82353 7 1.97566 6.87556 2.013 6.70222C2.60753 3.9415 5.05991 1.875 8 1.875C10.4858 1.875 12.6232 3.35256 13.5836 5.47819L9.63394 5.38416C9.42341 5.37916 9.25 5.54844 9.25 5.75906V6.625C9.25 6.83209 9.41791 7 9.625 7H15.625C15.8321 7 16 6.83209 16 6.625V0.625C16 0.417906 15.8321 0.25 15.625 0.25ZM15.2468 9H14.3538C14.1765 9 14.0243 9.12444 13.987 9.29778C13.3925 12.0585 10.9401 14.125 8 14.125C5.51419 14.125 3.37681 12.6474 2.41637 10.5218L6.36606 10.6158C6.57659 10.6208 6.75 10.4516 6.75 10.2409V9.375C6.75 9.16791 6.58209 9 6.375 9H0.375C0.167906 9 0 9.16791 0 9.375V15.375C0 15.5821 0.167906 15.75 0.375 15.75H1.24097C1.45156 15.75 1.62088 15.5766 1.61588 15.3661L1.54253 12.2856C2.93087 14.3737 5.3045 15.75 8 15.75C11.7871 15.75 14.9396 13.0336 15.6158 9.443C15.6591 9.21272 15.4811 9 15.2468 9Z",fill:"currentColor"})}),(0,i.jsx)("defs",{children:(0,i.jsx)("clipPath",{id:"clip0_1479_25070",children:(0,i.jsx)("rect",{width:"16",height:"16",fill:"white"})})})]}),lh=e=>(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,i.jsx)("g",{"clip-path":"url(#clip0_1479_25102)",children:(0,i.jsx)("path",{d:"M-1.88399 8.72062L0.358816 6.46094C0.594752 6.22344 1.00006 6.39031 1.00006 6.725V8.2525H4.00005V4.12438C4.00005 3.7275 4.16161 3.34313 4.44286 3.06219L7.06441 0.440625C7.34566 0.159375 7.72691 0 8.12347 0H14.5003C15.3281 0.003125 16 0.675 16 1.50281V14.5003C16 15.3281 15.3281 16 14.5003 16H5.50223C4.67411 16 4.00005 15.3281 4.00005 14.5003V11.2522H5.50005V14.5003H14.5003V1.50281H9.50128V4.75219C9.50128 5.16781 9.1669 5.50187 8.75128 5.50187H5.50005V8.25219H10.625C10.8322 8.25219 11 8.42 11 8.62719V9.37719C11 9.58438 10.8322 9.75219 10.625 9.75219H1.00006V11.2797C1.00006 11.6144 0.594752 11.7813 0.358816 11.5438L-1.88399 9.28406C-2.03867 9.12813 -2.03867 8.87656 -1.88399 8.72062ZM8.0016 4.00219V1.62469L5.62379 4.00219H8.0016Z",fill:"currentColor"})}),(0,i.jsx)("g",{"clip-path":"url(#clip1_1479_25102)",children:(0,i.jsx)("path",{d:"M0.103056 8.72062L2.09667 6.46094C2.30639 6.22344 2.66667 6.39031 2.66667 6.725V8.2525H5.33333V4.12438C5.33333 3.7275 5.47694 3.34313 5.72694 3.06219L8.05722 0.440625C8.30722 0.159375 8.64611 0 8.99861 0H14.6669C15.4028 0.003125 16 0.675 16 1.50281V14.5003C16 15.3281 15.4028 16 14.6669 16H6.66861C5.9325 16 5.33333 15.3281 5.33333 14.5003V11.2522H6.66667V14.5003H14.6669V1.50281H10.2233V4.75219C10.2233 5.16781 9.92611 5.50187 9.55667 5.50187H6.66667V8.25219H11.2222C11.4064 8.25219 11.5556 8.42 11.5556 8.62719V9.37719C11.5556 9.58438 11.4064 9.75219 11.2222 9.75219H2.66667V11.2797C2.66667 11.6144 2.30639 11.7813 2.09667 11.5438L0.103056 9.28406C-0.0344448 9.12813 -0.0344448 8.87656 0.103056 8.72062ZM8.89028 4.00219V1.62469L6.77666 4.00219H8.89028Z",fill:"currentColor"})}),(0,i.jsxs)("defs",{children:[(0,i.jsx)("clipPath",{id:"clip0_1479_25102",children:(0,i.jsx)("rect",{width:"13",height:"16",fill:"white",transform:"matrix(-1 0 0 1 16 0)"})}),(0,i.jsx)("clipPath",{id:"clip1_1479_25102",children:(0,i.jsx)("rect",{width:"3",height:"16",fill:"white"})})]})]}),lx=e=>(0,i.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:[(0,i.jsx)("g",{"clip-path":"url(#clip0_1426_8619)",children:(0,i.jsx)("path",{d:"M15.5572 3.06188L12.9356 0.440625C12.6544 0.159375 12.2731 0 11.8766 0H5.49969C4.67188 0.003125 4 0.675 4 1.50281V8.25219H0.375C0.167812 8.25219 0 8.42 0 8.62719V9.37719C0 9.58438 0.167812 9.75219 0.375 9.75219H9V11.2797C9 11.6144 9.40531 11.7812 9.64125 11.5437L11.8841 9.28406C12.0388 9.12813 12.0388 8.87656 11.8841 8.72062L9.64125 6.46094C9.40531 6.22344 9 6.39031 9 6.725V8.2525H5.49969V1.50281H10.4987V4.75219C10.4987 5.16781 10.8331 5.50187 11.2487 5.50187H14.5V14.5003H5.49969V11.2522H4V14.5003C4 15.3281 4.67188 16 5.49969 16H14.4978C15.3259 16 16 15.3281 16 14.5003V4.12406C16 3.7275 15.8384 3.34313 15.5572 3.06188ZM11.9984 4.00219V1.62469L14.3763 4.00219H11.9984Z",fill:"black"})}),(0,i.jsx)("defs",{children:(0,i.jsx)("clipPath",{id:"clip0_1426_8619",children:(0,i.jsx)("rect",{width:"16",height:"16",fill:"white"})})})]}),lm=e=>(0,i.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,i.jsx)("path",{d:"M14.5607 4.06066L11.9393 1.43934C11.658 1.15804 11.2765 1 10.8787 1H2.5C1.67156 1 1 1.67156 1 2.5V13.5C1 14.3284 1.67156 15 2.5 15H13.5C14.3284 15 15 14.3284 15 13.5V5.12131C15 4.72349 14.842 4.34196 14.5607 4.06066ZM9.5 2.5V5H5.5V2.5H9.5ZM13.3125 13.5H2.6875C2.63777 13.5 2.59008 13.4802 2.55492 13.4451C2.51975 13.4099 2.5 13.3622 2.5 13.3125V2.6875C2.5 2.63777 2.51975 2.59008 2.55492 2.55492C2.59008 2.51975 2.63777 2.5 2.6875 2.5H4V5.75C4 6.16422 4.33578 6.5 4.75 6.5H10.25C10.6642 6.5 11 6.16422 11 5.75V2.62131L13.4451 5.06641C13.4625 5.08382 13.4763 5.10449 13.4857 5.12724C13.4952 5.14999 13.5 5.17438 13.5 5.199V13.3125C13.5 13.3622 13.4802 13.4099 13.4451 13.4451C13.4099 13.4802 13.3622 13.5 13.3125 13.5ZM8 7.25C6.48366 7.25 5.25 8.48366 5.25 10C5.25 11.5163 6.48366 12.75 8 12.75C9.51634 12.75 10.75 11.5163 10.75 10C10.75 8.48366 9.51634 7.25 8 7.25ZM8 11.25C7.31075 11.25 6.75 10.6892 6.75 10C6.75 9.31075 7.31075 8.75 8 8.75C8.68925 8.75 9.25 9.31075 9.25 10C9.25 10.6892 8.68925 11.25 8 11.25Z",fill:"currentColor"})}),lp=e=>(0,i.jsx)("svg",{width:"17",height:"16",viewBox:"0 0 17 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,i.jsx)("path",{d:"M15.9143 1.75812L14.7422 0.585938C14.3515 0.195312 13.8397 0 13.3278 0C12.8159 0 12.304 0.195312 11.9137 0.585625L9.58593 2.91344L8.5 3.99938L0.901592 11.5975L0.504719 15.1669C0.454719 15.6163 0.80878 16 1.24847 16C1.27628 16 1.3044 15.9984 1.33253 15.9953L4.89939 15.6012L12.5006 8L13.5862 6.91437L15.914 4.58656C16.6953 3.80531 16.6953 2.53906 15.9143 1.75812ZM4.21095 14.1684L2.09909 14.4016L2.3344 12.2863L9.56062 5.06L10.53 4.09062L12.4094 5.97L11.44 6.93937L4.21095 14.1684ZM14.8534 3.52562L13.4697 4.90938L11.5906 3.03L12.9744 1.64625C13.1019 1.51875 13.2506 1.49969 13.3278 1.49969C13.405 1.49969 13.554 1.51875 13.6812 1.64625L14.8534 2.81844C15.0484 3.01375 15.0484 3.33094 14.8534 3.52562Z",fill:"currentColor"})}),lf=e=>(0,i.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:(0,i.jsx)("path",{d:"M7.26326 6.5462H8.71794V12.3642H7.26326V6.5462ZM7.9906 3.1102C7.43278 3.1102 6.97888 3.5641 6.97888 4.12192C6.97888 4.67974 7.43278 5.13364 7.9906 5.13364C8.54842 5.13364 9.00232 4.67974 9.00232 4.12192C9.00232 3.5641 8.54842 3.1102 7.9906 3.1102ZM16 8C16 12.411 12.411 16 8 16C3.589 16 0 12.411 0 8C0 3.589 3.589 0 8 0C12.411 0 16 3.589 16 8ZM14.5453 8C14.5453 4.3906 11.6093 1.4546 7.99992 1.4546C4.39052 1.4546 1.45452 4.3914 1.45452 8.0006C1.45452 11.6098 4.39052 14.546 7.99992 14.546C11.6093 14.546 14.5453 11.6092 14.5453 8.0006V8Z",fill:"currentColor"})});function lg(e){let{checksOnly:n=!0}=e,t=(0,G.p)(),l=(0,b.NL)(),r=(0,j.useRef)(null),a=(0,j.useRef)(null),[c,d]=(0,j.useState)(null),{isOpen:u,onOpen:h,onClose:x}=(0,eb.q)(),[m,p]=(0,ew.TH)(),[,f]=ev(),g=(0,j.useCallback)(async()=>{if(c){try{let{runs:e,checks:i}=await la(c,n);f(),await l.invalidateQueries({queryKey:P.checks()}),await l.invalidateQueries({queryKey:P.runs()}),m.includes("/checks")&&p("/checks");let r=n?"".concat(i," checks imported successfully"):"".concat(e," runs and ").concat(i," checks imported successfully");t({description:r,status:"info",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}catch(e){console.error("Import failed",e),t({title:"Import failed",description:"".concat(e),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}x()}},[l,c,t,x,m,p,f,n]),v=n?"checks":"runs and checks",{isDemoSite:y}=eg();return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(nh.u,{label:"Import Checklist from State File"+(y?" (Disabled in the demo site)":""),children:(0,i.jsx)(nS.h,{pt:"6px",variant:"unstyled","aria-label":"Import state",onClick:()=>{r.current&&r.current.click()},icon:(0,i.jsx)(s.J,{as:lx}),isDisabled:y})}),(0,i.jsx)("input",{type:"file",style:{display:"none"},ref:r,onChange:e=>{var n;(null===(n=e.target.files)||void 0===n?void 0:n.length)===1&&(d(e.target.files[0]),h()),r.current&&(r.current.value="")}}),(0,i.jsx)(i$.aR,{isOpen:u,leastDestructiveRef:a,onClose:x,size:"xl",children:(0,i.jsx)($.Z,{children:(0,i.jsxs)(i$._T,{children:[(0,i.jsx)(en.x,{fontSize:"lg",fontWeight:"bold",children:"Import state"}),(0,i.jsx)(et.f,{children:(0,i.jsxs)(o.k,{px:"5px",gap:"5px",rounded:"md",direction:"column",children:[(0,i.jsxs)(o.k,{alignItems:"center",gap:"5px",children:[(0,i.jsx)(tH.s,{color:"red.600"}),(0,i.jsx)(ei.x,{as:"span",fontWeight:"500",color:"red.600",children:"Caution!"})]}),(0,i.jsx)(o.k,{children:(0,i.jsxs)(ei.x,{children:["The current ",v," will be"," ",(0,i.jsx)(ei.x,{as:"span",fontWeight:"600",children:"merged"})," ","with the imported state"]})})]})}),(0,i.jsxs)(el.m,{children:[(0,i.jsx)(er.z,{ref:a,onClick:x,children:"Cancel"}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:g,ml:"5px",children:"Import"})]})]})})})]})}let lv=()=>{let[,e]=(0,ew.TH)(),[,n]=(0,ew.yj)("/checks/:checkId"),t=(0,b.NL)(),{successToast:r,failToast:s}=t_(),a=null==n?void 0:n.checkId,{isLoading:c,error:d,data:u,status:h}=(0,y.a)({queryKey:P.checks(),queryFn:nW,refetchOnMount:!0}),x=(0,j.useCallback)(n=>{e("/checks/".concat(n))},[e]),[m,p]=(0,j.useState)(u||[]),{mutate:f}=(0,te.D)({mutationFn:e=>nU(e),onSuccess:()=>{t.invalidateQueries({queryKey:P.checks()})}}),g=(0,j.useCallback)((e,n)=>{let t=[...m],[i]=t.splice(e,1);t.splice(n,0,i),f({source:e,destination:n}),p(t)},[m,p,f]);return((0,j.useCallback)(async()=>{let e=await nH();t.invalidateQueries({queryKey:P.checks()}),x(e.check_id)},[t,x]),(0,j.useEffect)(()=>{"success"===h&&(!a&&u.length>0&&e("/checks/".concat(u[0].check_id)),p(u))},[h,a,u,p,e]),c)?(0,i.jsx)(i.Fragment,{}):d?(0,i.jsxs)(i.Fragment,{children:["Error: ",d.message]}):(null==u?void 0:u.length)?(0,i.jsxs)(tc,{style:{height:"100%"},minSize:50,sizes:[20,80],children:[(0,i.jsx)(l.x,{borderRight:"lightgray solid 1px",height:"100%",style:{contain:"size"},children:(0,i.jsxs)(ne.g,{spacing:0,h:"100%",style:{contain:"strict"},alignItems:"stretch",children:[(0,i.jsx)(o.k,{justifyContent:"right",padding:"0px 10px",children:(0,i.jsx)(lg,{checksOnly:!0})}),(0,i.jsx)(nx.i,{}),(0,i.jsx)(ll,{checks:m,selectedItem:a,onCheckSelected:x,onChecksReordered:g})]})}),(0,i.jsx)(l.x,{height:"100%",children:(0,i.jsx)(ew.rs,{children:(0,i.jsx)(ew.AW,{path:"/checks/:checkId",children:e=>(0,i.jsx)(ln,{checkId:e.checkId},e.checkId)})})})]}):(0,i.jsx)(eZ.M,{h:"100%",children:(0,i.jsx)(l.x,{children:"No checks"})})};var lj=t(21297);let ly=()=>{let{isHistoryOpen:e,showHistory:n,closeHistory:t}=nq();return(0,i.jsxs)(l.x,{children:[(0,i.jsx)(l.x,{fontSize:"8pt",children:"History"}),(0,i.jsx)(er.z,{leftIcon:(0,i.jsx)(s.J,{as:eY.M1Q}),size:"xs",variant:"outline",onClick:()=>{e?(iT({name:"hide"}),t()):(iT({name:"show"}),n())},children:e?"Hide":"Show"})]})},lb=()=>{let{isCustomQueries:e,setCustomQueries:n,sqlQuery:t,setBaseSqlQuery:r}=_();return(0,i.jsxs)(l.x,{children:[(0,i.jsxs)(l.x,{fontSize:"8pt",children:["Custom Queries ","",(0,i.jsx)(nh.u,{label:"Custom queries allow you to use two SQL queries to compare results between current and base environments.",children:(0,i.jsx)(tH.s,{color:"gray.600",boxSize:"3"})})]}),(0,i.jsx)(lj.r,{size:"sm",isChecked:e,onChange:()=>{!1===e&&r&&r(t),n(!e)}})]})},lw=()=>{let{sqlQuery:e,baseSqlQuery:n,setSqlQuery:t,setBaseSqlQuery:r,primaryKeys:s,setPrimaryKeys:a,isCustomQueries:c}=_(),{envInfo:d}=eg(),u=e;(null==d?void 0:d.adapterType)==="sqlmesh"&&e===w&&(u="select * from db.mymodel");let{showRunId:x}=nq(),m=async e=>{let t="query_base"===e?n||"":u,i=function(e){switch(e){case"query":return ix;case"query_base":return im;case"query_diff":return ip;default:throw Error("Unknown query type: ".concat(e))}}(e),l={sql_template:t};"query_diff"===e&&(l.primary_keys=s,c&&(l.base_sql_template=n));let{run_id:r}=await i(l,{nowait:!0});return x(r),await ec(r)},{mutate:p,isPending:f}=(0,te.D)({mutationFn:m});return(0,i.jsxs)(o.k,{direction:"column",height:"100%",children:[(0,i.jsxs)(o.k,{justifyContent:"right",alignItems:"center",padding:"4pt 8pt",gap:"5px",height:"54px",borderBottom:"1px solid lightgray",flex:"0 0 54px",children:[(0,i.jsx)(ly,{}),(0,i.jsx)(lb,{}),(0,i.jsx)(h.L,{}),(0,i.jsx)(ib,{defaultPrimaryKeys:s,onPrimaryKeysChange:a}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>p("query_diff"),isDisabled:f,size:"xs",fontSize:"14px",marginTop:"16px",children:"Run Diff"})]}),(0,i.jsx)(l.x,{width:"100%",flex:"1",children:c?(0,i.jsx)(tD,{value:u,baseValue:n,onChange:t,onChangeBase:r,onRun:()=>p("query"),onRunBase:()=>p("query_base"),onRunDiff:()=>p("query_diff")}):(0,i.jsx)(tT,{value:u,onChange:t,onRun:()=>p("query"),onRunDiff:()=>p("query_diff")})})]})};var lk=t(26143);let lC=e=>(0,lk.c4)("#!"+e),l_=()=>[(0,lk.LD)(()=>window.location.hash.replace(/^#!/,"")||"/",()=>"/ssr"),lC];var lS=t(35653),lz=t(38222);let lR=e=>{var n;let{runId:t}=e,{isPending:l,error:r,data:s}=(0,y.a)({queryKey:P.run(t),queryFn:async()=>ec(t)}),o=(null==s?void 0:s.type)?null===(n=nO(s.type))||void 0===n?void 0:n.RunResultView:void 0;return(0,i.jsx)(tM,{isPending:l,error:r,run:s,RunResultView:o})},lE=e=>{let{error:n,resetError:t}=e;return(0,i.jsx)(eZ.M,{height:"100%",backgroundColor:"gray.50",children:(0,i.jsxs)(o.k,{p:4,direction:"column",justifyContent:"flex-start",backgroundColor:"white",border:"solid lightgray 1px",minHeight:"200px",children:[(0,i.jsx)(c.X,{width:"800px",size:"md",children:"You have encountered an error"}),(0,i.jsx)(l.x,{flex:"1",fontSize:"10pt",children:n.toString()}),(0,i.jsx)(er.z,{justifySelf:"center",alignSelf:"center",mt:"20px",colorScheme:"blue",size:"sm",onClick:()=>{t()},children:"Reset"})]})})},lT=e=>{let{children:n}=e;return(0,i.jsx)(tI.SV,{fallback:lE,children:n})};function lD(){let e=(0,G.p)(),n=async()=>{try{let e=await lo(),n=JSON.stringify(e,null,2),t=new Blob([n],{type:"application/json"}),i=new Date,l="recce-state-".concat((0,ii.WU)(i,"yyyy-MM-dd-HH-mm-ss"),".json");ir()(t,l)}catch(n){console.error("Export failed",n),e({title:"Export failed",description:"".concat(n),status:"error",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0})}};return(0,i.jsx)(nh.u,{label:"Export",children:(0,i.jsx)(nS.h,{size:"sm",variant:"unstyled","aria-label":"Export state",onClick:n,icon:(0,i.jsx)(s.J,{as:lh,verticalAlign:"middle",boxSize:"16px"})})})}t(58923);var lL=t(71651),lI=t(87202),lM=t(9783),lO=t(34889),lA=t(33246),lF=t(67192),lN=t(37854),lq=t(31617);function lV(e){let n=(0,lq.D)(e);return(0,ii.WU)(n,"yyyy-MM-dd'T'HH:mm:ss")}function lH(e){return Object.values(e).every(e=>null===e)?[(0,i.jsx)(o.k,{ml:"10px",children:"No information"},"no info")]:Object.entries(e).filter(e=>{let[n,t]=e;return"url"!==n&&null!=t}).map(e=>{let[n,t]=e;return(0,i.jsxs)(tu.HC,{ml:"10px",children:[n,": ",t]},n)})}function lP(){var e,n,t,l,a,d;let{envInfo:u,reviewMode:h,lineageGraph:x}=eg(),{isOpen:m,onOpen:p,onClose:f}=(0,eb.q)(),g=null==u?void 0:u.git,v=null==u?void 0:u.pullRequest,j={...g,...v},y=null==u?void 0:null===(e=u.dbt)||void 0===e?void 0:e.base,b=null==u?void 0:null===(n=u.dbt)||void 0===n?void 0:n.current,w=(null==y?void 0:y.generated_at)?lV(null==y?void 0:y.generated_at):"",k=(null==b?void 0:b.generated_at)?lV(null==b?void 0:b.generated_at):"",C=new Set,_=new Set;if(null==x?void 0:x.nodes)for(let e of Object.values(null==x?void 0:x.nodes))(null===(a=e.data.base)||void 0===a?void 0:a.schema)&&C.add(e.data.base.schema),(null===(d=e.data.current)||void 0===d?void 0:d.schema)&&_.add(e.data.current.schema);return(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(nh.u,{label:"Environment Info",placement:"bottom-end",children:(0,i.jsx)(nS.h,{size:"sm",variant:"unstyled","aria-label":"Export state",onClick:p,icon:(0,i.jsx)(s.J,{verticalAlign:"middle",as:lf,boxSize:"16px"})})}),(0,i.jsxs)(Y.u_,{isOpen:m,onClose:f,size:"3xl",children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{children:[(0,i.jsx)(en.x,{children:"Environment Information"}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(et.f,{children:(0,i.jsxs)(o.k,{direction:"column",gap:"5px",children:[h?(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(o.k,{justifyContent:"left",gap:"5px",direction:"column",children:[(0,i.jsx)(c.X,{size:"sm",children:"Review Information"}),(0,i.jsxs)(tu.QI,{spacing:1,children:[(null==j?void 0:j.url)&&(0,i.jsxs)(tu.HC,{ml:"10px",children:["url:"," ",(0,i.jsx)(r.r,{href:j.url,color:"blue.500",isExternal:!0,children:j.url})]}),j&&lH(j)]})]})}):(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)(o.k,{justifyContent:"left",gap:"5px",direction:"column",children:[(0,i.jsx)(c.X,{size:"sm",children:"Dev Information"}),(0,i.jsx)(tu.QI,{spacing:1,children:g&&lH(g)})]})}),(0,i.jsx)(nx.i,{}),(null==u?void 0:u.adapterType)==="dbt"&&(0,i.jsxs)(o.k,{justifyContent:"left",gap:"5px",direction:"column",children:[(0,i.jsx)(c.X,{size:"sm",children:"DBT"}),(0,i.jsx)(lL.x,{children:(0,i.jsxs)(lI.i,{variant:"simple",children:[(0,i.jsx)(lM.h,{children:(0,i.jsxs)(lO.Tr,{children:[(0,i.jsx)(lA.Th,{}),(0,i.jsx)(lA.Th,{children:"base"}),(0,i.jsx)(lA.Th,{children:"current"})]})}),(0,i.jsxs)(lF.p,{children:[(0,i.jsxs)(lO.Tr,{children:[(0,i.jsx)(lN.Td,{children:"schema"}),(0,i.jsx)(lN.Td,{children:JSON.stringify(Array.from(C))}),(0,i.jsx)(lN.Td,{children:JSON.stringify(Array.from(_))})]}),(0,i.jsxs)(lO.Tr,{children:[(0,i.jsx)(lN.Td,{children:"version"}),(0,i.jsx)(lN.Td,{children:null==y?void 0:y.dbt_version}),(0,i.jsx)(lN.Td,{children:null==b?void 0:b.dbt_version})]}),(0,i.jsxs)(lO.Tr,{children:[(0,i.jsx)(lN.Td,{children:"timestamp"}),(0,i.jsx)(lN.Td,{children:w}),(0,i.jsx)(lN.Td,{children:k})]})]})]})})]}),(null==u?void 0:u.adapterType)==="sqlmesh"&&(0,i.jsxs)(o.k,{justifyContent:"left",gap:"5px",direction:"column",children:[(0,i.jsx)(c.X,{size:"sm",children:"SQLMesh"}),(0,i.jsx)(lL.x,{children:(0,i.jsxs)(lI.i,{variant:"simple",children:[(0,i.jsx)(lM.h,{children:(0,i.jsxs)(lO.Tr,{children:[(0,i.jsx)(lA.Th,{}),(0,i.jsx)(lA.Th,{children:"base"}),(0,i.jsx)(lA.Th,{children:"current"})]})}),(0,i.jsx)(lF.p,{children:(0,i.jsxs)(lO.Tr,{children:[(0,i.jsx)(lN.Td,{children:"Environment"}),(0,i.jsx)(lN.Td,{children:null==u?void 0:null===(t=u.sqlmesh)||void 0===t?void 0:t.base_env}),(0,i.jsx)(lN.Td,{children:null==u?void 0:null===(l=u.sqlmesh)||void 0===l?void 0:l.current_env})]})})]})})]})]})}),(0,i.jsx)(el.m,{children:(0,i.jsx)(er.z,{colorScheme:"blue",mr:3,onClick:f,children:"Close"})})]})]})]})}function lW(){return(0,i.jsx)(R.tV,{children:(0,i.jsx)(i3,{interactive:!0})})}async function lK(){return(await U.get("/api/flag")).data}async function lJ(){try{await U.post("/api/onboarding/completed")}catch(e){}}let lB=()=>(0,y.a)({queryKey:P.flag(),queryFn:lK});var lU=t(97530);let lZ=e=>{let{isGuideOpen:n,closeGuide:t}=e;return(0,i.jsxs)(Y.u_,{isOpen:n,onClose:t,scrollBehavior:"inside",children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{maxW:"80vw",h:"80vh",children:[(0,i.jsx)(en.x,{children:"Welcome to Recce: 3 Steps to Begin"}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(et.f,{children:(0,i.jsxs)(tR.K,{spacing:4,children:[(0,i.jsxs)(tu.aV,{spacing:2,children:[(0,i.jsx)(tu.HC,{children:"Step 1: Click the model you want to check"}),(0,i.jsx)(tu.HC,{children:'Step 2: Click "Explore Change"'}),(0,i.jsx)(tu.HC,{children:'Step 3: Click "Add to Checklist"'})]}),(0,i.jsx)(nx.i,{}),(0,i.jsx)(a.E,{src:"https://datarecce.io/assets/images/onboarding/material.svg",alt:"placeholder"})]})}),(0,i.jsx)(el.m,{children:(0,i.jsx)(er.z,{colorScheme:"blue",onClick:t,children:"Got it!"})})]})]})},lQ=e=>{let{isGuideOpen:n,closeGuide:t}=e;return(0,i.jsxs)(Y.u_,{isOpen:n,onClose:t,scrollBehavior:"inside",children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{maxW:"40vw",h:"300px",children:[(0,i.jsx)(en.x,{children:"All nodes displayed"}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(nx.i,{}),(0,i.jsx)(et.f,{children:(0,i.jsxs)(tR.K,{spacing:4,children:[(0,i.jsx)(ei.x,{children:"In a single environment with only a target, no nodes are marked as changed."}),(0,i.jsxs)(o.k,{bg:"blue.100",color:"blue.700",children:[(0,i.jsx)(lU.h,{mt:"10px",ml:"5px"}),(0,i.jsxs)(ei.x,{margin:"5px",paddingX:"3px",children:["To see changed nodes, configure a target-base."," ",(0,i.jsx)(r.r,{textDecor:"underline",isExternal:!0,href:"https://datarecce.io/docs",children:"Learn how."})]})]})]})}),(0,i.jsx)(nx.i,{}),(0,i.jsx)(el.m,{children:(0,i.jsx)(er.z,{colorScheme:"blue",onClick:t,children:"Got it!"})})]})]})};var lX=()=>{let[e,n]=(0,j.useState)(!1),[t,l]=(0,j.useState)(!1),{data:r,isLoading:s}=lB();(0,j.useEffect)(()=>{if(!s&&r){let e=r.show_onboarding_guide;if(r.single_env_onboarding&&e){l(!0);return}!localStorage.getItem("hasVisited")&&e&&(n(!0),localStorage.setItem("hasVisited","true"))}},[r,s]);let o=()=>{n(!1),l(!1),lJ()};return s?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(lZ,{isGuideOpen:e,closeGuide:o}),(0,i.jsx)(lQ,{isGuideOpen:t,closeGuide:o})]})},lG=t(39502);t(28269);let lY=e=>{var n;let{run:t,isSelected:r,onSelectRun:a,onAddToChecklist:c,onGoToCheck:d}=e,{data:u}=(0,y.a)({queryKey:P.run(t.run_id),queryFn:async()=>await ec(t.run_id),enabled:(null==t?void 0:t.status)==="running",retry:!1}),h=(null===(n=nO(t.type))||void 0===n?void 0:n.icon)||ek.WzH,x=t.check_id;return(0,i.jsxs)(o.k,{minWidth:"200px",direction:"column",width:"100%",p:"5px 20px",cursor:"pointer",borderBottom:"solid 1px lightgray",borderLeft:"4px",borderLeftColor:r?"orange.400":"transparent",backgroundColor:r?"orange.50":"transparent",onClick:()=>{a(t.run_id)},_hover:{bg:r?"orange.50":"gray.200"},children:[(0,i.jsxs)(o.k,{onClick:()=>{},alignItems:"center",gap:"12px",children:[(0,i.jsx)(s.J,{as:h}),(0,i.jsx)(l.x,{flex:"1",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",color:t.name?"inherit":"gray.500",fontSize:"11pt",fontWeight:"500",children:t.name||""}),x?(0,i.jsx)(nh.u,{label:"Go to Check","aria-label":"Go to Check",children:(0,i.jsx)(ei.x,{onClick:e=>{e.preventDefault(),e.stopPropagation(),d(x)},children:(0,i.jsx)(s.J,{color:"green",as:th.FJM})})}):(0,i.jsx)(nh.u,{label:"Add to Checklist","aria-label":"Add to Checklist",children:(0,i.jsx)(ei.x,{onClick:e=>{e.preventDefault(),e.stopPropagation(),iT({name:"add_to_checklist"}),c(t.run_id)},children:(0,i.jsx)(s.J,{as:th.wO})})})]}),(0,i.jsx)(o.k,{justifyContent:"start",fontSize:"11pt",color:"gray.500",gap:"3px",alignItems:"center",children:(0,i.jsx)(ic,{run:u||t})})]})},l$=e=>{let{runAt:n}=e,t=n?function(e){let n=new Date,t=new Date;return(t.setDate(n.getDate()-1),null==e)?null:n.toDateString()===e.toDateString()?"Today":t.toDateString()===e.toDateString()?"Yesterday":(0,ii.WU)(e,"MMM d")}(new Date(n)):null;return(0,i.jsx)(o.k,{minWidth:"200px",width:"100%",p:"5px 20px",borderBottom:"solid 1px lightgray",color:"gray.500",fontSize:"11pt",children:t})},l0=()=>{let{data:e,isLoading:n,isFetching:t,error:r,refetch:s}=(0,y.a)({queryKey:P.runs(),queryFn:async()=>await ex(),retry:!1}),{showRunId:a,runId:d}=nq(),x=e=>{iT({name:"click_run"}),a(e,!1)},[,m]=(0,ew.TH)(),p=(0,b.NL)(),f=(0,j.useCallback)(async()=>{if(!d)return;let e=await nP(d);p.invalidateQueries({queryKey:P.checks()}),m("/checks/".concat(e.check_id))},[d,m,p]),g=(0,j.useCallback)(e=>{iT({name:"go_to_check"}),m("/checks/".concat(e))},[m]),v=null;return(0,i.jsxs)(o.k,{direction:"column",height:"100%",children:[(0,i.jsxs)(u.U,{width:"100%",flex:"0 0 54px",paddingInline:"24px 8px",borderBottom:"solid 1px lightgray",children:[(0,i.jsx)(c.X,{size:"md",children:"History"}),(0,i.jsx)(h.L,{}),(0,i.jsx)(nS.h,{variant:"unstyled",icon:(0,i.jsx)(n5.n,{}),"aria-label":"Search database",onClick:()=>{s()}})]}),(0,i.jsx)(l.x,{flex:"1 1 auto",children:n?"Loading...":(null==e?void 0:e.length)===0?(0,i.jsx)(eZ.M,{height:"100%",color:"gray.400",children:"No runs"}):(0,i.jsx)(lG.Z,{style:{minHeight:"100%",height:0},children:(e||[]).map((e,n)=>{let t=new Date(e.run_at).toDateString(),l=null!=v&&v!==t;return v=t,(0,i.jsxs)(i.Fragment,{children:[l&&(0,i.jsx)(l$,{runAt:e.run_at},t),(0,i.jsx)(lY,{run:e,isSelected:e.run_id===d,onSelectRun:x,onGoToCheck:g,onAddToChecklist:f},e.run_id)]})})})})]})};var l1=t(5552),l5=t(34533);let{definePartsStyle:l2,defineMultiStyleConfig:l4}=(0,l5.D)(l1.TB.keys),l6=l4({variants:{circular:l2({control:(0,l5.k0)({rounded:"full"})})},sizes:{xs:l2({icon:(0,l5.k0)({fontSize:"8px"}),control:(0,l5.k0)({boxSize:"16px",padding:"4px"}),label:(0,l5.k0)({fontSize:"xs"})})}}),l3=(0,t(86907).fj)({baseStyle:{borderRadius:"4px"}});var l9=t(35051);let l8=()=>{let e=(0,G.p)();return{toastSuccess:n=>{e({description:n,status:"success",variant:"left-accent",position:"bottom-right",duration:5e3,isClosable:!0})},toastError:(n,t)=>{var i,l;e({description:t?t instanceof iX.d7?"".concat(n,". ").concat(null==t?void 0:null===(l=t.response)||void 0===l?void 0:null===(i=l.data)||void 0===i?void 0:i.detail):"".concat(n,". ").concat(t):"".concat(n),status:"error",variant:"left-accent",position:"bottom-right",duration:5e3,isClosable:!0})}}},l7=e=>{(0,j.useEffect)(()=>{let n=e=>{e.preventDefault()};return e&&window.addEventListener("beforeunload",n),()=>{e&&window.removeEventListener("beforeunload",n)}},[e])},re=()=>{let{fileName:e,cloudMode:n,isDemoSite:t,isLoading:r}=eg(),a=(0,eb.q)(),c=(0,eb.q)(),d=!e&&!n&&!t,{data:u}=(0,y.a)({queryKey:P.checks(),queryFn:nW,enabled:d}),h=void 0!=u&&u.filter(e=>!e.is_preset).length>0;l7(d&&h);let[{newFileName:x,errorMessage:m,modified:p,overwriteWithMethod:f,bypass:g},v]=(0,j.useState)({newFileName:e||"recce_state.json"}),w=(0,j.useRef)(null),{toastSuccess:k,toastError:C}=l8(),_=(0,b.NL)(),S=async(e,n)=>{if(!x)return;let t="true"===localStorage.getItem(iS.bypassSaveOverwrite);try{"save"===e?await lr({filename:x,overwrite:n||t}):await ls({filename:x,overwrite:n||t}),k("save"===e?"Save file successfully":"Rename file successfully"),_.invalidateQueries({queryKey:P.lineage()}),g&&localStorage.setItem(iS.bypassSaveOverwrite,"true")}catch(n){if(n instanceof iX.d7){var i;if((null===(i=n.response)||void 0===i?void 0:i.status)===409){v(n=>({...n,overwriteWithMethod:e})),c.onOpen();return}}C("save"===e?"Save file failed":"Rename file failed",n)}finally{a.onClose()}};return n||t?(0,i.jsx)(i.Fragment,{}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)(o.k,{flex:"1",justifyContent:"center",alignItems:"center",children:[(0,i.jsx)(l.x,{fontWeight:"600",children:e||(n?"cloud":"New Instance"+(h?" (unsaved)":""))}),(0,i.jsx)(nh.u,{label:e?"Change Filename":"Save",openDelay:1e3,children:(0,i.jsx)(nS.h,{onClick:()=>{v({newFileName:e||"recce_state.json",modified:!e}),a.onOpen()},"aria-label":"",variant:"unstyled",size:"sm",children:(0,i.jsx)(s.J,{as:e?lp:lm,boxSize:"16px",verticalAlign:"middle"})})})]}),(0,i.jsxs)(Y.u_,{isOpen:a.isOpen,onClose:a.onClose,isCentered:!0,children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{children:[(0,i.jsx)(en.x,{children:e?"Change Filename":"Save File"}),(0,i.jsx)(ej.o,{}),(0,i.jsx)(et.f,{onKeyDown:e=>{e.stopPropagation()},children:(0,i.jsxs)(eC.NI,{isInvalid:!!m,children:[(0,i.jsx)(e_.l,{children:"File name:"}),(0,i.jsx)(nb.I,{ref:w,value:x,placeholder:"Enter filename",onChange:n=>{let t;let i=n.target.value;i?i.endsWith(".json")?/^[a-zA-Z0-9 _-]+\.json$/.test(i)?e&&i===e&&(t="Filename is the same as the current one."):t="Invalid filename. Only alphanumeric, space, _ and - are allowed.":t="Filename must end with .json.":t="Filename cannot be empty.",v(e=>({...e,modified:!0,newFileName:i,errorMessage:t}))},onKeyDown:n=>{"Enter"===n.key?m||(e?S("rename"):S("save")):"Escape"===n.key&&a.onClose()}}),(0,i.jsx)(l9.J1,{children:m})]})}),(0,i.jsxs)(el.m,{gap:"5px",children:[(0,i.jsx)(er.z,{size:"sm",colorScheme:e?void 0:"blue",onClick:()=>{S("save")},isDisabled:!x||!!m||!p,children:e?"Save as New File":"Confirm"}),e&&(0,i.jsx)(er.z,{size:"sm",colorScheme:"blue",onClick:()=>{S("rename")},isDisabled:!x||!!m||!p,children:"Rename"})]})]})]}),(0,i.jsxs)(Y.u_,{isOpen:c.isOpen,onClose:c.onClose,initialFocusRef:w,isCentered:!0,children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{children:[(0,i.jsx)(en.x,{children:"Overwrite File?"}),(0,i.jsx)(ej.o,{}),(0,i.jsxs)(et.f,{borderTop:"solid 1px lightgray",borderBottom:"solid 1px lightgray",onKeyDown:e=>{e.stopPropagation()},children:[(0,i.jsx)(l.x,{fontSize:"12pt",children:"save"===f?"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?"}),(0,i.jsx)(nn.X,{isChecked:g,onChange:e=>v(n=>({...n,bypass:e.target.checked})),fontWeight:"bold",size:"sm",pt:"8px",children:"Don't show this again"})]}),(0,i.jsxs)(el.m,{gap:"5px",children:[(0,i.jsx)(er.z,{variant:"outline",onClick:()=>{c.onClose(),a.onOpen(),v(e=>({...e,overwriteWithMethod:void 0}))},size:"sm",children:"Back"}),(0,i.jsx)(er.z,{size:"sm",colorScheme:"blue",onClick:()=>{f&&(S(f,!0),c.onClose())},children:"Overwrite"})]})]})]})]})};var rn=t(2842),rt=t(49624);function ri(){return(0,i.jsx)(nh.u,{label:"Syncing",children:(0,i.jsx)(er.z,{pt:"6px",variant:"unstyled",boxSize:"1em",children:(0,i.jsx)(tA.$,{})})})}function rl(){let[e,n]=(0,j.useState)(!1),t=(0,b.NL)(),[r,o]=(0,ew.TH)(),{isOpen:a,onOpen:c,onClose:d}=(0,eb.q)(),[u,h]=(0,j.useState)(""),x=(0,G.p)(),m=(0,j.useCallback)(async e=>{if(d(),n(!0),"conflict"===(await ld(e)).status){c(),n(!1);return}for(;await lc();)await new Promise(e=>setTimeout(e,1e3));x({description:"Sync Completed",status:"success",variant:"left-accent",position:"bottom",duration:5e3,isClosable:!0}),n(!1),h(""),t.invalidateQueries({queryKey:P.lineage()}),t.invalidateQueries({queryKey:P.checks()}),t.invalidateQueries({queryKey:P.runs()}),/^\/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(r)&&o("/checks")},[t,r,o,x,c,d]);return e?(0,i.jsx)(ri,{}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(nh.u,{label:"Sync with Cloud",children:(0,i.jsx)(nS.h,{size:"sm",variant:"unstyled","aria-label":"Sync state",onClick:()=>m({}),icon:(0,i.jsx)(s.J,{as:lu,verticalAlign:"middle",boxSize:"16px"})})}),(0,i.jsxs)(Y.u_,{isOpen:a,onClose:d,children:[(0,i.jsx)($.Z,{}),(0,i.jsxs)(ee.h,{children:[(0,i.jsx)(en.x,{fontSize:"lg",fontWeight:"bold",children:"Sync with Cloud"}),(0,i.jsxs)(et.f,{children:[(0,i.jsx)(l.x,{children:"New changes have been detected in the cloud. Please choose a method to sync your state"}),(0,i.jsx)(l.x,{mt:"5px",children:(0,i.jsx)(rn.E,{onChange:h,value:u,children:(0,i.jsxs)(tR.K,{direction:"column",children:[(0,i.jsxs)(rt.Y,{value:"merge",children:["Merge",(0,i.jsx)(nh.u,{label:"This will merge the local and remote states.",children:(0,i.jsx)("span",{children:(0,i.jsx)(s.J,{as:lU.h,ml:2,cursor:"pointer"})})})]}),(0,i.jsxs)(rt.Y,{value:"overwrite",children:["Overwrite",(0,i.jsx)(nh.u,{label:"This will overwrite the remote state file with the local state.",children:(0,i.jsx)("span",{children:(0,i.jsx)(s.J,{as:lU.h,ml:2,cursor:"pointer"})})})]}),(0,i.jsxs)(rt.Y,{value:"revert",children:["Revert",(0,i.jsx)(nh.u,{label:"This will discard local changes and revert to the cloud state.",children:(0,i.jsx)("span",{children:(0,i.jsx)(s.J,{as:lU.h,ml:2,cursor:"pointer"})})})]})]})})})]}),(0,i.jsxs)(el.m,{children:[(0,i.jsx)(er.z,{onClick:d,mr:3,children:"Cancel"}),(0,i.jsx)(er.z,{colorScheme:"blue",onClick:()=>m({method:u}),isDisabled:!u,children:"Sync"})]})]})]})]})}let rr=e=>{let{children:n,path:t}=e,[r]=(0,ew.yj)(t);return(0,i.jsx)(l.x,{display:r?"block":"none",height:"100%",children:n})};function rs(e){let{icon:n,href:t,...l}=e;return(0,i.jsx)(r.r,{height:"20px",color:"white",href:t,isExternal:!0,...l,children:(0,i.jsx)(s.J,{color:"white",boxSize:"20px",as:n})})}function ro(){let{reviewMode:e,isDemoSite:n,envInfo:t,cloudMode:x,isLoading:m}=eg(),p=function(){let[e,n]=(0,j.useState)("");return(0,j.useEffect)(()=>{(async function(){try{let e=await U.get("/api/version");n(e.data)}catch(e){console.error("Error fetching version number:",e)}})()},[]),e}(),{url:f,id:g}=(null==t?void 0:t.pullRequest)||{},v=f?f.split("/").pop():null;return(0,i.jsxs)(o.k,{gap:"10px",minHeight:"40px",alignItems:"center",bg:"rgb(255, 110, 66)",children:[(0,i.jsx)(a.E,{boxSize:"20px",ml:"18px",src:"/logo/recce-logo-white.png",alt:"recce-logo-white"}),(0,i.jsx)(c.X,{as:"h1",fontFamily:'"Montserrat", sans-serif',fontSize:"lg",color:"white",children:"RECCE"}),(0,i.jsx)(d.C,{fontSize:"sm",color:"white",colorScheme:"whiteAlpha",variant:"outline",children:p}),e&&(0,i.jsx)(d.C,{fontSize:"sm",color:"white",colorScheme:"whiteAlpha",variant:"outline",children:"review mode"}),x&&(0,i.jsx)(d.C,{fontSize:"sm",color:"white",colorScheme:"whiteAlpha",variant:"outline",children:(0,i.jsxs)(u.U,{children:[(0,i.jsx)(l.x,{children:"cloud mode"}),(0,i.jsx)(l.x,{borderLeft:"1px",borderLeftColor:"whiteAlpha.500",paddingLeft:"8px",children:(0,i.jsxs)(r.r,{href:f,_hover:{textDecoration:"none"},isExternal:!0,children:[(0,i.jsx)(s.J,{as:eY.X9P,boxSize:"3",fontWeight:"extrabold",strokeWidth:"1"})," #".concat(g)]})})]})}),n&&f&&(0,i.jsx)(i.Fragment,{children:(0,i.jsx)(d.C,{fontSize:"sm",color:"white",colorScheme:"whiteAlpha",variant:"outline",children:(0,i.jsxs)(u.U,{children:[(0,i.jsx)(l.x,{children:"demo mode"}),(0,i.jsx)(l.x,{borderLeft:"1px",borderLeftColor:"whiteAlpha.500",paddingLeft:"8px",children:(0,i.jsxs)(r.r,{href:f,_hover:{textDecoration:"none"},isExternal:!0,children:[(0,i.jsx)(s.J,{as:eY.X9P,boxSize:"3",fontWeight:"extrabold",strokeWidth:"1"})," #".concat(v)]})})]})})}),(0,i.jsx)(h.L,{}),(0,i.jsx)(rs,{icon:th.hJX,href:"https://github.com/DataRecce/recce"}),(0,i.jsx)(rs,{icon:th.w5k,href:"https://getdbt.slack.com/archives/C05C28V7CPP"}),(0,i.jsx)(rs,{mr:"18px",icon:th.MXt,href:"https://datarecce.io/docs"})]})}function ra(e){let{queryKey:n,fetchCallback:t,selectCallback:r}=e,{data:s,isLoading:o,error:a}=(0,y.a)({queryKey:n,queryFn:t,select:r});return o||a||0===s?(0,i.jsx)(i.Fragment,{}):(0,i.jsx)(l.x,{ml:"2px",height:"80%",aspectRatio:1,borderRadius:"full",bg:"tomato",alignContent:"center",color:"white",fontSize:"xs",children:s})}function rc(){let{isDemoSite:e,reviewMode:n,fileMode:t,cloudMode:r,isLoading:s}=eg(),[a,c]=(0,ew.TH)(),d=[{name:"Lineage",href:"/lineage"},{name:"Query",href:"/query"},{name:"Checklist",href:"/checks",badge:(0,i.jsx)(ra,{queryKey:P.checks(),fetchCallback:nW,selectCallback:e=>e.filter(e=>!e.is_checked).length})}],u=eR().findIndex(d,e=>{let{href:n}=e;return a.startsWith(n)});return(0,i.jsx)(x.m,{index:u,children:(0,i.jsxs)(m.t,{children:[(0,i.jsx)(l.x,{flex:"1",display:"flex",children:d.map(e=>{let{name:n,href:t,badge:l}=e;return(0,i.jsxs)(p.O,{onClick:()=>{c(t)},children:[n,l]},n)})}),!s&&!e&&(0,i.jsx)(re,{}),!s&&(0,i.jsxs)(o.k,{flex:"1",justifyContent:"right",alignItems:"center",mr:"8px",children:[r&&(0,i.jsx)(rl,{}),(0,i.jsx)(lD,{}),(0,i.jsx)(lP,{})]})]})})}function rd(){let{isRunResultOpen:e,isHistoryOpen:n,closeRunResult:t}=nq(),[r]=(0,ew.TH)(),s=e&&!r.startsWith("/checks"),o=n&&!r.startsWith("/checks");return(0,i.jsxs)(tc,{sizes:[0,100],minSize:o?300:0,gutterSize:o?5:0,style:{height:"100%"},children:[(0,i.jsx)(l.x,{style:{contain:"size"},children:o&&(0,i.jsx)(l0,{})}),(0,i.jsxs)(td,{sizes:s?[50,50]:[100,0],minSize:s?100:0,gutterSize:s?5:0,style:{flex:"1",contain:"size"},children:[(0,i.jsx)(l.x,{p:0,style:{contain:"content"},children:(0,i.jsxs)(lT,{children:[(0,i.jsx)(rr,{path:"/lineage",children:(0,i.jsx)(lW,{})}),(0,i.jsxs)(ew.rs,{children:[(0,i.jsx)(ew.AW,{path:"/query",children:(0,i.jsx)(lw,{})}),(0,i.jsx)(ew.AW,{path:"/checks/:slug*",children:(0,i.jsx)(lv,{})}),(0,i.jsx)(ew.AW,{path:"/runs/:runId",children:e=>{let{runId:n}=e;return(0,i.jsx)(lR,{runId:n})}}),(0,i.jsx)(ew.AW,{path:"/ssr",children:(0,i.jsx)(f.E,{size:"xs",isIndeterminate:!0})}),(0,i.jsx)(ew.AW,{children:(0,i.jsx)(ew.l_,{to:"/lineage"})})]})]})}),s?(0,i.jsx)(ih,{onClose:t}):(0,i.jsx)(l.x,{})]})]})}let ru=(0,g.B1)({components:{Checkbox:l6,Tooltip:l3}});function rh(){(0,j.useLayoutEffect)(()=>{!function(){var e;let n=(e=document.cookie.match("(^|;)\\s*recce_user_id\\s*=\\s*([^;]+)"))?e.pop():"",t=iR.env.AMPLITUDE_API_KEY;if(n&&t)try{iz.S1(t,n,{defaultTracking:!0})}catch(e){console.error(e)}}()},[]);let e=(0,lS.Z)({components:{MuiTooltip:{styleOverrides:{tooltip:{zIndex:1500}}}}});return(0,i.jsx)(lz.Z,{theme:e,children:(0,i.jsx)(v.x,{theme:ru,children:(0,i.jsx)(b.aH,{client:Z,children:(0,i.jsx)(ew.F0,{hook:l_,children:(0,i.jsx)(nV,{children:(0,i.jsxs)(o.k,{direction:"column",height:"100vh",overflow:"hidden",children:[(0,i.jsx)(ro,{}),(0,i.jsx)(rc,{}),(0,i.jsx)(lX,{}),(0,i.jsx)(rd,{})]})})})})})})}},76890:function(){},24550:function(){},50394:function(){},5637:function(){}},function(e){e.O(0,[887,524,434,678,509,648,989,147,995,739,283,303,22,25,355,495,599,852,67,868,986,744],function(){return e(e.s=17812)}),_N_E=e.O()}]);
\ No newline at end of file
diff --git a/recce/data/index.html b/recce/data/index.html
index 5cc0d4de..53452029 100644
--- a/recce/data/index.html
+++ b/recce/data/index.html
@@ -1,4 +1,4 @@
-recce
\ No newline at end of file
+ );position:absolute;will-change:left;min-width:50%;-webkit-animation:animation-11lmxjq 1s ease infinite normal none running;animation:animation-11lmxjq 1s ease infinite normal none running;}@-webkit-keyframes animation-11lmxjq{0%{left:-40%;}100%{left:100%;}}@keyframes animation-11lmxjq{0%{left:-40%;}100%{left:100%;}}