@object-ui/console 3.1.3 → 3.1.5

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 (132) hide show
  1. package/dist/assets/AddressField-BLYuFwUv.js +1 -0
  2. package/dist/assets/AdvancedChartImpl-Dvg6YIfN.js +7 -0
  3. package/dist/assets/AppManagementPage-C5q5QBar.js +1 -0
  4. package/dist/assets/AuditLogPage-BpLFTD-b.js +1 -0
  5. package/dist/assets/AuthPageLayout-DDjJTsQ6.js +1 -0
  6. package/dist/assets/AutoNumberField-DLmi_0fk.js +1 -0
  7. package/dist/assets/AvatarField-BfoEDA_D.js +1 -0
  8. package/dist/assets/BooleanField-W3_x7RAZ.js +1 -0
  9. package/dist/assets/ChartImpl-Cwo6IWnY.js +1 -0
  10. package/dist/assets/CodeField-BWFqblAU.js +1 -0
  11. package/dist/assets/ColorField-Y8WM1wXE.js +1 -0
  12. package/dist/assets/CreateAppPage-A-VfItcx.js +1 -0
  13. package/dist/assets/CurrencyField-BeuE1bRa.js +1 -0
  14. package/dist/assets/DashboardDesignPage-N8NL-jkM.js +1 -0
  15. package/dist/assets/DashboardView-Dy0d2kFj.js +1 -0
  16. package/dist/assets/DateField-2Lf9jstN.js +1 -0
  17. package/dist/assets/DateTimeField-BkMuhOZJ.js +1 -0
  18. package/dist/assets/EditAppPage-B6HL4COW.js +1 -0
  19. package/dist/assets/EmailField-CP_O7tmo.js +1 -0
  20. package/dist/assets/FileField-CcczwlRk.js +1 -0
  21. package/dist/assets/ForgotPasswordPage-Slo6CHvD.js +1 -0
  22. package/dist/assets/FormulaField-DLdg1ImO.js +1 -0
  23. package/dist/assets/GeolocationField-DqeMjnyo.js +1 -0
  24. package/dist/assets/GridField-DaWMYyuc.js +1 -0
  25. package/dist/assets/ImageField-DAn05d1y.js +1 -0
  26. package/dist/assets/KanbanEnhanced-Dj7Qccu2.js +1 -0
  27. package/dist/assets/KanbanImpl-D9BbG_RT.js +1 -0
  28. package/dist/assets/LocationField-DYHVF_gq.js +1 -0
  29. package/dist/assets/LoginPage-D2CqpSi0.js +1 -0
  30. package/dist/assets/LookupField-BF9vCmht.js +1 -0
  31. package/dist/assets/MarkdownImpl-B0Iew7iJ.js +29 -0
  32. package/dist/assets/MasterDetailField-Dw4RRQ5W.js +1 -0
  33. package/dist/assets/NumberField-BKuVHBrN.js +1 -0
  34. package/dist/assets/ObjectField-z00gmFEc.js +1 -0
  35. package/dist/assets/OrgManagementPage-BqtqRi_6.js +1 -0
  36. package/dist/assets/PageDesignPage-BzIL8o0u.js +1 -0
  37. package/dist/assets/PageView-eCi7zkJr.js +2 -0
  38. package/dist/assets/PasswordField-B_rXL4g9.js +1 -0
  39. package/dist/assets/PercentField-Bn_SIbNe.js +1 -0
  40. package/dist/assets/PermissionManagementPage-BmI-0QXt.js +1 -0
  41. package/dist/assets/PhoneField-DuheMaUR.js +1 -0
  42. package/dist/assets/ProfilePage-CUo-xIgl.js +1 -0
  43. package/dist/assets/QRCodeField-IPS2Rpmi.js +1 -0
  44. package/dist/assets/RatingField-M6qZlpA4.js +1 -0
  45. package/dist/assets/RecordDetailView-CFVPmfrM.js +1 -0
  46. package/dist/assets/RegisterPage-D7PJIabW.js +1 -0
  47. package/dist/assets/ReportView-DNOPIpWM.js +1 -0
  48. package/dist/assets/RichTextField-CDGy9V9x.js +1 -0
  49. package/dist/assets/RoleManagementPage-DwtqyfDW.js +1 -0
  50. package/dist/assets/SearchResultsPage-BxzOkRnL.js +1 -0
  51. package/dist/assets/SelectField-F6UDlyvf.js +1 -0
  52. package/dist/assets/SignatureField-CHN7xBII.js +1 -0
  53. package/dist/assets/SliderField-BOfEMQyU.js +1 -0
  54. package/dist/assets/SummaryField-CZ8KzmBZ.js +1 -0
  55. package/dist/assets/SystemHubPage-RFiJSMgW.js +1 -0
  56. package/dist/assets/TextAreaField-1E39zZ_x.js +1 -0
  57. package/dist/assets/TextField-CwuU0Crc.js +1 -0
  58. package/dist/assets/TimeField-CEWXxhLE.js +1 -0
  59. package/dist/assets/UrlField-BtUImn9B.js +1 -0
  60. package/dist/assets/UserField-DSSEoy5L.js +1 -0
  61. package/dist/assets/UserManagementPage-BBS1vYGa.js +1 -0
  62. package/dist/assets/VectorField-BjfQeTZT.js +1 -0
  63. package/dist/assets/data-adapter-wZ81OFjZ.js +39 -0
  64. package/dist/assets/framework-DJlDX9E6.js +1 -0
  65. package/dist/assets/index-D9-L0QBO.css +2 -0
  66. package/dist/assets/index-DDpLaQOV.js +8 -0
  67. package/dist/assets/infrastructure-C6Ph6Ug0.js +3 -0
  68. package/dist/assets/maplibre-gl-DsUGuDud.js +756 -0
  69. package/dist/assets/plugins-core-Cfhp_BXE.css +2 -0
  70. package/dist/assets/plugins-core-PiAAytWV.js +136 -0
  71. package/dist/assets/plugins-views-CE0VP3vl.js +62 -0
  72. package/dist/assets/plugins-views-DnNKJB60.css +1 -0
  73. package/dist/assets/rolldown-runtime-Dw2cE7zH.js +1 -0
  74. package/dist/assets/skeletons-DcGqw3b1.js +1 -0
  75. package/dist/assets/src-oeWLmiqa.js +1 -0
  76. package/dist/assets/systemObjects-5--4zaiX.js +1 -0
  77. package/dist/assets/ui-layout-DdDX0gzI.js +3 -0
  78. package/dist/assets/vendor-charts-Bl5l0H2K.js +3 -0
  79. package/dist/assets/vendor-objectstack-BtztJIHv.js +1 -0
  80. package/dist/assets/vendor-react-BwtAzZZ3.js +9 -0
  81. package/dist/index.html +15 -24
  82. package/dist/mockServiceWorker.js +1 -1
  83. package/package.json +44 -44
  84. package/dist/assets/AdvancedChartImpl-BvIFxlPf.js +0 -7
  85. package/dist/assets/AppManagementPage-6bzxYNlP.js +0 -1
  86. package/dist/assets/AuditLogPage-qCzdxaNq.js +0 -1
  87. package/dist/assets/AuthPageLayout-DkrxSZOE.js +0 -1
  88. package/dist/assets/ChartImpl-DYQ9eXJz.js +0 -1
  89. package/dist/assets/CreateAppPage-DNKskVHK.js +0 -1
  90. package/dist/assets/DashboardDesignPage-T9tEAHAx.js +0 -1
  91. package/dist/assets/DashboardView-jCJCERzJ.js +0 -1
  92. package/dist/assets/EditAppPage-UGT9V29B.js +0 -1
  93. package/dist/assets/ForgotPasswordPage-Ca0lLZwY.js +0 -1
  94. package/dist/assets/KanbanEnhanced-CyIdmKhW.js +0 -1
  95. package/dist/assets/KanbanImpl-PGPpv-gu.js +0 -1
  96. package/dist/assets/LoginPage-BR2RpoGG.js +0 -1
  97. package/dist/assets/MarkdownImpl-eDhoPCJp.js +0 -29
  98. package/dist/assets/OrgManagementPage-DjT2mZ2x.js +0 -1
  99. package/dist/assets/PageDesignPage-DTEQcEuR.js +0 -1
  100. package/dist/assets/PageView-CFJhE0CN.js +0 -2
  101. package/dist/assets/PermissionManagementPage-C_FPnvGW.js +0 -1
  102. package/dist/assets/ProfilePage-CQkgvEEi.js +0 -1
  103. package/dist/assets/RecordDetailView-ClpxNRz2.js +0 -1
  104. package/dist/assets/RegisterPage-6IYU4bdp.js +0 -1
  105. package/dist/assets/ReportView-DecAJ58u.js +0 -1
  106. package/dist/assets/RoleManagementPage-v0ia3MGn.js +0 -1
  107. package/dist/assets/SearchResultsPage-CaSb54ho.js +0 -1
  108. package/dist/assets/SystemHubPage-PNaxZEht.js +0 -1
  109. package/dist/assets/UserManagementPage-KAZy5fgy.js +0 -1
  110. package/dist/assets/data-adapter-DCM4pdG4.js +0 -1
  111. package/dist/assets/framework-jBjO8CT3.js +0 -10
  112. package/dist/assets/index-BwkHrw9s.js +0 -1
  113. package/dist/assets/index-DXak0mZe.css +0 -1
  114. package/dist/assets/index-tta28Q_N.js +0 -9
  115. package/dist/assets/infrastructure-CWeiQ12V.js +0 -1
  116. package/dist/assets/maplibre-gl-CENyyZ0G.js +0 -811
  117. package/dist/assets/plugins-core-BV7ym-7D.js +0 -8
  118. package/dist/assets/plugins-views-P3eB-els.css +0 -1
  119. package/dist/assets/plugins-views-gxDbTdkX.js +0 -62
  120. package/dist/assets/systemObjects-DSpePIIy.js +0 -1
  121. package/dist/assets/ui-components-BCiSmwiC.css +0 -1
  122. package/dist/assets/ui-components-BRpbeVr1.js +0 -36
  123. package/dist/assets/ui-layout-VeUu0ZVf.js +0 -1
  124. package/dist/assets/vendor-charts-DthMRf4E.js +0 -60
  125. package/dist/assets/vendor-dndkit-_-PfuStg.js +0 -5
  126. package/dist/assets/vendor-i18n-B3GHNV0X.js +0 -9
  127. package/dist/assets/vendor-icons-CnLeuN7Z.js +0 -8566
  128. package/dist/assets/vendor-objectstack-BkRCrdfn.js +0 -34
  129. package/dist/assets/vendor-radix-BPVlBHPl.js +0 -56
  130. package/dist/assets/vendor-react-Dvo_9NuO.js +0 -60
  131. package/dist/assets/vendor-ui-utils-CU11aiRA.js +0 -1
  132. package/dist/assets/vendor-zod-CZmssJWz.js +0 -39
