@owox/web 0.36.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-CfHV4Rj5.js","assets/index-BW17AtYZ.js","assets/index-Bu4VCLfp.css","assets/erd-fields-section-_gVp8PxG.js","assets/erd-fields-section-BnuhLJ6X.css"])))=>i.map(i=>d[i]);
2
+ import{t as Re,D as ke,r as l,j as n,A as kt,k as Mt,l as Pt,S as Ft,m as je,P as $t,n as Ht,o as De,p as Ut,q as Bt,s as Gt,L as Qt,v as Vt,w as Wt,T as Me,a as Pe,R as zt,H as Jt,b as Fe,x as Kt,y as qt,z as Zt,I as Yt,E as Xt,F as en,U as tn,G as nn,J as sn,K as an,O as rn,Q as on,V as P,W as ln,X as cn,Y as dn,_ as un,Z as ut,$ as ge,c as Se}from"./index-BW17AtYZ.js";import{A as pn,F as fn,p as hn,s as gn,t as mn,W as xn,m as Te,q as bn,B as wn,D as pt,v as Cn,w as vn,x as En,y as yn,u as jn,P as me,l as Ne,H as Ke,S as qe,E as Ze,N as Dn,R as Sn,b as Nn,c as Oe,d as On,e as Ye,n as _n,r as Ln,f as Xe,G as In,h as Rn,C as Tn,i as An,M as kn,j as Mn,o as Pn}from"./erd-fields-section-_gVp8PxG.js";import{P as Fn}from"./pencil-line-CUWsvz42.js";import{L as $n,Z as Hn,a as Un}from"./zoom-out-C2ChQihe.js";const Bn=[{part:"source",label:"Input source",helper:"View, Table, SQL, Pattern or Connector"},{part:"fields",label:"Fields",helper:"Number of fields in the Output Schema"},{part:"triggers",label:"Triggers",helper:"Scheduled triggers of the Data Mart"},{part:"reports",label:"Reports",helper:"Reports built on the Data Mart"},{part:"relationships",label:"Relationships",helper:"Joins with other Data Marts"},{part:"status",label:"Draft badge",helper:"Shown on Data Marts not yet published"},{part:"footer",label:"Quality and sharing",helper:"Data Quality, Data Last Updated and sharing icons"},{part:"fieldAlias",label:"Field aliases",helper:"Output Schema alias in place of the name"},{part:"fieldDescription",label:"Field descriptions",helper:"Output Schema description under each field"}],Gn=(t,e)=>[t,e].sort().join("->"),Qn=56;function Vn(t,e=Qn){const i=new Map;for(const a of t){if(a.sourceId===a.targetId)continue;const c=Gn(a.sourceId,a.targetId),h=i.get(c);h?h.push(a):i.set(c,[a])}const s=new Map;for(const a of t)a.sourceId===a.targetId&&s.set(a.id,0);for(const a of i.values()){const c=[...a].sort((b,x)=>b.id.localeCompare(x.id)),h=c.length;c.forEach((b,x)=>{s.set(b.id,(x-(h-1)/2)*e)})}return s}const Wn=11,zn=6.5;let _e,Le;const et=new Map;function Jn(){return _e===void 0&&(_e=typeof document>"u"?null:document.createElement("canvas").getContext("2d")),_e}function we(t){const e=et.get(t);if(e!==void 0)return e;const i=Jn();let s;return i?(Le??(Le=`${String(Wn)}px ${getComputedStyle(document.body).fontFamily||"sans-serif"}`),i.font=Le,s=i.measureText(t).width):s=t.length*zn,et.set(t,s),s}const Kn=40,qn=12,Zn=28,Yn=24,Xn=42,ei=240,ti=256;function Ce(t){return t==="erd"?ti:ei}function Ae(t){return{sourceHidden:t.source,fieldCountHidden:t.fields,triggersHidden:t.triggers,reportsHidden:t.reports,relationshipsHidden:t.relationships,footerHidden:t.footer,fieldLabels:Re(t)}}function ft(t,{sourceHidden:e=!1,fieldCountHidden:i=!1,triggersHidden:s=!1,reportsHidden:a=!1,relationshipsHidden:c=!1}={}){return{definition:!e&&!!t.definitionType&&ke.getInfo(t.definitionType).type!==null,fieldCount:!i&&t.fieldCount>0,triggers:!s&&(t.triggersCount??0)>0,reports:!a&&(t.reportsCount??0)>0,relationships:!c&&(t.relationshipCount??0)>0}}function xe(t,e){return`${String(t)} ${e}${t===1?"":"s"}`}function ni(t,e){const i=[];return e.definition&&t.definitionType&&i.push({kind:"definition",label:ke.getInfo(t.definitionType).displayName}),e.fieldCount&&i.push({kind:"fields",label:xe(t.fieldCount,"field")}),e.triggers&&i.push({kind:"triggers",label:xe(t.triggersCount??0,"trigger")}),e.reports&&i.push({kind:"reports",label:xe(t.reportsCount??0,"report")}),e.relationships&&i.push({kind:"relationships",label:xe(t.relationshipCount??0,"relationship")}),i}const ii=26,si=28,tt=4,ai=2;function ri(t,e,i=we){const s=Ce(e)-ii,a=[];let c=0;for(const h of t){const b=Math.ceil(i(h.label))+si+ai,x=a.at(-1);x&&c+tt+b<=s?(x.push(h),c+=tt+b):(a.push([h]),c=b)}return a}function ht(t,e,i={},s=we){return ri(ni(t,ft(t,i)),e,s)}function oi(t,e,i={},s=we){return ht(t,e,i,s).length}function li(t,e,i,s){const a=oi(t,e,i,s),c=a===0?0:Zn+(a-1)*Yn,h=i.footerHidden?qn:Xn;return Kn+c+h}function gt(t,e,i={},s=we){const a=li(t,e,i,s);if(e!=="erd")return a;const c=t.fields??[];return c.length===0?a:a+pn(c,i.fieldLabels??fn)}function ci(t,e,i,s,a,c){let h,b,x,y;if(c==="vertical"){const j=Math.max(40,Math.abs(s-e)*.3);h=t+a,b=e+j,x=i+a,y=s-j}else{const j=Math.max(40,Math.abs(i-t)*.3);h=t+j,b=e+a,x=i-j,y=s+a}return{path:`M ${t} ${e} C ${h} ${b}, ${x} ${y}, ${i} ${s}`,labelX:(t+3*h+3*x+i)/8,labelY:(e+3*b+3*y+s)/8}}function di({id:t,sourceX:e,sourceY:i,targetX:s,targetY:a,sourcePosition:c,targetPosition:h,selected:b,data:x}){const{bowOffset:y,warning:j,joinLabel:v,dimmed:g,direction:w,bidirectional:D}=x;let S;if(y!==0)S=ci(e,i,s,a,y,w);else{const[E,B,N]=hn({sourceX:e,sourceY:i,sourcePosition:c,targetX:s,targetY:a,targetPosition:h});S={path:E,labelX:B,labelY:N}}const _=j?xn:b?Te:bn,U=l.useId(),L=gn("mc-arrow",U);return n.jsxs(n.Fragment,{children:[n.jsx(mn,{markerId:L,color:_,withStart:D}),n.jsx(wn,{id:t,path:S.path,markerEnd:`url(#${L}-end)`,markerStart:D?`url(#${L}-start)`:void 0,style:{stroke:_,strokeWidth:b?vn:En,strokeDasharray:j?Cn:void 0,opacity:g?pt:1,transition:"opacity 0.2s, stroke 0.2s"}}),n.jsx(yn,{x:S.labelX,y:S.labelY,lines:v,selected:b??!1,dimmed:g,interactive:!0})]})}function nt({relationship:t}){const e=t.direction==="outgoing",i=e?kt:Mt,s=e?"Joins":"Joined by";return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",title:`${s} ${t.otherTitle}`,children:[n.jsx(i,{className:"text-muted-foreground h-3 w-3 shrink-0","aria-label":s}),n.jsx("span",{className:"text-foreground flex-1 truncate",children:t.otherTitle})]}),t.joinFields.length>0?t.joinFields.map(({field:a,otherField:c})=>n.jsxs("div",{className:"text-muted-foreground truncate pl-5 font-mono text-[10px] leading-[14px]",title:`${a} = ${c}`,children:[a," = ",c]},`${a}=${c}`)):n.jsx("div",{className:"text-muted-foreground/80 pl-5 text-[10.5px] leading-[14px] italic",children:"Join fields not set"})]})}function ui({dataMartTitle:t,relationships:e,onOpenRelationship:i}){return n.jsx("ul",{className:"border-t","aria-label":`Relationships of ${t}`,children:e.map(s=>n.jsx("li",{className:"border-border/50 border-b text-[11.5px] last:border-b-0",children:i?n.jsx("button",{type:"button",className:"nodrag hover:bg-muted/60 block w-full cursor-pointer px-3.5 py-1.5 text-left transition-colors","aria-label":`Open the relationship with ${s.otherTitle}`,onPointerDown:a=>{a.stopPropagation()},onClick:a=>{a.stopPropagation(),i(s.id,{viaKeyboard:a.detail===0})},children:n.jsx(nt,{relationship:s})}):n.jsx("div",{className:"px-3.5 py-1.5",children:n.jsx(nt,{relationship:s})})},`${s.id}:${s.direction}`))})}const pi={availableForReporting:{label:"Shared for reporting",description:"All project members can see this Data Mart and build reports on it"},availableForMaintenance:{label:"Shared for maintenance",description:"Members with the Data Owner role can edit, delete, and manage triggers for this Data Mart"}},fi=100,hi=200;function ne(t,e){return`${t} ${e}${t===1?"":"s"}`}function gi({dataMartTitle:t,summary:e,onOpenQuality:i,onRunQuality:s}){const[a,c]=l.useState(!1),[h,b]=l.useState(!1),x=l.useRef(null),y=l.useRef(null),j=l.useRef(null),v=l.useRef(null),g=l.useRef(null),w=l.useRef(!1),D=l.useRef(!1),S=l.useRef(!1),_=Pt(e),U=_.icon,L=[{count:e.errorChecks,singular:"execution error",tone:"error",icon:Ft},{count:e.errorFindings,singular:"critical finding",tone:"error",icon:je},{count:e.warningFindings,singular:"warning finding",tone:"warning",icon:je},{count:e.noticeFindings,singular:"notice finding",tone:"notice",icon:je}].filter(u=>u.count>0),E=(e.state==="ISSUES"||e.state==="EXECUTION_FAILED")&&L.length>0,B=L.map(u=>ne(u.count,u.singular)).join(", "),N=`Open Data Quality for ${t}: ${_.label}${E?`, ${B}`:""}`,$=_.isActive,J=e.state==="QUEUED"?"Queued":e.state==="RUNNING"?"Started":"Last checked";function A(){v.current!==null&&(clearTimeout(v.current),v.current=null)}function K(){g.current!==null&&(clearTimeout(g.current),g.current=null)}function I(){A(),K()}function Y(){K(),!(a||w.current||v.current!==null)&&(v.current=setTimeout(()=>{v.current=null,!w.current&&c(!0)},fi))}function H(){A(),!(!a||w.current||g.current!==null)&&(g.current=setTimeout(()=>{g.current=null,!w.current&&c(!1)},hi))}function m(u){if(u.stopPropagation(),u.preventDefault(),I(),w.current&&a){w.current=!1,c(!1);return}w.current=!0,c(!0),u.detail===0&&queueMicrotask(()=>{var T;(T=j.current)==null||T.focus()})}function R(u){if(I(),u){w.current=!0,c(!0);return}w.current=!1,c(!1)}function ie(u){u.stopPropagation(),u.preventDefault(),i()}async function G(u){if(u.stopPropagation(),u.preventDefault(),!($||h)){b(!0);try{await s()}finally{b(!1)}}}return l.useEffect(()=>()=>{v.current!==null&&clearTimeout(v.current),g.current!==null&&clearTimeout(g.current)},[]),l.useEffect(()=>{if(!a)return;function u(T){var se,X;const q=T.target;q instanceof Node&&((se=x.current)!=null&&se.contains(q)||(X=y.current)!=null&&X.contains(q)||(v.current!==null&&(clearTimeout(v.current),v.current=null),g.current!==null&&(clearTimeout(g.current),g.current=null),w.current=!1,c(!1)))}return document.addEventListener("pointerdown",u,!0),()=>{document.removeEventListener("pointerdown",u,!0)}},[a]),n.jsxs($t,{open:a,onOpenChange:R,children:[n.jsx(Ht,{asChild:!0,children:n.jsx("button",{ref:x,type:"button",className:`${E?"":De[_.tone]} -ml-0.5 inline-flex shrink-0 cursor-pointer items-center rounded p-0.5 transition-colors ${E?"gap-1.5":""}`,"aria-label":N,onPointerDown:u=>{u.stopPropagation()},onPointerEnter:()=>{Y()},onPointerLeave:()=>{H()},onFocus:()=>{if(S.current){S.current=!1;return}Y()},onBlur:()=>{H()},onClick:m,children:E?L.map(u=>{const T=ne(u.count,u.singular),q=u.icon;return n.jsxs("span",{role:"img","aria-label":T,className:`${De[u.tone]} inline-flex items-center gap-0.5`,children:[n.jsx(q,{className:"size-4","aria-hidden":!0}),n.jsx("span",{className:"leading-none font-medium tabular-nums",children:u.count})]},u.singular)}):n.jsx(U,{className:`size-4 ${e.state==="RUNNING"?"animate-spin":""}`,"aria-hidden":!0})})}),n.jsxs(Ut,{ref:y,side:"top",align:"center",role:"region","aria-label":`Data Quality checks for ${t}`,className:"w-72 max-w-72 p-3 text-xs sm:w-72 sm:max-w-72",onOpenAutoFocus:u=>{u.preventDefault()},onCloseAutoFocus:u=>{var T;u.preventDefault(),D.current&&(D.current=!1,S.current=!0,(T=x.current)==null||T.focus({preventScroll:!0}),queueMicrotask(()=>{S.current=!1}))},onEscapeKeyDown:()=>{D.current=!0},onPointerEnter:()=>{K()},onPointerLeave:()=>{H()},onPointerDown:u=>{u.stopPropagation()},children:[n.jsxs("div",{className:"border-border flex items-center justify-between gap-3 border-b pb-2",children:[n.jsx(Bt,{className:"text-sm font-semibold whitespace-nowrap",children:"Data Quality checks"}),n.jsx("span",{className:`${De[_.tone]} shrink-0 font-medium whitespace-nowrap`,children:_.label})]}),n.jsxs("div",{className:"text-muted-foreground space-y-1 py-2",children:[e.enabledChecks>0&&n.jsxs("p",{children:[e.enabledChecks," enabled"]}),$?n.jsx("p",{children:"Terminal results will be available after this run finishes."}):n.jsxs(n.Fragment,{children:[e.passedChecks>0&&n.jsxs("p",{children:[e.passedChecks," passed"]}),e.notApplicableChecks>0&&n.jsxs("p",{children:[e.notApplicableChecks," not applicable"]}),e.errorChecks>0&&n.jsx("p",{children:ne(e.errorChecks,"execution error")}),e.errorFindings>0&&n.jsx("p",{children:ne(e.errorFindings,"critical finding")}),e.warningFindings>0&&n.jsx("p",{children:ne(e.warningFindings,"warning finding")}),e.noticeFindings>0&&n.jsx("p",{children:ne(e.noticeFindings,"notice finding")})]}),e.lastRunAt&&n.jsx("p",{className:"text-foreground pt-2 pb-1 font-medium",children:`${J} ${Gt(e.lastRunAt)}`})]}),n.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[n.jsx("button",{ref:j,type:"button",className:"border-input bg-background hover:bg-muted inline-flex cursor-pointer items-center justify-center rounded-md border px-3 py-1.5 font-medium transition-colors","aria-label":`Open Data Quality page for ${t}`,onPointerDown:u=>{u.stopPropagation()},onClick:ie,children:"Open"}),n.jsxs("button",{type:"button",className:"bg-primary text-primary-foreground hover:bg-primary/90 inline-flex cursor-pointer items-center justify-center gap-1.5 rounded-md px-3 py-1.5 font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50","aria-label":`Run Quality for ${t}`,title:$?"A Data Quality run is already active":void 0,disabled:$||h,onPointerDown:u=>{u.stopPropagation()},onClick:u=>{G(u)},children:[h?n.jsx(Qt,{className:"size-3.5 animate-spin","aria-hidden":"true"}):n.jsx(Vt,{className:"size-3.5","aria-hidden":"true"}),h?"Starting…":"Run checks"]})]})]})]})}function mi({dataMartTitle:t,block:e,isChecking:i=!1}){const s=i?"checking…":Wt(e);return n.jsxs(Me,{children:[n.jsx(Pe,{asChild:!0,children:n.jsx("button",{type:"button",className:`nodrag inline-flex cursor-default items-center rounded p-0.5 transition-colors ${i||e!=null&&e.dataLastUpdatedAt?"text-muted-foreground hover:text-foreground":"text-muted-foreground/50 hover:text-muted-foreground"}`,"aria-label":`Data Last Updated for ${t}: ${s}`,onPointerDown:a=>{a.stopPropagation()},children:i?n.jsx(zt,{className:"h-3.5 w-3.5 animate-spin","aria-hidden":"true"}):n.jsx(Jt,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),n.jsx(Fe,{side:"top",align:"start",role:"tooltip",className:"max-w-xs",children:i?n.jsx("div",{className:"text-xs",children:"Checking Data Last Updated…"}):e?n.jsx(Kt,{block:e}):n.jsx("div",{className:"text-xs",children:"Data Last Updated has not been checked yet. Use Actions → Check Data Last Updated to measure the visible Data Marts."})})]})}const xi={fields:rn,triggers:an,reports:sn,relationships:nn};function Ie({icon:t,children:e,toggle:i}){const s="inline-flex h-5 shrink-0 items-center gap-1 rounded-md px-1.5 text-[11px] leading-none whitespace-nowrap",a=n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"inline-flex shrink-0","aria-hidden":"true",children:n.jsx(t,{className:"h-3 w-3"})}),e]});return i?n.jsx("button",{type:"button",className:`nodrag cursor-pointer transition-colors ${s} ${i.expanded?"bg-foreground/10 text-foreground":"bg-muted text-muted-foreground hover:text-foreground hover:bg-foreground/10"}`,"aria-expanded":i.expanded,"aria-label":i.label,title:i.label,onPointerDown:c=>{c.stopPropagation()},onClick:c=>{c.stopPropagation(),i.onToggle()},children:a}):n.jsx("span",{className:`bg-muted text-muted-foreground ${s}`,children:a})}function it({icon:t,flag:e,on:i}){if(!i)return null;const{label:s,description:a}=pi[e];return n.jsxs(Me,{children:[n.jsx(Pe,{asChild:!0,children:n.jsx("button",{type:"button",className:"hover:text-foreground nodrag inline-flex cursor-default rounded p-0.5 transition-colors","aria-label":s,onPointerDown:c=>{c.stopPropagation()},children:n.jsx(t,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),n.jsxs(Fe,{side:"top",align:"end",role:"tooltip",className:"max-w-xs",children:[n.jsx("div",{className:"text-xs font-medium",children:s}),n.jsx("div",{className:"text-xs opacity-80",children:a})]})]})}function bi({id:t,data:e,selected:i}){const[s,a]=l.useState(!1),[c,h]=l.useState(null),b=jn();l.useEffect(()=>{b(t)},[s,c,t,b]);const x=e.viewMode==="erd",y=e.fields,j=x&&y.length>0,v=e.objectLabels??qt,g=ft(e,Ae(v)),w=g.definition&&e.definitionType?ke.getInfo(e.definitionType):null,D=!v.status&&e.isDraft,S=ht(e,e.viewMode,Ae(v)),_=!x&&y.length>0&&g.fieldCount,U=e.relationships.length>0&&g.relationships,L=c==="fields"&&_,E=c==="relationships"&&U,B=L||E||j&&s,N=l.useRef(e.onRaisedChange);N.current=e.onRaisedChange,l.useEffect(()=>{var m;(m=N.current)==null||m.call(N,B)},[B]),l.useEffect(()=>()=>{var m;(m=N.current)==null||m.call(N,!1)},[]);const $=m=>{h(R=>R===m?null:m)},J=!v.footer,A=e.direction==="vertical"?me.Top:me.Left,K=e.direction==="vertical"?me.Bottom:me.Right,I=`Open ${e.title} in new tab`;function Y(m){if(m.kind==="definition")return w?n.jsx(Ie,{icon:w.icon,children:m.label},m.kind):null;const R=m.kind==="fields"&&_?{expanded:L,label:`${L?"Hide":"Show"} fields of ${e.title}`,onToggle:()=>{$("fields")}}:m.kind==="relationships"&&U?{expanded:E,label:`${E?"Hide":"Show"} relationships of ${e.title}`,onToggle:()=>{$("relationships")}}:void 0;return n.jsx(Ie,{icon:xi[m.kind],toggle:R,children:m.label},m.kind)}function H(m){m.stopPropagation(),m.preventDefault(),e.onOpenExternal()}return n.jsxs("div",{className:"bg-background relative flex cursor-grab flex-col overflow-hidden rounded-xl border shadow-sm active:cursor-grabbing",style:{width:Ce(e.viewMode),borderColor:e.highlighted?Ne:i?Te:void 0,boxShadow:e.highlighted?`0 0 0 3px ${Ne}40, 0 0 12px ${Ne}60`:i?`0 0 0 1px ${Te}`:void 0,opacity:e.dimmed?pt:1,filter:e.dimmed?"grayscale(0.8)":void 0,animation:e.highlighted?"node-pulse 1.5s ease-in-out infinite":void 0,transition:"opacity 0.2s, filter 0.2s"},children:[e.hasIncoming&&n.jsx(Ke,{type:"target",position:A,isConnectable:!1,style:qe}),n.jsxs("div",{className:"flex items-center gap-2 pt-3 pr-3 pl-3",children:[n.jsx("span",{className:"bg-muted text-foreground flex h-7 w-7 shrink-0 items-center justify-center rounded-md","aria-hidden":"true",children:n.jsx(Zt,{icon:e.icon,className:"h-4 w-4"})}),n.jsx("span",{className:"text-foreground min-w-0 flex-1 truncate text-sm font-semibold",title:e.title,children:e.title}),D&&n.jsx(Ie,{icon:Fn,children:"Draft"}),e.description&&n.jsxs(Me,{children:[n.jsx(Pe,{asChild:!0,children:n.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground nodrag inline-flex shrink-0 cursor-default rounded p-0.5 transition-colors","aria-label":`Description for ${e.title}`,onPointerDown:m=>{m.stopPropagation()},children:n.jsx(Yt,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),n.jsx(Fe,{side:"top",align:"center",role:"tooltip",className:"max-w-xs",children:e.description})]}),n.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground nodrag shrink-0 cursor-pointer rounded p-0.5 transition-colors",onPointerDown:m=>{m.stopPropagation()},onClick:H,title:I,"aria-label":I,children:n.jsx(Xt,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),S.map((m,R)=>n.jsx("div",{className:`flex items-center gap-1 overflow-hidden pr-3 pl-3 ${R===0?"pt-2":"pt-1"}`,children:m.map(Y)},m.map(ie=>ie.kind).join("+"))),!J&&n.jsx("div",{className:"h-3","aria-hidden":"true"}),J&&n.jsx(n.Fragment,{children:n.jsxs("div",{className:"text-muted-foreground flex items-center gap-1 pt-2.5 pr-3 pb-3 pl-3 text-[11px]",children:[n.jsx(gi,{dataMartTitle:e.title,summary:e.qualitySummary,onOpenQuality:e.onOpenQuality,onRunQuality:e.onRunQuality}),n.jsx(mi,{dataMartTitle:e.title,block:e.dataLastUpdated,isChecking:e.isCheckingDataLastUpdated}),n.jsxs("span",{className:"ml-auto flex items-center gap-1",children:[n.jsx(it,{icon:en,flag:"availableForReporting",on:e.availableForReporting}),n.jsx(it,{icon:tn,flag:"availableForMaintenance",on:e.availableForMaintenance})]})]})}),E&&n.jsx(ui,{dataMartTitle:e.title,relationships:e.relationships,onOpenRelationship:e.onOpenRelationship}),L&&n.jsx(Ze,{fields:y,labels:Re(v),expanded:s,onToggleExpanded:()=>{a(m=>!m)}}),j&&n.jsx(Ze,{fields:y,labels:Re(v),expanded:s,onToggleExpanded:()=>{a(m=>!m)}}),e.hasOutgoing&&n.jsx(Ke,{type:"source",position:K,isConnectable:!1,style:qe})]})}const st="model-canvas-layout",at="model-canvas-show-join-fields",rt="model-canvas-view-mode",ot="model-canvas-object-labels",wi="model-canvas-positions";function be(t){return`${wi}:${t}`}function Ci(t){if(!t)return{};const e=P.get(be(t),"json");if(!e)return{};const i={};for(const[s,a]of Object.entries(e)){const c=a;c&&typeof c.x=="number"&&typeof c.y=="number"&&(i[s]={x:c.x,y:c.y})}return i}const le=.2,vi=1e3,Ei=150,yi={modelCanvasNode:bi},ji={modelCanvasEdge:di};function mt(t){return JSON.stringify(t.map(({id:e,title:i,status:s,description:a,fieldCount:c,definitionType:h,fields:b,triggersCount:x,reportsCount:y,relationshipCount:j,relationships:v,availableForReporting:g,availableForMaintenance:w})=>({id:e,title:i,status:s,description:a,fieldCount:c,definitionType:h,fields:b,triggersCount:x,reportsCount:y,relationshipCount:j,relationships:v,availableForReporting:g,availableForMaintenance:w})))}function Di(t){return JSON.stringify(t)}function lt(t){return mt(t.map(e=>({...e,relationships:void 0})))}function ct(t){const e=new Set(t.map(i=>JSON.stringify([i.sourceId,i.targetId].sort())));return JSON.stringify([...e].sort())}function dt(t,e){const i=e(t),s=l.useRef({signature:i,value:t});return s.current.signature!==i&&(s.current={signature:i,value:t}),s.current.value}function Si(t){const{node:e,highlight:i,viewMode:s,objectLabels:a}=t;return{id:e.id,type:"modelCanvasNode",position:t.position,width:Ce(s),height:gt(e,s,t.layout),draggable:!0,selectable:!1,focusable:!1,deletable:!1,style:Pn,data:{title:e.title,isDraft:e.status===ut.DRAFT,fieldCount:e.fieldCount,triggersCount:e.triggersCount,reportsCount:e.reportsCount,relationshipCount:e.relationshipCount??0,relationships:e.relationships??[],availableForReporting:e.availableForReporting,availableForMaintenance:e.availableForMaintenance,description:e.description,icon:e.icon??null,definitionType:e.definitionType??null,fields:e.fields??[],viewMode:s,objectLabels:a,dataLastUpdated:e.dataLastUpdated,isCheckingDataLastUpdated:t.isCheckingDataLastUpdated,hasIncoming:t.hasIncoming,hasOutgoing:t.hasOutgoing,highlighted:i.highlighted,dimmed:i.dimmed,direction:t.direction,onOpenExternal:t.onOpenExternal,qualitySummary:e.qualitySummary,onOpenQuality:t.onOpenQuality,onRaisedChange:t.onRaisedChange,onRunQuality:t.onRunQuality,onOpenRelationship:t.onOpenRelationship}}}function Ni(t){return t.joinConditions.map(e=>`${e.sourceFieldName} = ${e.targetFieldName}`)}function Oi(t){const{edge:e,warning:i}=t;return{id:e.id,type:"modelCanvasEdge",source:e.sourceId,target:e.targetId,focusable:!1,selectable:!0,deletable:!1,data:{relationshipIds:e.relationshipIds,bowOffset:t.bowOffset,warning:i,joinLabel:t.joinLabel,dimmed:t.dimmed,direction:t.direction,bidirectional:e.bidirectional}}}function _i({nodes:t,edges:e,searchQuery:i,onOpenDataMart:s,onOpenQuality:a,onRunQuality:c,selectedRelationshipId:h=null,onSelectRelationship:b,isCheckingDataLastUpdated:x=!1,storageId:y,storageTitle:j,exportApiRef:v}){const g=Nn(),w=Oe(o=>o.width),D=Oe(o=>o.height),S=Oe(o=>o.domNode),_=l.useRef(s);_.current=s;const U=l.useRef(a);U.current=a;const L=l.useRef(c);L.current=c;const E=l.useRef(b);E.current=b;const B=l.useRef(h);B.current=h;const N=l.useRef(t);N.current=t;const $=l.useRef(i);$.current=i;const J=l.useRef(x);J.current=x;const[A,K]=l.useState(()=>on(P.get(st))),[I,Y]=l.useState(()=>ln(P.get(rt))),[H,m]=l.useState(()=>P.get(at,"boolean")??!1),[R,ie]=l.useState(()=>cn(P.get(ot))),G=l.useRef(null),u=l.useRef(y);(G.current===null||u.current!==y)&&(u.current=y,G.current=Ci(y));const[T,q]=l.useState(0),se=l.useRef(null),X=l.useRef(null),[xt,bt]=l.useState(!1),[ee,ae]=l.useState([]),[$e,He]=l.useState([]),[Ue,wt]=l.useState(()=>new Set),Be=l.useCallback((o,f)=>{wt(d=>{if(d.has(o)===f)return d;const p=new Set(d);return f?p.add(o):p.delete(o),p})},[]),[te,ce]=l.useState(null),Ge=l.useCallback((o,f)=>{var d;ce(null),(d=E.current)==null||d.call(E,o,f)},[]),Qe=l.useMemo(()=>On(ee),[ee]),V=dt(t,mt),Q=dt(e,Di);l.useImperativeHandle(v,()=>({exportCanvas:async o=>{await dn(t.map(d=>d.icon));const{exportModelCanvas:f}=await un(async()=>{const{exportModelCanvas:d}=await import("./index-CfHV4Rj5.js");return{exportModelCanvas:d}},__vite__mapDeps([0,1,2,3,4]));return f(o,{viewport:(S==null?void 0:S.querySelector(".react-flow__viewport"))??null,flowNodes:ee,nodes:t,edges:e,storageTitle:j})}}),[S,ee,t,e,j]),l.useEffect(()=>{var We;const o=new Set(Q.map(r=>r.targetId)),f=new Set(Q.map(r=>r.sourceId)),d=new Map(V.map(r=>[r.id,r.status===ut.DRAFT])),p=Ye(V,$.current,r=>r.id,r=>r.title),C=Ae(R),k=V.map(r=>({id:r.id,width:Ce(I),height:gt(r,I,C)})),M=H?new Map(Q.map(r=>[r.id,Ni(r)])):new Map,F=Q.map(r=>({id:r.id,sourceId:r.sourceId,targetId:r.targetId,label:_n(M.get(r.id)??[])})),W=JSON.stringify([lt(V),ct(Q),A,T,I,H,ge(R)]),re=((We=X.current)==null?void 0:We.key)===W?X.current.positions:Ln(k,F,A).positions;X.current={key:W,positions:re};const de=Vn(Q),O=new Set(V.map(r=>r.id)),z=Object.entries(G.current??{}),Z=Object.fromEntries(z.filter(([r])=>O.has(r)));z.length!==Object.keys(Z).length&&(G.current=Z,u.current&&P.set(be(u.current),Z));const ue=new Map(N.current.map(r=>[r.id,r.qualitySummary])),pe=new Map(N.current.map(r=>[r.id,r.dataLastUpdated])),fe=new Map(N.current.map(r=>[r.id,r.icon]));ae(V.map(r=>Si({node:{...r,qualitySummary:ue.get(r.id)??r.qualitySummary,dataLastUpdated:pe.get(r.id)??r.dataLastUpdated,icon:fe.has(r.id)?fe.get(r.id):r.icon},position:Z[r.id]??re.get(r.id)??{x:0,y:0},hasIncoming:o.has(r.id),hasOutgoing:f.has(r.id),highlight:p.get(r.id)??Xe,direction:A,viewMode:I,objectLabels:R,layout:C,onOpenExternal:()=>{_.current(r.id)},onOpenQuality:()=>{U.current(r.id)},onRunQuality:()=>L.current(r.id),onRaisedChange:oe=>{Be(r.id,oe)},onOpenRelationship:Ge,isCheckingDataLastUpdated:J.current}))),He(Q.map(r=>{var ze,Je;const oe=((ze=p.get(r.sourceId))==null?void 0:ze.dimmed)??!1,At=((Je=p.get(r.targetId))==null?void 0:Je.dimmed)??!1;return Oi({edge:r,joinLabel:M.get(r.id)??[],bowOffset:de.get(r.id)??0,warning:r.joinNotConfigured||(d.get(r.sourceId)??!1)||(d.get(r.targetId)??!1),dimmed:oe&&At,direction:A})})),bt(!0);const he=[lt(V),ct(Q),A,T,I],ye=se.current;if(ye!=null&&ye.every((r,oe)=>r===he[oe]))return;const Ve=[...p.entries()].filter(([,r])=>r.highlighted).map(([r])=>r),Tt=requestAnimationFrame(()=>{se.current=he,g.fitView(Ve.length>0?{nodes:Ve.map(r=>({id:r})),duration:300,padding:le}:{padding:le,duration:300})});return()=>{cancelAnimationFrame(Tt)}},[V,Q,A,T,I,H,R,g,Be,Ge]);const Ct=l.useCallback(o=>{ae(f=>In(o,f))},[]),vt=l.useCallback((o,f)=>{var d;ce(p=>p===f.id?null:f.id),(d=E.current)==null||d.call(E,null)},[]),Et=l.useCallback(()=>{var o;ce(null),(o=E.current)==null||o.call(E,null)},[]),yt=l.useCallback((o,f)=>{var C;ce(null);const{relationshipIds:d}=f.data,p=B.current;(C=E.current)==null||C.call(E,p&&d.includes(p)?p:d[0]??null)},[]),jt=l.useMemo(()=>ee.map(o=>{const f=o.id===te,d=Ue.has(o.id)?vi:0;return!!o.selected===f&&(o.zIndex??0)===d?o:{...o,selected:f,zIndex:d}}),[ee,te,Ue]),Dt=l.useMemo(()=>$e.map(o=>{const f=te!==null&&(o.source===te||o.target===te)||h!==null&&o.data.relationshipIds.includes(h);return!!o.selected===f?o:{...o,selected:f}}),[$e,te,h]),St=l.useCallback((o,f)=>{const d=G.current??{};d[f.id]={x:f.position.x,y:f.position.y},G.current=d,u.current&&P.set(be(u.current),d)},[]);l.useEffect(()=>{const o=new Map(t.map(p=>[p.id,p.qualitySummary])),f=new Map(t.map(p=>[p.id,p.dataLastUpdated])),d=new Map(t.map(p=>[p.id,p.icon??null]));ae(p=>p.map(C=>{const k=o.get(C.id)??C.data.qualitySummary,M=f.has(C.id)?f.get(C.id)??null:C.data.dataLastUpdated,F=d.has(C.id)?d.get(C.id)??null:C.data.icon;return C.data.qualitySummary!==k||C.data.dataLastUpdated!==M||C.data.icon!==F?{...C,data:{...C.data,qualitySummary:k,dataLastUpdated:M,icon:F}}:C}))},[t]),l.useEffect(()=>{ae(o=>o.map(f=>f.data.isCheckingDataLastUpdated===x?f:{...f,data:{...f.data,isCheckingDataLastUpdated:x}}))},[x]),l.useEffect(()=>{const o=Ye(N.current,i,d=>d.id,d=>d.title);ae(d=>d.map(p=>{const C=o.get(p.id)??Xe;return p.data.highlighted===C.highlighted&&p.data.dimmed===C.dimmed?p:{...p,data:{...p.data,...C}}})),He(d=>d.map(p=>{var F,W;const C=((F=o.get(p.source))==null?void 0:F.dimmed)??!1,k=((W=o.get(p.target))==null?void 0:W.dimmed)??!1,M=C&&k;return p.data.dimmed===M?p:{...p,data:{...p.data,dimmed:M}}}));const f=[...o.entries()].filter(([,d])=>d.highlighted).map(([d])=>d);f.length>0&&g.fitView({nodes:f.map(d=>({id:d})),duration:300,padding:le})},[i,g]);const Nt=l.useCallback(o=>{K(o),P.set(st,o),G.current={},u.current&&P.remove(be(u.current)),q(f=>f+1)},[]),Ot=l.useCallback(o=>{ie(f=>ge(f)===ge(o)?f:(P.set(ot,ge(o)),o))},[]),_t=l.useCallback(o=>{Y(o),P.set(rt,o)},[]),Lt=l.useCallback(o=>{m(o),P.set(at,o)},[]),ve=l.useRef(null),Ee=l.useRef(!1);l.useEffect(()=>{if(!h){ve.current=null;return}if(w===0||D===0)return;if(ve.current!==h)ve.current=h,Ee.current=!1;else if(Ee.current)return;const o=g.getEdges().find(O=>O.data.relationshipIds.includes(h));if(!o)return;const{x:f,y:d,zoom:p}=g.getViewport(),C=O=>{const z=O.x*p+f,Z=O.y*p+d,ue=O.width*p,pe=O.height*p,fe=Math.min(z+ue,w)-Math.max(z,0),he=Math.min(Z+pe,D)-Math.max(Z,0);return fe>=ue/2&&he>=pe/2},k=[o.source,o.target].map(O=>g.getNodesBounds([O]));if(k.some(C))return;const M=O=>({x:O.x+O.width/2,y:O.y+O.height/2}),F=g.getNodesBounds([o.source,o.target]),W={x:(w/2-f)/p,y:(D/2-d)/p},re=O=>{const z=M(O);return Math.hypot(z.x-W.x,z.y-W.y)},de=F.width*p<=w&&F.height*p<=D?M(F):M(re(k[0])<=re(k[1])?k[0]:k[1]);g.setCenter(de.x,de.y,{zoom:p,duration:300})},[h,w,D,g]);const It=l.useCallback(o=>{o&&(Ee.current=!0)},[]),Rt=l.useCallback((o,f)=>{if(w===0||D===0)return;const d=Rn(f,Qe,w,D,Ei);d.x===f.x&&d.y===f.y||g.setViewport(d)},[Qe,D,w,g]);return n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"absolute top-3 right-3 z-10 flex flex-col gap-1.5",children:[n.jsx(Se,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{g.fitView({padding:le,duration:300})},"aria-label":"Fit to view",children:n.jsx($n,{className:"h-6 w-6"})}),n.jsx(Se,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{g.zoomIn({duration:150})},"aria-label":"Zoom in",children:n.jsx(Hn,{className:"h-6 w-6"})}),n.jsx(Se,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{g.zoomOut({duration:150})},"aria-label":"Zoom out",children:n.jsx(Un,{className:"h-6 w-6"})}),n.jsx(Tn,{viewMode:I,onViewModeChange:_t,direction:A,onDirectionChange:Nt,showJoinFields:H,onShowJoinFieldsChange:Lt,objectLabels:R,onObjectLabelsChange:Ot,objectLabelOptions:Bn})]}),xt&&n.jsx(An,{nodes:jt,edges:Dt,nodeTypes:yi,edgeTypes:ji,onNodesChange:Ct,onNodeDragStop:St,onNodeClick:vt,onEdgeClick:yt,onPaneClick:Et,deleteKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,edgesFocusable:!1,minZoom:.05,maxZoom:2,onMove:Rt,onMoveStart:It,fitView:!0,fitViewOptions:{padding:le},proOptions:{hideAttribution:!0},style:{width:"100%",height:"100%"},children:n.jsx(kn,{pannable:!0,zoomable:!0,style:{width:140,height:100},nodeColor:Mn})})]})}function Ai({nodes:t,edges:e,searchQuery:i,onOpenDataMart:s,onOpenQuality:a,onRunQuality:c,selectedRelationshipId:h,onSelectRelationship:b,isCheckingDataLastUpdated:x,storageId:y,storageTitle:j,exportApiRef:v,className:g,style:w}){return t.length===0?null:n.jsxs("div",{className:`relative overflow-hidden ${g??""}`,style:w??{height:480},children:[n.jsx("style",{children:Dn}),n.jsx(Sn,{children:n.jsx(_i,{nodes:t,edges:e,searchQuery:i,onOpenDataMart:s,onOpenQuality:a,onRunQuality:c,selectedRelationshipId:h,onSelectRelationship:b,isCheckingDataLastUpdated:x,storageId:y,storageTitle:j,exportApiRef:v})})]})}export{Ai as default};
@@ -0,0 +1 @@
1
+ import{j as s,D as Oe,u as _e,r,C as Ae,N as Me,T as Re,a as ve,I as ke,b as Pe,E as Te,B as Le,t as be,c as U,M as Fe,g as He,d as Ge,e as We,h as Be,i as he,f as Ke}from"./index-BW17AtYZ.js";import{O as Ne,a as ze,g as $e,N as Ye,R as Ze,u as Ve,P as q,H as ee,S as te,E as Xe,b as Je,c as ge,d as Ue,e as qe,f as Qe,h as et,C as tt,i as st,M as it,j as nt,k as at,W as ae,D as Ce,l as se,m as ne,n as ot,r as rt,o as lt,p as ct,q as dt,s as ut,t as ht,B as gt,v as ft,w as pt,x as mt,y as xt,z as bt,A as Nt}from"./erd-fields-section-_gVp8PxG.js";import{L as Ct,Z as Et,a as It}from"./zoom-out-C2ChQihe.js";const yt=[{part:"source",label:"Input source",helper:"View, Table, SQL, Pattern or Connector"},{part:"fields",label:"Fields",helper:"Number of fields of the Data Mart"},{part:"status",label:"Status",helper:"Published or draft dot next to the title"},{part:"fieldAlias",label:"Field aliases",helper:"Output Schema alias in place of the name"},{part:"fieldDescription",label:"Field descriptions",helper:"Output Schema description under each field"}];function fe({isDraft:i,decorative:e=!1}){const l=i?"Draft":"Published";return s.jsxs("span",{className:"inline-flex shrink-0 items-center",title:l,children:[s.jsx("span",{className:"h-2 w-2 rounded-full",style:{background:i?Ne:ze},"aria-hidden":"true"}),!e&&s.jsx("span",{className:"sr-only",children:l})]})}function jt({type:i,joined:e=!1}){if(!i)return null;const l=Oe.getInfo(i),c=l.icon;return s.jsxs("span",{className:`border-border inline-flex items-center gap-1 border px-1.5 py-0.25 text-[8px] font-semibold tracking-wide uppercase ${e?"rounded-r-full":"-ml-0.5 rounded-full"}`,children:[s.jsx(c,{className:"h-2.5 w-2.5"}),l.displayName]})}const Y=3,Ee=.05,wt=1e-4,pe=1;function Dt(i,e,l,c){const d=i.maxX-i.minX,f=i.maxY-i.minY;return d<=0||f<=0||e<=0||l<=0?null:$e({x:i.minX,y:i.minY,width:d,height:f},e,l,Ee,Y,c)}function St(i){const e=Number.isFinite(i)&&i>0?Math.min(i,Y):pe;return{min:e>=Y?pe:e,max:Y}}function Ot(i,e,l){if(!Number.isFinite(i)||i<=0)return null;const c=i*(1+e),d=Math.min(Math.max(c,l.min),l.max);return!Number.isFinite(d)||Math.abs(d-i)<wt||e>0!=d>i?null:{zoom:d,delta:d/i-1}}const Z=240,Ie=48,Q=92,_t=.85,ie=1/_t-1,At=150,Mt=Ne;function me({data:i}){const e=He(i);if(!e)return null;const l=e.kind==="attention";return s.jsxs("span",{title:l?Ge:void 0,style:{position:"absolute",top:-18,right:4,display:"inline-flex",alignItems:"center",gap:2,fontSize:10,fontWeight:600,color:l?at:ae,lineHeight:1,whiteSpace:"nowrap"},children:[l&&s.jsx(We,{style:{width:12,height:12,color:Mt}}),e.label]})}function ye(i){return i==="erd"?bt:Z}function xe(i,e){return{width:i.isSource?Z:ye(i.viewMode),borderColor:i.highlighted?se:Be(i)?ae:e?ne:void 0,boxShadow:i.highlighted?`0 0 0 3px ${se}40, 0 0 12px ${se}60`:e?`0 0 0 1px ${ne}`:void 0,opacity:i.dimmed?Ce:1,filter:i.dimmed?"grayscale(0.8)":void 0,animation:i.highlighted?"node-pulse 1.5s ease-in-out infinite":void 0,transition:"opacity 0.2s, filter 0.2s",cursor:"pointer"}}function Rt({id:i,data:e,selected:l}){const[c,d]=r.useState(!1),f=Ve();r.useEffect(()=>{f(i)},[c,i,f]);const b=e.objectLabels,N=!b.source,u=!b.fields,S=!b.status,O=e.direction==="vertical"?q.Top:q.Left,C=e.direction==="vertical"?q.Bottom:q.Right;function y(p){p.stopPropagation(),p.preventDefault(),e.onOpenExternal()}if(e.isSource)return s.jsxs("div",{className:"bg-primary/5 relative flex items-center gap-2 rounded-xl border shadow-sm",style:{...xe(e,l),height:Ie,padding:"0 14px"},children:[s.jsx(me,{data:e}),s.jsx("span",{className:"text-foreground flex-1 truncate text-[13px] font-semibold",title:e.label,children:e.label}),S&&s.jsx(fe,{isDraft:e.isDraft,decorative:!0}),e.hasOutgoing&&s.jsx(ee,{type:"source",position:C,isConnectable:!1,style:te})]});const j=`Open ${e.label} in new tab`,w=e.viewMode==="erd"&&e.fields.length>0;return s.jsxs("div",{title:e.isCycleStub?Ae:void 0,className:"bg-background relative flex flex-col rounded-xl border shadow-sm",style:xe(e,l),children:[s.jsx(me,{data:e}),s.jsx(ee,{type:"target",position:O,isConnectable:!1,style:te}),s.jsxs("div",{className:"flex items-center gap-2 px-3.5 pt-3 pb-1",children:[s.jsx("span",{className:"text-foreground flex-1 truncate text-[13px] font-semibold",title:e.label,children:e.label}),S&&s.jsx(fe,{isDraft:e.isDraft,decorative:!0}),!e.userHasAccess&&s.jsx(Me,{}),e.description&&s.jsxs(Re,{children:[s.jsx(ve,{asChild:!0,children:s.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground inline-flex cursor-default rounded p-0.5 transition-colors","aria-label":`Description for ${e.label}`,onPointerDown:p=>{p.stopPropagation()},children:s.jsx(ke,{className:"h-3.5 w-3.5","aria-hidden":"true"})})}),s.jsx(Pe,{side:"top",align:"center",role:"tooltip",className:"max-w-xs",children:e.description})]}),s.jsx("button",{type:"button",className:"text-muted-foreground hover:text-foreground shrink-0 cursor-pointer rounded p-0.5 transition-colors",onPointerDown:p=>{p.stopPropagation()},onClick:y,title:j,"aria-label":j,children:s.jsx(Te,{className:"h-3.5 w-3.5","aria-hidden":"true"})})]}),s.jsxs("div",{className:"flex min-w-0 items-center gap-2 px-3.5 pt-1 pb-3",children:[N&&s.jsx(jt,{type:e.definitionType}),e.targetAlias&&s.jsx(Le,{variant:"secondary",className:"inline-block max-w-[90px] truncate px-1.5 py-0 text-[10px]",title:e.targetAlias,children:e.targetAlias}),u&&s.jsxs("span",{className:"text-muted-foreground ml-auto shrink-0 text-[11px]",children:[e.fieldCount??0," field",e.fieldCount!==1?"s":""]})]}),w&&s.jsx(Xe,{fields:e.fields,labels:be(b),expanded:c,onToggleExpanded:()=>{d(p=>!p)}}),e.hasOutgoing&&s.jsx(ee,{type:"source",position:C,isConnectable:!1,style:te})]})}function vt({id:i,sourceX:e,sourceY:l,targetX:c,targetY:d,sourcePosition:f,targetPosition:b,selected:N,data:u}){const[S,O,C]=ct({sourceX:e,sourceY:l,sourcePosition:f,targetX:c,targetY:d,targetPosition:b}),y=u.warning?ae:N?ne:dt,j=r.useId(),w=ut("rel-arrow",j);return s.jsxs(s.Fragment,{children:[s.jsx(ht,{markerId:w,color:y,withStart:!1}),s.jsx(gt,{id:i,path:S,markerEnd:`url(#${w}-end)`,style:{stroke:y,strokeWidth:N?pt:mt,strokeDasharray:u.warning?ft:void 0,opacity:u.dimmed?Ce:1,transition:"opacity 0.2s, stroke 0.2s"}}),s.jsx(xt,{x:O,y:C,lines:u.joinLabel,selected:N??!1,dimmed:u.dimmed})]})}const kt={relationshipNode:Rt},Pt={relationshipEdge:vt};function Tt(i){return JSON.stringify([i.nodes.map(e=>[e.id,e.data.isSource,e.data.label,e.data.targetAlias,e.data.fieldCount,e.data.description,e.data.isDraft,e.data.isBlocked,e.data.isJoinNotConfigured,e.data.isCycleStub,e.data.isMissingPrimaryKey,e.data.userHasAccess,e.data.hasOutgoing]),i.edges.map(e=>[e.id,e.source,e.target,e.data.warning])])}function Lt(i,e,l,c){return i?Ie:l!=="erd"?Q:Q+Nt(e,c)}function Ft({dataMartId:i,dataMartTitle:e,dataMartDescription:l,dataMartStatus:c,rootDefinitionType:d,definitionTypes:f,initialRelationships:b,graph:N,fieldCounts:u,showLooped:S,statusFilter:O,viewMode:C,objectLabels:y,direction:j,showJoinFields:w,fieldsByAliasPath:p,onOpenExternal:T}){let G=0;const R=(t,a)=>a&&!S||O!=="all"&&t!==O?(G++,!1):!0,_=new Map,M=[],W=new Set,L=c==="DRAFT";_.set(i,{dmId:i,title:e,description:l,depth:0,isSource:!0,isDraft:L,userHasAccess:!0});const h=new Map;h.set("",i);function E(t,a,m,I,A){const z=`path:${I}`;M.push({sourceId:t,targetId:z,joinLabel:w?A.map(X=>`${X.sourceFieldName} = ${X.targetFieldName}`):[]}),W.add(t),_.set(z,{dmId:a,aliasPath:I,...m}),h.set(I,z)}if(N)for(const t of N.nodes){const a=t.aliasPath.lastIndexOf("."),m=a===-1?"":t.aliasPath.slice(0,a),I=h.get(m);I&&R(t.relationship.targetDataMart.status,t.isCycleStub)&&E(I,t.relationship.targetDataMart.id,{title:t.relationship.targetDataMart.title,description:t.relationship.targetDataMart.description,depth:t.depth,isSource:!1,targetAlias:t.relationship.targetAlias,fieldCount:(u==null?void 0:u.get(t.relationship.id))??0,isDraft:t.relationship.targetDataMart.status==="DRAFT",isBlocked:t.isBlocked,isJoinNotConfigured:t.relationship.joinConditions.length===0,isCycleStub:t.isCycleStub,isMissingPrimaryKey:he(t.relationship.targetDataMart.hasPrimaryKey,t.relationship.joinConditions.length),userHasAccess:t.relationship.targetDataMart.userHasAccess},t.aliasPath,t.relationship.joinConditions)}else for(const t of b)R(t.targetDataMart.status,t.targetDataMart.id===i)&&E(i,t.targetDataMart.id,{title:t.targetDataMart.title,description:t.targetDataMart.description,depth:1,isSource:!1,targetAlias:t.targetAlias,fieldCount:(u==null?void 0:u.get(t.id))??0,isDraft:t.targetDataMart.status==="DRAFT",isBlocked:L,isJoinNotConfigured:t.joinConditions.length===0,isCycleStub:t.targetDataMart.id===i,isMissingPrimaryKey:he(t.targetDataMart.hasPrimaryKey,t.joinConditions.length),userHasAccess:t.targetDataMart.userHasAccess},t.targetAlias,t.joinConditions);const D=new Map,v=new Map,F=new Map,g=be(y);for(const[t,a]of _){const m=a.isSource||a.aliasPath===void 0?[]:(p==null?void 0:p.get(a.aliasPath))??[];D.set(t,m),v.set(t,a.isSource?Z:ye(C)),F.set(t,Lt(a.isSource,m,C,g))}const V=[..._.keys()].map(t=>({id:t,width:v.get(t)??Z,height:F.get(t)??Q})),B=M.map(t=>({id:`${t.sourceId}->${t.targetId}`,sourceId:t.sourceId,targetId:t.targetId,label:ot(t.joinLabel)})),{positions:k}=rt(V,B,j),H=[];for(const[t,a]of _)H.push({id:t,type:"relationshipNode",position:k.get(t)??{x:0,y:0},width:v.get(t)??Z,height:F.get(t)??Q,draggable:!1,selectable:!1,focusable:!1,style:lt,data:{isSource:a.isSource,label:a.title,targetAlias:a.targetAlias,fieldCount:a.fieldCount,description:a.description,definitionType:a.isSource?d:(f==null?void 0:f.get(a.dmId))??null,isDraft:a.isDraft??!1,isBlocked:a.isBlocked??!1,isJoinNotConfigured:a.isJoinNotConfigured??!1,isCycleStub:a.isCycleStub??!1,isMissingPrimaryKey:a.isMissingPrimaryKey??!1,userHasAccess:a.userHasAccess,hasOutgoing:W.has(t)&&!a.isCycleStub,highlighted:!1,dimmed:!1,fields:D.get(t)??[],viewMode:C,objectLabels:y,direction:j,onOpenExternal:()=>{T(a.dmId)}}});const P=[];for(const t of M){const a=_.get(t.sourceId),m=_.get(t.targetId);if(!a||!m)continue;const I=Ke(a,m);P.push({id:`${t.sourceId}->${t.targetId}`,type:"relationshipEdge",source:t.sourceId,target:t.targetId,focusable:!1,selectable:!1,data:{warning:I,dimmed:!1,joinLabel:t.joinLabel}})}return{nodes:H,edges:P,filteredOutCount:G}}function Ht({dataMartId:i,dataMartTitle:e,dataMartDescription:l,dataMartStatus:c,dataMartDefinitionType:d,definitionTypes:f,relationships:b,relationshipGraph:N,connectedFieldCounts:u,searchQuery:S,onRequestFullscreen:O,onOpenExternal:C,showLooped:y,statusFilter:j,viewMode:w,onViewModeChange:p,direction:T,onDirectionChange:G,showJoinFields:R,onShowJoinFieldsChange:_,objectLabels:M,onObjectLabelsChange:W,fieldsByAliasPath:L}){const h=Je(),E=ge(n=>n.width),D=ge(n=>n.height),v=r.useRef(!1),F=r.useRef(!1),g=r.useMemo(()=>Ft({dataMartId:i,dataMartTitle:e,dataMartDescription:l,dataMartStatus:c,rootDefinitionType:d??null,definitionTypes:f,initialRelationships:b,graph:N,fieldCounts:u,showLooped:y,statusFilter:j,viewMode:w,objectLabels:M,direction:T,showJoinFields:R,fieldsByAliasPath:L,onOpenExternal:C}),[i,e,l,c,d,f,b,N,u,y,j,w,M,T,R,L,C]),[V,B]=r.useState(null),[k,H]=r.useState(null),P=r.useMemo(()=>Tt(g),[g]),t=r.useMemo(()=>Ue(g.nodes),[g.nodes]),a=r.useRef(P),m=r.useMemo(()=>Dt(t,E,D,ie),[t,E,D]),I=r.useMemo(()=>St((m==null?void 0:m.zoom)??Number.NaN),[m]);r.useEffect(()=>{a.current!==P&&(a.current=P,F.current=!1,H(n=>n!==null&&g.nodes.some(o=>o.id===n)?n:null),B(n=>n!==null&&g.edges.some(o=>o.id===n)?n:null))},[P,g]);const A=r.useMemo(()=>qe(g.nodes,S,n=>n.id,n=>n.data.label),[g.nodes,S]),z=r.useMemo(()=>g.nodes.map(n=>{const o=A.get(n.id)??Qe,x=n.id===k;return n.data.highlighted===o.highlighted&&n.data.dimmed===o.dimmed&&(n.selected??!1)===x?n:{...n,selected:x,data:{...n.data,...o}}}),[g.nodes,A,k]),X=r.useMemo(()=>g.edges.map(n=>{var de,ue;const o=(((de=A.get(n.source))==null?void 0:de.dimmed)??!1)&&(((ue=A.get(n.target))==null?void 0:ue.dimmed)??!1),x=n.id===V||k!==null&&(n.source===k||n.target===k);return n.data.dimmed===o&&(n.selected??!1)===x?n:{...n,selected:x,data:{...n.data,dimmed:o}}}),[g.edges,A,V,k]),je=r.useCallback((n,o)=>{B(x=>x===o.id?null:o.id),H(null)},[]),we=r.useCallback((n,o)=>{H(x=>x===o.id?null:o.id),B(null)},[]),De=r.useCallback(()=>{B(null),H(null)},[]),oe=r.useRef(A);oe.current=A;const J=r.useCallback(()=>{const n=[...oe.current.entries()].filter(([,o])=>o.highlighted).map(([o])=>o);n.length!==0&&h.fitView({nodes:n.map(o=>({id:o})),duration:300,padding:ie})},[h]),$=r.useCallback(()=>h.fitView({minZoom:Ee,maxZoom:Y,padding:ie}),[h]),re=r.useRef(m);re.current=m;const le=r.useCallback(()=>{const n=re.current;return n?h.setViewport(n):$()},[$,h]),K=r.useCallback(()=>{F.current=!0},[]);r.useEffect(()=>{E===0||D===0||F.current||le().then(()=>{v.current=!0,J()})},[E,D,P,le,J]),r.useEffect(()=>{v.current&&J()},[A,J]);const ce=r.useCallback(n=>{K();const o=h.getZoom();if(!Number.isFinite(o)||o<=0){$();return}const x=Ot(o,n,I);x&&h.zoomTo(x.zoom,{duration:150})},[$,K,h,I]),Se=r.useCallback((n,o)=>{if(E===0||D===0||!Number.isFinite(o.zoom))return;const x=et(o,t,E,D,At);x.x===o.x&&x.y===o.y||h.setViewport(x)},[t,D,E,h]);return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"absolute top-3 right-3 z-10 flex items-start gap-2",children:s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx(U,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{K(),$()},"aria-label":"Fit to view",children:s.jsx(Ct,{className:"h-6 w-6"})}),s.jsx(U,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{ce(.25)},"aria-label":"Zoom in",children:s.jsx(Et,{className:"h-6 w-6"})}),s.jsx(U,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:()=>{ce(-.25)},"aria-label":"Zoom out",children:s.jsx(It,{className:"h-6 w-6"})}),O&&s.jsx(U,{variant:"outline",size:"icon",className:"h-12 w-12",onClick:O,"aria-label":"Expand diagram",children:s.jsx(Fe,{className:"h-6 w-6"})}),s.jsx(tt,{viewMode:w,onViewModeChange:p,direction:T,onDirectionChange:G,showJoinFields:R,onShowJoinFieldsChange:_,objectLabels:M,onObjectLabelsChange:W,objectLabelOptions:yt})]})}),s.jsxs("div",{className:"h-full w-full",onPointerDownCapture:K,onWheelCapture:K,children:[s.jsx(st,{nodes:z,edges:X,nodeTypes:kt,edgeTypes:Pt,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,edgesFocusable:!1,zoomOnDoubleClick:!1,minZoom:I.min,maxZoom:I.max,onEdgeClick:je,onNodeClick:we,onPaneClick:De,deleteKeyCode:null,panActivationKeyCode:null,onMove:Se,onMoveStart:n=>{n&&K()},proOptions:{hideAttribution:!0},style:{width:"100%",height:"100%"},children:s.jsx(it,{pannable:!0,zoomable:!0,style:{width:140,height:100},nodeColor:nt})}),g.nodes.length===1&&g.filteredOutCount>0&&s.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-6 flex justify-center",children:s.jsx("span",{className:"bg-background text-muted-foreground rounded-md border px-3 py-1.5 text-sm shadow-sm",children:"No related data marts match the current filters"})})]})]})}function Kt({dataMartId:i,dataMartTitle:e,dataMartDescription:l,dataMartStatus:c,dataMartDefinitionType:d,definitionTypes:f,relationships:b,relationshipGraph:N,connectedFieldCounts:u,searchQuery:S,onRequestFullscreen:O,showLooped:C,statusFilter:y,viewMode:j,onViewModeChange:w,direction:p,onDirectionChange:T,showJoinFields:G,onShowJoinFieldsChange:R,objectLabels:_,onObjectLabelsChange:M,fieldsByAliasPath:W,className:L,style:h}){const{scope:E}=_e(),D=r.useCallback(v=>{window.open(E(`/data-marts/${v}/data-setup`),"_blank","noopener,noreferrer")},[E]);return b.length===0?null:s.jsxs("div",{className:`relative overflow-hidden rounded-lg border ${L??""}`,style:h??{height:480},children:[s.jsx("style",{children:Ye}),s.jsx(Ze,{children:s.jsx(Ht,{dataMartId:i,dataMartTitle:e,dataMartDescription:l,dataMartStatus:c,dataMartDefinitionType:d,definitionTypes:f,relationships:b,relationshipGraph:N,connectedFieldCounts:u,searchQuery:S,onRequestFullscreen:O,onOpenExternal:D,showLooped:C,statusFilter:y,viewMode:j,onViewModeChange:w,direction:p,onDirectionChange:T,showJoinFields:G,onShowJoinFieldsChange:R,objectLabels:_,onObjectLabelsChange:M,fieldsByAliasPath:W})})]})}export{Kt as RelationshipCanvas,Rt as RelationshipFlowNode};
@@ -0,0 +1 @@
1
+ import{ac as E,ad as O,ae as G,af as Q,ag as M,ah as z,r as d,ai as H,aj as _,ak as D,al as I,am as J,an as N,u as L,j as e,ao as U,ap as Y,aq as $,ar as V,as as W,A as X,at as Z,au as ee,E as se,av as te,aw as ae,ax as ie,ay as ne,z as re,az as f,c as k,aA as w,aB as le,aC as S,aD as oe,aE as ce,aF as de,aG as ue,aH as he,aI as pe,aJ as me,aK as fe,aL as xe}from"./index-BW17AtYZ.js";function B(s){return["model-canvas-relationship-source",s]}function ge(s){var l;const n=E(),o=B(s),r=O({queryKey:o,queryFn:({signal:i})=>M.getDataMartById(s,{signal:i,skipLoadingIndicator:!0,skipErrorToast:!0})}),t=G({dataMartId:s,savedConfig:(l=r.data)==null?void 0:l.blendedFieldsConfig,onSaved:i=>{(async()=>(await n.cancelQueries({queryKey:o}),n.setQueryData(o,i),n.invalidateQueries({queryKey:[Q]})))()}});return{sourceDataMart:r.data??null,isLoading:r.isPending,retry:()=>{r.refetch()},configEditor:t}}const je={skipLoadingIndicator:!0,skipErrorToast:!0},ye=[];function ve(s,n){return{...s,nodes:s.nodes.map(o=>o.depth===1&&o.relationship.id===n.id?{...o,relationship:n,aliasPath:n.targetAlias}:o)}}function be({relationshipId:s,sourceDataMartId:n,storageId:o,configEditor:r}){const t=E(),{projectId:l=""}=z(),i=d.useMemo(()=>["model-canvas-relationship-graph",n],[n]),x=d.useMemo(()=>B(n),[n]),u=O({queryKey:i,queryFn:({signal:h})=>N.getRelationshipGraph(n,{signal:h,...je})}),{data:p}=H(n,{includeDraftTargets:!0}),a=d.useMemo(()=>{var h;return((h=u.data)==null?void 0:h.nodes.find(c=>c.depth===1&&c.relationship.id===s))??null},[u.data,s]),g=d.useMemo(()=>{var h;return((h=u.data)==null?void 0:h.nodes.filter(c=>c.depth===1&&c.relationship.id!==s).map(c=>c.relationship.targetAlias))??ye},[u.data,s]),j=d.useCallback(()=>{t.invalidateQueries({queryKey:[Q]})},[t]),y=d.useCallback(()=>{t.invalidateQueries({queryKey:["model-canvas",l,o]})},[t,l,o]),{localConfig:b,localConfigRef:v}=r,m=d.useMemo(()=>!p||!a?null:_(p.availableSources,p.blendedFields,b).find(c=>c.aliasPath===a.aliasPath)??null,[p,a,b]),R=d.useCallback(h=>{var F,A;D.success("Relationship updated");const c=(A=(F=t.getQueryData(i))==null?void 0:F.nodes.find(C=>C.relationship.id===h.id))==null?void 0:A.relationship;t.setQueryData(i,C=>C&&ve(C,h)),t.invalidateQueries({queryKey:i,refetchType:"none"}),c&&c.targetAlias!==h.targetAlias&&t.invalidateQueries({queryKey:x}),j(),y()},[t,i,x,j,y]),P=d.useCallback(h=>{t.setQueryData(i,c=>c&&I(c,h)),J(t,n,v.current,h)},[t,i,n,v]),q=d.useCallback(async()=>{try{await N.deleteRelationship(n,s,{skipLoadingIndicator:!0})}catch{return D.error("Failed to delete relationship"),!1}return D.success("Relationship deleted"),t.invalidateQueries({queryKey:i}),j(),y(),!0},[n,s,t,i,j,y]);return{relationship:(a==null?void 0:a.relationship)??null,aliasPath:(a==null?void 0:a.aliasPath)??null,isBlocked:(a==null?void 0:a.isBlocked)??!1,isCycleStub:(a==null?void 0:a.isCycleStub)??!1,isLoading:u.isPending,isGraphError:u.isError&&!u.data,retryGraph:()=>{u.refetch()},source:m,siblingAliases:g,onRelationshipUpdated:R,onRelationshipDescriptionSaved:P,onAliasChange:r.onAliasChange,onHideForReportingChange:r.onHideForReportingChange,onFieldOverrideChange:r.onFieldOverrideChange,onDescriptionOverrideChange:r.onDescriptionOverrideChange,deleteRelationship:q}}function T({dataMart:s}){const{scope:n}=L();return e.jsxs("a",{href:n(`/data-marts/${s.id}/data-setup`),target:"_blank",rel:"noopener noreferrer",title:`Open ${s.title} in a new tab`,className:"hover:text-foreground inline-flex min-w-0 items-center gap-1 hover:underline",children:[e.jsx(re,{icon:s.icon,className:"size-3.5 shrink-0","aria-hidden":"true"}),e.jsx("span",{className:"truncate",children:s.title})]})}function De({options:s,relationshipId:n,storageId:o,focusRequest:r=0,onRelationshipChange:t,onClose:l}){const{scope:i}=L(),x=d.useRef(null),u=d.useRef(r);u.current=r,d.useEffect(()=>{var a;r>0&&((a=x.current)==null||a.focus())},[r]);const p=s.find(a=>a.id===n)??s.at(0);return p?e.jsx(U,{open:!0,modal:!1,onOpenChange:a=>{a||l()},children:e.jsxs(Y,{ref:x,onOpenAutoFocus:a=>{var g;a.preventDefault(),u.current>0&&((g=x.current)==null||g.focus())},onInteractOutside:a=>{a.preventDefault()},children:[e.jsxs($,{className:"pr-12",children:[e.jsx(V,{children:"Relationship"}),e.jsxs("div",{className:"flex w-full min-w-0 items-center gap-4",children:[e.jsx(W,{asChild:!0,children:e.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[e.jsx(T,{dataMart:p.source}),e.jsx(X,{className:"size-3.5 shrink-0","aria-label":"joins"}),e.jsx(T,{dataMart:p.target})]})}),e.jsx(Z,{className:"shrink-0",children:e.jsxs(ee,{onClick:()=>{window.open(i(`/data-marts/${p.source.id}/data-setup`),"_blank","noopener,noreferrer")},children:[e.jsx(se,{className:"h-3.5 w-3.5"}),"Open in Data Setup"]})})]}),s.length>1&&e.jsx(te,{value:p.id,onValueChange:t,className:"mt-2",children:e.jsx(ae,{"aria-label":"Direction",children:s.map(a=>e.jsxs(ie,{value:a.id,children:[a.source.title," → ",a.target.title]},a.id))})})]}),e.jsx(ne,{children:e.jsx(Ce,{option:p,storageId:o,onDeleted:l},p.source.id)})]})}):null}function K(){return e.jsxs("div",{className:"flex flex-col gap-3","aria-busy":"true",children:[e.jsx(w,{className:"h-16 w-full"}),e.jsx(w,{className:"h-40 w-full"})]})}function Ce({option:s,storageId:n,onDeleted:o}){const r=ge(s.source.id);return r.sourceDataMart?e.jsx(Se,{option:s,storageId:n,configEditor:r.configEditor,onDeleted:o},s.id):r.isLoading?e.jsx(K,{}):e.jsxs(f,{role:"alert",className:"items-start gap-3 text-sm",children:[e.jsxs("p",{className:"text-muted-foreground",children:[s.source.title," could not be loaded, so this relationship cannot be edited."]}),e.jsx(k,{type:"button",variant:"outline",size:"sm",onClick:r.retry,children:"Retry"})]})}function Se({option:s,storageId:n,configEditor:o,onDeleted:r}){const t=be({relationshipId:s.id,sourceDataMartId:s.source.id,storageId:n,configEditor:o}),{relationship:l,source:i}=t,[x,u]=d.useState(!1),[p,a]=d.useState(!1),g=d.useId(),j=le(i,(l==null?void 0:l.targetDataMart.title)??s.target.title,t.onAliasChange);if(t.isLoading)return e.jsx(K,{});if(!l)return t.isGraphError?e.jsxs(f,{role:"alert",className:"items-start gap-3 text-sm",children:[e.jsx("p",{className:"text-muted-foreground",children:"This relationship could not be loaded."}),e.jsx(k,{type:"button",variant:"outline",size:"sm",onClick:t.retryGraph,children:"Retry"})]}):e.jsx(f,{role:"alert",children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"This relationship no longer exists. It may have been deleted."})});const y=async()=>{a(!0);const m=await t.deleteRelationship();a(!1),u(!1),m&&r()},b=l.sourceDataMart.title,v=l.targetDataMart.title;return e.jsxs(e.Fragment,{children:[e.jsxs(S,{title:"General",name:"relationship-sheet-general",children:[e.jsxs(f,{className:"flex-row flex-wrap items-center gap-2 empty:hidden",children:[!l.targetDataMart.userHasAccess&&e.jsx(oe,{}),e.jsx(ce,{relationship:l,isBlocked:t.isBlocked,isCycleStub:t.isCycleStub})]}),t.isCycleStub?e.jsx(f,{children:e.jsxs("p",{className:"text-muted-foreground text-sm",children:[v," is already on this join path, so the join stops here to avoid a loop and has no settings to edit."]})}):e.jsxs(f,{children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsx("label",{htmlFor:g,className:"text-sm font-medium",children:"Allow for reporting"}),e.jsx(de,{id:g,checked:(i==null?void 0:i.isIncluded)??!0,onCheckedChange:m=>{t.onHideForReportingChange((i==null?void 0:i.aliasPath)??t.aliasPath??l.targetAlias,(i==null?void 0:i.alias)??l.targetAlias,!m)}})]}),e.jsxs("p",{className:"text-muted-foreground text-xs",children:["Turn off to hide every field of ",v," from the reports of ",b,". The relationship stays in place."]})]})]}),!t.isCycleStub&&e.jsxs(e.Fragment,{children:[e.jsx(S,{title:"Join Settings",name:"relationship-sheet-join-settings",children:e.jsx(ue,{relationship:l,dataMartId:s.source.id,readOnly:!1,siblingAliases:t.siblingAliases,inheritedFrom:null,variant:"sheet",onSaved:t.onRelationshipUpdated})}),e.jsx(S,{title:"Description",name:"relationship-sheet-description",children:e.jsx(f,{children:e.jsx(he,{relationship:l,dataMartId:s.source.id,inheritedFrom:null,variant:"sheet",onSaved:t.onRelationshipDescriptionSaved})})}),e.jsx(S,{title:"Report Fields",name:"relationship-sheet-report-fields",children:i?e.jsx(pe,{fields:i.fields,onFieldOverrideChange:(m,R)=>{t.onFieldOverrideChange(i,m,R)},leadingToolbar:e.jsx(me,{outputAlias:j,variant:"sheet"}),variant:"sheet"}):e.jsx(f,{children:e.jsx("p",{className:"text-muted-foreground text-sm",children:"Fields will appear after configuring join conditions."})})})]}),e.jsx(S,{title:"Danger zone",name:"relationship-sheet-danger-zone",defaultOpen:!1,children:e.jsx(f,{children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-sm font-medium",children:"Delete this relationship"}),e.jsxs("p",{className:"text-muted-foreground text-sm",children:["Remove the join between ",b," and ",v,". This action cannot be undone."]})]}),e.jsxs(k,{type:"button",variant:"outline",className:"border-destructive/30 text-destructive hover:bg-destructive/10 hover:text-destructive dark:hover:bg-destructive/15 sm:shrink-0",onClick:()=>{u(!0)},children:[e.jsx(fe,{className:"size-4"}),"Delete Relationship"]})]})})}),e.jsx(xe,{open:x,onOpenChange:m=>{m||u(!1)},title:"Delete Relationship",description:"Are you sure you want to delete this relationship? This action cannot be undone.",confirmLabel:p?"Deleting...":"Delete",cancelLabel:"Cancel",variant:"destructive",onConfirm:()=>{y()}})]})}export{De as default};