@object-ui/plugin-designer 0.1.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +154 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3674 -828
- package/dist/index.umd.cjs +2 -2
- package/dist/{src → plugin-designer/src}/CollaborationProvider.d.ts +15 -2
- package/dist/{src → plugin-designer/src}/DataModelDesigner.d.ts +2 -1
- package/dist/{src → plugin-designer/src}/PageDesigner.d.ts +3 -2
- package/dist/{src → plugin-designer/src}/ProcessDesigner.d.ts +6 -2
- package/dist/{src → plugin-designer/src}/ReportDesigner.d.ts +0 -1
- package/dist/plugin-designer/src/ViewDesigner.d.ts +67 -0
- package/dist/plugin-designer/src/components/ConfirmDialog.d.ts +30 -0
- package/dist/plugin-designer/src/components/Minimap.d.ts +35 -0
- package/dist/plugin-designer/src/components/PropertyEditor.d.ts +43 -0
- package/dist/plugin-designer/src/components/VersionHistory.d.ts +34 -0
- package/dist/plugin-designer/src/components/index.d.ts +15 -0
- package/dist/plugin-designer/src/hooks/index.d.ts +17 -0
- package/dist/plugin-designer/src/hooks/useCanvasPanZoom.d.ts +40 -0
- package/dist/plugin-designer/src/hooks/useClipboard.d.ts +22 -0
- package/dist/plugin-designer/src/hooks/useConfirmDialog.d.ts +25 -0
- package/dist/plugin-designer/src/hooks/useMultiSelect.d.ts +27 -0
- package/dist/plugin-designer/src/hooks/useUndoRedo.d.ts +36 -0
- package/dist/plugin-designer/src/index.d.ts +17 -0
- package/package.json +11 -11
- package/dist/src/CollaborationProvider.d.ts.map +0 -1
- package/dist/src/DataModelDesigner.d.ts.map +0 -1
- package/dist/src/PageDesigner.d.ts.map +0 -1
- package/dist/src/ProcessDesigner.d.ts.map +0 -1
- package/dist/src/ReportDesigner.d.ts.map +0 -1
- package/dist/src/index.d.ts +0 -7
- package/dist/src/index.d.ts.map +0 -1
package/dist/index.umd.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(J,pe){typeof exports=="object"&&typeof module<"u"?pe(exports,require("@object-ui/core"),require("react"),require("lucide-react"),require("clsx"),require("tailwind-merge")):typeof define=="function"&&define.amd?define(["exports","@object-ui/core","react","lucide-react","clsx","tailwind-merge"],pe):(J=typeof globalThis<"u"?globalThis:J||self,pe(J.ObjectUIPluginDesigner={},J.ObjectUICore,J.React,J.lucideReact,J.clsx,J.tailwindMerge))})(this,(function(J,pe,n,h,ce,ue){"use strict";var Te={exports:{}},je={};var Le;function Be(){if(Le)return je;Le=1;var a=Symbol.for("react.transitional.element"),C=Symbol.for("react.fragment");function D(j,y,A){var w=null;if(A!==void 0&&(w=""+A),y.key!==void 0&&(w=""+y.key),"key"in y){A={};for(var g in y)g!=="key"&&(A[g]=y[g])}else A=y;return y=A.ref,{$$typeof:a,type:j,key:w,ref:y!==void 0?y:null,props:A}}return je.Fragment=C,je.jsx=D,je.jsxs=D,je}var Ne={};var Ge;function Je(){return Ge||(Ge=1,process.env.NODE_ENV!=="production"&&(function(){function a(c){if(c==null)return null;if(typeof c=="function")return c.$$typeof===q?null:c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case I:return"Fragment";case R:return"Profiler";case F:return"StrictMode";case V:return"Suspense";case K:return"SuspenseList";case re:return"Activity"}if(typeof c=="object")switch(typeof c.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),c.$$typeof){case f:return"Portal";case z:return c.displayName||"Context";case P:return(c._context.displayName||"Context")+".Consumer";case E:var L=c.render;return c=c.displayName,c||(c=L.displayName||L.name||"",c=c!==""?"ForwardRef("+c+")":"ForwardRef"),c;case Y:return L=c.displayName||null,L!==null?L:a(c.type)||"Memo";case X:L=c._payload,c=c._init;try{return a(c(L))}catch{}}return null}function C(c){return""+c}function D(c){try{C(c);var L=!1}catch{L=!0}if(L){L=console;var m=L.error,T=typeof Symbol=="function"&&Symbol.toStringTag&&c[Symbol.toStringTag]||c.constructor.name||"Object";return m.call(L,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",T),C(c)}}function j(c){if(c===I)return"<>";if(typeof c=="object"&&c!==null&&c.$$typeof===X)return"<...>";try{var L=a(c);return L?"<"+L+">":"<...>"}catch{return"<...>"}}function y(){var c=W.A;return c===null?null:c.getOwner()}function A(){return Error("react-stack-top-frame")}function w(c){if(te.call(c,"key")){var L=Object.getOwnPropertyDescriptor(c,"key").get;if(L&&L.isReactWarning)return!1}return c.key!==void 0}function g(c,L){function m(){oe||(oe=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",L))}m.isReactWarning=!0,Object.defineProperty(c,"key",{get:m,configurable:!0})}function N(){var c=a(this.type);return ee[c]||(ee[c]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),c=this.props.ref,c!==void 0?c:null}function o(c,L,m,T,b,r){var t=m.ref;return c={$$typeof:p,type:c,key:L,props:m,_owner:T},(t!==void 0?t:null)!==null?Object.defineProperty(c,"ref",{enumerable:!1,get:N}):Object.defineProperty(c,"ref",{enumerable:!1,value:null}),c._store={},Object.defineProperty(c._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(c,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(c,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:b}),Object.defineProperty(c,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:r}),Object.freeze&&(Object.freeze(c.props),Object.freeze(c)),c}function k(c,L,m,T,b,r){var t=L.children;if(t!==void 0)if(T)if(ne(t)){for(T=0;T<t.length;T++)u(t[T]);Object.freeze&&Object.freeze(t)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else u(t);if(te.call(L,"key")){t=a(c);var l=Object.keys(L).filter(function(i){return i!=="key"});T=0<l.length?"{key: someKey, "+l.join(": ..., ")+": ...}":"{key: someKey}",se[t+T]||(l=0<l.length?"{"+l.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,k,E,z,E),ue[E+k]=!0)}if(E=null,w!==void 0&&(h(w),E=""+w),b(a)&&(h(a.key),E=""+a.key),"key"in a){w={};for(var K in a)K!=="key"&&(w[K]=a[K])}else w=a;return E&&S(w,typeof t=="function"?t.displayName||t.name||"Unknown":t),P(t,E,w,i(),U,Z)}function T(t){v(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===I&&(t._payload.status==="fulfilled"?v(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function v(t){return typeof t=="object"&&t!==null&&t.$$typeof===j}var _=x,j=Symbol.for("react.transitional.element"),A=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),s=Symbol.for("react.consumer"),C=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),J=Symbol.for("react.activity"),ye=Symbol.for("react.client.reference"),B=_.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,oe=Object.prototype.hasOwnProperty,ve=Array.isArray,X=console.createTask?console.createTask:function(){return null};_={react_stack_bottom_frame:function(t){return t()}};var le,ie={},de=_.react_stack_bottom_frame.bind(_,d)(),ce=X(N(d)),ue={};F.Fragment=o,F.jsx=function(t,a,w){var k=1e4>B.recentlyCreatedOwnerStacks++;return y(t,a,w,!1,k?Error("react-stack-top-frame"):de,k?X(N(t)):ce)},F.jsxs=function(t,a,w){var k=1e4>B.recentlyCreatedOwnerStacks++;return y(t,a,w,!0,k?Error("react-stack-top-frame"):de,k?X(N(t)):ce)}})()),F}var $;function me(){return $||($=1,process.env.NODE_ENV==="production"?Y.exports=he():Y.exports=pe()),Y.exports}var e=me();function V(...n){return L.twMerge(G.clsx(n))}function ee({canvas:n={width:1200,height:800,gridSize:8,showGrid:!0,snapToGrid:!0},components:u=[],palette:h=xe,showComponentTree:N=!0,undoRedo:i=!0,readOnly:d=!1,onChange:b,className:S}){const[l,P]=x.useState(u),[y,T]=x.useState(null),[v,_]=x.useState(n.zoom??1),j=x.useMemo(()=>l.find(r=>r.id===y),[l,y]),A=x.useCallback((r,c)=>{if(d)return;const s={id:`comp-${Date.now()}`,type:r,label:c,position:{x:100,y:100,width:200,height:100},props:{}},C=[...l,s];P(C),T(s.id),b?.(C)},[l,d,b]),o=x.useCallback(r=>{if(d)return;const c=l.filter(s=>s.id!==r);P(c),y===r&&T(null),b?.(c)},[l,y,d,b]);return e.jsxs("div",{className:V("flex h-full w-full border rounded-lg overflow-hidden bg-background",S),children:[!d&&e.jsxs("div",{className:"w-60 border-r bg-muted/30 flex flex-col",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:h.map(r=>e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground px-2 py-1 uppercase",children:r.label}),r.items.map(c=>e.jsxs("button",{onClick:()=>A(c.type,c.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(f.Plus,{className:"h-3 w-3"}),c.label]},c.type))]},r.name))})]}),e.jsxs("div",{className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/20",children:[i&&!d&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:"Undo",children:e.jsx(f.Undo2,{className:"h-4 w-4"})}),e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:"Redo",children:e.jsx(f.Redo2,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:"Preview",children:e.jsx(f.Eye,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[Math.round(v*100),"%"]})]}),e.jsx("div",{className:"flex-1 overflow-auto bg-muted/10 p-4",children:e.jsx("div",{className:"relative bg-background border rounded shadow-sm mx-auto",style:{width:n.width*v,height:n.height*v,backgroundImage:n.showGrid?"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)":void 0,backgroundSize:n.showGrid&&n.gridSize?`${n.gridSize*v}px ${n.gridSize*v}px`:void 0},children:l.map(r=>e.jsxs("div",{className:V("absolute border rounded cursor-move select-none transition-shadow",y===r.id?"border-primary ring-2 ring-primary/20 shadow-md":"border-border hover:border-primary/50"),style:{left:r.position.x*v,top:r.position.y*v,width:typeof r.position.width=="number"?r.position.width*v:r.position.width,height:typeof r.position.height=="number"?r.position.height*v:r.position.height},onClick:()=>T(r.id),children:[e.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 bg-muted/50 text-xs border-b",children:[e.jsx(f.GripVertical,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:r.label??r.type}),!d&&e.jsx("button",{onClick:c=>{c.stopPropagation(),o(r.id)},className:"ml-auto p-0.5 rounded hover:bg-destructive/10",children:e.jsx(f.Trash2,{className:"h-3 w-3 text-destructive"})})]}),e.jsx("div",{className:"p-2 text-xs text-muted-foreground",children:r.type})]},r.id))})})]}),N&&e.jsxs("div",{className:"w-60 border-l bg-muted/30 flex flex-col",children:[e.jsxs("div",{className:"p-3 border-b font-medium text-sm flex items-center gap-2",children:[e.jsx(f.Layers,{className:"h-4 w-4"}),"Component Tree"]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:l.length===0?e.jsx("div",{className:"text-xs text-muted-foreground text-center py-4",children:"No components added yet"}):l.map(r=>e.jsx("button",{onClick:()=>T(r.id),className:V("w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded text-left",y===r.id?"bg-accent":"hover:bg-accent/50"),children:e.jsx("span",{className:"truncate",children:r.label??r.type})},r.id))}),j&&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: ",j.type]}),e.jsxs("div",{children:["ID: ",j.id]}),e.jsxs("div",{children:["Position: ",j.position.x,", ",j.position.y]}),e.jsxs("div",{children:["Size: ",j.position.width," × ",j.position.height]})]})]})]})]})}const xe=[{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 W(...n){return L.twMerge(G.clsx(n))}function te({entities:n=[],relationships:u=[],canvas:h={width:1200,height:800,showGrid:!0},showRelationshipLabels:N=!0,readOnly:i=!1,onEntitiesChange:d,onRelationshipsChange:b,className:S}){const[l,P]=x.useState(n),[y,T]=x.useState(u),[v,_]=x.useState(null),j=x.useCallback(()=>{if(i)return;const o={id:`entity-${Date.now()}`,name:`new_entity_${l.length+1}`,label:`New Entity ${l.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+l.length%4*280,y:50+Math.floor(l.length/4)*250}},r=[...l,o];P(r),_(o.id),d?.(r)},[l,i,d]),A=x.useCallback(o=>{if(i)return;const r=l.filter(s=>s.id!==o),c=y.filter(s=>s.sourceEntity!==o&&s.targetEntity!==o);P(r),T(c),v===o&&_(null),d?.(r),b?.(c)},[l,y,v,i,d,b]);return e.jsx("div",{className:W("flex h-full w-full border rounded-lg overflow-hidden bg-background",S),children:e.jsxs("div",{className:"flex flex-col w-full",children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/20",children:[e.jsx(f.Database,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:"Data Model Designer"}),e.jsx("div",{className:"flex-1"}),!i&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:j,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(f.Plus,{className:"h-3 w-3"})," Add Entity"]}),e.jsxs("button",{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(f.Link2,{className:"h-3 w-3"})," Add Relationship"]})]})]}),e.jsx("div",{className:"flex-1 overflow-auto bg-muted/10 p-4",children:e.jsxs("div",{className:"relative",style:{width:h.width,minHeight:h.height,backgroundImage:h.showGrid?"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)":void 0,backgroundSize:h.showGrid?"20px 20px":void 0},children:[e.jsx("svg",{className:"absolute inset-0 pointer-events-none",width:h.width,height:h.height,children:y.map(o=>{const r=l.find(s=>s.id===o.sourceEntity),c=l.find(s=>s.id===o.targetEntity);return!r||!c?null:e.jsxs("g",{children:[e.jsx("line",{x1:r.position.x+120,y1:r.position.y+50,x2:c.position.x+120,y2:c.position.y+50,stroke:"hsl(var(--primary))",strokeWidth:"2",strokeDasharray:o.type==="many-to-many"?"5,5":void 0}),N&&o.label&&e.jsx("text",{x:(r.position.x+c.position.x)/2+120,y:(r.position.y+c.position.y)/2+50-8,textAnchor:"middle",className:"text-xs fill-muted-foreground",children:o.label})]},o.id)})}),l.map(o=>e.jsxs("div",{className:W("absolute rounded-lg border-2 bg-background shadow-sm w-60 select-none",v===o.id?"border-primary ring-2 ring-primary/20":"border-border hover:border-primary/50"),style:{left:o.position.x,top:o.position.y},onClick:()=>_(o.id),children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-t-lg font-medium text-sm",style:{backgroundColor:o.color??"hsl(var(--primary) / 0.1)"},children:[e.jsx(f.Database,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"truncate",children:o.label}),!i&&e.jsx("button",{onClick:r=>{r.stopPropagation(),A(o.id)},className:"ml-auto p-0.5 rounded hover:bg-destructive/20",children:e.jsx(f.Trash2,{className:"h-3 w-3 text-destructive"})})]}),e.jsx("div",{className:"px-3 py-1 divide-y",children:o.fields.map(r=>e.jsxs("div",{className:"flex items-center gap-2 py-1 text-xs",children:[e.jsxs("span",{className:W("font-mono",r.primaryKey&&"font-bold text-primary"),children:[r.primaryKey?"🔑 ":"",r.name]}),e.jsx("span",{className:"text-muted-foreground ml-auto",children:r.type}),r.required&&e.jsx("span",{className:"text-destructive",children:"*"})]},r.name))})]},o.id))]})})]})})}function H(...n){return L.twMerge(G.clsx(n))}function re({processName:n="New Process",nodes:u=[],edges:h=[],lanes:N,canvas:i={width:1400,height:800,showGrid:!0},showToolbar:d=!0,readOnly:b=!1,onNodesChange:S,onEdgesChange:l,className:P}){const[y,T]=x.useState(u),[v,_]=x.useState(h),[j,A]=x.useState(null),o=x.useCallback((s,C)=>{if(b)return;const m={id:`node-${Date.now()}`,type:s,label:C,position:{x:200+y.length*160,y:200}},p=[...y,m];T(p),A(m.id),S?.(p)},[y,b,S]),r=x.useCallback(s=>{if(b)return;const C=y.filter(p=>p.id!==s),m=v.filter(p=>p.source!==s&&p.target!==s);T(C),_(m),j===s&&A(null),S?.(C),l?.(m)},[y,v,j,b,S,l]),c=s=>{switch(s){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"}};return e.jsxs("div",{className:H("flex flex-col h-full w-full border rounded-lg overflow-hidden bg-background",P),children:[d&&e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/20",children:[e.jsx(f.GitBranch,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:n}),e.jsx("div",{className:"flex-1"}),!b&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:()=>o("start-event","Start"),className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Add Start Event",children:[e.jsx(f.Play,{className:"h-3 w-3 text-green-600"})," Start"]}),e.jsxs("button",{onClick:()=>o("user-task","User Task"),className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Add User Task",children:[e.jsx(f.Square,{className:"h-3 w-3 text-blue-600"})," Task"]}),e.jsxs("button",{onClick:()=>o("exclusive-gateway","Decision"),className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Add Gateway",children:[e.jsx(f.Diamond,{className:"h-3 w-3 text-yellow-600"})," Gateway"]}),e.jsxs("button",{onClick:()=>o("end-event","End"),className:"flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",title:"Add End Event",children:[e.jsx(f.Square,{className:"h-3 w-3 text-red-600"})," End"]})]})]}),e.jsx("div",{className:"flex-1 overflow-auto bg-muted/10 p-4",children:e.jsxs("div",{className:"relative",style:{width:i.width,minHeight:i.height,backgroundImage:i.showGrid?"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)":void 0,backgroundSize:i.showGrid?"20px 20px":void 0},children:[e.jsxs("svg",{className:"absolute inset-0 pointer-events-none",width:i.width,height:i.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))"})})}),v.map(s=>{const C=y.find(p=>p.id===s.source),m=y.find(p=>p.id===s.target);return!C||!m?null:e.jsx("line",{x1:C.position.x+60,y1:C.position.y+25,x2:m.position.x,y2:m.position.y+25,stroke:"hsl(var(--foreground) / 0.5)",strokeWidth:"2",markerEnd:"url(#arrowhead)"},s.id)})]}),y.map(s=>e.jsxs("div",{className:"absolute select-none",style:{left:s.position.x,top:s.position.y},onClick:()=>A(s.id),children:[e.jsx("div",{className:H("flex items-center justify-center border-2 min-w-[120px] min-h-[50px] px-3 py-2",c(s.type),j===s.id&&"ring-2 ring-primary shadow-md"),children:e.jsx("span",{className:H("text-xs font-medium",(s.type==="exclusive-gateway"||s.type==="parallel-gateway")&&"-rotate-45"),children:s.label})}),!b&&j===s.id&&e.jsx("button",{onClick:C=>{C.stopPropagation(),r(s.id)},className:"absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow",children:e.jsx(f.Trash2,{className:"h-3 w-3"})})]},s.id))]})})]})}function se(...n){return L.twMerge(G.clsx(n))}const fe={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}};function ae({reportName:n="Untitled Report",objectName:u,pageSize:h="A4",orientation:N="portrait",margins:i={top:40,right:40,bottom:40,left:40},sections:d=[],showToolbar:b=!0,showPropertyPanel:S=!0,readOnly:l=!1,onSectionsChange:P,className:y}){const[T,v]=x.useState(d.length>0?d:[{type:"header",height:80,elements:[]},{type:"detail",height:400,elements:[],repeat:!0},{type:"footer",height:60,elements:[]}]),[_,j]=x.useState(null),A=fe[h],o=N==="landscape"?A.height:A.width,r=N==="landscape"?A.width:A.height,c=x.useCallback((m,p)=>{if(l)return;const g={id:`elem-${Date.now()}`,type:p,position:{x:i.left,y:10,width:200,height:30},properties:{text:p==="text"?"New Text":void 0,field:p==="field"?"field_name":void 0}},O=T.map((I,J)=>J===m?{...I,elements:[...I.elements,g]}:I);v(O),j(g.id),P?.(O)},[T,i.left,l,P]),s=x.useCallback(m=>{if(l)return;const p=T.map(g=>({...g,elements:g.elements.filter(O=>O.id!==m)}));v(p),_===m&&j(null),P?.(p)},[T,_,l,P]),C=m=>{switch(m){case"header":return"Report Header";case"page-header":return"Page Header";case"group-header":return"Group Header";case"detail":return"Detail";case"group-footer":return"Group Footer";case"page-footer":return"Page Footer";case"footer":return"Report Footer";default:return m}};return e.jsxs("div",{className:se("flex h-full w-full border rounded-lg overflow-hidden bg-background",y),children:[e.jsxs("div",{className:"flex-1 flex flex-col",children:[b&&e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/20",children:[e.jsx(f.FileText,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:n}),u&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",u,")"]}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[h," ",N]})]}),e.jsx("div",{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:o,minHeight:r},children:T.map((m,p)=>e.jsxs("div",{className:"relative border-b border-dashed border-gray-300",style:{minHeight:m.height},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:[C(m.type),m.repeat&&" ↻"]}),!l&&e.jsxs("div",{className:"absolute right-1 top-0 flex items-center gap-0.5",children:[e.jsx("button",{onClick:()=>c(p,"text"),className:"p-0.5 rounded hover:bg-accent",title:"Add Text",children:e.jsx(f.Type,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>c(p,"field"),className:"p-0.5 rounded hover:bg-accent",title:"Add Field",children:e.jsx(f.Plus,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>c(p,"image"),className:"p-0.5 rounded hover:bg-accent",title:"Add Image",children:e.jsx(f.ImageIcon,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>c(p,"chart"),className:"p-0.5 rounded hover:bg-accent",title:"Add Chart",children:e.jsx(f.BarChart3,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>c(p,"table"),className:"p-0.5 rounded hover:bg-accent",title:"Add Table",children:e.jsx(f.Table2,{className:"h-3 w-3"})})]}),e.jsx("div",{className:"relative",style:{minHeight:m.height,paddingTop:24},children:m.elements.map(g=>e.jsxs("div",{className:se("absolute border rounded px-2 py-1 text-xs cursor-pointer",_===g.id?"border-primary ring-1 ring-primary/30 bg-primary/5":"border-dashed border-gray-400 hover:border-primary/50"),style:{left:g.position.x,top:(typeof g.position.y=="number"?g.position.y:0)+24,width:g.position.width,height:g.position.height},onClick:()=>j(g.id),children:[e.jsxs("span",{className:"text-muted-foreground",children:[g.type==="text"&&(g.properties.text??"Text"),g.type==="field"&&`{${g.properties.field??"field"}}`,g.type==="image"&&"🖼 Image",g.type==="chart"&&"📊 Chart",g.type==="table"&&"📋 Table"]}),!l&&_===g.id&&e.jsx("button",{onClick:O=>{O.stopPropagation(),s(g.id)},className:"absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow",children:e.jsx(f.Trash2,{className:"h-2.5 w-2.5"})})]},g.id))})]},`${m.type}-${p}`))})})]}),S&&e.jsxs("div",{className:"w-56 border-l bg-muted/30 flex flex-col",children:[e.jsx("div",{className:"p-3 border-b font-medium text-sm",children:"Properties"}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3",children:_?e.jsx("div",{className:"space-y-2 text-xs",children:e.jsxs("div",{className:"text-muted-foreground",children:["Element ID: ",_]})}):e.jsx("div",{className:"text-xs text-muted-foreground text-center py-4",children:"Select an element to view properties"})})]})]})}const ne=x.createContext(null);ne.displayName="CollaborationContext";function be({config:n,user:u,onOperation:h,children:N}){const i=x.useMemo(()=>!n.enabled||!u?[]:[{userId:u.id,userName:u.name,avatar:u.avatar,color:ge(u.id),status:"active",lastActivity:new Date().toISOString()}],[n.enabled,u]),d=n.enabled&&!!u,b=x.useCallback(l=>{if(!d||!u)return;const P={...l,id:`op-${Date.now()}`,userId:u.id,timestamp:new Date().toISOString(),version:Date.now()};h?.(P)},[d,u,h]),S=x.useMemo(()=>({users:i,isConnected:d,sendOperation:b,currentUserId:u?.id}),[i,d,b,u?.id]);return e.jsx(ne.Provider,{value:S,children:N})}function ge(n){const u=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#f97316"];let h=0;for(let N=0;N<n.length;N++)h=(h<<5)-h+n.charCodeAt(N)|0;return u[Math.abs(h)%u.length]}D.ComponentRegistry.register("page-designer",ee,{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}]}),D.ComponentRegistry.register("data-model-designer",te,{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}]}),D.ComponentRegistry.register("process-designer",re,{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}]}),D.ComponentRegistry.register("report-designer",ae,{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}]}),R.CollaborationProvider=be,R.DataModelDesigner=te,R.PageDesigner=ee,R.ProcessDesigner=re,R.ReportDesigner=ae,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
|
|
6
|
+
<%s key={someKey} {...props} />`,T,t,l,t),se[t+T]=!0)}if(t=null,m!==void 0&&(D(m),t=""+m),w(L)&&(D(L.key),t=""+L.key),"key"in L){m={};for(var s in L)s!=="key"&&(m[s]=L[s])}else m=L;return t&&g(m,typeof c=="function"?c.displayName||c.name||"Unknown":c),o(c,t,m,y(),b,r)}function u(c){d(c)?c._store&&(c._store.validated=1):typeof c=="object"&&c!==null&&c.$$typeof===X&&(c._payload.status==="fulfilled"?d(c._payload.value)&&c._payload.value._store&&(c._payload.value._store.validated=1):c._store&&(c._store.validated=1))}function d(c){return typeof c=="object"&&c!==null&&c.$$typeof===p}var S=n,p=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),I=Symbol.for("react.fragment"),F=Symbol.for("react.strict_mode"),R=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),z=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),V=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),Y=Symbol.for("react.memo"),X=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),q=Symbol.for("react.client.reference"),W=S.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=Object.prototype.hasOwnProperty,ne=Array.isArray,ae=console.createTask?console.createTask:function(){return null};S={react_stack_bottom_frame:function(c){return c()}};var oe,ee={},le=S.react_stack_bottom_frame.bind(S,A)(),ie=ae(j(A)),se={};Ne.Fragment=I,Ne.jsx=function(c,L,m){var T=1e4>W.recentlyCreatedOwnerStacks++;return k(c,L,m,!1,T?Error("react-stack-top-frame"):le,T?ae(j(c)):ie)},Ne.jsxs=function(c,L,m){var T=1e4>W.recentlyCreatedOwnerStacks++;return k(c,L,m,!0,T?Error("react-stack-top-frame"):le,T?ae(j(c)):ie)}})()),Ne}var Ve;function Qe(){return Ve||(Ve=1,process.env.NODE_ENV==="production"?Te.exports=Be():Te.exports=Je()),Te.exports}var e=Qe();function xe(a,C={}){const{maxHistory:D=50}=C,[j,y]=n.useState(a),A=n.useRef([]),w=n.useRef([]),g=n.useCallback(u=>{y(d=>(A.current=[...A.current.slice(-(D-1)),d],w.current=[],u))},[D]),N=n.useCallback(()=>{A.current.length!==0&&y(u=>{const d=[...A.current],S=d.pop();return A.current=d,w.current=[u,...w.current],S})},[]),o=n.useCallback(()=>{w.current.length!==0&&y(u=>{const d=[...w.current],S=d.shift();return w.current=d,A.current=[...A.current,u],S})},[]),k=n.useCallback(u=>{A.current=[],w.current=[],y(u)},[]);return{current:j,canUndo:A.current.length>0,canRedo:w.current.length>0,undoCount:A.current.length,redoCount:w.current.length,push:g,undo:N,redo:o,reset:k}}function be(){const[a,C]=n.useState(!1),[D,j]=n.useState(""),[y,A]=n.useState(""),w=n.useRef(null),g=n.useCallback((k,u)=>(j(k),A(u),C(!0),new Promise(d=>{w.current=d})),[]),N=n.useCallback(()=>{C(!1),w.current?.(!0),w.current=null},[]),o=n.useCallback(()=>{C(!1),w.current?.(!1),w.current=null},[]);return{isOpen:a,title:D,message:y,confirm:g,onConfirm:N,onCancel:o}}function Ce(){const[a,C]=n.useState(new Set),D=n.useCallback((g,N=!1)=>{C(o=>{const k=new Set(N?o:[]);return o.has(g)&&N?k.delete(g):k.add(g),k})},[]),j=n.useCallback(g=>{C(new Set([g]))},[]),y=n.useCallback(g=>{C(new Set(g))},[]),A=n.useCallback(()=>{C(new Set)},[]),w=n.useCallback(g=>a.has(g),[a]);return{selectedIds:a,toggle:D,selectOne:j,selectMany:y,clearSelection:A,isSelected:w,count:a.size}}function fe(){const[a,C]=n.useState(null),D=n.useCallback(y=>{C(structuredClone(y))},[]),j=n.useCallback(()=>a?structuredClone(a):null,[a]);return{clipboard:a,copy:D,paste:j,hasContent:a!==null}}function Ie(a={}){const{minZoom:C=.25,maxZoom:D=3,zoomStep:j=.1,initialZoom:y=1}=a,[A,w]=n.useState(y),[g,N]=n.useState({x:0,y:0}),o=n.useRef(!1),k=n.useRef({x:0,y:0}),u=n.useCallback(P=>Math.min(D,Math.max(C,+P.toFixed(2))),[C,D]),d=n.useCallback(()=>w(P=>u(P+j)),[u,j]),S=n.useCallback(()=>w(P=>u(P-j)),[u,j]),p=n.useCallback(()=>{w(1),N({x:0,y:0})},[]),f=n.useCallback(P=>w(u(P)),[u]),I=n.useCallback(P=>{if(P.ctrlKey||P.metaKey){P.preventDefault();const z=P.deltaY>0?-j:j;w(E=>u(E+z))}},[u,j]),F=n.useCallback(P=>{if(P.button===1||P.button===0&&P.altKey){P.preventDefault(),o.current=!0,k.current={x:P.clientX,y:P.clientY};const z=V=>{if(!o.current)return;const K=V.clientX-k.current.x,Y=V.clientY-k.current.y;k.current={x:V.clientX,y:V.clientY},N(X=>({x:X.x+K,y:X.y+Y}))},E=()=>{o.current=!1,document.removeEventListener("mousemove",z),document.removeEventListener("mouseup",E)};document.addEventListener("mousemove",z),document.addEventListener("mouseup",E)}},[]),R={transform:`translate(${g.x}px, ${g.y}px) scale(${A})`,transformOrigin:"0 0"};return{zoom:A,panOffset:g,zoomIn:d,zoomOut:S,resetZoom:p,setZoom:f,handleWheel:I,startPan:F,transformStyle:R}}function Oe(...a){return ue.twMerge(ce.clsx(a))}function ge({isOpen:a,title:C,message:D,confirmLabel:j="Delete",cancelLabel:y="Cancel",destructive:A=!0,onConfirm:w,onCancel:g}){const N=n.useRef(null);return n.useEffect(()=>{const o=N.current;o&&(a&&!o.open?o.showModal():!a&&o.open&&o.close())},[a]),a?e.jsx("dialog",{ref:N,className:"fixed inset-0 z-50 m-auto rounded-lg border bg-background p-0 shadow-lg backdrop:bg-black/50",onClose:g,"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:[A&&e.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded-full bg-destructive/10",children:e.jsx(h.AlertTriangle,{className:"h-5 w-5 text-destructive"})}),e.jsx("h2",{id:"confirm-title",className:"text-lg font-semibold",children:C})]}),e.jsx("p",{id:"confirm-message",className:"text-sm text-muted-foreground mb-6",children:D}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx("button",{onClick:g,className:"px-4 py-2 text-sm rounded-md border hover:bg-accent",children:y}),e.jsx("button",{onClick:w,className:Oe("px-4 py-2 text-sm rounded-md font-medium",A?"bg-destructive text-destructive-foreground hover:bg-destructive/90":"bg-primary text-primary-foreground hover:bg-primary/90"),autoFocus:!0,children:j})]})]})}):null}function qe(...a){return ue.twMerge(ce.clsx(a))}function ke({title:a="Properties",fields:C,onChange:D,className:j}){const[y,A]=n.useState(new Set),w=n.useCallback(N=>{A(o=>{const k=new Set(o);return k.has(N)?k.delete(N):k.add(N),k})},[]),g=C.reduce((N,o)=>{const k=o.group??"General";return N[k]||(N[k]=[]),N[k].push(o),N},{});return e.jsxs("div",{className:qe("flex flex-col",j),role:"region","aria-label":a,children:[e.jsx("div",{className:"p-3 border-b font-medium text-sm",children:a}),e.jsxs("div",{className:"flex-1 overflow-y-auto",children:[Object.entries(g).map(([N,o])=>e.jsxs("div",{className:"border-b last:border-b-0",children:[e.jsxs("button",{onClick:()=>w(N),className:"w-full flex items-center gap-1 px-3 py-2 text-xs font-medium text-muted-foreground hover:bg-accent/50",children:[y.has(N)?e.jsx(h.ChevronRight,{className:"h-3 w-3"}):e.jsx(h.ChevronDown,{className:"h-3 w-3"}),N]}),!y.has(N)&&e.jsx("div",{className:"px-3 pb-2 space-y-2",children:o.map(k=>e.jsx($e,{field:k,onChange:D},k.name))})]},N)),C.length===0&&e.jsx("div",{className:"p-3 text-xs text-muted-foreground text-center",children:"Select an element to edit its properties"})]})]})}function $e({field:a,onChange:C}){const D=j=>{C(a.name,j)};return e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:a.label}),a.type==="text"&&e.jsx("input",{type:"text",value:String(a.value??""),onChange:j=>D(j.target.value),className:"w-full px-2 py-1 text-xs border rounded bg-background"}),a.type==="number"&&e.jsx("input",{type:"number",value:Number(a.value??0),onChange:j=>D(Number(j.target.value)),className:"w-full px-2 py-1 text-xs border rounded bg-background"}),a.type==="boolean"&&e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:!!a.value,onChange:j=>D(j.target.checked),className:"rounded"}),e.jsx("span",{className:"text-xs",children:a.value?"Yes":"No"})]}),a.type==="select"&&e.jsx("select",{value:String(a.value??""),onChange:j=>D(j.target.value),className:"w-full px-2 py-1 text-xs border rounded bg-background",children:a.options?.map(j=>e.jsx("option",{value:j.value,children:j.label},j.value))}),a.type==="color"&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:String(a.value??"#000000"),onChange:j=>D(j.target.value),className:"h-6 w-6 rounded border cursor-pointer"}),e.jsx("span",{className:"text-xs font-mono",children:String(a.value??"#000000")})]}),a.type==="textarea"&&e.jsx("textarea",{value:String(a.value??""),onChange:j=>D(j.target.value),className:"w-full px-2 py-1 text-xs border rounded bg-background resize-y",rows:3}),a.description&&e.jsx("p",{className:"text-[0.65rem] text-muted-foreground/70",children:a.description})]})}function et(...a){return ue.twMerge(ce.clsx(a))}function Ae({items:a,canvasWidth:C,canvasHeight:D,position:j="bottom-right",size:y=150,className:A}){const w=Math.min(y/C,y/D),g=C*w,N=D*w,o={"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:et("absolute border rounded bg-background/90 shadow-sm overflow-hidden",o[j],A),role:"img","aria-label":"Canvas minimap",children:e.jsxs("svg",{width:g,height:N,viewBox:`0 0 ${C} ${D}`,children:[e.jsx("rect",{width:C,height:D,fill:"hsl(var(--muted))",opacity:"0.3"}),a.map(k=>e.jsx("rect",{x:k.x,y:k.y,width:k.width,height:k.height,fill:k.selected?"hsl(var(--primary))":k.color??"hsl(var(--foreground) / 0.3)",rx:"2"},k.id))]})})}function tt(...a){return ue.twMerge(ce.clsx(a))}const Fe=n.createContext(null);Fe.displayName="CollaborationContext";function st({config:a,user:C,onOperation:D,onPresenceChange:j,children:y}){const A=n.useRef(null),[w,g]=n.useState([]),[N,o]=n.useState("disconnected"),k=n.useRef(0),u=n.useRef(null);n.useEffect(()=>{if(!a.enabled||!C||!a.serverUrl||!(typeof WebSocket<"u"))return;function F(){let R;try{if(R=new URL(a.serverUrl),R.protocol!=="ws:"&&R.protocol!=="wss:")return}catch{return}a.roomId&&R.searchParams.set("room",a.roomId),R.searchParams.set("userId",C.id),o("connecting");const P=new WebSocket(R.toString());P.onopen=()=>{o("connected"),P.send(JSON.stringify({type:"join",userId:C.id,userName:C.name,avatar:C.avatar}))},P.onmessage=z=>{try{const E=JSON.parse(z.data);if(E.type==="presence"){const V=E.users||[];g(V.filter(K=>K.userId!==C.id)),j?.(V)}else E.type==="operation"&&D?.(E.operation)}catch{}},P.onclose=()=>{o("disconnected"),A.current=null,a.enabled&&(u.current=setTimeout(F,a.autoSaveInterval??3e3))},P.onerror=()=>{o("error")},A.current=P}return F(),()=>{u.current&&clearTimeout(u.current),A.current&&(A.current.onclose=null,A.current.close(),A.current=null),o("disconnected")}},[a.enabled,a.serverUrl,a.roomId,a.autoSaveInterval,C,D,j]);const d=n.useMemo(()=>!a.enabled||!C?[]:[{userId:C.id,userName:C.name,avatar:C.avatar,color:at(C.id),status:"active",lastActivity:new Date().toISOString()},...w],[a.enabled,C,w]),S=a.enabled&&!!C&&(a.serverUrl?N==="connected":!0),p=n.useCallback(I=>{if(!a.enabled||!C)return;k.current+=1;const F={...I,id:`op-${Date.now()}-${k.current}`,userId:C.id,timestamp:new Date().toISOString(),version:k.current};A.current?.readyState===WebSocket.OPEN&&A.current.send(JSON.stringify({type:"operation",operation:F})),D?.(F)},[a.enabled,C,D]),f=n.useMemo(()=>({users:d,isConnected:S,sendOperation:p,currentUserId:C?.id,connectionState:N,versionCount:k.current}),[d,S,p,C?.id,N]);return e.jsx(Fe.Provider,{value:f,children:y})}function Se(){return n.useContext(Fe)}function nt({className:a}){const C=n.useContext(Fe);if(!C)return null;const{connectionState:D,users:j}=C,y={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:A,label:w}=y[D]??y.disconnected;return e.jsxs("div",{className:tt("flex items-center gap-2 text-xs",a),role:"status","aria-live":"polite","aria-label":`Collaboration: ${w}`,children:[e.jsx("span",{className:`inline-block h-2 w-2 rounded-full ${A}`}),e.jsx("span",{children:w}),D==="connected"&&j.length>1&&e.jsxs("span",{className:"text-muted-foreground",children:["(",j.length," users)"]})]})}function at(a){const C=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#f97316","#14b8a6","#f43f5e","#a855f7","#84cc16","#0ea5e9","#e879f9","#fb923c","#facc15"];let D=0;for(let j=0;j<a.length;j++)D=(D<<5)-D+a.charCodeAt(j)|0;return C[Math.abs(D)%C.length]}function de(...a){return ue.twMerge(ce.clsx(a))}function Ye({canvas:a={width:1200,height:800,gridSize:8,showGrid:!0,snapToGrid:!0},components:C=[],palette:D=ot,showComponentTree:j=!0,undoRedo:y=!0,propertyEditor:A=!0,readOnly:w=!1,showMinimap:g=!1,onChange:N,className:o}){const k=xe(C),u=k.current,d=n.useCallback(r=>{k.push(r),N?.(r)},[k,N]),S=Ie({initialZoom:a.zoom??1}),{zoom:p}=S,f=Ce(),I=n.useMemo(()=>{const r=Array.from(f.selectedIds);return r.length>0?r[0]:null},[f.selectedIds]),F=n.useMemo(()=>u.find(r=>r.id===I),[u,I]),R=fe(),P=be(),z=Se(),E=n.useCallback(r=>{z&&z.sendOperation({...r,userId:z.currentUserId??""})},[z]),[V,K]=n.useState(!0),[Y,X]=n.useState(!0),[re,q]=n.useState(g),W=n.useRef(null),te=n.useRef(null),ne=n.useCallback(r=>!a.snapToGrid||!a.gridSize?r:Math.round(r/a.gridSize)*a.gridSize,[a.snapToGrid,a.gridSize]),ae=n.useCallback((r,t)=>{if(w)return;const l=D.flatMap(M=>M.items).find(M=>M.type===r),s=l?.defaultSize,i={id:`comp-${Date.now()}`,type:r,label:t,position:{x:100,y:100,width:s?.width??200,height:s?.height??100},props:l?.defaultProps??{}},v=[...u,i];d(v),f.selectOne(i.id),E({type:"insert",elementId:i.id,data:{component:i}})},[u,w,D,d,f,E]),oe=n.useCallback(r=>{if(w)return;const t=u.filter(l=>l.id!==r);d(t),f.isSelected(r)&&f.clearSelection(),E({type:"delete",elementId:r,data:{}})},[u,w,d,f,E]),ee=n.useCallback(async()=>{if(w||f.count===0||!await P.confirm("Delete components",`Are you sure you want to delete ${f.count} component${f.count>1?"s":""}?`))return;const t=f.selectedIds,l=u.filter(s=>!t.has(s.id));d(l),f.clearSelection(),t.forEach(s=>{E({type:"delete",elementId:s,data:{}})})},[w,f,P,u,d,E]),le=n.useCallback((r,t)=>{if(w||!I)return;const l=u.map(s=>s.id!==I?s:r==="label"?{...s,label:String(t)}:r==="x"?{...s,position:{...s.position,x:Number(t)}}:r==="y"?{...s,position:{...s.position,y:Number(t)}}:r==="width"?{...s,position:{...s.position,width:Number(t)}}:r==="height"?{...s,position:{...s.position,height:Number(t)}}:{...s,props:{...s.props,[r]:t}});d(l),E({type:"update",elementId:I,data:{[r]:t}})},[w,I,u,d,E]),ie=n.useCallback(()=>{const r=f.selectedIds;if(r.size===0)return;const t=u.filter(l=>r.has(l.id));R.copy(t)},[f,u,R]),se=n.useCallback(()=>{if(w)return;const r=R.paste();if(!r||r.length===0)return;let t=0;const l=r.map(i=>({...i,id:`comp-${Date.now()}-${++t}-${Math.random().toString(36).slice(2,7)}`,position:{...i.position,x:i.position.x+20,y:i.position.y+20}})),s=[...u,...l];d(s),f.selectMany(l.map(i=>i.id)),l.forEach(i=>{E({type:"insert",elementId:i.id,data:{component:i}})})},[w,R,u,d,f,E]),c=n.useCallback((r,t)=>{w||(W.current={id:t.id,startX:r.clientX,startY:r.clientY},r.dataTransfer.effectAllowed="move",r.dataTransfer.setData("text/plain",t.id))},[w]),L=n.useCallback(r=>{r.preventDefault(),r.dataTransfer.dropEffect="move"},[]),m=n.useCallback(r=>{r.preventDefault();const t=W.current;if(!t||w)return;const l=(r.clientX-t.startX)/p,s=(r.clientY-t.startY)/p,i=u.map(v=>v.id!==t.id?v:{...v,position:{...v.position,x:ne(v.position.x+l),y:ne(v.position.y+s)}});d(i),E({type:"move",elementId:t.id,data:{}}),W.current=null},[w,p,u,d,ne,E]),T=n.useMemo(()=>F?[{name:"label",label:"Label",type:"text",value:F.label??"",group:"General"},{name:"x",label:"X",type:"number",value:F.position.x,group:"Position"},{name:"y",label:"Y",type:"number",value:F.position.y,group:"Position"},{name:"width",label:"Width",type:"number",value:F.position.width,group:"Size"},{name:"height",label:"Height",type:"number",value:F.position.height,group:"Size"}]:[],[F]),b=n.useMemo(()=>u.map(r=>({id:r.id,x:r.position.x,y:r.position.y,width:typeof r.position.width=="number"?r.position.width:100,height:typeof r.position.height=="number"?r.position.height:50,selected:f.isSelected(r.id)})),[u,f]);return n.useEffect(()=>{const r=te.current;if(!r)return;const t=l=>{const s=["INPUT","TEXTAREA","SELECT"].includes(l.target.tagName),i=l.ctrlKey||l.metaKey;if((l.key==="Delete"||l.key==="Backspace")&&f.count>0&&!s){l.preventDefault(),ee();return}if(l.key==="Escape"){f.clearSelection();return}if(!s){if(i&&l.key==="z"&&!l.shiftKey&&y&&!w){l.preventDefault(),k.undo();return}if(i&&(l.key==="z"&&l.shiftKey||l.key==="y")&&y&&!w){l.preventDefault(),k.redo();return}if(i&&l.key==="c"){l.preventDefault(),ie();return}if(i&&l.key==="v"&&!w){l.preventDefault(),se();return}if(i&&l.key==="a"){l.preventDefault(),f.selectMany(u.map(v=>v.id));return}}};return r.addEventListener("keydown",t),()=>r.removeEventListener("keydown",t)},[f,ee,y,w,k,ie,se,u]),e.jsxs("div",{ref:te,tabIndex:0,className:de("flex h-full w-full border rounded-lg overflow-hidden bg-background",o),children:[!w&&e.jsx("div",{className:de("border-r bg-muted/30 flex flex-col transition-[width] duration-200",V?"w-60":"w-0 overflow-hidden"),role:"region","aria-label":"Component palette",children:V&&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:D.map(r=>e.jsxs("div",{className:"mb-3",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground px-2 py-1 uppercase",children:r.label}),r.items.map(t=>e.jsxs("button",{onClick:()=>ae(t.type,t.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(h.Plus,{className:"h-3 w-3"}),t.label]},t.type))]},r.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:[!w&&e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:V?"Collapse palette":"Expand palette","aria-label":V?"Collapse palette":"Expand palette",onClick:()=>K(r=>!r),children:e.jsx(h.PanelLeftClose,{className:de("h-4 w-4",!V&&"rotate-180")})}),y&&!w&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-5 bg-border mx-1"}),e.jsx("button",{className:de("p-1.5 rounded hover:bg-accent",!k.canUndo&&"opacity-40 pointer-events-none"),title:"Undo (Ctrl+Z)","aria-label":"Undo",disabled:!k.canUndo,onClick:()=>k.undo(),children:e.jsx(h.Undo2,{className:"h-4 w-4"})}),e.jsx("button",{className:de("p-1.5 rounded hover:bg-accent",!k.canRedo&&"opacity-40 pointer-events-none"),title:"Redo (Ctrl+Shift+Z)","aria-label":"Redo",disabled:!k.canRedo,onClick:()=>k.redo(),children:e.jsx(h.Redo2,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),!w&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:de("p-1.5 rounded hover:bg-accent",f.count===0&&"opacity-40 pointer-events-none"),title:"Copy (Ctrl+C)","aria-label":"Copy",disabled:f.count===0,onClick:ie,children:e.jsx(h.Copy,{className:"h-4 w-4"})}),e.jsx("button",{className:de("p-1.5 rounded hover:bg-accent",!R.hasContent&&"opacity-40 pointer-events-none"),title:"Paste (Ctrl+V)","aria-label":"Paste",disabled:!R.hasContent,onClick:se,children:e.jsx(h.Clipboard,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),!w&&e.jsx("button",{className:de("p-1.5 rounded hover:bg-accent",f.count===0&&"opacity-40 pointer-events-none"),title:"Delete selected","aria-label":"Delete selected",disabled:f.count===0,onClick:ee,children:e.jsx(h.Trash2,{className:"h-4 w-4"})}),e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:"Preview","aria-label":"Preview",children:e.jsx(h.Eye,{className:"h-4 w-4"})}),e.jsx("button",{className:de("p-1.5 rounded hover:bg-accent",re&&"bg-accent"),title:"Toggle minimap","aria-label":"Toggle minimap",onClick:()=>q(r=>!r),children:e.jsx(h.Map,{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:S.zoomOut,children:e.jsx(h.Minus,{className:"h-3 w-3"})}),e.jsxs("span",{className:"text-xs text-muted-foreground w-10 text-center",children:[Math.round(p*100),"%"]}),e.jsx("button",{className:"p-1 rounded hover:bg-accent text-xs","aria-label":"Zoom in",onClick:S.zoomIn,children:e.jsx(h.Plus,{className:"h-3 w-3"})}),e.jsx("button",{className:"p-1 rounded hover:bg-accent text-xs","aria-label":"Reset zoom",onClick:S.resetZoom,children:e.jsx(h.Maximize2,{className:"h-3 w-3"})})]}),j&&e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:Y?"Collapse panel":"Expand panel","aria-label":Y?"Collapse panel":"Expand panel",onClick:()=>X(r=>!r),children:e.jsx(h.PanelRightClose,{className:de("h-4 w-4",!Y&&"rotate-180")})})]}),e.jsx("div",{className:"flex-1 overflow-auto bg-muted/10 p-4 relative",role:"region","aria-label":"Design canvas",onWheel:S.handleWheel,onMouseDown:S.startPan,onDragOver:L,onDrop:m,children:e.jsxs("div",{className:"relative bg-background border rounded shadow-sm mx-auto",style:{width:a.width*p,height:a.height*p,transform:`translate(${S.panOffset.x}px, ${S.panOffset.y}px)`,backgroundImage:a.showGrid?"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)":void 0,backgroundSize:a.showGrid&&a.gridSize?`${a.gridSize*p}px ${a.gridSize*p}px`:void 0},children:[u.map(r=>{const t=f.isSelected(r.id);return e.jsxs("div",{draggable:!w,onDragStart:l=>c(l,r),className:de("absolute border rounded cursor-move select-none transition-shadow",t?"border-primary ring-2 ring-primary/20 shadow-md":"border-border hover:border-primary/50"),style:{left:r.position.x*p,top:r.position.y*p,width:typeof r.position.width=="number"?r.position.width*p:r.position.width,height:typeof r.position.height=="number"?r.position.height*p:r.position.height},onClick:l=>f.toggle(r.id,l.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(h.GripVertical,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:r.label??r.type}),!w&&e.jsx("button",{onClick:l=>{l.stopPropagation(),oe(r.id)},className:"ml-auto p-0.5 rounded hover:bg-destructive/10","aria-label":`Delete ${r.label??r.type}`,children:e.jsx(h.Trash2,{className:"h-3 w-3 text-destructive"})})]}),e.jsx("div",{className:"p-2 text-xs text-muted-foreground",children:r.type})]},r.id)}),re&&e.jsx(Ae,{items:b,canvasWidth:a.width,canvasHeight:a.height})]})})]}),j&&e.jsx("div",{className:de("border-l bg-muted/30 flex flex-col transition-[width] duration-200",Y?"w-60":"w-0 overflow-hidden"),role:"region","aria-label":"Component tree",children:Y&&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(h.Layers,{className:"h-4 w-4"}),"Component Tree"]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:u.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."}):u.map(r=>e.jsx("button",{onClick:t=>f.toggle(r.id,t.shiftKey),className:de("w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded text-left",f.isSelected(r.id)?"bg-accent":"hover:bg-accent/50"),children:e.jsx("span",{className:"truncate",children:r.label??r.type})},r.id))}),A&&F?e.jsx("div",{className:"border-t",children:e.jsx(ke,{title:`Properties – ${F.label??F.type}`,fields:T,onChange:le})}):F&&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: ",F.type]}),e.jsxs("div",{children:["ID: ",F.id]}),e.jsxs("div",{children:["Position: ",F.position.x,","," ",F.position.y]}),e.jsxs("div",{children:["Size: ",F.position.width," ×"," ",F.position.height]})]})]})]})}),e.jsx(ge,{isOpen:P.isOpen,title:P.title,message:P.message,onConfirm:P.onConfirm,onCancel:P.onCancel})]})}const ot=[{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 _e(...a){return ue.twMerge(ce.clsx(a))}function rt(a,C=4,D=280,j=250,y=50,A=50){return a.map((w,g)=>({...w,position:{x:y+g%C*D,y:A+Math.floor(g/C)*j}}))}function Ze({entities:a=[],relationships:C=[],canvas:D={width:1200,height:800,showGrid:!0},showRelationshipLabels:j=!0,readOnly:y=!1,onEntitiesChange:A,onRelationshipsChange:w,className:g}){const N=n.useRef(null),o=xe({entities:a,relationships:C},{maxHistory:50}),{entities:k,relationships:u}=o.current,d=n.useCallback(s=>{o.push(s),A?.(s.entities),w?.(s.relationships)},[o,A,w]),S=be(),p=Ce(),f=p.count>0?Array.from(p.selectedIds)[0]:null,I=fe(),F=Ie({minZoom:.25,maxZoom:3,zoomStep:.1}),R=Se(),[P,z]=n.useState(!0),[E,V]=n.useState(!0),[K,Y]=n.useState(null),[X,re]=n.useState(""),q=n.useRef(null),W=n.useCallback(()=>{if(y)return;const s=o.current,i={id:`entity-${Date.now()}`,name:`new_entity_${s.entities.length+1}`,label:`New Entity ${s.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+s.entities.length%4*280,y:50+Math.floor(s.entities.length/4)*250}},v={entities:[...s.entities,i],relationships:s.relationships};d(v),p.selectOne(i.id),R?.sendOperation({type:"insert",userId:R?.currentUserId??"",elementId:i.id,data:{name:i.name,label:i.label}})},[y,o,d,p,R]),te=n.useCallback(async s=>{if(y)return;const i=k.find($=>$.id===s);if(!await S.confirm("Delete Entity",`Are you sure you want to delete "${i?.label??s}"? This action cannot be undone.`))return;const M=o.current,H={entities:M.entities.filter($=>$.id!==s),relationships:M.relationships.filter($=>$.sourceEntity!==s&&$.targetEntity!==s)};d(H),p.isSelected(s)&&p.clearSelection(),R?.sendOperation({type:"delete",userId:R?.currentUserId??"",elementId:s,data:{}})},[y,k,S,o,d,p,R]),ne=n.useCallback(async()=>{if(y||p.count===0)return;const s=Array.from(p.selectedIds);if(!await S.confirm("Delete Entities",`Are you sure you want to delete ${s.length} selected entity(s)? This action cannot be undone.`))return;const v=o.current,M=new Set(s),H={entities:v.entities.filter($=>!M.has($.id)),relationships:v.relationships.filter($=>!M.has($.sourceEntity)&&!M.has($.targetEntity))};d(H),p.clearSelection()},[y,p,S,o,d]),ae=n.useCallback(()=>{if(y)return;const s=o.current,i={entities:rt(s.entities),relationships:s.relationships};d(i)},[y,o,d]),oe=n.useCallback(()=>{const s=k.filter(i=>p.isSelected(i.id));s.length>0&&I.copy(s)},[k,p,I]),ee=n.useCallback(()=>{if(y)return;const s=I.paste();if(!s||s.length===0)return;const i=o.current,v=s.map((H,$)=>({...H,id:`entity-${Date.now()}-${$}`,name:`${H.name}_copy`,label:`${H.label} (Copy)`,position:{x:H.position.x+30,y:H.position.y+30}})),M={entities:[...i.entities,...v],relationships:i.relationships};d(M),p.selectMany(v.map(H=>H.id))},[y,I,o,d,p]),le=n.useCallback(s=>{if(y)return;const i=o.current,v={entities:i.entities.map(M=>{if(M.id!==s)return M;const H={name:`field_${M.fields.length+1}`,type:"text",required:!1};return{...M,fields:[...M.fields,H]}}),relationships:i.relationships};d(v)},[y,o,d]),ie=n.useCallback((s,i,v)=>{y||(Y({entityId:s,fieldIndex:i}),re(v))},[y]),se=n.useCallback(()=>{if(!K)return;const s=X.trim();if(s===""){Y(null);return}const i=o.current,v={entities:i.entities.map(M=>{if(M.id!==K.entityId)return M;const H=M.fields.map(($,De)=>De===K.fieldIndex?{...$,name:s}:$);return{...M,fields:H}}),relationships:i.relationships};d(v),Y(null)},[K,X,o,d]),c=n.useCallback(()=>{Y(null)},[]),L=n.useCallback((s,i)=>{if(y||!k.find(H=>H.id===i))return;const M=s.target.getBoundingClientRect();q.current={entityId:i,offsetX:s.clientX-M.left,offsetY:s.clientY-M.top},s.dataTransfer.effectAllowed="move",s.dataTransfer.setData("text/plain",i)},[y,k]),m=n.useCallback(s=>{s.preventDefault(),s.dataTransfer.dropEffect="move"},[]),T=n.useCallback(s=>{if(s.preventDefault(),!q.current)return;const i=s.currentTarget.getBoundingClientRect(),v=F.zoom,M=(s.clientX-i.left-F.panOffset.x)/v-q.current.offsetX,H=(s.clientY-i.top-F.panOffset.y)/v-q.current.offsetY,$=o.current,De={entities:$.entities.map(Pe=>Pe.id===q.current.entityId?{...Pe,position:{x:Math.max(0,Math.round(M)),y:Math.max(0,Math.round(H))}}:Pe),relationships:$.relationships};d(De),q.current=null},[F.zoom,F.panOffset,o,d]),b=f?k.find(s=>s.id===f):null,r=b?[{name:"name",label:"Name",type:"text",value:b.name,group:"General"},{name:"label",label:"Label",type:"text",value:b.label,group:"General"},{name:"description",label:"Description",type:"textarea",value:b.description??"",group:"General"},{name:"color",label:"Color",type:"color",value:b.color??"#3b82f6",group:"Appearance"},{name:"position.x",label:"X Position",type:"number",value:b.position.x,group:"Position"},{name:"position.y",label:"Y Position",type:"number",value:b.position.y,group:"Position"}]:[],t=n.useCallback((s,i)=>{if(!f)return;const v=o.current,M={entities:v.entities.map(H=>H.id!==f?H:s==="position.x"?{...H,position:{...H.position,x:Number(i)}}:s==="position.y"?{...H,position:{...H.position,y:Number(i)}}:{...H,[s]:i}),relationships:v.relationships};d(M)},[f,o,d]);n.useEffect(()=>{const s=N.current;if(!s)return;const i=v=>{const M=v.target.tagName;if(M==="INPUT"||M==="TEXTAREA"||M==="SELECT")return;const H=v.ctrlKey||v.metaKey;H&&v.key==="z"?(v.preventDefault(),o.undo()):H&&(v.key==="y"||v.shiftKey&&v.key==="Z")?(v.preventDefault(),o.redo()):H&&v.key==="c"?(v.preventDefault(),oe()):H&&v.key==="v"?(v.preventDefault(),ee()):(v.key==="Delete"||v.key==="Backspace")&&p.count>0?(v.preventDefault(),ne()):v.key==="Escape"&&(p.clearSelection(),Y(null))};return s.addEventListener("keydown",i),()=>s.removeEventListener("keydown",i)},[o,oe,ee,ne,p]);const l=k.map(s=>({id:s.id,x:s.position.x,y:s.position.y,width:240,height:40+s.fields.length*24,color:s.color,selected:p.isSelected(s.id)}));return e.jsxs("div",{ref:N,tabIndex:0,className:_e("flex h-full w-full border rounded-lg overflow-hidden bg-background",g),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(h.Database,{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:()=>o.undo(),disabled:!o.canUndo,"aria-label":"Undo",title:"Undo (Ctrl+Z)",className:"p-1 rounded hover:bg-accent disabled:opacity-40",children:e.jsx(h.Undo2,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>o.redo(),disabled:!o.canRedo,"aria-label":"Redo",title:"Redo (Ctrl+Y)",className:"p-1 rounded hover:bg-accent disabled:opacity-40",children:e.jsx(h.Redo2,{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:F.zoomOut,"aria-label":"Zoom Out",title:"Zoom Out",className:"p-1 rounded hover:bg-accent",children:e.jsx(h.ZoomOut,{className:"h-3.5 w-3.5"})}),e.jsxs("span",{className:"text-xs tabular-nums w-10 text-center",children:[Math.round(F.zoom*100),"%"]}),e.jsx("button",{onClick:F.zoomIn,"aria-label":"Zoom In",title:"Zoom In",className:"p-1 rounded hover:bg-accent",children:e.jsx(h.ZoomIn,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:F.resetZoom,"aria-label":"Reset Zoom",title:"Reset Zoom",className:"p-1 rounded hover:bg-accent",children:e.jsx(h.RotateCcw,{className:"h-3 w-3"})})]}),!y&&e.jsxs("div",{className:"flex items-center gap-1 border-l pl-2",children:[e.jsx("button",{onClick:oe,disabled:p.count===0,"aria-label":"Copy",title:"Copy (Ctrl+C)",className:"p-1 rounded hover:bg-accent disabled:opacity-40",children:e.jsx(h.Copy,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:ee,disabled:!I.hasContent,"aria-label":"Paste",title:"Paste (Ctrl+V)",className:"p-1 rounded hover:bg-accent disabled:opacity-40",children:e.jsx(h.Clipboard,{className:"h-3.5 w-3.5"})})]}),!y&&e.jsxs("button",{onClick:ae,"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(h.Grid3X3,{className:"h-3 w-3"})," Auto Layout"]}),e.jsx("div",{className:"flex-1"}),R?.isConnected&&e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",role:"status","aria-label":"Collaboration active",children:[e.jsx(h.Users,{className:"h-3 w-3"}),e.jsxs("span",{children:[R.users.length," user",R.users.length!==1?"s":""]})]}),p.count>1&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.count," selected"]}),!y&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:W,"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(h.Plus,{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(h.Link2,{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:F.handleWheel,onMouseDown:F.startPan,onDragOver:m,onDrop:T,children:[e.jsxs("div",{className:"relative",style:{width:D.width,minHeight:D.height,...F.transformStyle,backgroundImage:D.showGrid?"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)":void 0,backgroundSize:D.showGrid?"20px 20px":void 0},children:[e.jsx("svg",{className:"absolute inset-0 pointer-events-none",width:D.width,height:D.height,children:u.map(s=>{const i=k.find(M=>M.id===s.sourceEntity),v=k.find(M=>M.id===s.targetEntity);return!i||!v?null:e.jsxs("g",{children:[e.jsx("line",{x1:i.position.x+120,y1:i.position.y+50,x2:v.position.x+120,y2:v.position.y+50,stroke:"hsl(var(--primary))",strokeWidth:"2",strokeDasharray:s.type==="many-to-many"?"5,5":void 0}),j&&s.label&&e.jsx("text",{x:(i.position.x+v.position.x)/2+120,y:(i.position.y+v.position.y)/2+50-8,textAnchor:"middle",className:"text-xs fill-muted-foreground",children:s.label})]},s.id)})}),k.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."}),k.map(s=>e.jsxs("div",{role:"group","aria-label":s.label,draggable:!y,onDragStart:i=>L(i,s.id),className:_e("absolute rounded-lg border-2 bg-background shadow-sm w-60 select-none cursor-grab active:cursor-grabbing",p.isSelected(s.id)?"border-primary ring-2 ring-primary/20":"border-border hover:border-primary/50"),style:{left:s.position.x,top:s.position.y},onClick:i=>p.toggle(s.id,i.shiftKey),children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-t-lg font-medium text-sm",style:{backgroundColor:s.color??"hsl(var(--primary) / 0.1)"},children:[e.jsx(h.Database,{className:"h-3.5 w-3.5"}),e.jsx("span",{className:"truncate",children:s.label}),!y&&e.jsx("button",{onClick:i=>{i.stopPropagation(),te(s.id)},"aria-label":`Delete ${s.label}`,className:"ml-auto p-0.5 rounded hover:bg-destructive/20",children:e.jsx(h.Trash2,{className:"h-3 w-3 text-destructive"})})]}),e.jsx("div",{className:"px-3 py-1 divide-y",children:s.fields.map((i,v)=>e.jsxs("div",{className:"flex items-center gap-2 py-1 text-xs",children:[K&&K.entityId===s.id&&K.fieldIndex===v?e.jsx("input",{type:"text",value:X,onChange:M=>re(M.target.value),onBlur:se,onKeyDown:M=>{M.key==="Enter"&&se(),M.key==="Escape"&&c()},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:M=>M.stopPropagation()}):e.jsxs("span",{className:_e("font-mono cursor-text",i.primaryKey&&"font-bold text-primary"),onClick:M=>{M.stopPropagation(),ie(s.id,v,i.name)},title:"Click to edit field name",children:[i.primaryKey&&e.jsx("span",{className:"text-[0.65rem] font-semibold text-primary mr-0.5",children:"PK"}),i.name]}),e.jsx("span",{className:"text-muted-foreground ml-auto",children:i.type}),i.required&&e.jsx("span",{className:"text-destructive",children:"*"})]},`${i.name}-${v}`))}),!y&&e.jsx("div",{className:"px-3 py-1 border-t",children:e.jsxs("button",{onClick:i=>{i.stopPropagation(),le(s.id)},"aria-label":`Add field to ${s.label}`,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground w-full py-0.5",children:[e.jsx(h.Plus,{className:"h-3 w-3"})," Add Field"]})})]},s.id))]}),E&&k.length>0&&e.jsx(Ae,{items:l,canvasWidth:D.width,canvasHeight:D.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:()=>z(s=>!s),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":P,"aria-controls":"property-editor-panel",children:[P?e.jsx(h.ChevronDown,{className:"h-3 w-3"}):e.jsx(h.ChevronRight,{className:"h-3 w-3"}),"Properties"]}),P&&e.jsx("div",{id:"property-editor-panel",className:"flex-1 overflow-y-auto",children:e.jsx(ke,{title:b?b.label:"Properties",fields:r,onChange:t})})]}),e.jsx("div",{className:"border-t",children:e.jsxs("button",{onClick:()=>V(s=>!s),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":E,children:[E?e.jsx(h.ChevronDown,{className:"h-3 w-3"}):e.jsx(h.ChevronRight,{className:"h-3 w-3"}),"Minimap"]})})]}),e.jsx(ge,{isOpen:S.isOpen,title:S.title,message:S.message,onConfirm:S.onConfirm,onCancel:S.onCancel,destructive:!0})]})}function Me(...a){return ue.twMerge(ce.clsx(a))}const ve=120,Ee=50;function lt(a,C){if(a.length===0)return a;const D=200,j=100,y=new Map,A=new Map;for(const u of a)y.set(u.id,0),A.set(u.id,[]);for(const u of C)y.set(u.target,(y.get(u.target)??0)+1),A.get(u.source)?.push(u.target);const w=[],g=new Set;let N=a.filter(u=>(y.get(u.id)??0)===0).map(u=>u.id);for(N.length===0&&(N=[a[0].id]);N.length>0;){w.push(N);for(const d of N)g.add(d);const u=new Set;for(const d of N)for(const S of A.get(d)??[])g.has(S)||u.add(S);N=Array.from(u)}const o=a.filter(u=>!g.has(u.id)).map(u=>u.id);o.length>0&&w.push(o);const k=new Map;for(let u=0;u<w.length;u++){const d=w[u];for(let S=0;S<d.length;S++)k.set(d[S],{x:80+u*D,y:80+S*j})}return a.map(u=>({...u,position:k.get(u.id)??u.position}))}function He({processName:a="New Process",nodes:C=[],edges:D=[],lanes:j,canvas:y={width:1400,height:800,showGrid:!0},showMinimap:A=!0,showToolbar:w=!0,readOnly:g=!1,onNodesChange:N,onEdgesChange:o,className:k}){const u=xe({nodes:C,edges:D},{maxHistory:50}),d=u.current.nodes,S=u.current.edges,p=n.useCallback((x,Z)=>{u.push({nodes:x,edges:Z}),N?.(x),o?.(Z)},[u,N,o]),f=be(),I=Ce(),F=fe(),R=Ie({initialZoom:1}),P=Se(),[z,E]=n.useState(null),[V,K]=n.useState(!1),[Y,X]=n.useState(null),[re,q]=n.useState(null),[W,te]=n.useState(!0),[ne,ae]=n.useState(null),[oe,ee]=n.useState({x:0,y:0}),le=n.useRef(null),ie=n.useRef(N),se=n.useRef(o);ie.current=N,se.current=o,n.useEffect(()=>{ie.current?.(d),se.current?.(S)},[u.current]);const c=n.useCallback((x,Z)=>{if(g)return;const G={id:`node-${Date.now()}`,type:x,label:Z,position:{x:200+d.length*160,y:200}},O=[...d,G];p(O,S),E(G.id),I.selectOne(G.id),P?.sendOperation({type:"insert",elementId:G.id,data:{label:Z},userId:P.currentUserId??""})},[d,S,g,p,I,P]),L=n.useCallback(async x=>{if(g)return;const Z=d.find(B=>B.id===x);if(!await f.confirm("Delete Node",`Are you sure you want to delete "${Z?.label??x}"? This will also remove all connected edges.`))return;const O=d.filter(B=>B.id!==x),Q=S.filter(B=>B.source!==x&&B.target!==x);p(O,Q),z===x&&E(null),I.clearSelection(),P?.sendOperation({type:"delete",elementId:x,data:{},userId:P.currentUserId??""})},[d,S,z,g,p,f,I,P]),m=n.useCallback(async()=>{if(g||I.count===0||!await f.confirm("Delete Selected Nodes",`Are you sure you want to delete ${I.count} selected node(s) and their connected edges?`))return;const Z=I.selectedIds,G=d.filter(Q=>!Z.has(Q.id)),O=S.filter(Q=>!Z.has(Q.source)&&!Z.has(Q.target));p(G,O),E(null),I.clearSelection()},[d,S,g,p,f,I]),T=n.useCallback(()=>{const x=I.count>0?I.selectedIds:z?new Set([z]):new Set;if(x.size===0)return;const Z=d.filter(G=>x.has(G.id));F.copy(Z)},[d,z,I,F]),b=n.useCallback(()=>{if(g)return;const x=F.paste();if(!x||x.length===0)return;const Z=40,G=x.map(Q=>({...Q,id:`node-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,position:{x:Q.position.x+Z,y:Q.position.y+Z}})),O=[...d,...G];p(O,S),I.selectMany(G.map(Q=>Q.id)),E(G[0].id)},[g,d,S,F,p,I]),r=n.useCallback(()=>{K(x=>x?(X(null),!1):!0)},[]),t=n.useCallback(x=>{if(!V)return!1;if(!Y)return X(x),!0;if(Y===x)return!0;const Z={id:`edge-${Date.now()}`,source:Y,target:x},G=[...S,Z];return p(d,G),X(null),K(!1),P?.sendOperation({type:"insert",elementId:Z.id,data:{source:Y,target:x},userId:P.currentUserId??""}),!0},[V,Y,d,S,p,P]),l=n.useCallback(()=>{if(g||d.length===0)return;const x=lt(d,S);p(x,S)},[d,S,g,p]),s=n.useCallback((x,Z)=>{if(g||!d.find(Q=>Q.id===Z))return;ae(Z);const O=x.target.getBoundingClientRect();ee({x:x.clientX-O.left,y:x.clientY-O.top}),x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/plain",Z)},[g,d]),i=n.useCallback(x=>{if(x.preventDefault(),g||!ne)return;const Z=x.currentTarget.getBoundingClientRect(),G=R.zoom,O=(x.clientX-Z.left-R.panOffset.x)/G-oe.x,Q=(x.clientY-Z.top-R.panOffset.y)/G-oe.y,B=Math.max(0,Math.round(O/20)*20),ye=Math.max(0,Math.round(Q/20)*20),we=d.map(he=>he.id===ne?{...he,position:{x:B,y:ye}}:he);p(we,S),ae(null)},[g,ne,oe,d,S,R.zoom,R.panOffset,p]),v=n.useCallback(x=>{x.preventDefault(),x.dataTransfer.dropEffect="move"},[]),M=n.useMemo(()=>d.find(x=>x.id===z)??null,[d,z]),H=n.useMemo(()=>M?[{name:"label",label:"Name",type:"text",value:M.label,group:"General"},{name:"type",label:"Type",type:"select",value:M.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:M.description??"",group:"General"}]:[],[M]),$=n.useCallback((x,Z)=>{if(g||!z)return;const G=d.map(O=>O.id===z?{...O,[x]:Z}:O);p(G,S)},[g,z,d,S,p]),De=x=>{switch(x){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"}},Pe=n.useMemo(()=>d.map(x=>({id:x.id,x:x.position.x,y:x.position.y,width:ve,height:Ee,selected:I.isSelected(x.id)||x.id===z})),[d,I,z]);n.useEffect(()=>{const x=le.current;if(!x)return;const Z=G=>{const O=G.target?.tagName;if(O==="INPUT"||O==="TEXTAREA"||O==="SELECT")return;const Q=G.ctrlKey||G.metaKey;if(Q&&G.key==="z"&&!G.shiftKey){G.preventDefault(),u.undo();return}if(Q&&G.key==="y"||Q&&G.key==="z"&&G.shiftKey){G.preventDefault(),u.redo();return}if(Q&&G.key==="c"){G.preventDefault(),T();return}if(Q&&G.key==="v"){G.preventDefault(),b();return}if(G.key==="Delete"||G.key==="Backspace"){I.count>0?(G.preventDefault(),m()):z&&(G.preventDefault(),L(z));return}if(G.key==="Escape"){V?(K(!1),X(null)):(E(null),I.clearSelection());return}};return x.addEventListener("keydown",Z),()=>x.removeEventListener("keydown",Z)},[z,V,I,u,T,b,L,m]);const pt=n.useCallback(x=>{x.target===x.currentTarget&&(E(null),I.clearSelection(),V&&(K(!1),X(null)))},[V,I]);return e.jsxs("div",{ref:le,tabIndex:0,className:Me("flex flex-col h-full w-full border rounded-lg overflow-hidden bg-background",k),children:[e.jsx(ge,{isOpen:f.isOpen,title:f.title,message:f.message,onConfirm:f.onConfirm,onCancel:f.onCancel,destructive:!0}),w&&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(h.GitBranch,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm","aria-label":"Process name",children:a}),P?.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"}),P.users.length," user",P.users.length!==1?"s":""]}),e.jsx("div",{className:"flex-1"}),!g&&e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>u.undo(),disabled:!u.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(h.Undo2,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>u.redo(),disabled:!u.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(h.Redo2,{className:"h-3 w-3"})}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsx("button",{onClick:T,disabled:I.count===0&&!z,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(h.Copy,{className:"h-3 w-3"})}),e.jsx("button",{onClick:b,disabled:!F.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(h.Clipboard,{className:"h-3 w-3"})}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsxs("button",{onClick:r,className:Me("flex items-center gap-1 px-2 py-1 text-xs rounded hover:bg-accent",V&&"bg-primary text-primary-foreground"),title:"Connect nodes","aria-label":"Connect nodes","aria-pressed":V,children:[e.jsx(h.Link,{className:"h-3 w-3"})," Connect"]}),e.jsxs("button",{onClick:l,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(h.Layout,{className:"h-3 w-3"})," Layout"]}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsx("button",{onClick:R.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(h.ZoomIn,{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(R.zoom*100),"%"]}),e.jsx("button",{onClick:R.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(h.ZoomOut,{className:"h-3 w-3"})}),e.jsx("button",{onClick:R.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(h.RotateCcw,{className:"h-3 w-3"})}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"}),e.jsxs("button",{onClick:()=>c("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(h.Play,{className:"h-3 w-3 text-green-600"})," Start"]}),e.jsxs("button",{onClick:()=>c("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(h.Square,{className:"h-3 w-3 text-blue-600"})," Task"]}),e.jsxs("button",{onClick:()=>c("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(h.Diamond,{className:"h-3 w-3 text-yellow-600"})," Gateway"]}),e.jsxs("button",{onClick:()=>c("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(h.Square,{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(x=>!x),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(h.PanelRightClose,{className:"h-3 w-3"}):e.jsx(h.PanelRightOpen,{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:R.handleWheel,onMouseDown:R.startPan,children:e.jsxs("div",{className:"relative",style:{...R.transformStyle,width:y.width,minHeight:y.height,backgroundImage:y.showGrid?"radial-gradient(circle, hsl(var(--border)) 1px, transparent 1px)":void 0,backgroundSize:y.showGrid?"20px 20px":void 0},onClick:pt,onDrop:i,onDragOver:v,children:[e.jsxs("svg",{className:"absolute inset-0 pointer-events-none",width:y.width,height:y.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))"})})}),S.map(x=>{const Z=d.find(ze=>ze.id===x.source),G=d.find(ze=>ze.id===x.target);if(!Z||!G)return null;Z.position.x+ve/2;const O=Z.position.y+Ee/2;G.position.x+ve/2;const Q=G.position.y+Ee/2,B=Z.position.x+ve,ye=O,we=G.position.x,he=Q,mt=(B+we)/2,ht=`M ${B} ${ye} Q ${mt} ${ye}, ${(B+we)/2} ${(ye+he)/2} T ${we} ${he}`;return e.jsxs("g",{children:[e.jsx("path",{d:ht,fill:"none",stroke:"hsl(var(--foreground) / 0.5)",strokeWidth:"2",markerEnd:"url(#arrowhead)"}),x.label&&e.jsx("text",{x:(B+we)/2,y:(ye+he)/2-8,textAnchor:"middle",className:"text-[10px] fill-muted-foreground",children:x.label})]},x.id)})]}),d.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."}),d.map(x=>{const Z=I.isSelected(x.id)||z===x.id,G=Y===x.id,O=re===x.id,Q=V||O;return e.jsxs("div",{className:"absolute select-none",style:{left:x.position.x,top:x.position.y},role:"group","aria-label":x.label,draggable:!g&&!V,onDragStart:B=>s(B,x.id),onMouseEnter:()=>q(x.id),onMouseLeave:()=>q(null),onClick:B=>{t(x.id)||(B.shiftKey?I.toggle(x.id,!0):(E(x.id),I.selectOne(x.id)))},children:[e.jsx("div",{className:Me("flex items-center justify-center border-2 min-w-[120px] min-h-[50px] px-3 py-2 transition-shadow",De(x.type),Z&&"ring-2 ring-primary shadow-md",G&&"ring-2 ring-blue-400 shadow-lg",V&&!G&&"cursor-crosshair"),children:e.jsx("span",{className:Me("text-xs font-medium",(x.type==="exclusive-gateway"||x.type==="parallel-gateway"||x.type==="inclusive-gateway"||x.type==="event-based-gateway")&&"-rotate-45"),children:x.label})}),Q&&!g&&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:Ee/2-6},title:"Input port",onClick:B=>{B.stopPropagation(),t(x.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:Ee/2-6},title:"Output port",onClick:B=>{B.stopPropagation(),V?t(x.id):(K(!0),X(x.id))}}),e.jsx("div",{className:"absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair",style:{left:ve/2-6,top:-6},title:"Port",onClick:B=>{B.stopPropagation(),t(x.id)}}),e.jsx("div",{className:"absolute w-3 h-3 rounded-full bg-blue-400 border-2 border-white shadow cursor-crosshair",style:{left:ve/2-6,bottom:-6},title:"Port",onClick:B=>{B.stopPropagation(),t(x.id)}})]}),!g&&Z&&!V&&e.jsx("button",{onClick:B=>{B.stopPropagation(),L(x.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(h.Trash2,{className:"h-3 w-3"})})]},x.id)}),A&&d.length>0&&e.jsx(Ae,{items:Pe,canvasWidth:y.width??1400,canvasHeight:y.height??800,position:"bottom-right"})]})}),W&&!g&&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(ke,{title:M?`Properties: ${M.label}`:"Properties",fields:H,onChange:$})})]})]})}function me(...a){return ue.twMerge(ce.clsx(a))}const _={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:a=>`Are you sure you want to delete ${a} element${a>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"},it={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}},dt=[{type:"header",height:80,elements:[]},{type:"detail",height:400,elements:[],repeat:!0},{type:"footer",height:60,elements:[]}];function Xe({reportName:a=_.untitledReport,objectName:C,pageSize:D="A4",orientation:j="portrait",margins:y={top:40,right:40,bottom:40,left:40},sections:A=[],showToolbar:w=!0,showPropertyPanel:g=!0,readOnly:N=!1,onSectionsChange:o,className:k}){const u=xe(A.length>0?A:dt),d=u.current,S=n.useCallback(m=>{u.push(m),o?.(m)},[u,o]),p=Ce(),f=n.useMemo(()=>{const m=Array.from(p.selectedIds);return m.length>0?m[0]:null},[p.selectedIds]),I=fe(),F=be(),R=Se(),P=n.useCallback(m=>{R&&R.sendOperation({...m,userId:R.currentUserId??""})},[R]),[z,E]=n.useState(!0),V=n.useRef(null),K=n.useRef(null),Y=it[D],X=j==="landscape"?Y.height:Y.width,re=j==="landscape"?Y.width:Y.height,q=m=>{switch(m){case"header":return _.sectionHeader;case"page-header":return _.sectionPageHeader;case"group-header":return _.sectionGroupHeader;case"detail":return _.sectionDetail;case"group-footer":return _.sectionGroupFooter;case"page-footer":return _.sectionPageFooter;case"footer":return _.sectionFooter;default:return m}},W=n.useMemo(()=>f?d.flatMap(m=>m.elements).find(m=>m.id===f):null,[f,d]),te=n.useCallback((m,T)=>{if(N)return;const b={id:`elem-${Date.now()}`,type:T,position:{x:y.left,y:10,width:200,height:30},properties:{text:T==="text"?"New Text":void 0,field:T==="field"?"field_name":void 0}},r=d.map((t,l)=>l===m?{...t,elements:[...t.elements,b]}:t);S(r),p.selectOne(b.id),P({type:"insert",elementId:b.id,data:{element:b}})},[d,y.left,N,S,p,P]),ne=n.useCallback(m=>{if(N)return;const T=d.map(b=>({...b,elements:b.elements.filter(r=>r.id!==m)}));S(T),p.isSelected(m)&&p.clearSelection(),P({type:"delete",elementId:m,data:{}})},[d,N,S,p,P]),ae=n.useCallback(async()=>{if(N||p.count===0||!await F.confirm(_.deleteElementsTitle,_.deleteElementMessage(p.count)))return;const T=p.selectedIds,b=d.map(r=>({...r,elements:r.elements.filter(t=>!T.has(t.id))}));S(b),p.clearSelection(),T.forEach(r=>{P({type:"delete",elementId:r,data:{}})})},[N,p,F,d,S,P]),oe=n.useCallback((m,T)=>{if(N||!f)return;const b=d.map(r=>({...r,elements:r.elements.map(t=>t.id!==f?t:m==="x"?{...t,position:{...t.position,x:Number(T)}}:m==="y"?{...t,position:{...t.position,y:Number(T)}}:m==="width"?{...t,position:{...t.position,width:Number(T)}}:m==="height"?{...t,position:{...t.position,height:Number(T)}}:{...t,properties:{...t.properties,[m]:T}})}));S(b),P({type:"update",elementId:f,data:{[m]:T}})},[N,f,d,S,P]),ee=n.useCallback(()=>{const m=p.selectedIds;if(m.size===0)return;const b=d.flatMap(r=>r.elements).filter(r=>m.has(r.id));I.copy(b)},[p,d,I]),le=n.useCallback(()=>{if(N)return;const m=I.paste();if(!m||m.length===0)return;let T=0;const b=m.map(s=>({...s,id:`elem-${Date.now()}-${++T}-${Math.random().toString(36).slice(2,7)}`,position:{...s.position,x:s.position.x+20,y:s.position.y+20}})),r=d.findIndex(s=>s.type==="detail"),t=r>=0?r:0,l=d.map((s,i)=>i===t?{...s,elements:[...s.elements,...b]}:s);S(l),p.selectMany(b.map(s=>s.id)),b.forEach(s=>{P({type:"insert",elementId:s.id,data:{element:s}})})},[N,I,d,S,p,P]),ie=n.useCallback((m,T,b)=>{N||(V.current={id:T.id,sectionIndex:b,startX:m.clientX,startY:m.clientY},m.dataTransfer.effectAllowed="move",m.dataTransfer.setData("text/plain",T.id))},[N]),se=n.useCallback(m=>{m.preventDefault(),m.dataTransfer.dropEffect="move"},[]),c=n.useCallback((m,T)=>{m.preventDefault();const b=V.current;if(!b||N)return;const r=m.clientX-b.startX,t=m.clientY-b.startY;if(b.sectionIndex===T){const l=d.map((s,i)=>i!==T?s:{...s,elements:s.elements.map(v=>v.id!==b.id?v:{...v,position:{...v.position,x:Math.max(0,v.position.x+r),y:Math.max(0,(typeof v.position.y=="number"?v.position.y:0)+t)}})});S(l)}else{let l=null;const s=d.map((i,v)=>{if(v!==b.sectionIndex)return i;const M=i.elements.find(H=>H.id===b.id);return M&&(l={...M,position:{...M.position,x:Math.max(0,M.position.x+r),y:Math.max(0,10)}}),{...i,elements:i.elements.filter(H=>H.id!==b.id)}});if(l){const i=s.map((v,M)=>M!==T?v:{...v,elements:[...v.elements,l]});S(i)}}P({type:"move",elementId:b.id,data:{}}),V.current=null},[N,d,S,P]),L=n.useMemo(()=>{if(!W)return[];const m=[{name:"x",label:_.propX,type:"number",value:W.position.x,group:_.groupPosition},{name:"y",label:_.propY,type:"number",value:W.position.y,group:_.groupPosition},{name:"width",label:_.propWidth,type:"number",value:W.position.width,group:_.groupSize},{name:"height",label:_.propHeight,type:"number",value:W.position.height,group:_.groupSize}];return W.type==="text"&&m.push({name:"text",label:_.propText,type:"text",value:W.properties.text??"",group:_.groupContent}),W.type==="field"&&m.push({name:"field",label:_.propField,type:"text",value:W.properties.field??"",group:_.groupContent}),m},[W]);return n.useEffect(()=>{const m=K.current;if(!m)return;const T=b=>{const r=["INPUT","TEXTAREA","SELECT"].includes(b.target.tagName),t=b.ctrlKey||b.metaKey;if((b.key==="Delete"||b.key==="Backspace")&&p.count>0&&!r){b.preventDefault(),ae();return}if(b.key==="Escape"){p.clearSelection();return}if(!r){if(t&&b.key==="z"&&!b.shiftKey&&!N){b.preventDefault(),u.undo();return}if(t&&(b.key==="z"&&b.shiftKey||b.key==="y")&&!N){b.preventDefault(),u.redo();return}if(t&&b.key==="c"){b.preventDefault(),ee();return}if(t&&b.key==="v"&&!N){b.preventDefault(),le();return}if(t&&b.key==="a"){b.preventDefault();const l=d.flatMap(s=>s.elements).map(s=>s.id);p.selectMany(l);return}}};return m.addEventListener("keydown",T),()=>m.removeEventListener("keydown",T)},[p,ae,N,u,ee,le,d]),e.jsxs("div",{ref:K,tabIndex:0,className:me("flex h-full w-full border rounded-lg overflow-hidden bg-background",k),children:[e.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[w&&e.jsxs("div",{role:"toolbar","aria-label":_.designerToolbar,className:"flex items-center gap-2 p-2 border-b bg-muted/20",children:[e.jsx(h.FileText,{className:"h-4 w-4"}),e.jsx("span",{className:"font-medium text-sm",children:a}),C&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",C,")"]}),!N&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-5 bg-border mx-1"}),e.jsx("button",{className:me("p-1.5 rounded hover:bg-accent",!u.canUndo&&"opacity-40 pointer-events-none"),title:_.undoShortcut,"aria-label":_.undo,disabled:!u.canUndo,onClick:()=>u.undo(),children:e.jsx(h.Undo2,{className:"h-4 w-4"})}),e.jsx("button",{className:me("p-1.5 rounded hover:bg-accent",!u.canRedo&&"opacity-40 pointer-events-none"),title:_.redoShortcut,"aria-label":_.redo,disabled:!u.canRedo,onClick:()=>u.redo(),children:e.jsx(h.Redo2,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),!N&&e.jsxs(e.Fragment,{children:[e.jsx("button",{className:me("p-1.5 rounded hover:bg-accent",p.count===0&&"opacity-40 pointer-events-none"),title:_.copyShortcut,"aria-label":_.copy,disabled:p.count===0,onClick:ee,children:e.jsx(h.Copy,{className:"h-4 w-4"})}),e.jsx("button",{className:me("p-1.5 rounded hover:bg-accent",!I.hasContent&&"opacity-40 pointer-events-none"),title:_.pasteShortcut,"aria-label":_.paste,disabled:!I.hasContent,onClick:le,children:e.jsx(h.Clipboard,{className:"h-4 w-4"})}),e.jsx("div",{className:"w-px h-5 bg-border mx-1"})]}),!N&&e.jsx("button",{className:me("p-1.5 rounded hover:bg-accent",p.count===0&&"opacity-40 pointer-events-none"),title:_.deleteSelected,"aria-label":_.deleteSelected,disabled:p.count===0,onClick:ae,children:e.jsx(h.Trash2,{className:"h-4 w-4"})}),e.jsx("div",{className:"flex-1"}),R?.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"}),_.collaborationConnected,R.users.length>1&&` (${R.users.length})`]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[D," ",j]}),g&&e.jsx("button",{className:"p-1.5 rounded hover:bg-accent",title:z?_.collapsePanel:_.expandPanel,"aria-label":z?_.collapsePanel:_.expandPanel,onClick:()=>E(m=>!m),children:e.jsx(h.PanelRightClose,{className:me("h-4 w-4",!z&&"rotate-180")})})]}),e.jsx("div",{role:"region","aria-label":_.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:X,minHeight:re},children:d.map((m,T)=>e.jsxs("div",{className:"relative border-b border-dashed border-gray-300",style:{minHeight:m.height},onDragOver:se,onDrop:b=>c(b,T),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:[q(m.type),m.repeat&&" ↻"]}),!N&&e.jsxs("div",{className:"absolute right-1 top-0 flex items-center gap-0.5",children:[e.jsx("button",{onClick:()=>te(T,"text"),className:"p-0.5 rounded hover:bg-accent",title:_.addText,"aria-label":_.addText,children:e.jsx(h.Type,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>te(T,"field"),className:"p-0.5 rounded hover:bg-accent",title:_.addField,"aria-label":_.addField,children:e.jsx(h.Plus,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>te(T,"image"),className:"p-0.5 rounded hover:bg-accent",title:_.addImage,"aria-label":_.addImage,children:e.jsx(h.ImageIcon,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>te(T,"chart"),className:"p-0.5 rounded hover:bg-accent",title:_.addChart,"aria-label":_.addChart,children:e.jsx(h.BarChart3,{className:"h-3 w-3"})}),e.jsx("button",{onClick:()=>te(T,"table"),className:"p-0.5 rounded hover:bg-accent",title:_.addTable,"aria-label":_.addTable,children:e.jsx(h.Table2,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"relative",style:{minHeight:m.height,paddingTop:24},children:[m.elements.length===0&&e.jsx("div",{className:"text-xs text-muted-foreground text-center pt-4",children:_.addElementsPrompt}),m.elements.map(b=>{const r=p.isSelected(b.id);return e.jsxs("div",{draggable:!N,onDragStart:t=>ie(t,b,T),className:me("absolute border rounded px-2 py-1 text-xs cursor-pointer",r?"border-primary ring-1 ring-primary/30 bg-primary/5":"border-dashed border-gray-400 hover:border-primary/50"),style:{left:b.position.x,top:(typeof b.position.y=="number"?b.position.y:0)+24,width:b.position.width,height:b.position.height},onClick:t=>p.toggle(b.id,t.shiftKey),children:[e.jsxs("span",{className:"text-muted-foreground",children:[b.type==="text"&&(b.properties.text??_.elementText),b.type==="field"&&`{${b.properties.field??"field"}}`,b.type==="image"&&_.elementImage,b.type==="chart"&&_.elementChart,b.type==="table"&&_.elementTable]}),!N&&r&&e.jsx("button",{onClick:t=>{t.stopPropagation(),ne(b.id)},className:"absolute -top-2 -right-2 p-0.5 rounded-full bg-destructive text-destructive-foreground shadow","aria-label":_.deleteElement,children:e.jsx(h.Trash2,{className:"h-2.5 w-2.5"})})]},b.id)})]})]},`${m.type}-${T}`))})})]}),g&&e.jsx("div",{role:"region","aria-label":_.propertiesPanel,className:me("border-l bg-muted/30 flex flex-col transition-[width] duration-200",z?"w-56":"w-0 overflow-hidden"),children:z&&(f&&W?e.jsx(ke,{title:`${_.properties} – ${W.type}`,fields:L,onChange:oe}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"p-3 border-b font-medium text-sm",children:_.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:_.selectElementPrompt})})]}))}),e.jsx(ge,{isOpen:F.isOpen,title:F.title,message:F.message,onConfirm:F.onConfirm,onCancel:F.onCancel})]})}function Re(...a){return ue.twMerge(ce.clsx(a))}const U={title:"View Designer",saveView:"Save View",cancel:"Cancel",availableFields:"Available Fields",allFieldsAdded:"All fields added",noColumnsTitle:"No columns added yet. Select fields from the palette to add columns.",columnsCount:a=>`Columns (${a})`,viewType:"View Type",viewName:"View Name",viewNamePlaceholder:"Enter view name...",columnProperties:"Column Properties",selectColumnPrompt:"Select a column to edit its properties",labelField:"Label",widthField:"Width",widthPlaceholder:"auto",fieldLabel:"Field:",addFilter:"Add Filter",addSort:"Add Sort",valuePlaceholder:"Value",asc:"Asc",desc:"Desc",selectField:"Select field...",moveUp:"Move up",moveDown:"Move down",moveColumnUp:"Move column up",moveColumnDown:"Move column down",hideColumn:"Hide column",showColumn:"Show column",toggleVisibility:"Toggle column visibility",removeColumn:"Remove column",copyColumn:"Copy column",pasteColumn:"Paste column",deleteColumnTitle:"Delete Column",deleteColumnMessage:a=>`Are you sure you want to delete the column "${a}"? This action cannot be undone.`,undo:"Undo (Ctrl+Z)",redo:"Redo (Ctrl+Y)",gridOptionsHint:"Grid view uses the columns configured above.",groupByField:"Group By Field",startDateField:"Start Date Field",titleField:"Title Field",latitudeField:"Latitude Field",longitudeField:"Longitude Field",imageField:"Image Field",dateField:"Date Field"},Ke=[{type:"grid",label:"Grid",icon:h.LayoutGrid},{type:"kanban",label:"Kanban",icon:h.Kanban},{type:"gallery",label:"Gallery",icon:h.Image},{type:"calendar",label:"Calendar",icon:h.Calendar},{type:"timeline",label:"Timeline",icon:h.Clock},{type:"gantt",label:"Gantt",icon:h.GanttChart},{type:"map",label:"Map",icon:h.Map}],ct=[{value:"equals",label:"="},{value:"contains",label:"Contains"},{value:"startsWith",label:"Starts with"},{value:"gt",label:">"},{value:"lt",label:"<"},{value:"gte",label:">="},{value:"lte",label:"<="},{value:"ne",label:"!="}];function We({objectName:a,viewId:C,viewLabel:D="",viewType:j="grid",columns:y=[],filters:A=[],sort:w=[],availableFields:g=[],options:N={},readOnly:o=!1,onSave:k,onCancel:u,className:d}){const S=n.useRef(null),p=xe({columns:y,filters:A,sort:w,viewType:j,viewLabel:D,options:N}),{columns:f,filters:I,sort:F,viewType:R,viewLabel:P,options:z}=p.current,E=n.useCallback(t=>{p.push({...p.current,...t})},[p]),V=fe(),K=be(),Y=Se(),[X,re]=n.useState(null),[q,W]=n.useState("columns"),te=n.useMemo(()=>{const t=new Set(f.map(l=>l.field));return g.filter(l=>!t.has(l.name))},[g,f]),ne=n.useCallback(t=>{if(o)return;const l=g.find(i=>i.name===t),s={field:t,label:l?.label??t,visible:!0,order:f.length};E({columns:[...f,s]}),Y?.sendOperation({type:"insert",userId:Y.currentUserId??"",elementId:t,data:{column:s}})},[g,f,o,E,Y]),ae=n.useCallback(async t=>{if(o)return;const l=f[t];!l||!await K.confirm(U.deleteColumnTitle,U.deleteColumnMessage(l.label||l.field))||(E({columns:f.filter((i,v)=>v!==t)}),X===t&&re(null),Y?.sendOperation({type:"delete",userId:Y.currentUserId??"",elementId:l.field,data:{}}))},[o,f,K,E,X,Y]),oe=n.useCallback(t=>{o||E({columns:f.map((l,s)=>s===t?{...l,visible:!l.visible}:l)})},[o,f,E]),ee=n.useCallback((t,l)=>{if(o)return;const s=l==="up"?t-1:t+1;if(s<0||s>=f.length)return;const i=[...f],v=i[t];i[t]=i[s],i[s]=v,E({columns:i}),re(s)},[o,f,E]),le=n.useCallback(()=>{o||g.length===0||E({filters:[...I,{field:g[0].name,operator:"equals",value:""}]})},[o,g,I,E]),ie=n.useCallback(t=>{o||E({filters:I.filter((l,s)=>s!==t)})},[o,I,E]),se=n.useCallback((t,l)=>{o||E({filters:I.map((s,i)=>i===t?{...s,...l}:s)})},[o,I,E]),c=n.useCallback(()=>{o||g.length===0||E({sort:[...F,{field:g[0].name,direction:"asc"}]})},[o,g,F,E]),L=n.useCallback(t=>{o||E({sort:F.filter((l,s)=>s!==t)})},[o,F,E]),m=n.useCallback((t,l)=>{o||E({sort:F.map((s,i)=>i===t?{...s,...l}:s)})},[o,F,E]),T=n.useCallback(()=>{X===null||!f[X]||V.copy(f[X])},[X,f,V]),b=n.useCallback(()=>{if(o)return;const t=V.paste();if(!t)return;const l={...t,field:`${t.field}_copy`,label:`${t.label||t.field} (Copy)`,order:f.length};E({columns:[...f,l]})},[o,V,f,E]),r=n.useCallback(()=>{k?.({viewId:C,viewLabel:P||`${a} View`,viewType:R,columns:f,filters:I,sort:F,options:z})},[k,C,P,a,R,f,I,F,z]);return n.useEffect(()=>{const t=S.current;if(!t)return;const l=s=>{const i=["INPUT","TEXTAREA","SELECT"].includes(s.target.tagName),v=s.ctrlKey||s.metaKey;if(!i){if(v&&s.key==="z"&&!s.shiftKey&&!o){s.preventDefault(),p.undo();return}if(v&&(s.key==="z"&&s.shiftKey||s.key==="y")&&!o){s.preventDefault(),p.redo();return}if(v&&s.key==="c"){s.preventDefault(),T();return}if(v&&s.key==="v"&&!o){s.preventDefault(),b();return}}};return t.addEventListener("keydown",l),()=>t.removeEventListener("keydown",l)},[o,p,T,b]),e.jsxs("div",{ref:S,tabIndex:-1,className:Re("flex flex-col h-full w-full border rounded-lg overflow-hidden bg-background",d),children:[e.jsxs("div",{className:"flex items-center gap-2 p-2 border-b bg-muted/20 shrink-0",role:"toolbar",children:[e.jsx(h.Settings2,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium text-sm",children:U.title}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["— ",a]}),Y?.isConnected&&Y.users.length>1&&e.jsxs("div",{className:"flex items-center gap-1 ml-2",role:"status","aria-label":"Active collaborators",children:[Y.users.slice(0,3).map(t=>e.jsx("div",{className:"h-5 w-5 rounded-full text-[10px] font-bold flex items-center justify-center text-white",style:{backgroundColor:t.color},title:t.userName,children:t.userName.charAt(0).toUpperCase()},t.userId)),Y.users.length>3&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["+",Y.users.length-3]})]}),e.jsx("div",{className:"flex-1"}),!o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:p.undo,disabled:!p.canUndo,className:"p-1.5 rounded hover:bg-accent disabled:opacity-30",title:U.undo,"aria-label":U.undo,"data-testid":"view-designer-undo",children:e.jsx(h.Undo2,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:p.redo,disabled:!p.canRedo,className:"p-1.5 rounded hover:bg-accent disabled:opacity-30",title:U.redo,"aria-label":U.redo,"data-testid":"view-designer-redo",children:e.jsx(h.Redo2,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"})]}),!o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:T,disabled:X===null,className:"p-1.5 rounded hover:bg-accent disabled:opacity-30",title:U.copyColumn,"aria-label":U.copyColumn,"data-testid":"view-designer-copy",children:e.jsx(h.Copy,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:b,disabled:!V.hasContent,className:"p-1.5 rounded hover:bg-accent disabled:opacity-30",title:U.pasteColumn,"aria-label":U.pasteColumn,"data-testid":"view-designer-paste",children:e.jsx(h.Clipboard,{className:"h-3.5 w-3.5"})}),e.jsx("div",{className:"w-px h-4 bg-border mx-1"})]}),!o&&e.jsxs(e.Fragment,{children:[u&&e.jsxs("button",{onClick:u,className:"flex items-center gap-1 px-3 py-1.5 text-xs rounded border border-border hover:bg-accent","data-testid":"view-designer-cancel",children:[e.jsx(h.X,{className:"h-3 w-3"})," ",U.cancel]}),e.jsxs("button",{onClick:r,className:"flex items-center gap-1 px-3 py-1.5 text-xs rounded bg-primary text-primary-foreground hover:bg-primary/90","data-testid":"view-designer-save",children:[e.jsx(h.Save,{className:"h-3 w-3"})," ",U.saveView]})]})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[!o&&e.jsxs("div",{className:"w-56 border-r bg-muted/30 flex flex-col shrink-0",children:[e.jsx("div",{className:"p-3 border-b font-medium text-sm",children:U.availableFields}),e.jsx("div",{className:"flex-1 overflow-y-auto p-2",children:te.length===0?e.jsx("div",{className:"text-xs text-muted-foreground text-center py-4",children:U.allFieldsAdded}):te.map(t=>e.jsxs("button",{onClick:()=>ne(t.name),className:"w-full flex items-center gap-2 px-2 py-1.5 text-sm rounded hover:bg-accent text-left","data-testid":`field-${t.name}`,children:[e.jsx(h.Plus,{className:"h-3 w-3 text-muted-foreground"}),e.jsx("span",{className:"truncate",children:t.label||t.name}),e.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:t.type})]},t.name))})]}),e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"p-3 border-b space-y-3 shrink-0 bg-muted/10",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:U.viewType}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:Ke.map(({type:t,label:l,icon:s})=>e.jsxs("button",{onClick:()=>!o&&E({viewType:t}),className:Re("flex items-center gap-2 px-3 py-2 text-sm rounded-md border-2 transition-all font-medium",R===t?"border-primary bg-primary text-primary-foreground shadow-sm":"border-border bg-background hover:border-primary/50 hover:bg-accent"),"data-testid":`view-type-${t}`,children:[e.jsx(s,{className:"h-4 w-4"}),l]},t))})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("label",{className:"text-xs font-semibold text-foreground",children:U.viewName}),e.jsx("input",{type:"text",value:P,onChange:t=>!o&&E({viewLabel:t.target.value}),placeholder:U.viewNamePlaceholder,className:"px-3 py-2 text-sm border-2 rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-primary focus:border-primary",readOnly:o,"data-testid":"view-label-input"})]})]}),e.jsx("div",{className:"flex-1 overflow-auto p-3",children:f.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-sm text-muted-foreground",children:e.jsxs("div",{className:"text-center",children:[e.jsx(h.Columns3,{className:"h-8 w-8 mx-auto mb-2 opacity-50"}),e.jsx("p",{children:U.noColumnsTitle})]})}):e.jsxs("div",{className:"space-y-1",children:[e.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-2",children:U.columnsCount(f.length)}),f.map((t,l)=>e.jsxs("div",{className:Re("flex items-center gap-2 px-3 py-2 rounded border transition-colors cursor-pointer",X===l?"border-primary bg-primary/5 ring-1 ring-primary/20":"border-border hover:border-primary/50",!t.visible&&"opacity-50"),onClick:()=>re(l),"data-testid":`column-${t.field}`,children:[e.jsx(h.GripVertical,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),e.jsx("span",{className:"text-sm font-medium truncate flex-1",children:t.label||t.field}),e.jsx("span",{className:"text-xs text-muted-foreground",children:t.field}),!o&&e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx("button",{onClick:s=>{s.stopPropagation(),ee(l,"up")},disabled:l===0,className:"p-0.5 rounded hover:bg-accent disabled:opacity-30",title:U.moveUp,"aria-label":U.moveColumnUp,children:e.jsx(h.ArrowUp,{className:"h-3 w-3"})}),e.jsx("button",{onClick:s=>{s.stopPropagation(),ee(l,"down")},disabled:l===f.length-1,className:"p-0.5 rounded hover:bg-accent disabled:opacity-30",title:U.moveDown,"aria-label":U.moveColumnDown,children:e.jsx(h.ArrowDown,{className:"h-3 w-3"})}),e.jsx("button",{onClick:s=>{s.stopPropagation(),oe(l)},className:"p-0.5 rounded hover:bg-accent",title:t.visible!==!1?U.hideColumn:U.showColumn,"aria-label":U.toggleVisibility,children:t.visible!==!1?e.jsx(h.Eye,{className:"h-3 w-3"}):e.jsx(h.EyeOff,{className:"h-3 w-3"})}),e.jsx("button",{onClick:s=>{s.stopPropagation(),ae(l)},className:"p-0.5 rounded hover:bg-destructive/10",title:U.removeColumn,"aria-label":U.removeColumn,children:e.jsx(h.Trash2,{className:"h-3 w-3 text-destructive"})})]})]},`${t.field}-${l}`))]})})]}),e.jsxs("div",{className:"w-64 border-l bg-muted/30 flex flex-col shrink-0",children:[e.jsx("div",{className:"flex border-b shrink-0",role:"tablist",children:["columns","filters","sort","options"].map(t=>e.jsx("button",{onClick:()=>W(t),role:"tab","aria-selected":q===t,className:Re("flex-1 px-2 py-2 text-xs font-medium capitalize transition-colors",q===t?"border-b-2 border-primary text-primary":"text-muted-foreground hover:text-foreground"),children:t},t))}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-3",children:[q==="columns"&&e.jsx("div",{children:X!==null&&f[X]?e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"text-xs font-medium",children:U.columnProperties}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:U.labelField}),e.jsx("input",{type:"text",value:f[X].label??"",onChange:t=>{if(o)return;const l=X;E({columns:f.map((s,i)=>i===l?{...s,label:t.target.value}:s)})},className:"w-full px-2 py-1 text-sm border rounded bg-background mt-1",readOnly:o,"data-testid":"column-label-input"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:U.widthField}),e.jsx("input",{type:"text",value:f[X].width??"",onChange:t=>{if(o)return;const l=X,s=t.target.value;E({columns:f.map((i,v)=>v===l?{...i,width:/^\d+$/.test(s)?Number(s):s}:i)})},placeholder:U.widthPlaceholder,className:"w-full px-2 py-1 text-sm border rounded bg-background mt-1",readOnly:o,"data-testid":"column-width-input"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:[U.fieldLabel," ",e.jsx("span",{className:"font-mono",children:f[X].field})]})]}):e.jsx("div",{className:"text-xs text-muted-foreground text-center py-4",children:U.selectColumnPrompt})}),q==="filters"&&e.jsxs("div",{className:"space-y-2",children:[I.map((t,l)=>e.jsxs("div",{className:"space-y-1 p-2 border rounded bg-background","data-testid":`filter-${l}`,children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("select",{value:t.field,onChange:s=>se(l,{field:s.target.value}),className:"flex-1 px-1 py-0.5 text-xs border rounded bg-background",disabled:o,children:g.map(s=>e.jsx("option",{value:s.name,children:s.label||s.name},s.name))}),!o&&e.jsx("button",{onClick:()=>ie(l),className:"p-0.5 rounded hover:bg-destructive/10",children:e.jsx(h.Trash2,{className:"h-3 w-3 text-destructive"})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("select",{value:t.operator,onChange:s=>se(l,{operator:s.target.value}),className:"w-24 px-1 py-0.5 text-xs border rounded bg-background",disabled:o,children:ct.map(s=>e.jsx("option",{value:s.value,children:s.label},s.value))}),e.jsx("input",{type:"text",value:t.value??"",onChange:s=>se(l,{value:s.target.value}),placeholder:U.valuePlaceholder,className:"flex-1 px-1 py-0.5 text-xs border rounded bg-background",readOnly:o})]})]},l)),!o&&e.jsxs("button",{onClick:le,className:"w-full flex items-center justify-center gap-1 px-2 py-1.5 text-xs rounded border border-dashed border-border hover:bg-accent","data-testid":"add-filter","aria-label":U.addFilter,children:[e.jsx(h.Plus,{className:"h-3 w-3"})," ",U.addFilter]})]}),q==="sort"&&e.jsxs("div",{className:"space-y-2",children:[F.map((t,l)=>e.jsxs("div",{className:"flex items-center gap-1 p-2 border rounded bg-background","data-testid":`sort-${l}`,children:[e.jsx("select",{value:t.field,onChange:s=>m(l,{field:s.target.value}),className:"flex-1 px-1 py-0.5 text-xs border rounded bg-background",disabled:o,children:g.map(s=>e.jsx("option",{value:s.name,children:s.label||s.name},s.name))}),e.jsxs("select",{value:t.direction,onChange:s=>m(l,{direction:s.target.value}),className:"w-16 px-1 py-0.5 text-xs border rounded bg-background",disabled:o,children:[e.jsx("option",{value:"asc",children:U.asc}),e.jsx("option",{value:"desc",children:U.desc})]}),!o&&e.jsx("button",{onClick:()=>L(l),className:"p-0.5 rounded hover:bg-destructive/10",children:e.jsx(h.Trash2,{className:"h-3 w-3 text-destructive"})})]},l)),!o&&e.jsxs("button",{onClick:c,className:"w-full flex items-center justify-center gap-1 px-2 py-1.5 text-xs rounded border border-dashed border-border hover:bg-accent","data-testid":"add-sort","aria-label":U.addSort,children:[e.jsx(h.Plus,{className:"h-3 w-3"})," ",U.addSort]})]}),q==="options"&&e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"text-xs font-medium",children:[Ke.find(t=>t.type===R)?.label??R," Options"]}),R==="kanban"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:U.groupByField}),e.jsxs("select",{value:z.groupBy??"",onChange:t=>!o&&E({options:{...z,groupBy:t.target.value}}),className:"w-full px-2 py-1 text-sm border rounded bg-background mt-1",disabled:o,"data-testid":"kanban-group-by",children:[e.jsx("option",{value:"",children:U.selectField}),g.map(t=>e.jsx("option",{value:t.name,children:t.label||t.name},t.name))]})]}),R==="calendar"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:U.startDateField}),e.jsxs("select",{value:z.startDateField??"",onChange:t=>!o&&E({options:{...z,startDateField:t.target.value}}),className:"w-full px-2 py-1 text-sm border rounded bg-background mt-1",disabled:o,"data-testid":"calendar-start-date",children:[e.jsx("option",{value:"",children:U.selectField}),g.map(t=>e.jsx("option",{value:t.name,children:t.label||t.name},t.name))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:U.titleField}),e.jsxs("select",{value:z.titleField??"",onChange:t=>!o&&E({options:{...z,titleField:t.target.value}}),className:"w-full px-2 py-1 text-sm border rounded bg-background mt-1",disabled:o,"data-testid":"calendar-title-field",children:[e.jsx("option",{value:"",children:U.selectField}),g.map(t=>e.jsx("option",{value:t.name,children:t.label||t.name},t.name))]})]})]}),R==="map"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:U.latitudeField}),e.jsxs("select",{value:z.latitudeField??"",onChange:t=>!o&&E({options:{...z,latitudeField:t.target.value}}),className:"w-full px-2 py-1 text-sm border rounded bg-background mt-1",disabled:o,children:[e.jsx("option",{value:"",children:U.selectField}),g.map(t=>e.jsx("option",{value:t.name,children:t.label||t.name},t.name))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:U.longitudeField}),e.jsxs("select",{value:z.longitudeField??"",onChange:t=>!o&&E({options:{...z,longitudeField:t.target.value}}),className:"w-full px-2 py-1 text-sm border rounded bg-background mt-1",disabled:o,children:[e.jsx("option",{value:"",children:U.selectField}),g.map(t=>e.jsx("option",{value:t.name,children:t.label||t.name},t.name))]})]})]}),R==="gallery"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:U.imageField}),e.jsxs("select",{value:z.imageField??"",onChange:t=>!o&&E({options:{...z,imageField:t.target.value}}),className:"w-full px-2 py-1 text-sm border rounded bg-background mt-1",disabled:o,children:[e.jsx("option",{value:"",children:U.selectField}),g.map(t=>e.jsx("option",{value:t.name,children:t.label||t.name},t.name))]})]}),(R==="timeline"||R==="gantt")&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:U.dateField}),e.jsxs("select",{value:z.dateField??z.startDateField??"",onChange:t=>!o&&E({options:{...z,dateField:t.target.value,startDateField:t.target.value}}),className:"w-full px-2 py-1 text-sm border rounded bg-background mt-1",disabled:o,children:[e.jsx("option",{value:"",children:U.selectField}),g.map(t=>e.jsx("option",{value:t.name,children:t.label||t.name},t.name))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs text-muted-foreground",children:U.titleField}),e.jsxs("select",{value:z.titleField??"",onChange:t=>!o&&E({options:{...z,titleField:t.target.value}}),className:"w-full px-2 py-1 text-sm border rounded bg-background mt-1",disabled:o,children:[e.jsx("option",{value:"",children:U.selectField}),g.map(t=>e.jsx("option",{value:t.name,children:t.label||t.name},t.name))]})]})]}),R==="grid"&&e.jsx("div",{className:"text-xs text-muted-foreground text-center py-2",children:U.gridOptionsHint})]})]})]})]}),e.jsx(ge,{isOpen:K.isOpen,title:K.title,message:K.message,onConfirm:K.onConfirm,onCancel:K.onCancel})]})}function Ue(...a){return ue.twMerge(ce.clsx(a))}function ut({versions:a,onRestore:C,className:D}){return e.jsxs("div",{className:Ue("flex flex-col",D),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(h.History,{className:"h-4 w-4"}),"Version History"]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:a.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"}),a.map(j=>e.jsxs("div",{className:Ue("relative flex items-start gap-3 px-3 py-2 hover:bg-accent/50",j.isCurrent&&"bg-accent/30"),children:[e.jsx("div",{className:Ue("relative z-10 mt-1 h-2.5 w-2.5 rounded-full border-2 bg-background",j.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",j.version]}),j.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:j.description}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 text-[0.65rem] text-muted-foreground/70",children:[e.jsx(h.User,{className:"h-2.5 w-2.5"}),e.jsx("span",{children:j.userName}),e.jsx(h.Clock,{className:"h-2.5 w-2.5 ml-1"}),e.jsx("span",{children:new Date(j.timestamp).toLocaleString()})]}),!j.isCurrent&&C&&e.jsx("button",{onClick:()=>C(j.version),className:"mt-1 text-[0.65rem] text-primary hover:underline",children:"Restore this version"})]})]},j.version))]})})]})}pe.ComponentRegistry.register("page-designer",Ye,{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}]}),pe.ComponentRegistry.register("data-model-designer",Ze,{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}]}),pe.ComponentRegistry.register("process-designer",He,{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}]}),pe.ComponentRegistry.register("report-designer",Xe,{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}]}),pe.ComponentRegistry.register("view-designer",We,{label:"View Designer",category:"Designer",inputs:[{name:"objectName",type:"string",label:"Object Name"},{name:"viewId",type:"string",label:"View ID"},{name:"viewLabel",type:"string",label:"View Label"},{name:"viewType",type:"string",label:"View Type",defaultValue:"grid"},{name:"readOnly",type:"boolean",label:"Read Only",defaultValue:!1}]}),J.CollaborationProvider=st,J.ConfirmDialog=ge,J.ConnectionStatusIndicator=nt,J.DataModelDesigner=Ze,J.Minimap=Ae,J.PageDesigner=Ye,J.ProcessDesigner=He,J.PropertyEditor=ke,J.ReportDesigner=Xe,J.VersionHistory=ut,J.ViewDesigner=We,J.useCanvasPanZoom=Ie,J.useClipboard=fe,J.useConfirmDialog=be,J.useMultiSelect=Ce,J.useUndoRedo=xe,Object.defineProperty(J,Symbol.toStringTag,{value:"Module"})}));
|
|
@@ -9,6 +9,10 @@ export interface CollaborationContextValue {
|
|
|
9
9
|
sendOperation: (operation: Omit<CollaborationOperation, 'id' | 'timestamp' | 'version'>) => void;
|
|
10
10
|
/** Current user ID */
|
|
11
11
|
currentUserId?: string;
|
|
12
|
+
/** Connection state */
|
|
13
|
+
connectionState: 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
14
|
+
/** Version history entries (when versionHistory is enabled) */
|
|
15
|
+
versionCount: number;
|
|
12
16
|
}
|
|
13
17
|
export interface CollaborationProviderProps {
|
|
14
18
|
/** Collaboration configuration */
|
|
@@ -21,16 +25,25 @@ export interface CollaborationProviderProps {
|
|
|
21
25
|
};
|
|
22
26
|
/** Callback when an operation is received from another user */
|
|
23
27
|
onOperation?: (operation: CollaborationOperation) => void;
|
|
28
|
+
/** Callback when a remote user joins or leaves */
|
|
29
|
+
onPresenceChange?: (users: CollaborationPresence[]) => void;
|
|
24
30
|
/** Children */
|
|
25
31
|
children: React.ReactNode;
|
|
26
32
|
}
|
|
27
33
|
/**
|
|
28
34
|
* Provider for multi-user collaborative editing.
|
|
29
35
|
* Manages WebSocket connection, presence, and operation broadcasting.
|
|
36
|
+
* Supports real-time collaboration via WebSocket when serverUrl is configured.
|
|
30
37
|
*/
|
|
31
|
-
export declare function CollaborationProvider({ config, user, onOperation, children, }: CollaborationProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
export declare function CollaborationProvider({ config, user, onOperation, onPresenceChange, children, }: CollaborationProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
32
39
|
/**
|
|
33
40
|
* Hook to access the collaboration context.
|
|
34
41
|
*/
|
|
35
42
|
export declare function useCollaboration(): CollaborationContextValue | null;
|
|
36
|
-
|
|
43
|
+
/**
|
|
44
|
+
* Connection status indicator component.
|
|
45
|
+
* Shows the current collaboration connection state with a colored dot and label.
|
|
46
|
+
*/
|
|
47
|
+
export declare function ConnectionStatusIndicator({ className }: {
|
|
48
|
+
className?: string;
|
|
49
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -22,6 +22,7 @@ export interface DataModelDesignerProps {
|
|
|
22
22
|
/**
|
|
23
23
|
* Data model designer for creating ER diagrams.
|
|
24
24
|
* Allows visual design of entities, fields, and relationships.
|
|
25
|
+
* Supports undo/redo, multi-select, copy/paste, pan/zoom, drag-to-reposition,
|
|
26
|
+
* inline field editing, property editor, minimap, auto-layout, and collaboration.
|
|
25
27
|
*/
|
|
26
28
|
export declare function DataModelDesigner({ entities: initialEntities, relationships: initialRelationships, canvas, showRelationshipLabels, readOnly, onEntitiesChange, onRelationshipsChange, className, }: DataModelDesignerProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
//# sourceMappingURL=DataModelDesigner.d.ts.map
|
|
@@ -14,6 +14,8 @@ export interface PageDesignerProps {
|
|
|
14
14
|
propertyEditor?: boolean;
|
|
15
15
|
/** Read-only mode */
|
|
16
16
|
readOnly?: boolean;
|
|
17
|
+
/** Show minimap */
|
|
18
|
+
showMinimap?: boolean;
|
|
17
19
|
/** Callback when components change */
|
|
18
20
|
onChange?: (components: DesignerComponent[]) => void;
|
|
19
21
|
/** Custom CSS class */
|
|
@@ -23,5 +25,4 @@ export interface PageDesignerProps {
|
|
|
23
25
|
* Drag-and-drop page designer component.
|
|
24
26
|
* Allows visual composition of UI components on a canvas.
|
|
25
27
|
*/
|
|
26
|
-
export declare function PageDesigner({ canvas, components: initialComponents, palette, showComponentTree, undoRedo, readOnly, onChange, className, }: PageDesignerProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
//# sourceMappingURL=PageDesigner.d.ts.map
|
|
28
|
+
export declare function PageDesigner({ canvas, components: initialComponents, palette, showComponentTree, undoRedo: undoRedoEnabled, propertyEditor: propertyEditorEnabled, readOnly, showMinimap: showMinimapProp, onChange, className, }: PageDesignerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -28,6 +28,10 @@ export interface ProcessDesignerProps {
|
|
|
28
28
|
/**
|
|
29
29
|
* Process designer for creating BPMN 2.0 workflows.
|
|
30
30
|
* Supports nodes, edges, lanes, and conditional flows.
|
|
31
|
+
*
|
|
32
|
+
* Phase 2-4 features: undo/redo, confirm dialogs, multi-select,
|
|
33
|
+
* copy/paste, pan/zoom, minimap, edge creation UI, auto-layout,
|
|
34
|
+
* property editor, drag-and-drop, collaboration, keyboard shortcuts,
|
|
35
|
+
* and collapsible panels.
|
|
31
36
|
*/
|
|
32
|
-
export declare function ProcessDesigner({ processName, nodes: initialNodes, edges: initialEdges, lanes: _lanes, canvas, showToolbar, readOnly, onNodesChange, onEdgesChange, className, }: ProcessDesignerProps): import("react/jsx-runtime").JSX.Element;
|
|
33
|
-
//# sourceMappingURL=ProcessDesigner.d.ts.map
|
|
37
|
+
export declare function ProcessDesigner({ processName, nodes: initialNodes, edges: initialEdges, lanes: _lanes, canvas, showMinimap: showMinimapProp, showToolbar, readOnly, onNodesChange, onEdgesChange, className, }: ProcessDesignerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -35,4 +35,3 @@ export interface ReportDesignerProps {
|
|
|
35
35
|
* Supports sections (header, detail, footer) with drag-and-drop elements.
|
|
36
36
|
*/
|
|
37
37
|
export declare function ReportDesigner({ reportName, objectName, pageSize, orientation, margins, sections: initialSections, showToolbar, showPropertyPanel, readOnly, onSectionsChange, className, }: ReportDesignerProps): import("react/jsx-runtime").JSX.Element;
|
|
38
|
-
//# sourceMappingURL=ReportDesigner.d.ts.map
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ViewDesignerColumn } from '../../types/src';
|
|
2
|
+
type ViewType = 'grid' | 'kanban' | 'gallery' | 'calendar' | 'timeline' | 'gantt' | 'map';
|
|
3
|
+
export interface ViewDesignerProps {
|
|
4
|
+
/** Object name this view is for */
|
|
5
|
+
objectName: string;
|
|
6
|
+
/** View identifier (for editing existing views) */
|
|
7
|
+
viewId?: string;
|
|
8
|
+
/** Initial view label */
|
|
9
|
+
viewLabel?: string;
|
|
10
|
+
/** Initial view type */
|
|
11
|
+
viewType?: ViewType;
|
|
12
|
+
/** Initial columns configuration */
|
|
13
|
+
columns?: ViewDesignerColumn[];
|
|
14
|
+
/** Initial filter conditions */
|
|
15
|
+
filters?: Array<{
|
|
16
|
+
field: string;
|
|
17
|
+
operator: string;
|
|
18
|
+
value: any;
|
|
19
|
+
}>;
|
|
20
|
+
/** Initial sort configuration */
|
|
21
|
+
sort?: Array<{
|
|
22
|
+
field: string;
|
|
23
|
+
direction: 'asc' | 'desc';
|
|
24
|
+
}>;
|
|
25
|
+
/** Available fields from the object schema */
|
|
26
|
+
availableFields?: Array<{
|
|
27
|
+
name: string;
|
|
28
|
+
label: string;
|
|
29
|
+
type: string;
|
|
30
|
+
}>;
|
|
31
|
+
/** Type-specific options (kanban groupField, calendar startDateField, etc.) */
|
|
32
|
+
options?: Record<string, any>;
|
|
33
|
+
/** Read-only mode */
|
|
34
|
+
readOnly?: boolean;
|
|
35
|
+
/** Callback when save is clicked */
|
|
36
|
+
onSave?: (config: ViewDesignerConfig) => void;
|
|
37
|
+
/** Callback when cancel is clicked */
|
|
38
|
+
onCancel?: () => void;
|
|
39
|
+
/** Custom CSS class */
|
|
40
|
+
className?: string;
|
|
41
|
+
}
|
|
42
|
+
/** The output configuration from the view designer */
|
|
43
|
+
export interface ViewDesignerConfig {
|
|
44
|
+
viewId?: string;
|
|
45
|
+
viewLabel: string;
|
|
46
|
+
viewType: ViewType;
|
|
47
|
+
columns: ViewDesignerColumn[];
|
|
48
|
+
filters: Array<{
|
|
49
|
+
field: string;
|
|
50
|
+
operator: string;
|
|
51
|
+
value: any;
|
|
52
|
+
}>;
|
|
53
|
+
sort: Array<{
|
|
54
|
+
field: string;
|
|
55
|
+
direction: 'asc' | 'desc';
|
|
56
|
+
}>;
|
|
57
|
+
options: Record<string, any>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Visual designer for creating and editing list views.
|
|
61
|
+
* Provides a 3-panel layout:
|
|
62
|
+
* - Left: Field palette (available fields to add)
|
|
63
|
+
* - Center: View layout preview (columns, order)
|
|
64
|
+
* - Right: Properties panel (view settings, filters, sort)
|
|
65
|
+
*/
|
|
66
|
+
export declare function ViewDesigner({ objectName, viewId, viewLabel: initialViewLabel, viewType: initialViewType, columns: initialColumns, filters: initialFilters, sort: initialSort, availableFields, options: initialOptions, readOnly, onSave, onCancel, className, }: ViewDesignerProps): import("react/jsx-runtime").JSX.Element;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export interface ConfirmDialogProps {
|
|
9
|
+
/** Whether the dialog is open */
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
/** Dialog title */
|
|
12
|
+
title: string;
|
|
13
|
+
/** Dialog message */
|
|
14
|
+
message: string;
|
|
15
|
+
/** Confirm button label */
|
|
16
|
+
confirmLabel?: string;
|
|
17
|
+
/** Cancel button label */
|
|
18
|
+
cancelLabel?: string;
|
|
19
|
+
/** Whether this is a destructive action */
|
|
20
|
+
destructive?: boolean;
|
|
21
|
+
/** Called when user confirms */
|
|
22
|
+
onConfirm: () => void;
|
|
23
|
+
/** Called when user cancels */
|
|
24
|
+
onCancel: () => void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Confirmation dialog for destructive actions in designers.
|
|
28
|
+
* Uses native dialog element for proper focus trapping and accessibility.
|
|
29
|
+
*/
|
|
30
|
+
export declare function ConfirmDialog({ isOpen, title, message, confirmLabel, cancelLabel, destructive, onConfirm, onCancel, }: ConfirmDialogProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectUI
|
|
3
|
+
* Copyright (c) 2024-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
export interface MinimapItem {
|
|
9
|
+
id: string;
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
color?: string;
|
|
15
|
+
selected?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface MinimapProps {
|
|
18
|
+
/** Items to display on the minimap */
|
|
19
|
+
items: MinimapItem[];
|
|
20
|
+
/** Canvas width */
|
|
21
|
+
canvasWidth: number;
|
|
22
|
+
/** Canvas height */
|
|
23
|
+
canvasHeight: number;
|
|
24
|
+
/** Position of the minimap */
|
|
25
|
+
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
26
|
+
/** Minimap size */
|
|
27
|
+
size?: number;
|
|
28
|
+
/** CSS class */
|
|
29
|
+
className?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Minimap component for canvas-based designers.
|
|
33
|
+
* Shows a bird's-eye view of all items on the canvas.
|
|
34
|
+
*/
|
|
35
|
+
export declare function Minimap({ items, canvasWidth, canvasHeight, position, size, className, }: MinimapProps): import("react/jsx-runtime").JSX.Element;
|