@nice2dev/ui 1.1.5 → 1.1.7

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.
Files changed (164) hide show
  1. package/CHANGELOG.md +102 -0
  2. package/README.md +50 -29
  3. package/css/legacy-bg-text-aliases.css +65 -61
  4. package/dist/NiceCodeEditor-Bc81wiaN.js +1134 -0
  5. package/dist/NiceCodeEditor-D6f8KdHN.js +1134 -0
  6. package/dist/NiceCodeEditor-DE3saxyt.cjs +260 -0
  7. package/dist/NiceCodeEditor-DZM16My5.cjs +260 -0
  8. package/dist/NiceCodeEditor-HqmcJjmZ.js +1179 -0
  9. package/dist/NiceColorPicker-6EqXaDj0.cjs +1 -0
  10. package/dist/NiceColorPicker-BiEWqWnd.js +596 -0
  11. package/dist/NiceColorPicker-Cuc6YXqz.cjs +1 -0
  12. package/dist/NiceColorPicker-DMATcNWG.js +596 -0
  13. package/dist/NiceColorPicker-R3O1nemp.js +596 -0
  14. package/dist/NiceConfirmDialog-B0e10fRL.cjs +1 -0
  15. package/dist/NiceConfirmDialog-BBDgEMHv.js +81 -0
  16. package/dist/NiceConfirmDialog-C7kdr8jJ.js +81 -0
  17. package/dist/NiceConfirmDialog-DMHqPfFM.js +81 -0
  18. package/dist/NiceConfirmDialog-ZJpQLQQS.cjs +1 -0
  19. package/dist/NiceDataGrid-BzUw4dSu.cjs +10 -0
  20. package/dist/NiceDataGrid-CPKcVOVz.js +1743 -0
  21. package/dist/NiceDataGrid-DJr33WMy.cjs +10 -0
  22. package/dist/NiceDataGrid-D_4gZ1Hu.js +1736 -0
  23. package/dist/NiceDataGrid-DlUAaXhD.js +1736 -0
  24. package/dist/NiceDocumentViewer-8ghRVtfO.js +672 -0
  25. package/dist/NiceDocumentViewer-ChWtA_Ry.cjs +180 -0
  26. package/dist/NiceDocumentViewer-DwLUV7Tc.js +672 -0
  27. package/dist/NiceDocumentViewer-goMzF1w3.cjs +180 -0
  28. package/dist/NiceDocumentViewer-gt1mxzP8.js +672 -0
  29. package/dist/NiceForm-CHEAHxDw.js +4805 -0
  30. package/dist/NiceForm-CJUp1CL0.cjs +1 -0
  31. package/dist/NiceForm-Cp_RH3Yj.js +4805 -0
  32. package/dist/NiceForm-a6tGr6ss.js +4819 -0
  33. package/dist/NiceForm-jU89oe2S.cjs +1 -0
  34. package/dist/NiceGantt-BnQwyTfG.cjs +1 -0
  35. package/dist/NiceGantt-D8coFAvK.js +328 -0
  36. package/dist/NiceGantt-DOZfT6r5.js +328 -0
  37. package/dist/NiceGantt-DQzH1V-R.js +328 -0
  38. package/dist/NiceGantt-jQ8ZpXko.cjs +1 -0
  39. package/dist/NiceHtmlEditor-B1nlXJNW.cjs +10 -0
  40. package/dist/NiceHtmlEditor-Bv3VqJPG.js +862 -0
  41. package/dist/NiceHtmlEditor-CKsGj-Ei.cjs +10 -0
  42. package/dist/NiceHtmlEditor-CloMgyzg.js +841 -0
  43. package/dist/NiceHtmlEditor-DUAHmkWI.js +841 -0
  44. package/dist/NiceLoginForm-Ce_QLnLf.js +736 -0
  45. package/dist/NiceLoginForm-DLpNTQlR.cjs +1 -0
  46. package/dist/NiceLoginForm-Dg0286Cc.js +736 -0
  47. package/dist/NiceLoginForm-X05Vadeg.js +708 -0
  48. package/dist/NiceLoginForm-f_dBCnUi.cjs +1 -0
  49. package/dist/NiceMention-BByI4nFG.js +11120 -0
  50. package/dist/NiceMention-BjeLN4Jx.cjs +430 -0
  51. package/dist/NiceMention-C2TPiMph.cjs +430 -0
  52. package/dist/NiceMention-C67vT6m0.js +11145 -0
  53. package/dist/NiceMention-D1cdy63w.cjs +430 -0
  54. package/dist/NiceMention-OaCi-GNO.js +11094 -0
  55. package/dist/NiceMention-QIuggb9Y.js +11122 -0
  56. package/dist/NiceMention.css +1 -1
  57. package/dist/NiceModal-CHaan9al.js +95 -0
  58. package/dist/NiceModal-Czq6OEAT.js +95 -0
  59. package/dist/NiceModal-D-HFwawr.js +95 -0
  60. package/dist/NiceModal-DOy2XTzc.cjs +1 -0
  61. package/dist/NiceModal-DkawKzEE.cjs +1 -0
  62. package/dist/NiceModuleLifecyclePanel-1CsP8Zst.js +6997 -0
  63. package/dist/NiceModuleLifecyclePanel-Bkx4Yg-3.cjs +1 -0
  64. package/dist/NiceModuleLifecyclePanel-C5oYtczk.js +6999 -0
  65. package/dist/NiceModuleLifecyclePanel-DCcy2yYi.cjs +1 -0
  66. package/dist/NiceModuleLifecyclePanel-DqdgW-0s.js +7004 -0
  67. package/dist/NiceModuleLifecyclePanel.css +1 -1
  68. package/dist/NicePagination-7od5KUa3.cjs +1 -0
  69. package/dist/NicePagination-DMrkR8hH.cjs +1 -0
  70. package/dist/NicePagination-DQmZpsSQ.js +179 -0
  71. package/dist/NicePagination-DipQRjPq.js +172 -0
  72. package/dist/NicePagination-KhlVXYaT.js +172 -0
  73. package/dist/NicePivotGrid-B-KthuqL.cjs +152 -0
  74. package/dist/NicePivotGrid-CLCTHkKO.cjs +152 -0
  75. package/dist/NicePivotGrid-DV54FCsH.js +1174 -0
  76. package/dist/NicePivotGrid-DoWLUPUs.js +1167 -0
  77. package/dist/NicePivotGrid-etwpfccz.js +1167 -0
  78. package/dist/NiceSavedQueryPanel-BABkTNc5.js +5129 -0
  79. package/dist/NiceSavedQueryPanel-Cfeig83P.cjs +586 -0
  80. package/dist/NiceSavedQueryPanel-DTWRLseb.cjs +586 -0
  81. package/dist/NiceSavedQueryPanel-Dy154sxE.js +5129 -0
  82. package/dist/NiceSavedQueryPanel-v7AffOOe.js +5129 -0
  83. package/dist/NiceSavedQueryPanel.css +1 -1
  84. package/dist/NiceScheduler-BEgB7ZgF.cjs +5 -0
  85. package/dist/NiceScheduler-C9JprsEI.cjs +5 -0
  86. package/dist/NiceScheduler-DSP-PPh0.js +1645 -0
  87. package/dist/NiceScheduler-DuPnaA3t.js +1652 -0
  88. package/dist/NiceScheduler-Oa89YZx9.js +1645 -0
  89. package/dist/NiceSelect-A336yeLZ.js +433 -0
  90. package/dist/NiceSelect-B5hTbqi2.js +433 -0
  91. package/dist/NiceSelect-BYSgDYzq.cjs +1 -0
  92. package/dist/NiceSelect-Dudf2T5T.js +433 -0
  93. package/dist/NiceSelect-DwBAIrX7.cjs +1 -0
  94. package/dist/NiceWindow-B6zjBTl9.cjs +1 -0
  95. package/dist/NiceWindow-BKQEx7Vf.js +1623 -0
  96. package/dist/NiceWindow-BnTH7Gy0.js +1623 -0
  97. package/dist/NiceWindow-CZN9NVZw.cjs +1 -0
  98. package/dist/NiceWindow-lxtPR7yZ.js +1623 -0
  99. package/dist/NiceWindow.css +1 -1
  100. package/dist/charts-B8_V3_nq.cjs +882 -0
  101. package/dist/charts-BZgyyybE.js +31933 -0
  102. package/dist/charts-FuDk5-r6.js +31958 -0
  103. package/dist/charts-INj3yFo5.js +31946 -0
  104. package/dist/charts-NolNXKUL.cjs +882 -0
  105. package/dist/charts.cjs +1 -1
  106. package/dist/charts.css +1 -1
  107. package/dist/charts.mjs +1 -1
  108. package/dist/core-A_A6c7an.js +795 -0
  109. package/dist/core-B2iH2J_X.js +795 -0
  110. package/dist/core-BmspZEfD.js +795 -0
  111. package/dist/core-DAfLOet6.cjs +1 -0
  112. package/dist/core-ZG3bgnBR.cjs +1 -0
  113. package/dist/data-branching-B3TOqXAO.cjs +1 -0
  114. package/dist/data-branching-BUGiICDZ.js +6275 -0
  115. package/dist/data-branching-DMXmcocj.js +6275 -0
  116. package/dist/data-branching-YE8P9M5P.js +6275 -0
  117. package/dist/data-branching-t6uhAwIm.cjs +1 -0
  118. package/dist/data-branching.cjs +1 -1
  119. package/dist/data-branching.mjs +1 -1
  120. package/dist/data.cjs +1 -1
  121. package/dist/data.d.ts +7 -2
  122. package/dist/data.mjs +3 -3
  123. package/dist/devops-BhV3OmF7.js +8285 -0
  124. package/dist/devops-BqUxnbRi.cjs +17 -0
  125. package/dist/devops-Bx-Qwj9w.cjs +17 -0
  126. package/dist/devops-DYZatW45.js +8251 -0
  127. package/dist/devops-R98k2zpd.js +8251 -0
  128. package/dist/devops.cjs +1 -1
  129. package/dist/devops.d.ts +29 -16
  130. package/dist/devops.mjs +1 -1
  131. package/dist/editors.cjs +1 -1
  132. package/dist/editors.d.ts +59 -28
  133. package/dist/editors.mjs +7 -7
  134. package/dist/feedback.cjs +1 -1
  135. package/dist/feedback.mjs +3 -3
  136. package/dist/index.cjs +445 -445
  137. package/dist/index.css +1 -1
  138. package/dist/index.d.ts +214 -119
  139. package/dist/index.mjs +16635 -16351
  140. package/dist/lazy.cjs +1 -1
  141. package/dist/lazy.d.ts +31 -18
  142. package/dist/lazy.mjs +24 -24
  143. package/dist/navigation.cjs +1 -1
  144. package/dist/navigation.d.ts +17 -14
  145. package/dist/navigation.mjs +130 -130
  146. package/dist/no-code-BPaAS4wW.cjs +332 -0
  147. package/dist/no-code-CBwUVL1i.js +7447 -0
  148. package/dist/no-code-CjktkQ50.js +7447 -0
  149. package/dist/no-code-DW2NrRba.js +7447 -0
  150. package/dist/no-code-DmFxrZ5T.cjs +332 -0
  151. package/dist/no-code.cjs +1 -1
  152. package/dist/no-code.d.ts +2 -2
  153. package/dist/no-code.mjs +1 -1
  154. package/dist/overlays.cjs +1 -1
  155. package/dist/overlays.d.ts +4 -4
  156. package/dist/overlays.mjs +2 -2
  157. package/dist/pickerCommons-C4XWRUvH.cjs +1 -0
  158. package/dist/pickerCommons-C_BpYs_m.cjs +1 -0
  159. package/dist/pickerCommons-DAOXH_u5.js +1122 -0
  160. package/dist/pickerCommons-Dn4wnDco.js +1122 -0
  161. package/dist/pickerCommons-DskswPS5.js +1122 -0
  162. package/dist/pickerCommons.css +1 -1
  163. package/dist/style.css +7 -7
  164. package/package.json +3 -3