@@ -1 +0,0 @@
1
- import{B as Dt,r as ye,C as xe}from"./framework-jBjO8CT3.js";import"./vendor-objectstack-BkRCrdfn.js";import{r as a,j as e,R as Wt}from"./vendor-react-Dvo_9NuO.js";import{t as le,c as oe}from"./vendor-ui-utils-CU11aiRA.js";import{T as _t,a as Re,C as ue,m as ve,be as Zt,o as Ne,p as we,_ as Ue,bf as ze,l as me,K as Ee,ag as St,M as lt,bg as Yt,aN as ot,G as Ke,aw as Xt,aQ as rt,b2 as Et,b3 as It,r as Pt,aj as Jt,b4 as qt,bh as Qt,bi as Ot,bj as it,bk as Tt,bl as ea,bm as bt,bn as ta,aM as aa,ak as dt,a6 as Rt,N as ct,aY as Ge,b7 as pt,X as ut,b as sa,d as mt,P as ra,bo as na,S as la,F as Mt,f as Ie,bp as At,as as Lt,bq as oa,aX as ia,y as He,U as Be,at as $t,J as Ve,br as da,u as ca,b5 as pa,b6 as ua,ai as We,bs as Ft,bt as Ut,bu as zt,b0 as ma,aa as Kt,bv as xa,aP as ga,av as ba,aS as ha,aT as fa,aG as ya,a8 as va}from"./vendor-icons-CnLeuN7Z.js";import{u as ja}from"./infrastructure-CWeiQ12V.js";import"./vendor-zod-CZmssJWz.js";import"./ui-components-BRpbeVr1.js";import"./vendor-radix-BPVlBHPl.js";import"./vendor-i18n-B3GHNV0X.js";import"./vendor-charts-DthMRf4E.js";function Ce(t,r={}){const{maxHistory:p=50}=r,[i,l]=a.useState(t),u=a.useRef([]),o=a.useRef([]),h=a.useCallback(c=>{l(m=>(u.current=[...u.current.slice(-(p-1)),m],o.current=[],c))},[p]),x=a.useCallback(()=>{u.current.length!==0&&l(c=>{const m=[...u.current],C=m.pop();return u.current=m,o.current=[c,...o.current],C})},[]),s=a.useCallback(()=>{o.current.length!==0&&l(c=>{const m=[...o.current],C=m.shift();return o.current=m,u.current=[...u.current,c],C})},[]),d=a.useCallback(c=>{u.current=[],o.current=[],l(c)},[]);return{current:i,canUndo:u.current.length>0,canRedo:o.current.length>0,undoCount:u.current.length,redoCount:o.current.length,push:h,undo:x,redo:s,reset:d}}function Me(){const[t,r]=a.useState(!1),[p,i]=a.useState(""),[l,u]=a.useState(""),o=a.useRef(null),h=a.useCallback((d,c)=>(i(d),u(c),r(!0),new Promise(m=>{o.current=m})),[]),x=a.useCallback(()=>{r(!1),o.current?.(!0),o.current=null},[]),s=a.useCallback(()=>{r(!1),o.current?.(!1),o.current=null},[]);return{isOpen:t,title:p,message:l,confirm:h,onConfirm:x,onCancel:s}}function _e(){const[t,r]=a.useState(new Set),p=a.useCallback((h,x=!1)=>{r(s=>{const d=new Set(x?s:[]);return s.has(h)&&x?d.delete(h):d.add(h),d})},[]),i=a.useCallback(h=>{r(new Set([h]))},[]),l=a.useCallback(h=>{r(new Set(h))},[]),u=a.useCallback(()=>{r(new Set)},[]),o=a.useCallback(h=>t.has(h),[t]);return{selectedIds:t,toggle:p,selectOne:i,selectMany:l,clearSelection:u,isSelected:o,count:t.size}}function Ze(){const[t,r]=a.useState(null),p=a.useCallback(l=>{r(structuredClone(l))},[]),i=a.useCallback(()=>t?structuredClone(t):null,[t]);return{clipboard:t,copy:p,paste:i,hasContent:t!==null}}function xt(t={}){const{minZoom:r=.25,maxZoom:p=3,zoomStep:i=.1,initialZoom:l=1}=t,[u,o]=a.useState(l),[h,x]=a.useState({x:0,y:0}),s=a.useRef(!1),d=a.useRef({x:0,y:0}),c=a.useCallback(A=>Math.min(p,Math.max(r,+A.toFixed(2))),[r,p]),m=a.useCallback(()=>o(A=>c(A+i)),[c,i]),C=a.useCallback(()=>o(A=>c(A-i)),[c,i]),g=a.useCallback(()=>{o(1),x({x:0,y:0})},[]),S=a.useCallback(A=>o(c(A)),[c]),M=a.useCallback(A=>{if(A.ctrlKey||A.metaKey){A.preventDefault();const H=A.deltaY>0?-i:i;o(N=>c(N+H))}},[c,i]),I=a.useCallback(A=>{if(A.button===1||A.button===0&&A.altKey){A.preventDefault(),s.current=!0,d.current={x:A.clientX,y:A.clientY};const H=k=>{if(!s.current)return;const y=k.clientX-d.current.x,D=k.clientY-d.current.y;d.current={x:k.clientX,y:k.clientY},x(T=>({x:T.x+y,y:T.y+D}))},N=()=>{s.current=!1,document.removeEventListener("mousemove",H),document.removeEventListener("mouseup",N)};document.addEventListener("mousemove",H),document.addEventListener("mouseup",N)}},[]),L={transform:`translate(${h.x}px, ${h.y}px) scale(${u})`,transformOrigin:"0 0"};return{zoom:u,panOffset:h,zoomIn:m,zoomOut:C,resetZoom:g,setZoom:S,handleWheel:M,startPan:I,transformStyle:L}}function Na(...t){return le(oe(t))}function Ye({isOpen:t,title:r,message:p,confirmLabel:i="Delete",cancelLabel:l="Cancel",destructive:u=!0,onConfirm:o,onCancel:h}){const x=a.useRef(null);return a.useEffect(()=>{const s=x.current;s&&(t&&!s.open?s.showModal():!t&&s.open&&s.close())},[t]),t?e.jsx("dialog",{ref:x,className:"fixed inset-0 z-50 m-auto rounded-lg border bg-background p-0 shadow-lg backdrop:bg-black/50",onClose:h,"aria-labelledby":"confirm-title","aria-describedby":"confirm-message",children:e.jsxs("div",{className:"w-80 p-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[u&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10",children:e.jsx(_t,{className:"h-5 w-5 text-destructive"})}),e.jsx("h2",{id:"confirm-title",className:"text-lg font-semibold",children:r})]}),e.jsx("p",{id:"confirm-message",className:"text-sm text-muted-foreground mb-6",children:p}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:h,className:"px-4 py-2 text-sm rounded-md border hover:bg-accent",children:l}),e.jsx("button",{onClick:o,className:Na("px-4 py-2 text-sm rounded-md font-medium",u?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"),autoFocus:!0,children:i})]})]})}):null}function wa(...t){return le(oe(t))}function Xe({title:t="Properties",fields:r,onChange:p,className:i}){const[l,u]=a.useState(new Set),o=a.useCallback(x=>{u(s=>{const d=new Set(s);return d.has(x)?d.delete(x):d.add(x),d})},[]),h=r.reduce((x,s)=>{const d=s.group??"General";return x[d]||(x[d]=[]),x[d].push(s),x},{});return e.jsxs("div",{className:wa("flex flex-col",i),role:"region","aria-label":t,children:[e.jsx("div",{className:"p-3 border-b font-medium text-sm",children:t}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[Object.entries(h).map(([x,s])=>e.jsxs("div",{className:"border-b last:border-b-0",children:[e.jsxs("button",{onClick:()=>o(x),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50",children:[l.has(x)?e.jsx(Re,{className:"h-3 w-3"}):e.jsx(ue,{className:"h-3 w-3"}),x]}),!l.has(x)&&e.jsx("div",{className:"px-3 pb-2 space-y-2",children:s.map(d=>e.jsx(Ca,{field:d,onChange:p},d.name))})]},x)),r.length===0&&e.jsx("div",{className:"p-3 text-xs text-muted-foreground text-center",children:"Select an element to edit its properties"})]})]})}function Ca({field:t,onChange:r}){const p=i=>{r(t.name,i)};return e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:t.label}),t.type==="text"&&e.jsx("input",{type:"text",value:String(t.value??""),onChange:i=>p(i.target.value),className:"w-full px-2 py-1 text-xs border rounded bg-background"}),t.type==="number"&&e.jsx("input",{type:"number",value:Number(t.value??0),onChange:i=>p(Number(i.target.value)),className:"w-full px-2 py-1 text-xs border rounded bg-background"}),t.type==="boolean"&&e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:!!t.value,onChange:i=>p(i.target.checked),className:"rounded"}),e.jsx("span",{className:"text-xs",children:t.value?"Yes":"No"})]}),t.type==="select"&&e.jsx("select",{value:String(t.value??""),onChange:i=>p(i.target.value),className:"w-full px-2 py-1 text-xs border rounded bg-background",children:t.options?.map(i=>e.jsx("option",{value:i.value,children:i.label},i.value))}),t.type==="color"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:String(t.value??"#000000"),onChange:i=>p(i.target.value),className:"h-6 w-6 rounded border cursor-pointer"}),e.jsx("span",{className:"text-xs font-mono",children:String(t.value??"#000000")})]}),t.type==="textarea"&&e.jsx("textarea",{value:String(t.value??""),onChange:i=>p(i.target.value),className:"w-full px-2 py-1 text-xs border rounded bg-background resize-y",rows:3}),t.description&&e.jsx("p",{className:"text-[0.65rem] text-muted-foreground/70",children:t.description})]})}function ka(...t){return le(oe(t))}function gt({items:t,canvasWidth:r,canvasHeight:p,position:i="bottom-right",size:l=150,className:u}){const o=Math.min(l/r,l/p),h=r*o,x=p*o,s={"top-left":"top-2 left-2","top-right":"top-2 right-2","bottom-left":"bottom-2 left-2","bottom-right":"bottom-2 right-2"};return e.jsx("div",{className:ka("absolute border rounded bg-background/90 shadow-sm overflow-hidden",s[i],u),role:"img","aria-label":"Canvas minimap",children:e.jsxs("svg",{width:h,height:x,viewBox:`0 0 ${r} ${p}`,children:[e.jsx("rect",{width:r,height:p,fill:"hsl(var(--muted))",opacity:"0.3"}),t.map(d=>e.jsx("rect",{x:d.x,y:d.y,width:d.width,height:d.height,fill:d.selected?"hsl(var(--primary))":d.color??"hsl(var(--foreground) / 0.3)",rx:"2"},d.id))]})})}function Da(...t){return le(oe(t))}const Je=a.createContext(null);Je.displayName="CollaborationContext";function Ds({config:t,user:r,onOperation:p,onPresenceChange:i,children:l}){const u=a.useRef(null),[o,h]=a.useState([]),[x,s]=a.useState("disconnected"),d=a.useRef(0),c=a.useRef(null);a.useEffect(()=>{if(!t.enabled||!r||!t.serverUrl||!(typeof WebSocket<"u"))return;function I(){let L;try{if(L=new URL(t.serverUrl),L.protocol!=="ws:"&&L.protocol!=="wss:")return}catch{return}t.roomId&&L.searchParams.set("room",t.roomId),L.searchParams.set("userId",r.id),s("connecting");const A=new WebSocket(L.toString());A.onopen=()=>{s("connected"),A.send(JSON.stringify({type:"join",userId:r.id,userName:r.name,avatar:r.avatar}))},A.onmessage=H=>{try{const N=JSON.parse(H.data);if(N.type==="presence"){const k=N.users||[];h(k.filter(y=>y.userId!==r.id)),i?.(k)}else N.type==="operation"&&p?.(N.operation)}catch{}},A.onclose=()=>{s("disconnected"),u.current=null,t.enabled&&(c.current=setTimeout(I,t.autoSaveInterval??3e3))},A.onerror=()=>{s("error")},u.current=A}return I(),()=>{c.current&&clearTimeout(c.current),u.current&&(u.current.onclose=null,u.current.close(),u.current=null),s("disconnected")}},[t.enabled,t.serverUrl,t.roomId,t.autoSaveInterval,r,p,i]);const m=a.useMemo(()=>!t.enabled||!r?[]:[{userId:r.id,userName:r.name,avatar:r.avatar,color:Sa(r.id),status:"active",lastActivity:new Date().toISOString()},...o],[t.enabled,r,o]),C=t.enabled&&!!r&&(t.serverUrl?x==="connected":!0),g=a.useCallback(M=>{if(!t.enabled||!r)return;d.current+=1;const I={...M,id:`op-${Date.now()}-${d.current}`,userId:r.id,timestamp:new Date().toISOString(),version:d.current};u.current?.readyState===WebSocket.OPEN&&u.current.send(JSON.stringify({type:"operation",operation:I})),p?.(I)},[t.enabled,r,p]),S=a.useMemo(()=>({users:m,isConnected:C,sendOperation:g,currentUserId:r?.id,connectionState:x,versionCount:d.current}),[m,C,g,r?.id,x]);return e.jsx(Je.Provider,{value:S,children:l})}function qe(){return a.useContext(Je)}function Ss({className:t}){const r=a.useContext(Je);if(!r)return null;const{connectionState:p,users:i}=r,l={connected:{color:"bg-green-500",label:"Connected"},connecting:{color:"bg-yellow-500 animate-pulse",label:"Connecting…"},disconnected:{color:"bg-gray-400",label:"Disconnected"},error:{color:"bg-red-500",label:"Connection error"}},{color:u,label:o}=l[p]??l.disconnected;return e.jsxs("div",{className:Da("flex items-center gap-2 text-xs",t),role:"status","aria-live":"polite","aria-label":`Collaboration: ${o}`,children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${u}`}),e.jsx("span",{children:o}),p==="connected"&&i.length>1&&e.jsxs("span",{className:"text-muted-foreground",children:["(",i.length," users)"]})]})}function Sa(t){const r=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#f97316","#14b8a6","#f43f5e","#a855f7","#84cc16","#0ea5e9","#e879f9","#fb923c","#facc15"];let p=0;for(let i=0;i<t.length;i++)p=(p<<5)-p+t.charCodeAt(i)|0;return r[Math.abs(p)%r.length]}function ce(...t){return le(oe(t))}function Ea({canvas:t={width:1200,height:800,gridSize:8,showGrid:!0,snapToGrid:!0},components:r=[],palette:p=Ia,showComponentTree:i=!0,undoRedo:l=!0,propertyEditor:u=!0,readOnly:o=!1,showMinimap:h=!1,onChange:x,className:s}){const d=Ce(r),c=d.current,m=a.useCallback(b=>{d.push(b),x?.(b)},[d,x]),C=xt({initialZoom:t.zoom??1}),{zoom:g}=C,S=_e(),M=a.useMemo(()=>{const b=Array.from(S.selectedIds);return b.length>0?b[0]:null},[S.selectedIds]),I=a.useMemo(()=>c.find(b=>b.id===M),[c,M]),L=Ze(),A=Me(),H=qe(),N=a.useCallback(b=>{H&&H.sendOperation({...b,userId:H.currentUserId??""})},[H]),[k,y]=a.useState(!0),[D,T]=a.useState(!0),[Y,O]=a.useState(h),W=a.useRef(null),te=a.useRef(null),re=a.useCallback(b=>!t.snapToGrid||!t.gridSize?b:Math.round(b/t.gridSize)*t.gridSize,[t.snapToGrid,t.gridSize]),F=a.useCallback((b,E)=>{if(o)return;const z=p.flatMap(se=>se.items).find(se=>se.type===b),B=z?.defaultSize,q={id:`comp-${Date.now()}`,type:b,label:E,position:{x:100,y:100,width:B?.width??200,height:B?.height??100},props:z?.defaultProps??{}},ee=[...c,q];m(ee),S.selectOne(q.id),N({type:"insert",elementId:q.id,data:{component:q}})},[c,o,p,m,S,N]),X=a.useCallback(b=>{if(o)return;const E=c.filter(z=>z.id!==b);m(E),S.isSelected(b)&&S.clearSelection(),N({type:"delete",elementId:b,data:{}})},[c,o,m,S,N]),V=a.useCallback(async()=>{if(o||S.count===0||!await A.confirm("Delete components",`Are you sure you want to delete ${S.count} component${S.count>1?"s":""}?`))return;const E=S.selectedIds,z=c.filter(B=>!E.has(B.id));m(z),S.clearSelection(),E.forEach(B=>{N({type:"delete",elementId:B,data:{}})})},[o,S,A,c,m,N]),j=a.useCallback((b,E)=>{if(o||!M)return;const z=c.map(B=>B.id!==M?B:b==="label"?{...B,label:String(E)}:b==="x"?{...B,position:{...B.position,x:Number(E)}}:b==="y"?{...B,position:{...B.position,y:Number(E)}}:b==="width"?{...B,position:{...B.position,width:Number(E)}}:b==="height"?{...B,position:{...B.position,height:Number(E)}}:{...B,props:{...B.props,[b]:E}});m(z),N({type:"update",elementId:M,data:{[b]:E}})},[o,M,c,m,N]),U=a.useCallback(()=>{const b=S.selectedIds;if(b.size===0)return;const E=c.filter(z=>b.has(z.id));L.copy(E)},[S,c,L]),$=a.useCallback(()=>{if(o)return;const b=L.paste();if(!b||b.length===0)return;let E=0;const z=b.map(q=>({...q,id:`comp-${Date.now()}-${++E}-${Math.random().toString(36).slice(2,7)}`,position:{...q.position,x:q.position.x+20,y:q.position.y+20}})),B=[...c,...z];m(B),S.selectMany(z.map(q=>q.id)),z.forEach(q=>{N({type:"insert",elementId:q.id,data:{component:q}})})},[o,L,c,m,S,N]),J=a.useCallback((b,E)=>{o||(W.current={id:E.id,startX:b.clientX,startY:b.clientY},b.dataTransfer.effectAllowed="move",b.dataTransfer.setData("text/plain",E.id))},[o]),ae=a.useCallback(b=>{b.preventDefault(),b.dataTransfer.dropEffect="move"},[]),P=a.useCallback(b=>{b.preventDefault();const E=W.current;if(!E||o)return;const z=(b.clientX-E.startX)/g,B=(b.clientY-E.startY)/g,q=c.map(ee=>ee.id!==E.id?ee:{...ee,position:{...ee.position,x:re(ee.position.x+z),y:re(ee.position.y+B)}});m(q),N({type:"move",elementId:E.id,data:{}}),W.current=null},[o,g,c,m,re,N]),Z=a.useMemo(()=>I?[{name:"label",label:"Label",type:"text",value:I.label??"",group:"General"},{name:"x",label:"X",type:"number",value:I.position.x,group:"Position"},{name:"y",label:"Y",type:"number",value:I.position.y,group:"Position"},{name:"width",label:"Width",type:"number",value:I.position.width,group:"Size"},{name:"height",label:"Height",type:"number",value:I.position.height,group:"Size"}]:[],[I]),R=a.useMemo(()=>c.map(b=>({id:b.id,x:b.position.x,y:b.position.y,width:typeof b.position.width=="number"?b.position.width:100,height:typeof b.position.height=="number"?b.position.height:50,selected:S.isSelected(b.id)})),[c,S]);return a.useEffect(()=>{const b=te.current;if(!b)return;const E=z=>{const B=["INPUT","TEXTAREA","SELECT"].includes(z.target.tagName),q=z.ctrlKey||z.metaKey;if((z.key==="Delete"||z.key==="Backspace")&&S.count>0&&!B){z.preventDefault(),V();return}if(z.key==="Escape"){S.clearSelection();return}if(!B){if(q&&z.key==="z"&&!z.shiftKey&&l&&!o){z.preventDefault(),d.undo();return}if(q&&(z.key==="z"&&z.shiftKey||z.key==="y")&&l&&!o){z.preventDefault(),d.redo();return}if(q&&z.key==="c"){z.preventDefault(),U();return}if(q&&z.key==="v"&&!o){z.preventDefault(),$();return}if(q&&z.key==="a"){z.preventDefault(),S.selectMany(c.map(ee=>ee.id));return}}};return b.addEventListener("keydown",E),()=>b.removeEventListener("keydown",E)},[S,V,l,o,d,U,$,c]),e.jsxs("div",{ref:te,tabIndex:0,className:ce("flex h-full w-full border rounded-lg overflow-hidden bg-background",s),children:[!o&&e.jsx("div",{className:ce("border-r bg-muted/30 flex flex-col transition-[width] duration-200",k?"w-60":"w-0 overflow-hidden"),role:"region","aria-label":"Component palette",children:k&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-3 border-b font-medium text-sm",children:"Components"}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:p.map(b=>e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground px-2 py-1 uppercase",children:b.label}),b.items.map(E=>e.jsxs("button",{onClick:()=>F(E.type,E.label),className:"w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-accent text-left",children:[e.jsx(ve,{className:"h-3 w-3"}),E.label]},E.type))]},b.name))})]})}),e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/20",role:"toolbar","aria-label":"Designer toolbar",children:[!o&&e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:k?"Collapse palette":"Expand palette","aria-label":k?"Collapse palette":"Expand palette",onClick:()=>y(b=>!b),children:e.jsx(Zt,{className:ce("h-4 w-4",!k&&"rotate-180")})}),l&&!o&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-5 bg-border mx-1"}),e.jsx("button",{className:ce("p-1.5 rounded hover:bg-accent",!d.canUndo&&"opacity-40 pointer-events-none"),title:"Undo (Ctrl+Z)","aria-label":"Undo",disabled:!d.canUndo,onClick:()=>d.undo(),children:e.jsx(Ne,{className:"h-4 w-4"})}),e.jsx("button",{className:ce("p-1.5 rounded hover:bg-accent",!d.canRedo&&"opacity-40 pointer-events-none"),title:"Redo (Ctrl+Shift+Z)","aria-label":"Redo",disabled:!d.canRedo,onClick:()=>d.redo(),children:e.jsx(we,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),!o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:ce("p-1.5 rounded hover:bg-accent",S.count===0&&"opacity-40 pointer-events-none"),title:"Copy (Ctrl+C)","aria-label":"Copy",disabled:S.count===0,onClick:U,children:e.jsx(Ue,{className:"h-4 w-4"})}),e.jsx("button",{className:ce("p-1.5 rounded hover:bg-accent",!L.hasContent&&"opacity-40 pointer-events-none"),title:"Paste (Ctrl+V)","aria-label":"Paste",disabled:!L.hasContent,onClick:$,children:e.jsx(ze,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),!o&&e.jsx("button",{className:ce("p-1.5 rounded hover:bg-accent",S.count===0&&"opacity-40 pointer-events-none"),title:"Delete selected","aria-label":"Delete selected",disabled:S.count===0,onClick:V,children:e.jsx(me,{className:"h-4 w-4"})}),e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:"Preview","aria-label":"Preview",children:e.jsx(Ee,{className:"h-4 w-4"})}),e.jsx("button",{className:ce("p-1.5 rounded hover:bg-accent",Y&&"bg-accent"),title:"Toggle minimap","aria-label":"Toggle minimap",onClick:()=>O(b=>!b),children:e.jsx(St,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{className:"p-1 rounded hover:bg-accent text-xs","aria-label":"Zoom out",onClick:C.zoomOut,children:e.jsx(lt,{className:"h-3 w-3"})}),e.jsxs("span",{className:"text-xs text-muted-foreground w-10 text-center",children:[Math.round(g*100),"%"]}),e.jsx("button",{className:"p-1 rounded hover:bg-accent text-xs","aria-label":"Zoom in",onClick:C.zoomIn,children:e.jsx(ve,{className:"h-3 w-3"})}),e.jsx("button",{className:"p-1 rounded hover:bg-accent text-xs","aria-label":"Reset zoom",onClick:C.resetZoom,children:e.jsx(Yt,{className:"h-3 w-3"})})]}),i&&e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:D?"Collapse panel":"Expand panel","aria-label":D?"Collapse panel":"Expand panel",onClick:()=>T(b=>!b),children:e.jsx(ot,{className:ce("h-4 w-4",!D&&"rotate-180")})})]}),e.jsx("div",{className:"flex-1 overflow-auto bg-muted/10 p-4 relative",role:"region","aria-label":"Design canvas",onWheel:C.handleWheel,onMouseDown:C.startPan,onDragOver:ae,onDrop:P,children:e.jsxs("div",{className:"relative bg-background border rounded shadow-sm mx-auto",style:{width:t.width*g,height:t.height*g,transform:`translate(${C.panOffset.x}px, ${C.panOffset.y}px)`,backgroundImage:t.showGrid?"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)":void 0,backgroundSize:t.showGrid&&t.gridSize?`${t.gridSize*g}px ${t.gridSize*g}px`:void 0},children:[c.map(b=>{const E=S.isSelected(b.id);return e.jsxs("div",{draggable:!o,onDragStart:z=>J(z,b),className:ce("absolute border rounded cursor-move select-none transition-shadow",E?"border-primary ring-2 ring-primary/20 shadow-md":"border-border hover:border-primary/50"),style:{left:b.position.x*g,top:b.position.y*g,width:typeof b.position.width=="number"?b.position.width*g:b.position.width,height:typeof b.position.height=="number"?b.position.height*g:b.position.height},onClick:z=>S.toggle(b.id,z.shiftKey),children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted/50 text-xs border-b",children:[e.jsx(Ke,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:b.label??b.type}),!o&&e.jsx("button",{onClick:z=>{z.stopPropagation(),X(b.id)},className:"ml-auto p-0.5 rounded hover:bg-destructive/10","aria-label":`Delete ${b.label??b.type}`,children:e.jsx(me,{className:"h-3 w-3 text-destructive"})})]}),e.jsx("div",{className:"p-2 text-xs text-muted-foreground",children:b.type})]},b.id)}),Y&&e.jsx(gt,{items:R,canvasWidth:t.width,canvasHeight:t.height})]})})]}),i&&e.jsx("div",{className:ce("border-l bg-muted/30 flex flex-col transition-[width] duration-200",D?"w-60":"w-0 overflow-hidden"),role:"region","aria-label":"Component tree",children:D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"p-3 border-b font-medium text-sm flex items-center gap-2",children:[e.jsx(Xt,{className:"h-4 w-4"}),"Component Tree"]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:c.length===0?e.jsx("div",{className:"text-xs text-muted-foreground text-center py-4",children:"No components added yet. Click a component in the palette to add it to the canvas."}):c.map(b=>e.jsx("button",{onClick:E=>S.toggle(b.id,E.shiftKey),className:ce("w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded text-left",S.isSelected(b.id)?"bg-accent":"hover:bg-accent/50"),children:e.jsx("span",{className:"truncate",children:b.label??b.type})},b.id))}),u&&I?e.jsx("div",{className:"border-t",children:e.jsx(Xe,{title:`Properties – ${I.label??I.type}`,fields:Z,onChange:j})}):I&&e.jsxs("div",{className:"border-t p-3",children:[e.jsx("div",{className:"text-xs font-medium mb-2",children:"Properties"}),e.jsxs("div",{className:"text-xs text-muted-foreground space-y-1",children:[e.jsxs("div",{children:["Type: ",I.type]}),e.jsxs("div",{children:["ID: ",I.id]}),e.jsxs("div",{children:["Position: ",I.position.x,","," ",I.position.y]}),e.jsxs("div",{children:["Size: ",I.position.width," ×"," ",I.position.height]})]})]})]})}),e.jsx(Ye,{isOpen:A.isOpen,title:A.title,message:A.message,onConfirm:A.onConfirm,onCancel:A.onCancel})]})}const Ia=[{name:"layout",label:"Layout",items:[{type:"container",label:"Container",defaultSize:{width:400,height:300}},{type:"flex",label:"Flex",defaultSize:{width:400,height:200}},{type:"grid",label:"Grid",defaultSize:{width:400,height:300}},{type:"card",label:"Card",defaultSize:{width:300,height:200}},{type:"tabs",label:"Tabs",defaultSize:{width:400,height:300}}]},{name:"form",label:"Form",items:[{type:"input",label:"Input",defaultSize:{width:300,height:60}},{type:"textarea",label:"Textarea",defaultSize:{width:300,height:120}},{type:"select",label:"Select",defaultSize:{width:300,height:60}},{type:"checkbox",label:"Checkbox",defaultSize:{width:200,height:40}},{type:"button",label:"Button",defaultSize:{width:120,height:40}}]},{name:"data",label:"Data",items:[{type:"table",label:"Table",defaultSize:{width:600,height:400}},{type:"chart",label:"Chart",defaultSize:{width:400,height:300}},{type:"list",label:"List",defaultSize:{width:300,height:400}},{type:"statistic",label:"Statistic",defaultSize:{width:200,height:100}}]}];function Pa(t,r={}){return Ce(t,r)}function at(...t){return le(oe(t))}const Ta=["text","number","boolean","date","datetime","uuid","email","url","phone","json","integer","float","decimal","currency","percent","textarea","select","multiselect","lookup","attachment","formula","autonumber"];function Ra(t,r=4,p=280,i=250,l=50,u=50){return t.map((o,h)=>({...o,position:{x:l+h%r*p,y:u+Math.floor(h/r)*i}}))}function Ma({entities:t=[],relationships:r=[],canvas:p={width:1200,height:800,showGrid:!0},showRelationshipLabels:i=!0,readOnly:l=!1,onEntitiesChange:u,onRelationshipsChange:o,className:h}){const x=a.useRef(null),s=Pa({entities:t,relationships:r},{maxHistory:50}),{entities:d,relationships:c}=s.current,m=a.useCallback(f=>{s.push(f),u?.(f.entities),o?.(f.relationships)},[s,u,o]),C=Me(),g=_e(),S=g.count>0?Array.from(g.selectedIds)[0]:null,M=Ze(),I=xt({minZoom:.25,maxZoom:3,zoomStep:.1}),L=qe(),[A,H]=a.useState(!0),[N,k]=a.useState(!0),[y,D]=a.useState(null),[T,Y]=a.useState(""),[O,W]=a.useState(null),[te,re]=a.useState(""),F=a.useRef(null),X=a.useCallback(()=>{if(l)return;const f=s.current,n={id:`entity-${Date.now()}`,name:`new_entity_${f.entities.length+1}`,label:`New Entity ${f.entities.length+1}`,fields:[{name:"id",type:"uuid",primaryKey:!0,required:!0},{name:"created_at",type:"datetime",required:!0},{name:"updated_at",type:"datetime",required:!0}],position:{x:50+f.entities.length%4*280,y:50+Math.floor(f.entities.length/4)*250}},w={entities:[...f.entities,n],relationships:f.relationships};m(w),g.selectOne(n.id),L?.sendOperation({type:"insert",userId:L?.currentUserId??"",elementId:n.id,data:{name:n.name,label:n.label}})},[l,s,m,g,L]),V=a.useCallback(async f=>{if(l)return;const n=d.find(_=>_.id===f);if(!await C.confirm("Delete Entity",`Are you sure you want to delete "${n?.label??f}"? This action cannot be undone.`))return;const v=s.current,K={entities:v.entities.filter(_=>_.id!==f),relationships:v.relationships.filter(_=>_.sourceEntity!==f&&_.targetEntity!==f)};m(K),g.isSelected(f)&&g.clearSelection(),L?.sendOperation({type:"delete",userId:L?.currentUserId??"",elementId:f,data:{}})},[l,d,C,s,m,g,L]),j=a.useCallback(async()=>{if(l||g.count===0)return;const f=Array.from(g.selectedIds);if(!await C.confirm("Delete Entities",`Are you sure you want to delete ${f.length} selected entity(s)? This action cannot be undone.`))return;const w=s.current,v=new Set(f),K={entities:w.entities.filter(_=>!v.has(_.id)),relationships:w.relationships.filter(_=>!v.has(_.sourceEntity)&&!v.has(_.targetEntity))};m(K),g.clearSelection()},[l,g,C,s,m]),U=a.useCallback(()=>{if(l)return;const f=s.current,n={entities:Ra(f.entities),relationships:f.relationships};m(n)},[l,s,m]),$=a.useCallback(()=>{const f=d.filter(n=>g.isSelected(n.id));f.length>0&&M.copy(f)},[d,g,M]),J=a.useCallback(()=>{if(l)return;const f=M.paste();if(!f||f.length===0)return;const n=s.current,w=f.map((K,_)=>({...K,id:`entity-${Date.now()}-${_}`,name:`${K.name}_copy`,label:`${K.label} (Copy)`,position:{x:K.position.x+30,y:K.position.y+30}})),v={entities:[...n.entities,...w],relationships:n.relationships};m(v),g.selectMany(w.map(K=>K.id))},[l,M,s,m,g]),ae=a.useCallback(f=>{if(l)return;const n=s.current,w={entities:n.entities.map(v=>{if(v.id!==f)return v;const K={name:`field_${v.fields.length+1}`,type:"text",required:!1};return{...v,fields:[...v.fields,K]}}),relationships:n.relationships};m(w)},[l,s,m]),P=a.useCallback((f,n,w)=>{l||(D({entityId:f,fieldIndex:n}),Y(w))},[l]),Z=a.useCallback(()=>{if(!y)return;const f=T.trim();if(f===""){D(null);return}const n=s.current,w={entities:n.entities.map(v=>{if(v.id!==y.entityId)return v;const K=v.fields.map((_,Q)=>Q===y.fieldIndex?{..._,name:f}:_);return{...v,fields:K}}),relationships:n.relationships};m(w),D(null)},[y,T,s,m]),R=a.useCallback(()=>{D(null)},[]),b=a.useCallback((f,n)=>{l||(W(f),re(n))},[l]),E=a.useCallback(()=>{if(!O)return;const f=te.trim();if(f===""){W(null);return}const n=s.current,w={entities:n.entities.map(v=>v.id===O?{...v,label:f}:v),relationships:n.relationships};m(w),W(null)},[O,te,s,m]),z=a.useCallback(()=>{W(null)},[]),B=a.useCallback((f,n,w)=>{if(l)return;const v=s.current,K={entities:v.entities.map(_=>{if(_.id!==f)return _;const Q=_.fields.map((de,he)=>he===n?{...de,type:w}:de);return{..._,fields:Q}}),relationships:v.relationships};m(K)},[l,s,m]),q=a.useCallback((f,n)=>{if(l||!d.find(K=>K.id===n))return;const v=f.target.getBoundingClientRect();F.current={entityId:n,offsetX:f.clientX-v.left,offsetY:f.clientY-v.top},f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",n)},[l,d]),ee=a.useCallback(f=>{f.preventDefault(),f.dataTransfer.dropEffect="move"},[]),se=a.useCallback(f=>{if(f.preventDefault(),!F.current)return;const n=f.currentTarget.getBoundingClientRect(),w=I.zoom,v=(f.clientX-n.left-I.panOffset.x)/w-F.current.offsetX,K=(f.clientY-n.top-I.panOffset.y)/w-F.current.offsetY,_=s.current,Q={entities:_.entities.map(de=>de.id===F.current.entityId?{...de,position:{x:Math.max(0,Math.round(v)),y:Math.max(0,Math.round(K))}}:de),relationships:_.relationships};m(Q),F.current=null},[I.zoom,I.panOffset,s,m]),ie=S?d.find(f=>f.id===S):null,Qe=ie?[{name:"name",label:"Name",type:"text",value:ie.name,group:"General"},{name:"label",label:"Label",type:"text",value:ie.label,group:"General"},{name:"description",label:"Description",type:"textarea",value:ie.description??"",group:"General"},{name:"color",label:"Color",type:"color",value:ie.color??"#3b82f6",group:"Appearance"},{name:"position.x",label:"X Position",type:"number",value:ie.position.x,group:"Position"},{name:"position.y",label:"Y Position",type:"number",value:ie.position.y,group:"Position"}]:[],Oe=a.useCallback((f,n)=>{if(!S)return;const w=s.current,v={entities:w.entities.map(K=>K.id!==S?K:f==="position.x"?{...K,position:{...K.position,x:Number(n)}}:f==="position.y"?{...K,position:{...K.position,y:Number(n)}}:{...K,[f]:n}),relationships:w.relationships};m(v)},[S,s,m]);a.useEffect(()=>{const f=x.current;if(!f)return;const n=w=>{const v=w.target.tagName;if(v==="INPUT"||v==="TEXTAREA"||v==="SELECT")return;const K=w.ctrlKey||w.metaKey;K&&w.key==="z"?(w.preventDefault(),s.undo()):K&&(w.key==="y"||w.shiftKey&&w.key==="Z")?(w.preventDefault(),s.redo()):K&&w.key==="c"?(w.preventDefault(),$()):K&&w.key==="v"?(w.preventDefault(),J()):(w.key==="Delete"||w.key==="Backspace")&&g.count>0?(w.preventDefault(),j()):w.key==="Escape"&&(g.clearSelection(),D(null),W(null))};return f.addEventListener("keydown",n),()=>f.removeEventListener("keydown",n)},[s,$,J,j,g]);const et=d.map(f=>({id:f.id,x:f.position.x,y:f.position.y,width:240,height:40+f.fields.length*24,color:f.color,selected:g.isSelected(f.id)}));return e.jsxs("div",{ref:x,tabIndex:0,className:at("flex h-full w-full border rounded-lg overflow-hidden bg-background",h),children:[e.jsxs("div",{className:"flex flex-col flex-1 min-w-0",children:[e.jsxs("div",{role:"toolbar","aria-label":"Designer toolbar",className:"flex items-center gap-2 p-2 border-b bg-muted/20 flex-wrap",children:[e.jsx(rt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:"Data Model Designer"}),e.jsxs("div",{className:"flex items-center gap-1 ml-2 border-l pl-2",children:[e.jsx("button",{onClick:()=>s.undo(),disabled:!s.canUndo,"aria-label":"Undo",title:"Undo (Ctrl+Z)",className:"p-1 rounded hover:bg-accent disabled:opacity-40",children:e.jsx(Ne,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>s.redo(),disabled:!s.canRedo,"aria-label":"Redo",title:"Redo (Ctrl+Y)",className:"p-1 rounded hover:bg-accent disabled:opacity-40",children:e.jsx(we,{className:"h-3.5 w-3.5"})})]}),e.jsxs("div",{className:"flex items-center gap-1 border-l pl-2",children:[e.jsx("button",{onClick:I.zoomOut,"aria-label":"Zoom Out",title:"Zoom Out",className:"p-1 rounded hover:bg-accent",children:e.jsx(Et,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"text-xs tabular-nums w-10 text-center",children:[Math.round(I.zoom*100),"%"]}),e.jsx("button",{onClick:I.zoomIn,"aria-label":"Zoom In",title:"Zoom In",className:"p-1 rounded hover:bg-accent",children:e.jsx(It,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:I.resetZoom,"aria-label":"Reset Zoom",title:"Reset Zoom",className:"p-1 rounded hover:bg-accent",children:e.jsx(Pt,{className:"h-3 w-3"})})]}),!l&&e.jsxs("div",{className:"flex items-center gap-1 border-l pl-2",children:[e.jsx("button",{onClick:$,disabled:g.count===0,"aria-label":"Copy",title:"Copy (Ctrl+C)",className:"p-1 rounded hover:bg-accent disabled:opacity-40",children:e.jsx(Ue,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:J,disabled:!M.hasContent,"aria-label":"Paste",title:"Paste (Ctrl+V)",className:"p-1 rounded hover:bg-accent disabled:opacity-40",children:e.jsx(ze,{className:"h-3.5 w-3.5"})})]}),!l&&e.jsxs("button",{onClick:U,"aria-label":"Auto Layout",title:"Auto Layout",className:"flex items-center gap-1 px-2 py-1 text-xs rounded border hover:bg-accent",children:[e.jsx(Jt,{className:"h-3 w-3"})," Auto Layout"]}),e.jsx("div",{className:"flex-1"}),L?.isConnected&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",role:"status","aria-label":"Collaboration active",children:[e.jsx(qt,{className:"h-3 w-3"}),e.jsxs("span",{children:[L.users.length," user",L.users.length!==1?"s":""]})]}),g.count>1&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[g.count," selected"]}),!l&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:X,"aria-label":"Add Entity",className:"flex items-center gap-1 px-2 py-1 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90",children:[e.jsx(ve,{className:"h-3 w-3"})," Add Entity"]}),e.jsxs("button",{"aria-label":"Add Relationship",title:"Add Relationship (coming soon)",className:"flex items-center gap-1 px-2 py-1 text-xs rounded bg-secondary text-secondary-foreground hover:bg-secondary/80",children:[e.jsx(Qt,{className:"h-3 w-3"})," Add Relationship"]})]})]}),e.jsxs("div",{role:"region","aria-label":"Canvas",className:"flex-1 overflow-auto bg-muted/10 p-4 relative",onWheel:I.handleWheel,onMouseDown:I.startPan,onDragOver:ee,onDrop:se,children:[e.jsxs("div",{className:"relative",style:{width:p.width,minHeight:p.height,...I.transformStyle,backgroundImage:p.showGrid?"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)":void 0,backgroundSize:p.showGrid?"20px 20px":void 0},children:[e.jsx("svg",{className:"absolute inset-0 pointer-events-none",width:p.width,height:p.height,children:c.map(f=>{const n=d.find(v=>v.id===f.sourceEntity),w=d.find(v=>v.id===f.targetEntity);return!n||!w?null:e.jsxs("g",{children:[e.jsx("line",{x1:n.position.x+120,y1:n.position.y+50,x2:w.position.x+120,y2:w.position.y+50,stroke:"hsl(var(--primary))",strokeWidth:"2",strokeDasharray:f.type==="many-to-many"?"5,5":void 0}),i&&f.label&&e.jsx("text",{x:(n.position.x+w.position.x)/2+120,y:(n.position.y+w.position.y)/2+50-8,textAnchor:"middle",className:"text-xs fill-muted-foreground",children:f.label})]},f.id)})}),d.length===0&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-muted-foreground text-sm",children:"No entities in the model. Click 'Add Entity' to create your first entity."}),d.map(f=>e.jsxs("div",{role:"group","aria-label":f.label,draggable:!l,onDragStart:n=>q(n,f.id),className:at("absolute rounded-lg border-2 bg-background shadow-sm w-60 select-none cursor-grab active:cursor-grabbing",g.isSelected(f.id)?"border-primary ring-2 ring-primary/20":"border-border hover:border-primary/50"),style:{left:f.position.x,top:f.position.y},onClick:n=>g.toggle(f.id,n.shiftKey),children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-t-lg font-medium text-sm",style:{backgroundColor:f.color??"hsl(var(--primary) / 0.1)"},children:[e.jsx(rt,{className:"h-3.5 w-3.5"}),O===f.id?e.jsx("input",{type:"text",value:te,onChange:n=>re(n.target.value),onBlur:E,onKeyDown:n=>{n.key==="Enter"&&E(),n.key==="Escape"&&z()},className:"text-sm font-medium px-1 py-0 border rounded bg-background w-32 focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0,onClick:n=>n.stopPropagation(),"data-testid":`entity-label-input-${f.id}`}):e.jsx("span",{className:"truncate cursor-text",onDoubleClick:n=>{n.stopPropagation(),b(f.id,f.label)},title:"Double-click to edit label","data-testid":`entity-label-${f.id}`,children:f.label}),!l&&e.jsx("button",{onClick:n=>{n.stopPropagation(),V(f.id)},"aria-label":`Delete ${f.label}`,className:"ml-auto p-0.5 rounded hover:bg-destructive/20",children:e.jsx(me,{className:"h-3 w-3 text-destructive"})})]}),e.jsx("div",{className:"px-3 py-1 divide-y",children:f.fields.map((n,w)=>e.jsxs("div",{className:"flex items-center gap-2 py-1 text-xs",children:[y&&y.entityId===f.id&&y.fieldIndex===w?e.jsx("input",{type:"text",value:T,onChange:v=>Y(v.target.value),onBlur:Z,onKeyDown:v=>{v.key==="Enter"&&Z(),v.key==="Escape"&&R()},className:"font-mono text-xs px-1 py-0 border rounded bg-background w-24 focus:outline-none focus:ring-1 focus:ring-primary",autoFocus:!0,onClick:v=>v.stopPropagation()}):e.jsxs("span",{className:at("font-mono cursor-text",n.primaryKey&&"font-bold text-primary"),onClick:v=>{v.stopPropagation(),P(f.id,w,n.name)},title:"Click to edit field name",children:[n.primaryKey&&e.jsx("span",{className:"text-[0.65rem] font-semibold text-primary mr-0.5",children:"PK"}),n.name]}),l?e.jsx("span",{className:"text-muted-foreground ml-auto",children:n.type}):e.jsx("select",{value:n.type,onChange:v=>{v.stopPropagation(),B(f.id,w,v.target.value)},onClick:v=>v.stopPropagation(),className:"text-xs text-muted-foreground ml-auto bg-transparent border-none focus:ring-1 focus:ring-primary rounded cursor-pointer p-0","data-testid":`field-type-${f.id}-${w}`,children:Ta.map(v=>e.jsx("option",{value:v,children:v},v))}),n.required&&e.jsx("span",{className:"text-destructive",children:"*"})]},`${n.name}-${w}`))}),!l&&e.jsx("div",{className:"px-3 py-1 border-t",children:e.jsxs("button",{onClick:n=>{n.stopPropagation(),ae(f.id)},"aria-label":`Add field to ${f.label}`,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground w-full py-0.5",children:[e.jsx(ve,{className:"h-3 w-3"})," Add Field"]})})]},f.id))]}),N&&d.length>0&&e.jsx(gt,{items:et,canvasWidth:p.width,canvasHeight:p.height,position:"bottom-right",size:150})]})]}),e.jsxs("div",{className:"w-64 border-l flex flex-col bg-background shrink-0",children:[e.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[e.jsxs("button",{onClick:()=>H(f=>!f),className:"flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50 border-b","aria-expanded":A,"aria-controls":"property-editor-panel",children:[A?e.jsx(ue,{className:"h-3 w-3"}):e.jsx(Re,{className:"h-3 w-3"}),"Properties"]}),A&&e.jsx("div",{id:"property-editor-panel",className:"flex-1 overflow-y-auto",children:e.jsx(Xe,{title:ie?ie.label:"Properties",fields:Qe,onChange:Oe})})]}),e.jsx("div",{className:"border-t",children:e.jsxs("button",{onClick:()=>k(f=>!f),className:"flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50 w-full","aria-expanded":N,children:[N?e.jsx(ue,{className:"h-3 w-3"}):e.jsx(Re,{className:"h-3 w-3"}),"Minimap"]})})]}),e.jsx(Ye,{isOpen:C.isOpen,title:C.title,message:C.message,onConfirm:C.onConfirm,onCancel:C.onCancel,destructive:!0})]})}function Ae(...t){return le(oe(t))}const ke=120,Pe=50;function Aa(t,r){if(t.length===0)return t;const p=200,i=100,l=new Map,u=new Map;for(const c of t)l.set(c.id,0),u.set(c.id,[]);for(const c of r)l.set(c.target,(l.get(c.target)??0)+1),u.get(c.source)?.push(c.target);const o=[],h=new Set;let x=t.filter(c=>(l.get(c.id)??0)===0).map(c=>c.id);for(x.length===0&&(x=[t[0].id]);x.length>0;){o.push(x);for(const m of x)h.add(m);const c=new Set;for(const m of x)for(const C of u.get(m)??[])h.has(C)||c.add(C);x=Array.from(c)}const s=t.filter(c=>!h.has(c.id)).map(c=>c.id);s.length>0&&o.push(s);const d=new Map;for(let c=0;c<o.length;c++){const m=o[c];for(let C=0;C<m.length;C++)d.set(m[C],{x:80+c*p,y:80+C*i})}return t.map(c=>({...c,position:d.get(c.id)??c.position}))}function La({processName:t="New Process",nodes:r=[],edges:p=[],lanes:i,canvas:l={width:1400,height:800,showGrid:!0},showMinimap:u=!0,showToolbar:o=!0,readOnly:h=!1,onNodesChange:x,onEdgesChange:s,className:d}){const c=Ce({nodes:r,edges:p},{maxHistory:50}),m=c.current.nodes,C=c.current.edges,g=a.useCallback((n,w)=>{c.push({nodes:n,edges:w}),x?.(n),s?.(w)},[c,x,s]),S=Me(),M=_e(),I=Ze(),L=xt({initialZoom:1}),A=qe(),[H,N]=a.useState(null),[k,y]=a.useState(!1),[D,T]=a.useState(null),[Y,O]=a.useState(null),[W,te]=a.useState(!0),[re,F]=a.useState(null),[X,V]=a.useState({x:0,y:0}),j=a.useRef(null),U=a.useRef(x),$=a.useRef(s);U.current=x,$.current=s,a.useEffect(()=>{U.current?.(m),$.current?.(C)},[c.current]);const J=a.useCallback((n,w)=>{if(h)return;const v={id:`node-${Date.now()}`,type:n,label:w,position:{x:200+m.length*160,y:200}},K=[...m,v];g(K,C),N(v.id),M.selectOne(v.id),A?.sendOperation({type:"insert",elementId:v.id,data:{label:w},userId:A.currentUserId??""})},[m,C,h,g,M,A]),ae=a.useCallback(async n=>{if(h)return;const w=m.find(Q=>Q.id===n);if(!await S.confirm("Delete Node",`Are you sure you want to delete "${w?.label??n}"? This will also remove all connected edges.`))return;const K=m.filter(Q=>Q.id!==n),_=C.filter(Q=>Q.source!==n&&Q.target!==n);g(K,_),H===n&&N(null),M.clearSelection(),A?.sendOperation({type:"delete",elementId:n,data:{},userId:A.currentUserId??""})},[m,C,H,h,g,S,M,A]),P=a.useCallback(async()=>{if(h||M.count===0||!await S.confirm("Delete Selected Nodes",`Are you sure you want to delete ${M.count} selected node(s) and their connected edges?`))return;const w=M.selectedIds,v=m.filter(_=>!w.has(_.id)),K=C.filter(_=>!w.has(_.source)&&!w.has(_.target));g(v,K),N(null),M.clearSelection()},[m,C,h,g,S,M]),Z=a.useCallback(()=>{const n=M.count>0?M.selectedIds:H?new Set([H]):new Set;if(n.size===0)return;const w=m.filter(v=>n.has(v.id));I.copy(w)},[m,H,M,I]),R=a.useCallback(()=>{if(h)return;const n=I.paste();if(!n||n.length===0)return;const w=40,v=n.map(_=>({..._,id:`node-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,position:{x:_.position.x+w,y:_.position.y+w}})),K=[...m,...v];g(K,C),M.selectMany(v.map(_=>_.id)),N(v[0].id)},[h,m,C,I,g,M]),b=a.useCallback(()=>{y(n=>n?(T(null),!1):!0)},[]),E=a.useCallback(n=>{if(!k)return!1;if(!D)return T(n),!0;if(D===n)return!0;const w={id:`edge-${Date.now()}`,source:D,target:n},v=[...C,w];return g(m,v),T(null),y(!1),A?.sendOperation({type:"insert",elementId:w.id,data:{source:D,target:n},userId:A.currentUserId??""}),!0},[k,D,m,C,g,A]),z=a.useCallback(()=>{if(h||m.length===0)return;const n=Aa(m,C);g(n,C)},[m,C,h,g]),B=a.useCallback((n,w)=>{if(h||!m.find(_=>_.id===w))return;F(w);const K=n.target.getBoundingClientRect();V({x:n.clientX-K.left,y:n.clientY-K.top}),n.dataTransfer.effectAllowed="move",n.dataTransfer.setData("text/plain",w)},[h,m]),q=a.useCallback(n=>{if(n.preventDefault(),h||!re)return;const w=n.currentTarget.getBoundingClientRect(),v=L.zoom,K=(n.clientX-w.left-L.panOffset.x)/v-X.x,_=(n.clientY-w.top-L.panOffset.y)/v-X.y,Q=Math.max(0,Math.round(K/20)*20),de=Math.max(0,Math.round(_/20)*20),he=m.map(fe=>fe.id===re?{...fe,position:{x:Q,y:de}}:fe);g(he,C),F(null)},[h,re,X,m,C,L.zoom,L.panOffset,g]),ee=a.useCallback(n=>{n.preventDefault(),n.dataTransfer.dropEffect="move"},[]),se=a.useMemo(()=>m.find(n=>n.id===H)??null,[m,H]),ie=a.useMemo(()=>se?[{name:"label",label:"Name",type:"text",value:se.label,group:"General"},{name:"type",label:"Type",type:"select",value:se.type,options:[{label:"Start Event",value:"start-event"},{label:"End Event",value:"end-event"},{label:"User Task",value:"user-task"},{label:"Service Task",value:"service-task"},{label:"Script Task",value:"script-task"},{label:"Exclusive Gateway",value:"exclusive-gateway"},{label:"Parallel Gateway",value:"parallel-gateway"},{label:"Inclusive Gateway",value:"inclusive-gateway"}],group:"General"},{name:"description",label:"Description",type:"textarea",value:se.description??"",group:"General"}]:[],[se]),Qe=a.useCallback((n,w)=>{if(h||!H)return;const v=m.map(K=>K.id===H?{...K,[n]:w}:K);g(v,C)},[h,H,m,C,g]),Oe=n=>{switch(n){case"start-event":return"rounded-full bg-green-100 border-green-500 text-green-700";case"end-event":return"rounded-full bg-red-100 border-red-500 text-red-700";case"exclusive-gateway":case"parallel-gateway":case"inclusive-gateway":case"event-based-gateway":return"rotate-45 bg-yellow-100 border-yellow-500 text-yellow-700";case"user-task":return"rounded bg-blue-100 border-blue-500 text-blue-700";case"service-task":case"script-task":return"rounded bg-purple-100 border-purple-500 text-purple-700";default:return"rounded bg-gray-100 border-gray-500 text-gray-700"}},et=a.useMemo(()=>m.map(n=>({id:n.id,x:n.position.x,y:n.position.y,width:ke,height:Pe,selected:M.isSelected(n.id)||n.id===H})),[m,M,H]);a.useEffect(()=>{const n=j.current;if(!n)return;const w=v=>{const K=v.target?.tagName;if(K==="INPUT"||K==="TEXTAREA"||K==="SELECT")return;const _=v.ctrlKey||v.metaKey;if(_&&v.key==="z"&&!v.shiftKey){v.preventDefault(),c.undo();return}if(_&&v.key==="y"||_&&v.key==="z"&&v.shiftKey){v.preventDefault(),c.redo();return}if(_&&v.key==="c"){v.preventDefault(),Z();return}if(_&&v.key==="v"){v.preventDefault(),R();return}if(v.key==="Delete"||v.key==="Backspace"){M.count>0?(v.preventDefault(),P()):H&&(v.preventDefault(),ae(H));return}if(v.key==="Escape"){k?(y(!1),T(null)):(N(null),M.clearSelection());return}};return n.addEventListener("keydown",w),()=>n.removeEventListener("keydown",w)},[H,k,M,c,Z,R,ae,P]);const f=a.useCallback(n=>{n.target===n.currentTarget&&(N(null),M.clearSelection(),k&&(y(!1),T(null)))},[k,M]);return e.jsxs("div",{ref:j,tabIndex:0,className:Ae("flex flex-col h-full w-full border rounded-lg overflow-hidden bg-background",d),children:[e.jsx(Ye,{isOpen:S.isOpen,title:S.title,message:S.message,onConfirm:S.onConfirm,onCancel:S.onCancel,destructive:!0}),o&&e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/20",role:"toolbar","aria-label":"Process toolbar",children:[e.jsx(Ot,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm","aria-label":"Process name",children:t}),A?.isConnected&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",role:"status","aria-label":"Collaboration active",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-green-500"}),A.users.length," user",A.users.length!==1?"s":""]}),e.jsx("div",{className:"flex-1"}),!h&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>c.undo(),disabled:!c.canUndo,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40",title:"Undo (Ctrl+Z)","aria-label":"Undo",children:e.jsx(Ne,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>c.redo(),disabled:!c.canRedo,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40",title:"Redo (Ctrl+Y)","aria-label":"Redo",children:e.jsx(we,{className:"h-3 w-3"})}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsx("button",{onClick:Z,disabled:M.count===0&&!H,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40",title:"Copy (Ctrl+C)","aria-label":"Copy",children:e.jsx(Ue,{className:"h-3 w-3"})}),e.jsx("button",{onClick:R,disabled:!I.hasContent,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent disabled:opacity-40",title:"Paste (Ctrl+V)","aria-label":"Paste",children:e.jsx(ze,{className:"h-3 w-3"})}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsxs("button",{onClick:b,className:Ae("flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",k&&"bg-primary text-primary-foreground"),title:"Connect nodes","aria-label":"Connect nodes","aria-pressed":k,children:[e.jsx(it,{className:"h-3 w-3"})," Connect"]}),e.jsxs("button",{onClick:z,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Auto layout","aria-label":"Auto layout",children:[e.jsx(Tt,{className:"h-3 w-3"})," Layout"]}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsx("button",{onClick:L.zoomIn,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Zoom in","aria-label":"Zoom in",children:e.jsx(It,{className:"h-3 w-3"})}),e.jsxs("span",{className:"text-xs tabular-nums min-w-[3ch] text-center","aria-label":"Zoom level",children:[Math.round(L.zoom*100),"%"]}),e.jsx("button",{onClick:L.zoomOut,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Zoom out","aria-label":"Zoom out",children:e.jsx(Et,{className:"h-3 w-3"})}),e.jsx("button",{onClick:L.resetZoom,className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Reset zoom","aria-label":"Reset zoom",children:e.jsx(Pt,{className:"h-3 w-3"})}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsxs("button",{onClick:()=>J("start-event","Start"),className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Add Start Event","aria-label":"Add Start Event",children:[e.jsx(ea,{className:"h-3 w-3 text-green-600"})," Start"]}),e.jsxs("button",{onClick:()=>J("user-task","User Task"),className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Add User Task","aria-label":"Add User Task",children:[e.jsx(bt,{className:"h-3 w-3 text-blue-600"})," Task"]}),e.jsxs("button",{onClick:()=>J("exclusive-gateway","Decision"),className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Add Gateway","aria-label":"Add Gateway",children:[e.jsx(ta,{className:"h-3 w-3 text-yellow-600"})," Gateway"]}),e.jsxs("button",{onClick:()=>J("end-event","End"),className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Add End Event","aria-label":"Add End Event",children:[e.jsx(bt,{className:"h-3 w-3 text-red-600"})," End"]}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsx("button",{onClick:()=>te(n=>!n),className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:W?"Hide properties":"Show properties","aria-label":W?"Hide property panel":"Show property panel","aria-expanded":W,children:W?e.jsx(ot,{className:"h-3 w-3"}):e.jsx(aa,{className:"h-3 w-3"})})]})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsx("div",{className:"flex-1 overflow-auto bg-muted/10 p-4",role:"region","aria-label":"Process canvas",onWheel:L.handleWheel,onMouseDown:L.startPan,children:e.jsxs("div",{className:"relative",style:{...L.transformStyle,width:l.width,minHeight:l.height,backgroundImage:l.showGrid?"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)":void 0,backgroundSize:l.showGrid?"20px 20px":void 0},onClick:f,onDrop:q,onDragOver:ee,children:[e.jsxs("svg",{className:"absolute inset-0 pointer-events-none",width:l.width,height:l.height,children:[e.jsx("defs",{children:e.jsx("marker",{id:"arrowhead",markerWidth:"10",markerHeight:"7",refX:"10",refY:"3.5",orient:"auto",children:e.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"hsl(var(--foreground))"})})}),C.map(n=>{const w=m.find(tt=>tt.id===n.source),v=m.find(tt=>tt.id===n.target);if(!w||!v)return null;w.position.x+ke/2;const K=w.position.y+Pe/2;v.position.x+ke/2;const _=v.position.y+Pe/2,Q=w.position.x+ke,de=K,he=v.position.x,fe=_,Bt=(Q+he)/2,Vt=`M ${Q} ${de} Q ${Bt} ${de}, ${(Q+he)/2} ${(de+fe)/2} T ${he} ${fe}`;return e.jsxs("g",{children:[e.jsx("path",{d:Vt,fill:"none",stroke:"hsl(var(--foreground) / 0.5)",strokeWidth:"2",markerEnd:"url(#arrowhead)"}),n.label&&e.jsx("text",{x:(Q+he)/2,y:(de+fe)/2-8,textAnchor:"middle",className:"text-[10px] fill-muted-foreground",children:n.label})]},n.id)})]}),m.length===0&&e.jsx("div",{className:"flex items-center justify-center h-full min-h-[200px] text-muted-foreground text-sm",children:"No nodes in the process. Use the toolbar buttons to add start events, tasks, gateways, and end events."}),m.map(n=>{const w=M.isSelected(n.id)||H===n.id,v=D===n.id,K=Y===n.id,_=k||K;return e.jsxs("div",{className:"absolute select-none",style:{left:n.position.x,top:n.position.y},role:"group","aria-label":n.label,draggable:!h&&!k,onDragStart:Q=>B(Q,n.id),onMouseEnter:()=>O(n.id),onMouseLeave:()=>O(null),onClick:Q=>{E(n.id)||(Q.shiftKey?M.toggle(n.id,!0):(N(n.id),M.selectOne(n.id)))},children:[e.jsx("div",{className:Ae("flex items-center justify-center border-2 min-w-[120px] min-h-[50px] px-3 py-2 transition-shadow",Oe(n.type),w&&"ring-2 ring-primary shadow-md",v&&"ring-2 ring-blue-400 shadow-lg",k&&!v&&"cursor-crosshair"),children:e.jsx("span",{className:Ae("text-xs font-medium",(n.type==="exclusive-gateway"||n.type==="parallel-gateway"||n.type==="inclusive-gateway"||n.type==="event-based-gateway")&&"-rotate-45"),children:n.label})}),_&&!h&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute w-3 h-3 rounded-full bg-blue-500 border-2 border-white shadow cursor-crosshair",style:{left:-6,top:Pe/2-6},title:"Input port",onClick:Q=>{Q.stopPropagation(),E(n.id)}}),e.jsx("div",{className:"absolute w-3 h-3 rounded-full bg-blue-500 border-2 border-white shadow cursor-crosshair",style:{right:-6,top:Pe/2-6},title:"Output port",onClick:Q=>{Q.stopPropagation(),k?E(n.id):(y(!0),T(n.id))}}),e.jsx("div",{className:"absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair",style:{left:ke/2-6,top:-6},title:"Port",onClick:Q=>{Q.stopPropagation(),E(n.id)}}),e.jsx("div",{className:"absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair",style:{left:ke/2-6,bottom:-6},title:"Port",onClick:Q=>{Q.stopPropagation(),E(n.id)}})]}),!h&&w&&!k&&e.jsx("button",{onClick:Q=>{Q.stopPropagation(),ae(n.id)},className:"absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow","aria-label":"Delete node",children:e.jsx(me,{className:"h-3 w-3"})})]},n.id)}),u&&m.length>0&&e.jsx(gt,{items:et,canvasWidth:l.width??1400,canvasHeight:l.height??800,position:"bottom-right"})]})}),W&&!h&&e.jsx("div",{className:"w-64 border-l bg-background overflow-y-auto flex-shrink-0",role:"complementary","aria-label":"Property panel",children:e.jsx(Xe,{title:se?`Properties: ${se.label}`:"Properties",fields:ie,onChange:Qe})})]})]})}function ge(...t){return le(oe(t))}const G={untitledReport:"Untitled Report",reportCanvas:"Report canvas",properties:"Properties",propertiesPanel:"Properties panel",designerToolbar:"Report designer toolbar",selectElementPrompt:"Select an element to edit its properties",addElementsPrompt:"Add elements using the buttons above",addText:"Add Text",addField:"Add Field",addImage:"Add Image",addChart:"Add Chart",addTable:"Add Table",undo:"Undo",undoShortcut:"Undo (Ctrl+Z)",redo:"Redo",redoShortcut:"Redo (Ctrl+Shift+Z)",copy:"Copy",copyShortcut:"Copy (Ctrl+C)",paste:"Paste",pasteShortcut:"Paste (Ctrl+V)",deleteSelected:"Delete selected",deleteElement:"Delete element",deleteElementsTitle:"Delete elements",deleteElementMessage:t=>`Are you sure you want to delete ${t} element${t>1?"s":""}?`,collapsePanel:"Collapse panel",expandPanel:"Expand panel",collaborationConnected:"Connected",sectionHeader:"Report Header",sectionPageHeader:"Page Header",sectionGroupHeader:"Group Header",sectionDetail:"Detail",sectionGroupFooter:"Group Footer",sectionPageFooter:"Page Footer",sectionFooter:"Report Footer",elementText:"Text",elementImage:"🖼 Image",elementChart:"📊 Chart",elementTable:"📋 Table",propLabel:"Label",propX:"X",propY:"Y",propWidth:"Width",propHeight:"Height",propText:"Text",propField:"Field",groupPosition:"Position",groupSize:"Size",groupContent:"Content",groupGeneral:"General"},$a={A4:{width:595,height:842},A3:{width:842,height:1191},Letter:{width:612,height:792},Legal:{width:612,height:1008},Tabloid:{width:792,height:1224}},Fa=[{type:"header",height:80,elements:[]},{type:"detail",height:400,elements:[],repeat:!0},{type:"footer",height:60,elements:[]}];function Ua({reportName:t=G.untitledReport,objectName:r,pageSize:p="A4",orientation:i="portrait",margins:l={top:40,right:40,bottom:40,left:40},sections:u=[],showToolbar:o=!0,showPropertyPanel:h=!0,readOnly:x=!1,onSectionsChange:s,className:d}){const c=Ce(u.length>0?u:Fa),m=c.current,C=a.useCallback(P=>{c.push(P),s?.(P)},[c,s]),g=_e(),S=a.useMemo(()=>{const P=Array.from(g.selectedIds);return P.length>0?P[0]:null},[g.selectedIds]),M=Ze(),I=Me(),L=qe(),A=a.useCallback(P=>{L&&L.sendOperation({...P,userId:L.currentUserId??""})},[L]),[H,N]=a.useState(!0),k=a.useRef(null),y=a.useRef(null),D=$a[p],T=i==="landscape"?D.height:D.width,Y=i==="landscape"?D.width:D.height,O=P=>{switch(P){case"header":return G.sectionHeader;case"page-header":return G.sectionPageHeader;case"group-header":return G.sectionGroupHeader;case"detail":return G.sectionDetail;case"group-footer":return G.sectionGroupFooter;case"page-footer":return G.sectionPageFooter;case"footer":return G.sectionFooter;default:return P}},W=a.useMemo(()=>S?m.flatMap(P=>P.elements).find(P=>P.id===S):null,[S,m]),te=a.useCallback((P,Z)=>{if(x)return;const R={id:`elem-${Date.now()}`,type:Z,position:{x:l.left,y:10,width:200,height:30},properties:{text:Z==="text"?"New Text":void 0,field:Z==="field"?"field_name":void 0}},b=m.map((E,z)=>z===P?{...E,elements:[...E.elements,R]}:E);C(b),g.selectOne(R.id),A({type:"insert",elementId:R.id,data:{element:R}})},[m,l.left,x,C,g,A]),re=a.useCallback(P=>{if(x)return;const Z=m.map(R=>({...R,elements:R.elements.filter(b=>b.id!==P)}));C(Z),g.isSelected(P)&&g.clearSelection(),A({type:"delete",elementId:P,data:{}})},[m,x,C,g,A]),F=a.useCallback(async()=>{if(x||g.count===0||!await I.confirm(G.deleteElementsTitle,G.deleteElementMessage(g.count)))return;const Z=g.selectedIds,R=m.map(b=>({...b,elements:b.elements.filter(E=>!Z.has(E.id))}));C(R),g.clearSelection(),Z.forEach(b=>{A({type:"delete",elementId:b,data:{}})})},[x,g,I,m,C,A]),X=a.useCallback((P,Z)=>{if(x||!S)return;const R=m.map(b=>({...b,elements:b.elements.map(E=>E.id!==S?E:P==="x"?{...E,position:{...E.position,x:Number(Z)}}:P==="y"?{...E,position:{...E.position,y:Number(Z)}}:P==="width"?{...E,position:{...E.position,width:Number(Z)}}:P==="height"?{...E,position:{...E.position,height:Number(Z)}}:{...E,properties:{...E.properties,[P]:Z}})}));C(R),A({type:"update",elementId:S,data:{[P]:Z}})},[x,S,m,C,A]),V=a.useCallback(()=>{const P=g.selectedIds;if(P.size===0)return;const R=m.flatMap(b=>b.elements).filter(b=>P.has(b.id));M.copy(R)},[g,m,M]),j=a.useCallback(()=>{if(x)return;const P=M.paste();if(!P||P.length===0)return;let Z=0;const R=P.map(B=>({...B,id:`elem-${Date.now()}-${++Z}-${Math.random().toString(36).slice(2,7)}`,position:{...B.position,x:B.position.x+20,y:B.position.y+20}})),b=m.findIndex(B=>B.type==="detail"),E=b>=0?b:0,z=m.map((B,q)=>q===E?{...B,elements:[...B.elements,...R]}:B);C(z),g.selectMany(R.map(B=>B.id)),R.forEach(B=>{A({type:"insert",elementId:B.id,data:{element:B}})})},[x,M,m,C,g,A]),U=a.useCallback((P,Z,R)=>{x||(k.current={id:Z.id,sectionIndex:R,startX:P.clientX,startY:P.clientY},P.dataTransfer.effectAllowed="move",P.dataTransfer.setData("text/plain",Z.id))},[x]),$=a.useCallback(P=>{P.preventDefault(),P.dataTransfer.dropEffect="move"},[]),J=a.useCallback((P,Z)=>{P.preventDefault();const R=k.current;if(!R||x)return;const b=P.clientX-R.startX,E=P.clientY-R.startY;if(R.sectionIndex===Z){const z=m.map((B,q)=>q!==Z?B:{...B,elements:B.elements.map(ee=>ee.id!==R.id?ee:{...ee,position:{...ee.position,x:Math.max(0,ee.position.x+b),y:Math.max(0,(typeof ee.position.y=="number"?ee.position.y:0)+E)}})});C(z)}else{let z=null;const B=m.map((q,ee)=>{if(ee!==R.sectionIndex)return q;const se=q.elements.find(ie=>ie.id===R.id);return se&&(z={...se,position:{...se.position,x:Math.max(0,se.position.x+b),y:Math.max(0,10)}}),{...q,elements:q.elements.filter(ie=>ie.id!==R.id)}});if(z){const q=B.map((ee,se)=>se!==Z?ee:{...ee,elements:[...ee.elements,z]});C(q)}}A({type:"move",elementId:R.id,data:{}}),k.current=null},[x,m,C,A]),ae=a.useMemo(()=>{if(!W)return[];const P=[{name:"x",label:G.propX,type:"number",value:W.position.x,group:G.groupPosition},{name:"y",label:G.propY,type:"number",value:W.position.y,group:G.groupPosition},{name:"width",label:G.propWidth,type:"number",value:W.position.width,group:G.groupSize},{name:"height",label:G.propHeight,type:"number",value:W.position.height,group:G.groupSize}];return W.type==="text"&&P.push({name:"text",label:G.propText,type:"text",value:W.properties.text??"",group:G.groupContent}),W.type==="field"&&P.push({name:"field",label:G.propField,type:"text",value:W.properties.field??"",group:G.groupContent}),P},[W]);return a.useEffect(()=>{const P=y.current;if(!P)return;const Z=R=>{const b=["INPUT","TEXTAREA","SELECT"].includes(R.target.tagName),E=R.ctrlKey||R.metaKey;if((R.key==="Delete"||R.key==="Backspace")&&g.count>0&&!b){R.preventDefault(),F();return}if(R.key==="Escape"){g.clearSelection();return}if(!b){if(E&&R.key==="z"&&!R.shiftKey&&!x){R.preventDefault(),c.undo();return}if(E&&(R.key==="z"&&R.shiftKey||R.key==="y")&&!x){R.preventDefault(),c.redo();return}if(E&&R.key==="c"){R.preventDefault(),V();return}if(E&&R.key==="v"&&!x){R.preventDefault(),j();return}if(E&&R.key==="a"){R.preventDefault();const z=m.flatMap(B=>B.elements).map(B=>B.id);g.selectMany(z);return}}};return P.addEventListener("keydown",Z),()=>P.removeEventListener("keydown",Z)},[g,F,x,c,V,j,m]),e.jsxs("div",{ref:y,tabIndex:0,className:ge("flex h-full w-full border rounded-lg overflow-hidden bg-background",d),children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[o&&e.jsxs("div",{role:"toolbar","aria-label":G.designerToolbar,className:"flex items-center gap-2 p-2 border-b bg-muted/20",children:[e.jsx(dt,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:t}),r&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",r,")"]}),!x&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-5 bg-border mx-1"}),e.jsx("button",{className:ge("p-1.5 rounded hover:bg-accent",!c.canUndo&&"opacity-40 pointer-events-none"),title:G.undoShortcut,"aria-label":G.undo,disabled:!c.canUndo,onClick:()=>c.undo(),children:e.jsx(Ne,{className:"h-4 w-4"})}),e.jsx("button",{className:ge("p-1.5 rounded hover:bg-accent",!c.canRedo&&"opacity-40 pointer-events-none"),title:G.redoShortcut,"aria-label":G.redo,disabled:!c.canRedo,onClick:()=>c.redo(),children:e.jsx(we,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),!x&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:ge("p-1.5 rounded hover:bg-accent",g.count===0&&"opacity-40 pointer-events-none"),title:G.copyShortcut,"aria-label":G.copy,disabled:g.count===0,onClick:V,children:e.jsx(Ue,{className:"h-4 w-4"})}),e.jsx("button",{className:ge("p-1.5 rounded hover:bg-accent",!M.hasContent&&"opacity-40 pointer-events-none"),title:G.pasteShortcut,"aria-label":G.paste,disabled:!M.hasContent,onClick:j,children:e.jsx(ze,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),!x&&e.jsx("button",{className:ge("p-1.5 rounded hover:bg-accent",g.count===0&&"opacity-40 pointer-events-none"),title:G.deleteSelected,"aria-label":G.deleteSelected,disabled:g.count===0,onClick:F,children:e.jsx(me,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),L?.isConnected&&e.jsxs("span",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-full bg-green-500"}),G.collaborationConnected,L.users.length>1&&` (${L.users.length})`]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p," ",i]}),h&&e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:H?G.collapsePanel:G.expandPanel,"aria-label":H?G.collapsePanel:G.expandPanel,onClick:()=>N(P=>!P),children:e.jsx(ot,{className:ge("h-4 w-4",!H&&"rotate-180")})})]}),e.jsx("div",{role:"region","aria-label":G.reportCanvas,className:"flex-1 overflow-auto bg-muted/10 p-4 flex justify-center",children:e.jsx("div",{className:"bg-white shadow-lg border",style:{width:T,minHeight:Y},children:m.map((P,Z)=>e.jsxs("div",{className:"relative border-b border-dashed border-gray-300",style:{minHeight:P.height},onDragOver:$,onDrop:R=>J(R,Z),children:[e.jsxs("div",{className:"absolute left-0 top-0 px-2 py-0.5 bg-muted text-xs text-muted-foreground border-r border-b rounded-br",children:[O(P.type),P.repeat&&" ↻"]}),!x&&e.jsxs("div",{className:"absolute right-1 top-0 flex items-center gap-0.5",children:[e.jsx("button",{onClick:()=>te(Z,"text"),className:"p-0.5 rounded hover:bg-accent",title:G.addText,"aria-label":G.addText,children:e.jsx(Rt,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>te(Z,"field"),className:"p-0.5 rounded hover:bg-accent",title:G.addField,"aria-label":G.addField,children:e.jsx(ve,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>te(Z,"image"),className:"p-0.5 rounded hover:bg-accent",title:G.addImage,"aria-label":G.addImage,children:e.jsx(ct,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>te(Z,"chart"),className:"p-0.5 rounded hover:bg-accent",title:G.addChart,"aria-label":G.addChart,children:e.jsx(Ge,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>te(Z,"table"),className:"p-0.5 rounded hover:bg-accent",title:G.addTable,"aria-label":G.addTable,children:e.jsx(pt,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"relative",style:{minHeight:P.height,paddingTop:24},children:[P.elements.length===0&&e.jsx("div",{className:"text-xs text-muted-foreground text-center pt-4",children:G.addElementsPrompt}),P.elements.map(R=>{const b=g.isSelected(R.id);return e.jsxs("div",{draggable:!x,onDragStart:E=>U(E,R,Z),className:ge("absolute border rounded px-2 py-1 text-xs cursor-pointer",b?"border-primary ring-1 ring-primary/30 bg-primary/5":"border-dashed border-gray-400 hover:border-primary/50"),style:{left:R.position.x,top:(typeof R.position.y=="number"?R.position.y:0)+24,width:R.position.width,height:R.position.height},onClick:E=>g.toggle(R.id,E.shiftKey),children:[e.jsxs("span",{className:"text-muted-foreground",children:[R.type==="text"&&(R.properties.text??G.elementText),R.type==="field"&&`{${R.properties.field??"field"}}`,R.type==="image"&&G.elementImage,R.type==="chart"&&G.elementChart,R.type==="table"&&G.elementTable]}),!x&&b&&e.jsx("button",{onClick:E=>{E.stopPropagation(),re(R.id)},className:"absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow","aria-label":G.deleteElement,children:e.jsx(me,{className:"h-2.5 w-2.5"})})]},R.id)})]})]},`${P.type}-${Z}`))})})]}),h&&e.jsx("div",{role:"region","aria-label":G.propertiesPanel,className:ge("border-l bg-muted/30 flex flex-col transition-[width] duration-200",H?"w-56":"w-0 overflow-hidden"),children:H&&(S&&W?e.jsx(Xe,{title:`${G.properties} – ${W.type}`,fields:ae,onChange:X}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-3 border-b font-medium text-sm",children:G.properties}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:e.jsx("div",{className:"text-xs text-muted-foreground text-center py-4",children:G.selectElementPrompt})})]}))}),e.jsx(Ye,{isOpen:I.isOpen,title:I.title,message:I.message,onConfirm:I.onConfirm,onCancel:I.onCancel})]})}const ht={"appDesigner.basicInfo":"Basic Info","appDesigner.objects":"Objects","appDesigner.navigation":"Navigation","appDesigner.branding":"Branding","appDesigner.stepBasicDesc":"Name, title, and layout","appDesigner.stepObjectsDesc":"Select business objects","appDesigner.stepNavigationDesc":"Build navigation tree","appDesigner.stepBrandingDesc":"Logo, colors, and favicon","appDesigner.appName":"App Name","appDesigner.appTitle":"Title","appDesigner.appDescription":"Description","appDesigner.appIcon":"Icon","appDesigner.template":"Template","appDesigner.layout":"Layout","appDesigner.layoutSidebar":"Sidebar","appDesigner.layoutHeader":"Header","appDesigner.layoutEmpty":"Empty","appDesigner.snakeCaseHint":"Must be snake_case (e.g. my_app)","appDesigner.searchObjects":"Search objects…","appDesigner.selectAll":"Select All","appDesigner.deselectAll":"Deselect All","appDesigner.noObjectsFound":"No objects found.","appDesigner.addGroup":"Add Group","appDesigner.addUrl":"Add URL","appDesigner.addSeparator":"Add Separator","appDesigner.noNavItemsHint":"No navigation items yet. Select objects in the previous step or add items manually.","appDesigner.separatorLabel":"— Separator —","appDesigner.newGroup":"New Group","appDesigner.newLink":"New Link","appDesigner.logoUrl":"Logo URL","appDesigner.primaryColor":"Primary Color","appDesigner.faviconUrl":"Favicon URL","appDesigner.preview":"Preview","common.cancel":"Cancel","common.back":"Back","common.next":"Next","common.close":"Close","appDesigner.complete":"Complete","appDesigner.saveDraft":"Save Draft","appDesigner.cancelConfirmTitle":"Discard changes?","appDesigner.cancelConfirmMessage":"You have unsaved changes. Are you sure you want to cancel?","appDesigner.confirmDiscard":"Discard","appDesigner.keepEditing":"Keep Editing","appDesigner.navNoItems":"No navigation items. Click buttons above to add items.","appDesigner.navNoPreviewItems":"No items","appDesigner.navLivePreview":"Live Preview","appDesigner.navCollapseGroup":"Collapse group","appDesigner.navExpandGroup":"Expand group","appDesigner.navAddChild":"Add child","appDesigner.navMoveUp":"Move up","appDesigner.navMoveDown":"Move down","appDesigner.navRemove":"Remove","appDesigner.navObjectPage":"Object Page","appDesigner.navDashboard":"Dashboard","appDesigner.navPage":"Page","appDesigner.navReport":"Report","appDesigner.navGroup":"Group","appDesigner.navUrl":"URL","appDesigner.navSeparator":"Separator","appDesigner.navTypeObject":"Object","appDesigner.navTypeDashboard":"Dashboard","appDesigner.navTypePage":"Page","appDesigner.navTypeReport":"Report","appDesigner.navTypeUrl":"URL","appDesigner.navTypeGroup":"Group","appDesigner.navTypeSeparator":"Separator","appDesigner.navTypeAction":"Action","appDesigner.navEditIcon":"Edit icon","appDesigner.navToggleVisible":"Toggle visibility","appDesigner.navHidden":"Hidden","appDesigner.navExportSchema":"Export JSON","appDesigner.navImportSchema":"Import JSON","appDesigner.navExportSuccess":"Navigation schema exported","appDesigner.navImportSuccess":"Navigation schema imported","appDesigner.navImportError":"Invalid navigation JSON","appDesigner.navIconPlaceholder":"Icon name (e.g. Users)","appDesigner.dashboardEditor":"Dashboard Editor","appDesigner.noWidgets":"No widgets. Click a button above to add one.","appDesigner.widgetLayoutSize":"Layout Size","appDesigner.widgetWidth":"Width","appDesigner.widgetHeight":"Height","appDesigner.dashboardPreview":"Dashboard Preview","appDesigner.noWidgetsPreview":"No widgets to preview","appDesigner.pageCanvasEditor":"Page Canvas Editor","appDesigner.emptyPage":"Empty page. Click a button above to add a component.","appDesigner.pagePreview":"Page Preview","appDesigner.noComponentsPreview":"No components to preview","appDesigner.modePage":"Page","appDesigner.modeDashboard":"Dashboard","appDesigner.undo":"Undo","appDesigner.redo":"Redo","appDesigner.brandingEditor":"Branding Editor","appDesigner.brandingExport":"Export JSON","appDesigner.brandingImport":"Import JSON","appDesigner.brandingPreview":"Preview","appDesigner.brandingSampleButton":"Sample Button","appDesigner.brandingSampleText":"This is how your brand theme will look.","appDesigner.colorPalette":"Color Palette","appDesigner.fontFamily":"Font Family","appDesigner.fontDefault":"Default (System)","appDesigner.modeLight":"Light","appDesigner.modeDark":"Dark","appDesigner.mobilePreview":"Mobile Preview"};function ft(t){return(r,p)=>{let i=t[r]||r;if(p)for(const[l,u]of Object.entries(p))i=i.replace(`{{${l}}}`,String(u));return i}}function be(){try{const t=ja();return t.t("appDesigner.basicInfo")==="appDesigner.basicInfo"?{t:ft(ht)}:{t:t.t}}catch{return{t:ft(ht)}}}function pe(...t){return le(oe(t))}const za={name:"",title:"",description:"",icon:"",template:"",layout:"sidebar",objects:[],navigation:[],branding:{logo:"",primaryColor:"#3b82f6",favicon:""}};function yt(t){return t.filter(r=>r.selected).map(r=>({id:r.name,type:"object",label:r.label,icon:r.icon,objectName:r.name}))}let vt=0;function Ka(t){return vt+=1,`${t}_${Date.now()}_${vt}`}function Ga({steps:t,currentIndex:r,onStepClick:p}){return e.jsx("nav",{className:"flex items-center justify-center gap-0 px-4 py-6",children:t.map((i,l)=>{const u=l<r,o=l===r;return e.jsxs(Wt.Fragment,{children:[l>0&&e.jsx("div",{className:pe("h-0.5 w-12 sm:w-20",u?"bg-blue-500":"bg-gray-200")}),e.jsxs("button",{type:"button","data-testid":`wizard-step-${i.id}`,onClick:()=>p(l),className:pe("flex flex-col items-center gap-1 outline-none focus-visible:ring-2 focus-visible:ring-blue-400 rounded-lg px-2 py-1",o&&"cursor-default",!o&&"cursor-pointer"),children:[e.jsx("div",{className:pe("flex h-8 w-8 items-center justify-center rounded-full text-sm font-semibold transition-colors",u&&"bg-blue-500 text-white",o&&"bg-blue-600 text-white ring-2 ring-blue-300",!u&&!o&&"bg-gray-200 text-gray-500"),children:u?e.jsx(mt,{className:"h-4 w-4"}):l+1}),e.jsx("span",{className:pe("text-xs font-medium",o?"text-blue-600":"text-gray-500"),children:i.label})]})]},i.id)})})}function Ha({draft:t,templates:r,readOnly:p,onChange:i,t:l}){const u=t.name.length>0&&!Dt(t.name);return e.jsxs("div",{"data-testid":"wizard-step-basic-content",className:"mx-auto max-w-lg space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{htmlFor:"app-name",className:"block text-sm font-medium text-gray-700",children:[l("appDesigner.appName")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:"app-name","data-testid":"app-name-input",type:"text",value:t.name,onChange:o=>i({name:o.target.value}),placeholder:"my_app",disabled:p,className:pe("block w-full rounded-md border px-3 py-2 text-sm shadow-sm outline-none transition-colors","focus:border-blue-500 focus:ring-1 focus:ring-blue-500","disabled:cursor-not-allowed disabled:bg-gray-50",u?"border-red-400":"border-gray-300")}),u&&e.jsx("p",{className:"text-xs text-red-500",children:l("appDesigner.snakeCaseHint")})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{htmlFor:"app-title",className:"block text-sm font-medium text-gray-700",children:[l("appDesigner.appTitle")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:"app-title","data-testid":"app-title-input",type:"text",value:t.title,onChange:o=>i({title:o.target.value}),placeholder:"My Application",disabled:p,className:"block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"app-description",className:"block text-sm font-medium text-gray-700",children:l("appDesigner.appDescription")}),e.jsx("textarea",{id:"app-description","data-testid":"app-description-input",value:t.description??"",onChange:o=>i({description:o.target.value}),rows:3,disabled:p,className:"block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50 resize-none"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"app-icon",className:"block text-sm font-medium text-gray-700",children:l("appDesigner.appIcon")}),e.jsx("input",{id:"app-icon",type:"text",value:t.icon??"",onChange:o=>i({icon:o.target.value}),placeholder:"LayoutDashboard",disabled:p,className:"block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50"})]}),r.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"app-template",className:"block text-sm font-medium text-gray-700",children:l("appDesigner.template")}),e.jsxs("select",{id:"app-template",value:t.template??"",onChange:o=>i({template:o.target.value}),disabled:p,className:"block w-full rounded-md border border-gray-300 px-3 py-2 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50",children:[e.jsx("option",{value:"",children:"None"}),r.map(o=>e.jsx("option",{value:o.id,children:o.label},o.id))]})]}),e.jsxs("fieldset",{className:"space-y-2",children:[e.jsx("legend",{className:"text-sm font-medium text-gray-700",children:l("appDesigner.layout")}),e.jsx("div",{className:"flex gap-3",children:[{value:"sidebar",labelKey:"appDesigner.layoutSidebar",Icon:ra},{value:"header",labelKey:"appDesigner.layoutHeader",Icon:Tt},{value:"empty",labelKey:"appDesigner.layoutEmpty",Icon:na}].map(({value:o,labelKey:h,Icon:x})=>e.jsxs("label",{"data-testid":`app-layout-${o}`,className:pe("flex flex-1 cursor-pointer flex-col items-center gap-1.5 rounded-lg border-2 p-3 transition-colors",t.layout===o?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300",p&&"pointer-events-none opacity-60"),children:[e.jsx(x,{className:"h-5 w-5 text-gray-600"}),e.jsx("span",{className:"text-xs font-medium text-gray-700",children:l(h)}),e.jsx("input",{type:"radio",name:"layout",value:o,checked:t.layout===o,onChange:()=>i({layout:o}),disabled:p,className:"sr-only"})]},o))})]})]})}function Ba({objects:t,readOnly:r,onToggle:p,onToggleAll:i,search:l,onSearchChange:u,t:o}){const h=a.useMemo(()=>{if(!l)return t;const s=l.toLowerCase();return t.filter(d=>d.name.toLowerCase().includes(s)||d.label.toLowerCase().includes(s))},[t,l]),x=t.length>0&&t.every(s=>s.selected);return t.every(s=>!s.selected),e.jsxs("div",{"data-testid":"wizard-step-objects-content",className:"mx-auto max-w-2xl space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(la,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{"data-testid":"object-search",type:"text",value:l,onChange:s=>u(s.target.value),placeholder:o("appDesigner.searchObjects"),className:"block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500"})]}),e.jsx("button",{type:"button",onClick:()=>i(!x),disabled:r,className:"rounded-md border border-gray-300 px-3 py-2 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50",children:o(x?"appDesigner.deselectAll":"appDesigner.selectAll")})]}),h.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-gray-400",children:o("appDesigner.noObjectsFound")}):e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:h.map(s=>e.jsxs("button",{type:"button","data-testid":`object-card-${s.name}`,disabled:r,onClick:()=>p(s.name),className:pe("flex flex-col items-start gap-1 rounded-lg border-2 p-3 text-left transition-colors",s.selected?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300",r&&"pointer-events-none opacity-60"),children:[e.jsxs("div",{className:"flex w-full items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-gray-800",children:s.label}),e.jsx("div",{className:pe("flex h-5 w-5 items-center justify-center rounded border transition-colors",s.selected?"border-blue-500 bg-blue-500 text-white":"border-gray-300"),children:s.selected&&e.jsx(mt,{className:"h-3 w-3"})})]}),e.jsx("span",{className:"text-xs text-gray-500",children:s.name}),s.icon&&e.jsx("span",{className:"text-xs text-gray-400",children:s.icon})]},s.name))})]})}const Va={object:"bg-green-100 text-green-700",group:"bg-purple-100 text-purple-700",url:"bg-sky-100 text-sky-700",separator:"bg-gray-100 text-gray-600",dashboard:"bg-amber-100 text-amber-700",page:"bg-teal-100 text-teal-700",report:"bg-rose-100 text-rose-700",action:"bg-orange-100 text-orange-700"};function Wa({items:t,readOnly:r,onAdd:p,onRemove:i,onReorder:l,t:u}){return e.jsxs("div",{"data-testid":"wizard-step-navigation-content",className:"mx-auto max-w-lg space-y-4",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button","data-testid":"add-group-btn",onClick:()=>p("group"),disabled:r,className:"inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(Mt,{className:"h-3.5 w-3.5"}),u("appDesigner.addGroup")]}),e.jsxs("button",{type:"button","data-testid":"add-url-btn",onClick:()=>p("url"),disabled:r,className:"inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(it,{className:"h-3.5 w-3.5"}),u("appDesigner.addUrl")]}),e.jsxs("button",{type:"button","data-testid":"add-separator-btn",onClick:()=>p("separator"),disabled:r,className:"inline-flex items-center gap-1.5 rounded-md border border-gray-300 px-3 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(lt,{className:"h-3.5 w-3.5"}),u("appDesigner.addSeparator")]})]}),t.length===0?e.jsx("p",{className:"py-8 text-center text-sm text-gray-400",children:u("appDesigner.noNavItemsHint")}):e.jsx("ul",{className:"space-y-1.5",children:t.map((o,h)=>e.jsxs("li",{"data-testid":`nav-item-${o.id}`,className:"flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2",children:[o.icon&&e.jsx("span",{className:"text-xs text-gray-400",children:o.icon}),e.jsx("span",{className:"flex-1 truncate text-sm text-gray-800",children:o.type==="separator"?u("appDesigner.separatorLabel"):ye(o.label)}),e.jsx("span",{className:pe("rounded-full px-2 py-0.5 text-[10px] font-medium",Va[o.type]??"bg-gray-100 text-gray-600"),children:o.type}),e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsx("button",{type:"button",onClick:()=>l(o.id,"up"),disabled:r||h===0,className:"rounded p-0.5 text-gray-400 transition-colors hover:text-gray-700 disabled:opacity-30","aria-label":"Move up",children:e.jsx(Ie,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>l(o.id,"down"),disabled:r||h===t.length-1,className:"rounded p-0.5 text-gray-400 transition-colors hover:text-gray-700 disabled:opacity-30","aria-label":"Move down",children:e.jsx(ue,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>i(o.id),disabled:r,className:"rounded p-0.5 text-gray-400 transition-colors hover:text-red-500 disabled:opacity-30","aria-label":"Remove",children:e.jsx(me,{className:"h-3.5 w-3.5"})})]})]},o.id))})]})}function _a({branding:t,title:r,readOnly:p,onChange:i,t:l}){return e.jsxs("div",{"data-testid":"wizard-step-branding-content",className:"mx-auto max-w-lg space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"branding-logo",className:"block text-sm font-medium text-gray-700",children:l("appDesigner.logoUrl")}),e.jsxs("div",{className:"relative",children:[e.jsx(ct,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{id:"branding-logo","data-testid":"branding-logo-input",type:"text",value:t.logo??"",onChange:u=>i({logo:u.target.value}),placeholder:"https://example.com/logo.svg",disabled:p,className:"block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"branding-color",className:"block text-sm font-medium text-gray-700",children:l("appDesigner.primaryColor")}),e.jsxs("div",{className:"relative",children:[e.jsx(At,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{id:"branding-color","data-testid":"branding-color-input",type:"text",value:t.primaryColor??"#3b82f6",onChange:u=>i({primaryColor:u.target.value}),placeholder:"#3b82f6",disabled:p,className:"block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"branding-favicon",className:"block text-sm font-medium text-gray-700",children:l("appDesigner.faviconUrl")}),e.jsxs("div",{className:"relative",children:[e.jsx(Lt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{id:"branding-favicon","data-testid":"branding-favicon-input",type:"text",value:t.favicon??"",onChange:u=>i({favicon:u.target.value}),placeholder:"https://example.com/favicon.ico",disabled:p,className:"block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("span",{className:"block text-sm font-medium text-gray-700",children:l("appDesigner.preview")}),e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[t.logo?e.jsx("img",{src:t.logo,alt:"App logo",className:"h-8 w-8 rounded object-contain"}):e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded bg-gray-100 text-xs text-gray-400",children:"Logo"}),e.jsx("span",{className:"text-sm font-semibold text-gray-800",children:r||l("appDesigner.appTitle")})]}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 rounded-full border border-gray-200",style:{backgroundColor:t.primaryColor||"#3b82f6"}}),e.jsx("span",{className:"text-xs text-gray-500",children:t.primaryColor||"#3b82f6"})]}),t.favicon&&e.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[e.jsx("img",{src:t.favicon,alt:"Favicon",className:"h-4 w-4 rounded object-contain"}),e.jsx("span",{className:"text-xs text-gray-500",children:"Favicon"})]})]})]})]})}function Za({availableObjects:t=[],templates:r=[],initialDraft:p,onComplete:i,onCancel:l,onSaveDraft:u,readOnly:o=!1,className:h}){const{t:x}=be(),s=Me(),[d,c]=a.useState(0),[m,C]=a.useState(""),[g,S]=a.useState(()=>({...za,objects:t.map(j=>({...j})),...p})),M=a.useMemo(()=>[{id:"basic",label:x("appDesigner.basicInfo"),description:x("appDesigner.stepBasicDesc"),icon:"Settings"},{id:"objects",label:x("appDesigner.objects"),description:x("appDesigner.stepObjectsDesc"),icon:"Database"},{id:"navigation",label:x("appDesigner.navigation"),description:x("appDesigner.stepNavigationDesc"),icon:"Menu"},{id:"branding",label:x("appDesigner.branding"),description:x("appDesigner.stepBrandingDesc"),icon:"Palette"}],[x]),I=d===0,L=d===M.length-1,A=a.useMemo(()=>g.name.length>0&&Dt(g.name)&&g.title.trim().length>0,[g.name,g.title]),H=a.useMemo(()=>d===0?A:!0,[d,A]),N=a.useCallback(j=>{S(U=>({...U,...j}))},[]),k=a.useCallback(j=>{S(U=>({...U,branding:{...U.branding,...j}}))},[]),y=a.useCallback(j=>{S(U=>({...U,objects:U.objects.map($=>$.name===j?{...$,selected:!$.selected}:$)}))},[]),D=a.useCallback(j=>{S(U=>({...U,objects:U.objects.map($=>({...$,selected:j}))}))},[]),T=a.useCallback(j=>{const U={id:Ka(j),type:j,label:j==="separator"?"":j==="group"?"New Group":"New Link",...j==="group"?{children:[]}:{},...j==="url"?{url:""}:{}};S($=>({...$,navigation:[...$.navigation,U]}))},[]),Y=a.useCallback(j=>{S(U=>({...U,navigation:U.navigation.filter($=>$.id!==j)}))},[]),O=a.useCallback((j,U)=>{S($=>{const J=[...$.navigation],ae=J.findIndex(Z=>Z.id===j);if(ae<0)return $;const P=U==="up"?ae-1:ae+1;return P<0||P>=J.length?$:([J[ae],J[P]]=[J[P],J[ae]],{...$,navigation:J})})},[]),W=a.useCallback(()=>{L||(d===1&&S(j=>({...j,navigation:yt(j.objects)})),c(j=>j+1))},[d,L]),te=a.useCallback(()=>{I||c(j=>j-1)},[I]),re=a.useCallback(()=>{i?.(g)},[g,i]),F=a.useCallback(async()=>{(g.name.length>0||g.title.length>0)&&l?await s.confirm(x("appDesigner.cancelConfirmTitle"),x("appDesigner.cancelConfirmMessage"))&&l():l?.()},[g.name,g.title,l,s,x]),X=a.useCallback(()=>{u?.(g)},[g,u]),V=a.useCallback(j=>{j<=d?c(j):j===d+1&&H&&(d===1&&j===2&&S(U=>({...U,navigation:yt(U.objects)})),c(j))},[d,H]);return e.jsxs("div",{className:pe("flex h-full flex-col rounded-xl border border-gray-200 bg-white shadow-sm",h),children:[s.isOpen&&e.jsx("div",{"data-testid":"cancel-confirm-dialog",className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40",role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:"mx-4 w-full max-w-sm rounded-lg bg-white p-6 shadow-xl",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx("h3",{className:"text-base font-semibold text-gray-900",children:s.title}),e.jsx("button",{type:"button",onClick:s.onCancel,className:"rounded p-1 text-gray-400 hover:text-gray-600","aria-label":x("common.close"),children:e.jsx(ut,{className:"h-4 w-4"})})]}),e.jsx("p",{className:"mt-2 text-sm text-gray-600",children:s.message}),e.jsxs("div",{className:"mt-4 flex justify-end gap-2",children:[e.jsx("button",{type:"button","data-testid":"cancel-confirm-keep",onClick:s.onCancel,className:"rounded-md border border-gray-300 px-3 py-1.5 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50",children:x("appDesigner.keepEditing")}),e.jsx("button",{type:"button","data-testid":"cancel-confirm-discard",onClick:s.onConfirm,className:"rounded-md bg-red-600 px-3 py-1.5 text-sm font-medium text-white transition-colors hover:bg-red-700",children:x("appDesigner.confirmDiscard")})]})]})}),e.jsx("div",{className:"border-b border-gray-100",children:e.jsx(Ga,{steps:M,currentIndex:d,onStepClick:V})}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-6",children:[d===0&&e.jsx(Ha,{draft:g,templates:r,readOnly:o,onChange:N,t:x}),d===1&&e.jsx(Ba,{objects:g.objects,readOnly:o,onToggle:y,onToggleAll:D,search:m,onSearchChange:C,t:x}),d===2&&e.jsx(Wa,{items:g.navigation,readOnly:o,onAdd:T,onRemove:Y,onReorder:O,t:x}),d===3&&e.jsx(_a,{branding:g.branding,title:g.title,readOnly:o,onChange:k,t:x})]}),e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-100 px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{type:"button","data-testid":"wizard-cancel",onClick:F,disabled:o,className:"rounded-md px-4 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",children:x("common.cancel")}),u&&e.jsx("button",{type:"button","data-testid":"wizard-save-draft",onClick:X,disabled:o,className:"rounded-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50",children:x("appDesigner.saveDraft")})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[!I&&e.jsxs("button",{type:"button","data-testid":"wizard-back",onClick:te,disabled:o,className:"inline-flex items-center gap-1 rounded-md border border-gray-300 px-4 py-2 text-sm font-medium text-gray-700 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(sa,{className:"h-4 w-4"}),x("common.back")]}),L?e.jsxs("button",{type:"button","data-testid":"wizard-complete",onClick:re,disabled:o||!H,className:"inline-flex items-center gap-1 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(mt,{className:"h-4 w-4"}),x("appDesigner.complete")]}):e.jsxs("button",{type:"button","data-testid":"wizard-next",onClick:W,disabled:o||!H,className:"inline-flex items-center gap-1 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-blue-700 disabled:cursor-not-allowed disabled:opacity-50",children:[x("common.next"),e.jsx(Re,{className:"h-4 w-4"})]})]})]})]})}function De(...t){return le(oe(t))}let jt=0;function Nt(t){return jt+=1,`${t}_${Date.now()}_${jt}`}const Te={object:{labelKey:"appDesigner.navTypeObject",color:"bg-green-100 text-green-700",Icon:rt},dashboard:{labelKey:"appDesigner.navTypeDashboard",color:"bg-amber-100 text-amber-700",Icon:ia},page:{labelKey:"appDesigner.navTypePage",color:"bg-teal-100 text-teal-700",Icon:dt},report:{labelKey:"appDesigner.navTypeReport",color:"bg-rose-100 text-rose-700",Icon:Ge},url:{labelKey:"appDesigner.navTypeUrl",color:"bg-sky-100 text-sky-700",Icon:it},group:{labelKey:"appDesigner.navTypeGroup",color:"bg-purple-100 text-purple-700",Icon:Mt},separator:{labelKey:"appDesigner.navTypeSeparator",color:"bg-gray-100 text-gray-600",Icon:lt},action:{labelKey:"appDesigner.navTypeAction",color:"bg-orange-100 text-orange-700",Icon:oa}},Ya=[{type:"object",labelKey:"appDesigner.navObjectPage"},{type:"dashboard",labelKey:"appDesigner.navDashboard"},{type:"page",labelKey:"appDesigner.navPage"},{type:"report",labelKey:"appDesigner.navReport"},{type:"group",labelKey:"appDesigner.navGroup"},{type:"url",labelKey:"appDesigner.navUrl"},{type:"separator",labelKey:"appDesigner.navSeparator"}];function Gt({item:t,depth:r,index:p,total:i,readOnly:l,onRemove:u,onMoveUp:o,onMoveDown:h,onToggleExpand:x,onUpdateLabel:s,onUpdateIcon:d,onToggleVisible:c,onAddChild:m,expandedIds:C,t:g}){const[S,M]=a.useState(!1),[I,L]=a.useState(ye(t.label)??""),[A,H]=a.useState(!1),[N,k]=a.useState(t.icon||""),y=Te[t.type];t.type==="group"&&t.children&&t.children.length>0;const D=C.has(t.id),T=t.visible===!1,Y=()=>{I.trim()?s(t.id,I.trim()):L(ye(t.label)??""),M(!1)},O=()=>{d(t.id,N.trim()),H(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs("li",{"data-testid":`nav-designer-item-${t.id}`,className:De("flex items-center gap-2 rounded-md border border-gray-200 bg-white px-2 py-1.5 transition-colors hover:bg-gray-50",T&&"opacity-50"),style:{marginLeft:r*20},children:[e.jsx(Ke,{className:"h-3.5 w-3.5 shrink-0 cursor-grab text-gray-300"}),t.type==="group"?e.jsx("button",{type:"button",onClick:()=>x(t.id),className:"rounded p-0.5 text-gray-400 hover:text-gray-600","aria-label":g(D?"appDesigner.navCollapseGroup":"appDesigner.navExpandGroup"),children:D?e.jsx(ue,{className:"h-3.5 w-3.5"}):e.jsx(Re,{className:"h-3.5 w-3.5"})}):e.jsx("span",{className:"w-5"}),A&&!l?e.jsx("input",{type:"text",value:N,onChange:W=>k(W.target.value),onBlur:O,onKeyDown:W=>{W.key==="Enter"&&O(),W.key==="Escape"&&(k(t.icon||""),H(!1))},autoFocus:!0,placeholder:g("appDesigner.navIconPlaceholder"),"data-testid":`nav-designer-icon-input-${t.id}`,className:"w-24 rounded border border-blue-300 px-1 py-0.5 text-xs outline-none focus:ring-1 focus:ring-blue-400"}):e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx(y.Icon,{className:"h-3.5 w-3.5 shrink-0 text-gray-500"}),!l&&t.type!=="separator"&&e.jsx("button",{type:"button",onClick:()=>{k(t.icon||""),H(!0)},className:"rounded p-0.5 text-gray-300 hover:text-blue-500","aria-label":g("appDesigner.navEditIcon"),"data-testid":`nav-designer-edit-icon-${t.id}`,children:e.jsx($t,{className:"h-2.5 w-2.5"})})]}),t.type==="separator"?e.jsx("span",{className:"flex-1 text-xs italic text-gray-400",children:g("appDesigner.separatorLabel")}):S&&!l?e.jsx("input",{type:"text",value:I,onChange:W=>L(W.target.value),onBlur:Y,onKeyDown:W=>{W.key==="Enter"&&Y(),W.key==="Escape"&&(L(ye(t.label)??""),M(!1))},autoFocus:!0,className:"flex-1 rounded border border-blue-300 px-1.5 py-0.5 text-sm outline-none focus:ring-1 focus:ring-blue-400"}):e.jsx("span",{className:De("flex-1 truncate text-sm text-gray-800",!l&&"cursor-text"),onDoubleClick:()=>{!l&&t.type!=="separator"&&(L(ye(t.label)??""),M(!0))},children:ye(t.label)}),e.jsx("span",{className:De("rounded-full px-2 py-0.5 text-[10px] font-medium",y.color),children:g(y.labelKey)}),T&&e.jsx("span",{className:"rounded-full bg-gray-200 px-1.5 py-0.5 text-[10px] font-medium text-gray-500","data-testid":`nav-designer-hidden-badge-${t.id}`,children:g("appDesigner.navHidden")}),!l&&t.type!=="separator"&&e.jsx("button",{type:"button",onClick:()=>c(t.id),className:"rounded p-0.5 text-gray-400 hover:text-gray-700","aria-label":g("appDesigner.navToggleVisible"),"data-testid":`nav-designer-toggle-visible-${t.id}`,children:T?e.jsx(Ve,{className:"h-3.5 w-3.5"}):e.jsx(Ee,{className:"h-3.5 w-3.5"})}),t.type==="group"&&!l&&e.jsx("button",{type:"button",onClick:()=>m(t.id,"page"),className:"rounded p-0.5 text-gray-400 hover:text-blue-500","aria-label":g("appDesigner.navAddChild"),"data-testid":`nav-designer-add-child-${t.id}`,children:e.jsx(ve,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>o(t.id),disabled:l||p===0,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":g("appDesigner.navMoveUp"),children:e.jsx(Ie,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>h(t.id),disabled:l||p===i-1,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":g("appDesigner.navMoveDown"),children:e.jsx(ue,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:()=>u(t.id),disabled:l,className:"rounded p-0.5 text-gray-400 hover:text-red-500 disabled:opacity-30","aria-label":g("appDesigner.navRemove"),"data-testid":`nav-designer-remove-${t.id}`,children:e.jsx(me,{className:"h-3.5 w-3.5"})})]}),t.type==="group"&&D&&t.children&&e.jsx(e.Fragment,{children:t.children.map((W,te)=>e.jsx(Gt,{item:W,depth:r+1,index:te,total:t.children.length,readOnly:l,onRemove:u,onMoveUp:o,onMoveDown:h,onToggleExpand:x,onUpdateLabel:s,onUpdateIcon:d,onToggleVisible:c,onAddChild:m,expandedIds:C,t:g},W.id))})]})}function Xa({items:t,t:r}){return e.jsxs("div",{"data-testid":"nav-designer-preview",className:"w-56 shrink-0 rounded-lg border border-gray-200 bg-gray-50 p-3",children:[e.jsx("h4",{className:"mb-2 text-xs font-semibold uppercase text-gray-500",children:r("appDesigner.navLivePreview")}),t.length===0?e.jsx("p",{className:"text-xs text-gray-400",children:r("appDesigner.navNoPreviewItems")}):e.jsx("ul",{className:"space-y-0.5",children:t.map(p=>e.jsx(Ht,{item:p,depth:0},p.id))})]})}function Ht({item:t,depth:r}){const p=Te[t.type];return t.type==="separator"?e.jsx("li",{className:"my-1 border-t border-gray-200",style:{marginLeft:r*12}}):e.jsxs(e.Fragment,{children:[e.jsxs("li",{className:"flex items-center gap-1.5 rounded px-2 py-1 text-xs text-gray-700 hover:bg-gray-100",style:{marginLeft:r*12},children:[e.jsx(p.Icon,{className:"h-3 w-3 text-gray-400"}),e.jsx("span",{className:"truncate",children:ye(t.label)})]}),t.type==="group"&&t.children?.map(i=>e.jsx(Ht,{item:i,depth:r+1},i.id))]})}function Ja({items:t,onChange:r,readOnly:p=!1,showPreview:i=!0,className:l,onExport:u,onImport:o}){const{t:h}=be(),x=a.useRef(null),[s,d]=a.useState(()=>new Set(t.filter(N=>N.type==="group").map(N=>N.id))),c=a.useCallback(N=>{function k(y){return y.filter(D=>D.id!==N).map(D=>D.children?{...D,children:k(D.children)}:D)}r(k(t))},[t,r]),m=a.useCallback((N,k)=>{function y(D){const T=D.findIndex(Y=>Y.id===N);if(T>=0){const Y=k==="up"?T-1:T+1;if(Y>=0&&Y<D.length){const O=[...D];return[O[T],O[Y]]=[O[Y],O[T]],O}return D}return D.map(Y=>Y.children?{...Y,children:y(Y.children)}:Y)}r(y(t))},[t,r]),C=a.useCallback((N,k)=>{function y(D){return D.map(T=>T.id===N?{...T,label:k}:T.children?{...T,children:y(T.children)}:T)}r(y(t))},[t,r]),g=a.useCallback((N,k)=>{function y(D){return D.map(T=>T.id===N?{...T,icon:k||void 0}:T.children?{...T,children:y(T.children)}:T)}r(y(t))},[t,r]),S=a.useCallback(N=>{function k(y){return y.map(D=>D.id===N?{...D,visible:D.visible===!1}:D.children?{...D,children:k(D.children)}:D)}r(k(t))},[t,r]),M=a.useCallback((N,k)=>{const y={id:Nt(k),type:k,label:k==="separator"?"":`New ${h(Te[k].labelKey)}`,...k==="group"?{children:[]}:{},...k==="url"?{url:""}:{}};function D(T){return T.map(Y=>Y.id===N&&Y.type==="group"?{...Y,children:[...Y.children||[],y]}:Y.children?{...Y,children:D(Y.children)}:Y)}r(D(t)),d(T=>new Set(T).add(N))},[t,r]),I=a.useCallback(N=>{const k={id:Nt(N),type:N,label:N==="separator"?"":`New ${h(Te[N].labelKey)}`,...N==="group"?{children:[]}:{},...N==="url"?{url:""}:{}};r([...t,k])},[t,r,h]),L=a.useCallback(N=>{d(k=>{const y=new Set(k);return y.has(N)?y.delete(N):y.add(N),y})},[]),A=a.useCallback(()=>{if(u)u(t);else{const N=JSON.stringify(t,null,2),k=new Blob([N],{type:"application/json"}),y=URL.createObjectURL(k),D=document.createElement("a");D.href=y,D.download="navigation-schema.json",D.click(),URL.revokeObjectURL(y)}},[t,u]),H=a.useCallback(N=>{const k=N.target.files?.[0];if(!k)return;const y=new FileReader;y.onload=D=>{try{const T=JSON.parse(D.target?.result);Array.isArray(T)&&(o?o(T):r(T))}catch{}},y.readAsText(k),x.current&&(x.current.value="")},[r,o]);return e.jsxs("div",{"data-testid":"navigation-designer",className:De("flex flex-col gap-4 sm:flex-row",l),children:[e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[Ya.map(({type:N,labelKey:k})=>{const{Icon:y,color:D}=Te[N];return e.jsxs("button",{type:"button","data-testid":`nav-designer-add-${N}`,onClick:()=>I(N),disabled:p,className:De("inline-flex items-center gap-1 rounded-md border border-gray-200 px-2.5 py-1 text-xs font-medium transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50"),children:[e.jsx(ve,{className:"h-3 w-3"}),h(k)]},N)}),e.jsx("span",{className:"mx-1 hidden h-4 w-px bg-gray-200 sm:block"}),e.jsxs("button",{type:"button","data-testid":"nav-designer-export",onClick:A,className:"inline-flex items-center gap-1 rounded-md border border-gray-200 px-2.5 py-1 text-xs font-medium transition-colors hover:bg-gray-50",children:[e.jsx(He,{className:"h-3 w-3"}),h("appDesigner.navExportSchema")]}),e.jsxs("label",{"data-testid":"nav-designer-import",className:De("inline-flex cursor-pointer items-center gap-1 rounded-md border border-gray-200 px-2.5 py-1 text-xs font-medium transition-colors hover:bg-gray-50",p&&"cursor-not-allowed opacity-50"),children:[e.jsx(Be,{className:"h-3 w-3"}),h("appDesigner.navImportSchema"),e.jsx("input",{ref:x,type:"file",accept:".json",className:"hidden",onChange:H,disabled:p,"data-testid":"nav-designer-import-input"})]})]}),t.length===0?e.jsx("div",{className:"py-8 text-center text-sm text-gray-400",children:h("appDesigner.navNoItems")}):e.jsx("ul",{className:"space-y-1","data-testid":"nav-designer-tree",children:t.map((N,k)=>e.jsx(Gt,{item:N,depth:0,index:k,total:t.length,readOnly:p,onRemove:c,onMoveUp:y=>m(y,"up"),onMoveDown:y=>m(y,"down"),onToggleExpand:L,onUpdateLabel:C,onUpdateIcon:g,onToggleVisible:S,onAddChild:M,expandedIds:s,t:h},N.id))})]}),i&&e.jsx(Xa,{items:t,t:h})]})}function wt(...t){return le(oe(t))}const qa=[{value:"edit",label:"Edit",Icon:$t},{value:"preview",label:"Preview",Icon:Ee},{value:"code",label:"Code",Icon:da}];function Es({mode:t,onChange:r,disabled:p=!1,className:i}){return e.jsx("div",{"data-testid":"editor-mode-toggle",className:wt("inline-flex items-center rounded-lg border border-gray-200 bg-gray-50 p-0.5",i),role:"radiogroup","aria-label":"Editor mode",children:qa.map(({value:l,label:u,Icon:o})=>e.jsxs("button",{type:"button",role:"radio","aria-checked":t===l,"data-testid":`editor-mode-${l}`,onClick:()=>r(l),disabled:p,className:wt("inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors",t===l?"bg-white text-gray-900 shadow-sm":"text-gray-500 hover:text-gray-700",p&&"cursor-not-allowed opacity-50"),children:[e.jsx(o,{className:"h-3.5 w-3.5"}),u]},l))})}function nt(...t){return le(oe(t))}const Se=[{type:"metric",label:"KPI Metric",Icon:ca},{type:"bar",label:"Bar Chart",Icon:Ge},{type:"line",label:"Line Chart",Icon:pa},{type:"pie",label:"Pie Chart",Icon:ua},{type:"table",label:"Table",Icon:pt},{type:"grid",label:"Grid",Icon:We}];let Ct=0;function Qa(){return Ct+=1,`widget_${Date.now()}_${Ct}`}function Oa({widget:t,index:r,total:p,selected:i,readOnly:l,onSelect:u,onRemove:o,onMoveUp:h,onMoveDown:x}){const s=t.type||"metric",d=Se.find(c=>c.type===s)||Se[0];return e.jsxs("div",{"data-testid":`dashboard-widget-${t.id}`,onClick:u,className:nt("group cursor-pointer rounded-lg border-2 p-3 transition-colors",i?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"),children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ke,{className:"h-4 w-4 text-gray-300"}),e.jsx(d.Icon,{className:"h-4 w-4 text-gray-500"}),e.jsx("span",{className:"text-sm font-medium text-gray-800",children:t.title||`Widget ${r+1}`})]}),!l&&e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[e.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),h()},disabled:r===0,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":"Move up",children:e.jsx(Ie,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),x()},disabled:r===p-1,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":"Move down",children:e.jsx(ue,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),o()},className:"rounded p-0.5 text-gray-400 hover:text-red-500","aria-label":"Remove widget","data-testid":`dashboard-widget-remove-${t.id}`,children:e.jsx(me,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("div",{className:"mt-1.5 flex items-center gap-2",children:[e.jsx("span",{className:"rounded-full bg-gray-100 px-2 py-0.5 text-[10px] font-medium text-gray-600",children:d.label}),t.object&&e.jsx("span",{className:"text-[10px] text-gray-400",children:t.object})]})]})}function es({widget:t,readOnly:r,onChange:p,onClose:i}){const{t:l}=be();return e.jsxs("div",{"data-testid":"widget-property-panel",className:"shrink-0 space-y-4 rounded-lg border border-gray-200 bg-white p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-800",children:l("appDesigner.widgetProperties")}),e.jsx("button",{type:"button",onClick:i,className:"rounded p-0.5 text-gray-400 hover:text-gray-600","aria-label":"Close",children:e.jsx(ut,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"widget-title",className:"text-xs font-medium text-gray-600",children:"Title"}),e.jsx("input",{id:"widget-title","data-testid":"widget-prop-title",type:"text",value:t.title??"",onChange:u=>p({title:u.target.value}),disabled:r,className:"block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"widget-type",className:"text-xs font-medium text-gray-600",children:"Type"}),e.jsx("select",{id:"widget-type","data-testid":"widget-prop-type",value:t.type??"metric",onChange:u=>p({type:u.target.value}),disabled:r,className:"block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50",children:Se.map(u=>e.jsx("option",{value:u.type,children:u.label},u.type))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"widget-object",className:"text-xs font-medium text-gray-600",children:"Data Source (Object)"}),e.jsx("input",{id:"widget-object","data-testid":"widget-prop-object",type:"text",value:t.object??"",onChange:u=>p({object:u.target.value}),disabled:r,placeholder:"e.g. orders",className:"block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"widget-value-field",className:"text-xs font-medium text-gray-600",children:"Value Field"}),e.jsx("input",{id:"widget-value-field","data-testid":"widget-prop-value-field",type:"text",value:t.valueField??"",onChange:u=>p({valueField:u.target.value}),disabled:r,placeholder:"e.g. amount",className:"block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"widget-aggregate",className:"text-xs font-medium text-gray-600",children:"Aggregate"}),e.jsxs("select",{id:"widget-aggregate","data-testid":"widget-prop-aggregate",value:t.aggregate??"count",onChange:u=>p({aggregate:u.target.value}),disabled:r,className:"block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50",children:[e.jsx("option",{value:"count",children:"Count"}),e.jsx("option",{value:"sum",children:"Sum"}),e.jsx("option",{value:"avg",children:"Average"}),e.jsx("option",{value:"min",children:"Min"}),e.jsx("option",{value:"max",children:"Max"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"widget-color",className:"text-xs font-medium text-gray-600",children:"Color Variant"}),e.jsxs("select",{id:"widget-color","data-testid":"widget-prop-color",value:t.colorVariant??"default",onChange:u=>p({colorVariant:u.target.value}),disabled:r,className:"block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50",children:[e.jsx("option",{value:"default",children:"Default"}),e.jsx("option",{value:"blue",children:"Blue"}),e.jsx("option",{value:"teal",children:"Teal"}),e.jsx("option",{value:"orange",children:"Orange"}),e.jsx("option",{value:"purple",children:"Purple"}),e.jsx("option",{value:"success",children:"Success"}),e.jsx("option",{value:"warning",children:"Warning"}),e.jsx("option",{value:"danger",children:"Danger"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-gray-600",children:l("appDesigner.widgetLayoutSize")}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:"widget-width",className:"text-[10px] text-gray-400",children:l("appDesigner.widgetWidth")}),e.jsx("input",{id:"widget-width","data-testid":"widget-prop-width",type:"number",min:1,value:t.layout?.w??1,onChange:u=>p({layout:{...t.layout,w:Number(u.target.value)||1}}),disabled:r,className:"block w-full rounded-md border border-gray-300 px-2 py-1 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50"})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{htmlFor:"widget-height",className:"text-[10px] text-gray-400",children:l("appDesigner.widgetHeight")}),e.jsx("input",{id:"widget-height","data-testid":"widget-prop-height",type:"number",min:1,value:t.layout?.h??1,onChange:u=>p({layout:{...t.layout,h:Number(u.target.value)||1}}),disabled:r,className:"block w-full rounded-md border border-gray-300 px-2 py-1 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50"})]})]})]})]})}function ts({schema:t}){const{t:r}=be(),p=t.widgets||[];return e.jsxs("div",{"data-testid":"dashboard-preview",className:"rounded-lg border border-gray-200 bg-gray-50 p-4",children:[e.jsx("h4",{className:"mb-3 text-sm font-semibold text-gray-700",children:t.title||r("appDesigner.dashboardPreview")}),p.length===0?e.jsx("div",{className:"text-xs text-gray-400",children:r("appDesigner.noWidgetsPreview")}):e.jsx("div",{className:"grid gap-2",style:{gridTemplateColumns:`repeat(${t.columns??2}, 1fr)`},children:p.map(i=>{const l=Se.find(u=>u.type===(i.type||"metric"))||Se[0];return e.jsxs("div",{className:"rounded-md border border-gray-200 bg-white p-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(l.Icon,{className:"h-3 w-3 text-gray-400"}),e.jsx("span",{className:"text-xs font-medium text-gray-600",children:i.title||"Untitled"})]}),e.jsx("div",{className:"mt-1 text-[10px] text-gray-400",children:l.label})]},i.id)})})]})}function as({schema:t,onChange:r,readOnly:p=!1,className:i,onExport:l,onImport:u,selectedWidgetId:o,onWidgetSelect:h}){const{t:x}=be(),[s,d]=a.useState(null),[c,m]=a.useState(!1),C=a.useRef(null),g=a.useRef(null),S=o!==void 0,M=S?o:s,I=a.useCallback(j=>{h&&h(j),S||d(j)},[S,h,d]),{current:L,canUndo:A,canRedo:H,push:N,undo:k,redo:y}=Ce(t),D=a.useCallback(j=>{N(j),r(j)},[N,r]),T=L.widgets||[],Y=T.find(j=>j.id===M),O=a.useCallback(j=>{const U=Qa(),$={id:U,title:"",type:j,layout:{x:0,y:T.length,w:L.columns??2,h:1}};D({...L,widgets:[...T,$]}),I(U)},[L,T,D,I]),W=a.useCallback(j=>{D({...L,widgets:T.filter(U=>U.id!==j)}),M===j&&I(null)},[L,T,M,D,I]),te=a.useCallback((j,U)=>{const $=T.findIndex(P=>P.id===j);if($<0)return;const J=U==="up"?$-1:$+1;if(J<0||J>=T.length)return;const ae=[...T];[ae[$],ae[J]]=[ae[J],ae[$]],D({...L,widgets:ae})},[L,T,D]),re=a.useCallback(j=>{M&&D({...L,widgets:T.map(U=>U.id===M?{...U,...j}:U)})},[L,T,M,D]);a.useEffect(()=>{const j=C.current;if(!j)return;const U=$=>{if(!p){if(($.ctrlKey||$.metaKey)&&$.key==="z"&&!$.shiftKey){$.preventDefault(),k();return}if(($.ctrlKey||$.metaKey)&&($.key==="y"||$.key==="z"&&$.shiftKey)){$.preventDefault(),y();return}if(($.key==="Delete"||$.key==="Backspace")&&M){const J=$.target;if(J.tagName==="INPUT"||J.tagName==="SELECT"||J.tagName==="TEXTAREA")return;$.preventDefault(),W(M)}}};return j.addEventListener("keydown",U),()=>j.removeEventListener("keydown",U)},[p,k,y,M,W]);const F=a.useCallback(()=>{l&&l(L)},[L,l]),X=a.useCallback(()=>{g.current?.click()},[]),V=a.useCallback(j=>{const U=j.target.files?.[0];if(!U)return;const $=new FileReader;$.onload=()=>{try{const J=JSON.parse($.result);J&&J.type==="dashboard"&&(D(J),u?.(J))}catch{}},$.readAsText(U),j.target.value=""},[D,u]);return e.jsxs("div",{ref:C,tabIndex:0,"data-testid":"dashboard-editor",className:nt("flex flex-col gap-4 outline-none",i),children:[e.jsx("input",{ref:g,type:"file",accept:".json",className:"hidden","data-testid":"dashboard-import-input",onChange:V}),Y&&!c&&e.jsx(es,{widget:Y,readOnly:p,onChange:re,onClose:()=>I(null)}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700",children:[x("appDesigner.addWidget"),":"]}),Se.map(({type:j,label:U,Icon:$})=>e.jsxs("button",{type:"button","data-testid":`dashboard-add-${j}`,onClick:()=>O(j),disabled:p||c,className:"inline-flex items-center gap-1.5 rounded-md border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx($,{className:"h-3.5 w-3.5"}),U]},j))]}),e.jsxs("div",{className:"flex items-center gap-1",children:[!p&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","data-testid":"dashboard-undo",onClick:k,disabled:!A,className:"rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":x("appDesigner.undo"),children:e.jsx(Ne,{className:"h-4 w-4"})}),e.jsx("button",{type:"button","data-testid":"dashboard-redo",onClick:y,disabled:!H,className:"rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":x("appDesigner.redo"),children:e.jsx(we,{className:"h-4 w-4"})})]}),e.jsx("button",{type:"button","data-testid":"dashboard-export",onClick:F,className:"rounded p-1.5 text-gray-400 hover:text-gray-700","aria-label":x("appDesigner.navExportSchema"),children:e.jsx(He,{className:"h-4 w-4"})}),!p&&e.jsx("button",{type:"button","data-testid":"dashboard-import",onClick:X,className:"rounded p-1.5 text-gray-400 hover:text-gray-700","aria-label":x("appDesigner.navImportSchema"),children:e.jsx(Be,{className:"h-4 w-4"})}),e.jsx("button",{type:"button","data-testid":"dashboard-preview-toggle",onClick:()=>m(j=>!j),className:nt("rounded p-1.5 transition-colors",c?"bg-blue-100 text-blue-600":"text-gray-400 hover:text-gray-700"),"aria-label":x(c?"appDesigner.modeEdit":"appDesigner.preview"),children:c?e.jsx(Ve,{className:"h-4 w-4"}):e.jsx(Ee,{className:"h-4 w-4"})})]})]}),c?e.jsx(ts,{schema:L}):T.length===0?e.jsx("div",{className:"flex h-48 items-center justify-center rounded-lg border-2 border-dashed border-gray-200 text-sm text-gray-400",children:x("appDesigner.noWidgets")}):e.jsx("div",{className:"grid gap-3",style:{gridTemplateColumns:`repeat(${L.columns??2}, 1fr)`},children:T.map((j,U)=>e.jsx(Oa,{widget:j,index:U,total:T.length,selected:j.id===M,readOnly:p,onSelect:()=>I(j.id??null),onRemove:()=>W(j.id),onMoveUp:()=>te(j.id,"up"),onMoveDown:()=>te(j.id,"down")},j.id))})]})]})}function Fe(...t){return le(oe(t))}const je=[{type:"grid",label:"Data Grid",Icon:pt},{type:"kanban",label:"Kanban Board",Icon:Ft},{type:"calendar",label:"Calendar",Icon:Ut},{type:"gallery",label:"Gallery",Icon:zt},{type:"dashboard",label:"Dashboard",Icon:Ge},{type:"form",label:"Form",Icon:dt},{type:"layout-grid",label:"Grid Layout",Icon:We}],ss=[{value:"page",labelKey:"appDesigner.modePage"},{value:"dashboard",labelKey:"appDesigner.modeDashboard"}];let kt=0;function rs(){return kt+=1,`component_${Date.now()}_${kt}`}function ns({component:t,index:r,total:p,selected:i,readOnly:l,onSelect:u,onRemove:o,onMoveUp:h,onMoveDown:x}){const s=je.find(d=>d.type===t.type)||je[0];return e.jsxs("div",{"data-testid":`canvas-component-${t.id}`,onClick:u,className:Fe("group flex cursor-pointer items-center gap-3 rounded-lg border-2 px-3 py-3 transition-colors",i?"border-blue-500 bg-blue-50":"border-gray-200 hover:border-gray-300"),children:[e.jsx(Ke,{className:"h-4 w-4 shrink-0 cursor-grab text-gray-300"}),e.jsx(s.Icon,{className:"h-5 w-5 shrink-0 text-gray-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("span",{className:"text-sm font-medium text-gray-800",children:t.label}),e.jsx("span",{className:"ml-2 text-[10px] text-gray-400",children:s.label})]}),!l&&e.jsxs("div",{className:"flex items-center gap-0.5 opacity-0 transition-opacity group-hover:opacity-100",children:[e.jsx("button",{type:"button",onClick:d=>{d.stopPropagation(),h()},disabled:r===0,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":"Move up",children:e.jsx(Ie,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:d=>{d.stopPropagation(),x()},disabled:r===p-1,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":"Move down",children:e.jsx(ue,{className:"h-3.5 w-3.5"})}),e.jsx("button",{type:"button",onClick:d=>{d.stopPropagation(),o()},className:"rounded p-0.5 text-gray-400 hover:text-red-500","aria-label":"Remove component","data-testid":`canvas-component-remove-${t.id}`,children:e.jsx(me,{className:"h-3.5 w-3.5"})})]})]})}function ls({component:t,readOnly:r,onChange:p,onClose:i}){const{t:l}=be();return e.jsxs("div",{"data-testid":"component-property-panel",className:"w-64 shrink-0 space-y-4 rounded-lg border border-gray-200 bg-white p-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-semibold text-gray-800",children:l("appDesigner.componentProperties")}),e.jsx("button",{type:"button",onClick:i,className:"rounded p-0.5 text-gray-400 hover:text-gray-600","aria-label":"Close",children:e.jsx(ut,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"component-label",className:"text-xs font-medium text-gray-600",children:"Label"}),e.jsx("input",{id:"component-label","data-testid":"component-prop-label",type:"text",value:t.label,onChange:u=>p({label:u.target.value}),disabled:r,className:"block w-full rounded-md border border-gray-300 px-2.5 py-1.5 text-sm outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:bg-gray-50"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-gray-600",children:"Type"}),e.jsx("div",{className:"rounded-md bg-gray-50 px-2.5 py-1.5 text-sm text-gray-600",children:je.find(u=>u.type===t.type)?.label??t.type})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs font-medium text-gray-600",children:"ID"}),e.jsx("div",{className:"rounded-md bg-gray-50 px-2.5 py-1.5 text-xs font-mono text-gray-500",children:t.id})]})]})}function os({schema:t,components:r}){const{t:p}=be();return e.jsxs("div",{"data-testid":"page-preview",className:"rounded-lg border border-gray-200 bg-gray-50 p-4",children:[e.jsx("h4",{className:"mb-3 text-sm font-semibold text-gray-700",children:t.title||p("appDesigner.pagePreview")}),r.length===0?e.jsx("div",{className:"text-xs text-gray-400",children:p("appDesigner.noComponentsPreview")}):e.jsx("div",{className:"space-y-2",children:r.map(i=>{const l=je.find(u=>u.type===i.type)||je[0];return e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-gray-200 bg-white p-2",children:[e.jsx(l.Icon,{className:"h-4 w-4 text-gray-400"}),e.jsx("span",{className:"text-xs font-medium text-gray-600",children:i.label}),e.jsx("span",{className:"text-[10px] text-gray-400",children:l.label})]},i.id)})})]})}function is({schema:t,onChange:r,readOnly:p=!1,className:i,onExport:l,onImport:u}){const{t:o}=be(),h=a.useRef(null),x=a.useRef(null),[s,d]=a.useState(()=>(t.children?Array.isArray(t.children)?t.children:[t.children]:[]).map((X,V)=>({id:X.id||`existing_${V}`,type:X.type||"grid",label:X.title||X.label||`Component ${V+1}`,props:X}))),[c,m]=a.useState(null),[C,g]=a.useState(!1),[S,M]=a.useState("page"),I=s.find(F=>F.id===c),{canUndo:L,canRedo:A,push:H,undo:N,redo:k}=Ce(s),y=a.useCallback(F=>{d(F),H(F),r({...t,children:F.map(X=>({type:X.type,id:X.id,title:X.label,...X.props}))})},[t,r,H]),D=a.useCallback(F=>{const X=rs(),V=je.find($=>$.type===F),j={id:X,type:F,label:V?.label||F},U=[...s,j];y(U),m(X)},[s,y]),T=a.useCallback(F=>{const X=s.filter(V=>V.id!==F);y(X),c===F&&m(null)},[s,c,y]),Y=a.useCallback((F,X)=>{const V=s.findIndex($=>$.id===F);if(V<0)return;const j=X==="up"?V-1:V+1;if(j<0||j>=s.length)return;const U=[...s];[U[V],U[j]]=[U[j],U[V]],y(U)},[s,y]),O=a.useCallback(F=>{if(!c)return;const X=s.map(V=>V.id===c?{...V,...F}:V);y(X)},[s,c,y]);a.useEffect(()=>{const F=h.current;if(!F)return;const X=V=>{if(!p){if((V.ctrlKey||V.metaKey)&&V.key==="z"&&!V.shiftKey){V.preventDefault(),N();return}if((V.ctrlKey||V.metaKey)&&(V.key==="y"||V.key==="z"&&V.shiftKey)){V.preventDefault(),k();return}if((V.key==="Delete"||V.key==="Backspace")&&c){const j=V.target;if(j.tagName==="INPUT"||j.tagName==="SELECT"||j.tagName==="TEXTAREA")return;V.preventDefault(),T(c)}}};return F.addEventListener("keydown",X),()=>F.removeEventListener("keydown",X)},[p,N,k,c,T]);const W=a.useCallback(()=>{l&&l(t)},[t,l]),te=a.useCallback(()=>{x.current?.click()},[]),re=a.useCallback(F=>{const X=F.target.files?.[0];if(!X)return;const V=new FileReader;V.onload=()=>{try{const j=JSON.parse(V.result);if(j&&j.type==="page"){const $=(j.children?Array.isArray(j.children)?j.children:[j.children]:[]).map((J,ae)=>({id:J.id||`imported_${ae}`,type:J.type||"grid",label:J.title||J.label||`Component ${ae+1}`,props:J}));d($),H($),r(j),u?.(j)}}catch{}},V.readAsText(X),F.target.value=""},[r,H,u]);return e.jsxs("div",{ref:h,tabIndex:0,"data-testid":"page-canvas-editor",className:Fe("flex flex-col gap-4 outline-none sm:flex-row",i),children:[e.jsx("input",{ref:x,type:"file",accept:".json",className:"hidden","data-testid":"canvas-import-input",onChange:re}),e.jsxs("div",{className:"flex-1 space-y-4",children:[e.jsx("div",{className:"flex items-center gap-2 border-b border-gray-200 pb-2",role:"tablist",children:ss.map(F=>e.jsx("button",{type:"button",role:"tab","data-testid":`canvas-mode-${F.value}`,"aria-selected":S===F.value,onClick:()=>M(F.value),className:Fe("rounded-t-md px-3 py-1.5 text-xs font-medium transition-colors",S===F.value?"border-b-2 border-blue-500 text-blue-600":"text-gray-500 hover:text-gray-700"),children:o(F.labelKey)},F.value))}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"text-sm font-medium text-gray-700",children:[o("appDesigner.addComponent"),":"]}),je.map(({type:F,label:X,Icon:V})=>e.jsxs("button",{type:"button","data-testid":`canvas-add-${F}`,onClick:()=>D(F),disabled:p||C,className:"inline-flex items-center gap-1.5 rounded-md border border-gray-200 px-2.5 py-1.5 text-xs font-medium text-gray-600 transition-colors hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(V,{className:"h-3.5 w-3.5"}),X]},F))]}),e.jsxs("div",{className:"flex items-center gap-1",children:[!p&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button","data-testid":"canvas-undo",onClick:N,disabled:!L,className:"rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":o("appDesigner.undo"),children:e.jsx(Ne,{className:"h-4 w-4"})}),e.jsx("button",{type:"button","data-testid":"canvas-redo",onClick:k,disabled:!A,className:"rounded p-1.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":o("appDesigner.redo"),children:e.jsx(we,{className:"h-4 w-4"})})]}),e.jsx("button",{type:"button","data-testid":"canvas-export",onClick:W,className:"rounded p-1.5 text-gray-400 hover:text-gray-700","aria-label":o("appDesigner.navExportSchema"),children:e.jsx(He,{className:"h-4 w-4"})}),!p&&e.jsx("button",{type:"button","data-testid":"canvas-import",onClick:te,className:"rounded p-1.5 text-gray-400 hover:text-gray-700","aria-label":o("appDesigner.navImportSchema"),children:e.jsx(Be,{className:"h-4 w-4"})}),e.jsx("button",{type:"button","data-testid":"canvas-preview-toggle",onClick:()=>g(F=>!F),className:Fe("rounded p-1.5 transition-colors",C?"bg-blue-100 text-blue-600":"text-gray-400 hover:text-gray-700"),"aria-label":o(C?"appDesigner.modeEdit":"appDesigner.preview"),children:C?e.jsx(Ve,{className:"h-4 w-4"}):e.jsx(Ee,{className:"h-4 w-4"})})]})]}),C?e.jsx(os,{schema:t,components:s}):s.length===0?e.jsx("div",{className:"flex h-48 items-center justify-center rounded-lg border-2 border-dashed border-gray-200 text-sm text-gray-400",children:o("appDesigner.emptyPage")}):e.jsx("div",{className:"space-y-2",children:s.map((F,X)=>e.jsx(ns,{component:F,index:X,total:s.length,selected:F.id===c,readOnly:p,onSelect:()=>m(F.id),onRemove:()=>T(F.id),onMoveUp:()=>Y(F.id,"up"),onMoveDown:()=>Y(F.id,"down")},F.id))})]}),I&&!C&&e.jsx(ls,{component:I,readOnly:p,onChange:O,onClose:()=>m(null)})]})}function Le(...t){return le(oe(t))}const ds={grid:{label:"Grid",Icon:We},kanban:{label:"Kanban",Icon:Ft},calendar:{label:"Calendar",Icon:Ut},gallery:{label:"Gallery",Icon:zt},timeline:{label:"Timeline",Icon:Kt},map:{label:"Map",Icon:St},gantt:{label:"Gantt",Icon:ma}},cs=[{value:"compact",label:"Compact"},{value:"medium",label:"Medium"},{value:"tall",label:"Tall"}];function $e({title:t,icon:r,defaultOpen:p=!0,children:i}){const[l,u]=a.useState(p);return e.jsxs("div",{className:"border-b border-gray-100 pb-3",children:[e.jsxs("button",{type:"button",onClick:()=>u(!l),className:"flex w-full items-center gap-2 py-2 text-left",children:[r,e.jsx("span",{className:"flex-1 text-xs font-semibold uppercase text-gray-500",children:t}),l?e.jsx(Ie,{className:"h-3.5 w-3.5 text-gray-400"}):e.jsx(ue,{className:"h-3.5 w-3.5 text-gray-400"})]}),l&&e.jsx("div",{className:"space-y-2",children:i})]})}function ps({config:t,onChange:r,availableViewTypes:p=["grid","kanban","calendar","gallery","timeline","map","gantt"],readOnly:i=!1,className:l}){const u=a.useCallback(s=>{r({...t,...s})},[t,r]),o=a.useCallback(s=>{u({columns:t.columns.map(d=>d.name===s?{...d,visible:!d.visible}:d)})},[t,u]),h=a.useCallback((s,d)=>{const c=[...t.columns],m=c.findIndex(g=>g.name===s);if(m<0)return;const C=d==="up"?m-1:m+1;C<0||C>=c.length||([c[m],c[C]]=[c[C],c[m]],u({columns:c}))},[t,u]),x=a.useMemo(()=>t.columns.filter(s=>s.visible).length,[t.columns]);return e.jsxs("div",{"data-testid":"object-view-configurator",className:Le("w-72 space-y-3 rounded-lg border border-gray-200 bg-white p-4",l),children:[e.jsx($e,{title:"View Type",icon:e.jsx(We,{className:"h-3.5 w-3.5 text-gray-500"}),children:e.jsx("div",{className:"flex flex-wrap gap-1.5",children:p.map(s=>{const{label:d,Icon:c}=ds[s];return e.jsxs("button",{type:"button","data-testid":`view-type-${s}`,onClick:()=>u({viewType:s}),disabled:i,className:Le("inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors",t.viewType===s?"bg-blue-100 text-blue-700":"text-gray-600 hover:bg-gray-100",i&&"cursor-not-allowed opacity-50"),children:[e.jsx(c,{className:"h-3 w-3"}),d]},s)})})}),e.jsx($e,{title:`Fields (${x}/${t.columns.length})`,icon:e.jsx(xa,{className:"h-3.5 w-3.5 text-gray-500"}),children:t.columns.length===0?e.jsx("p",{className:"text-xs text-gray-400",children:"No fields configured."}):e.jsx("ul",{className:"space-y-0.5",children:t.columns.map((s,d)=>e.jsxs("li",{"data-testid":`view-column-${s.name}`,className:"flex items-center gap-1.5 rounded px-1.5 py-1 text-xs hover:bg-gray-50",children:[e.jsx("button",{type:"button",onClick:()=>o(s.name),disabled:i,className:Le("rounded p-0.5 transition-colors",s.visible?"text-blue-500":"text-gray-300"),"aria-label":s.visible?"Hide field":"Show field",children:s.visible?e.jsx(Ee,{className:"h-3 w-3"}):e.jsx(Ve,{className:"h-3 w-3"})}),e.jsx("span",{className:"flex-1 truncate text-gray-700",children:s.label}),e.jsx("button",{type:"button",onClick:()=>h(s.name,"up"),disabled:i||d===0,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":"Move up",children:e.jsx(Ie,{className:"h-3 w-3"})}),e.jsx("button",{type:"button",onClick:()=>h(s.name,"down"),disabled:i||d===t.columns.length-1,className:"rounded p-0.5 text-gray-400 hover:text-gray-700 disabled:opacity-30","aria-label":"Move down",children:e.jsx(ue,{className:"h-3 w-3"})})]},s.name))})}),e.jsx($e,{title:"Toolbar",icon:e.jsx(ga,{className:"h-3.5 w-3.5 text-gray-500"}),children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.showSearch,onChange:s=>u({showSearch:s.target.checked}),disabled:i,"data-testid":"view-toggle-search",className:"h-3.5 w-3.5 rounded border-gray-300"}),e.jsx("span",{className:"text-xs text-gray-700",children:"Show Search"})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.showFilters,onChange:s=>u({showFilters:s.target.checked}),disabled:i,"data-testid":"view-toggle-filters",className:"h-3.5 w-3.5 rounded border-gray-300"}),e.jsx("span",{className:"text-xs text-gray-700",children:"Show Filters"})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.showSort,onChange:s=>u({showSort:s.target.checked}),disabled:i,"data-testid":"view-toggle-sort",className:"h-3.5 w-3.5 rounded border-gray-300"}),e.jsx("span",{className:"text-xs text-gray-700",children:"Show Sort"})]})]})}),e.jsx($e,{title:"Appearance",icon:e.jsx(ba,{className:"h-3.5 w-3.5 text-gray-500"}),defaultOpen:!1,children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-[10px] font-medium text-gray-500",children:"Row Height"}),e.jsx("div",{className:"flex gap-1",children:cs.map(({value:s,label:d})=>e.jsx("button",{type:"button","data-testid":`view-row-height-${s}`,onClick:()=>u({rowHeight:s}),disabled:i,className:Le("flex-1 rounded px-2 py-1 text-[10px] font-medium transition-colors",t.rowHeight===s?"bg-blue-100 text-blue-700":"bg-gray-50 text-gray-500 hover:bg-gray-100"),children:d},s))})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.striped,onChange:s=>u({striped:s.target.checked}),disabled:i,"data-testid":"view-toggle-striped",className:"h-3.5 w-3.5 rounded border-gray-300"}),e.jsx("span",{className:"text-xs text-gray-700",children:"Striped Rows"})]}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:t.bordered,onChange:s=>u({bordered:s.target.checked}),disabled:i,"data-testid":"view-toggle-bordered",className:"h-3.5 w-3.5 rounded border-gray-300"}),e.jsx("span",{className:"text-xs text-gray-700",children:"Bordered"})]})]})})]})}function ne(...t){return le(oe(t))}const us=[{hex:"#3b82f6",name:"Blue"},{hex:"#6366f1",name:"Indigo"},{hex:"#8b5cf6",name:"Violet"},{hex:"#a855f7",name:"Purple"},{hex:"#ec4899",name:"Pink"},{hex:"#ef4444",name:"Red"},{hex:"#f97316",name:"Orange"},{hex:"#f59e0b",name:"Amber"},{hex:"#eab308",name:"Yellow"},{hex:"#22c55e",name:"Green"},{hex:"#14b8a6",name:"Teal"},{hex:"#06b6d4",name:"Cyan"},{hex:"#0ea5e9",name:"Sky"},{hex:"#64748b",name:"Slate"},{hex:"#1e293b",name:"Dark"},{hex:"#0f172a",name:"Navy"}],ms=["Inter","Roboto","Open Sans","Lato","Montserrat","Poppins","Source Sans Pro","Noto Sans","system-ui"];function xs({branding:t,onChange:r,appTitle:p="My App",readOnly:i=!1,className:l,onExport:u,onImport:o}){const{t:h}=be(),[x,s]=a.useState("light"),{current:d,push:c,canUndo:m,canRedo:C,undo:g,redo:S}=Ce(t),M=a.useRef(!0);a.useEffect(()=>{if(M.current){M.current=!1;return}r(d)},[d]);const I=a.useCallback(y=>{const D={...d,...y};M.current=!0,c(D),r(D)},[d,c,r]),L=a.useCallback(()=>{if(u){u(d);return}const y=new Blob([JSON.stringify(d,null,2)],{type:"application/json"}),D=URL.createObjectURL(y),T=document.createElement("a");T.href=D,T.download="branding.json",T.click(),URL.revokeObjectURL(D)},[d,u]),A=a.useCallback(()=>{if(o){o(d);return}const y=document.createElement("input");y.type="file",y.accept=".json",y.onchange=D=>{const T=D.target.files?.[0];if(!T)return;const Y=new FileReader;Y.onload=O=>{try{const W=JSON.parse(O.target?.result);if(typeof W=="object"&&W!==null){const te={...d,...W};c(te),r(te)}}catch{}},Y.readAsText(T)},y.click()},[d,c,r,o]),H=a.useCallback(y=>{i||((y.ctrlKey||y.metaKey)&&y.key==="z"&&(y.preventDefault(),y.shiftKey?S():g()),(y.ctrlKey||y.metaKey)&&y.key==="y"&&(y.preventDefault(),S()))},[i,g,S]),N=d.primaryColor||"#3b82f6",k=x==="dark";return e.jsxs("div",{"data-testid":"branding-editor",className:ne("flex flex-col gap-4 sm:gap-6",l),onKeyDown:H,tabIndex:0,children:[e.jsxs("div",{"data-testid":"branding-editor-toolbar",className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-800 mr-auto",children:h("appDesigner.brandingEditor")}),e.jsxs("button",{"data-testid":"branding-undo",type:"button",onClick:g,disabled:!m||i,className:ne("inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors",m&&!i?"border-gray-300 bg-white text-gray-700 hover:bg-gray-50":"border-gray-200 bg-gray-50 text-gray-400 cursor-not-allowed"),title:h("appDesigner.undo"),children:[e.jsx(Ne,{className:"h-3.5 w-3.5"}),h("appDesigner.undo")]}),e.jsxs("button",{"data-testid":"branding-redo",type:"button",onClick:S,disabled:!C||i,className:ne("inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors",C&&!i?"border-gray-300 bg-white text-gray-700 hover:bg-gray-50":"border-gray-200 bg-gray-50 text-gray-400 cursor-not-allowed"),title:h("appDesigner.redo"),children:[e.jsx(we,{className:"h-3.5 w-3.5"}),h("appDesigner.redo")]}),e.jsxs("button",{"data-testid":"branding-export",type:"button",onClick:L,className:"inline-flex items-center gap-1 rounded-md border border-gray-300 bg-white px-2.5 py-1.5 text-xs font-medium text-gray-700 shadow-sm transition-colors hover:bg-gray-50",title:h("appDesigner.brandingExport"),children:[e.jsx(He,{className:"h-3.5 w-3.5"}),h("appDesigner.brandingExport")]}),e.jsxs("button",{"data-testid":"branding-import",type:"button",onClick:A,disabled:i,className:ne("inline-flex items-center gap-1 rounded-md border px-2.5 py-1.5 text-xs font-medium shadow-sm transition-colors",i?"border-gray-200 bg-gray-50 text-gray-400 cursor-not-allowed":"border-gray-300 bg-white text-gray-700 hover:bg-gray-50"),title:h("appDesigner.brandingImport"),children:[e.jsx(Be,{className:"h-3.5 w-3.5"}),h("appDesigner.brandingImport")]})]}),e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:gap-6",children:[e.jsxs("div",{className:"flex-1 space-y-5",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"be-logo",className:"block text-sm font-medium text-gray-700",children:h("appDesigner.logoUrl")}),e.jsxs("div",{className:"relative",children:[e.jsx(ct,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{id:"be-logo","data-testid":"branding-logo-input",type:"text",value:d.logo??"",onChange:y=>I({logo:y.target.value}),placeholder:"https://example.com/logo.svg",disabled:i,className:"block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"be-color",className:"block text-sm font-medium text-gray-700",children:h("appDesigner.primaryColor")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(At,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{id:"be-color","data-testid":"branding-color-input",type:"text",value:d.primaryColor??"#3b82f6",onChange:y=>I({primaryColor:y.target.value}),placeholder:"#3b82f6",disabled:i,className:"block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50"})]}),e.jsx("input",{"data-testid":"branding-color-picker",type:"color",value:N,onChange:y=>I({primaryColor:y.target.value}),disabled:i,className:"h-9 w-9 cursor-pointer rounded-md border border-gray-300 p-0.5 disabled:cursor-not-allowed"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-xs text-gray-500",children:h("appDesigner.colorPalette")}),e.jsx("div",{"data-testid":"branding-color-palette",className:"flex flex-wrap gap-1.5",children:us.map(y=>e.jsx("button",{"data-testid":`branding-swatch-${y.hex.slice(1)}`,type:"button",onClick:()=>!i&&I({primaryColor:y.hex}),disabled:i,className:ne("h-6 w-6 rounded-full border-2 transition-transform hover:scale-110 disabled:cursor-not-allowed",N===y.hex?"border-gray-800 ring-2 ring-offset-1 ring-gray-400":"border-transparent"),style:{backgroundColor:y.hex},title:y.name},y.hex))})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"be-favicon",className:"block text-sm font-medium text-gray-700",children:h("appDesigner.faviconUrl")}),e.jsxs("div",{className:"relative",children:[e.jsx(Lt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsx("input",{id:"be-favicon","data-testid":"branding-favicon-input",type:"text",value:d.favicon??"",onChange:y=>I({favicon:y.target.value}),placeholder:"https://example.com/favicon.ico",disabled:i,className:"block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50"})]})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{htmlFor:"be-font",className:"block text-sm font-medium text-gray-700",children:h("appDesigner.fontFamily")}),e.jsxs("div",{className:"relative",children:[e.jsx(Rt,{className:"absolute left-2.5 top-2.5 h-4 w-4 text-gray-400"}),e.jsxs("select",{id:"be-font","data-testid":"branding-font-select",value:d.fontFamily??"",onChange:y=>I({fontFamily:y.target.value||void 0}),disabled:i,className:"block w-full rounded-md border border-gray-300 py-2 pl-9 pr-3 text-sm shadow-sm outline-none transition-colors focus:border-blue-500 focus:ring-1 focus:ring-blue-500 disabled:cursor-not-allowed disabled:bg-gray-50 appearance-none",children:[e.jsx("option",{value:"",children:h("appDesigner.fontDefault")}),ms.map(y=>e.jsx("option",{value:y,children:y},y))]})]})]})]}),e.jsxs("div",{className:"flex-1 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:h("appDesigner.brandingPreview")}),e.jsxs("div",{"data-testid":"branding-mode-toggle",className:"flex rounded-md border border-gray-300 overflow-hidden",children:[e.jsxs("button",{"data-testid":"branding-mode-light",type:"button",onClick:()=>s("light"),className:ne("inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium transition-colors",x==="light"?"bg-blue-50 text-blue-700":"bg-white text-gray-600 hover:bg-gray-50"),children:[e.jsx(ha,{className:"h-3.5 w-3.5"}),h("appDesigner.modeLight")]}),e.jsxs("button",{"data-testid":"branding-mode-dark",type:"button",onClick:()=>s("dark"),className:ne("inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium transition-colors",x==="dark"?"bg-gray-800 text-gray-100":"bg-white text-gray-600 hover:bg-gray-50"),children:[e.jsx(fa,{className:"h-3.5 w-3.5"}),h("appDesigner.modeDark")]})]})]}),e.jsxs("div",{"data-testid":"branding-preview",className:ne("rounded-lg border p-4 transition-colors",k?"border-gray-700 bg-gray-900 text-gray-100":"border-gray-200 bg-white text-gray-800"),style:{fontFamily:d.fontFamily||"inherit"},children:[e.jsx("div",{className:"rounded-md p-3 mb-3",style:{backgroundColor:N},children:e.jsxs("div",{className:"flex items-center gap-3",children:[d.logo?e.jsx("img",{src:d.logo,alt:"Logo",className:"h-8 w-8 rounded object-contain bg-white/20"}):e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded bg-white/20 text-xs text-white",children:"Logo"}),e.jsx("span",{className:"text-sm font-semibold text-white",children:p})]})}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"h-4 w-4 rounded-full border border-gray-200",style:{backgroundColor:N}}),e.jsx("span",{className:ne("text-xs",k?"text-gray-400":"text-gray-500"),children:N})]}),e.jsx("button",{type:"button",className:"rounded-md px-3 py-1.5 text-xs font-medium text-white transition-colors",style:{backgroundColor:N},tabIndex:-1,children:h("appDesigner.brandingSampleButton")}),e.jsx("p",{className:ne("text-xs",k?"text-gray-400":"text-gray-500"),children:h("appDesigner.brandingSampleText")}),d.favicon&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:d.favicon,alt:"Favicon",className:"h-4 w-4 rounded object-contain"}),e.jsx("span",{className:ne("text-xs",k?"text-gray-400":"text-gray-500"),children:"Favicon"})]}),d.fontFamily&&e.jsxs("div",{className:ne("text-xs",k?"text-gray-400":"text-gray-500"),children:[h("appDesigner.fontFamily"),": ",d.fontFamily]})]})]}),e.jsxs("div",{"data-testid":"branding-preview-mobile",className:ne("mx-auto w-48 rounded-xl border-2 p-2 transition-colors",k?"border-gray-700 bg-gray-900":"border-gray-300 bg-white"),style:{fontFamily:d.fontFamily||"inherit"},children:[e.jsx("div",{className:"text-center text-[10px] font-medium text-gray-400 mb-1",children:h("appDesigner.mobilePreview")}),e.jsx("div",{className:"rounded-md p-2 mb-1",style:{backgroundColor:N},children:e.jsxs("div",{className:"flex items-center gap-1.5",children:[d.logo?e.jsx("img",{src:d.logo,alt:"Logo",className:"h-4 w-4 rounded object-contain bg-white/20"}):e.jsx("div",{className:"flex h-4 w-4 items-center justify-center rounded bg-white/20 text-[6px] text-white",children:"L"}),e.jsx("span",{className:"text-[9px] font-semibold text-white truncate",children:p})]})}),e.jsxs("div",{className:"space-y-1 px-1",children:[e.jsx("div",{className:ne("h-2 w-3/4 rounded",k?"bg-gray-700":"bg-gray-200")}),e.jsx("div",{className:ne("h-2 w-1/2 rounded",k?"bg-gray-700":"bg-gray-200")}),e.jsx("div",{className:ne("h-2 w-2/3 rounded",k?"bg-gray-700":"bg-gray-200")})]})]})]})]})]})}function st(...t){return le(oe(t))}function Is({versions:t,onRestore:r,className:p}){return e.jsxs("div",{className:st("flex flex-col",p),role:"region","aria-label":"Version history",children:[e.jsxs("div",{className:"p-3 border-b font-medium text-sm flex items-center gap-2",children:[e.jsx(ya,{className:"h-4 w-4"}),"Version History"]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:t.length===0?e.jsx("div",{className:"p-3 text-xs text-muted-foreground text-center",children:"No version history available"}):e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute left-5 top-0 bottom-0 w-px bg-border"}),t.map(i=>e.jsxs("div",{className:st("relative flex items-start gap-3 px-3 py-2 hover:bg-accent/50",i.isCurrent&&"bg-accent/30"),children:[e.jsx("div",{className:st("relative z-10 mt-1 h-2.5 w-2.5 rounded-full border-2 bg-background",i.isCurrent?"border-primary":"border-muted-foreground")}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs",children:[e.jsxs("span",{className:"font-medium",children:["v",i.version]}),i.isCurrent&&e.jsx("span",{className:"px-1 py-0.5 rounded bg-primary/10 text-primary text-[0.6rem]",children:"Current"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate",children:i.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-[0.65rem] text-muted-foreground/70",children:[e.jsx(va,{className:"h-2.5 w-2.5"}),e.jsx("span",{children:i.userName}),e.jsx(Kt,{className:"h-2.5 w-2.5 ml-1"}),e.jsx("span",{children:new Date(i.timestamp).toLocaleString()})]}),!i.isCurrent&&r&&e.jsx("button",{onClick:()=>r(i.version),className:"mt-1 text-[0.65rem] text-primary hover:underline",children:"Restore this version"})]})]},i.version))]})})]})}xe.register("page-designer",Ea,{label:"Page Designer",category:"Designer",inputs:[{name:"canvas",type:"code",label:"Canvas Configuration"},{name:"components",type:"code",label:"Components"},{name:"showComponentTree",type:"boolean",label:"Show Component Tree",defaultValue:!0},{name:"undoRedo",type:"boolean",label:"Undo/Redo",defaultValue:!0},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});xe.register("data-model-designer",Ma,{label:"Data Model Designer",category:"Designer",inputs:[{name:"entities",type:"code",label:"Entities"},{name:"relationships",type:"code",label:"Relationships"},{name:"autoLayout",type:"boolean",label:"Auto Layout",defaultValue:!1},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});xe.register("process-designer",La,{label:"Process Designer (BPMN)",category:"Designer",inputs:[{name:"processName",type:"string",label:"Process Name"},{name:"nodes",type:"code",label:"Nodes"},{name:"edges",type:"code",label:"Edges"},{name:"showMinimap",type:"boolean",label:"Show Minimap",defaultValue:!1},{name:"showToolbar",type:"boolean",label:"Show Toolbar",defaultValue:!0},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});xe.register("report-designer",Ua,{label:"Report Designer",category:"Designer",inputs:[{name:"reportName",type:"string",label:"Report Name"},{name:"objectName",type:"string",label:"Data Source Object"},{name:"sections",type:"code",label:"Sections"},{name:"showToolbar",type:"boolean",label:"Show Toolbar",defaultValue:!0},{name:"showPropertyPanel",type:"boolean",label:"Show Property Panel",defaultValue:!0},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});xe.register("app-creation-wizard",Za,{label:"App Creation Wizard",category:"Designer",inputs:[{name:"availableObjects",type:"code",label:"Available Objects"},{name:"templates",type:"code",label:"Templates"},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});xe.register("navigation-designer",Ja,{label:"Navigation Designer",category:"Designer",inputs:[{name:"items",type:"code",label:"Navigation Items"},{name:"showPreview",type:"boolean",label:"Show Preview",defaultValue:!0},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});xe.register("dashboard-editor",as,{label:"Dashboard Editor",category:"Designer",inputs:[{name:"schema",type:"code",label:"Dashboard Schema"},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});xe.register("page-canvas-editor",is,{label:"Page Canvas Editor",category:"Designer",inputs:[{name:"schema",type:"code",label:"Page Schema"},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});xe.register("object-view-configurator",ps,{label:"Object View Configurator",category:"Designer",inputs:[{name:"config",type:"code",label:"View Config"},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});xe.register("branding-editor",xs,{label:"Branding Editor",category:"Designer",inputs:[{name:"branding",type:"code",label:"Branding Config"},{name:"appTitle",type:"string",label:"App Title"},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]});export{Za as AppCreationWizard,xs as BrandingEditor,Ds as CollaborationProvider,Ye as ConfirmDialog,Ss as ConnectionStatusIndicator,as as DashboardEditor,Ma as DataModelDesigner,Es as EditorModeToggle,gt as Minimap,Ja as NavigationDesigner,ps as ObjectViewConfigurator,is as PageCanvasEditor,Ea as PageDesigner,La as ProcessDesigner,Xe as PropertyEditor,Ua as ReportDesigner,Is as VersionHistory,xt as useCanvasPanZoom,Ze as useClipboard,Me as useConfirmDialog,Pa as useDesignerHistory,_e as useMultiSelect,Ce as useUndoRedo};