@@ -0,0 +1 @@
1
+ "use strict";const r=require("react"),m=require("./charts-B8_V3_nq.cjs"),i=require("react/jsx-runtime"),q=r.createContext(null);function J({children:e,initialPolicy:o,policyEndpoint:t,instanceCeiling:s,tenantPolicy:a,groupPolicy:n,userPreference:u,instanceId:l="default",tenantId:d,onPolicyChange:h}){const[c,S]=r.useState(o||m.od),[g,R]=r.useState(u),[b,x]=r.useState(!!t),[E,p]=r.useState(null),y=r.useRef(new Map);r.useEffect(()=>{const v=s||m.hd(l),f=m.sd(v,a,n,g);S(f),h?.(f),y.current.forEach(N=>{N.updatePolicy(f)})},[s,a,n,g,l,h]),r.useEffect(()=>{if(!t)return;(async()=>{x(!0),p(null);try{const f=await fetch(t,{credentials:"include"});if(!f.ok)throw new Error(`Failed to fetch policy: ${f.status}`);const N=f.headers.get(m.fd);if(N){const M=m.md(N);if(M){const T=s||m.hd(l),H=m.sd(T,a?{...a,mode:M}:{tenantId:"default",mode:M,allowGroupOverride:!0,allowUserOverride:!0,updatedAt:Date.now()},n,g);S(H),h?.(H)}}try{const M=await f.json();M.policy&&(S(M.policy),h?.(M.policy))}catch{}}catch(f){p(f instanceof Error?f:new Error("Unknown error"))}finally{x(!1)}})()},[t,s,a,n,g,l,h]);const A=r.useCallback(v=>{R(f=>({userId:f?.userId||"anonymous",preferredMode:v.preferredMode||f?.preferredMode||"traceless",restrictCookies:v.restrictCookies??f?.restrictCookies,restrictLocalStorage:v.restrictLocalStorage??f?.restrictLocalStorage,restrictSessionStorage:v.restrictSessionStorage??f?.restrictSessionStorage,setAt:Date.now()}))},[]),k=r.useCallback(()=>m.ld(c,l,d),[c,l,d]),z=r.useCallback(()=>m.vd(c),[c]),V=r.useCallback(async()=>{if(t){x(!0);try{const v=await fetch(t,{credentials:"include",cache:"no-cache"});if(v.ok){const f=v.headers.get(m.fd);if(f){const N=m.md(f);if(N){const M=s||m.hd(l),T=m.sd(M,a?{...a,mode:N}:void 0,n,g);S(T),h?.(T)}}}}finally{x(!1)}}},[t,s,a,n,g,l,h]),G=r.useCallback((v="nice2dev")=>{let f=y.current.get(v);return f||(f=new m.an(c,v),y.current.set(v,f)),f},[c]),O=r.useMemo(()=>m.dd(c),[c]),W=r.useMemo(()=>({policy:c,canUseCookies:c.cookiesAllowed,canUseLocalStorage:c.localStorageAllowed,canUseSessionStorage:c.sessionStorageAllowed,canPersist:c.localStorageAllowed,mode:c.effectiveMode,requiresConsentBanner:c.requiresConsentBanner,badgeInfo:O,setUserPreference:A,generateReport:k,runAudit:z,refreshPolicy:V,getStorageAdapter:G,isLoading:b,error:E}),[c,O,A,k,z,V,G,b,E]);return r.createElement(q.Provider,{value:W},e)}function Q(){const e=r.useContext(q);if(!e)throw new Error("useTracelessPolicy must be used within a TracelessProvider");return e}function L(){const e=r.useContext(q);if(e)return e;const o=new m.an(m.od);return{policy:m.od,canUseCookies:!1,canUseLocalStorage:!1,canUseSessionStorage:!1,canPersist:!1,mode:"traceless",requiresConsentBanner:!1,badgeInfo:m.dd(m.od),setUserPreference:()=>{},generateReport:()=>m.ld(m.od,"default"),runAudit:()=>m.vd(m.od),refreshPolicy:async()=>{},getStorageAdapter:()=>o,isLoading:!1,error:null}}function D(e="nice2dev"){const{getStorageAdapter:o}=L();return r.useMemo(()=>o(e),[o,e])}function I(e,o,t){const s=D(t?.namespace),{canPersist:a,canUseSessionStorage:n}=L(),u=t?.storageMode==="session"?n:a,[l,d]=r.useState(()=>{if(u){const c=s.get(e,t?.storageMode);if(c!==null)return c}return o}),h=r.useCallback(c=>{d(S=>{const g=typeof c=="function"?c(S):c;return u&&s.set(e,g,t?.storageMode==="session"?"session":"local"),g})},[s,e,u,t?.storageMode]);return[l,h,u]}function X(){const{requiresConsentBanner:e,mode:o}=L(),t=D("nice2dev-consent"),[s,a]=r.useState(()=>t.get("banner-dismissed")===!0),n=r.useCallback(()=>{a(!0),t.set("banner-dismissed",!0)},[t]);return{shouldShow:e&&!s,mode:o,dismiss:n}}function Y(e=!1){const{runAudit:o}=L(),[t,s]=r.useState(null),a=r.useCallback(()=>{const n=o();return s(n),n},[o]);return r.useEffect(()=>{e&&a()},[e,a]),{result:t,run:a,isCompliant:t?.compliant??null}}function Z(){const{policy:e,getStorageAdapter:o}=L(),t=r.useMemo(()=>o("local"),[o]),s=r.useCallback(l=>t.get(l),[t]),a=r.useCallback((l,d)=>{t.set(l,d)},[t]),n=r.useCallback(l=>{t.remove(l)},[t]),u=r.useCallback(()=>{t.clear()},[t]);return r.useMemo(()=>({getItem:s,setItem:a,removeItem:n,clear:u,isAvailable:e.localStorageAllowed,effectiveMode:e.effectiveMode,policy:e}),[s,a,n,u,e])}function _(){const{policy:e,getStorageAdapter:o}=L(),t=r.useMemo(()=>o("session"),[o]),s=r.useCallback(l=>t.get(l),[t]),a=r.useCallback((l,d)=>{t.set(l,d)},[t]),n=r.useCallback(l=>{t.remove(l)},[t]),u=r.useCallback(()=>{t.clear()},[t]);return r.useMemo(()=>({getItem:s,setItem:a,removeItem:n,clear:u,isAvailable:e.sessionStorageAllowed,effectiveMode:e.effectiveMode}),[s,a,n,u,e])}function ee({storageKey:e,initialState:o={},onStateChange:t,storageType:s="auto"}){const{policy:a,getStorageAdapter:n}=L(),u=`nice-datagrid-${e}`,l=r.useMemo(()=>{if(s==="local"&&a.localStorageAllowed)return"local";if(s==="session"&&a.sessionStorageAllowed)return"session";if(s==="auto"){if(a.localStorageAllowed)return"local";if(a.sessionStorageAllowed)return"session"}return"memory"},[s,a]),d=r.useMemo(()=>n(l==="session"?"session-grid":"local-grid"),[n,l]),[h,c]=r.useState(()=>{const b=d.get(u);if(b)try{return{...o,...JSON.parse(b)}}catch{return o}return o});r.useEffect(()=>{d.set(u,JSON.stringify(h)),t?.(h)},[h,d,u,t]);const S=r.useCallback(b=>{c(x=>({...x,...b}))},[]),g=r.useCallback(()=>{d.remove(u),c(o)},[d,u,o]);return{state:h,updateState:S,setState:c,clearState:g,degraded:l==="memory",effectiveStorageType:l,policy:a}}function te({storageKey:e,autoSaveInterval:o=5e3,maxVersions:t=10}){const{policy:s,getStorageAdapter:a}=L(),n=`nice-editor-${e}`,u=`${n}-history`,l=r.useMemo(()=>a("editor"),[a]),[d,h]=I(n,null,{storageMode:s.localStorageAllowed?"local":"session"}),[c,S]=I(u,[],{storageMode:"local"}),g=r.useCallback((p,y)=>{const A={content:p,cursorPosition:y,lastModified:Date.now(),version:(d?.version??0)+1};h(A)},[d,h]),R=r.useCallback(()=>{!d||!s.localStorageAllowed||S(p=>[...p,d].slice(-t))},[d,s.localStorageAllowed,t,S]),b=r.useCallback(p=>{const y=c.find(A=>A.version===p);y&&h(y)},[c,h]),x=r.useCallback(()=>{l.remove(n),h(null)},[l,n,h]),E=r.useRef(null);return r.useEffect(()=>{if(!o||!d?.content||d.content===E.current)return;const p=setTimeout(()=>{E.current=d.content??null},o);return()=>clearTimeout(p)},[d?.content,o]),{draft:d,saveDraft:g,saveToHistory:R,restoreVersion:b,clearDraft:x,history:c,hasDraft:d!==null,degraded:!s.localStorageAllowed&&!s.sessionStorageAllowed,policy:s}}function re(e="local"){const o=D(e),t=r.useRef([]);return r.useMemo(()=>({getItem:s=>o.get(s),setItem:(s,a)=>{o.set(s,a),t.current.includes(s)||t.current.push(s)},removeItem:s=>{o.remove(s),t.current=t.current.filter(a=>a!==s)},clear:()=>{o.clear(),t.current=[]},get length(){return t.current.length},key:s=>t.current[s]??null}),[o])}function se(e){const{policy:o}=L();return r.useMemo(()=>{const t=o.cookiesAllowed&&e.cookies!==!1,s=o.localStorageAllowed&&e.localStorage!==!1,a=o.sessionStorageAllowed&&e.sessionStorage!==!1;return{cookiesAllowed:t,localStorageAllowed:s,sessionStorageAllowed:a,effectiveMode:o.effectiveMode,canPersist:s||a,degraded:!s&&!a}},[o,e.cookies,e.localStorage,e.sessionStorage])}const j=({height:e=200})=>i.jsx("div",{className:"ntd-lazy-loading",style:{display:"flex",alignItems:"center",justifyContent:"center",height:e,background:"var(--ntd-color-surface, #f5f5f5)",borderRadius:"var(--ntd-radius, 8px)",animation:"ntd-pulse 1.5s ease-in-out infinite"},children:i.jsx("div",{className:"ntd-lazy-loading-spinner",style:{width:24,height:24,border:"2px solid var(--ntd-color-border, #ddd)",borderTopColor:"var(--ntd-color-primary, #6366f1)",borderRadius:"50%",animation:"ntd-spin 0.8s linear infinite"}})}),K=(e,o)=>i.jsxs("div",{className:"ntd-lazy-error",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:24,background:"var(--ntd-color-error-bg, #fee2e2)",borderRadius:"var(--ntd-radius, 8px)",color:"var(--ntd-color-error, #dc2626)"},children:[i.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),i.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),i.jsx("p",{style:{margin:"12px 0 8px",fontWeight:500},children:"Failed to load component"}),i.jsx("p",{style:{margin:0,fontSize:"0.875em",opacity:.8},children:e.message}),i.jsx("button",{onClick:o,style:{marginTop:16,padding:"8px 16px",border:"none",borderRadius:"var(--ntd-radius, 8px)",background:"var(--ntd-color-error, #dc2626)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:"0.875em"},children:"Retry"})]});class oe extends r.Component{constructor(){super(...arguments),this.state={error:null},this.handleRetry=()=>{this.setState({error:null})}}static getDerivedStateFromError(o){return{error:o}}render(){return this.state.error?this.props.fallback(this.state.error,this.handleRetry):this.props.children}}function w(e,o={}){const{fallback:t=i.jsx(j,{}),preloadOnMount:s=!1,preloadOnHover:a=!1,preloadAfterIdle:n,minLoadingTime:u=0,ssrFallback:l,errorFallback:d=K,displayName:h}=o;let c=null,S=!1;const g=async()=>{if(c)return c;const p=Date.now();c=e();const y=await c;if(u>0){const A=Date.now()-p;A<u&&await new Promise(k=>setTimeout(k,u-A))}return S=!0,y},R=r.lazy(g),b=p=>{const y=r.useRef(null);return r.useEffect(()=>{s&&!S&&g()},[]),r.useEffect(()=>{if(n&&!S){const k="requestIdleCallback"in window?window.requestIdleCallback(()=>g(),{timeout:n}):setTimeout(()=>g(),n);return()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(k):clearTimeout(k)}}},[]),r.useEffect(()=>{if(!a||S)return;const k=y.current;if(!k)return;const z=()=>{S||g()};return k.addEventListener("mouseenter",z,{once:!0}),()=>k.removeEventListener("mouseenter",z)},[]),typeof window>"u"&&l?i.jsx(i.Fragment,{children:l}):i.jsx("div",{ref:y,className:"ntd-lazy-wrapper",children:i.jsx(oe,{fallback:d,children:i.jsx(r.Suspense,{fallback:t,children:i.jsx(R,{...p})})})})},x=async()=>{S||await g()},E=b;return E.preload=x,E.displayName=h||"LazyComponent",E}function ae(e=.1,o="100px"){const t=r.useRef(null),[s,a]=r.useState(!1);return r.useEffect(()=>{if(!t.current||s)return;const n=new IntersectionObserver(([u])=>{u.isIntersecting&&(a(!0),n.disconnect())},{threshold:e,rootMargin:o});return n.observe(t.current),()=>n.disconnect()},[e,o,s]),[t,s]}function ne(e,o=2e3){r.useEffect(()=>{if("requestIdleCallback"in window){const t=window.requestIdleCallback(()=>{e.forEach(s=>s())},{timeout:o});return()=>window.cancelIdleCallback(t)}else{const t=setTimeout(()=>{e.forEach(s=>s())},o);return()=>clearTimeout(t)}},[])}function le(e,o){const t=r.useRef(new Set);r.useEffect(()=>{const s=document.querySelectorAll("a[href]"),a=n=>{const l=n.currentTarget.getAttribute("href");l&&e[l]&&!t.current.has(l)&&(e[l](),t.current.add(l))};return s.forEach(n=>{n.addEventListener("mouseenter",a)}),()=>{s.forEach(n=>{n.removeEventListener("mouseenter",a)})}},[o,e])}const U=()=>i.jsx(j,{height:400}),$=()=>i.jsx(j,{height:300}),F=()=>i.jsx(j,{height:500}),B=()=>i.jsx(j,{height:600}),P=e=>e,C={CodeEditor:w(P(()=>Promise.resolve().then(()=>require("./NiceCodeEditor-DE3saxyt.cjs")).then(e=>({default:e.NiceCodeEditor}))),{fallback:i.jsx(U,{}),preloadOnHover:!0,displayName:"LazyCodeEditor"}),HtmlEditor:w(P(()=>Promise.resolve().then(()=>require("./NiceHtmlEditor-CKsGj-Ei.cjs")).then(e=>({default:e.NiceHtmlEditor}))),{fallback:i.jsx(U,{}),preloadOnHover:!0,displayName:"LazyHtmlEditor"}),DocumentViewer:w(P(()=>Promise.resolve().then(()=>require("./NiceDocumentViewer-ChWtA_Ry.cjs")).then(e=>({default:e.NiceDocumentViewer}))),{fallback:i.jsx(j,{height:600}),displayName:"LazyDocumentViewer"}),Chart:w(P(()=>Promise.resolve().then(()=>require("./charts-B8_V3_nq.cjs")).then(e=>e.NiceChart$1).then(e=>({default:e.NiceChart}))),{fallback:i.jsx($,{}),preloadAfterIdle:3e3,displayName:"LazyChart"}),VectorMap:w(P(()=>Promise.resolve().then(()=>require("./charts-B8_V3_nq.cjs")).then(e=>e.NiceVectorMap$1).then(e=>({default:e.NiceVectorMap}))),{fallback:i.jsx(j,{height:400}),displayName:"LazyVectorMap"}),Sankey:w(P(()=>Promise.resolve().then(()=>require("./charts-B8_V3_nq.cjs")).then(e=>e.NiceSankey$1).then(e=>({default:e.NiceSankey}))),{fallback:i.jsx($,{}),displayName:"LazySankey"}),Scheduler:w(P(()=>Promise.resolve().then(()=>require("./NiceScheduler-BEgB7ZgF.cjs")).then(e=>e.NiceScheduler$1).then(e=>({default:e.NiceScheduler}))),{fallback:i.jsx(B,{}),displayName:"LazyScheduler"}),Gantt:w(P(()=>Promise.resolve().then(()=>require("./NiceGantt-jQ8ZpXko.cjs")).then(e=>({default:e.NiceGantt}))),{fallback:i.jsx(B,{}),displayName:"LazyGantt"}),PivotGrid:w(P(()=>Promise.resolve().then(()=>require("./NicePivotGrid-CLCTHkKO.cjs")).then(e=>e.NicePivotGrid$1).then(e=>({default:e.NicePivotGrid}))),{fallback:i.jsx(F,{}),displayName:"LazyPivotGrid"}),DataGrid:w(P(()=>Promise.resolve().then(()=>require("./NiceDataGrid-BzUw4dSu.cjs")).then(e=>e.NiceDataGrid$1).then(e=>({default:e.NiceDataGrid}))),{fallback:i.jsx(F,{}),preloadAfterIdle:2e3,displayName:"LazyDataGrid"})};async function ce(){await Promise.all([C.CodeEditor.preload(),C.HtmlEditor.preload(),C.DocumentViewer.preload(),C.Chart.preload(),C.VectorMap.preload(),C.Sankey.preload(),C.Scheduler.preload(),C.Gantt.preload(),C.PivotGrid.preload()])}async function ie(e){await Promise.all(e.map(o=>C[o].preload()))}exports.DefaultErrorFallback=K;exports.DefaultLoadingFallback=j;exports.LazyComponents=C;exports.TracelessProvider=J;exports.createLazyComponent=w;exports.preloadAllHeavyComponents=ce;exports.preloadComponents=ie;exports.useCookieBannerVisibility=X;exports.useEditorStatePersistence=te;exports.useGridStatePersistence=ee;exports.useLazyOnVisible=ae;exports.usePersistedState=I;exports.usePreloadOnIdle=ne;exports.usePreloadOnRouteHint=le;exports.useResolvedStorageProps=se;exports.useStorageAdapter=D;exports.useStorageAudit=Y;exports.useTracelessLocalStorage=Z;exports.useTracelessPolicy=Q;exports.useTracelessPolicySafe=L;exports.useTracelessSessionStorage=_;exports.useTracelessStorage=re;
@@ -0,0 +1 @@
1
+ "use strict";const r=require("react"),m=require("./charts-NolNXKUL.cjs"),i=require("react/jsx-runtime"),q=r.createContext(null);function J({children:e,initialPolicy:o,policyEndpoint:t,instanceCeiling:s,tenantPolicy:a,groupPolicy:n,userPreference:u,instanceId:l="default",tenantId:d,onPolicyChange:h}){const[c,S]=r.useState(o||m.od),[g,R]=r.useState(u),[b,x]=r.useState(!!t),[E,p]=r.useState(null),y=r.useRef(new Map);r.useEffect(()=>{const v=s||m.hd(l),f=m.sd(v,a,n,g);S(f),h?.(f),y.current.forEach(N=>{N.updatePolicy(f)})},[s,a,n,g,l,h]),r.useEffect(()=>{if(!t)return;(async()=>{x(!0),p(null);try{const f=await fetch(t,{credentials:"include"});if(!f.ok)throw new Error(`Failed to fetch policy: ${f.status}`);const N=f.headers.get(m.fd);if(N){const M=m.md(N);if(M){const T=s||m.hd(l),H=m.sd(T,a?{...a,mode:M}:{tenantId:"default",mode:M,allowGroupOverride:!0,allowUserOverride:!0,updatedAt:Date.now()},n,g);S(H),h?.(H)}}try{const M=await f.json();M.policy&&(S(M.policy),h?.(M.policy))}catch{}}catch(f){p(f instanceof Error?f:new Error("Unknown error"))}finally{x(!1)}})()},[t,s,a,n,g,l,h]);const A=r.useCallback(v=>{R(f=>({userId:f?.userId||"anonymous",preferredMode:v.preferredMode||f?.preferredMode||"traceless",restrictCookies:v.restrictCookies??f?.restrictCookies,restrictLocalStorage:v.restrictLocalStorage??f?.restrictLocalStorage,restrictSessionStorage:v.restrictSessionStorage??f?.restrictSessionStorage,setAt:Date.now()}))},[]),k=r.useCallback(()=>m.ld(c,l,d),[c,l,d]),z=r.useCallback(()=>m.vd(c),[c]),V=r.useCallback(async()=>{if(t){x(!0);try{const v=await fetch(t,{credentials:"include",cache:"no-cache"});if(v.ok){const f=v.headers.get(m.fd);if(f){const N=m.md(f);if(N){const M=s||m.hd(l),T=m.sd(M,a?{...a,mode:N}:void 0,n,g);S(T),h?.(T)}}}}finally{x(!1)}}},[t,s,a,n,g,l,h]),G=r.useCallback((v="nice2dev")=>{let f=y.current.get(v);return f||(f=new m.an(c,v),y.current.set(v,f)),f},[c]),O=r.useMemo(()=>m.dd(c),[c]),W=r.useMemo(()=>({policy:c,canUseCookies:c.cookiesAllowed,canUseLocalStorage:c.localStorageAllowed,canUseSessionStorage:c.sessionStorageAllowed,canPersist:c.localStorageAllowed,mode:c.effectiveMode,requiresConsentBanner:c.requiresConsentBanner,badgeInfo:O,setUserPreference:A,generateReport:k,runAudit:z,refreshPolicy:V,getStorageAdapter:G,isLoading:b,error:E}),[c,O,A,k,z,V,G,b,E]);return r.createElement(q.Provider,{value:W},e)}function Q(){const e=r.useContext(q);if(!e)throw new Error("useTracelessPolicy must be used within a TracelessProvider");return e}function L(){const e=r.useContext(q);if(e)return e;const o=new m.an(m.od);return{policy:m.od,canUseCookies:!1,canUseLocalStorage:!1,canUseSessionStorage:!1,canPersist:!1,mode:"traceless",requiresConsentBanner:!1,badgeInfo:m.dd(m.od),setUserPreference:()=>{},generateReport:()=>m.ld(m.od,"default"),runAudit:()=>m.vd(m.od),refreshPolicy:async()=>{},getStorageAdapter:()=>o,isLoading:!1,error:null}}function D(e="nice2dev"){const{getStorageAdapter:o}=L();return r.useMemo(()=>o(e),[o,e])}function I(e,o,t){const s=D(t?.namespace),{canPersist:a,canUseSessionStorage:n}=L(),u=t?.storageMode==="session"?n:a,[l,d]=r.useState(()=>{if(u){const c=s.get(e,t?.storageMode);if(c!==null)return c}return o}),h=r.useCallback(c=>{d(S=>{const g=typeof c=="function"?c(S):c;return u&&s.set(e,g,t?.storageMode==="session"?"session":"local"),g})},[s,e,u,t?.storageMode]);return[l,h,u]}function X(){const{requiresConsentBanner:e,mode:o}=L(),t=D("nice2dev-consent"),[s,a]=r.useState(()=>t.get("banner-dismissed")===!0),n=r.useCallback(()=>{a(!0),t.set("banner-dismissed",!0)},[t]);return{shouldShow:e&&!s,mode:o,dismiss:n}}function Y(e=!1){const{runAudit:o}=L(),[t,s]=r.useState(null),a=r.useCallback(()=>{const n=o();return s(n),n},[o]);return r.useEffect(()=>{e&&a()},[e,a]),{result:t,run:a,isCompliant:t?.compliant??null}}function Z(){const{policy:e,getStorageAdapter:o}=L(),t=r.useMemo(()=>o("local"),[o]),s=r.useCallback(l=>t.get(l),[t]),a=r.useCallback((l,d)=>{t.set(l,d)},[t]),n=r.useCallback(l=>{t.remove(l)},[t]),u=r.useCallback(()=>{t.clear()},[t]);return r.useMemo(()=>({getItem:s,setItem:a,removeItem:n,clear:u,isAvailable:e.localStorageAllowed,effectiveMode:e.effectiveMode,policy:e}),[s,a,n,u,e])}function _(){const{policy:e,getStorageAdapter:o}=L(),t=r.useMemo(()=>o("session"),[o]),s=r.useCallback(l=>t.get(l),[t]),a=r.useCallback((l,d)=>{t.set(l,d)},[t]),n=r.useCallback(l=>{t.remove(l)},[t]),u=r.useCallback(()=>{t.clear()},[t]);return r.useMemo(()=>({getItem:s,setItem:a,removeItem:n,clear:u,isAvailable:e.sessionStorageAllowed,effectiveMode:e.effectiveMode}),[s,a,n,u,e])}function ee({storageKey:e,initialState:o={},onStateChange:t,storageType:s="auto"}){const{policy:a,getStorageAdapter:n}=L(),u=`nice-datagrid-${e}`,l=r.useMemo(()=>{if(s==="local"&&a.localStorageAllowed)return"local";if(s==="session"&&a.sessionStorageAllowed)return"session";if(s==="auto"){if(a.localStorageAllowed)return"local";if(a.sessionStorageAllowed)return"session"}return"memory"},[s,a]),d=r.useMemo(()=>n(l==="session"?"session-grid":"local-grid"),[n,l]),[h,c]=r.useState(()=>{const b=d.get(u);if(b)try{return{...o,...JSON.parse(b)}}catch{return o}return o});r.useEffect(()=>{d.set(u,JSON.stringify(h)),t?.(h)},[h,d,u,t]);const S=r.useCallback(b=>{c(x=>({...x,...b}))},[]),g=r.useCallback(()=>{d.remove(u),c(o)},[d,u,o]);return{state:h,updateState:S,setState:c,clearState:g,degraded:l==="memory",effectiveStorageType:l,policy:a}}function te({storageKey:e,autoSaveInterval:o=5e3,maxVersions:t=10}){const{policy:s,getStorageAdapter:a}=L(),n=`nice-editor-${e}`,u=`${n}-history`,l=r.useMemo(()=>a("editor"),[a]),[d,h]=I(n,null,{storageMode:s.localStorageAllowed?"local":"session"}),[c,S]=I(u,[],{storageMode:"local"}),g=r.useCallback((p,y)=>{const A={content:p,cursorPosition:y,lastModified:Date.now(),version:(d?.version??0)+1};h(A)},[d,h]),R=r.useCallback(()=>{!d||!s.localStorageAllowed||S(p=>[...p,d].slice(-t))},[d,s.localStorageAllowed,t,S]),b=r.useCallback(p=>{const y=c.find(A=>A.version===p);y&&h(y)},[c,h]),x=r.useCallback(()=>{l.remove(n),h(null)},[l,n,h]),E=r.useRef(null);return r.useEffect(()=>{if(!o||!d?.content||d.content===E.current)return;const p=setTimeout(()=>{E.current=d.content??null},o);return()=>clearTimeout(p)},[d?.content,o]),{draft:d,saveDraft:g,saveToHistory:R,restoreVersion:b,clearDraft:x,history:c,hasDraft:d!==null,degraded:!s.localStorageAllowed&&!s.sessionStorageAllowed,policy:s}}function re(e="local"){const o=D(e),t=r.useRef([]);return r.useMemo(()=>({getItem:s=>o.get(s),setItem:(s,a)=>{o.set(s,a),t.current.includes(s)||t.current.push(s)},removeItem:s=>{o.remove(s),t.current=t.current.filter(a=>a!==s)},clear:()=>{o.clear(),t.current=[]},get length(){return t.current.length},key:s=>t.current[s]??null}),[o])}function se(e){const{policy:o}=L();return r.useMemo(()=>{const t=o.cookiesAllowed&&e.cookies!==!1,s=o.localStorageAllowed&&e.localStorage!==!1,a=o.sessionStorageAllowed&&e.sessionStorage!==!1;return{cookiesAllowed:t,localStorageAllowed:s,sessionStorageAllowed:a,effectiveMode:o.effectiveMode,canPersist:s||a,degraded:!s&&!a}},[o,e.cookies,e.localStorage,e.sessionStorage])}const j=({height:e=200})=>i.jsx("div",{className:"ntd-lazy-loading",style:{display:"flex",alignItems:"center",justifyContent:"center",height:e,background:"var(--ntd-color-surface, #f5f5f5)",borderRadius:"var(--ntd-radius, 8px)",animation:"ntd-pulse 1.5s ease-in-out infinite"},children:i.jsx("div",{className:"ntd-lazy-loading-spinner",style:{width:24,height:24,border:"2px solid var(--ntd-color-border, #ddd)",borderTopColor:"var(--ntd-color-primary, #6366f1)",borderRadius:"50%",animation:"ntd-spin 0.8s linear infinite"}})}),K=(e,o)=>i.jsxs("div",{className:"ntd-lazy-error",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:24,background:"var(--ntd-color-error-bg, #fee2e2)",borderRadius:"var(--ntd-radius, 8px)",color:"var(--ntd-color-error, #dc2626)"},children:[i.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[i.jsx("circle",{cx:"12",cy:"12",r:"10"}),i.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),i.jsx("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),i.jsx("p",{style:{margin:"12px 0 8px",fontWeight:500},children:"Failed to load component"}),i.jsx("p",{style:{margin:0,fontSize:"0.875em",opacity:.8},children:e.message}),i.jsx("button",{onClick:o,style:{marginTop:16,padding:"8px 16px",border:"none",borderRadius:"var(--ntd-radius, 8px)",background:"var(--ntd-color-error, #dc2626)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:"0.875em"},children:"Retry"})]});class oe extends r.Component{constructor(){super(...arguments),this.state={error:null},this.handleRetry=()=>{this.setState({error:null})}}static getDerivedStateFromError(o){return{error:o}}render(){return this.state.error?this.props.fallback(this.state.error,this.handleRetry):this.props.children}}function w(e,o={}){const{fallback:t=i.jsx(j,{}),preloadOnMount:s=!1,preloadOnHover:a=!1,preloadAfterIdle:n,minLoadingTime:u=0,ssrFallback:l,errorFallback:d=K,displayName:h}=o;let c=null,S=!1;const g=async()=>{if(c)return c;const p=Date.now();c=e();const y=await c;if(u>0){const A=Date.now()-p;A<u&&await new Promise(k=>setTimeout(k,u-A))}return S=!0,y},R=r.lazy(g),b=p=>{const y=r.useRef(null);return r.useEffect(()=>{s&&!S&&g()},[]),r.useEffect(()=>{if(n&&!S){const k="requestIdleCallback"in window?window.requestIdleCallback(()=>g(),{timeout:n}):setTimeout(()=>g(),n);return()=>{"cancelIdleCallback"in window?window.cancelIdleCallback(k):clearTimeout(k)}}},[]),r.useEffect(()=>{if(!a||S)return;const k=y.current;if(!k)return;const z=()=>{S||g()};return k.addEventListener("mouseenter",z,{once:!0}),()=>k.removeEventListener("mouseenter",z)},[]),typeof window>"u"&&l?i.jsx(i.Fragment,{children:l}):i.jsx("div",{ref:y,className:"ntd-lazy-wrapper",children:i.jsx(oe,{fallback:d,children:i.jsx(r.Suspense,{fallback:t,children:i.jsx(R,{...p})})})})},x=async()=>{S||await g()},E=b;return E.preload=x,E.displayName=h||"LazyComponent",E}function ae(e=.1,o="100px"){const t=r.useRef(null),[s,a]=r.useState(!1);return r.useEffect(()=>{if(!t.current||s)return;const n=new IntersectionObserver(([u])=>{u.isIntersecting&&(a(!0),n.disconnect())},{threshold:e,rootMargin:o});return n.observe(t.current),()=>n.disconnect()},[e,o,s]),[t,s]}function ne(e,o=2e3){r.useEffect(()=>{if("requestIdleCallback"in window){const t=window.requestIdleCallback(()=>{e.forEach(s=>s())},{timeout:o});return()=>window.cancelIdleCallback(t)}else{const t=setTimeout(()=>{e.forEach(s=>s())},o);return()=>clearTimeout(t)}},[])}function le(e,o){const t=r.useRef(new Set);r.useEffect(()=>{const s=document.querySelectorAll("a[href]"),a=n=>{const l=n.currentTarget.getAttribute("href");l&&e[l]&&!t.current.has(l)&&(e[l](),t.current.add(l))};return s.forEach(n=>{n.addEventListener("mouseenter",a)}),()=>{s.forEach(n=>{n.removeEventListener("mouseenter",a)})}},[o,e])}const U=()=>i.jsx(j,{height:400}),$=()=>i.jsx(j,{height:300}),F=()=>i.jsx(j,{height:500}),B=()=>i.jsx(j,{height:600}),P=e=>e,C={CodeEditor:w(P(()=>Promise.resolve().then(()=>require("./NiceCodeEditor-DZM16My5.cjs")).then(e=>({default:e.NiceCodeEditor}))),{fallback:i.jsx(U,{}),preloadOnHover:!0,displayName:"LazyCodeEditor"}),HtmlEditor:w(P(()=>Promise.resolve().then(()=>require("./NiceHtmlEditor-B1nlXJNW.cjs")).then(e=>({default:e.NiceHtmlEditor}))),{fallback:i.jsx(U,{}),preloadOnHover:!0,displayName:"LazyHtmlEditor"}),DocumentViewer:w(P(()=>Promise.resolve().then(()=>require("./NiceDocumentViewer-goMzF1w3.cjs")).then(e=>({default:e.NiceDocumentViewer}))),{fallback:i.jsx(j,{height:600}),displayName:"LazyDocumentViewer"}),Chart:w(P(()=>Promise.resolve().then(()=>require("./charts-NolNXKUL.cjs")).then(e=>e.NiceChart$1).then(e=>({default:e.NiceChart}))),{fallback:i.jsx($,{}),preloadAfterIdle:3e3,displayName:"LazyChart"}),VectorMap:w(P(()=>Promise.resolve().then(()=>require("./charts-NolNXKUL.cjs")).then(e=>e.NiceVectorMap$1).then(e=>({default:e.NiceVectorMap}))),{fallback:i.jsx(j,{height:400}),displayName:"LazyVectorMap"}),Sankey:w(P(()=>Promise.resolve().then(()=>require("./charts-NolNXKUL.cjs")).then(e=>e.NiceSankey$1).then(e=>({default:e.NiceSankey}))),{fallback:i.jsx($,{}),displayName:"LazySankey"}),Scheduler:w(P(()=>Promise.resolve().then(()=>require("./NiceScheduler-C9JprsEI.cjs")).then(e=>e.NiceScheduler$1).then(e=>({default:e.NiceScheduler}))),{fallback:i.jsx(B,{}),displayName:"LazyScheduler"}),Gantt:w(P(()=>Promise.resolve().then(()=>require("./NiceGantt-BnQwyTfG.cjs")).then(e=>({default:e.NiceGantt}))),{fallback:i.jsx(B,{}),displayName:"LazyGantt"}),PivotGrid:w(P(()=>Promise.resolve().then(()=>require("./NicePivotGrid-B-KthuqL.cjs")).then(e=>e.NicePivotGrid$1).then(e=>({default:e.NicePivotGrid}))),{fallback:i.jsx(F,{}),displayName:"LazyPivotGrid"}),DataGrid:w(P(()=>Promise.resolve().then(()=>require("./NiceDataGrid-DJr33WMy.cjs")).then(e=>e.NiceDataGrid$1).then(e=>({default:e.NiceDataGrid}))),{fallback:i.jsx(F,{}),preloadAfterIdle:2e3,displayName:"LazyDataGrid"})};async function ce(){await Promise.all([C.CodeEditor.preload(),C.HtmlEditor.preload(),C.DocumentViewer.preload(),C.Chart.preload(),C.VectorMap.preload(),C.Sankey.preload(),C.Scheduler.preload(),C.Gantt.preload(),C.PivotGrid.preload()])}async function ie(e){await Promise.all(e.map(o=>C[o].preload()))}exports.DefaultErrorFallback=K;exports.DefaultLoadingFallback=j;exports.LazyComponents=C;exports.TracelessProvider=J;exports.createLazyComponent=w;exports.preloadAllHeavyComponents=ce;exports.preloadComponents=ie;exports.useCookieBannerVisibility=X;exports.useEditorStatePersistence=te;exports.useGridStatePersistence=ee;exports.useLazyOnVisible=ae;exports.usePersistedState=I;exports.usePreloadOnIdle=ne;exports.usePreloadOnRouteHint=le;exports.useResolvedStorageProps=se;exports.useStorageAdapter=D;exports.useStorageAudit=Y;exports.useTracelessLocalStorage=Z;exports.useTracelessPolicy=Q;exports.useTracelessPolicySafe=L;exports.useTracelessSessionStorage=_;exports.useTracelessStorage=re;
@@ -0,0 +1 @@
1
+ "use strict";const e=require("react/jsx-runtime"),c=require("./charts-B8_V3_nq.cjs"),a=require("react");function pe(p=new Date){const M=new Date().getTime()-p.getTime(),S=Math.floor(M/1e3),z=Math.floor(S/60),I=Math.floor(z/60),U=Math.floor(I/24);let W;return S<60?W="just now":z<60?W=`${z} minute${z>1?"s":""} ago`:I<24?W=`${I} hour${I>1?"s":""} ago`:U<30?W=`${U} day${U>1?"s":""} ago`:W=p.toLocaleDateString(),{date:p,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,relative:W}}function xe(p){return p.substring(0,7)}function ue(p){const f=p||crypto.randomUUID();return{id:f,shortId:xe(f)}}const Y=["development","testing","uat","staging","production"],B={development:"var(--nice-success, #22c55e)",testing:"var(--nice-primary, #3b82f6)",uat:"var(--nice-warning, #f59e0b)",staging:"var(--nice-accent, #8b5cf6)",production:"var(--nice-danger, #ef4444)"},_={development:"🛠️",testing:"🧪",uat:"👥",staging:"🚀",production:"🏭"};function ee(p){return Y.indexOf(p)}function ie(p,f){return ee(p)<ee(f)}const ge=[{name:"customers",displayName:"Customers",recordCount:15420,sizeBytes:256e5,module:"CRM"},{name:"products",displayName:"Products",recordCount:3200,sizeBytes:85e5,module:"Inventory"},{name:"orders",displayName:"Orders",recordCount:48500,sizeBytes:125e6,module:"Sales"},{name:"order_items",displayName:"Order Items",recordCount:156e3,sizeBytes:45e6,module:"Sales",hasForeignKeys:!0},{name:"invoices",displayName:"Invoices",recordCount:42e3,sizeBytes:85e6,module:"Finance"},{name:"employees",displayName:"Employees",recordCount:450,sizeBytes:25e5,module:"HR"},{name:"config",displayName:"Configuration",recordCount:1200,sizeBytes:5e5,module:"System"}],he=[{id:"prod-1",shortId:"prod-1",name:"production",displayName:"Production",description:"Live production environment",isDefault:!0,isProtected:!0,createdBy:{id:"system",name:"System"},createdAt:{date:new Date("2024-01-01"),relative:"1 year ago"},lastActivity:{date:new Date,relative:"just now"},status:"active",type:"data",environment:"production",tenant:"tenant-1",size:{records:265770,bytes:2921e5}},{id:"uat-1",shortId:"uat-1",name:"uat",displayName:"UAT",description:"User Acceptance Testing",isDefault:!1,isProtected:!0,createdBy:{id:"admin",name:"Admin"},createdAt:{date:new Date("2025-01-15"),relative:"3 months ago"},lastActivity:{date:new Date,relative:"2 days ago"},upstream:"prod-1",status:"active",type:"data",environment:"uat",tenant:"tenant-1",sourceSnapshot:"snapshot-prod-20250115",size:{records:265e3,bytes:29e7}},{id:"dev-1",shortId:"dev-1",name:"development",displayName:"Development",description:"Development environment",isDefault:!1,isProtected:!1,createdBy:{id:"dev-1",name:"Developer"},createdAt:{date:new Date("2025-03-01"),relative:"1 month ago"},lastActivity:{date:new Date,relative:"1 hour ago"},upstream:"uat-1",status:"active",type:"data",environment:"development",tenant:"tenant-1",tables:["customers","products","orders"],size:{records:67120,bytes:1591e5}}],se=({tenant:p,branches:f,currentUser:M={id:"user-1",name:"Current User"},availableTables:S=ge,readOnly:z=!1,onCreateBranch:I,onDeleteBranch:U,onSwitchBranch:W,onCloneBranch:H,onSyncBranch:G,onProtectBranch:V,onScheduleSync:m,className:b,style:q,"data-testid":C})=>{const[T,g]=a.useState(f??he),[O,v]=a.useState(null),[L,j]=a.useState(null),[A,$]=a.useState("development"),[l,y]=a.useState(""),[x,R]=a.useState([]),[P,d]=a.useState(!0),[w,F]=a.useState({requireApproval:!0,approversCount:1,requireBackup:!0,allowDirectChanges:!1}),[k,i]=a.useState({enabled:!1,frequency:"daily",direction:"pull"}),t=a.useMemo(()=>T.find(n=>n.id===O),[T,O]),r=a.useMemo(()=>{const n={production:[],staging:[],uat:[],testing:[],development:[]};return T.forEach(u=>{n[u.environment].push(u)}),n},[T]),o=n=>n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:n<1024*1024*1024?`${(n/(1024*1024)).toFixed(1)} MB`:`${(n/(1024*1024*1024)).toFixed(1)} GB`,h=a.useCallback(()=>{const n={...ue(),name:l||`${A}-${Date.now()}`,displayName:l||A,isDefault:!1,isProtected:!1,createdBy:M,createdAt:pe(),status:"active",type:"data",environment:A,tenant:p,sourceSnapshot:t?.id,upstream:t?.id,tables:P?void 0:x,size:{records:0,bytes:0}};g(u=>[...u,n]),I?.(n),H?.(t?.id??"",A,P?void 0:x),j(null),N()},[l,A,t,P,x,M,p,I,H]),N=()=>{y(""),$("development"),R([]),d(!0)},K=a.useCallback(()=>{t&&(g(n=>n.filter(u=>u.id!==t.id)),U?.(t.id),v(null),j(null))},[t,U]),E=n=>{t&&(G?.(t.id,n),j(null))},X=()=>{t&&(g(n=>n.map(u=>u.id===t.id?{...u,isProtected:!0}:u)),V?.(t.id,w),j(null))},s={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)"};return e.jsxs("div",{className:`nice-data-branch-manager ${b||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:s.bg,color:s.text,fontFamily:"system-ui, sans-serif",...q},"data-testid":C,children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsxs("h3",{style:{margin:0,fontSize:16},children:[e.jsx(c.oa,{name:"database",size:16})," Data Environments"]}),e.jsxs("span",{style:{fontSize:12,color:s.textMuted},children:["Tenant: ",p," • ",T.length," environments"]})]}),!z&&e.jsx("button",{onClick:()=>{v(T.find(n=>n.isDefault)?.id??null),j("clone")},style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"+ New Environment"})]}),e.jsx("div",{style:{padding:16,borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",gap:8,overflowX:"auto"},children:Y.map((n,u)=>{const D=r[n],Q=D.length>0;return e.jsxs(a.Fragment,{children:[e.jsxs("div",{style:{padding:"8px 16px",borderRadius:6,background:Q?B[n]+"20":s.cardBg,border:`2px solid ${Q?B[n]:s.border}`,opacity:Q?1:.5,cursor:Q?"pointer":"default"},onClick:()=>Q&&v(D[0].id),children:[e.jsx("div",{style:{fontSize:18},children:_[n]}),e.jsx("div",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase"},children:n}),Q&&e.jsxs("div",{style:{fontSize:10,color:s.textMuted},children:[D.length," branch",D.length>1?"es":""]})]}),u<Y.length-1&&e.jsx("div",{style:{color:s.textMuted,fontSize:20},children:"→"})]},n)})}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[e.jsxs("div",{style:{width:300,borderRight:`1px solid ${s.border}`,overflow:"auto"},children:[e.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${s.border}`,fontSize:11,color:s.textMuted},children:"All Environments"}),T.map(n=>e.jsxs("div",{onClick:()=>v(n.id),style:{padding:"12px 16px",borderBottom:`1px solid ${s.border}`,background:O===n.id?s.cardBg:"transparent",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:16},children:_[n.environment]}),e.jsx("span",{style:{fontWeight:500},children:n.displayName}),n.isProtected&&e.jsx("span",{style:{fontSize:12},children:e.jsx(c.oa,{name:"lock",size:12})}),n.isDefault&&e.jsx("span",{style:{padding:"2px 6px",background:B[n.environment],borderRadius:4,fontSize:9,fontWeight:600},children:"DEFAULT"})]}),e.jsxs("div",{style:{fontSize:11,color:s.textMuted,marginTop:4},children:[n.size?.records.toLocaleString()," records •"," ",o(n.size?.bytes??0)]}),e.jsx("div",{style:{fontSize:10,color:s.textMuted,marginTop:2},children:n.lastActivity?.relative})]},n.id))]}),e.jsx("div",{style:{flex:1,overflow:"auto",padding:16},children:t?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:8},children:[e.jsx("span",{style:{fontSize:32},children:_[t.environment]}),e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:20},children:t.displayName}),e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",background:B[t.environment],borderRadius:4,fontSize:10,fontWeight:600,marginTop:4},children:t.environment.toUpperCase()})]})]}),t.description&&e.jsx("p",{style:{color:s.textMuted,margin:"8px 0"},children:t.description})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:24},children:[{label:"Records",value:t.size?.records.toLocaleString()??"0"},{label:"Size",value:o(t.size?.bytes??0)},{label:"Tables",value:t.tables?.length.toString()??"All"},{label:"Status",value:t.status}].map(n=>e.jsxs("div",{style:{padding:12,background:s.cardBg,borderRadius:8,textAlign:"center"},children:[e.jsx("div",{style:{fontSize:18,fontWeight:600},children:n.value}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:n.label})]},n.label))}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsx("h4",{style:{margin:"0 0 12px 0",fontSize:14},children:"Details"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"120px 1fr",gap:"8px 16px",fontSize:13},children:[e.jsx("span",{style:{color:s.textMuted},children:"Created by"}),e.jsx("span",{children:t.createdBy.name}),e.jsx("span",{style:{color:s.textMuted},children:"Created at"}),e.jsx("span",{children:t.createdAt.date?.toLocaleString()}),e.jsx("span",{style:{color:s.textMuted},children:"Last activity"}),e.jsx("span",{children:t.lastActivity?.relative}),t.upstream&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:s.textMuted},children:"Source"}),e.jsx("span",{children:T.find(n=>n.id===t.upstream)?.displayName??"Unknown"})]}),t.sourceSnapshot&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:s.textMuted},children:"Snapshot"}),e.jsx("span",{children:t.sourceSnapshot})]})]})]}),t.tables&&e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("h4",{style:{margin:"0 0 12px 0",fontSize:14},children:["Included Tables (",t.tables.length,")"]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:t.tables.map(n=>e.jsxs("span",{style:{padding:"4px 10px",background:s.cardBg,borderRadius:4,fontSize:12},children:[e.jsx(c.oa,{name:"database",size:14})," ",n]},n))})]}),!z&&e.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[e.jsxs("button",{onClick:()=>W?.(t.id),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:12},children:[e.jsx(c.oa,{name:"zap",size:14})," Switch to this environment"]}),e.jsxs("button",{onClick:()=>j("clone"),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:[e.jsx(c.oa,{name:"clipboard",size:14})," Clone"]}),e.jsxs("button",{onClick:()=>j("sync"),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:[e.jsx(c.oa,{name:"refresh",size:14})," Sync"]}),!t.isProtected&&e.jsxs("button",{onClick:()=>j("protect"),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:[e.jsx(c.oa,{name:"lock",size:14})," Protect"]}),!t.isDefault&&!t.isProtected&&e.jsxs("button",{onClick:()=>j("delete"),style:{padding:"8px 16px",borderRadius:6,border:"1px solid var(--nice-danger, #ef4444)",background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:12},children:[e.jsx(c.oa,{name:"trash",size:14})," Delete"]})]})]}):e.jsxs("div",{style:{padding:32,textAlign:"center",color:s.textMuted},children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:e.jsx(c.oa,{name:"database",size:48})}),e.jsx("div",{children:"Select an environment to view details"})]})})]}),L==="clone"&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-75, rgba(0, 0, 0, 0.75))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>j(null),children:e.jsxs("div",{onClick:n=>n.stopPropagation(),style:{background:s.cardBg,borderRadius:12,padding:24,width:500,maxHeight:"80vh",overflow:"auto"},children:[e.jsxs("h3",{style:{margin:"0 0 16px 0"},children:[e.jsx(c.oa,{name:"clipboard",size:14})," Clone Environment"]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",marginBottom:6,fontSize:12,color:s.textMuted},children:"Source Environment"}),e.jsxs("div",{style:{padding:12,background:s.bg,borderRadius:6,display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{children:_[t?.environment??"production"]}),e.jsx("span",{children:t?.displayName??"Production"})]})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",marginBottom:6,fontSize:12,color:s.textMuted},children:"Target Environment"}),e.jsx("select",{value:A,onChange:n=>$(n.target.value),style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:13},children:Y.filter(n=>ie(t?.environment??"production",n)||n==="development"||n==="testing").map(n=>e.jsxs("option",{value:n,children:[_[n]," ",n.charAt(0).toUpperCase()+n.slice(1)]},n))})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{style:{display:"block",marginBottom:6,fontSize:12,color:s.textMuted},children:"Environment Name"}),e.jsx("input",{type:"text",value:l,onChange:n=>y(n.target.value),placeholder:`${A}-${new Date().toISOString().split("T")[0]}`,style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${s.border}`,background:s.bg,color:s.text,fontSize:13}})]}),e.jsx("div",{style:{marginBottom:16},children:e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:P,onChange:n=>d(n.target.checked)}),e.jsx("span",{style:{fontSize:13},children:"Include all tables"})]})}),!P&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("label",{style:{display:"block",marginBottom:6,fontSize:12,color:s.textMuted},children:["Select Tables (",x.length," selected)"]}),e.jsx("div",{style:{maxHeight:200,overflow:"auto",border:`1px solid ${s.border}`,borderRadius:6},children:S.map(n=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",borderBottom:`1px solid ${s.border}`,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:x.includes(n.name),onChange:u=>{u.target.checked?R(D=>[...D,n.name]):R(D=>D.filter(Q=>Q!==n.name))}}),e.jsx("span",{style:{flex:1,fontSize:13},children:n.displayName}),e.jsxs("span",{style:{fontSize:11,color:s.textMuted},children:[n.recordCount.toLocaleString()," rows"]})]},n.name))})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>j(null),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:h,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Clone Environment"})]})]})}),L==="sync"&&t&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-75, rgba(0, 0, 0, 0.75))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>j(null),children:e.jsxs("div",{onClick:n=>n.stopPropagation(),style:{background:s.cardBg,borderRadius:12,padding:24,width:400},children:[e.jsxs("h3",{style:{margin:"0 0 16px 0"},children:[e.jsx(c.oa,{name:"refresh",size:14})," Sync Environment"]}),e.jsxs("p",{style:{color:s.textMuted,fontSize:13,marginBottom:16},children:["Synchronize data between ",t.displayName," and its source."]}),e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[e.jsxs("button",{onClick:()=>E("pull"),style:{flex:1,padding:"16px",borderRadius:8,border:`2px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",textAlign:"center"},children:[e.jsx("div",{style:{fontSize:24,marginBottom:8},children:e.jsx(c.oa,{name:"arrow-down",size:24})}),e.jsx("div",{style:{fontWeight:500},children:"Pull"}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:"Get changes from source"})]}),e.jsxs("button",{onClick:()=>E("push"),disabled:t.environment==="production",style:{flex:1,padding:"16px",borderRadius:8,border:`2px solid ${s.border}`,background:"transparent",color:t.environment==="production"?s.textMuted:s.text,cursor:t.environment==="production"?"not-allowed":"pointer",textAlign:"center",opacity:t.environment==="production"?.5:1},children:[e.jsx("div",{style:{fontSize:24,marginBottom:8},children:e.jsx(c.oa,{name:"arrow-up",size:24})}),e.jsx("div",{style:{fontWeight:500},children:"Push"}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:"Send changes to source"})]})]}),e.jsx("button",{onClick:()=>j(null),style:{width:"100%",padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"})]})}),L==="delete"&&t&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-75, rgba(0, 0, 0, 0.75))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>j(null),children:e.jsxs("div",{onClick:n=>n.stopPropagation(),style:{background:s.cardBg,borderRadius:12,padding:24,width:400},children:[e.jsxs("h3",{style:{margin:"0 0 16px 0",color:"var(--nice-color-error, #ef4444)"},children:[e.jsx(c.oa,{name:"trash",size:14})," Delete Environment"]}),e.jsxs("p",{style:{color:s.textMuted,fontSize:13,marginBottom:16},children:["Are you sure you want to delete ",e.jsx("strong",{children:t.displayName}),"? This will remove all ",t.size?.records.toLocaleString()," records."]}),e.jsxs("div",{style:{padding:12,background:"var(--nice-danger-tint-15, #ef444420)",border:"1px solid var(--nice-danger, #ef4444)",borderRadius:6,marginBottom:16,fontSize:12},children:[e.jsx(c.oa,{name:"warning",size:14})," This action cannot be undone."]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>j(null),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:K,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-error, #ef4444)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Delete Environment"})]})]})}),L==="protect"&&t&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-75, rgba(0, 0, 0, 0.75))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>j(null),children:e.jsxs("div",{onClick:n=>n.stopPropagation(),style:{background:s.cardBg,borderRadius:12,padding:24,width:450},children:[e.jsxs("h3",{style:{margin:"0 0 16px 0"},children:[e.jsx(c.oa,{name:"lock",size:14})," Protect Environment"]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginBottom:16},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:w.requireApproval,onChange:n=>F(u=>({...u,requireApproval:n.target.checked}))}),e.jsx("span",{style:{fontSize:13},children:"Require approval for changes"})]}),w.requireApproval&&e.jsxs("div",{style:{marginLeft:24},children:[e.jsx("label",{style:{display:"block",marginBottom:4,fontSize:11,color:s.textMuted},children:"Minimum approvers"}),e.jsx("input",{type:"number",min:1,max:5,value:w.approversCount,onChange:n=>F(u=>({...u,approversCount:parseInt(n.target.value)||1})),style:{width:80,padding:6,borderRadius:4,border:`1px solid ${s.border}`,background:s.bg,color:s.text}})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:w.requireBackup,onChange:n=>F(u=>({...u,requireBackup:n.target.checked}))}),e.jsx("span",{style:{fontSize:13},children:"Require backup before changes"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!w.allowDirectChanges,onChange:n=>F(u=>({...u,allowDirectChanges:!n.target.checked}))}),e.jsx("span",{style:{fontSize:13},children:"Block direct changes (require merge)"})]})]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>j(null),style:{padding:"8px 16px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:X,style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-warning, #f59e0b)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Apply Protection"})]})]})})]})},ye=Object.freeze(Object.defineProperty({__proto__:null,NiceDataBranchManager:se},Symbol.toStringTag,{value:"Module"})),fe=[{table:"customers",displayName:"Customers",module:"CRM",added:15,modified:42,deleted:3,records:[{id:"CUST-001",changeType:"added",primaryKey:{customer_id:"CUST-001"},fields:[{field:"name",fieldType:"string",oldValue:void 0,newValue:"Acme Corp",changeType:"added"},{field:"email",fieldType:"string",oldValue:void 0,newValue:"info@acme.com",changeType:"added"},{field:"status",fieldType:"string",oldValue:void 0,newValue:"active",changeType:"added"}],changedAt:new Date,changedBy:"admin"},{id:"CUST-042",changeType:"modified",primaryKey:{customer_id:"CUST-042"},fields:[{field:"email",fieldType:"string",oldValue:"old@email.com",newValue:"new@email.com",changeType:"modified"},{field:"phone",fieldType:"string",oldValue:"+1-555-0100",newValue:"+1-555-0199",changeType:"modified"},{field:"updated_at",fieldType:"datetime",oldValue:"2025-01-01",newValue:"2025-04-01",changeType:"modified"}],changedAt:new Date,changedBy:"user1"},{id:"CUST-099",changeType:"deleted",primaryKey:{customer_id:"CUST-099"},fields:[{field:"name",fieldType:"string",oldValue:"Old Customer",newValue:void 0,changeType:"deleted"},{field:"status",fieldType:"string",oldValue:"inactive",newValue:void 0,changeType:"deleted"}],changedAt:new Date,changedBy:"admin"}]},{table:"products",displayName:"Products",module:"Inventory",added:8,modified:25,deleted:0,records:[{id:"PROD-NEW-1",changeType:"added",primaryKey:{product_id:"PROD-NEW-1"},fields:[{field:"name",fieldType:"string",oldValue:void 0,newValue:"New Product",changeType:"added"},{field:"price",fieldType:"decimal",oldValue:void 0,newValue:99.99,changeType:"added"}],changedAt:new Date,changedBy:"inventory_admin"}]},{table:"orders",displayName:"Orders",module:"Sales",added:156,modified:12,deleted:0,records:[]},{table:"config",displayName:"Configuration",module:"System",added:0,modified:3,deleted:0,records:[{id:"CFG-TAX-RATE",changeType:"modified",primaryKey:{config_key:"tax_rate"},fields:[{field:"value",fieldType:"decimal",oldValue:.2,newValue:.21,changeType:"modified"}],changedAt:new Date,changedBy:"admin"}]}],oe=({sourceBranch:p,targetBranch:f,branches:M=[],diffItems:S=fe,onCompare:z,onExport:I,onSelectRecord:U,className:W,style:H,"data-testid":G})=>{const[V,m]=a.useState("summary"),[b,q]=a.useState("all"),[C,T]=a.useState(null),[g,O]=a.useState(null),[v,L]=a.useState(""),[j,A]=a.useState(!1),[$,l]=a.useState(p?.id??""),[y,x]=a.useState(f?.id??""),R=a.useMemo(()=>S.reduce((r,o)=>({tables:r.tables+1,added:r.added+o.added,modified:r.modified+o.modified,deleted:r.deleted+o.deleted}),{tables:0,added:0,modified:0,deleted:0}),[S]),P=a.useMemo(()=>S.filter(r=>{if(b==="added"&&r.added===0||b==="modified"&&r.modified===0||b==="deleted"&&r.deleted===0)return!1;if(v){const o=v.toLowerCase();return r.table.toLowerCase().includes(o)||r.displayName.toLowerCase().includes(o)||r.module?.toLowerCase().includes(o)}return!0}).sort((r,o)=>o.added+o.modified+o.deleted-(r.added+r.modified+r.deleted)),[S,b,v]),d=a.useMemo(()=>S.find(r=>r.table===C),[S,C]),w=a.useMemo(()=>d?d.records.filter(r=>b==="all"?!0:r.changeType===b):[],[d,b]),F=a.useCallback(()=>{$&&y&&z?.($,y)},[$,y,z]),k=r=>{switch(r){case"added":return"var(--nice-color-success, #22c55e)";case"modified":return"var(--nice-color-warning, #f59e0b)";case"deleted":return"var(--nice-color-error, #ef4444)";default:return"var(--nice-text-muted, #888)"}},i=r=>{switch(r){case"added":return"+";case"modified":return"~";case"deleted":return"-";default:return" "}},t={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)"};return e.jsxs("div",{className:`nice-data-diff-viewer ${W||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",...H},"data-testid":G,children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:16},children:[e.jsx(c.oa,{name:"bar-chart",size:16})," Data Diff Viewer"]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("select",{value:$,onChange:r=>l(r.target.value),style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"",children:"Select source..."}),M.map(r=>e.jsxs("option",{value:r.id,children:[_[r.environment]," ",r.displayName]},r.id))]}),e.jsx("span",{style:{color:t.textMuted},children:"→"}),e.jsxs("select",{value:y,onChange:r=>x(r.target.value),style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"",children:"Select target..."}),M.map(r=>e.jsxs("option",{value:r.id,children:[_[r.environment]," ",r.displayName]},r.id))]}),e.jsx("button",{onClick:F,disabled:!$||!y,style:{padding:"6px 12px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-bg-primary, #fff)",cursor:$&&y?"pointer":"not-allowed",fontSize:12,opacity:$&&y?1:.5},children:"Compare"})]}),e.jsx("div",{style:{flex:1}}),e.jsxs("select",{onChange:r=>{r.target.value&&(I?.(r.target.value),r.target.value="")},style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12},children:[e.jsx("option",{value:"",children:"Export..."}),e.jsx("option",{value:"json",children:"JSON"}),e.jsx("option",{value:"csv",children:"CSV"}),e.jsx("option",{value:"sql",children:"SQL Script"})]})]}),e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:24},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{color:t.textMuted,fontSize:12},children:"Tables:"}),e.jsx("span",{style:{fontWeight:600},children:R.tables})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:k("added")}}),e.jsxs("span",{style:{fontSize:12},children:["+",R.added," added"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:k("modified")}}),e.jsxs("span",{style:{fontSize:12},children:["~",R.modified," modified"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:10,height:10,borderRadius:"50%",background:k("deleted")}}),e.jsxs("span",{style:{fontSize:12},children:["-",R.deleted," deleted"]})]}),e.jsx("div",{style:{flex:1}}),e.jsx("div",{style:{display:"flex",gap:4},children:["all","added","modified","deleted"].map(r=>e.jsx("button",{onClick:()=>q(r),style:{padding:"4px 12px",borderRadius:4,border:"none",background:b===r?"var(--nice-color-primary, #3b82f6)":t.cardBg,color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:11,textTransform:"capitalize"},children:r},r))}),e.jsx("input",{type:"text",value:v,onChange:r=>L(r.target.value),placeholder:"Search tables...",style:{padding:"6px 12px",borderRadius:6,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontSize:12,width:180}})]}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[e.jsxs("div",{style:{width:280,borderRight:`1px solid ${t.border}`,overflow:"auto"},children:[e.jsxs("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`,fontSize:11,color:t.textMuted},children:["Tables (",P.length,")"]}),P.map(r=>e.jsxs("div",{onClick:()=>{T(r.table),O(null),m("table")},style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,background:C===r.table?t.cardBg:"transparent",cursor:"pointer"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[e.jsx("span",{style:{fontSize:14},children:e.jsx(c.oa,{name:"database",size:14})}),e.jsx("span",{style:{fontWeight:500,fontSize:13},children:r.displayName})]}),e.jsxs("div",{style:{display:"flex",gap:12,fontSize:11},children:[r.added>0&&e.jsxs("span",{style:{color:k("added")},children:["+",r.added]}),r.modified>0&&e.jsxs("span",{style:{color:k("modified")},children:["~",r.modified]}),r.deleted>0&&e.jsxs("span",{style:{color:k("deleted")},children:["-",r.deleted]})]}),r.module&&e.jsx("div",{style:{fontSize:10,color:t.textMuted,marginTop:4},children:r.module})]},r.table))]}),e.jsxs("div",{style:{flex:1,overflow:"auto"},children:[V==="summary"&&e.jsxs("div",{style:{padding:32,textAlign:"center",color:t.textMuted},children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:e.jsx(c.oa,{name:"bar-chart",size:48})}),e.jsx("div",{children:"Select a table to view changes"})]}),V==="table"&&d&&e.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h4",{style:{margin:0,fontSize:14},children:d.displayName}),e.jsxs("span",{style:{fontSize:11,color:t.textMuted},children:[d.table," • ",d.module]})]}),e.jsxs("div",{style:{display:"flex",gap:8,fontSize:12},children:[e.jsxs("span",{style:{color:k("added")},children:["+",d.added]}),e.jsxs("span",{style:{color:k("modified")},children:["~",d.modified]}),e.jsxs("span",{style:{color:k("deleted")},children:["-",d.deleted]})]})]}),e.jsx("div",{style:{flex:1,overflow:"auto"},children:w.length===0?e.jsx("div",{style:{padding:32,textAlign:"center",color:t.textMuted},children:"No records match the current filter"}):e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:t.cardBg},children:[e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Change"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Record ID"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Fields Changed"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Changed By"}),e.jsx("th",{style:{padding:"8px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Date"})]})}),e.jsx("tbody",{children:w.map(r=>e.jsxs("tr",{onClick:()=>{O(r),m("record")},style:{cursor:"pointer",background:g?.id===r.id?t.cardBg:"transparent"},children:[e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`},children:e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,borderRadius:4,background:k(r.changeType)+"30",color:k(r.changeType),fontWeight:600,fontSize:14},children:i(r.changeType)})}),e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`,fontFamily:"monospace"},children:r.id}),e.jsxs("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`},children:[r.fields.length," field",r.fields.length!==1?"s":""]}),e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`},children:r.changedBy??"-"}),e.jsx("td",{style:{padding:"8px 12px",borderBottom:`1px solid ${t.border}`,color:t.textMuted},children:r.changedAt?.toLocaleString()??"-"})]},r.id))})]})})]}),V==="record"&&g&&d&&e.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:12},children:[e.jsx("button",{onClick:()=>m("table"),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsxs("div",{children:[e.jsxs("h4",{style:{margin:0,fontSize:14},children:[d.displayName," / ",g.id]}),e.jsx("span",{style:{display:"inline-block",padding:"2px 8px",background:k(g.changeType)+"30",color:k(g.changeType),borderRadius:4,fontSize:10,fontWeight:600,marginTop:4,textTransform:"uppercase"},children:g.changeType})]})]}),e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${t.border}`,background:t.cardBg},children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,marginBottom:4},children:"Primary Key"}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:12},children:Object.entries(g.primaryKey).map(([r,o])=>e.jsxs("span",{style:{marginRight:16},children:[e.jsxs("span",{style:{color:t.textMuted},children:[r,":"]})," ",String(o)]},r))})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:16},children:[e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:t.cardBg},children:[e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`,width:30}}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Field"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Type"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Source Value"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${t.border}`},children:"Target Value"})]})}),e.jsx("tbody",{children:g.fields.map(r=>e.jsxs("tr",{children:[e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`},children:e.jsx("span",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:20,height:20,borderRadius:4,background:k(r.changeType)+"30",color:k(r.changeType),fontWeight:600,fontSize:12},children:i(r.changeType)})}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,fontWeight:500},children:r.field}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,color:t.textMuted},children:r.fieldType}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,fontFamily:"monospace",background:r.changeType==="deleted"?"var(--nice-danger-tint-15, #ef444420)":"transparent"},children:r.oldValue!==void 0?String(r.oldValue):e.jsx("span",{style:{color:t.textMuted,fontStyle:"italic"},children:"null"})}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${t.border}`,fontFamily:"monospace",background:r.changeType==="added"?"var(--nice-success-tint-12, #22c55e20)":r.changeType==="modified"?"var(--nice-warning-tint-15, #f59e0b20)":"transparent"},children:r.newValue!==void 0?String(r.newValue):e.jsx("span",{style:{color:t.textMuted,fontStyle:"italic"},children:"null"})})]},r.field))})]}),e.jsxs("div",{style:{marginTop:24,padding:16,background:t.cardBg,borderRadius:8},children:[e.jsx("div",{style:{fontSize:11,color:t.textMuted,marginBottom:8},children:"Change Metadata"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"100px 1fr",gap:"8px 16px",fontSize:12},children:[e.jsx("span",{style:{color:t.textMuted},children:"Changed by"}),e.jsx("span",{children:g.changedBy??"Unknown"}),e.jsx("span",{style:{color:t.textMuted},children:"Changed at"}),e.jsx("span",{children:g.changedAt?.toLocaleString()??"Unknown"})]})]})]})]})]})]})]})},me=Object.freeze(Object.defineProperty({__proto__:null,NiceDataDiffViewer:oe},Symbol.toStringTag,{value:"Module"})),be=[{id:"commit-1",shortId:"c1a2b3c",message:"Initial production snapshot",branch:"production",environment:"production",author:{id:"system",name:"System"},timestamp:new Date("2025-01-01T10:00:00"),parents:[],isMerge:!1,isSnapshot:!0,stats:{tables:25,recordsAdded:265770,recordsModified:0,recordsDeleted:0},tags:["v1.0.0"]},{id:"commit-2",shortId:"d4e5f6g",message:"Clone to UAT for Q1 testing",branch:"uat",environment:"uat",author:{id:"admin",name:"Admin"},timestamp:new Date("2025-01-15T09:00:00"),parents:["commit-1"],isMerge:!1,isSnapshot:!0,stats:{tables:25,recordsAdded:265e3,recordsModified:0,recordsDeleted:0}},{id:"commit-3",shortId:"h7i8j9k",message:"Customer data migration",branch:"uat",environment:"uat",author:{id:"user1",name:"Data Engineer"},timestamp:new Date("2025-02-01T14:30:00"),parents:["commit-2"],isMerge:!1,isSnapshot:!1,stats:{tables:1,recordsAdded:500,recordsModified:1200,recordsDeleted:50}},{id:"commit-4",shortId:"l0m1n2o",message:"Clone to development",branch:"development",environment:"development",author:{id:"dev1",name:"Developer"},timestamp:new Date("2025-03-01T08:00:00"),parents:["commit-3"],isMerge:!1,isSnapshot:!0,stats:{tables:15,recordsAdded:67120,recordsModified:0,recordsDeleted:0}},{id:"commit-5",shortId:"p3q4r5s",message:"New product catalog import",branch:"development",environment:"development",author:{id:"dev1",name:"Developer"},timestamp:new Date("2025-03-10T16:45:00"),parents:["commit-4"],isMerge:!1,isSnapshot:!1,stats:{tables:2,recordsAdded:350,recordsModified:0,recordsDeleted:0}},{id:"commit-6",shortId:"t6u7v8w",message:"Tax rate configuration update",branch:"development",environment:"development",author:{id:"dev2",name:"Config Admin"},timestamp:new Date("2025-03-15T11:20:00"),parents:["commit-5"],isMerge:!1,isSnapshot:!1,stats:{tables:1,recordsAdded:0,recordsModified:3,recordsDeleted:0}},{id:"commit-7",shortId:"x9y0z1a",message:"Merge development changes to UAT",branch:"uat",environment:"uat",author:{id:"admin",name:"Admin"},timestamp:new Date("2025-03-20T09:00:00"),parents:["commit-3","commit-6"],isMerge:!0,isSnapshot:!1,stats:{tables:3,recordsAdded:350,recordsModified:3,recordsDeleted:0},tags:["uat-release-1"]},{id:"commit-8",shortId:"b2c3d4e",message:"Production weekly backup",branch:"production",environment:"production",author:{id:"system",name:"System"},timestamp:new Date("2025-03-25T02:00:00"),parents:["commit-1"],isMerge:!1,isSnapshot:!0,stats:{tables:25,recordsAdded:0,recordsModified:5420,recordsDeleted:120},tags:["backup-2025-03-25"]}],de=({branches:p=[],commits:f=be,selectedCommitId:M,viewMode:S,showLanes:z=!0,onSelectCommit:I,onSelectBranch:U,onCompare:W,onRestore:H,className:G,style:V,"data-testid":m})=>{const[b,q]=a.useState("graph"),[C,T]=a.useState(null),[g,O]=a.useState(null),[v,L]=a.useState(null),j=S??b,A=M??C,$=a.useRef(null),l=a.useMemo(()=>[...f].sort((i,t)=>t.timestamp.getTime()-i.timestamp.getTime()),[f]),y=a.useMemo(()=>{const i={};return Y.forEach((t,r)=>{i[t]=r}),f.reduce((t,r)=>(t[r.id]=i[r.environment]??0,t),{})},[f]),x=a.useMemo(()=>f.find(i=>i.id===A),[f,A]),R=a.useCallback(i=>{g?(W?.(g,i),O(null)):(T(i),I?.(i))},[g,W,I]),P=i=>{const r=new Date().getTime()-i.getTime(),o=Math.floor(r/(1e3*60*60*24));return o===0?"Today":o===1?"Yesterday":o<7?`${o} days ago`:o<30?`${Math.floor(o/7)} weeks ago`:`${Math.floor(o/30)} months ago`},d={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)"},w=140,F=12,k=80;return e.jsxs("div",{className:`nice-data-branch-graph ${G||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:d.bg,color:d.text,fontFamily:"system-ui, sans-serif",...V},"data-testid":m,children:[e.jsxs("div",{style:{padding:"12px 16px",borderBottom:`1px solid ${d.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:16},children:[e.jsx(c.oa,{name:"bar-chart",size:16})," Data History"]}),e.jsx("div",{style:{display:"flex",gap:4},children:["graph","timeline","list"].map(i=>e.jsxs("button",{onClick:()=>q(i),style:{padding:"4px 12px",borderRadius:4,border:"none",background:j===i?"var(--nice-color-primary, #3b82f6)":d.cardBg,color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:11,textTransform:"capitalize"},children:[e.jsx(c.oa,{name:i==="graph"?"box":i==="timeline"?"calendar":"clipboard",size:14})," ",i]},i))}),e.jsx("div",{style:{flex:1}}),g?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsxs("span",{style:{fontSize:12,color:d.textMuted},children:["Select target to compare with ",f.find(i=>i.id===g)?.shortId]}),e.jsx("button",{onClick:()=>O(null),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${d.border}`,background:"transparent",color:d.text,cursor:"pointer",fontSize:11},children:"Cancel"})]}):e.jsxs("span",{style:{fontSize:12,color:d.textMuted},children:[l.length," snapshots"]})]}),z&&j==="graph"&&e.jsxs("div",{style:{display:"flex",borderBottom:`1px solid ${d.border}`,background:d.cardBg},children:[Y.map(i=>e.jsxs("div",{style:{width:w,padding:"8px 12px",textAlign:"center",borderRight:`1px solid ${d.border}`},children:[e.jsx("span",{style:{fontSize:16},children:_[i]}),e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",color:B[i]},children:i})]},i)),e.jsx("div",{style:{flex:1,padding:"8px 12px"},children:e.jsx("div",{style:{fontSize:11,color:d.textMuted},children:"Details"})})]}),e.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden"},children:[j==="graph"&&e.jsx("div",{ref:$,style:{flex:1,overflow:"auto"},children:e.jsxs("div",{style:{position:"relative",minHeight:l.length*k},children:[e.jsx("svg",{style:{position:"absolute",top:0,left:0,width:w*Y.length,height:l.length*k,pointerEvents:"none"},children:l.map((i,t)=>{const r=t*k+k/2,o=y[i.id]*w+w/2;return i.parents.map(h=>{const N=l.findIndex(n=>n.id===h);if(N===-1)return null;const K=N*k+k/2,E=y[h]*w+w/2,X=i.isMerge&&i.parents.indexOf(h)>0,s=o===E?`M ${o} ${r} L ${E} ${K}`:`M ${o} ${r} C ${o} ${(r+K)/2}, ${E} ${(r+K)/2}, ${E} ${K}`;return e.jsx("path",{d:s,fill:"none",stroke:X?"var(--nice-color-accent, #8b5cf6)":B[i.environment],strokeWidth:2,strokeDasharray:X?"4,4":void 0,opacity:.6},`${i.id}-${h}`)})})}),l.map((i,t)=>{const r=t*k+k/2,o=y[i.id]*w+w/2,h=i.id===A,N=i.id===v,K=i.id===g;return e.jsxs(a.Fragment,{children:[e.jsx("div",{onClick:()=>R(i.id),onMouseEnter:()=>L(i.id),onMouseLeave:()=>L(null),style:{position:"absolute",left:o-F,top:r-F,width:F*2,height:F*2,borderRadius:i.isMerge?4:"50%",background:h||K?"var(--nice-bg-primary, #fff)":B[i.environment],border:`3px solid ${B[i.environment]}`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:600,color:h||K?"var(--nice-text-primary, #000)":"var(--nice-bg-primary, #fff)",zIndex:N?10:1,transform:N?"scale(1.2)":"scale(1)",transition:"transform 0.1s",boxShadow:h?"0 0 0 3px rgba(59, 130, 246, 0.5)":"none"},children:i.isSnapshot?e.jsx(c.oa,{name:"camera",size:12}):i.isMerge?e.jsx(c.oa,{name:"shuffle",size:12}):null}),e.jsxs("div",{style:{position:"absolute",left:w*Y.length+16,top:r-20,right:16,height:40,display:"flex",alignItems:"center",gap:12,padding:"4px 12px",background:h?d.cardBg:"transparent",borderRadius:6,borderLeft:h?`3px solid ${B[i.environment]}`:"none"},children:[e.jsx("span",{style:{fontFamily:"monospace",fontSize:11,color:B[i.environment]},children:i.shortId}),e.jsx("span",{style:{fontSize:12,flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:i.message}),i.tags?.map(E=>e.jsxs("span",{style:{padding:"2px 6px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--nice-color-warning, #f59e0b)",borderRadius:4,fontSize:9},children:[e.jsx(c.oa,{name:"tag",size:12})," ",E]},E)),e.jsx("span",{style:{fontSize:10,color:d.textMuted,whiteSpace:"nowrap"},children:P(i.timestamp)})]})]},i.id)})]})}),j==="timeline"&&e.jsx("div",{style:{flex:1,overflow:"auto",padding:16},children:l.map((i,t)=>{const r=i.id===A,o=l[t-1],h=!o||i.timestamp.toDateString()!==o.timestamp.toDateString();return e.jsxs(a.Fragment,{children:[h&&e.jsx("div",{style:{padding:"8px 0",fontSize:11,fontWeight:600,color:d.textMuted,borderBottom:`1px solid ${d.border}`,marginBottom:8},children:i.timestamp.toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})}),e.jsxs("div",{onClick:()=>R(i.id),style:{display:"flex",gap:12,padding:12,marginBottom:8,background:r?d.cardBg:"transparent",borderRadius:8,cursor:"pointer",border:`1px solid ${r?B[i.environment]:"transparent"}`},children:[e.jsx("div",{style:{width:60,textAlign:"right",fontSize:11,color:d.textMuted},children:i.timestamp.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}),e.jsxs("div",{style:{width:80,padding:"4px 8px",background:B[i.environment]+"30",color:B[i.environment],borderRadius:4,fontSize:10,textAlign:"center",fontWeight:600,textTransform:"uppercase"},children:[_[i.environment]," ",i.environment.substring(0,4)]}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontFamily:"monospace",fontSize:11,color:d.textMuted},children:i.shortId}),i.isSnapshot&&e.jsx("span",{style:{fontSize:12},children:e.jsx(c.oa,{name:"camera",size:12})}),i.isMerge&&e.jsx("span",{style:{fontSize:12},children:e.jsx(c.oa,{name:"shuffle",size:12})}),i.tags?.map(N=>e.jsx("span",{style:{padding:"1px 6px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--nice-color-warning, #f59e0b)",borderRadius:3,fontSize:9},children:N},N))]}),e.jsx("div",{style:{fontSize:13,marginTop:4},children:i.message}),e.jsxs("div",{style:{fontSize:11,color:d.textMuted,marginTop:4},children:["by ",i.author.name," •"," ",e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["+",i.stats.recordsAdded]})," ",e.jsxs("span",{style:{color:"var(--nice-color-warning, #f59e0b)"},children:["~",i.stats.recordsModified]})," ",e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:["-",i.stats.recordsDeleted]})]})]})]})]},i.id)})}),j==="list"&&e.jsx("div",{style:{flex:1,overflow:"auto"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:12},children:[e.jsx("thead",{children:e.jsxs("tr",{style:{background:d.cardBg},children:[e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${d.border}`},children:"ID"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${d.border}`},children:"Environment"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${d.border}`},children:"Message"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${d.border}`},children:"Author"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"left",borderBottom:`1px solid ${d.border}`},children:"Date"}),e.jsx("th",{style:{padding:"10px 12px",textAlign:"right",borderBottom:`1px solid ${d.border}`},children:"Changes"})]})}),e.jsx("tbody",{children:l.map(i=>e.jsxs("tr",{onClick:()=>R(i.id),style:{cursor:"pointer",background:i.id===A?d.cardBg:"transparent"},children:[e.jsxs("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`,fontFamily:"monospace"},children:[i.shortId,i.isSnapshot&&e.jsxs(e.Fragment,{children:[" ",e.jsx(c.oa,{name:"camera",size:12})]}),i.isMerge&&e.jsxs(e.Fragment,{children:[" ",e.jsx(c.oa,{name:"shuffle",size:12})]})]}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`},children:e.jsx("span",{style:{padding:"2px 8px",background:B[i.environment]+"30",color:B[i.environment],borderRadius:4,fontSize:10,fontWeight:600},children:i.environment})}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`},children:i.message}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`,color:d.textMuted},children:i.author.name}),e.jsx("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`,color:d.textMuted},children:i.timestamp.toLocaleString()}),e.jsxs("td",{style:{padding:"10px 12px",borderBottom:`1px solid ${d.border}`,textAlign:"right"},children:[e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["+",i.stats.recordsAdded]})," ",e.jsxs("span",{style:{color:"var(--nice-color-warning, #f59e0b)"},children:["~",i.stats.recordsModified]})," ",e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:["-",i.stats.recordsDeleted]})]})]},i.id))})]})}),x&&e.jsxs("div",{style:{width:320,borderLeft:`1px solid ${d.border}`,overflow:"auto",padding:16},children:[e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[e.jsx("span",{style:{fontSize:24},children:e.jsx(c.oa,{name:x.isSnapshot?"camera":x.isMerge?"shuffle":"edit",size:24})}),e.jsx("span",{style:{padding:"4px 10px",background:B[x.environment]+"30",color:B[x.environment],borderRadius:6,fontSize:11,fontWeight:600,textTransform:"uppercase"},children:x.environment})]}),e.jsx("h4",{style:{margin:"0 0 8px 0",fontSize:14},children:x.message}),x.description&&e.jsx("p",{style:{margin:0,fontSize:12,color:d.textMuted},children:x.description})]}),x.tags&&x.tags.length>0&&e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:d.textMuted,marginBottom:4},children:"Tags"}),e.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:x.tags.map(i=>e.jsxs("span",{style:{padding:"2px 8px",background:"var(--nice-warning-tint-20, #f59e0b30)",color:"var(--nice-color-warning, #f59e0b)",borderRadius:4,fontSize:11},children:[e.jsx(c.oa,{name:"tag",size:12})," ",i]},i))})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:d.textMuted,marginBottom:8},children:"Changes"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:8},children:[e.jsxs("div",{style:{padding:10,background:d.cardBg,borderRadius:6,textAlign:"center"},children:[e.jsx("div",{style:{fontSize:16,fontWeight:600},children:x.stats.tables}),e.jsx("div",{style:{fontSize:10,color:d.textMuted},children:"Tables"})]}),e.jsxs("div",{style:{padding:10,background:"var(--nice-success-tint-12, #22c55e20)",borderRadius:6,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:16,fontWeight:600,color:"var(--nice-color-success, #22c55e)"},children:["+",x.stats.recordsAdded]}),e.jsx("div",{style:{fontSize:10,color:d.textMuted},children:"Added"})]}),e.jsxs("div",{style:{padding:10,background:"var(--nice-warning-tint-15, #f59e0b20)",borderRadius:6,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:16,fontWeight:600,color:"var(--nice-color-warning, #f59e0b)"},children:["~",x.stats.recordsModified]}),e.jsx("div",{style:{fontSize:10,color:d.textMuted},children:"Modified"})]}),e.jsxs("div",{style:{padding:10,background:"var(--nice-danger-tint-15, #ef444420)",borderRadius:6,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:16,fontWeight:600,color:"var(--nice-color-error, #ef4444)"},children:["-",x.stats.recordsDeleted]}),e.jsx("div",{style:{fontSize:10,color:d.textMuted},children:"Deleted"})]})]})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("div",{style:{fontSize:11,color:d.textMuted,marginBottom:8},children:"Details"}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"80px 1fr",gap:"6px 12px",fontSize:12},children:[e.jsx("span",{style:{color:d.textMuted},children:"ID"}),e.jsx("span",{style:{fontFamily:"monospace"},children:x.shortId}),e.jsx("span",{style:{color:d.textMuted},children:"Author"}),e.jsx("span",{children:x.author.name}),e.jsx("span",{style:{color:d.textMuted},children:"Date"}),e.jsx("span",{children:x.timestamp.toLocaleString()}),e.jsx("span",{style:{color:d.textMuted},children:"Type"}),e.jsx("span",{children:x.isSnapshot?"Snapshot":x.isMerge?"Merge":"Change"}),x.parents.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:d.textMuted},children:"Parents"}),e.jsx("span",{style:{fontFamily:"monospace"},children:x.parents.map(i=>f.find(t=>t.id===i)?.shortId??i).join(", ")})]})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[e.jsxs("button",{onClick:()=>O(x.id),style:{padding:"8px 12px",borderRadius:6,border:`1px solid ${d.border}`,background:"transparent",color:d.text,cursor:"pointer",fontSize:12},children:[e.jsx(c.oa,{name:"search",size:14})," Compare with..."]}),x.isSnapshot&&e.jsxs("button",{onClick:()=>H?.(x.id),style:{padding:"8px 12px",borderRadius:6,border:"none",background:"var(--nice-color-warning, #f59e0b)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:12,fontWeight:500},children:[e.jsx(c.oa,{name:"reply",size:14})," Restore this snapshot"]})]})]})]})]})},ve=Object.freeze(Object.defineProperty({__proto__:null,NiceDataBranchGraph:de},Symbol.toStringTag,{value:"Module"})),je=[{target:".nice-data-merge-builder",titleKey:"tutorial.dataMergeBuilder.intro.title",title:"Data merge",contentKey:"tutorial.dataMergeBuilder.intro.content",content:"Walk through the steps: choose source and target branches, preview changes, resolve conflicts, set options, then confirm the merge.",placement:"auto"}],Se=[{id:"prod-1",shortId:"prod-1",name:"production",displayName:"Production",isDefault:!0,isProtected:!0,createdBy:{id:"system",name:"System"},createdAt:{date:new Date,relative:"1 year ago"},status:"active",type:"data",environment:"production",tenant:"tenant-1",size:{records:265770,bytes:2921e5}},{id:"uat-1",shortId:"uat-1",name:"uat",displayName:"UAT",isDefault:!1,isProtected:!0,createdBy:{id:"admin",name:"Admin"},createdAt:{date:new Date,relative:"3 months ago"},upstream:"prod-1",status:"active",type:"data",environment:"uat",tenant:"tenant-1",size:{records:265e3,bytes:29e7}},{id:"dev-1",shortId:"dev-1",name:"development",displayName:"Development",isDefault:!1,isProtected:!1,createdBy:{id:"dev1",name:"Developer"},createdAt:{date:new Date,relative:"1 month ago"},upstream:"uat-1",status:"active",type:"data",environment:"development",tenant:"tenant-1",size:{records:67120,bytes:1591e5}}],te={sourceId:"dev-1",targetId:"uat-1",tables:[{table:"customers",displayName:"Customers",module:"CRM",inserts:15,updates:42,deletes:3,conflicts:2,selected:!0},{table:"products",displayName:"Products",module:"Inventory",inserts:350,updates:25,deletes:0,conflicts:0,selected:!0},{table:"config",displayName:"Configuration",module:"System",inserts:0,updates:3,deletes:0,conflicts:1,selected:!0},{table:"orders",displayName:"Orders",module:"Sales",inserts:0,updates:0,deletes:0,conflicts:0,selected:!1}],conflicts:[{id:"conflict-1",table:"customers",recordId:"CUST-042",field:"email",sourceValue:"new@email.com",targetValue:"different@email.com",type:"concurrent-update"},{id:"conflict-2",table:"customers",recordId:"CUST-099",field:"status",sourceValue:"deleted",targetValue:"active",type:"delete-update"},{id:"conflict-3",table:"config",recordId:"CFG-TAX-RATE",field:"value",sourceValue:.21,targetValue:.22,type:"concurrent-update"}],estimatedDuration:45,requiresApproval:!0},ae=({branches:p=Se,sourceBranchId:f,targetBranchId:M,onPreview:S,onMerge:z,onCancel:I,tutorial:U,className:W,style:H,"data-testid":G})=>{const[V,m]=a.useState("select"),[b,q]=a.useState(f??""),[C,T]=a.useState(M??""),[g,O]=a.useState(null),[v,L]=a.useState([]),[j,A]=a.useState("keep-source"),[$,l]=a.useState(!0),[y,x]=a.useState(!1),[R,P]=a.useState(null),[d,w]=a.useState({}),[F,k]=a.useState(!1),i=a.useMemo(()=>p.find(n=>n.id===b),[p,b]),t=a.useMemo(()=>p.find(n=>n.id===C),[p,C]),r=a.useMemo(()=>i?p.filter(n=>n.id!==b&&(ie(i.environment,n.environment)||n.environment==="development"||n.environment==="testing")):p,[p,b,i]),o=a.useMemo(()=>g?g.tables.filter(u=>v.includes(u.table)).reduce((u,D)=>({inserts:u.inserts+D.inserts,updates:u.updates+D.updates,deletes:u.deletes+D.deletes,conflicts:u.conflicts+D.conflicts}),{inserts:0,updates:0,deletes:0,conflicts:0}):{inserts:0,updates:0,deletes:0,conflicts:0},[g,v]),h=a.useMemo(()=>g?g.conflicts.filter(n=>!d[n.id]):[],[g,d]),N=a.useCallback(async()=>{k(!0),S?.(b,C),await new Promise(n=>setTimeout(n,1e3)),O(te),L(te.tables.filter(n=>n.selected).map(n=>n.table)),k(!1),m("preview")},[b,C,S]),K=a.useCallback(()=>{const n={sourceId:b,targetId:C,strategy:j,tables:v,createBackup:$,dryRun:y,scheduledAt:R??void 0,conflictResolutions:Object.entries(d).reduce((u,[D,Q])=>({...u,[D]:{conflictId:D,strategy:Q}}),{})};z?.(n)},[b,C,j,v,$,y,R,d,z]),E=(n,u)=>{w(D=>({...D,[n]:u}))},X=n=>{if(!g)return;const u={};g.conflicts.forEach(D=>{u[D.id]=n}),w(u)},s={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)"};return e.jsxs("div",{className:`nice-data-merge-builder ${W||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:s.bg,color:s.text,fontFamily:"system-ui, sans-serif",...H},"data-testid":G,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${s.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18},children:[e.jsx(c.oa,{name:"shuffle",size:16})," Data Merge"]}),e.jsx("div",{style:{display:"flex",gap:8,marginLeft:"auto"},children:["select","preview","conflicts","options","confirm"].map((n,u)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("div",{style:{width:24,height:24,borderRadius:"50%",background:V===n?"var(--nice-color-primary, #3b82f6)":["select","preview","conflicts","options","confirm"].indexOf(V)>u?"var(--nice-color-success, #22c55e)":s.cardBg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:600},children:["select","preview","conflicts","options","confirm"].indexOf(V)>u?e.jsx(c.oa,{name:"check",size:14}):u+1}),u<4&&e.jsx("div",{style:{width:24,height:2,background:["select","preview","conflicts","options","confirm"].indexOf(V)>u?"var(--nice-color-success, #22c55e)":s.border}})]},n))}),e.jsx(c.Ql,{steps:c.Yl(U,je)})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[V==="select"&&e.jsxs("div",{style:{maxWidth:600,margin:"0 auto"},children:[e.jsx("h4",{style:{marginTop:0},children:"Select Environments"}),e.jsx("p",{style:{color:s.textMuted,fontSize:13},children:"Choose the source and target environments for the merge operation."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto 1fr",gap:16,alignItems:"center",marginTop:24},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:s.textMuted},children:"Source Environment"}),e.jsxs("select",{value:b,onChange:n=>{q(n.target.value),T("")},style:{width:"100%",padding:12,borderRadius:8,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:14},children:[e.jsx("option",{value:"",children:"Select source..."}),p.map(n=>e.jsxs("option",{value:n.id,children:[_[n.environment]," ",n.displayName]},n.id))]}),i&&e.jsxs("div",{style:{marginTop:12,padding:12,background:B[i.environment]+"20",borderRadius:8,border:`1px solid ${B[i.environment]}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:20},children:_[i.environment]}),e.jsx("span",{style:{fontWeight:600},children:i.displayName})]}),e.jsxs("div",{style:{fontSize:11,color:s.textMuted,marginTop:4},children:[i.size?.records.toLocaleString()," records"]})]})]}),e.jsx("div",{style:{fontSize:24,color:s.textMuted},children:"→"}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:s.textMuted},children:"Target Environment"}),e.jsxs("select",{value:C,onChange:n=>T(n.target.value),disabled:!b,style:{width:"100%",padding:12,borderRadius:8,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:14,opacity:b?1:.5},children:[e.jsx("option",{value:"",children:"Select target..."}),r.map(n=>e.jsxs("option",{value:n.id,children:[_[n.environment]," ",n.displayName]},n.id))]}),t&&e.jsxs("div",{style:{marginTop:12,padding:12,background:B[t.environment]+"20",borderRadius:8,border:`1px solid ${B[t.environment]}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontSize:20},children:_[t.environment]}),e.jsx("span",{style:{fontWeight:600},children:t.displayName}),t.isProtected&&e.jsx("span",{children:e.jsx(c.oa,{name:"lock",size:16})})]}),e.jsxs("div",{style:{fontSize:11,color:s.textMuted,marginTop:4},children:[t.size?.records.toLocaleString()," records"]})]})]})]}),e.jsxs("div",{style:{marginTop:32,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:I,style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:N,disabled:!b||!C||F,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-bg-primary, #fff)",cursor:b&&C&&!F?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:b&&C&&!F?1:.5},children:F?e.jsxs(e.Fragment,{children:[e.jsx(c.oa,{name:"clock",size:14})," Loading..."]}):"Preview Changes →"})]})]}),V==="preview"&&g&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:24},children:[e.jsx("button",{onClick:()=>m("select"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsx("h4",{style:{margin:0},children:"Preview Changes"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12,marginBottom:24},children:[e.jsxs("div",{style:{padding:16,background:"var(--nice-success-tint-12, #22c55e20)",borderRadius:8,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:24,fontWeight:600,color:"var(--nice-color-success, #22c55e)"},children:["+",o.inserts]}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:"Inserts"})]}),e.jsxs("div",{style:{padding:16,background:"var(--nice-warning-tint-15, #f59e0b20)",borderRadius:8,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:24,fontWeight:600,color:"var(--nice-color-warning, #f59e0b)"},children:["~",o.updates]}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:"Updates"})]}),e.jsxs("div",{style:{padding:16,background:"var(--nice-danger-tint-15, #ef444420)",borderRadius:8,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:24,fontWeight:600,color:"var(--nice-color-error, #ef4444)"},children:["-",o.deletes]}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:"Deletes"})]}),e.jsxs("div",{style:{padding:16,background:"var(--nice-accent-tint-12, #8b5cf620)",borderRadius:8,textAlign:"center"},children:[e.jsxs("div",{style:{fontSize:24,fontWeight:600,color:"var(--nice-color-accent, #8b5cf6)"},children:[e.jsx(c.oa,{name:"warning",size:14})," ",o.conflicts]}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:"Conflicts"})]})]}),e.jsxs("div",{style:{marginBottom:24},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},children:[e.jsxs("span",{style:{fontSize:12,color:s.textMuted},children:["Select tables to merge (",v.length," / ",g.tables.length,")"]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{onClick:()=>L(g.tables.map(n=>n.table)),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:11},children:"Select All"}),e.jsx("button",{onClick:()=>L([]),style:{padding:"4px 8px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:11},children:"Clear"})]})]}),e.jsx("div",{style:{border:`1px solid ${s.border}`,borderRadius:8,overflow:"hidden"},children:g.tables.map(n=>e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px",borderBottom:`1px solid ${s.border}`,cursor:"pointer",background:v.includes(n.table)?s.cardBg:"transparent"},children:[e.jsx("input",{type:"checkbox",checked:v.includes(n.table),onChange:u=>{u.target.checked?L(D=>[...D,n.table]):L(D=>D.filter(Q=>Q!==n.table))}}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:n.displayName}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:n.module})]}),e.jsxs("div",{style:{display:"flex",gap:12,fontSize:12},children:[n.inserts>0&&e.jsxs("span",{style:{color:"var(--nice-color-success, #22c55e)"},children:["+",n.inserts]}),n.updates>0&&e.jsxs("span",{style:{color:"var(--nice-color-warning, #f59e0b)"},children:["~",n.updates]}),n.deletes>0&&e.jsxs("span",{style:{color:"var(--nice-color-error, #ef4444)"},children:["-",n.deletes]}),n.conflicts>0&&e.jsxs("span",{style:{color:"var(--nice-color-accent, #8b5cf6)"},children:[e.jsx(c.oa,{name:"warning",size:14})," ",n.conflicts]})]})]},n.table))})]}),e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>m("select"),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"← Back"}),e.jsx("button",{onClick:()=>m(o.conflicts>0?"conflicts":"options"),disabled:v.length===0,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-bg-primary, #fff)",cursor:v.length>0?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:v.length>0?1:.5},children:o.conflicts>0?"Resolve Conflicts →":"Configure Merge →"})]})]}),V==="conflicts"&&g&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:24},children:[e.jsx("button",{onClick:()=>m("preview"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsxs("h4",{style:{margin:0},children:["Resolve Conflicts (",h.length," remaining)"]})]}),e.jsxs("div",{style:{padding:16,background:s.cardBg,borderRadius:8,marginBottom:24,display:"flex",alignItems:"center",gap:12},children:[e.jsx("span",{style:{fontSize:13},children:"Apply to all conflicts:"}),e.jsx("button",{onClick:()=>X("keep-source"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:"Keep Source"}),e.jsx("button",{onClick:()=>X("keep-target"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:"Keep Target"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:g.conflicts.map(n=>{const u=!!d[n.id];return e.jsxs("div",{style:{padding:16,background:s.cardBg,borderRadius:8,border:`1px solid ${u?"var(--nice-color-success, #22c55e)":"var(--nice-color-accent, #8b5cf6)"}`},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:12},children:[e.jsx("span",{style:{fontSize:16},children:e.jsx(c.oa,{name:u?"check":"warning",size:16})}),e.jsxs("div",{children:[e.jsxs("div",{style:{fontWeight:500},children:[n.table,".",n.field]}),e.jsxs("div",{style:{fontSize:11,color:s.textMuted},children:["Record: ",n.recordId," • ",n.type.replace("-"," ")]})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[e.jsxs("div",{style:{padding:12,background:d[n.id]==="keep-source"?"var(--nice-success-tint-12, #22c55e20)":s.bg,borderRadius:6,border:`1px solid ${d[n.id]==="keep-source"?"var(--nice-color-success, #22c55e)":s.border}`,cursor:"pointer"},onClick:()=>E(n.id,"keep-source"),children:[e.jsxs("div",{style:{fontSize:10,color:s.textMuted,marginBottom:4},children:["Source (",i?.displayName,")"]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:13},children:String(n.sourceValue)})]}),e.jsxs("div",{style:{padding:12,background:d[n.id]==="keep-target"?"var(--nice-success-tint-12, #22c55e20)":s.bg,borderRadius:6,border:`1px solid ${d[n.id]==="keep-target"?"var(--nice-color-success, #22c55e)":s.border}`,cursor:"pointer"},onClick:()=>E(n.id,"keep-target"),children:[e.jsxs("div",{style:{fontSize:10,color:s.textMuted,marginBottom:4},children:["Target (",t?.displayName,")"]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:13},children:String(n.targetValue)})]})]})]},n.id)})}),e.jsxs("div",{style:{marginTop:24,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>m("preview"),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"← Back"}),e.jsx("button",{onClick:()=>m("options"),disabled:h.length>0,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-bg-primary, #fff)",cursor:h.length===0?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:h.length===0?1:.5},children:"Configure Merge →"})]})]}),V==="options"&&e.jsxs("div",{style:{maxWidth:500,margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:24},children:[e.jsx("button",{onClick:()=>m(o.conflicts>0?"conflicts":"preview"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsx("h4",{style:{margin:0},children:"Merge Options"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:$,onChange:n=>l(n.target.checked)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13},children:"Create backup before merge"}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:"Recommended for protected environments"})]})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:y,onChange:n=>x(n.target.checked)}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13},children:"Dry run (preview only)"}),e.jsx("div",{style:{fontSize:11,color:s.textMuted},children:"Simulate merge without applying changes"})]})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:s.textMuted},children:"Schedule merge (optional)"}),e.jsx("input",{type:"datetime-local",value:R?.toISOString().slice(0,16)??"",onChange:n=>P(n.target.value?new Date(n.target.value):null),style:{padding:10,borderRadius:6,border:`1px solid ${s.border}`,background:s.cardBg,color:s.text,fontSize:13}})]})]}),e.jsxs("div",{style:{marginTop:32,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>m(o.conflicts>0?"conflicts":"preview"),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"← Back"}),e.jsx("button",{onClick:()=>m("confirm"),style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Review & Confirm →"})]})]}),V==="confirm"&&g&&e.jsxs("div",{style:{maxWidth:500,margin:"0 auto"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:24},children:[e.jsx("button",{onClick:()=>m("options"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:12},children:"← Back"}),e.jsx("h4",{style:{margin:0},children:"Confirm Merge"})]}),e.jsxs("div",{style:{padding:20,background:s.cardBg,borderRadius:8,marginBottom:24},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:16},children:[e.jsxs("div",{style:{padding:"8px 12px",background:B[i?.environment??"development"]+"30",borderRadius:6},children:[_[i?.environment??"development"]," ",i?.displayName]}),e.jsx("span",{children:"→"}),e.jsxs("div",{style:{padding:"8px 12px",background:B[t?.environment??"production"]+"30",borderRadius:6},children:[_[t?.environment??"production"]," ",t?.displayName]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px 16px",fontSize:13},children:[e.jsx("span",{style:{color:s.textMuted},children:"Tables"}),e.jsx("span",{children:v.length}),e.jsx("span",{style:{color:s.textMuted},children:"Records affected"}),e.jsx("span",{children:o.inserts+o.updates+o.deletes}),e.jsx("span",{style:{color:s.textMuted},children:"Backup"}),e.jsx("span",{children:$?"Yes":"No"}),e.jsx("span",{style:{color:s.textMuted},children:"Mode"}),e.jsx("span",{children:y?"Dry run":"Apply changes"}),R&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:s.textMuted},children:"Scheduled"}),e.jsx("span",{children:R.toLocaleString()})]})]})]}),t?.isProtected&&e.jsxs("div",{style:{padding:12,background:"var(--nice-warning-tint-15, #f59e0b20)",border:"1px solid var(--nice-warning, #f59e0b)",borderRadius:6,marginBottom:24,fontSize:12},children:[e.jsx(c.oa,{name:"warning",size:14})," Target environment is protected and may require approval."]}),e.jsxs("div",{style:{display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:I,style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${s.border}`,background:"transparent",color:s.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:K,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:y?e.jsxs(e.Fragment,{children:[e.jsx(c.oa,{name:"search",size:14})," Run Dry Merge"]}):R?e.jsxs(e.Fragment,{children:[e.jsx(c.oa,{name:"calendar",size:14})," Schedule Merge"]}):e.jsxs(e.Fragment,{children:[e.jsx(c.oa,{name:"shuffle",size:14})," Execute Merge"]})})]})]})]})]})},ke=Object.freeze(Object.defineProperty({__proto__:null,NiceDataMergeBuilder:ae},Symbol.toStringTag,{value:"Module"})),ze=[{id:"conflict-1",table:"customers",tableName:"Customers",recordId:"CUST-042",recordLabel:"Acme Corp",type:"concurrent-update",severity:"high",fields:[{field:"email",fieldLabel:"Email Address",dataType:"string",sourceValue:"new.contact@acme.com",targetValue:"old.contact@acme.com",baseValue:"original@acme.com"},{field:"phone",fieldLabel:"Phone Number",dataType:"string",sourceValue:"+1-555-NEW-0000",targetValue:"+1-555-OLD-0000",baseValue:"+1-555-000-0000"},{field:"credit_limit",fieldLabel:"Credit Limit",dataType:"number",sourceValue:75e3,targetValue:5e4,baseValue:25e3}],metadata:{sourceModifiedAt:new Date("2024-01-15T10:30:00"),sourceModifiedBy:"john.dev",targetModifiedAt:new Date("2024-01-15T14:45:00"),targetModifiedBy:"mary.sales"},suggestion:"keep-target",suggestionReason:"Target was modified more recently"},{id:"conflict-2",table:"products",tableName:"Products",recordId:"PRD-1337",recordLabel:"Widget Pro Max",type:"delete-update",severity:"critical",fields:[{field:"_deleted",fieldLabel:"Record Status",dataType:"boolean",sourceValue:!0,targetValue:!1},{field:"name",fieldLabel:"Product Name",dataType:"string",sourceValue:"[DELETED]",targetValue:"Widget Pro Max v2"}],suggestion:"keep-target",suggestionReason:"Record was updated in target, deletion may be accidental"},{id:"conflict-3",table:"config",tableName:"Configuration",recordId:"CFG-TAX-RATE",recordLabel:"Tax Rate Settings",type:"concurrent-update",severity:"medium",fields:[{field:"value",fieldLabel:"Value",dataType:"number",sourceValue:.21,targetValue:.22,baseValue:.2},{field:"effective_date",fieldLabel:"Effective Date",dataType:"date",sourceValue:"2024-02-01",targetValue:"2024-03-01"}],suggestion:"keep-source",suggestionReason:"Source has the newer effective date"}],J={"concurrent-update":{label:"Concurrent Update",icon:"zap",description:"Record was modified in both environments"},"delete-update":{label:"Delete vs Update",icon:"trash",description:"Record deleted in source but updated in target"},"update-delete":{label:"Update vs Delete",icon:"edit",description:"Record updated in source but deleted in target"},"constraint-violation":{label:"Constraint Violation",icon:"slash",description:"Change violates database constraints"},"unique-key-conflict":{label:"Unique Key Conflict",icon:"lock",description:"Duplicate unique key detected"},"foreign-key-missing":{label:"Missing FK Reference",icon:"link",description:"Referenced record does not exist"},"type-mismatch":{label:"Type Mismatch",icon:"warning",description:"Data type incompatibility"},"schema-change":{label:"Schema Change",icon:"clipboard",description:"Schema differs between environments"}},Z={low:"var(--nice-color-success, #22c55e)",medium:"var(--nice-color-warning, #f59e0b)",high:"var(--nice-warning, #f97316)",critical:"var(--nice-color-error, #ef4444)"},le=({conflicts:p=ze,sourceEnvironment:f="development",targetEnvironment:M="uat",showSuggestions:S=!0,allowCustomValues:z=!0,onResolve:I,onSkip:U,onCancel:W,className:H,style:G,"data-testid":V})=>{const[m,b]=a.useState(0),[q,C]=a.useState({}),[T,g]=a.useState({}),[O,v]=a.useState(null),[L,j]=a.useState(""),[A,$]=a.useState("single"),l=p[m],y=a.useMemo(()=>Object.keys(q).length,[q]),x=a.useMemo(()=>{if(!l)return!1;const r=T[l.id]||{};return l.fields.every(o=>r[o.field]?.resolution)},[l,T]),R=a.useCallback(r=>{if(T[r.id])return;const o={};r.fields.forEach(h=>{o[h.field]={resolution:"source",value:h.sourceValue}}),g(h=>({...h,[r.id]:o}))},[T]);a.useEffect(()=>{l&&R(l)},[l,R]);const P=(r,o,h)=>{if(!l)return;const N=l.fields.find(E=>E.field===r);if(!N)return;const K=o==="source"?N.sourceValue:o==="target"?N.targetValue:h;g(E=>({...E,[l.id]:{...E[l.id],[r]:{resolution:o,value:K}}}))},d=r=>{if(!l)return;const o={};l.fields.forEach(h=>{o[h.field]={resolution:r,value:r==="source"?h.sourceValue:h.targetValue}}),g(h=>({...h,[l.id]:o}))},w=()=>{if(!l||!x)return;const r={conflictId:l.id,strategy:"manual",fieldResolutions:T[l.id]};C(o=>({...o,[l.id]:r})),m<p.length-1&&b(m+1)},F=()=>{l&&(U?.(l.id),m<p.length-1&&b(m+1))},k=()=>{const r=Object.values(q);I?.(r)},i=(r,o)=>r===null?"null":r===void 0?"undefined":o==="date"?new Date(r).toLocaleDateString():o==="number"?Number(r).toLocaleString():typeof r=="boolean"?r?"true":"false":String(r),t={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)",source:B[f],target:B[M]};return p.length===0?e.jsxs("div",{className:`nice-data-conflict-resolver ${H||""}`,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",padding:40,...G},"data-testid":V,children:[e.jsx("div",{style:{fontSize:48,marginBottom:16},children:e.jsx(c.oa,{name:"check",size:48})}),e.jsx("h3",{style:{margin:0},children:"No Conflicts"}),e.jsx("p",{style:{color:t.textMuted,marginTop:8},children:"All data is compatible for merge."})]}):e.jsxs("div",{className:`nice-data-conflict-resolver ${H||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:t.bg,color:t.text,fontFamily:"system-ui, sans-serif",...G},"data-testid":V,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18},children:[e.jsx(c.oa,{name:"warning",size:16})," Resolve Conflicts"]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:12},children:[e.jsxs("div",{style:{fontSize:13,color:t.textMuted},children:["Resolved: ",e.jsx("strong",{style:{color:t.text},children:y})," /"," ",p.length]}),e.jsx("div",{style:{width:100,height:6,background:t.cardBg,borderRadius:3,overflow:"hidden"},children:e.jsx("div",{style:{width:`${y/p.length*100}%`,height:"100%",background:"var(--nice-color-success, #22c55e)",transition:"width 0.2s"}})})]}),e.jsxs("div",{style:{display:"flex",border:`1px solid ${t.border}`,borderRadius:6,overflow:"hidden"},children:[e.jsx("button",{onClick:()=>$("single"),style:{padding:"6px 12px",border:"none",background:A==="single"?t.cardBg:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"Single"}),e.jsx("button",{onClick:()=>$("list"),style:{padding:"6px 12px",border:"none",borderLeft:`1px solid ${t.border}`,background:A==="list"?t.cardBg:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"List"})]})]}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[A==="single"&&l&&e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,marginBottom:20},children:[e.jsx("button",{onClick:()=>b(Math.max(0,m-1)),disabled:m===0,style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:m>0?"pointer":"not-allowed",opacity:m>0?1:.5,fontSize:12},children:"← Previous"}),e.jsxs("span",{style:{fontSize:13,color:t.textMuted},children:["Conflict ",m+1," of ",p.length]}),e.jsx("button",{onClick:()=>b(Math.min(p.length-1,m+1)),disabled:m===p.length-1,style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:m<p.length-1?"pointer":"not-allowed",opacity:m<p.length-1?1:.5,fontSize:12},children:"Next →"}),q[l.id]&&e.jsxs("span",{style:{marginLeft:"auto",padding:"4px 8px",background:"#22c55e30",color:"var(--nice-color-success, #22c55e)",borderRadius:4,fontSize:11},children:[e.jsx(c.oa,{name:"check",size:14})," Resolved"]})]}),e.jsxs("div",{style:{padding:16,background:t.cardBg,borderRadius:8,marginBottom:20},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("span",{style:{fontSize:24},children:e.jsx(c.oa,{name:J[l.type].icon,size:24})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:600,fontSize:15},children:[l.tableName,":"," ",l.recordLabel??l.recordId]}),e.jsxs("div",{style:{fontSize:12,color:t.textMuted},children:[J[l.type].label," —"," ",J[l.type].description]})]}),e.jsx("div",{style:{padding:"4px 8px",background:Z[l.severity]+"30",color:Z[l.severity],borderRadius:4,fontSize:10,fontWeight:600,textTransform:"uppercase"},children:l.severity})]}),l.metadata&&e.jsxs("div",{style:{display:"flex",gap:24,marginTop:12,paddingTop:12,borderTop:`1px solid ${t.border}`,fontSize:11,color:t.textMuted},children:[l.metadata.sourceModifiedAt&&e.jsxs("span",{children:["Source modified: ",l.metadata.sourceModifiedAt.toLocaleString()," ","by ",l.metadata.sourceModifiedBy]}),l.metadata.targetModifiedAt&&e.jsxs("span",{children:["Target modified: ",l.metadata.targetModifiedAt.toLocaleString()," ","by ",l.metadata.targetModifiedBy]})]}),S&&l.suggestion&&e.jsxs("div",{style:{marginTop:12,padding:12,background:"var(--nice-primary-tint-12, #3b82f620)",border:"1px solid var(--nice-primary, #3b82f6)",borderRadius:6,fontSize:12},children:[e.jsxs("strong",{children:[e.jsx(c.oa,{name:"lightbulb",size:14})," Suggestion:"]})," ",l.suggestionReason,e.jsx("button",{onClick:()=>d(l.suggestion==="keep-source"?"source":"target"),style:{marginLeft:12,padding:"4px 8px",borderRadius:4,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:11},children:"Apply"})]})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginBottom:16},children:[e.jsx("span",{style:{fontSize:12,color:t.textMuted,lineHeight:"28px"},children:"Apply to all fields:"}),e.jsxs("button",{onClick:()=>d("source"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.source}`,background:`${t.source}20`,color:t.text,cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",gap:6},children:[_[f]," Keep Source"]}),e.jsxs("button",{onClick:()=>d("target"),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.target}`,background:`${t.target}20`,color:t.text,cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",gap:6},children:[_[M]," Keep Target"]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:l.fields.map(r=>{const o=T[l.id]?.[r.field],h=O===`${l.id}-${r.field}`;return e.jsxs("div",{style:{background:t.cardBg,borderRadius:8,overflow:"hidden",border:`1px solid ${o?.resolution?"var(--nice-color-success, #22c55e)":t.border}`},children:[e.jsxs("div",{style:{padding:"10px 16px",background:o?.resolution?"var(--nice-success-tint-10, #22c55e10)":"transparent",borderBottom:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{width:16,height:16,display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,color:o?.resolution?"var(--nice-color-success, #22c55e)":t.textMuted},children:e.jsx(c.oa,{name:o?.resolution?"check":"circle",size:14})}),e.jsx("span",{style:{fontWeight:500},children:r.fieldLabel}),e.jsxs("span",{style:{fontSize:11,color:t.textMuted},children:["(",r.field,")"]}),e.jsx("span",{style:{marginLeft:"auto",fontSize:10,padding:"2px 6px",background:t.bg,borderRadius:4,color:t.textMuted},children:r.dataType})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:1,background:t.border},children:[e.jsxs("div",{onClick:()=>P(r.field,"source"),style:{padding:16,background:o?.resolution==="source"?`${t.source}20`:t.bg,cursor:"pointer",border:o?.resolution==="source"?`2px solid ${t.source}`:"2px solid transparent"},children:[e.jsxs("div",{style:{fontSize:10,color:t.source,marginBottom:8,display:"flex",alignItems:"center",gap:4},children:[_[f]," Source",o?.resolution==="source"&&e.jsx("span",{style:{marginLeft:4},children:e.jsx(c.oa,{name:"check",size:14})})]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:14,wordBreak:"break-all"},children:i(r.sourceValue,r.dataType)})]}),e.jsxs("div",{onClick:()=>P(r.field,"target"),style:{padding:16,background:o?.resolution==="target"?`${t.target}20`:t.bg,cursor:"pointer",border:o?.resolution==="target"?`2px solid ${t.target}`:"2px solid transparent"},children:[e.jsxs("div",{style:{fontSize:10,color:t.target,marginBottom:8,display:"flex",alignItems:"center",gap:4},children:[_[M]," Target",o?.resolution==="target"&&e.jsx("span",{style:{marginLeft:4},children:e.jsx(c.oa,{name:"check",size:14})})]}),e.jsx("div",{style:{fontFamily:"monospace",fontSize:14,wordBreak:"break-all"},children:i(r.targetValue,r.dataType)})]})]}),z&&e.jsxs("div",{style:{padding:12,background:o?.resolution==="custom"?"var(--nice-accent-tint-12, #8b5cf620)":t.bg,borderTop:`1px solid ${t.border}`,display:"flex",alignItems:"center",gap:12},children:[e.jsx("span",{style:{fontSize:12,color:t.textMuted},children:"Custom value:"}),h?e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"text",value:L,onChange:N=>j(N.target.value),style:{flex:1,padding:8,borderRadius:4,border:`1px solid ${t.border}`,background:t.cardBg,color:t.text,fontFamily:"monospace",fontSize:13},autoFocus:!0}),e.jsx("button",{onClick:()=>{P(r.field,"custom",L),v(null)},style:{padding:"6px 12px",borderRadius:4,border:"none",background:"var(--nice-color-accent, #8b5cf6)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:12},children:"Apply"}),e.jsx("button",{onClick:()=>v(null),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:12},children:"Cancel"})]}):e.jsx("button",{onClick:()=>{j(o?.resolution==="custom"?String(o.value):String(r.sourceValue)),v(`${l.id}-${r.field}`)},style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${t.border}`,background:o?.resolution==="custom"?"var(--nice-accent-tint-12, #8b5cf620)":"transparent",color:t.text,cursor:"pointer",fontSize:12},children:o?.resolution==="custom"?`Using: ${i(o.value,r.dataType)}`:"Enter custom..."})]})]},r.field)})}),e.jsxs("div",{style:{marginTop:24,display:"flex",gap:12,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:F,style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:13},children:"Skip"}),e.jsx("button",{onClick:w,disabled:!x,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-success, #22c55e)",color:"var(--nice-bg-primary, #fff)",cursor:x?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:x?1:.5},children:m<p.length-1?"Confirm & Next →":"Confirm"})]})]}),A==="list"&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:p.map((r,o)=>{const h=!!q[r.id];return e.jsxs("div",{onClick:()=>{b(o),$("single")},style:{padding:16,background:t.cardBg,borderRadius:8,cursor:"pointer",border:`1px solid ${h?"var(--nice-color-success, #22c55e)":t.border}`,display:"flex",alignItems:"center",gap:12},children:[e.jsx("span",{style:{fontSize:20},children:e.jsx(c.oa,{name:h?"check":J[r.type].icon,size:14})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{fontWeight:500},children:[r.tableName,": ",r.recordLabel??r.recordId]}),e.jsxs("div",{style:{fontSize:11,color:t.textMuted},children:[r.fields.length," fields • ",J[r.type].label]})]}),e.jsx("div",{style:{padding:"4px 8px",background:Z[r.severity]+"30",color:Z[r.severity],borderRadius:4,fontSize:10,fontWeight:600,textTransform:"uppercase"},children:r.severity})]},r.id)})})]}),e.jsxs("div",{style:{padding:"16px 20px",borderTop:`1px solid ${t.border}`,display:"flex",justifyContent:"space-between"},children:[e.jsx("button",{onClick:W,style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${t.border}`,background:"transparent",color:t.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsxs("button",{onClick:k,disabled:y===0,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-bg-primary, #fff)",cursor:y>0?"pointer":"not-allowed",fontSize:13,fontWeight:500,opacity:y>0?1:.5},children:["Finish (",y," resolved)"]})]})]})},Ce=Object.freeze(Object.defineProperty({__proto__:null,NiceDataConflictResolver:le},Symbol.toStringTag,{value:"Module"})),we=[{id:"snap-001",name:"Q1 Release Backup",description:"Backup before Q1 2024 release deployment",environment:"production",createdAt:new Date("2024-01-15T06:00:00"),createdBy:{id:"admin",name:"Admin"},size:{records:265770,bytes:2921e5},type:"manual",status:"ready",tags:["release","q1-2024"]},{id:"snap-002",name:"Daily Backup 2024-01-20",environment:"production",createdAt:new Date("2024-01-20T02:00:00"),createdBy:{id:"system",name:"System"},size:{records:267e3,bytes:2942e5},type:"scheduled",status:"ready",expiresAt:new Date("2024-02-20T02:00:00")},{id:"snap-003",name:"Pre-Merge: UAT to Prod",description:"Automatic backup before merge operation",environment:"production",createdAt:new Date("2024-01-22T10:30:00"),createdBy:{id:"system",name:"System"},size:{records:267500,bytes:295e6},type:"pre-merge",status:"locked",tags:["merge","automatic"]},{id:"snap-004",name:"Selected Tables Only",description:"Partial snapshot of CRM module",environment:"production",createdAt:new Date("2024-01-23T14:00:00"),createdBy:{id:"dev1",name:"John"},size:{records:15e3,bytes:185e5},type:"manual",status:"ready",tables:["customers","contacts","opportunities"],tags:["crm","partial"]},{id:"snap-005",name:"Failed Backup",environment:"production",createdAt:new Date("2024-01-24T02:00:00"),createdBy:{id:"system",name:"System"},size:{records:0,bytes:0},type:"scheduled",status:"failed"}],Be=[{id:"sched-daily",name:"Daily Backup",cron:"0 2 * * *",enabled:!0,nextRun:new Date(Date.now()+480*60*1e3),lastRun:new Date(Date.now()-960*60*1e3),retainCount:7},{id:"sched-weekly",name:"Weekly Full Backup",cron:"0 4 * * 0",enabled:!0,nextRun:new Date(Date.now()+4320*60*1e3),lastRun:new Date(Date.now()-5760*60*1e3),retainCount:4},{id:"sched-monthly",name:"Monthly Archive",cron:"0 6 1 * *",enabled:!1,lastRun:new Date(Date.now()-360*60*60*1e3),retainCount:12}],Me={enabled:!0,maxCount:30,maxAgeDays:90,keepTagged:!0,keepLocked:!0},re=p=>{if(p===0)return"0 B";const f=1024,M=["B","KB","MB","GB","TB"],S=Math.floor(Math.log(p)/Math.log(f));return parseFloat((p/Math.pow(f,S)).toFixed(1))+" "+M[S]},ne=p=>{const M=new Date().getTime()-p.getTime(),S=Math.floor(M/(1e3*60*60)),z=Math.floor(S/24);return z>0?`${z} day${z>1?"s":""} ago`:S>0?`${S} hour${S>1?"s":""} ago`:"Just now"},Re=p=>{const f=p.split(" ");if(f.length!==5)return p;const[M,S,z,I,U]=f;return z==="*"&&I==="*"&&U==="*"?`Daily at ${S.padStart(2,"0")}:${M.padStart(2,"0")}`:z==="*"&&I==="*"?`Weekly on ${["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][parseInt(U)]} at ${S.padStart(2,"0")}:${M.padStart(2,"0")}`:I==="*"?`Monthly on day ${z} at ${S.padStart(2,"0")}:${M.padStart(2,"0")}`:p},Te={creating:{icon:"clock",color:"var(--nice-color-warning, #f59e0b)",label:"Creating"},ready:{icon:"check",color:"var(--nice-color-success, #22c55e)",label:"Ready"},failed:{icon:"close",color:"var(--nice-color-error, #ef4444)",label:"Failed"},expired:{icon:"clock",color:"var(--nice-text-muted, #888)",label:"Expired"},locked:{icon:"lock",color:"var(--nice-color-primary, #3b82f6)",label:"Locked"}},$e={manual:{icon:"user",label:"Manual"},scheduled:{icon:"calendar",label:"Scheduled"},"pre-merge":{icon:"shuffle",label:"Pre-Merge"},"pre-restore":{icon:"reply",label:"Pre-Restore"}},ce=({environment:p="production",snapshots:f=we,retentionPolicy:M=Me,schedules:S=Be,onCreateSnapshot:z,onRestoreSnapshot:I,onDeleteSnapshot:U,onCompareSnapshots:W,onExportSnapshot:H,onUpdateRetentionPolicy:G,onUpdateSchedules:V,className:m,style:b,"data-testid":q})=>{const[C,T]=a.useState("snapshots"),[g,O]=a.useState(!1),[v,L]=a.useState([]),[j,A]=a.useState(""),[$,l]=a.useState(""),[y,x]=a.useState(M),[R,P]=a.useState(S),d=a.useMemo(()=>{const t=f.filter(o=>o.status==="ready").length,r=f.reduce((o,h)=>o+h.size.bytes,0);return{total:f.length,ready:t,totalSize:r}},[f]),w=()=>{z?.({name:j||`Snapshot ${new Date().toISOString()}`,description:$}),O(!1),A(""),l("")},F=()=>{v.length===2&&W?.(v[0],v[1])},k=t=>{const r=R.map(o=>o.id===t?{...o,enabled:!o.enabled}:o);P(r),V?.(r)},i={bg:"var(--nice-bg-elevated, #1e1e1e)",cardBg:"var(--nice-bg-elevated, #252525)",border:"var(--nice-bg-tertiary, #333)",text:"var(--nice-text-primary, #e0e0e0)",textMuted:"var(--nice-text-muted, #888)",env:B[p]};return e.jsxs("div",{className:`nice-data-snapshot ${m||""}`,style:{display:"flex",flexDirection:"column",height:"100%",background:i.bg,color:i.text,fontFamily:"system-ui, sans-serif",...b},"data-testid":q,children:[e.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${i.border}`,display:"flex",alignItems:"center",gap:16},children:[e.jsxs("h3",{style:{margin:0,fontSize:18},children:[e.jsx(c.oa,{name:"camera",size:16})," Snapshots"]}),e.jsxs("div",{style:{padding:"4px 10px",background:i.env+"30",borderRadius:4,fontSize:12,display:"flex",alignItems:"center",gap:6},children:[_[p]," ",p.charAt(0).toUpperCase()+p.slice(1)]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:16,fontSize:12,color:i.textMuted},children:[e.jsxs("span",{children:[e.jsx("strong",{style:{color:i.text},children:d.total})," snapshots"]}),e.jsxs("span",{children:[e.jsx("strong",{style:{color:i.text},children:re(d.totalSize)})," total"]})]}),e.jsxs("button",{onClick:()=>O(!0),style:{padding:"8px 16px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500,display:"flex",alignItems:"center",gap:6},children:[e.jsx(c.oa,{name:"camera",size:14})," Create Snapshot"]})]}),e.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${i.border}`,padding:"0 20px"},children:["snapshots","schedules","settings"].map(t=>e.jsxs("button",{onClick:()=>T(t),style:{padding:"12px 20px",border:"none",background:"transparent",color:C===t?i.text:i.textMuted,cursor:"pointer",fontSize:13,fontWeight:C===t?600:400,borderBottom:C===t?"2px solid var(--nice-primary, #3b82f6)":"2px solid transparent",marginBottom:-1},children:[t==="snapshots"&&e.jsxs(e.Fragment,{children:[e.jsx(c.oa,{name:"folder",size:14})," Snapshots"]}),t==="schedules"&&e.jsxs(e.Fragment,{children:[e.jsx(c.oa,{name:"calendar",size:14})," Schedules"]}),t==="settings"&&e.jsxs(e.Fragment,{children:[e.jsx(c.oa,{name:"settings",size:14})," Settings"]})]},t))}),e.jsxs("div",{style:{flex:1,overflow:"auto",padding:20},children:[C==="snapshots"&&e.jsxs("div",{children:[v.length>0&&e.jsxs("div",{style:{padding:12,background:i.cardBg,borderRadius:8,marginBottom:16,display:"flex",alignItems:"center",gap:12},children:[e.jsxs("span",{style:{fontSize:13},children:[v.length," selected"]}),v.length===2&&e.jsx("button",{onClick:F,style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:12},children:"Compare"}),e.jsx("button",{onClick:()=>L([]),style:{padding:"6px 12px",borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:12,marginLeft:"auto"},children:"Clear"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:f.map(t=>{const r=v.includes(t.id),o=Te[t.status],h=$e[t.type];return e.jsx("div",{style:{padding:16,background:i.cardBg,borderRadius:8,border:`1px solid ${r?"var(--nice-color-primary, #3b82f6)":i.border}`},children:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("input",{type:"checkbox",checked:r,onChange:N=>{N.target.checked?L(K=>[...K,t.id]):L(K=>K.filter(E=>E!==t.id))},style:{marginTop:4}}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[e.jsx("span",{style:{fontWeight:600},children:t.name}),e.jsxs("span",{style:{padding:"2px 6px",background:o.color+"20",color:o.color,borderRadius:4,fontSize:10},children:[e.jsx(c.oa,{name:o.icon,size:14})," ",o.label]}),e.jsxs("span",{style:{padding:"2px 6px",background:i.bg,color:i.textMuted,borderRadius:4,fontSize:10},children:[e.jsx(c.oa,{name:h.icon,size:14})," ",h.label]})]}),t.description&&e.jsx("div",{style:{fontSize:12,color:i.textMuted,marginBottom:8},children:t.description}),e.jsxs("div",{style:{display:"flex",gap:16,fontSize:11,color:i.textMuted},children:[e.jsx("span",{children:ne(t.createdAt)}),e.jsxs("span",{children:["by ",t.createdBy.name]}),e.jsxs("span",{children:[t.size.records.toLocaleString()," records"]}),e.jsx("span",{children:re(t.size.bytes)}),t.tables&&e.jsxs("span",{children:[t.tables.length," tables"]}),t.expiresAt&&e.jsxs("span",{style:{color:"var(--nice-color-warning, #f59e0b)"},children:["Expires: ",t.expiresAt.toLocaleDateString()]})]}),t.tags&&t.tags.length>0&&e.jsx("div",{style:{display:"flex",gap:6,marginTop:8},children:t.tags.map(N=>e.jsxs("span",{style:{padding:"2px 8px",background:"var(--nice-accent-tint-12, #8b5cf620)",color:"var(--nice-color-accent, #8b5cf6)",borderRadius:4,fontSize:10},children:["#",N]},N))})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[t.status==="ready"&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>I?.(t.id),title:"Restore","aria-label":"Restore",style:{padding:8,borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:14},children:e.jsx(c.oa,{name:"reply",size:14})}),e.jsx("button",{onClick:()=>H?.(t.id,"sql"),title:"Export","aria-label":"Export",style:{padding:8,borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:14},children:e.jsx(c.oa,{name:"upload",size:14})})]}),t.status!=="locked"&&e.jsx("button",{onClick:()=>U?.(t.id),title:"Delete","aria-label":"Delete",style:{padding:8,borderRadius:4,border:`1px solid ${i.border}`,background:"transparent",color:"var(--nice-color-error, #ef4444)",cursor:"pointer",fontSize:14},children:e.jsx(c.oa,{name:"trash",size:14})})]})]})},t.id)})})]}),C==="schedules"&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[R.map(t=>e.jsx("div",{style:{padding:16,background:i.cardBg,borderRadius:8,border:`1px solid ${i.border}`,opacity:t.enabled?1:.6},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("label",{className:"toggle",style:{display:"flex",alignItems:"center",cursor:"pointer"},children:e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:()=>k(t.id),style:{width:16,height:16}})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500},children:t.name}),e.jsxs("div",{style:{fontSize:12,color:i.textMuted},children:[Re(t.cron)," • Keep ",t.retainCount," snapshots"]})]}),e.jsxs("div",{style:{textAlign:"right",fontSize:11,color:i.textMuted},children:[t.enabled&&t.nextRun&&e.jsxs("div",{children:["Next: ",t.nextRun.toLocaleString()]}),t.lastRun&&e.jsxs("div",{children:["Last: ",ne(t.lastRun)]})]})]})},t.id)),e.jsx("button",{style:{padding:16,borderRadius:8,border:`1px dashed ${i.border}`,background:"transparent",color:i.textMuted,cursor:"pointer",fontSize:13},children:"+ Add Schedule"})]}),C==="settings"&&e.jsxs("div",{style:{maxWidth:500},children:[e.jsx("h4",{style:{marginTop:0},children:"Retention Policy"}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:y.enabled,onChange:t=>x({...y,enabled:t.target.checked})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:13},children:"Enable automatic cleanup"}),e.jsx("div",{style:{fontSize:11,color:i.textMuted},children:"Automatically delete old snapshots based on policy"})]})]}),y.enabled&&e.jsxs("div",{style:{padding:16,background:i.cardBg,borderRadius:8,display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:i.textMuted},children:"Maximum number of snapshots"}),e.jsx("input",{type:"number",value:y.maxCount??"",onChange:t=>x({...y,maxCount:parseInt(t.target.value)||void 0}),placeholder:"Unlimited",style:{padding:10,borderRadius:6,border:`1px solid ${i.border}`,background:i.bg,color:i.text,fontSize:13,width:150}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:i.textMuted},children:"Maximum age (days)"}),e.jsx("input",{type:"number",value:y.maxAgeDays??"",onChange:t=>x({...y,maxAgeDays:parseInt(t.target.value)||void 0}),placeholder:"Unlimited",style:{padding:10,borderRadius:6,border:`1px solid ${i.border}`,background:i.bg,color:i.text,fontSize:13,width:150}})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:y.keepTagged??!1,onChange:t=>x({...y,keepTagged:t.target.checked})}),e.jsx("span",{style:{fontSize:13},children:"Keep tagged snapshots"})]}),e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:12,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:y.keepLocked??!1,onChange:t=>x({...y,keepLocked:t.target.checked})}),e.jsx("span",{style:{fontSize:13},children:"Keep locked snapshots"})]})]}),e.jsx("button",{onClick:()=>G?.(y),style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500,alignSelf:"flex-start"},children:"Save Policy"})]})]})]}),g&&e.jsx("div",{style:{position:"fixed",inset:0,background:"var(--nice-overlay-70, rgba(0, 0, 0, 0.7))",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3},onClick:()=>O(!1),children:e.jsxs("div",{style:{background:i.cardBg,borderRadius:12,padding:24,width:400},onClick:t=>t.stopPropagation(),children:[e.jsxs("h4",{style:{margin:"0 0 16px"},children:[e.jsx(c.oa,{name:"camera",size:14})," Create Snapshot"]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:i.textMuted},children:"Snapshot Name"}),e.jsx("input",{type:"text",value:j,onChange:t=>A(t.target.value),placeholder:`Snapshot ${new Date().toISOString().split("T")[0]}`,style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${i.border}`,background:i.bg,color:i.text,fontSize:13,boxSizing:"border-box"}})]}),e.jsxs("div",{children:[e.jsx("label",{style:{display:"block",marginBottom:8,fontSize:12,color:i.textMuted},children:"Description (optional)"}),e.jsx("textarea",{value:$,onChange:t=>l(t.target.value),placeholder:"What's this snapshot for?",rows:3,style:{width:"100%",padding:10,borderRadius:6,border:`1px solid ${i.border}`,background:i.bg,color:i.text,fontSize:13,resize:"vertical",boxSizing:"border-box"}})]})]}),e.jsxs("div",{style:{display:"flex",gap:12,marginTop:24,justifyContent:"flex-end"},children:[e.jsx("button",{onClick:()=>O(!1),style:{padding:"10px 20px",borderRadius:6,border:`1px solid ${i.border}`,background:"transparent",color:i.text,cursor:"pointer",fontSize:13},children:"Cancel"}),e.jsx("button",{onClick:w,style:{padding:"10px 20px",borderRadius:6,border:"none",background:"var(--nice-color-primary, #3b82f6)",color:"var(--nice-bg-primary, #fff)",cursor:"pointer",fontSize:13,fontWeight:500},children:"Create"})]})]})})]})},De=Object.freeze(Object.defineProperty({__proto__:null,NiceDataSnapshot:ce},Symbol.toStringTag,{value:"Module"}));exports.NiceDataBranchGraph=de;exports.NiceDataBranchGraph$1=ve;exports.NiceDataBranchManager=se;exports.NiceDataBranchManager$1=ye;exports.NiceDataConflictResolver=le;exports.NiceDataConflictResolver$1=Ce;exports.NiceDataDiffViewer=oe;exports.NiceDataDiffViewer$1=me;exports.NiceDataMergeBuilder=ae;exports.NiceDataMergeBuilder$1=ke;exports.NiceDataSnapshot=ce;exports.NiceDataSnapshot$1=De;