@arach/arc 0.1.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 +60 -0
- package/dist/arc.es.js +9215 -0
- package/dist/arc.umd.js +172 -0
- package/dist/index.d.ts +152 -0
- package/package.json +81 -0
package/dist/arc.umd.js
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
(function(K,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],a):(K=typeof globalThis<"u"?globalThis:K||self,a(K.Arc={},K.ReactJSXRuntime,K.React))})(this,(function(K,a,b){"use strict";function Bo(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,o.get?o:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const O=Bo(b),Wo={width:1600,height:900},kn={enabled:!0,size:24,color:"#71717a",opacity:.1,type:"dots"},Uo=[{name:"Zinc",value:"#71717a"},{name:"Sky",value:"#38bdf8"},{name:"Violet",value:"#a78bfa"},{name:"Emerald",value:"#34d399"}],q={xs:{width:80,height:36},s:{width:95,height:42},m:{width:145,height:68},l:{width:210,height:85}},Xo={xpc:{color:"emerald",strokeWidth:2,label:"XPC"},http:{color:"amber",strokeWidth:2,label:"HTTP"},tailscale:{color:"zinc",strokeWidth:2,label:"Tailscale"},cloudkit:{color:"sky",strokeWidth:2,label:"CloudKit",dashed:!0},audio:{color:"emerald",strokeWidth:3,label:"audio"},peer:{color:"zinc",strokeWidth:1.5,dashed:!0}},jo=["top","right","bottom","left","bottomRight","bottomLeft"],Et=["violet","emerald","blue","amber","zinc","sky"],Go=["xs","s","m","l"],Me=0;function Vo(e,t){const n=e[t];if(!n)return null;const o=q[n.size]||q.m;return{...n,...o}}function Dt(e,t,n){const o=Vo(e,t);if(!o)return{x:0,y:0};switch(n){case"left":return{x:o.x-Me,y:o.y+o.height/2};case"right":return{x:o.x+o.width+Me,y:o.y+o.height/2};case"top":return{x:o.x+o.width/2,y:o.y-Me};case"bottom":return{x:o.x+o.width/2,y:o.y+o.height+Me};case"bottomRight":return{x:o.x+o.width+Me,y:o.y+o.height-15};case"bottomLeft":return{x:o.x-Me,y:o.y+o.height-15};case"topRight":return{x:o.x+o.width+Me,y:o.y+15};case"topLeft":return{x:o.x-Me,y:o.y+15};default:return{x:o.x+o.width/2,y:o.y+o.height/2}}}function Ko(e,t){return{x:(e.x+t.x)/2,y:(e.y+t.y)/2}}function qo(){return`node_${crypto.randomUUID().slice(0,8)}`}const Zo=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Jo=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,n,o)=>o?o.toUpperCase():n.toLowerCase()),vn=e=>{const t=Jo(e);return t.charAt(0).toUpperCase()+t.slice(1)},wn=(...e)=>e.filter((t,n,o)=>!!t&&t.trim()!==""&&o.indexOf(t)===n).join(" ").trim(),Qo=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var Ro={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const ei=b.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:r="",children:i,iconNode:s,...l},c)=>b.createElement("svg",{ref:c,...Ro,width:t,height:t,stroke:e,strokeWidth:o?Number(n)*24/Number(t):n,className:wn("lucide",r),...!i&&!Qo(l)&&{"aria-hidden":"true"},...l},[...s.map(([d,f])=>b.createElement(d,f)),...Array.isArray(i)?i:[i]]));const I=(e,t)=>{const n=b.forwardRef(({className:o,...r},i)=>b.createElement(ei,{ref:i,iconNode:t,className:wn(`lucide-${Zo(vn(e))}`,`lucide-${e}`,o),...r}));return n.displayName=vn(e),n};const ti=I("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const ni=I("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);const ri=I("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const oi=I("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);const Ot=I("box",[["path",{d:"M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z",key:"hh9hay"}],["path",{d:"m3.3 7 8.7 5 8.7-5",key:"g66t2b"}],["path",{d:"M12 22V12",key:"d0xqtd"}]]);const ii=I("braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const si=I("camera",[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);const ai=I("chart-no-axes-column-increasing",[["path",{d:"M5 21v-6",key:"1hz6c0"}],["path",{d:"M12 21V9",key:"uvy0l4"}],["path",{d:"M19 21V3",key:"11j9sm"}]]);const li=I("chart-pie",[["path",{d:"M21 12c.552 0 1.005-.449.95-.998a10 10 0 0 0-8.953-8.951c-.55-.055-.998.398-.998.95v8a1 1 0 0 0 1 1z",key:"pzmjnu"}],["path",{d:"M21.21 15.89A10 10 0 1 1 8 2.83",key:"k2fpak"}]]);const ci=I("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const Cn=I("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const Nn=I("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const zn=I("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const di=I("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);const ui=I("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]);const hi=I("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]);const fi=I("crop",[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]]);const pi=I("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);const gi=I("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const Mn=I("file-code",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]]);const yi=I("file-image",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);const mi=I("file",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]]);const xi=I("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const bi=I("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);const ki=I("funnel",[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]]);const vi=I("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const _n=I("grid-3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]);const wi=I("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);const Ci=I("headphones",[["path",{d:"M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3",key:"1xhozi"}]]);const Ni=I("image",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]]);const zi=I("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);const $n=I("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]);const Mi=I("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);const _i=I("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const $i=I("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const Si=I("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const Ai=I("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const Ii=I("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);const Ei=I("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);const Di=I("mic",[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]]);const Oi=I("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);const Li=I("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]);const Ti=I("mouse-pointer-2",[["path",{d:"M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",key:"edeuup"}]]);const Pi=I("move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]);const Fi=I("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);const Yi=I("palette",[["path",{d:"M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z",key:"e79jfc"}],["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}]]);const Hi=I("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]);const Bi=I("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);const Sn=I("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Wi=I("redo-2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);const Ui=I("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);const Xi=I("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);const ji=I("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const Gi=I("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const An=I("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const Vi=I("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const Ki=I("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const qi=I("share",[["path",{d:"M12 2v13",key:"1km8f5"}],["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}]]);const Zi=I("shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);const Ji=I("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const Qi=I("speaker",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["circle",{cx:"12",cy:"14",r:"4",key:"1jruaj"}],["path",{d:"M12 14h.01",key:"1etili"}]]);const In=I("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Ri=I("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);const es=I("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const Lt=I("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const ts=I("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);const ns=I("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const rs=I("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const os=I("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]);const is=I("watch",[["path",{d:"M12 10v2.2l1.6 1",key:"n3r21l"}],["path",{d:"m16.13 7.66-.81-4.05a2 2 0 0 0-2-1.61h-2.68a2 2 0 0 0-2 1.61l-.78 4.05",key:"18k57s"}],["path",{d:"m7.88 16.36.8 4a2 2 0 0 0 2 1.61h2.72a2 2 0 0 0 2-1.61l.81-4.05",key:"16ny36"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}]]);const ss=I("wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);const as=I("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);const ls=I("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);const cs=I("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]);const ds=I("zoom-out",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),En={Monitor:Oi,Server:Vi,Smartphone:Ji,Watch:is,Cloud:di,Cpu:hi,Database:pi,HardDrive:wi,Wifi:ss,Globe:vi,User:rs,Users:os,Lock:Si,Key:zi,Shield:Zi,Mic:Di,Camera:si,Speaker:Qi,Headphones:Ci,Code:ui,Terminal:es,FileCode:Mn,Folder:bi,Zap:ls,Activity:ti,BarChart:ai,PieChart:li,ArrowRight:ri,ArrowDown:ni,RefreshCw:Ui,Repeat:Xi,Box:Ot,Package:Fi,Layers:$n,Grid:_n,Settings:Ki,Bell:oi,Mail:Ai,MessageSquare:Ei,Search:An,Filter:ki,Download:gi,Upload:ns,Play:Bi,Pause:Hi,Square:In,Circle:zn},Dn=Object.keys(En);function On(e){return En[e]||Ot}const us="Box",Tt={talkie:{id:"talkie",name:"Talkie Docs",description:"Dark theme matching Talkie documentation",canvas:{background:"bg-zinc-950",border:"border-zinc-800",grid:{color:"rgb(113 113 122)",size:24,opacity:.1}},node:{background:"bg-zinc-900",border:"border-zinc-800",borderRadius:"rounded-xl",accentPosition:"left",accentWidth:4,textColor:"text-white",subtitleStyle:"colored",descriptionColor:"text-zinc-500",iconBackground:"bg-zinc-900",iconBorderStyle:"colored"},connector:{defaultDashed:!0,defaultStrokeWidth:2,arrowStyle:"filled",labelFont:"ui-monospace, monospace",labelSize:11}},blueprint:{id:"blueprint",name:"Blueprint",description:"Technical blueprint style with blue tones",canvas:{background:"bg-slate-900",border:"border-slate-700",grid:{color:"rgb(71 85 105)",size:20,opacity:.2}},node:{background:"bg-slate-800/80",border:"border-slate-600",borderRadius:"rounded-lg",accentPosition:"top",accentWidth:3,textColor:"text-slate-100",subtitleStyle:"muted",descriptionColor:"text-slate-400",iconBackground:"bg-slate-700/50",iconBorderStyle:"muted"},connector:{defaultDashed:!1,defaultStrokeWidth:2,arrowStyle:"filled",labelFont:"ui-sans-serif, system-ui",labelSize:10}},light:{id:"light",name:"Light Mode",description:"Clean light theme for documents",canvas:{background:"bg-white",border:"border-zinc-200",grid:{color:"rgb(161 161 170)",size:24,opacity:.15}},node:{background:"bg-white",border:"border-zinc-200",borderRadius:"rounded-xl",accentPosition:"left",accentWidth:4,textColor:"text-zinc-900",subtitleStyle:"colored",descriptionColor:"text-zinc-500",iconBackground:"bg-zinc-50",iconBorderStyle:"colored"},connector:{defaultDashed:!0,defaultStrokeWidth:2,arrowStyle:"filled",labelFont:"ui-monospace, monospace",labelSize:11}},minimal:{id:"minimal",name:"Minimal",description:"Simple and clean with subtle styling",canvas:{background:"bg-zinc-900",border:"border-zinc-800",grid:{color:"transparent",size:0,opacity:0}},node:{background:"bg-zinc-800/60",border:"border-zinc-700/50",borderRadius:"rounded-2xl",accentPosition:"none",accentWidth:0,textColor:"text-zinc-100",subtitleStyle:"muted",descriptionColor:"text-zinc-500",iconBackground:"bg-transparent",iconBorderStyle:"none"},connector:{defaultDashed:!1,defaultStrokeWidth:1.5,arrowStyle:"outline",labelFont:"ui-sans-serif, system-ui",labelSize:10}}},Ln="talkie";function Tn(e){return Tt[e]||Tt[Ln]}function hs(){return Object.values(Tt).map(e=>({id:e.id,name:e.name,description:e.description}))}const Pn=()=>({layout:{...Wo},grid:{...kn},nodes:{},nodeData:{},connectors:[],connectorStyles:{...Xo},groups:[],images:[],exportZone:null}),Pt={diagram:Pn(),editor:{selectedNodeIds:[],selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null,mode:"select",pendingConnector:null,pendingGroup:null,isDragging:!1,dragOffset:{x:0,y:0},dragNodeOffsets:{},template:Ln,zoom:1,viewMode:"2d"},meta:{filename:null,isDirty:!1,lastSaved:null},history:{past:[],future:[]}};function oe(e){return{...e,history:{past:[...e.history.past.slice(-49),e.diagram],future:[]},meta:{...e.meta,isDirty:!0}}}function fs(e,t){switch(t.type){case"node/add":{const{position:n,nodeData:o}=t,r=qo(),i=oe(e);return{...i,diagram:{...i.diagram,nodes:{...i.diagram.nodes,[r]:{x:n.x,y:n.y,size:"normal"}},nodeData:{...i.diagram.nodeData,[r]:{icon:us,name:"New Node",subtitle:"",description:"",color:"violet",...o}}},editor:{...i.editor,selectedNodeIds:[r],selectedConnectorIndex:null,mode:"select"}}}case"node/remove":{const{nodeId:n}=t,o=oe(e),{[n]:r,...i}=o.diagram.nodes,{[n]:s,...l}=o.diagram.nodeData,c=o.diagram.connectors.filter(d=>d.from!==n&&d.to!==n);return{...o,diagram:{...o.diagram,nodes:i,nodeData:l,connectors:c},editor:{...o.editor,selectedNodeIds:[],selectedConnectorIndex:null}}}case"node/move":{const{nodeId:n,x:o,y:r}=t;return{...e,diagram:{...e.diagram,nodes:{...e.diagram.nodes,[n]:{...e.diagram.nodes[n],x:o,y:r}}},meta:{...e.meta,isDirty:!0}}}case"nodes/move":{const{moves:n}=t,o={...e.diagram.nodes};for(const{nodeId:r,x:i,y:s}of n)o[r]&&(o[r]={...o[r],x:i,y:s});return{...e,diagram:{...e.diagram,nodes:o},meta:{...e.meta,isDirty:!0}}}case"node/update":{const{nodeId:n,updates:o}=t,r=oe(e);return{...r,diagram:{...r.diagram,nodeData:{...r.diagram.nodeData,[n]:{...r.diagram.nodeData[n],...o}}}}}case"node/resize":{const{nodeId:n,size:o,width:r,height:i}=t,s=oe(e),c={...s.diagram.nodes[n]};return o!==void 0&&(c.size=o,delete c.width,delete c.height),r!==void 0&&(c.width=r),i!==void 0&&(c.height=i),{...s,diagram:{...s.diagram,nodes:{...s.diagram.nodes,[n]:c}}}}case"node/updatePosition":{const{nodeId:n,updates:o}=t,r=oe(e),i=r.diagram.nodes[n];return{...r,diagram:{...r.diagram,nodes:{...r.diagram.nodes,[n]:{...i,...o}}}}}case"connector/add":{const{from:n,to:o,fromAnchor:r,toAnchor:i,style:s="http"}=t,l=oe(e);return{...l,diagram:{...l.diagram,connectors:[...l.diagram.connectors,{from:n,to:o,fromAnchor:r,toAnchor:i,style:s}]},editor:{...l.editor,selectedNodeIds:[],selectedConnectorIndex:l.diagram.connectors.length,mode:"select",pendingConnector:null}}}case"connector/remove":{const{index:n}=t,o=oe(e);return{...o,diagram:{...o.diagram,connectors:o.diagram.connectors.filter((r,i)=>i!==n)},editor:{...o.editor,selectedConnectorIndex:null}}}case"connector/update":{const{index:n,updates:o}=t,r=oe(e);return{...r,diagram:{...r.diagram,connectors:r.diagram.connectors.map((i,s)=>s===n?{...i,...o}:i)}}}case"connectorStyle/update":{const{styleName:n,updates:o}=t,r=oe(e);return{...r,diagram:{...r.diagram,connectorStyles:{...r.diagram.connectorStyles,[n]:{...r.diagram.connectorStyles[n],...o}}}}}case"connectorStyle/add":{const{styleName:n,style:o}=t,r=oe(e);return{...r,diagram:{...r.diagram,connectorStyles:{...r.diagram.connectorStyles,[n]:o}}}}case"connectorStyle/delete":{const{styleName:n}=t,o=oe(e),{[n]:r,...i}=o.diagram.connectorStyles;return{...o,diagram:{...o.diagram,connectorStyles:i}}}case"group/add":{const{group:n}=t,o=`group_${crypto.randomUUID().slice(0,8)}`,r=oe(e),i=r.diagram.groups||[];return{...r,diagram:{...r.diagram,groups:[...i,{id:o,...n}]},editor:{...r.editor,selectedGroupId:o,selectedNodeIds:[],selectedConnectorIndex:null}}}case"group/update":{const{groupId:n,updates:o}=t,r=oe(e),i=r.diagram.groups||[];return{...r,diagram:{...r.diagram,groups:i.map(s=>s.id===n?{...s,...o}:s)}}}case"group/remove":{const{groupId:n}=t,o=oe(e),r=o.diagram.groups||[];return{...o,diagram:{...o.diagram,groups:r.filter(i=>i.id!==n)},editor:{...o.editor,selectedGroupId:null}}}case"select/group":return{...e,editor:{...e.editor,selectedGroupId:t.groupId,selectedNodeIds:[],selectedConnectorIndex:null,selectedImageId:null}};case"image/add":{const{image:n}=t,o=`img_${crypto.randomUUID().slice(0,8)}`,r=oe(e),i=r.diagram.images||[];return{...r,diagram:{...r.diagram,images:[...i,{id:o,...n}]},editor:{...r.editor,selectedImageId:o,selectedNodeIds:[],selectedConnectorIndex:null,selectedGroupId:null}}}case"image/update":{const{imageId:n,updates:o}=t,r=oe(e),i=r.diagram.images||[];return{...r,diagram:{...r.diagram,images:i.map(s=>s.id===n?{...s,...o}:s)}}}case"image/remove":{const{imageId:n}=t,o=oe(e),r=o.diagram.images||[];return{...o,diagram:{...o.diagram,images:r.filter(i=>i.id!==n)},editor:{...o.editor,selectedImageId:null}}}case"select/image":return{...e,editor:{...e.editor,selectedImageId:t.imageId,selectedNodeIds:[],selectedConnectorIndex:null,selectedGroupId:null}};case"exportZone/set":{const{zone:n}=t;return{...e,diagram:{...e.diagram,exportZone:n},meta:{...e.meta,isDirty:!0}}}case"exportZone/clear":return{...e,diagram:{...e.diagram,exportZone:null},meta:{...e.meta,isDirty:!0}};case"select/node":{const{nodeId:n,addToSelection:o}=t;let r;return o?e.editor.selectedNodeIds.includes(n)?r=e.editor.selectedNodeIds.filter(i=>i!==n):r=[...e.editor.selectedNodeIds,n]:r=[n],{...e,editor:{...e.editor,selectedNodeIds:r,selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null}}}case"select/nodes":return{...e,editor:{...e.editor,selectedNodeIds:t.nodeIds,selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null}};case"select/connector":return{...e,editor:{...e.editor,selectedNodeIds:[],selectedConnectorIndex:t.index,selectedGroupId:null,selectedImageId:null}};case"select/clear":return{...e,editor:{...e.editor,selectedNodeIds:[],selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null}};case"mode/set":return{...e,editor:{...e.editor,mode:t.mode,pendingConnector:null,selectedNodeIds:[],selectedConnectorIndex:null}};case"pending/set":return{...e,editor:{...e.editor,pendingConnector:t.pendingConnector}};case"pending/clear":return{...e,editor:{...e.editor,pendingConnector:null}};case"drag/start":{const{offset:n,nodeOffsets:o,selectedIds:r}=t;return{...e,editor:{...e.editor,isDragging:!0,dragOffset:n,dragNodeOffsets:o||{},selectedNodeIds:r||e.editor.selectedNodeIds,selectedConnectorIndex:null,selectedGroupId:null,selectedImageId:null}}}case"drag/end":{const n=oe(e);return{...n,editor:{...n.editor,isDragging:!1,dragOffset:{x:0,y:0},dragNodeOffsets:{}}}}case"diagram/load":return{...e,diagram:t.diagram,meta:{filename:t.filename||null,isDirty:!1,lastSaved:null},history:{past:[],future:[]},editor:{...e.editor,selectedNodeIds:[],selectedConnectorIndex:null,mode:"select",pendingConnector:null}};case"diagram/new":return{...Pt,diagram:Pn()};case"diagram/saved":return{...e,meta:{...e.meta,filename:t.filename||e.meta.filename,isDirty:!1,lastSaved:new Date().toISOString()}};case"undo":{if(e.history.past.length===0)return e;const n=e.history.past[e.history.past.length-1],o=e.history.past.slice(0,-1);return{...e,diagram:n,history:{past:o,future:[e.diagram,...e.history.future]},meta:{...e.meta,isDirty:!0}}}case"redo":{if(e.history.future.length===0)return e;const n=e.history.future[0],o=e.history.future.slice(1);return{...e,diagram:n,history:{past:[...e.history.past,e.diagram],future:o},meta:{...e.meta,isDirty:!0}}}case"layout/update":{const n=oe(e);return{...n,diagram:{...n.diagram,layout:{...n.diagram.layout,...t.updates}}}}case"layout/expand":{const n=e.diagram.layout,o=Math.max(n.width,t.width||n.width),r=Math.max(n.height,t.height||n.height);return o===n.width&&r===n.height?e:{...e,diagram:{...e.diagram,layout:{...n,width:o,height:r}},meta:{...e.meta,isDirty:!0}}}case"grid/update":return{...e,diagram:{...e.diagram,grid:{...e.diagram.grid,...t.updates}}};case"template/set":{const n=Tn(t.templateId);return{...e,diagram:{...e.diagram,grid:{...e.diagram.grid,color:n.canvas.grid.color,size:n.canvas.grid.size,opacity:n.canvas.grid.opacity}},editor:{...e.editor,template:t.templateId},meta:{...e.meta,isDirty:!0}}}case"zoom/set":return{...e,editor:{...e.editor,zoom:Math.min(2,Math.max(.25,t.zoom))}};case"viewMode/set":return{...e,editor:{...e.editor,viewMode:t.viewMode}};default:return e}}const Fn=b.createContext(null);function Yn({children:e,initialDiagram:t}){const[n,o]=b.useReducer(fs,t?{...Pt,diagram:t}:Pt),r={addNode:b.useCallback((i,s)=>{o({type:"node/add",position:i,nodeData:s})},[]),removeNode:b.useCallback(i=>{o({type:"node/remove",nodeId:i})},[]),moveNode:b.useCallback((i,s,l)=>{o({type:"node/move",nodeId:i,x:s,y:l})},[]),moveNodes:b.useCallback(i=>{o({type:"nodes/move",moves:i})},[]),updateNode:b.useCallback((i,s)=>{o({type:"node/update",nodeId:i,updates:s})},[]),resizeNode:b.useCallback((i,s,l,c)=>{o({type:"node/resize",nodeId:i,size:s,width:l,height:c})},[]),updateNodePosition:b.useCallback((i,s)=>{o({type:"node/updatePosition",nodeId:i,updates:s})},[]),addConnector:b.useCallback((i,s,l,c,d)=>{o({type:"connector/add",from:i,to:s,fromAnchor:l,toAnchor:c,style:d})},[]),removeConnector:b.useCallback(i=>{o({type:"connector/remove",index:i})},[]),updateConnector:b.useCallback((i,s)=>{o({type:"connector/update",index:i,updates:s})},[]),addGroup:b.useCallback(i=>{o({type:"group/add",group:i})},[]),updateGroup:b.useCallback((i,s)=>{o({type:"group/update",groupId:i,updates:s})},[]),removeGroup:b.useCallback(i=>{o({type:"group/remove",groupId:i})},[]),addImage:b.useCallback(i=>{o({type:"image/add",image:i})},[]),updateImage:b.useCallback((i,s)=>{o({type:"image/update",imageId:i,updates:s})},[]),removeImage:b.useCallback(i=>{o({type:"image/remove",imageId:i})},[]),setExportZone:b.useCallback(i=>{o({type:"exportZone/set",zone:i})},[]),clearExportZone:b.useCallback(()=>{o({type:"exportZone/clear"})},[]),selectNode:b.useCallback((i,s=!1)=>{o({type:"select/node",nodeId:i,addToSelection:s})},[]),selectNodes:b.useCallback(i=>{o({type:"select/nodes",nodeIds:i})},[]),selectConnector:b.useCallback(i=>{o({type:"select/connector",index:i})},[]),selectGroup:b.useCallback(i=>{o({type:"select/group",groupId:i})},[]),selectImage:b.useCallback(i=>{o({type:"select/image",imageId:i})},[]),clearSelection:b.useCallback(()=>{o({type:"select/clear"})},[]),setMode:b.useCallback(i=>{o({type:"mode/set",mode:i})},[]),setPendingConnector:b.useCallback(i=>{o({type:"pending/set",pendingConnector:i})},[]),clearPendingConnector:b.useCallback(()=>{o({type:"pending/clear"})},[]),startDrag:b.useCallback((i,s,l,c)=>{o({type:"drag/start",nodeId:i,offset:s,nodeOffsets:l,selectedIds:c})},[]),endDrag:b.useCallback(()=>{o({type:"drag/end"})},[]),loadDiagram:b.useCallback((i,s)=>{o({type:"diagram/load",diagram:i,filename:s})},[]),newDiagram:b.useCallback(()=>{o({type:"diagram/new"})},[]),markSaved:b.useCallback(i=>{o({type:"diagram/saved",filename:i})},[]),undo:b.useCallback(()=>{o({type:"undo"})},[]),redo:b.useCallback(()=>{o({type:"redo"})},[]),updateLayout:b.useCallback(i=>{o({type:"layout/update",updates:i})},[]),expandLayout:b.useCallback((i,s)=>{o({type:"layout/expand",width:i,height:s})},[]),setTemplate:b.useCallback(i=>{o({type:"template/set",templateId:i})},[]),setZoom:b.useCallback(i=>{o({type:"zoom/set",zoom:i})},[]),zoomIn:b.useCallback(()=>{o({type:"zoom/set",zoom:n.editor.zoom*1.25})},[n.editor.zoom]),zoomOut:b.useCallback(()=>{o({type:"zoom/set",zoom:n.editor.zoom/1.25})},[n.editor.zoom]),resetZoom:b.useCallback(()=>{o({type:"zoom/set",zoom:1})},[]),setViewMode:b.useCallback(i=>{o({type:"viewMode/set",viewMode:i})},[])};return a.jsx(Fn.Provider,{value:{state:n,dispatch:o,actions:r},children:e})}function le(){const e=b.useContext(Fn);if(!e)throw new Error("useEditor must be used within an EditorProvider");return e}function ke(){const{state:e}=le();return e.diagram}function je(){const{state:e}=le();return e.editor}function Hn(){const{state:e}=le();return e.meta}function ps(){const{state:e}=le();return e.history}function Bn(){const{state:e}=le();return e.editor.template}function Ft(){const{state:e}=le();return e.editor.viewMode}const Wn="https://arc.jdi.sh";function gs({title:e,description:t,image:n,url:o}){b.useEffect(()=>{const r=document.title,i=c=>document.querySelector(`meta[property="${c}"]`)?.content,s={"og:title":i("og:title"),"og:description":i("og:description"),"og:image":i("og:image"),"og:url":i("og:url"),"twitter:title":i("twitter:title"),"twitter:description":i("twitter:description"),"twitter:image":i("twitter:image"),"twitter:url":i("twitter:url")},l=(c,d)=>{let f=document.querySelector(`meta[property="${c}"]`);f||(f=document.createElement("meta"),f.setAttribute("property",c),document.head.appendChild(f)),f.content=d};document.title=e,l("og:title",e),l("twitter:title",e);{l("og:description",t),l("twitter:description",t);const c=document.querySelector('meta[name="description"]');c&&(c.content=t)}{const c=n.startsWith("http")?n:`${Wn}${n}`;l("og:image",c),l("twitter:image",c)}{const c=o.startsWith("http")?o:`${Wn}${o}`;l("og:url",c),l("twitter:url",c)}return()=>{document.title=r,Object.entries(s).forEach(([c,d])=>{if(d){const f=document.querySelector(`meta[property="${c}"]`);f&&(f.content=d)}})}},[e,t,n,o])}function ys(){const{actions:e}=le(),t=Bn(),n=hs();return a.jsxs("div",{className:"relative group",children:[a.jsx("button",{className:"p-2 rounded-lg hover:bg-zinc-100 dark:hover:bg-zinc-800 text-zinc-600 dark:text-zinc-400 transition-colors",title:"Change template",children:a.jsx(Yi,{className:"w-4 h-4"})}),a.jsx("div",{className:"absolute left-0 top-full mt-1 opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all z-50",children:a.jsxs("div",{className:"bg-white dark:bg-zinc-900 rounded-lg shadow-lg border border-zinc-200 dark:border-zinc-800 py-1 min-w-[180px]",children:[a.jsx("div",{className:"px-3 py-1.5 text-xs font-medium text-zinc-500 dark:text-zinc-500 uppercase tracking-wide",children:"Style Template"}),n.map(o=>a.jsxs("button",{onClick:()=>e.setTemplate(o.id),className:`
|
|
2
|
+
w-full px-3 py-2 text-left text-sm transition-colors
|
|
3
|
+
${t===o.id?"bg-blue-50 dark:bg-blue-900/30 text-blue-600 dark:text-blue-400":"hover:bg-zinc-100 dark:hover:bg-zinc-800 text-zinc-700 dark:text-zinc-300"}
|
|
4
|
+
`,children:[a.jsx("div",{className:"font-medium",children:o.name}),a.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-500 mt-0.5",children:o.description})]},o.id))]})})]})}function st({icon:e,label:t,onClick:n}){return a.jsx("button",{onClick:n,title:t,className:"p-2 rounded-lg text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-800 transition-colors",children:a.jsx(e,{className:"w-4 h-4"})})}function ms({onNew:e,onOpen:t,onSave:n,onShare:o,isDark:r,onToggleTheme:i}){const s=Hn();return a.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-white dark:bg-zinc-900 border-b border-zinc-200 dark:border-zinc-800",children:[a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(st,{icon:mi,label:"New diagram",onClick:e}),a.jsx(st,{icon:xi,label:"Open diagram",onClick:t}),a.jsx(st,{icon:Gi,label:"Save diagram",onClick:n}),a.jsx("div",{className:"w-px h-5 bg-zinc-200 dark:bg-zinc-700 mx-1"}),a.jsx(ys,{})]}),a.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.filename&&a.jsx("span",{className:"font-medium text-zinc-700 dark:text-zinc-300 truncate max-w-[200px]",children:s.filename}),s.isDirty&&a.jsxs("span",{className:"flex items-center gap-1 text-xs text-zinc-500",children:[a.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-500"}),"Edited"]})]}),a.jsxs("div",{className:"flex items-center gap-1",children:[i&&a.jsx(st,{icon:r?Ri:Li,label:r?"Light mode":"Dark mode",onClick:i}),a.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-white bg-blue-500 hover:bg-blue-600 rounded-lg transition-colors",children:[a.jsx(qi,{className:"w-4 h-4"}),"Share"]})]})]})}function ve({icon:e,label:t,onClick:n,active:o=!1,disabled:r=!1}){return a.jsx("button",{onClick:n,disabled:r,title:t,className:`
|
|
5
|
+
p-2 rounded-lg transition-all
|
|
6
|
+
${o?"bg-blue-500 text-white shadow-sm":"text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-700"}
|
|
7
|
+
${r?"opacity-30 cursor-not-allowed":""}
|
|
8
|
+
`,children:a.jsx(e,{className:"w-4 h-4",strokeWidth:2})})}function at(){return a.jsx("div",{className:"w-px h-6 bg-zinc-200 dark:bg-zinc-600 mx-0.5"})}function xs(){const{actions:e}=le(),t=je(),n=ps(),o=ke(),r=n.past.length>0,i=n.future.length>0,s=t.selectedNodeIds?.length>0||t.selectedConnectorIndex!==null||t.selectedGroupId!==null||t.selectedImageId!==null,l=o.exportZone!==null,c=()=>{if(t.selectedNodeIds?.length>0)for(const f of t.selectedNodeIds)e.removeNode(f);else t.selectedConnectorIndex!==null?e.removeConnector(t.selectedConnectorIndex):t.selectedGroupId!==null?e.removeGroup(t.selectedGroupId):t.selectedImageId!==null&&e.removeImage(t.selectedImageId)},d=()=>{if(t.selectedNodeIds?.length>0){let u=1/0,h=1/0,p=-1/0,g=-1/0;for(const x of t.selectedNodeIds){const k=o.nodes[x];if(!k)continue;const y=q[k.size]||q.m,m=y.width,C=y.height;u=Math.min(u,k.x),h=Math.min(h,k.y),p=Math.max(p,k.x+m),g=Math.max(g,k.y+C)}u!==1/0&&e.setExportZone({x:Math.max(0,Math.round(u-40)),y:Math.max(0,Math.round(h-40)),width:Math.round(p-u+80),height:Math.round(g-h+80)})}else if(l)e.clearExportZone();else{const{width:f,height:u}=o.layout,h=Math.min(800,f*.8),p=Math.min(600,u*.8);e.setExportZone({x:Math.round((f-h)/2),y:Math.round((u-p)/2),width:Math.round(h),height:Math.round(p)})}e.setMode("select")};return a.jsx("div",{className:"absolute top-4 left-1/2 -translate-x-1/2 z-20",children:a.jsxs("div",{className:"flex items-center gap-0.5 px-2 py-1.5 bg-white dark:bg-zinc-800 rounded-xl shadow-lg border border-zinc-200 dark:border-zinc-700",children:[a.jsx(ve,{icon:Ti,label:"Select (V)",onClick:()=>e.setMode("select"),active:t.mode==="select"}),a.jsx(ve,{icon:Pi,label:"Pan (H / Space)",onClick:()=>e.setMode("pan"),active:t.mode==="pan"}),a.jsx(at,{}),a.jsx(ve,{icon:Sn,label:"Add node (N)",onClick:()=>e.setMode("addNode"),active:t.mode==="addNode"}),a.jsx(ve,{icon:Mi,label:"Add connector (C)",onClick:()=>e.setMode("addConnector"),active:t.mode==="addConnector"}),a.jsx(ve,{icon:In,label:"Rectangle group (R)",onClick:()=>e.setMode("addRect"),active:t.mode==="addRect"}),a.jsx(ve,{icon:zn,label:"Circle group (O)",onClick:()=>e.setMode("addCircle"),active:t.mode==="addCircle"}),a.jsx(at,{}),a.jsx(ve,{icon:fi,label:t.selectedNodeIds?.length>0?"Crop to selection":l?"Clear export zone":"Set export zone",onClick:d,active:l}),a.jsx(at,{}),a.jsx(ve,{icon:ts,label:"Undo (⌘Z)",onClick:e.undo,disabled:!r}),a.jsx(ve,{icon:Wi,label:"Redo (⌘⇧Z)",onClick:e.redo,disabled:!i}),a.jsx(at,{}),a.jsx(ve,{icon:Lt,label:"Delete",onClick:c,disabled:!s})]})})}const Un=30*(Math.PI/180),Xn=Math.cos(Un),jn=Math.sin(Un);function T(e,t,n=0){return{screenX:(e-t)*Xn,screenY:-(e+t)*jn-n}}function Yt(e,t){const n=e/Xn,o=-t/jn,r=(n+o)/2,i=(o-n)/2;return{x:r,y:i}}function Oe(e,t,n,o=0,r=0,i=0){const s={frontBottom:T(e,0,0),rightBottom:T(e,t,0),backBottom:T(0,t,0),leftBottom:T(0,0,0),frontTop:T(e,0,n),rightTop:T(e,t,n),backTop:T(0,t,n),leftTop:T(0,0,n)},l=z=>({x:z.screenX+o,y:z.screenY+r}),c=Object.fromEntries(Object.entries(s).map(([z,_])=>[z,l(_)])),d=(z,_,N,E)=>{if(E<=0){const B=T(0,0,N),W=T(z,0,N),G=T(z,_,N),P=T(0,_,N);return`M ${B.screenX+o},${B.screenY+r} L ${W.screenX+o},${W.screenY+r} L ${G.screenX+o},${G.screenY+r} L ${P.screenX+o},${P.screenY+r} Z`}const S=Math.min(z,_)/2,w=Math.min(E,S),M=8,$=[],A=(B,W,G,P)=>{for(let ne=0;ne<=M;ne++){const Q=G+(P-G)*(ne/M),ye=B+w*Math.cos(Q),R=W+w*Math.sin(Q),U=T(ye,R,N);$.push(`${U.screenX+o},${U.screenY+r}`)}};return A(w,w,Math.PI,Math.PI*1.5),A(z-w,w,Math.PI*1.5,Math.PI*2),A(z-w,_-w,0,Math.PI*.5),A(w,_-w,Math.PI*.5,Math.PI),`M ${$[0]} L ${$.slice(1).join(" L ")} Z`},f=z=>`M ${z.map(_=>`${_.x},${_.y}`).join(" L ")} Z`,u=(z,_,N,E,S,w)=>{const $=[];for(let G=0;G<6;G++){const P=S+(w-S)*(G/6),ne=S+(w-S)*((G+1)/6),Q=(P+ne)/2,ye=Math.cos(Q),R=Math.sin(Q),Z=ye*-.577+R*-.577+0*.577,H=.3+Math.max(0,Z+.4)*.5,Ae=T(z+N*Math.cos(P),_+N*Math.sin(P),0),X=T(z+N*Math.cos(ne),_+N*Math.sin(ne),0),xe=T(z+N*Math.cos(P),_+N*Math.sin(P),E),Xe=T(z+N*Math.cos(ne),_+N*Math.sin(ne),E),bn=`M ${Ae.screenX+o},${Ae.screenY+r} L ${X.screenX+o},${X.screenY+r} L ${Xe.screenX+o},${Xe.screenY+r} L ${xe.screenX+o},${xe.screenY+r} Z`;$.push({path:bn,intensity:H})}return $},h=Math.min(i,Math.min(e,t)/2),p=d(e,t,n,h);let g,x,k,y,m,C;if(h>0){const z=[{x:T(0,h,0).screenX+o,y:T(0,h,0).screenY+r},{x:T(0,t-h,0).screenX+o,y:T(0,t-h,0).screenY+r},{x:T(0,t-h,n).screenX+o,y:T(0,t-h,n).screenY+r},{x:T(0,h,n).screenX+o,y:T(0,h,n).screenY+r}];g=f(z);const _=[{x:T(h,0,0).screenX+o,y:T(h,0,0).screenY+r},{x:T(e-h,0,0).screenX+o,y:T(e-h,0,0).screenY+r},{x:T(e-h,0,n).screenX+o,y:T(e-h,0,n).screenY+r},{x:T(h,0,n).screenX+o,y:T(h,0,n).screenY+r}];x=f(_),k=u(h,h,h,n,Math.PI,Math.PI*1.5),y=u(e-h,h,h,n,Math.PI*1.5,Math.PI*2),m=u(h,t-h,h,n,Math.PI*.5,Math.PI),C=u(e-h,t-h,h,n,0,Math.PI*.5)}else{const z=[c.leftBottom,c.backBottom,c.backTop,c.leftTop],_=[c.leftBottom,c.frontBottom,c.frontTop,c.leftTop];g=f(z),x=f(_),k=[],y=[],m=[],C=[]}const v=`M ${c.leftBottom.x},${c.leftBottom.y} L ${c.frontBottom.x},${c.frontBottom.y} L ${c.rightBottom.x},${c.rightBottom.y} L ${c.backBottom.x},${c.backBottom.y} Z`;return{top:p,left:g,right:x,cornerFrontLeft:k,cornerFrontRight:y,cornerBackLeft:m,cornerBackRight:C,outline:v}}function Gn(e,t=60,n=50){return{top:`hsl(${e}, ${t}%, ${Math.min(n+15,95)}%)`,right:`hsl(${e}, ${t}%, ${n}%)`,left:`hsl(${e}, ${t}%, ${Math.max(n-15,15)}%)`}}const Ge={violet:{hue:270,saturation:60,lightness:55},blue:{hue:220,saturation:70,lightness:50},cyan:{hue:190,saturation:80,lightness:45},emerald:{hue:155,saturation:65,lightness:45},amber:{hue:40,saturation:90,lightness:50},rose:{hue:350,saturation:70,lightness:55},slate:{hue:220,saturation:15,lightness:50},zinc:{hue:240,saturation:5,lightness:50}};function Vn(e){const t=Ge[e]||Ge.slate;return Gn(t.hue,t.saturation,t.lightness)}function bs(e,t,n,o=0,r=0){const i=[T(0,0,0),T(e,0,0),T(0,t,0),T(e,t,0),T(0,0,n),T(e,0,n),T(0,t,n),T(e,t,n)],s=i.map(h=>h.screenX+o),l=i.map(h=>h.screenY+r),c=Math.min(...s),d=Math.max(...s),f=Math.min(...l),u=Math.max(...l);return{minX:c,minY:f,maxX:d,maxY:u,width:d-c,height:u-f}}const Ht=.1,Bt=4,Kn=1.15;function ks(e={}){const{initialZoom:t=1,initialPan:n={x:0,y:0},panModeActive:o=!1,onTransformChange:r}=e,[i,s]=b.useState({zoom:t,pan:n,isPanning:!1}),l=b.useRef(null),c=b.useRef(!1),d=b.useRef({x:0,y:0}),f=b.useRef(!1),u=b.useCallback((w,M)=>{s($=>{const A=Math.min(Bt,Math.max(Ht,w));if(M&&l.current){const B=l.current.getBoundingClientRect(),W=M.x-B.left,G=M.y-B.top,P=(W-$.pan.x)/$.zoom,ne=(G-$.pan.y)/$.zoom,Q=W-P*A,ye=G-ne*A;return{...$,zoom:A,pan:{x:Q,y:ye}}}return{...$,zoom:A}})},[]),h=b.useCallback(w=>{s(M=>({...M,pan:w}))},[]),p=b.useCallback(w=>{s(M=>{const $=Math.min(Bt,M.zoom*Kn);if(w&&l.current){const A=l.current.getBoundingClientRect(),B=w.x-A.left,W=w.y-A.top,G=(B-M.pan.x)/M.zoom,P=(W-M.pan.y)/M.zoom;return{...M,zoom:$,pan:{x:B-G*$,y:W-P*$}}}return{...M,zoom:$}})},[]),g=b.useCallback(w=>{s(M=>{const $=Math.max(Ht,M.zoom/Kn);if(w&&l.current){const A=l.current.getBoundingClientRect(),B=w.x-A.left,W=w.y-A.top,G=(B-M.pan.x)/M.zoom,P=(W-M.pan.y)/M.zoom;return{...M,zoom:$,pan:{x:B-G*$,y:W-P*$}}}return{...M,zoom:$}})},[]),x=b.useCallback(()=>{s({zoom:1,pan:{x:0,y:0},isPanning:!1})},[]),k=b.useCallback((w,M=40)=>{if(!l.current)return;const $=l.current.getBoundingClientRect(),A=($.width-M*2)/w.width,B=($.height-M*2)/w.height,W=Math.min(A,B,1),G=($.width-w.width*W)/2,P=($.height-w.height*W)/2;s({zoom:W,pan:{x:G,y:P},isPanning:!1})},[]),y=b.useCallback(w=>{if(w.preventDefault(),w.ctrlKey||w.metaKey){const $=-w.deltaY*.01,A=i.zoom*(1+$);u(A,{x:w.clientX,y:w.clientY})}else s($=>({...$,pan:{x:$.pan.x-w.deltaX,y:$.pan.y-w.deltaY}}))},[i.zoom,u]),m=b.useCallback(w=>{(w.button===1||w.button===0&&f.current||w.button===0&&o)&&(w.preventDefault(),c.current=!0,d.current={x:w.clientX,y:w.clientY},s($=>({...$,isPanning:!0})),w.target.setPointerCapture(w.pointerId))},[o]),C=b.useCallback(w=>{if(!c.current)return;const M=w.clientX-d.current.x,$=w.clientY-d.current.y;d.current={x:w.clientX,y:w.clientY},s(A=>({...A,pan:{x:A.pan.x+M,y:A.pan.y+$}}))},[]),v=b.useCallback(()=>{c.current=!1,s(w=>({...w,isPanning:!1}))},[]),z=b.useCallback(w=>{w.code==="Space"&&!w.repeat&&(f.current=!0)},[]),_=b.useCallback(w=>{w.code==="Space"&&(f.current=!1)},[]);b.useEffect(()=>{const w=l.current;if(w)return w.addEventListener("wheel",y,{passive:!1}),w.addEventListener("pointerdown",m),w.addEventListener("pointermove",C),w.addEventListener("pointerup",v),w.addEventListener("pointerleave",v),window.addEventListener("keydown",z),window.addEventListener("keyup",_),()=>{w.removeEventListener("wheel",y),w.removeEventListener("pointerdown",m),w.removeEventListener("pointermove",C),w.removeEventListener("pointerup",v),w.removeEventListener("pointerleave",v),window.removeEventListener("keydown",z),window.removeEventListener("keyup",_)}},[y,m,C,v,z,_]),b.useEffect(()=>{r?.({zoom:i.zoom,pan:i.pan})},[i.zoom,i.pan,r]);const N=b.useCallback(w=>{if(!l.current)return w;const M=l.current.getBoundingClientRect();return{x:(w.x-M.left-i.pan.x)/i.zoom,y:(w.y-M.top-i.pan.y)/i.zoom}},[i.zoom,i.pan]),E=b.useCallback(w=>{if(!l.current)return w;const M=l.current.getBoundingClientRect();return{x:w.x*i.zoom+i.pan.x+M.left,y:w.y*i.zoom+i.pan.y+M.top}},[i.zoom,i.pan]),S={transform:`translate(${i.pan.x}px, ${i.pan.y}px) scale(${i.zoom})`,transformOrigin:"0 0",transition:i.isPanning?"none":"transform 0.1s ease-out"};return{containerRef:l,zoom:i.zoom,pan:i.pan,isPanning:i.isPanning,setZoom:u,setPan:h,zoomIn:p,zoomOut:g,resetTransform:x,fitToView:k,screenToCanvas:N,canvasToScreen:E,transformStyle:S}}const vs={left:{violet:"border-l-4 border-l-violet-500",emerald:"border-l-4 border-l-emerald-500",blue:"border-l-4 border-l-blue-500",amber:"border-l-4 border-l-amber-500",zinc:"border-l-4 border-l-zinc-500",sky:"border-l-4 border-l-sky-500"},top:{violet:"border-t-3 border-t-violet-500",emerald:"border-t-3 border-t-emerald-500",blue:"border-t-3 border-t-blue-500",amber:"border-t-3 border-t-amber-500",zinc:"border-t-3 border-t-zinc-500",sky:"border-t-3 border-t-sky-500"},none:{violet:"",emerald:"",blue:"",amber:"",zinc:"",sky:""}},ws={colored:{violet:"border-violet-500/50",emerald:"border-emerald-500/50",blue:"border-blue-500/50",amber:"border-amber-500/50",zinc:"border-zinc-600",sky:"border-sky-500/50"},muted:{violet:"border-zinc-600",emerald:"border-zinc-600",blue:"border-zinc-600",amber:"border-zinc-600",zinc:"border-zinc-600",sky:"border-zinc-600"},none:{violet:"border-transparent",emerald:"border-transparent",blue:"border-transparent",amber:"border-transparent",zinc:"border-transparent",sky:"border-transparent"}},Cs={violet:"text-violet-400",emerald:"text-emerald-400",blue:"text-blue-400",amber:"text-amber-400",zinc:"text-zinc-400",sky:"text-sky-400"},Ns={colored:{violet:"text-violet-400",emerald:"text-emerald-400",blue:"text-blue-400",amber:"text-amber-400",zinc:"text-zinc-500",sky:"text-sky-400"},muted:{violet:"text-zinc-500",emerald:"text-zinc-500",blue:"text-zinc-500",amber:"text-zinc-500",zinc:"text-zinc-500",sky:"text-zinc-500"}};function zs({nodeId:e,node:t,data:n,layout:o,template:r,isSelected:i,onPointerDown:s,onClick:l,onMouseEnter:c,onMouseLeave:d}){const f=On(n.icon),u=t.size||"m",h=n.color||"violet",p=q[u]||q.m,g=t.width||p.width,x=t.height||p.height,k=u==="l",y=u==="s"||u==="xs",m=u==="xs",C=t.x/o.width*100,v=t.y/o.height*100,z=g/o.width*100,_=x/o.height*100,N=r?.node||{},E=N.accentPosition||"left",S=vs[E]?.[h]||"",w=N.iconBorderStyle||"colored",M=ws[w]?.[h]||"",$=N.subtitleStyle||"colored",A=Ns[$]?.[h]||"text-zinc-500",B=r?.canvas?.background?.includes("white")?"ring-offset-white":"ring-offset-zinc-950";return a.jsx("div",{className:"absolute cursor-move select-none pointer-events-auto",style:{left:`${C}%`,top:`${v}%`,width:`${z}%`,height:`${_}%`},onMouseEnter:c,onMouseLeave:d,onPointerDown:W=>s(W,e),onClick:W=>{W.stopPropagation(),l(e,W)},children:a.jsxs("div",{className:`
|
|
9
|
+
relative h-full
|
|
10
|
+
${N.background||"bg-zinc-900"}
|
|
11
|
+
border ${N.border||"border-zinc-800"}
|
|
12
|
+
${N.borderRadius||"rounded-xl"}
|
|
13
|
+
${S}
|
|
14
|
+
${k?"px-5 py-4":y?"px-3 py-2.5":"px-4 py-3"}
|
|
15
|
+
transition-all duration-150
|
|
16
|
+
${i?`ring-2 ring-blue-500 ring-offset-2 ${B}`:""}
|
|
17
|
+
`,children:[a.jsxs("div",{className:"flex items-start gap-3",children:[a.jsx("div",{className:`
|
|
18
|
+
flex-shrink-0 rounded-lg
|
|
19
|
+
${k?"w-12 h-12":y?"w-8 h-8":"w-10 h-10"}
|
|
20
|
+
flex items-center justify-center
|
|
21
|
+
${N.iconBackground||"bg-zinc-900"}
|
|
22
|
+
border ${M}
|
|
23
|
+
`,children:a.jsx(f,{className:`${k?"w-6 h-6":y?"w-4 h-4":"w-5 h-5"} ${Cs[h]}`})}),a.jsxs("div",{className:"min-w-0 flex-1 pt-0.5",children:[a.jsx("div",{className:`font-semibold ${N.textColor||"text-white"} ${k?"text-base":y?"text-xs":"text-sm"}`,children:n.name}),n.subtitle&&a.jsx("div",{className:`font-mono ${A} ${m?"text-[8px]":y?"text-[9px]":"text-[11px]"}`,children:n.subtitle})]})]}),n.description&&!y&&!m&&a.jsx("div",{className:`mt-2 ${N.descriptionColor||"text-zinc-500"} ${k?"text-xs":"text-[11px]"}`,children:n.description})]})})}const Le={emerald:"#34d399",amber:"#fbbf24",zinc:"#71717a",sky:"#38bdf8",violet:"#a78bfa",blue:"#60a5fa"};function Ms({id:e,color:t}){return a.jsx("marker",{id:e,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto",markerUnits:"userSpaceOnUse",children:a.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:Le[t]})})}function _s({id:e,color:t}){return a.jsx("marker",{id:e,markerWidth:"8",markerHeight:"6",refX:"1",refY:"3",orient:"auto",markerUnits:"userSpaceOnUse",children:a.jsx("polygon",{points:"8 0, 0 3, 8 6",fill:Le[t]})})}function $s(){return{dx:0,dy:0}}function qn({x:e,y:t,color:n,size:o=4}){const r=$s();return a.jsx("circle",{cx:e+r.dx,cy:t+r.dy,r:o,fill:Le[n]||Le.zinc,className:"pointer-events-none"})}function lt(e,t){const n=Math.abs(t)*.5;switch(e){case"top":return{dx:0,dy:-n};case"bottom":return{dx:0,dy:n};case"left":return{dx:-n,dy:0};case"right":return{dx:n,dy:0};case"bottomRight":return{dx:n*.7,dy:n*.7};case"bottomLeft":return{dx:-n*.7,dy:n*.7};default:return{dx:0,dy:0}}}function Ss(e,t,n,o,r,i=50){const s=t.x-e.x,l=t.y-e.y,c=Math.sqrt(s*s+l*l);if(r==="natural"||r==="down"||r==="up"){const x=lt(n,c),k=lt(o,c),y=i/50,m=e.x+x.dx*y,C=e.y+x.dy*y,v=t.x+k.dx*y,z=t.y+k.dy*y;return`M ${e.x} ${e.y} C ${m} ${C}, ${v} ${z}, ${t.x} ${t.y}`}if(n==="right"&&o==="left"||n==="left"&&o==="right"){const x=(e.x+t.x)/2;return`M ${e.x} ${e.y} C ${x} ${e.y}, ${x} ${t.y}, ${t.x} ${t.y}`}if(n==="bottom"&&o==="top"||n==="top"&&o==="bottom"){const x=(e.y+t.y)/2;return`M ${e.x} ${e.y} C ${e.x} ${x}, ${t.x} ${x}, ${t.x} ${t.y}`}const d=lt(n,c),f=lt(o,c),u=e.x+d.dx,h=e.y+d.dy,p=t.x+f.dx,g=t.y+f.dy;return`M ${e.x} ${e.y} C ${u} ${h}, ${p} ${g}, ${t.x} ${t.y}`}function As({connector:e,nodes:t,connectorStyles:n,isSelected:o,onClick:r,index:i}){const s=n[e.style];if(!s)return null;const l=Dt(t,e.from,e.fromAnchor),c=Dt(t,e.to,e.toAnchor),d=Ko(l,c),f=e.curveDepth??40,u=Ss(l,c,e.fromAnchor,e.toAnchor,e.curve,f),h=Le[s.color]||Le.zinc,p=s.showArrow!==!1,g=s.showEndpoints!==!1,x=s.bidirectional===!0,k=s.animated!==!1&&s.dashed,y=e.fromAnchor==="bottom"||e.fromAnchor==="top";let m,C,v;e.curve==="down"?(m=d.x,C=Math.max(l.y,c.y)+60,v="middle"):y?(m=l.x+12,C=d.y,v="start"):(m=d.x,C=Math.min(l.y,c.y)-8,v="middle");const z=s.dashed?"8 4":void 0;let _,N;p&&(x?(_=`url(#arrow-start-${s.color})`,N=`url(#arrow-${s.color})`):N=`url(#arrow-${s.color})`);const E=k?x?"animate-dash-bidirectional":"animate-dash-forward":"";return a.jsxs("g",{className:"cursor-pointer",onClick:S=>{S.stopPropagation(),r(i)},children:[a.jsx("path",{d:u,fill:"none",stroke:"transparent",strokeWidth:20}),o&&a.jsx("path",{d:u,fill:"none",stroke:"#3b82f6",strokeWidth:s.strokeWidth+6,strokeOpacity:.3,strokeDasharray:z}),a.jsx("path",{d:u,fill:"none",stroke:h,strokeWidth:s.strokeWidth,strokeDasharray:z,markerStart:_,markerEnd:N,strokeLinecap:"round",strokeLinejoin:"round",className:E}),g&&a.jsxs(a.Fragment,{children:[a.jsx(qn,{x:l.x,y:l.y,color:s.color,size:4}),a.jsx(qn,{x:c.x,y:c.y,color:s.color,size:4})]}),s.label&&s.label.length>0&&!e.curve&&a.jsx("text",{x:m,y:C,textAnchor:v,fill:h,fontSize:"11",fontFamily:"ui-monospace, monospace",fontWeight:"500",children:s.label})]})}function Is({layout:e,nodes:t,connectors:n,connectorStyles:o,selectedConnectorIndex:r,onConnectorClick:i}){const s=[...new Set(n.map(l=>o[l.style]?.color).filter(Boolean))];return a.jsxs(a.Fragment,{children:[a.jsx("style",{children:`
|
|
24
|
+
@keyframes dash-forward {
|
|
25
|
+
0% {
|
|
26
|
+
stroke-dashoffset: 0;
|
|
27
|
+
}
|
|
28
|
+
100% {
|
|
29
|
+
stroke-dashoffset: 12;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@keyframes dash-bidirectional {
|
|
34
|
+
0% {
|
|
35
|
+
stroke-dashoffset: 0;
|
|
36
|
+
}
|
|
37
|
+
50% {
|
|
38
|
+
stroke-dashoffset: 12;
|
|
39
|
+
}
|
|
40
|
+
100% {
|
|
41
|
+
stroke-dashoffset: 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.animate-dash-forward {
|
|
46
|
+
animation: dash-forward 2s linear infinite;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.animate-dash-bidirectional {
|
|
50
|
+
animation: dash-bidirectional 2s linear infinite;
|
|
51
|
+
}
|
|
52
|
+
`}),a.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",children:[a.jsx("defs",{children:s.map(l=>a.jsxs(b.Fragment,{children:[a.jsx(Ms,{id:`arrow-${l}`,color:l}),a.jsx(_s,{id:`arrow-start-${l}`,color:l})]},l))}),a.jsx("g",{className:"pointer-events-auto",children:n.map((l,c)=>a.jsx(As,{index:c,connector:l,nodes:t,connectorStyles:o,isSelected:r===c,onClick:i},c))})]})]})}function Es({layout:e,nodes:t,visibleNodeId:n,onAnchorClick:o,pendingConnector:r}){if(!n)return null;const i=["top","right","bottom","left"];return a.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",children:a.jsx("g",{className:"pointer-events-auto",children:i.map(s=>{const l=Dt(t,n,s),c=r?.from===n&&r?.fromAnchor===s;return a.jsxs("g",{children:[a.jsx("circle",{cx:l.x,cy:l.y,r:12,fill:"transparent",className:"cursor-pointer",onClick:d=>{d.stopPropagation(),o(n,s)}}),a.jsx("circle",{cx:l.x,cy:l.y,r:c?7:5,className:`
|
|
53
|
+
${c?"fill-blue-500":"fill-blue-400 hover:fill-blue-500"}
|
|
54
|
+
transition-all duration-150
|
|
55
|
+
`,style:{pointerEvents:"none"}}),a.jsx("circle",{cx:l.x,cy:l.y,r:2,className:"fill-white",style:{pointerEvents:"none"}})]},s)})})})}const Zn={violet:{fill:"rgba(139, 92, 246, 0.1)",stroke:"rgba(139, 92, 246, 0.5)"},emerald:{fill:"rgba(52, 211, 153, 0.1)",stroke:"rgba(52, 211, 153, 0.5)"},blue:{fill:"rgba(96, 165, 250, 0.1)",stroke:"rgba(96, 165, 250, 0.5)"},amber:{fill:"rgba(251, 191, 36, 0.1)",stroke:"rgba(251, 191, 36, 0.5)"},zinc:{fill:"rgba(113, 113, 122, 0.1)",stroke:"rgba(113, 113, 122, 0.5)"},sky:{fill:"rgba(56, 189, 248, 0.1)",stroke:"rgba(56, 189, 248, 0.5)"}};function Ds({group:e,isSelected:t,onClick:n,onDragStart:o,onResize:r}){const i=Zn[e.color]||Zn.zinc,{x:s,y:l,width:c,height:d,type:f,label:u}=e,h=g=>{g.stopPropagation(),n(e.id),o(e.id,g)},p=(g,x)=>{g.stopPropagation(),r(e.id,x,g)};return a.jsxs("g",{className:"cursor-move",children:[f==="circle"?a.jsx("ellipse",{cx:s+c/2,cy:l+d/2,rx:c/2,ry:d/2,fill:i.fill,stroke:t?"#3b82f6":i.stroke,strokeWidth:t?2:1.5,strokeDasharray:e.dashed?"8 4":void 0,onMouseDown:h}):a.jsx("rect",{x:s,y:l,width:c,height:d,rx:12,ry:12,fill:i.fill,stroke:t?"#3b82f6":i.stroke,strokeWidth:t?2:1.5,strokeDasharray:e.dashed?"8 4":void 0,onMouseDown:h}),u&&a.jsx("text",{x:s+12,y:l+20,fill:i.stroke,fontSize:"12",fontWeight:"500",fontFamily:"ui-sans-serif, system-ui, sans-serif",style:{pointerEvents:"none"},children:u}),t&&a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:s,cy:l,r:5,fill:"#3b82f6",className:"cursor-nwse-resize",onMouseDown:g=>p(g,"nw")}),a.jsx("circle",{cx:s+c,cy:l,r:5,fill:"#3b82f6",className:"cursor-nesw-resize",onMouseDown:g=>p(g,"ne")}),a.jsx("circle",{cx:s,cy:l+d,r:5,fill:"#3b82f6",className:"cursor-nesw-resize",onMouseDown:g=>p(g,"sw")}),a.jsx("circle",{cx:s+c,cy:l+d,r:5,fill:"#3b82f6",className:"cursor-nwse-resize",onMouseDown:g=>p(g,"se")})]})]})}function Os({layout:e,groups:t,selectedGroupId:n,onGroupClick:o,onGroupUpdate:r,screenToCanvas:i}){const[s,l]=b.useState(null),c=b.useCallback((h,p)=>{const g=t.find(k=>k.id===h);if(!g)return;const x=i({x:p.clientX,y:p.clientY});l({groupId:h,type:"move",startX:x.x,startY:x.y,originalX:g.x,originalY:g.y})},[t,i]),d=b.useCallback((h,p,g)=>{const x=t.find(y=>y.id===h);if(!x)return;const k=i({x:g.clientX,y:g.clientY});l({groupId:h,type:"resize",corner:p,startX:k.x,startY:k.y,originalX:x.x,originalY:x.y,originalWidth:x.width,originalHeight:x.height})},[t,i]),f=b.useCallback(h=>{if(!s)return;const p=i({x:h.clientX,y:h.clientY}),g=p.x-s.startX,x=p.y-s.startY;if(s.type==="move")r(s.groupId,{x:Math.round(s.originalX+g),y:Math.round(s.originalY+x)});else if(s.type==="resize"){let k=s.originalX,y=s.originalY,m=s.originalWidth,C=s.originalHeight;s.corner.includes("w")&&(k=s.originalX+g,m=s.originalWidth-g),s.corner.includes("e")&&(m=s.originalWidth+g),s.corner.includes("n")&&(y=s.originalY+x,C=s.originalHeight-x),s.corner.includes("s")&&(C=s.originalHeight+x),m>=40&&C>=40&&r(s.groupId,{x:Math.round(k),y:Math.round(y),width:Math.round(m),height:Math.round(C)})}},[s,i,r]),u=b.useCallback(()=>{l(null)},[]);return!t||t.length===0?null:a.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",onMouseMove:s?f:void 0,onMouseUp:s?u:void 0,onMouseLeave:s?u:void 0,style:{pointerEvents:s?"auto":"none"},children:a.jsx("g",{className:"pointer-events-auto",children:t.map(h=>a.jsx(Ds,{group:h,isSelected:n===h.id,onClick:o,onDragStart:c,onResize:d},h.id))})})}function Ls({image:e,isSelected:t,onClick:n,onDragStart:o,onResize:r}){const{x:i,y:s,width:l,height:c,src:d,opacity:f=1}=e,u=p=>{p.stopPropagation(),n(e.id),o(e.id,p)},h=(p,g)=>{p.stopPropagation(),r(e.id,g,p)};return a.jsxs("g",{className:"cursor-move",children:[a.jsx("image",{href:d,x:i,y:s,width:l,height:c,preserveAspectRatio:"xMidYMid meet",onMouseDown:u,style:{cursor:"move",opacity:f}}),t&&a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:i,y:s,width:l,height:c,fill:"none",stroke:"#3b82f6",strokeWidth:2,strokeDasharray:"4 2",style:{pointerEvents:"none"}}),a.jsx("circle",{cx:i,cy:s,r:5,fill:"#3b82f6",className:"cursor-nwse-resize",onMouseDown:p=>h(p,"nw")}),a.jsx("circle",{cx:i+l,cy:s,r:5,fill:"#3b82f6",className:"cursor-nesw-resize",onMouseDown:p=>h(p,"ne")}),a.jsx("circle",{cx:i,cy:s+c,r:5,fill:"#3b82f6",className:"cursor-nesw-resize",onMouseDown:p=>h(p,"sw")}),a.jsx("circle",{cx:i+l,cy:s+c,r:5,fill:"#3b82f6",className:"cursor-nwse-resize",onMouseDown:p=>h(p,"se")})]})]})}function Ts({layout:e,images:t,selectedImageId:n,onImageClick:o,onImageUpdate:r,screenToCanvas:i}){const[s,l]=b.useState(null),c=b.useCallback((h,p)=>{const g=t.find(k=>k.id===h);if(!g)return;const x=i({x:p.clientX,y:p.clientY});l({imageId:h,type:"move",startX:x.x,startY:x.y,originalX:g.x,originalY:g.y})},[t,i]),d=b.useCallback((h,p,g)=>{const x=t.find(y=>y.id===h);if(!x)return;const k=i({x:g.clientX,y:g.clientY});l({imageId:h,type:"resize",corner:p,startX:k.x,startY:k.y,originalX:x.x,originalY:x.y,originalWidth:x.width,originalHeight:x.height,aspectRatio:x.width/x.height})},[t,i]),f=b.useCallback(h=>{if(!s)return;const p=i({x:h.clientX,y:h.clientY}),g=p.x-s.startX,x=p.y-s.startY;if(s.type==="move")r(s.imageId,{x:Math.round(s.originalX+g),y:Math.round(s.originalY+x)});else if(s.type==="resize"){let k=s.originalX,y=s.originalY,m=s.originalWidth,C=s.originalHeight;const v=!h.shiftKey;if(s.corner.includes("e")&&(m=s.originalWidth+g),s.corner.includes("w")&&(k=s.originalX+g,m=s.originalWidth-g),s.corner.includes("s")&&(C=s.originalHeight+x),s.corner.includes("n")&&(y=s.originalY+x,C=s.originalHeight-x),v&&s.aspectRatio){if(s.corner==="se"||s.corner==="nw"){const z=Math.abs(m-s.originalWidth),_=Math.abs(C-s.originalHeight);z>_?C=m/s.aspectRatio:m=C*s.aspectRatio}else if(s.corner==="sw"||s.corner==="ne"){const z=Math.abs(m-s.originalWidth),_=Math.abs(C-s.originalHeight);z>_?C=m/s.aspectRatio:m=C*s.aspectRatio}}m>=20&&C>=20&&r(s.imageId,{x:Math.round(k),y:Math.round(y),width:Math.round(m),height:Math.round(C)})}},[s,i,r]),u=b.useCallback(()=>{l(null)},[]);return!t||t.length===0?null:a.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",onMouseMove:s?f:void 0,onMouseUp:s?u:void 0,onMouseLeave:s?u:void 0,style:{pointerEvents:s?"auto":"none"},children:a.jsx("g",{className:"pointer-events-auto",children:t.map(h=>a.jsx(Ls,{image:h,isSelected:n===h.id,onClick:o,onDragStart:c,onResize:d},h.id))})})}const ct={violet:"#8b5cf6",emerald:"#34d399",blue:"#60a5fa",amber:"#fbbf24",zinc:"#71717a",sky:"#38bdf8"};function Ps({diagram:e,viewportBounds:t,onViewportChange:n,width:o=160,height:r=100}){const i=b.useRef(null),s=e.layout,l=o/s.width,c=r/s.height,d=Math.min(l,c),f=s.width*d,u=s.height*d,h=(t?.x||0)*d,p=(t?.y||0)*d,g=(t?.width||s.width)*d,x=(t?.height||s.height)*d,k=b.useCallback(y=>{if(!i.current||!n)return;const m=i.current.getBoundingClientRect(),C=y.clientX-m.left,v=y.clientY-m.top,z=C/d,_=v/d;n({x:z-(t?.width||s.width)/2,y:_-(t?.height||s.height)/2})},[d,n,t,s]);return a.jsx("div",{ref:i,className:"absolute bottom-4 left-4 bg-white dark:bg-zinc-900 rounded-lg shadow-lg border border-zinc-200 dark:border-zinc-700 overflow-hidden cursor-pointer",style:{width:f+8,height:u+8,padding:4},onClick:k,children:a.jsxs("svg",{width:f,height:u,viewBox:`0 0 ${s.width} ${s.height}`,className:"bg-zinc-50 dark:bg-zinc-800 rounded",children:[(e.groups||[]).map(y=>a.jsx("rect",{x:y.x,y:y.y,width:y.width,height:y.height,fill:ct[y.color]||ct.zinc,opacity:.2,rx:4},y.id)),(e.images||[]).map(y=>a.jsx("rect",{x:y.x,y:y.y,width:y.width,height:y.height,fill:"#9ca3af",opacity:.3},y.id)),e.connectors.map((y,m)=>{const C=e.nodes[y.from],v=e.nodes[y.to];if(!C||!v)return null;const z=C.x+50,_=C.y+25,N=v.x+50,E=v.y+25;return a.jsx("line",{x1:z,y1:_,x2:N,y2:E,stroke:"#9ca3af",strokeWidth:2/d,opacity:.5},m)}),Object.entries(e.nodes).map(([y,m])=>{const C=e.nodeData[y];if(!C)return null;const v=ct[C.color]||ct.zinc,z=m.size||"m",_=z==="l"?210:z==="s"?95:z==="xs"?80:145,N=z==="l"?85:z==="s"?42:z==="xs"?36:68;return a.jsx("rect",{x:m.x,y:m.y,width:m.width||_,height:m.height||N,fill:v,rx:4},y)}),a.jsx("rect",{x:h/d,y:p/d,width:g/d,height:x/d,fill:"none",stroke:"#3b82f6",strokeWidth:2/d,strokeDasharray:`${4/d} ${2/d}`})]})})}function Fs({layout:e,exportZone:t,isEditing:n,onZoneUpdate:o,onZoneClear:r,screenToCanvas:i}){const[s,l]=b.useState(null),c=b.useRef(null),d=b.useCallback((y,m)=>{if(!t||!n)return;m.stopPropagation(),m.target.setPointerCapture(m.pointerId);const C=i({x:m.clientX,y:m.clientY});l({type:"resize",corner:y,startX:C.x,startY:C.y,originalX:t.x,originalY:t.y,originalWidth:t.width,originalHeight:t.height})},[t,n,i]),f=b.useCallback(y=>{if(!t||!n)return;y.stopPropagation(),y.target.setPointerCapture(y.pointerId);const m=i({x:y.clientX,y:y.clientY});l({type:"move",startX:m.x,startY:m.y,originalX:t.x,originalY:t.y})},[t,n,i]),u=b.useCallback(y=>{if(!s||!t)return;const m=i({x:y.clientX,y:y.clientY}),C=m.x-s.startX,v=m.y-s.startY;if(s.type==="move")o({...t,x:Math.max(0,Math.round(s.originalX+C)),y:Math.max(0,Math.round(s.originalY+v))});else if(s.type==="resize"){let z=s.originalX,_=s.originalY,N=s.originalWidth,E=s.originalHeight;s.corner.includes("w")&&(z=s.originalX+C,N=s.originalWidth-C),s.corner.includes("e")&&(N=s.originalWidth+C),s.corner.includes("n")&&(_=s.originalY+v,E=s.originalHeight-v),s.corner.includes("s")&&(E=s.originalHeight+v),N>=50&&E>=50&&o({x:Math.max(0,Math.round(z)),y:Math.max(0,Math.round(_)),width:Math.round(N),height:Math.round(E)})}},[s,t,i,o]),h=b.useCallback(y=>{y.target.releasePointerCapture&&y.target.releasePointerCapture(y.pointerId),l(null)},[]);if(!t)return null;const{x:p,y:g,width:x,height:k}=t;return a.jsxs("svg",{ref:c,className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${e.width} ${e.height}`,preserveAspectRatio:"none",style:{pointerEvents:"none"},children:[a.jsx("defs",{children:a.jsxs("mask",{id:"exportZoneMask",children:[a.jsx("rect",{x:0,y:0,width:e.width,height:e.height,fill:"white"}),a.jsx("rect",{x:p,y:g,width:x,height:k,fill:"black"})]})}),a.jsx("rect",{x:0,y:0,width:e.width,height:e.height,fill:"rgba(0,0,0,0.3)",mask:"url(#exportZoneMask)",style:{pointerEvents:"none"}}),n&&a.jsx("rect",{x:p,y:g,width:x,height:k,fill:"transparent",style:{pointerEvents:"auto",cursor:"move"},onPointerDown:f,onPointerMove:u,onPointerUp:h}),a.jsx("rect",{x:p,y:g,width:x,height:k,fill:"none",stroke:"#10b981",strokeWidth:2,strokeDasharray:"8 4",style:{pointerEvents:"none"}}),a.jsxs("text",{x:p+8,y:g-8,fill:"#10b981",fontSize:"12",fontWeight:"600",fontFamily:"ui-sans-serif, system-ui, sans-serif",style:{pointerEvents:"none"},children:["Export Zone (",x," x ",k,")"]}),n&&a.jsx("g",{children:[{cx:p,cy:g,cursor:"nwse-resize",corner:"nw"},{cx:p+x,cy:g,cursor:"nesw-resize",corner:"ne"},{cx:p,cy:g+k,cursor:"nesw-resize",corner:"sw"},{cx:p+x,cy:g+k,cursor:"nwse-resize",corner:"se"},{cx:p+x/2,cy:g,cursor:"ns-resize",corner:"n",r:5},{cx:p+x/2,cy:g+k,cursor:"ns-resize",corner:"s",r:5},{cx:p,cy:g+k/2,cursor:"ew-resize",corner:"w",r:5},{cx:p+x,cy:g+k/2,cursor:"ew-resize",corner:"e",r:5}].map(({cx:y,cy:m,cursor:C,corner:v,r:z=6})=>a.jsx("circle",{cx:y,cy:m,r:z,fill:"#10b981",style:{pointerEvents:"auto",cursor:C},onPointerDown:_=>d(v,_),onPointerMove:u,onPointerUp:h},v))})]})}function Ys({grid:e,viewportBounds:t,containerSize:n,zoom:o}){if(!e?.enabled)return null;const{size:r=24,color:i="#71717a",opacity:s=.1,type:l="dots"}=e,c=r*o,d=t.x%r*o,f=t.y%r*o,u=b.useMemo(()=>{const h={position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",opacity:s,backgroundPosition:`${-d}px ${-f}px`,backgroundSize:`${c}px ${c}px`};return l==="dots"?{...h,backgroundImage:`radial-gradient(circle, ${i} 1px, transparent 1px)`}:{...h,backgroundImage:`linear-gradient(${i} 1px, transparent 1px), linear-gradient(90deg, ${i} 1px, transparent 1px)`}},[l,i,c,d,f,s]);return a.jsx("div",{className:"infinite-grid",style:u})}function Hs({zoom:e,onZoomIn:t,onZoomOut:n,onReset:o,onFitToView:r}){const i=Math.round(e*100);return a.jsxs("div",{className:"absolute bottom-3 right-3 flex items-center gap-1 bg-white dark:bg-zinc-800 rounded-lg shadow-lg border border-zinc-200 dark:border-zinc-700 p-1",children:[a.jsx("button",{onClick:n,disabled:e<=Ht,className:"p-1.5 rounded hover:bg-zinc-100 dark:hover:bg-zinc-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",title:"Zoom out (scroll down)",children:a.jsx(ds,{className:"w-4 h-4 text-zinc-600 dark:text-zinc-400"})}),a.jsxs("button",{onClick:o,className:"px-2 py-1 text-xs font-medium text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-700 rounded min-w-[48px] transition-colors",title:"Reset to 100%",children:[i,"%"]}),a.jsx("button",{onClick:t,disabled:e>=Bt,className:"p-1.5 rounded hover:bg-zinc-100 dark:hover:bg-zinc-700 disabled:opacity-40 disabled:cursor-not-allowed transition-colors",title:"Zoom in (scroll up)",children:a.jsx(cs,{className:"w-4 h-4 text-zinc-600 dark:text-zinc-400"})}),a.jsx("div",{className:"w-px h-4 bg-zinc-200 dark:bg-zinc-700 mx-0.5"}),a.jsx("button",{onClick:r,className:"p-1.5 rounded hover:bg-zinc-100 dark:hover:bg-zinc-700 transition-colors",title:"Fit to view",children:a.jsx(Ii,{className:"w-4 h-4 text-zinc-600 dark:text-zinc-400"})})]})}function Bs({viewMode:e,onViewModeChange:t}){return a.jsxs("div",{className:"absolute bottom-3 right-44 flex items-center gap-1 bg-white dark:bg-zinc-800 rounded-lg shadow-lg border border-zinc-200 dark:border-zinc-700 p-1",children:[a.jsx("button",{onClick:()=>t("2d"),className:`p-1.5 rounded transition-colors ${e==="2d"?"bg-violet-100 dark:bg-violet-900/50 text-violet-600 dark:text-violet-400":"hover:bg-zinc-100 dark:hover:bg-zinc-700 text-zinc-600 dark:text-zinc-400"}`,title:"2D View",children:a.jsx($n,{className:"w-4 h-4"})}),a.jsx("button",{onClick:()=>t("isometric"),className:`p-1.5 rounded transition-colors ${e==="isometric"?"bg-violet-100 dark:bg-violet-900/50 text-violet-600 dark:text-violet-400":"hover:bg-zinc-100 dark:hover:bg-zinc-700 text-zinc-600 dark:text-zinc-400"}`,title:"Isometric View",children:a.jsx(Ot,{className:"w-4 h-4"})})]})}const Ws=25,Us=50,Xs=6;function dt(e,t){const n=20+t*50;return`hsl(${e.hue}, ${e.saturation}%, ${n}%)`}function js({nodes:e,nodeData:t,selectedNodeIds:n,onNodeClick:o,onNodePointerDown:r,originX:i=400,originY:s=500}){const l=b.useMemo(()=>Object.entries(e).filter(([c])=>t[c]).sort(([,c],[,d])=>{const f=c.x+c.y+(c.z||0),u=d.x+d.y+(d.z||0);return f-u}),[e,t]);return a.jsxs("svg",{className:"absolute inset-0 w-full h-full",style:{overflow:"visible"},children:[l.map(([c,d])=>{const f=t[c];if(!f)return null;const u=q[d.size]||q.m,p=(d.width||u.width)*.8,g=d.isoDepth??Us,x=d.isoHeight??Ws,k=d.z??0,y=T(d.x,d.y,k),m=i+y.screenX,C=s+y.screenY,v=Oe(p,g,x,m,C,Xs),z=Ge[f.color]||Ge.violet,_=Vn(f.color),N=n.includes(c),E=T(d.x+p/2,d.y+g/2,k+x),S=i+E.screenX,w=s+E.screenY;return a.jsxs("g",{className:"cursor-pointer",onClick:()=>o?.(c),onPointerDown:M=>r?.(M,c),children:[N&&a.jsxs("g",{filter:"url(#selection-glow)",children:[a.jsx("path",{d:v.top,fill:"rgba(59, 130, 246, 0.3)"}),a.jsx("path",{d:v.right,fill:"rgba(59, 130, 246, 0.2)"}),a.jsx("path",{d:v.left,fill:"rgba(59, 130, 246, 0.15)"})]}),v.cornerBackLeft?.map((M,$)=>a.jsx("path",{d:M.path,fill:dt(z,M.intensity)},`cbl-${$}`)),v.cornerBackRight?.map((M,$)=>a.jsx("path",{d:M.path,fill:dt(z,M.intensity)},`cbr-${$}`)),a.jsx("path",{d:v.left,fill:_.left,stroke:N?"#3b82f6":"rgba(0,0,0,0.3)",strokeWidth:N?2:.5}),a.jsx("path",{d:v.right,fill:_.right,stroke:N?"#3b82f6":"rgba(0,0,0,0.3)",strokeWidth:N?2:.5}),v.cornerFrontLeft?.map((M,$)=>a.jsx("path",{d:M.path,fill:dt(z,M.intensity)},`cfl-${$}`)),v.cornerFrontRight?.map((M,$)=>a.jsx("path",{d:M.path,fill:dt(z,M.intensity)},`cfr-${$}`)),a.jsx("path",{d:v.top,fill:_.top,stroke:N?"#3b82f6":"rgba(255,255,255,0.1)",strokeWidth:N?2:.5}),a.jsx("text",{x:S,y:w-5,textAnchor:"middle",className:"fill-white text-xs font-semibold pointer-events-none",style:{textShadow:"0 1px 2px rgba(0,0,0,0.8)",fontSize:"11px"},children:f.name})]},c)}),a.jsx("defs",{children:a.jsxs("filter",{id:"selection-glow",x:"-50%",y:"-50%",width:"200%",height:"200%",children:[a.jsx("feGaussianBlur",{stdDeviation:"4",result:"blur"}),a.jsxs("feMerge",{children:[a.jsx("feMergeNode",{in:"blur"}),a.jsx("feMergeNode",{in:"SourceGraphic"})]})]})})]})}const Gs=25,Vs=50,Wt={emerald:"#34d399",amber:"#fbbf24",zinc:"#71717a",sky:"#38bdf8",violet:"#a78bfa",blue:"#60a5fa"};function Jn(e,t,n,o){const r=q[e.size]||q.m,s=(e.width||r.width)*.8,l=e.isoDepth??Vs,c=e.isoHeight??Gs,d=e.z??0;let f,u,h;switch(t){case"left":f=e.x,u=e.y+l/2,h=d+c/2;break;case"right":f=e.x+s/2,u=e.y,h=d+c/2;break;case"top":f=e.x+s/2,u=e.y+l/2,h=d+c;break;case"bottom":f=e.x+s/2,u=e.y+l/2,h=d;break;case"topLeft":f=e.x,u=e.y+l,h=d+c;break;case"topRight":f=e.x+s,u=e.y,h=d+c;break;case"bottomLeft":f=e.x,u=e.y+l,h=d;break;case"bottomRight":f=e.x+s,u=e.y,h=d;break;default:f=e.x+s/2,u=e.y+l/2,h=d+c}const p=T(f,u,h);return{x:n+p.screenX,y:o+p.screenY}}function Ks(e,t){const n=t.x-e.x,o=t.y-e.y,r=Math.sqrt(n*n+o*o),i=(e.x+t.x)/2,s=(e.y+t.y)/2,l=-o/r*r*.2,c=n/r*r*.2;return`M ${e.x} ${e.y} Q ${i+l} ${s+c}, ${t.x} ${t.y}`}function qs({nodes:e,nodeData:t,connectors:n,connectorStyles:o,selectedConnectorIndex:r,onConnectorClick:i,originX:s=400,originY:l=500}){return a.jsxs("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",style:{overflow:"visible"},children:[a.jsx("defs",{children:Object.entries(Wt).map(([c,d])=>a.jsx("marker",{id:`iso-arrow-${c}`,markerWidth:"8",markerHeight:"6",refX:"7",refY:"3",orient:"auto",markerUnits:"userSpaceOnUse",children:a.jsx("polygon",{points:"0 0, 8 3, 0 6",fill:d})},c))}),a.jsx("g",{className:"pointer-events-auto",children:n.map((c,d)=>{const f=o[c.style];if(!f)return null;const u=e[c.from],h=e[c.to];if(!u||!h||!t[c.from]||!t[c.to])return null;const p=Jn(u,c.fromAnchor,s,l),g=Jn(h,c.toAnchor,s,l),x=Ks(p,g),k=Wt[f.color]||Wt.zinc,y=r===d,m=f.showArrow!==!1,C=f.dashed?"8 4":void 0;return a.jsxs("g",{className:"cursor-pointer",onClick:v=>{v.stopPropagation(),i?.(d)},children:[a.jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:20}),y&&a.jsx("path",{d:x,fill:"none",stroke:"#3b82f6",strokeWidth:f.strokeWidth+6,strokeOpacity:.3,strokeDasharray:C}),a.jsx("path",{d:x,fill:"none",stroke:k,strokeWidth:f.strokeWidth,strokeDasharray:C,markerEnd:m?`url(#iso-arrow-${f.color})`:void 0,strokeLinecap:"round",strokeLinejoin:"round",style:{filter:"drop-shadow(0 2px 4px rgba(0,0,0,0.3))"}}),a.jsx("circle",{cx:p.x,cy:p.y,r:4,fill:k}),a.jsx("circle",{cx:g.x,cy:g.y,r:4,fill:k}),f.label&&a.jsx("text",{x:(p.x+g.x)/2,y:(p.y+g.y)/2-10,textAnchor:"middle",fill:k,fontSize:"10",fontFamily:"ui-monospace, monospace",fontWeight:"500",style:{textShadow:"0 1px 2px rgba(0,0,0,0.8)"},children:f.label})]},d)})})]})}const Zs={defaultViewMode:"2d",enableViewModeToggle:!1,enableZoom:!0,enablePan:!0,enableDrag:!0,enableSelection:!0,showZoomControls:!0,showMiniMap:!0,showGrid:!0};function Qn({onViewportChange:e,embedConfig:t}){const{actions:n}=le(),o=ke(),r=je(),i=Bn(),s=Ft(),l=Tn(i),[c,d]=b.useState(null),f={...Zs,...t},{containerRef:u,zoom:h,pan:p,isPanning:g,zoomIn:x,zoomOut:k,resetTransform:y,fitToView:m,setPan:C,screenToCanvas:v,transformStyle:z}=ks({initialZoom:1,initialPan:{x:0,y:0},panModeActive:r.mode==="pan"}),_=b.useRef(null),N=b.useRef(s);b.useEffect(()=>{if(N.current!==s)if(N.current=s,s==="isometric"&&u.current){const D=o.layout.width/2,F=o.layout.height-100,Y=Object.keys(o.nodes);if(Y.length>0){let j=1/0,V=1/0,ee=-1/0,ae=-1/0;const ue=.866,J=.5;for(const mu of Y){const De=o.nodes[mu];if(!De)continue;const xu=De.z||0,bu=De.isoHeight||25,Yo=D+(De.x-De.y)*ue,Ho=F-(De.x+De.y)*J-xu-bu;j=Math.min(j,Yo-50),ee=Math.max(ee,Yo+50),V=Math.min(V,Ho-20),ae=Math.max(ae,Ho+50)}const re=(j+ee)/2,pe=(V+ae)/2,me=u.current.getBoundingClientRect(),be=me.width/2-re,Ee=me.height/2-pe;C({x:be,y:Ee})}}else s==="2d"&&y()},[s,o.nodes,o.layout,u,C,y]);const E=b.useCallback((D,F)=>{if(r.mode!=="select"||g||!f.enableSelection&&!f.enableDrag)return;D.target instanceof Element&&D.target.setPointerCapture?.(D.pointerId);const Y=v({x:D.clientX,y:D.clientY}),j=D.shiftKey;let V=Y;if(s==="isometric"){const J=o.layout.width/2,re=o.layout.height-100;V=Yt(Y.x-J,Y.y-re)}let ee;j?r.selectedNodeIds.includes(F)?ee=r.selectedNodeIds.filter(J=>J!==F):ee=[...r.selectedNodeIds,F]:ee=r.selectedNodeIds.includes(F)?r.selectedNodeIds:[F];const ae={};for(const J of ee){const re=o.nodes[J];re&&(ae[J]={x:V.x-re.x,y:V.y-re.y})}const ue=o.nodes[F];if(!f.enableDrag){n.selectNodes(ee);return}n.startDrag(F,{x:V.x-ue.x,y:V.y-ue.y},ae,ee)},[r.mode,r.selectedNodeIds,g,o.nodes,o.layout,n,v,s,f.enableDrag,f.enableSelection]),S=b.useCallback(D=>{if(!r.isDragging||r.selectedNodeIds.length===0||g)return;const F=v({x:D.clientX,y:D.clientY});let Y=F;if(s==="isometric"){const ue=o.layout.width/2,J=o.layout.height-100;Y=Yt(F.x-ue,F.y-J)}const j=r.selectedNodeIds.map(ue=>{const J=r.dragNodeOffsets?.[ue]||r.dragOffset,re=Math.round(Y.x-J.x),pe=Math.round(Y.y-J.y);return{nodeId:ue,x:re,y:pe}});n.moveNodes(j);const V=200;let ee=o.layout.width,ae=o.layout.height;for(const ue of j){const J=o.nodes[ue.nodeId],re=q[J?.size]||q.m,pe=J?.width||re.width,me=J?.height||re.height,be=ue.x+pe+V,Ee=ue.y+me+V;be>ee&&(ee=be),Ee>ae&&(ae=Ee)}s==="2d"&&(ee>o.layout.width||ae>o.layout.height)&&n.expandLayout(ee,ae)},[r.isDragging,r.selectedNodeIds,r.dragOffset,r.dragNodeOffsets,g,o.nodes,o.layout,n,v,s]),w=b.useCallback(()=>{r.isDragging&&n.endDrag()},[r.isDragging,n]),M=b.useCallback((D,F)=>{g||r.mode==="addConnector"&&d(D)},[r.mode,g]),$=b.useCallback((D,F)=>{r.mode==="addConnector"&&(r.pendingConnector?r.pendingConnector.from!==D&&(n.addConnector(r.pendingConnector.from,D,r.pendingConnector.fromAnchor,F,"http"),d(null)):n.setPendingConnector({from:D,fromAnchor:F}))},[r.mode,r.pendingConnector,n]),A=b.useCallback(D=>{if(g)return;const F=D.target;if(!(!F.classList.contains("canvas-bg")&&F!==_.current))if(r.mode==="addNode"){const Y=v({x:D.clientX,y:D.clientY}),j=Math.round(Y.x-q.m.width/2),V=Math.round(Y.y-q.m.height/2);n.addNode({x:Math.max(0,j),y:Math.max(0,V)})}else r.mode==="addConnector"&&(n.clearPendingConnector(),d(null))},[r.mode,g,n,v]),B=b.useCallback(D=>{r.mode==="select"&&!g&&n.selectConnector(D)},[r.mode,g,n]),W=b.useCallback(D=>{r.mode==="select"&&!g&&n.selectGroup(D)},[r.mode,g,n]),G=b.useCallback(D=>{r.mode==="select"&&!g&&n.selectImage(D)},[r.mode,g,n]),P=b.useCallback(D=>{D.preventDefault(),D.stopPropagation();const Y=Array.from(D.dataTransfer.files).filter(V=>V.type.startsWith("image/")||V.name.endsWith(".svg"));if(Y.length===0)return;const j=v({x:D.clientX,y:D.clientY});Y.forEach((V,ee)=>{const ae=new FileReader;ae.onload=ue=>{const J=ue.target?.result,re=new Image;re.onload=()=>{let pe=re.width,me=re.height;const be=300;if(pe>be||me>be){const Ee=Math.min(be/pe,be/me);pe=Math.round(pe*Ee),me=Math.round(me*Ee)}n.addImage({src:J,name:V.name,x:Math.round(j.x+ee*20),y:Math.round(j.y+ee*20),width:pe,height:me,opacity:1})},re.src=J},ae.readAsDataURL(V)})},[v,n]),ne=b.useCallback(D=>{D.preventDefault(),D.stopPropagation()},[]),[Q,ye]=b.useState({width:800,height:600}),R=b.useCallback(()=>{if(u.current){const D=u.current.getBoundingClientRect();ye({width:D.width,height:D.height})}},[u]);b.useEffect(()=>(R(),window.addEventListener("resize",R),()=>window.removeEventListener("resize",R)),[R]);const U={x:-p.x/h,y:-p.y/h,width:Q.width/h,height:Q.height/h};b.useEffect(()=>{e?.(U)},[U.x,U.y,U.width,U.height,e]),b.useEffect(()=>{if(s!=="2d")return;const D=U.x+U.width,F=U.y+U.height,Y=100;if(D>o.layout.width-Y||F>o.layout.height-Y){const j=Math.max(o.layout.width,D+Y),V=Math.max(o.layout.height,F+Y);(j>o.layout.width||V>o.layout.height)&&n.expandLayout(j,V)}},[s,U.x,U.y,U.width,U.height,o.layout.width,o.layout.height,n]);const Z=b.useCallback(D=>{const F=-(D.x*h)+Q.width/2,Y=-(D.y*h)+Q.height/2;C({x:F,y:Y})},[h,Q,C]),se=b.useCallback(D=>{n.setExportZone(D)},[n]),[H,Ae]=b.useState(null),[X,xe]=b.useState(null),Xe=b.useCallback(D=>{const F=D.target,Y=F.classList.contains("canvas-bg")||F===_.current;if(r.mode==="addRect"||r.mode==="addCircle"){const j=v({x:D.clientX,y:D.clientY});Ae({type:r.mode==="addRect"?"rect":"circle",startX:j.x,startY:j.y,currentX:j.x,currentY:j.y})}else if(r.mode==="select"&&Y&&!g){const j=v({x:D.clientX,y:D.clientY});xe({startX:j.x,startY:j.y,currentX:j.x,currentY:j.y})}},[r.mode,v,g]),bn=b.useCallback(D=>{if(H){const F=v({x:D.clientX,y:D.clientY});Ae(Y=>Y?{...Y,currentX:F.x,currentY:F.y}:null)}if(X){const F=v({x:D.clientX,y:D.clientY});xe(Y=>Y?{...Y,currentX:F.x,currentY:F.y}:null)}},[H,X,v]),gu=b.useCallback(()=>{if(H){const D=Math.min(H.startX,H.currentX),F=Math.min(H.startY,H.currentY),Y=Math.abs(H.currentX-H.startX),j=Math.abs(H.currentY-H.startY);Y>20&&j>20&&n.addGroup({x:Math.round(D),y:Math.round(F),width:Math.round(Y),height:Math.round(j),type:H.type==="circle"?"circle":"rect",color:"zinc",label:"",dashed:!0}),Ae(null),n.setMode("select")}if(X){const D=Math.min(X.startX,X.currentX),F=Math.min(X.startY,X.currentY),Y=Math.abs(X.currentX-X.startX),j=Math.abs(X.currentY-X.startY);if(Y>5||j>5){const V=[];for(const[ee,ae]of Object.entries(o.nodes)){if(!o.nodeData[ee])continue;const J=q[ae.size]||q.m,re=J.width,pe=J.height,me=ae.x,be=ae.y;me<D+Y&&me+re>D&&be<F+j&&be+pe>F&&V.push(ee)}V.length>0?n.selectNodes(V):n.clearSelection()}else n.clearSelection();xe(null)}},[H,X,o.nodes,o.nodeData,n]),Po=r.mode==="addConnector"?c||r.pendingConnector?.from:null,yu=()=>g?"cursor-grabbing":r.mode==="pan"?"cursor-grab":r.mode==="addNode"?"cursor-crosshair":r.mode==="addConnector"?"cursor-pointer":r.mode==="addRect"||r.mode==="addCircle"?"cursor-crosshair":"cursor-default",Fo=(()=>{switch(r.mode){case"addNode":return"Click to place node";case"addConnector":return"Click nodes to connect";case"pan":return"Drag to pan canvas";case"addRect":return"Draw rectangle group";case"addCircle":return"Draw circle group";default:return null}})();return a.jsxs("div",{className:"relative w-full h-full",children:[a.jsxs("div",{ref:u,className:`
|
|
56
|
+
w-full h-full overflow-hidden
|
|
57
|
+
${l.canvas.background}
|
|
58
|
+
${yu()}
|
|
59
|
+
`,style:{touchAction:"none"},onDrop:P,onDragOver:ne,children:[f.showGrid&&a.jsx(Ys,{grid:o.grid,viewportBounds:U,containerSize:Q,zoom:h}),a.jsx("div",{style:z,children:a.jsxs("div",{ref:_,className:"relative canvas-bg",style:{width:o.layout.width,height:o.layout.height},onClick:A,onMouseDown:Xe,onMouseMove:bn,onMouseUp:gu,onPointerMove:S,onPointerUp:w,onPointerLeave:w,children:[a.jsx(Os,{layout:o.layout,groups:o.groups||[],selectedGroupId:r.selectedGroupId,onGroupClick:W,onGroupUpdate:n.updateGroup,screenToCanvas:v}),a.jsx(Ts,{layout:o.layout,images:o.images||[],selectedImageId:r.selectedImageId,onImageClick:G,onImageUpdate:n.updateImage,screenToCanvas:v}),H&&a.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${o.layout.width} ${o.layout.height}`,children:H.type==="circle"?a.jsx("ellipse",{cx:(H.startX+H.currentX)/2,cy:(H.startY+H.currentY)/2,rx:Math.abs(H.currentX-H.startX)/2,ry:Math.abs(H.currentY-H.startY)/2,fill:"rgba(113, 113, 122, 0.1)",stroke:"rgba(113, 113, 122, 0.5)",strokeWidth:"2",strokeDasharray:"8 4"}):a.jsx("rect",{x:Math.min(H.startX,H.currentX),y:Math.min(H.startY,H.currentY),width:Math.abs(H.currentX-H.startX),height:Math.abs(H.currentY-H.startY),rx:12,fill:"rgba(113, 113, 122, 0.1)",stroke:"rgba(113, 113, 122, 0.5)",strokeWidth:"2",strokeDasharray:"8 4"})}),X&&a.jsx("svg",{className:"absolute inset-0 w-full h-full pointer-events-none",viewBox:`0 0 ${o.layout.width} ${o.layout.height}`,children:a.jsx("rect",{x:Math.min(X.startX,X.currentX),y:Math.min(X.startY,X.currentY),width:Math.abs(X.currentX-X.startX),height:Math.abs(X.currentY-X.startY),fill:"rgba(59, 130, 246, 0.1)",stroke:"rgba(59, 130, 246, 0.8)",strokeWidth:"1",strokeDasharray:"4 2"})}),s==="2d"?a.jsxs(a.Fragment,{children:[a.jsx(Is,{layout:o.layout,nodes:o.nodes,connectors:o.connectors,connectorStyles:o.connectorStyles,selectedConnectorIndex:r.selectedConnectorIndex,onConnectorClick:B}),Po&&a.jsx(Es,{layout:o.layout,nodes:o.nodes,visibleNodeId:Po,onAnchorClick:$,pendingConnector:r.pendingConnector}),a.jsx("div",{className:"absolute inset-0 pointer-events-none",children:Object.entries(o.nodes).map(([D,F])=>{const Y=o.nodeData[D];return Y?a.jsx(zs,{nodeId:D,node:F,data:Y,layout:o.layout,template:l,isSelected:r.selectedNodeIds.includes(D),onPointerDown:E,onClick:M,onMouseEnter:()=>r.mode==="addConnector"&&d(D),onMouseLeave:()=>r.mode==="addConnector"&&d(null)},D):null})})]}):a.jsxs(a.Fragment,{children:[a.jsx(qs,{nodes:o.nodes,nodeData:o.nodeData,connectors:o.connectors,connectorStyles:o.connectorStyles,selectedConnectorIndex:r.selectedConnectorIndex,onConnectorClick:B,originX:o.layout.width/2,originY:o.layout.height-100}),a.jsx(js,{nodes:o.nodes,nodeData:o.nodeData,selectedNodeIds:r.selectedNodeIds,onNodeClick:D=>n.selectNode(D),onNodePointerDown:E,originX:o.layout.width/2,originY:o.layout.height-100})]}),a.jsx(Fs,{layout:o.layout,exportZone:o.exportZone,isEditing:r.mode==="select",onZoneUpdate:se,onZoneClear:n.clearExportZone,screenToCanvas:v})]})})]}),Fo&&a.jsx("div",{className:`absolute top-2 left-2 px-2 py-1 rounded text-white text-xs font-medium ${r.mode==="pan"?"bg-zinc-600":"bg-blue-500"}`,children:Fo}),r.pendingConnector&&a.jsx("div",{className:"absolute top-2 right-2 px-2 py-1 rounded bg-amber-500 text-white text-xs font-medium",children:"Select target anchor"}),f.showZoomControls&&a.jsx(Hs,{zoom:h,onZoomIn:()=>x(),onZoomOut:()=>k(),onReset:y,onFitToView:()=>m(o.layout)}),f.enableViewModeToggle&&a.jsx(Bs,{viewMode:s,onViewModeChange:n.setViewMode}),f.showMiniMap&&s==="2d"&&a.jsx(Ps,{diagram:o,viewportBounds:U,onViewportChange:Z})]})}const Rn={};function Ve(e,t){const n=O.useRef(Rn);return n.current===Rn&&(n.current=e(t)),n}const Ut=O[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0,-3)],Js=Ut&&Ut!==O.useLayoutEffect?Ut:e=>e();function we(e){const t=Ve(Qs).current;return t.next=e,Js(t.effect),t.trampoline}function Qs(){const e={next:void 0,callback:Rs,trampoline:(...t)=>e.callback?.(...t),effect:()=>{e.callback=e.next}};return e}function Rs(){if(process.env.NODE_ENV!=="production")throw new Error("Base UI: Cannot call an event handler while rendering.")}function er({controlled:e,default:t,name:n,state:o="value"}){const{current:r}=O.useRef(e!==void 0),[i,s]=O.useState(t),l=r?e:i;if(process.env.NODE_ENV!=="production"){O.useEffect(()=>{r!==(e!==void 0)&&console.error([`Base UI: A component is changing the ${r?"":"un"}controlled ${o} state of ${n} to be ${r?"un":""}controlled.`,"Elements should not switch from uncontrolled to controlled (or vice versa).",`Decide between using a controlled or uncontrolled ${n} element for the lifetime of the component.`,"The nature of the state is determined during the first render. It's considered controlled if the value is not `undefined`.","More info: https://fb.me/react-controlled-components"].join(`
|
|
60
|
+
`))},[o,n,e]);const{current:d}=O.useRef(t);O.useEffect(()=>{!r&&JSON.stringify(d)!==JSON.stringify(t)&&console.error([`Base UI: A component is changing the default ${o} state of an uncontrolled ${n} after being initialized. To suppress this warning opt to use a controlled ${n}.`].join(`
|
|
61
|
+
`))},[JSON.stringify(t)])}const c=O.useCallback(d=>{r||s(d)},[]);return[l,c]}function ut(e,...t){const n=new URL(`https://base-ui.com/production-error/${e}`);return t.forEach(o=>n.searchParams.append("args[]",o)),`Base UI error #${e}; visit ${n} for the full message.`}function ht(e,t,n,o){const r=Ve(tr).current;return ta(r,e,t,n,o)&&nr(r,[e,t,n,o]),r.callback}function ea(e){const t=Ve(tr).current;return na(t,e)&&nr(t,e),t.callback}function tr(){return{callback:null,cleanup:null,refs:[]}}function ta(e,t,n,o,r){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==o||e.refs[3]!==r}function na(e,t){return e.refs.length!==t.length||e.refs.some((n,o)=>n!==t[o])}function nr(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){const o=Array(t.length).fill(null);for(let r=0;r<t.length;r+=1){const i=t[r];if(i!=null)switch(typeof i){case"function":{const s=i(n);typeof s=="function"&&(o[r]=s);break}case"object":{i.current=n;break}}}e.cleanup=()=>{for(let r=0;r<t.length;r+=1){const i=t[r];if(i!=null)switch(typeof i){case"function":{const s=o[r];typeof s=="function"?s():i(null);break}case"object":{i.current=null;break}}}}}}}const ra=parseInt(O.version,10);function oa(e){return ra>=e}function rr(e){if(!O.isValidElement(e))return null;const t=e,n=t.props;return(oa(19)?n?.ref:t.ref)??null}function Xt(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}function ia(e,t){const n={};for(const o in e){const r=e[o];if(t?.hasOwnProperty(o)){const i=t[o](r);i!=null&&Object.assign(n,i);continue}r===!0?n[`data-${o.toLowerCase()}`]="":r&&(n[`data-${o.toLowerCase()}`]=r.toString())}return n}function sa(e,t){return typeof e=="function"?e(t):e}function aa(e,t){return typeof e=="function"?e(t):e}const Ke={};function or(e,t,n,o,r){let i={...jt(e,Ke)};return t&&(i=ft(i,t)),n&&(i=ft(i,n)),o&&(i=ft(i,o)),i}function la(e){if(e.length===0)return Ke;if(e.length===1)return jt(e[0],Ke);let t={...jt(e[0],Ke)};for(let n=1;n<e.length;n+=1)t=ft(t,e[n]);return t}function ft(e,t){return ir(t)?t(e):ca(e,t)}function ca(e,t){if(!t)return e;for(const n in t){const o=t[n];switch(n){case"style":{e[n]=Xt(e.style,o);break}case"className":{e[n]=sr(e.className,o);break}default:da(n,o)?e[n]=ua(e[n],o):e[n]=o}}return e}function da(e,t){const n=e.charCodeAt(0),o=e.charCodeAt(1),r=e.charCodeAt(2);return n===111&&o===110&&r>=65&&r<=90&&(typeof t=="function"||typeof t>"u")}function ir(e){return typeof e=="function"}function jt(e,t){return ir(e)?e(t):e??Ke}function ua(e,t){return t?e?n=>{if(ha(n)){const r=n;Gt(r);const i=t(r);return r.baseUIHandlerPrevented||e?.(r),i}const o=t(n);return e?.(n),o}:t:e}function Gt(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}function sr(e,t){return t?e?t+" "+e:t:e}function ha(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}const pt=Object.freeze([]),Ne=Object.freeze({});function gt(e,t,n={}){const o=t.render,r=fa(t,n);if(n.enabled===!1)return null;const i=n.state??Ne;return pa(e,o,r,i)}function fa(e,t={}){const{className:n,style:o,render:r}=e,{state:i=Ne,ref:s,props:l,stateAttributesMapping:c,enabled:d=!0}=t,f=d?sa(n,i):void 0,u=d?aa(o,i):void 0,h=d?ia(i,c):Ne,p=d?Xt(h,Array.isArray(l)?la(l):l)??Ne:Ne;return typeof document<"u"&&(d?Array.isArray(s)?p.ref=ea([p.ref,rr(r),...s]):p.ref=ht(p.ref,rr(r),s):ht(null,null)),d?(f!==void 0&&(p.className=sr(p.className,f)),u!==void 0&&(p.style=Xt(p.style,u)),p):Ne}function pa(e,t,n,o){if(t){if(typeof t=="function")return t(n,o);const r=or(n,t.props);return r.ref=n.ref,O.cloneElement(t,r)}if(e&&typeof e=="string")return ga(e,n);throw new Error(process.env.NODE_ENV!=="production"?"Base UI: Render element or function are not defined.":ut(8))}function ga(e,t){return e==="button"?b.createElement("button",{type:"button",...t,key:t.key}):e==="img"?b.createElement("img",{alt:"",...t,key:t.key}):O.createElement(e,t)}const _e=typeof document<"u"?O.useLayoutEffect:()=>{},Vt=O.createContext({register:()=>{},unregister:()=>{},subscribeMapChange:()=>()=>{},elementsRef:{current:[]},nextIndexRef:{current:0}});process.env.NODE_ENV!=="production"&&(Vt.displayName="CompositeListContext");function ya(){return O.useContext(Vt)}function ma(e){const{children:t,elementsRef:n,labelsRef:o,onMapChange:r}=e,i=we(r),s=O.useRef(0),l=Ve(ba).current,c=Ve(xa).current,[d,f]=O.useState(0),u=O.useRef(d),h=we((y,m)=>{c.set(y,m??null),u.current+=1,f(u.current)}),p=we(y=>{c.delete(y),u.current+=1,f(u.current)}),g=O.useMemo(()=>{const y=new Map;return Array.from(c.keys()).filter(C=>C.isConnected).sort(ka).forEach((C,v)=>{const z=c.get(C)??{};y.set(C,{...z,index:v})}),y},[c,d]);_e(()=>{if(typeof MutationObserver!="function"||g.size===0)return;const y=new MutationObserver(m=>{const C=new Set,v=z=>C.has(z)?C.delete(z):C.add(z);m.forEach(z=>{z.removedNodes.forEach(v),z.addedNodes.forEach(v)}),C.size===0&&(u.current+=1,f(u.current))});return g.forEach((m,C)=>{C.parentElement&&y.observe(C.parentElement,{childList:!0})}),()=>{y.disconnect()}},[g]),_e(()=>{u.current===d&&(n.current.length!==g.size&&(n.current.length=g.size),o&&o.current.length!==g.size&&(o.current.length=g.size),s.current=g.size),i(g)},[i,g,n,o,d]),_e(()=>()=>{n.current=[]},[n]),_e(()=>()=>{o&&(o.current=[])},[o]);const x=we(y=>(l.add(y),()=>{l.delete(y)}));_e(()=>{l.forEach(y=>y(g))},[l,g]);const k=O.useMemo(()=>({register:h,unregister:p,subscribeMapChange:x,elementsRef:n,labelsRef:o,nextIndexRef:s}),[h,p,x,n,o,s]);return a.jsx(Vt.Provider,{value:k,children:t})}function xa(){return new Map}function ba(){return new Set}function ka(e,t){const n=e.compareDocumentPosition(t);return n&Node.DOCUMENT_POSITION_FOLLOWING||n&Node.DOCUMENT_POSITION_CONTAINED_BY?-1:n&Node.DOCUMENT_POSITION_PRECEDING||n&Node.DOCUMENT_POSITION_CONTAINS?1:0}function va(e){return e==null||e.hasAttribute("disabled")||e.getAttribute("aria-disabled")==="true"}function wa(){return typeof window<"u"}function Ca(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Kt(e){return wa()?e instanceof HTMLElement||e instanceof Ca(e).HTMLElement:!1}const qt="ArrowLeft",Zt="ArrowRight",Na="ArrowUp",za="ArrowDown";function Te(e){e.preventDefault(),e.stopPropagation()}const ar=Math.floor;function yt(e,t,n){return Math.floor(e/t)!==n}function mt(e,t){return t<0||t>=e.current.length}function Ma(e,t){return ge(e,{disabledIndices:t})}function _a(e,t){return ge(e,{decrement:!0,startingIndex:e.current.length,disabledIndices:t})}function ge(e,{startingIndex:t=-1,decrement:n=!1,disabledIndices:o,amount:r=1}={}){let i=t;do i+=n?-r:r;while(i>=0&&i<=e.current.length-1&&qe(e,i,o));return i}function $a(e,{event:t,orientation:n,loopFocus:o,rtl:r,cols:i,disabledIndices:s,minIndex:l,maxIndex:c,prevIndex:d,stopEvent:f=!1}){let u=d;const h=[],p={};let g=!1;{let y=null,m=-1;e.current.forEach((C,v)=>{if(C==null)return;const z=C.closest('[role="row"]');z&&(g=!0),(z!==y||m===-1)&&(y=z,m+=1,h[m]=[]),h[m].push(v),p[v]=m})}const x=g&&h.length>0&&h.some(y=>y.length!==i);function k(y){if(!x||d===-1)return;const m=p[d];if(m==null)return;const C=h[m].indexOf(d);let v=y==="up"?m-1:m+1;o&&(v<0?v=h.length-1:v>=h.length&&(v=0));const z=new Set;for(;v>=0&&v<h.length&&!z.has(v);){z.add(v);const _=h[v];if(_.length===0){v=y==="up"?v-1:v+1;continue}const N=Math.min(C,_.length-1);for(let E=N;E>=0;E-=1){const S=_[E];if(!qe(e,S,s))return S}v=y==="up"?v-1:v+1,o&&(v<0?v=h.length-1:v>=h.length&&(v=0))}}if(t.key===Na){const y=k("up");if(y!==void 0)f&&Te(t),u=y;else{if(f&&Te(t),d===-1)u=c;else if(u=ge(e,{startingIndex:u,amount:i,decrement:!0,disabledIndices:s}),o&&(d-i<l||u<0)){const m=d%i,C=c%i,v=c-(C-m);C===m?u=c:u=C>m?v:v-i}mt(e,u)&&(u=d)}}if(t.key===za){const y=k("down");y!==void 0?(f&&Te(t),u=y):(f&&Te(t),d===-1?u=l:(u=ge(e,{startingIndex:d,amount:i,disabledIndices:s}),o&&d+i>c&&(u=ge(e,{startingIndex:d%i-i,amount:i,disabledIndices:s}))),mt(e,u)&&(u=d))}if(n==="both"){const y=ar(d/i);t.key===(r?qt:Zt)&&(f&&Te(t),d%i!==i-1?(u=ge(e,{startingIndex:d,disabledIndices:s}),o&&yt(u,i,y)&&(u=ge(e,{startingIndex:d-d%i-1,disabledIndices:s}))):o&&(u=ge(e,{startingIndex:d-d%i-1,disabledIndices:s})),yt(u,i,y)&&(u=d)),t.key===(r?Zt:qt)&&(f&&Te(t),d%i!==0?(u=ge(e,{startingIndex:d,decrement:!0,disabledIndices:s}),o&&yt(u,i,y)&&(u=ge(e,{startingIndex:d+(i-d%i),decrement:!0,disabledIndices:s}))):o&&(u=ge(e,{startingIndex:d+(i-d%i),decrement:!0,disabledIndices:s})),yt(u,i,y)&&(u=d));const m=ar(c/i)===y;mt(e,u)&&(o&&m?u=t.key===(r?Zt:qt)?c:ge(e,{startingIndex:d-d%i-1,disabledIndices:s}):u=d)}return u}function Sa(e,t,n){const o=[];let r=0;return e.forEach(({width:i,height:s},l)=>{if(i>t&&process.env.NODE_ENV!=="production")throw new Error(process.env.NODE_ENV!=="production"?`[Floating UI]: Invalid grid - item width at index ${l} is greater than grid columns`:ut(29,l));let c=!1;for(n&&(r=0);!c;){const d=[];for(let f=0;f<i;f+=1)for(let u=0;u<s;u+=1)d.push(r+f+u*t);r%t+i<=t&&d.every(f=>o[f]==null)?(d.forEach(f=>{o[f]=l}),c=!0):r+=1}}),[...o]}function Aa(e,t,n,o,r){if(e===-1)return-1;const i=n.indexOf(e),s=t[e];switch(r){case"tl":return i;case"tr":return s?i+s.width-1:i;case"bl":return s?i+(s.height-1)*o:i;case"br":return n.lastIndexOf(e);default:return-1}}function Ia(e,t){return t.flatMap((n,o)=>e.includes(n)?[o]:[])}function qe(e,t,n){if(typeof n=="function")return n(t);if(n)return n.includes(t);const o=e.current[t];return o?o.hasAttribute("disabled")||o.getAttribute("aria-disabled")==="true":!1}const Ze="ArrowUp",Pe="ArrowDown",xt="ArrowLeft",Je="ArrowRight",bt="Home",kt="End",lr=new Set([xt,Je]),Ea=new Set([xt,Je,bt,kt]),cr=new Set([Ze,Pe]),Da=new Set([Ze,Pe,bt,kt]),dr=new Set([...lr,...cr]),Oa=new Set([...dr,bt,kt]),La="Shift",Ta="Control",Pa="Alt",Fa="Meta",Ya=new Set([La,Ta,Pa,Fa]);function Ha(e){return Kt(e)&&e.tagName==="INPUT"}function ur(e){return!!(Ha(e)&&e.selectionStart!=null||Kt(e)&&e.tagName==="TEXTAREA")}function hr(e,t,n,o){if(!e||!t||!t.scrollTo)return;let r=e.scrollLeft,i=e.scrollTop;const s=e.clientWidth<e.scrollWidth,l=e.clientHeight<e.scrollHeight;if(s&&o!=="vertical"){const c=fr(e,t,"left"),d=vt(e),f=vt(t);n==="ltr"&&(c+t.offsetWidth+f.scrollMarginRight>e.scrollLeft+e.clientWidth-d.scrollPaddingRight?r=c+t.offsetWidth+f.scrollMarginRight-e.clientWidth+d.scrollPaddingRight:c-f.scrollMarginLeft<e.scrollLeft+d.scrollPaddingLeft&&(r=c-f.scrollMarginLeft-d.scrollPaddingLeft)),n==="rtl"&&(c-f.scrollMarginRight<e.scrollLeft+d.scrollPaddingLeft?r=c-f.scrollMarginLeft-d.scrollPaddingLeft:c+t.offsetWidth+f.scrollMarginRight>e.scrollLeft+e.clientWidth-d.scrollPaddingRight&&(r=c+t.offsetWidth+f.scrollMarginRight-e.clientWidth+d.scrollPaddingRight))}if(l&&o!=="horizontal"){const c=fr(e,t,"top"),d=vt(e),f=vt(t);c-f.scrollMarginTop<e.scrollTop+d.scrollPaddingTop?i=c-f.scrollMarginTop-d.scrollPaddingTop:c+t.offsetHeight+f.scrollMarginBottom>e.scrollTop+e.clientHeight-d.scrollPaddingBottom&&(i=c+t.offsetHeight+f.scrollMarginBottom-e.clientHeight+d.scrollPaddingBottom)}e.scrollTo({left:r,top:i,behavior:"auto"})}function fr(e,t,n){const o=n==="left"?"offsetLeft":"offsetTop";let r=0;for(;t.offsetParent&&(r+=t[o],t.offsetParent!==e);)t=t.offsetParent;return r}function vt(e){const t=getComputedStyle(e);return{scrollMarginTop:parseFloat(t.scrollMarginTop)||0,scrollMarginRight:parseFloat(t.scrollMarginRight)||0,scrollMarginBottom:parseFloat(t.scrollMarginBottom)||0,scrollMarginLeft:parseFloat(t.scrollMarginLeft)||0,scrollPaddingTop:parseFloat(t.scrollPaddingTop)||0,scrollPaddingRight:parseFloat(t.scrollPaddingRight)||0,scrollPaddingBottom:parseFloat(t.scrollPaddingBottom)||0,scrollPaddingLeft:parseFloat(t.scrollPaddingLeft)||0}}const Ba="data-composite-item-active",Wa=[];function Ua(e){const{itemSizes:t,cols:n=1,loopFocus:o=!0,dense:r=!1,orientation:i="both",direction:s,highlightedIndex:l,onHighlightedIndexChange:c,rootRef:d,enableHomeAndEndKeys:f=!1,stopEventPropagation:u=!1,disabledIndices:h,modifierKeys:p=Wa}=e,[g,x]=O.useState(0),k=n>1,y=O.useRef(null),m=ht(y,d),C=O.useRef([]),v=O.useRef(!1),z=l??g,_=we((S,w=!1)=>{if((c??x)(S),w){const M=C.current[S];hr(y.current,M,s,i)}}),N=we(S=>{if(S.size===0||v.current)return;v.current=!0;const w=Array.from(S.keys()),M=w.find(A=>A?.hasAttribute(Ba))??null,$=M?w.indexOf(M):-1;$!==-1&&_($),hr(y.current,M,s,i)}),E=O.useMemo(()=>({"aria-orientation":i==="both"?void 0:i,ref:m,onFocus(S){!y.current||!ur(S.target)||S.target.setSelectionRange(0,S.target.value.length??0)},onKeyDown(S){const w=f?Oa:dr;if(!w.has(S.key)||Xa(S,p)||!y.current)return;const $=s==="rtl",A=$?xt:Je,B={horizontal:A,vertical:Pe,both:A}[i],W=$?Je:xt,G={horizontal:W,vertical:Ze,both:W}[i];if(ur(S.target)&&!va(S.target)){const Z=S.target.selectionStart,se=S.target.selectionEnd,H=S.target.value??"";if(Z==null||S.shiftKey||Z!==se||S.key!==G&&Z<H.length||S.key!==B&&Z>0)return}let P=z;const ne=Ma(C,h),Q=_a(C,h);if(k){const Z=t||Array.from({length:C.current.length},()=>({width:1,height:1})),se=Sa(Z,n,r),H=se.findIndex(X=>X!=null&&!qe(C,X,h)),Ae=se.reduce((X,xe,Xe)=>xe!=null&&!qe(C,xe,h)?Xe:X,-1);P=se[$a({current:se.map(X=>X?C.current[X]:null)},{event:S,orientation:i,loopFocus:o,cols:n,disabledIndices:Ia([...h||C.current.map((X,xe)=>qe(C,xe)?xe:void 0),void 0],se),minIndex:H,maxIndex:Ae,prevIndex:Aa(z>Q?ne:z,Z,se,n,S.key===Pe?"bl":S.key===Je?"tr":"tl"),rtl:$})]}const ye={horizontal:[A],vertical:[Pe],both:[A,Pe]}[i],R={horizontal:[W],vertical:[Ze],both:[W,Ze]}[i],U=k?w:{horizontal:f?Ea:lr,vertical:f?Da:cr,both:w}[i];f&&(S.key===bt?P=ne:S.key===kt&&(P=Q)),P===z&&(ye.includes(S.key)||R.includes(S.key))&&(o&&P===Q&&ye.includes(S.key)?P=ne:o&&P===ne&&R.includes(S.key)?P=Q:P=ge(C,{startingIndex:P,decrement:R.includes(S.key),disabledIndices:h})),P!==z&&!mt(C,P)&&(u&&S.stopPropagation(),U.has(S.key)&&S.preventDefault(),_(P,!0),queueMicrotask(()=>{C.current[P]?.focus()}))}}),[n,r,s,h,C,f,z,k,t,o,m,p,_,i,u]);return O.useMemo(()=>({props:E,highlightedIndex:z,onHighlightedIndexChange:_,elementsRef:C,disabledIndices:h,onMapChange:N,relayKeyboardEvent:E.onKeyDown}),[E,z,_,C,h,N])}function Xa(e,t){for(const n of Ya.values())if(!t.includes(n)&&e.getModifierState(n))return!0;return!1}const Jt=O.createContext(void 0);process.env.NODE_ENV!=="production"&&(Jt.displayName="CompositeRootContext");function pr(e=!1){const t=O.useContext(Jt);if(t===void 0&&!e)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.":ut(16));return t}const gr=O.createContext(void 0);process.env.NODE_ENV!=="production"&&(gr.displayName="DirectionContext");function ja(){return O.useContext(gr)?.direction??"ltr"}function Ga(e){const{render:t,className:n,refs:o=pt,props:r=pt,state:i=Ne,stateAttributesMapping:s,highlightedIndex:l,onHighlightedIndexChange:c,orientation:d,dense:f,itemSizes:u,loopFocus:h,cols:p,enableHomeAndEndKeys:g,onMapChange:x,stopEventPropagation:k=!0,rootRef:y,disabledIndices:m,modifierKeys:C,highlightItemOnHover:v=!1,tag:z="div",..._}=e,N=ja(),{props:E,highlightedIndex:S,onHighlightedIndexChange:w,elementsRef:M,onMapChange:$,relayKeyboardEvent:A}=Ua({itemSizes:u,cols:p,loopFocus:h,dense:f,orientation:d,highlightedIndex:l,onHighlightedIndexChange:c,rootRef:y,stopEventPropagation:k,enableHomeAndEndKeys:g,direction:N,disabledIndices:m,modifierKeys:C}),B=gt(z,e,{state:i,ref:o,props:[E,...r,_],stateAttributesMapping:s}),W=O.useMemo(()=>({highlightedIndex:S,onHighlightedIndexChange:w,highlightItemOnHover:v,relayKeyboardEvent:A}),[S,w,v,A]);return a.jsx(Jt.Provider,{value:W,children:a.jsx(ma,{elementsRef:M,onMapChange:G=>{x?.(G),$(G)},children:B})})}const yr=O.createContext(void 0);process.env.NODE_ENV!=="production"&&(yr.displayName="ToolbarRootContext");function Va(e){return O.useContext(yr)}const Qt=O.createContext(void 0);process.env.NODE_ENV!=="production"&&(Qt.displayName="ToggleGroupContext");function Ka(e=!0){const t=O.useContext(Qt);if(t===void 0&&!e)throw new Error(process.env.NODE_ENV!=="production"?"Base UI: ToggleGroupContext is missing. ToggleGroup parts must be placed within <ToggleGroup>.":ut(7));return t}let qa=(function(e){return e.disabled="data-disabled",e.orientation="data-orientation",e.multiple="data-multiple",e})({});const mr={multiple(e){return e?{[qa.multiple]:""}:null}},xr=O.forwardRef(function(t,n){const{defaultValue:o,disabled:r=!1,loopFocus:i=!0,onValueChange:s,orientation:l="horizontal",multiple:c=!1,value:d,className:f,render:u,...h}=t,p=Va(),g=O.useMemo(()=>{if(d===void 0)return o??[]},[d,o]),x=(p?.disabled??!1)||r,[k,y]=er({controlled:d,default:g,name:"ToggleGroup",state:"value"}),m=we((N,E,S)=>{let w;if(c?(w=k.slice(),E?w.push(N):w.splice(k.indexOf(N),1)):w=E?[N]:[],Array.isArray(w)){if(s?.(w,S),S.isCanceled)return;y(w)}}),C=O.useMemo(()=>({disabled:x,multiple:c,orientation:l}),[x,l,c]),v=O.useMemo(()=>({disabled:x,orientation:l,setGroupValue:m,value:k}),[x,l,m,k]),z={role:"group"},_=gt("div",t,{enabled:!!p,state:C,ref:n,props:[z,h],stateAttributesMapping:mr});return a.jsx(Qt.Provider,{value:v,children:p?_:a.jsx(Ga,{render:u,className:f,state:C,refs:[n],props:[z,h],stateAttributesMapping:mr,loopFocus:i})})});process.env.NODE_ENV!=="production"&&(xr.displayName="ToggleGroup");const Za={...O};let br=0;function Ja(e,t="mui"){const[n,o]=O.useState(e),r=e||n;return O.useEffect(()=>{n==null&&(br+=1,o(`${t}-${br}`))},[n,t]),r}const kr=Za.useId;function Qa(e,t){if(kr!==void 0){const n=kr();return e??`${t}-${n}`}return Ja(e,t)}function Ra(e){return Qa(e,"base-ui")}let Rt;process.env.NODE_ENV!=="production"&&(Rt=new Set);function vr(...e){if(process.env.NODE_ENV!=="production"){const t=e.join(" ");Rt.has(t)||(Rt.add(t),console.error(`Base UI: ${t}`))}}function el(e){const{focusableWhenDisabled:t,disabled:n,composite:o=!1,tabIndex:r=0,isNativeButton:i}=e,s=o&&t!==!1,l=o&&t===!1;return{props:O.useMemo(()=>{const d={onKeyDown(f){n&&t&&f.key!=="Tab"&&f.preventDefault()}};return o||(d.tabIndex=r,!i&&n&&(d.tabIndex=t?r:-1)),(i&&(t||s)||!i&&n)&&(d["aria-disabled"]=n),i&&(!t||l)&&(d.disabled=n),d},[o,n,t,s,l,i,r])}}function tl(e={}){const{disabled:t=!1,focusableWhenDisabled:n,tabIndex:o=0,native:r=!0}=e,i=O.useRef(null),s=pr(!0)!==void 0,l=we(()=>{const h=i.current;return!!(h?.tagName==="A"&&h?.href)}),{props:c}=el({focusableWhenDisabled:n,disabled:t,composite:s,tabIndex:o,isNativeButton:r});process.env.NODE_ENV!=="production"&&O.useEffect(()=>{if(!i.current)return;const h=i.current.tagName==="BUTTON";r?h||vr("A component that acts as a button was not rendered as a native <button>, which does not match the default. Ensure that the element passed to the `render` prop of the component is a real <button>, or set the `nativeButton` prop on the component to `false`."):h&&vr("A component that acts as a button was rendered as a native <button>, which does not match the default. Ensure that the element passed to the `render` prop of the component is not a real <button>, or set the `nativeButton` prop on the component to `true`.")},[r]);const d=O.useCallback(()=>{const h=i.current;nl(h)&&s&&t&&c.disabled===void 0&&h.disabled&&(h.disabled=!1)},[t,c.disabled,s]);_e(d,[d]);const f=O.useCallback((h={})=>{const{onClick:p,onMouseDown:g,onKeyUp:x,onKeyDown:k,onPointerDown:y,...m}=h;return or({type:r?"button":void 0,onClick(v){if(t){v.preventDefault();return}p?.(v)},onMouseDown(v){t||g?.(v)},onKeyDown(v){if(t||(Gt(v),k?.(v)),v.baseUIHandlerPrevented)return;const z=v.target===v.currentTarget&&!r&&!l()&&!t,_=v.key==="Enter",N=v.key===" ";z&&((N||_)&&v.preventDefault(),_&&p?.(v))},onKeyUp(v){t||(Gt(v),x?.(v)),!v.baseUIHandlerPrevented&&v.target===v.currentTarget&&!r&&!t&&v.key===" "&&p?.(v)},onPointerDown(v){if(t){v.preventDefault();return}y?.(v)}},r?void 0:{role:"button"},c,m)},[t,c,r,l]),u=we(h=>{i.current=h,d()});return{getButtonProps:f,buttonRef:u}}function nl(e){return Kt(e)&&e.tagName==="BUTTON"}let rl=(function(e){return e[e.None=0]="None",e[e.GuessFromOrder=1]="GuessFromOrder",e})({});function ol(e={}){const{label:t,metadata:n,textRef:o,indexGuessBehavior:r,index:i}=e,{register:s,unregister:l,subscribeMapChange:c,elementsRef:d,labelsRef:f,nextIndexRef:u}=ya(),h=O.useRef(-1),[p,g]=O.useState(i??(r===rl.GuessFromOrder?()=>{if(h.current===-1){const y=u.current;u.current+=1,h.current=y}return h.current}:-1)),x=O.useRef(null),k=O.useCallback(y=>{if(x.current=y,p!==-1&&y!==null&&(d.current[p]=y,f)){const m=t!==void 0;f.current[p]=m?t:o?.current?.textContent??y.textContent}},[p,d,f,t,o]);return _e(()=>{if(i!=null)return;const y=x.current;if(y)return s(y,n),()=>{l(y)}},[i,s,l,n]),_e(()=>{if(i==null)return c(y=>{const m=x.current?y.get(x.current)?.index:null;m!=null&&g(m)})},[i,c,g]),O.useMemo(()=>({ref:k,index:p}),[p,k])}function il(e={}){const{highlightItemOnHover:t,highlightedIndex:n,onHighlightedIndexChange:o}=pr(),{ref:r,index:i}=ol(e),s=n===i,l=O.useRef(null),c=ht(r,l);return{compositeProps:O.useMemo(()=>({tabIndex:s?0:-1,onFocus(){o(i)},onMouseMove(){const f=l.current;if(!t||!f)return;const u=f.hasAttribute("disabled")||f.ariaDisabled==="true";!s&&!u&&f.focus()}}),[s,o,i,t]),compositeRef:c,index:i}}function sl(e){const{render:t,className:n,state:o=Ne,props:r=pt,refs:i=pt,metadata:s,stateAttributesMapping:l,tag:c="div",...d}=e,{compositeProps:f,compositeRef:u}=il({metadata:s});return gt(c,e,{state:o,ref:[...i,u],props:[f,...r,d],stateAttributesMapping:l})}const al="none";function ll(e,t,n,o){let r=!1,i=!1;const s=Ne;return{reason:e,event:t??new Event("base-ui"),cancel(){r=!0},allowPropagation(){i=!0},get isCanceled(){return r},get isPropagationAllowed(){return i},trigger:n,...s}}const wr=O.forwardRef(function(t,n){const{className:o,defaultPressed:r=!1,disabled:i=!1,form:s,onPressedChange:l,pressed:c,render:d,type:f,value:u,nativeButton:h=!0,...p}=t,g=Ra(u||void 0),x=Ka(),k=x?.value??[],y=x?void 0:r,m=(i||x?.disabled)??!1,[C,v]=er({controlled:x?k?.indexOf(g)>-1:c,default:y,name:"Toggle",state:"pressed"}),z=we(($,A)=>{g&&x?.setGroupValue?.(g,$,A),l?.($,A)}),{getButtonProps:_,buttonRef:N}=tl({disabled:m,native:h}),E=O.useMemo(()=>({disabled:m,pressed:C}),[m,C]),S=[N,n],w=[{"aria-pressed":C,onClick($){const A=!C,B=ll(al,$.nativeEvent);z(A,B),!B.isCanceled&&v(A)}},p,_],M=gt("button",t,{enabled:!x,state:E,ref:S,props:w});return x?a.jsx(sl,{tag:"button",render:d,className:o,state:E,refs:S,props:w}):M});process.env.NODE_ENV!=="production"&&(wr.displayName="Toggle");function cl({value:e,onChange:t}){const[n,o]=b.useState(""),r=n?Dn.filter(i=>i.toLowerCase().includes(n.toLowerCase())):Dn;return a.jsxs("div",{className:"space-y-2",children:[a.jsxs("div",{className:"relative",children:[a.jsx(An,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-4 h-4 text-zinc-400"}),a.jsx("input",{type:"text",placeholder:"Search icons...",value:n,onChange:i=>o(i.target.value),className:"w-full pl-8 pr-3 py-1.5 text-sm rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]}),a.jsx("div",{className:"grid grid-cols-6 gap-1 max-h-40 overflow-y-auto p-1 bg-zinc-50 dark:bg-zinc-800/50 rounded-lg",children:r.map(i=>{const s=On(i),l=e===i;return a.jsx("button",{onClick:()=>t(i),title:i,className:`
|
|
62
|
+
p-2 rounded-lg transition-colors
|
|
63
|
+
${l?"bg-blue-500 text-white":"hover:bg-zinc-200 dark:hover:bg-zinc-700 text-zinc-600 dark:text-zinc-400"}
|
|
64
|
+
`,children:a.jsx(s,{className:"w-5 h-5 mx-auto"})},i)})}),a.jsxs("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 text-center",children:["Selected: ",e]})]})}const dl={violet:"bg-violet-500",emerald:"bg-emerald-500",blue:"bg-blue-500",amber:"bg-amber-500",zinc:"bg-zinc-500",sky:"bg-sky-500"};function ul({value:e,onChange:t}){return a.jsx("div",{className:"flex items-center gap-2",children:Et.map(n=>a.jsx("button",{onClick:()=>t(n),title:n,className:`
|
|
65
|
+
w-7 h-7 rounded-full transition-all
|
|
66
|
+
${dl[n]}
|
|
67
|
+
${e===n?"ring-2 ring-offset-2 ring-blue-500 dark:ring-offset-zinc-900 scale-110":"hover:scale-110"}
|
|
68
|
+
`},n))})}const Cr=25,Nr=50;function Qe({label:e,value:t,onChange:n,placeholder:o,type:r="text",className:i=""}){return a.jsxs("div",{className:i,children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:e}),a.jsx("input",{type:r,value:t||"",onChange:s=>n(r==="number"?parseInt(s.target.value)||0:s.target.value),placeholder:o,className:"w-full px-3 py-1.5 text-sm rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]})}const zr={xs:"XS",s:"S",m:"M",l:"L"};function hl({value:e,onChange:t}){return a.jsx(xr,{value:e?[e]:["m"],onValueChange:n=>{n.length>0&&t(n[0])},className:"flex gap-1 bg-zinc-100 dark:bg-zinc-800 p-1 rounded-lg",children:Go.map(n=>a.jsx(wr,{value:n,"aria-label":`Size ${zr[n]}`,className:`flex-1 py-1.5 text-xs font-medium rounded-md transition-colors uppercase
|
|
69
|
+
data-[pressed]:bg-blue-500 data-[pressed]:text-white
|
|
70
|
+
hover:bg-zinc-200 dark:hover:bg-zinc-700
|
|
71
|
+
text-zinc-600 dark:text-zinc-400`,children:zr[n]||n},n))})}function fl({nodeId:e}){const{actions:t}=le(),n=ke(),o=Ft(),r=n.nodes[e],i=n.nodeData[e];if(!r||!i)return null;const s=(m,C)=>{t.updateNode(e,{[m]:C})},l=m=>{t.resizeNode(e,m)},c=(m,C)=>{m==="width"?t.resizeNode(e,void 0,C,void 0):t.resizeNode(e,void 0,void 0,C)},d=(m,C)=>{t.updateNodePosition(e,{[m]:C})},f=q[r.size]||q.m,u=r.width||f.width,h=r.height||f.height,p=r.width!==void 0||r.height!==void 0,g=o==="isometric",x=r.z??0,k=r.isoHeight??Cr,y=r.isoDepth??Nr;return a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-900 dark:text-white",children:"Node Properties"}),a.jsx(Qe,{label:"Name",value:i.name,onChange:m=>s("name",m),placeholder:"Node name"}),a.jsx(Qe,{label:"Subtitle",value:i.subtitle,onChange:m=>s("subtitle",m),placeholder:"e.g., Swift, TypeScript"}),a.jsx(Qe,{label:"Description",value:i.description,onChange:m=>s("description",m),placeholder:"Brief description"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Size"}),a.jsx(hl,{value:r.size,onChange:l}),a.jsxs("div",{className:"flex gap-2 mt-2",children:[a.jsx(Qe,{label:"W",type:"number",value:u,onChange:m=>c("width",m),className:"flex-1"}),a.jsx(Qe,{label:"H",type:"number",value:h,onChange:m=>c("height",m),className:"flex-1"})]}),p&&a.jsx("button",{onClick:()=>t.resizeNode(e,r.size||"m"),className:"mt-1 text-xs text-blue-500 hover:text-blue-600",children:"Reset to preset"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Color"}),a.jsx(ul,{value:i.color,onChange:m=>s("color",m)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Icon"}),a.jsx(cl,{value:i.icon,onChange:m=>s("icon",m)})]}),g&&a.jsxs("div",{className:"pt-3 border-t border-zinc-200 dark:border-zinc-700",children:[a.jsxs("h4",{className:"text-xs font-semibold text-zinc-700 dark:text-zinc-300 mb-3 flex items-center gap-2",children:[a.jsx("span",{className:"w-4 h-4 rounded bg-gradient-to-br from-violet-500 to-blue-500"}),"3D Properties"]}),a.jsxs("div",{className:"space-y-3",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Elevation (Z)"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"range",min:"0",max:"200",value:x,onChange:m=>d("z",parseInt(m.target.value)),className:"flex-1 h-1.5 bg-zinc-200 dark:bg-zinc-700 rounded-lg appearance-none cursor-pointer accent-violet-500"}),a.jsx("input",{type:"number",value:x,onChange:m=>d("z",parseInt(m.target.value)||0),className:"w-14 px-2 py-1 text-xs text-center rounded border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Box Height"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"range",min:"10",max:"100",value:k,onChange:m=>d("isoHeight",parseInt(m.target.value)),className:"flex-1 h-1.5 bg-zinc-200 dark:bg-zinc-700 rounded-lg appearance-none cursor-pointer accent-violet-500"}),a.jsx("input",{type:"number",value:k,onChange:m=>d("isoHeight",parseInt(m.target.value)||Cr),className:"w-14 px-2 py-1 text-xs text-center rounded border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Box Depth"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"range",min:"20",max:"120",value:y,onChange:m=>d("isoDepth",parseInt(m.target.value)),className:"flex-1 h-1.5 bg-zinc-200 dark:bg-zinc-700 rounded-lg appearance-none cursor-pointer accent-violet-500"}),a.jsx("input",{type:"number",value:y,onChange:m=>d("isoDepth",parseInt(m.target.value)||Nr),className:"w-14 px-2 py-1 text-xs text-center rounded border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]})]}),(r.z!==void 0||r.isoHeight!==void 0||r.isoDepth!==void 0)&&a.jsx("button",{onClick:()=>{t.updateNodePosition(e,{z:void 0,isoHeight:void 0,isoDepth:void 0})},className:"text-xs text-blue-500 hover:text-blue-600",children:"Reset to defaults"})]})]}),a.jsx("div",{className:"pt-2 border-t border-zinc-200 dark:border-zinc-700",children:a.jsxs("div",{className:"text-xs text-zinc-400 space-y-1",children:[a.jsxs("div",{children:["Position: (",r.x,", ",r.y,")",g&&`, Z: ${x}`]}),a.jsxs("div",{children:["ID: ",e]})]})})]})}function Fe({label:e,value:t,onChange:n,options:o}){return a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:e}),a.jsx("select",{value:t,onChange:r=>n(r.target.value),className:"w-full px-3 py-1.5 text-sm rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800",children:o.map(r=>a.jsx("option",{value:r.value,children:r.label},r.value))})]})}function pl({connectorIndex:e}){const{actions:t,dispatch:n}=le(),o=ke(),r=o.connectors[e];if(!r)return null;const i=o.connectorStyles[r.style],s=(u,h)=>{t.updateConnector(e,{[u]:h})},l=(u,h)=>{n({type:"connectorStyle/update",styleName:r.style,updates:{[u]:h}})},c=Object.keys(o.connectorStyles).map(u=>({value:u,label:`${u} (${o.connectorStyles[u].label||u})`})),d=jo.map(u=>({value:u,label:u})),f=Object.keys(o.nodes).map(u=>({value:u,label:o.nodeData[u]?.name||u}));return a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-900 dark:text-white",children:"Connector Properties"}),a.jsx(Fe,{label:"Style",value:r.style,onChange:u=>s("style",u),options:c}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsx(Fe,{label:"From Node",value:r.from,onChange:u=>s("from",u),options:f}),a.jsx(Fe,{label:"From Anchor",value:r.fromAnchor,onChange:u=>s("fromAnchor",u),options:d})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[a.jsx(Fe,{label:"To Node",value:r.to,onChange:u=>s("to",u),options:f}),a.jsx(Fe,{label:"To Anchor",value:r.toAnchor,onChange:u=>s("toAnchor",u),options:d})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsx(Fe,{label:"Path Style",value:r.curve||"auto",onChange:u=>s("curve",u==="auto"?void 0:u),options:[{value:"auto",label:"Auto (based on anchors)"},{value:"natural",label:"Natural Curve"}]}),r.curve==="natural"&&a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:["Curve Tension: ",r.curveDepth??50,"%"]}),a.jsx("input",{type:"range",min:"20",max:"100",value:r.curveDepth??50,onChange:u=>s("curveDepth",parseInt(u.target.value)),className:"w-full"})]})]}),a.jsxs("div",{className:"pt-3 border-t border-zinc-200 dark:border-zinc-700 space-y-2",children:[a.jsx("div",{className:"text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Style Options"}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:i?.showArrow!==!1,onChange:u=>l("showArrow",u.target.checked),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Show arrow"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:i?.showEndpoints!==!1,onChange:u=>l("showEndpoints",u.target.checked),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Show endpoint dots"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:i?.dashed===!0,onChange:u=>l("dashed",u.target.checked),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Dashed line"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:i?.bidirectional===!0,onChange:u=>l("bidirectional",u.target.checked),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Bidirectional (arrows at both ends)"})]}),i?.dashed&&a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:i?.animated!==!1,onChange:u=>l("animated",u.target.checked),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Animated motion"})]})]}),a.jsx("div",{className:"pt-2 border-t border-zinc-200 dark:border-zinc-700",children:a.jsxs("div",{className:"text-xs text-zinc-400",children:["Index: ",e," | Style: ",r.style]})})]})}function Re({label:e,value:t,onChange:n,placeholder:o,type:r="text",className:i=""}){return a.jsxs("div",{className:i,children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:e}),a.jsx("input",{type:r,value:t||"",onChange:s=>n(r==="number"?parseInt(s.target.value)||0:s.target.value),placeholder:o,className:"w-full px-3 py-1.5 text-sm rounded-lg border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]})}function gl({value:e,onChange:t}){return a.jsx("div",{className:"flex flex-wrap gap-2",children:Et.map(n=>a.jsx("button",{onClick:()=>t(n),className:`
|
|
72
|
+
w-6 h-6 rounded-full transition-all
|
|
73
|
+
${e===n?"ring-2 ring-offset-2 ring-blue-500":""}
|
|
74
|
+
`,style:{backgroundColor:{violet:"#8b5cf6",emerald:"#34d399",blue:"#60a5fa",amber:"#fbbf24",zinc:"#71717a",sky:"#38bdf8"}[n]}},n))})}function yl({value:e,onChange:t}){return a.jsx("div",{className:"flex gap-2",children:["rect","circle"].map(n=>a.jsx("button",{onClick:()=>t(n),className:`
|
|
75
|
+
flex-1 py-1.5 text-xs font-medium rounded-lg transition-colors capitalize
|
|
76
|
+
${e===n?"bg-blue-500 text-white":"bg-zinc-100 dark:bg-zinc-800 hover:bg-zinc-200 dark:hover:bg-zinc-700"}
|
|
77
|
+
`,children:n==="rect"?"Rectangle":"Circle"},n))})}function ml({groupId:e}){const{actions:t}=le(),o=ke().groups?.find(i=>i.id===e);if(!o)return null;const r=(i,s)=>{t.updateGroup(e,{[i]:s})};return a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-900 dark:text-white",children:"Group Properties"}),a.jsx(Re,{label:"Label",value:o.label,onChange:i=>r("label",i),placeholder:"Group label"}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Shape"}),a.jsx(yl,{value:o.type,onChange:i=>r("type",i)})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Color"}),a.jsx(gl,{value:o.color,onChange:i=>r("color",i)})]}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx("input",{type:"checkbox",id:"dashed",checked:o.dashed??!0,onChange:i=>r("dashed",i.target.checked),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("label",{htmlFor:"dashed",className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Dashed border"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-2",children:"Dimensions"}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx(Re,{label:"X",type:"number",value:o.x,onChange:i=>r("x",i)}),a.jsx(Re,{label:"Y",type:"number",value:o.y,onChange:i=>r("y",i)}),a.jsx(Re,{label:"Width",type:"number",value:o.width,onChange:i=>r("width",i)}),a.jsx(Re,{label:"Height",type:"number",value:o.height,onChange:i=>r("height",i)})]})]}),a.jsx("div",{className:"pt-2 border-t border-zinc-200 dark:border-zinc-700",children:a.jsxs("div",{className:"text-xs text-zinc-400",children:["ID: ",e]})})]})}function xl({imageId:e}){const{actions:t}=le(),r=(ke().images||[]).find(l=>l.id===e);if(!r)return null;const i=l=>{t.updateImage(e,l)},s=()=>{t.removeImage(e)};return a.jsxs("div",{className:"space-y-4",children:[a.jsxs("div",{className:"flex items-center justify-between",children:[a.jsx("h3",{className:"font-semibold text-sm text-zinc-900 dark:text-zinc-100",children:"Image"}),a.jsx("button",{onClick:s,className:"p-1.5 text-red-500 hover:bg-red-100 dark:hover:bg-red-900/30 rounded",title:"Delete image",children:a.jsx(Lt,{size:16})})]}),a.jsx("div",{className:"border border-zinc-200 dark:border-zinc-700 rounded-lg p-2 bg-zinc-50 dark:bg-zinc-800",children:a.jsx("img",{src:r.src,alt:r.name||"Dropped image",className:"w-full h-auto max-h-32 object-contain"})}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-600 dark:text-zinc-400 mb-1",children:"Name"}),a.jsx("input",{type:"text",value:r.name||"",onChange:l=>i({name:l.target.value}),className:`w-full px-2 py-1.5 text-sm border border-zinc-200 dark:border-zinc-700 rounded
|
|
78
|
+
bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100
|
|
79
|
+
focus:outline-none focus:ring-2 focus:ring-blue-500`,placeholder:"Image name"})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-600 dark:text-zinc-400 mb-1",children:"X"}),a.jsx("input",{type:"number",value:r.x,onChange:l=>i({x:parseInt(l.target.value)||0}),className:`w-full px-2 py-1.5 text-sm border border-zinc-200 dark:border-zinc-700 rounded
|
|
80
|
+
bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100
|
|
81
|
+
focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-600 dark:text-zinc-400 mb-1",children:"Y"}),a.jsx("input",{type:"number",value:r.y,onChange:l=>i({y:parseInt(l.target.value)||0}),className:`w-full px-2 py-1.5 text-sm border border-zinc-200 dark:border-zinc-700 rounded
|
|
82
|
+
bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100
|
|
83
|
+
focus:outline-none focus:ring-2 focus:ring-blue-500`})]})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-600 dark:text-zinc-400 mb-1",children:"Width"}),a.jsx("input",{type:"number",value:r.width,onChange:l=>i({width:parseInt(l.target.value)||100}),className:`w-full px-2 py-1.5 text-sm border border-zinc-200 dark:border-zinc-700 rounded
|
|
84
|
+
bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100
|
|
85
|
+
focus:outline-none focus:ring-2 focus:ring-blue-500`})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-600 dark:text-zinc-400 mb-1",children:"Height"}),a.jsx("input",{type:"number",value:r.height,onChange:l=>i({height:parseInt(l.target.value)||100}),className:`w-full px-2 py-1.5 text-sm border border-zinc-200 dark:border-zinc-700 rounded
|
|
86
|
+
bg-white dark:bg-zinc-800 text-zinc-900 dark:text-zinc-100
|
|
87
|
+
focus:outline-none focus:ring-2 focus:ring-blue-500`})]})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-600 dark:text-zinc-400 mb-1",children:"Opacity"}),a.jsx("input",{type:"range",min:"0",max:"1",step:"0.1",value:r.opacity??1,onChange:l=>i({opacity:parseFloat(l.target.value)}),className:"w-full"}),a.jsxs("div",{className:"text-xs text-zinc-500 text-right",children:[Math.round((r.opacity??1)*100),"%"]})]})]})}function bl(){const{dispatch:e}=le(),n=ke().grid||kn,o=r=>{e({type:"grid/update",updates:r})};return a.jsxs("div",{className:"space-y-4 pt-4 border-t border-zinc-200 dark:border-zinc-700",children:[a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsx(_n,{className:"w-4 h-4 text-zinc-500"}),a.jsx("h3",{className:"text-sm font-semibold text-zinc-900 dark:text-white",children:"Grid Settings"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:n.enabled,onChange:r=>o({enabled:r.target.checked}),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Show grid"})]}),n.enabled&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Grid Type"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("button",{onClick:()=>o({type:"dots"}),className:`
|
|
88
|
+
flex-1 px-3 py-1.5 text-xs rounded border transition-colors
|
|
89
|
+
${n.type==="dots"?"bg-blue-50 dark:bg-blue-900/30 border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300":"border-zinc-200 dark:border-zinc-700 text-zinc-600 dark:text-zinc-400 hover:bg-zinc-50 dark:hover:bg-zinc-800"}
|
|
90
|
+
`,children:"Dots"}),a.jsx("button",{onClick:()=>o({type:"lines"}),className:`
|
|
91
|
+
flex-1 px-3 py-1.5 text-xs rounded border transition-colors
|
|
92
|
+
${n.type==="lines"?"bg-blue-50 dark:bg-blue-900/30 border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300":"border-zinc-200 dark:border-zinc-700 text-zinc-600 dark:text-zinc-400 hover:bg-zinc-50 dark:hover:bg-zinc-800"}
|
|
93
|
+
`,children:"Lines"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:["Grid Size: ",n.size,"px"]}),a.jsx("input",{type:"range",min:"10",max:"50",value:n.size,onChange:r=>o({size:parseInt(r.target.value)}),className:"w-full"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Grid Color"}),a.jsxs("div",{className:"flex gap-2",children:[Uo.map(({name:r,value:i})=>a.jsx("button",{onClick:()=>o({color:i}),className:`
|
|
94
|
+
w-6 h-6 rounded-full border-2 transition-all
|
|
95
|
+
${n.color===i?"ring-2 ring-offset-2 ring-blue-500 dark:ring-offset-zinc-900":"border-transparent"}
|
|
96
|
+
`,style:{backgroundColor:i},title:r},i)),a.jsx("input",{type:"color",value:n.color,onChange:r=>o({color:r.target.value}),className:"w-6 h-6 rounded cursor-pointer border-0 p-0",title:"Custom color"})]})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:["Opacity: ",Math.round(n.opacity*100),"%"]}),a.jsx("input",{type:"range",min:"5",max:"50",value:n.opacity*100,onChange:r=>o({opacity:parseInt(r.target.value)/100}),className:"w-full"})]})]})]})}const en={violet:"bg-violet-500",emerald:"bg-emerald-500",blue:"bg-blue-500",amber:"bg-amber-500",zinc:"bg-zinc-500",sky:"bg-sky-500"};function kl({styleName:e,style:t,onUpdate:n,onDelete:o,connectorsUsingStyle:r}){const[i,s]=b.useState(!1);return a.jsxs("div",{className:"border border-zinc-200 dark:border-zinc-700 rounded-lg overflow-hidden",children:[a.jsxs("button",{onClick:()=>s(!i),className:"w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-zinc-50 dark:hover:bg-zinc-800/50",children:[i?a.jsx(Cn,{className:"w-4 h-4 text-zinc-400"}):a.jsx(Nn,{className:"w-4 h-4 text-zinc-400"}),a.jsx("div",{className:`w-3 h-3 rounded-full ${en[t.color]}`}),a.jsx("span",{className:"text-sm font-medium text-zinc-900 dark:text-white flex-1",children:e}),a.jsxs("span",{className:"text-xs text-zinc-400",children:[r," connection",r!==1?"s":""]})]}),i&&a.jsxs("div",{className:"px-3 pb-3 pt-1 space-y-3 border-t border-zinc-200 dark:border-zinc-700",children:[a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Label"}),a.jsx("input",{type:"text",value:t.label||"",onChange:l=>n({label:l.target.value}),placeholder:"Optional label",className:"w-full px-2 py-1.5 text-sm rounded border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"})]}),a.jsxs("div",{children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Color"}),a.jsx("div",{className:"flex gap-1.5",children:Et.map(l=>a.jsx("button",{onClick:()=>n({color:l}),className:`
|
|
97
|
+
w-6 h-6 rounded-full ${en[l]}
|
|
98
|
+
${t.color===l?"ring-2 ring-offset-2 ring-blue-500 dark:ring-offset-zinc-900":""}
|
|
99
|
+
`},l))})]}),a.jsxs("div",{children:[a.jsxs("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:["Stroke Width: ",t.strokeWidth||2]}),a.jsx("input",{type:"range",min:"1",max:"6",value:t.strokeWidth||2,onChange:l=>n({strokeWidth:parseInt(l.target.value)}),className:"w-full"})]}),a.jsxs("div",{className:"space-y-2",children:[a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.dashed===!0,onChange:l=>n({dashed:l.target.checked}),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Dashed"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.showArrow!==!1,onChange:l=>n({showArrow:l.target.checked}),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Show arrow"})]}),a.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[a.jsx("input",{type:"checkbox",checked:t.showEndpoints!==!1,onChange:l=>n({showEndpoints:l.target.checked}),className:"rounded border-zinc-300 dark:border-zinc-600"}),a.jsx("span",{className:"text-sm text-zinc-600 dark:text-zinc-400",children:"Show endpoint dots"})]})]}),r===0&&a.jsxs("button",{onClick:o,className:"flex items-center gap-1.5 text-xs text-red-600 dark:text-red-400 hover:text-red-700",children:[a.jsx(Lt,{className:"w-3.5 h-3.5"}),"Delete style"]})]})]})}function vl(){const{dispatch:e,actions:t}=le(),n=ke(),[o,r]=b.useState(""),[i,s]=b.useState(!0),l={};for(const u of Object.keys(n.connectorStyles))l[u]=n.connectors.filter(h=>h.style===u).length;const c=(u,h)=>{e({type:"connectorStyle/update",styleName:u,updates:h})},d=()=>{if(!o.trim())return;const u=o.toLowerCase().replace(/[^a-z0-9]/g,"");!u||n.connectorStyles[u]||(e({type:"connectorStyle/add",styleName:u,style:{color:"zinc",strokeWidth:2,label:o,dashed:!1,showArrow:!0,showEndpoints:!0}}),r(""))},f=u=>{e({type:"connectorStyle/delete",styleName:u})};return a.jsxs("div",{className:"space-y-4",children:[a.jsx("h3",{className:"text-sm font-semibold text-zinc-900 dark:text-white",children:"Connector Styles"}),a.jsx("p",{className:"text-xs text-zinc-500 dark:text-zinc-400",children:"Define reusable styles for connectors. Click a style to edit it."}),a.jsx("div",{className:"space-y-2",children:Object.entries(n.connectorStyles).map(([u,h])=>a.jsx(kl,{styleName:u,style:h,onUpdate:p=>c(u,p),onDelete:()=>f(u),connectorsUsingStyle:l[u]||0},u))}),a.jsxs("div",{className:"pt-3 border-t border-zinc-200 dark:border-zinc-700",children:[a.jsx("label",{className:"block text-xs font-medium text-zinc-500 dark:text-zinc-400 mb-1",children:"Add New Style"}),a.jsxs("div",{className:"flex gap-2",children:[a.jsx("input",{type:"text",value:o,onChange:u=>r(u.target.value),onKeyDown:u=>u.key==="Enter"&&d(),placeholder:"Style name...",className:"flex-1 px-2 py-1.5 text-sm rounded border border-zinc-200 dark:border-zinc-700 bg-white dark:bg-zinc-800"}),a.jsx("button",{onClick:d,disabled:!o.trim(),className:"px-3 py-1.5 text-sm bg-blue-500 text-white rounded hover:bg-blue-600 disabled:opacity-50 disabled:cursor-not-allowed",children:a.jsx(Sn,{className:"w-4 h-4"})})]})]}),a.jsxs("div",{className:"pt-4 mt-4 border-t border-zinc-200 dark:border-zinc-700",children:[a.jsxs("button",{onClick:()=>s(!i),className:"flex items-center gap-2 text-sm font-semibold text-zinc-900 dark:text-white mb-2",children:[i?a.jsx(Cn,{className:"w-4 h-4"}):a.jsx(Nn,{className:"w-4 h-4"}),"Connections (",n.connectors.length,")"]}),i&&a.jsx("div",{className:"space-y-1",children:n.connectors.map((u,h)=>{const p=n.nodeData[u.from]?.name||u.from,g=n.nodeData[u.to]?.name||u.to,x=n.connectorStyles[u.style];return a.jsxs("button",{onClick:()=>t.selectConnector(h),className:"w-full flex items-center gap-2 px-2 py-1.5 text-left text-xs rounded hover:bg-zinc-100 dark:hover:bg-zinc-800",children:[a.jsx("div",{className:`w-2 h-2 rounded-full ${en[x?.color]||"bg-zinc-400"}`}),a.jsxs("span",{className:"text-zinc-600 dark:text-zinc-400 truncate",children:[p," → ",g]}),a.jsx("span",{className:"text-zinc-400 dark:text-zinc-500 ml-auto",children:u.style})]},h)})})]}),a.jsx(bl,{})]})}function wl(){const e=je(),t=e.selectedNodeIds?.length>0,n=e.selectedConnectorIndex!==null,o=e.selectedGroupId!==null,r=e.selectedImageId!==null,i=t||n||o||r,s=e.selectedNodeIds?.[0];return a.jsx("div",{className:"w-72 flex-shrink-0 bg-white dark:bg-zinc-900 border-l border-zinc-200 dark:border-zinc-800 overflow-y-auto",children:a.jsxs("div",{className:"p-4",children:[t&&a.jsxs(a.Fragment,{children:[e.selectedNodeIds.length>1&&a.jsxs("div",{className:"mb-3 px-2 py-1 bg-blue-100 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 text-xs rounded",children:[e.selectedNodeIds.length," nodes selected"]}),a.jsx(fl,{nodeId:s})]}),n&&a.jsx(pl,{connectorIndex:e.selectedConnectorIndex}),o&&a.jsx(ml,{groupId:e.selectedGroupId}),r&&a.jsx(xl,{imageId:e.selectedImageId}),!i&&a.jsx(vl,{})]})})}function Mr(e,t,n,o,r){switch(r){case"left":return{x:e,y:t+o/2};case"right":return{x:e+n,y:t+o/2};case"top":return{x:e+n/2,y:t};case"bottom":return{x:e+n/2,y:t+o};case"bottomRight":return{x:e+n,y:t+o-15};case"bottomLeft":return{x:e,y:t+o-15};case"topRight":return{x:e+n,y:t+15};case"topLeft":return{x:e,y:t+15};default:return{x:e+n/2,y:t+o/2}}}function Cl(e,t,n,o){const r=t.x-e.x,i=t.y-e.y;let s=e.x,l=e.y,c=t.x,d=t.y;const f=Math.min(Math.abs(r),Math.abs(i),50);return n==="right"||n==="bottomRight"||n==="topRight"?s=e.x+f:n==="left"||n==="bottomLeft"||n==="topLeft"?s=e.x-f:n==="bottom"?l=e.y+f:n==="top"&&(l=e.y-f),o==="left"||o==="bottomLeft"||o==="topLeft"?c=t.x-f:o==="right"||o==="bottomRight"||o==="topRight"?c=t.x+f:o==="top"?d=t.y-f:o==="bottom"&&(d=t.y+f),`M ${e.x} ${e.y} C ${s} ${l}, ${c} ${d}, ${t.x} ${t.y}`}const tn={violet:{bg:"#8b5cf6",text:"#ffffff"},emerald:{bg:"#34d399",text:"#ffffff"},blue:{bg:"#60a5fa",text:"#ffffff"},amber:{bg:"#fbbf24",text:"#1f2937"},zinc:{bg:"#71717a",text:"#ffffff"},sky:{bg:"#38bdf8",text:"#ffffff"}},_r={violet:{fill:"rgba(139, 92, 246, 0.1)",stroke:"rgba(139, 92, 246, 0.5)"},emerald:{fill:"rgba(52, 211, 153, 0.1)",stroke:"rgba(52, 211, 153, 0.5)"},blue:{fill:"rgba(96, 165, 250, 0.1)",stroke:"rgba(96, 165, 250, 0.5)"},amber:{fill:"rgba(251, 191, 36, 0.1)",stroke:"rgba(251, 191, 36, 0.5)"},zinc:{fill:"rgba(113, 113, 122, 0.1)",stroke:"rgba(113, 113, 122, 0.5)"},sky:{fill:"rgba(56, 189, 248, 0.1)",stroke:"rgba(56, 189, 248, 0.5)"}};function nn(e,t={}){const{backgroundColor:n="#ffffff",includeGrid:o=!1,padding:r=20}=t,i=e.exportZone||{x:0,y:0,width:e.layout.width,height:e.layout.height},s=`${i.x-r} ${i.y-r} ${i.width+r*2} ${i.height+r*2}`,l=i.width+r*2,c=i.height+r*2;let d=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${c}" viewBox="${s}">
|
|
100
|
+
`;if(d+=` <rect x="${i.x-r}" y="${i.y-r}" width="${i.width+r*2}" height="${i.height+r*2}" fill="${n}"/>
|
|
101
|
+
`,o&&e.grid?.enabled){const h=e.grid.size||20,p=e.grid.color||"#e5e7eb";d+=` <defs>
|
|
102
|
+
`,d+=` <pattern id="grid" width="${h}" height="${h}" patternUnits="userSpaceOnUse">
|
|
103
|
+
`,e.grid.type==="dots"?d+=` <circle cx="${h/2}" cy="${h/2}" r="1" fill="${p}"/>
|
|
104
|
+
`:d+=` <path d="M ${h} 0 L 0 0 0 ${h}" fill="none" stroke="${p}" stroke-width="0.5"/>
|
|
105
|
+
`,d+=` </pattern>
|
|
106
|
+
`,d+=` </defs>
|
|
107
|
+
`,d+=` <rect x="${i.x-r}" y="${i.y-r}" width="${i.width+r*2}" height="${i.height+r*2}" fill="url(#grid)"/>
|
|
108
|
+
`}const f=e.groups||[];for(const h of f){const p=_r[h.color]||_r.zinc;h.type==="circle"?d+=` <ellipse cx="${h.x+h.width/2}" cy="${h.y+h.height/2}" rx="${h.width/2}" ry="${h.height/2}" fill="${p.fill}" stroke="${p.stroke}" stroke-width="1.5"${h.dashed?' stroke-dasharray="8 4"':""}/>
|
|
109
|
+
`:d+=` <rect x="${h.x}" y="${h.y}" width="${h.width}" height="${h.height}" rx="12" fill="${p.fill}" stroke="${p.stroke}" stroke-width="1.5"${h.dashed?' stroke-dasharray="8 4"':""}/>
|
|
110
|
+
`,h.label&&(d+=` <text x="${h.x+12}" y="${h.y+20}" fill="${p.stroke}" font-size="12" font-weight="500" font-family="ui-sans-serif, system-ui, sans-serif">${wt(h.label)}</text>
|
|
111
|
+
`)}const u=e.images||[];for(const h of u)d+=` <image href="${h.src}" x="${h.x}" y="${h.y}" width="${h.width}" height="${h.height}" opacity="${h.opacity??1}" preserveAspectRatio="xMidYMid meet"/>
|
|
112
|
+
`;for(const h of e.connectors){const p=e.nodes[h.from],g=e.nodes[h.to];if(!p||!g)continue;e.nodeData[h.from],e.nodeData[h.to];const x=q[p.size]||q.m,k=q[g.size]||q.m,y=e.connectorStyles?.[h.style]||{color:"zinc",strokeWidth:2},m=tn[y.color]?.bg||"#71717a",C=Mr(p.x,p.y,p.width||x.width,p.height||x.height,h.fromAnchor),v=Mr(g.x,g.y,g.width||k.width,g.height||k.height,h.toAnchor),z=Cl(C,v,h.fromAnchor,h.toAnchor);if(d+=` <path d="${z}" fill="none" stroke="${m}" stroke-width="${y.strokeWidth||2}"${y.dashed?' stroke-dasharray="6 3"':""}/>
|
|
113
|
+
`,d+=` <circle cx="${v.x}" cy="${v.y}" r="4" fill="${m}"/>
|
|
114
|
+
`,y.label){const _=(C.x+v.x)/2,N=(C.y+v.y)/2;d+=` <text x="${_}" y="${N-8}" text-anchor="middle" fill="${m}" font-size="10" font-family="ui-sans-serif, system-ui, sans-serif">${wt(y.label)}</text>
|
|
115
|
+
`}}for(const[h,p]of Object.entries(e.nodes)){const g=e.nodeData[h];if(!g)continue;const x=q[p.size]||q.m,k=p.width||x.width,y=p.height||x.height,m=tn[g.color]||tn.zinc;d+=` <rect x="${p.x}" y="${p.y}" width="${k}" height="${y}" rx="12" fill="${m.bg}"/>
|
|
116
|
+
`;const C=p.size==="xs"?10:p.size==="s"?11:13;d+=` <text x="${p.x+k/2}" y="${p.y+y/2+C/3}" text-anchor="middle" fill="${m.text}" font-size="${C}" font-weight="600" font-family="ui-sans-serif, system-ui, sans-serif">${wt(g.name||"Node")}</text>
|
|
117
|
+
`,g.subtitle&&y>=60&&(d+=` <text x="${p.x+k/2}" y="${p.y+y/2+C+8}" text-anchor="middle" fill="${m.text}" opacity="0.8" font-size="${C-2}" font-family="ui-sans-serif, system-ui, sans-serif">${wt(g.subtitle)}</text>
|
|
118
|
+
`)}return d+="</svg>",d}async function Nl(e,t={}){const{scale:n=2,backgroundColor:o="#ffffff"}=t,r=nn(e,{backgroundColor:o,...t}),i=new Blob([r],{type:"image/svg+xml;charset=utf-8"}),s=URL.createObjectURL(i);return new Promise((l,c)=>{const d=new Image;d.onload=()=>{const f=document.createElement("canvas");f.width=d.width*n,f.height=d.height*n;const u=f.getContext("2d");u.scale(n,n),u.drawImage(d,0,0),URL.revokeObjectURL(s),f.toBlob(h=>{h?l(h):c(new Error("Failed to generate PNG"))},"image/png")},d.onerror=()=>{URL.revokeObjectURL(s),c(new Error("Failed to load SVG"))},d.src=s})}function zl(e){const t={l:e.layout,n:e.nodes,d:e.nodeData,c:e.connectors,s:e.connectorStyles,g:e.groups,i:e.images,e:e.exportZone},n=JSON.stringify(t),o=btoa(encodeURIComponent(n));return`${window.location.origin+window.location.pathname}#/view/${o}`}function $r(e,t,n){const o=e instanceof Blob?e:new Blob([e],{type:n}),r=URL.createObjectURL(o),i=document.createElement("a");i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r)}function wt(e){return e?e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"):""}function Ml(e){const t=e.exportZone||{x:0,y:0,width:e.layout.width,height:e.layout.height},n=50,o={},r={};for(const[d,f]of Object.entries(e.nodes)){const u=e.nodeData[d];if(!u)continue;const h=q[f.size]||q.m,p=f.x+(f.width||h.width),g=f.y+(f.height||h.height);f.x<t.x+t.width+n&&p>t.x-n&&f.y<t.y+t.height+n&&g>t.y-n&&(o[d]={x:f.x-t.x,y:f.y-t.y,size:f.size||"m"},r[d]={icon:u.icon||"Box",name:u.name||"Node",...u.subtitle&&{subtitle:u.subtitle},...u.description&&{description:u.description},color:u.color||"zinc"})}const i=e.connectors.filter(d=>o[d.from]&&o[d.to]).map(d=>({from:d.from,to:d.to,fromAnchor:d.fromAnchor,toAnchor:d.toAnchor,style:d.style,...d.curve&&{curve:d.curve}})),s=new Set(i.map(d=>d.style)),l={};for(const d of s){const f=e.connectorStyles?.[d];f&&(l[d]={color:f.color||"zinc",strokeWidth:f.strokeWidth||2,...f.label&&{label:f.label},...f.dashed&&{dashed:!0}})}const c={layout:{width:t.width,height:t.height},nodes:o,nodeData:r,connectors:i,connectorStyles:l};return`import type { ArcDiagramData } from '../ArcDiagram'
|
|
119
|
+
|
|
120
|
+
const diagram: ArcDiagramData = ${Ct(c)}
|
|
121
|
+
|
|
122
|
+
export default diagram
|
|
123
|
+
`}function Ct(e,t=0){const n=" ".repeat(t),o=" ".repeat(t+1);if(e==null)return"null";if(typeof e=="string")return`'${e.replace(/'/g,"\\'")}'`;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return e.length===0?"[]":`[
|
|
124
|
+
${e.map(i=>`${o}${Ct(i,t+1)}`).join(`,
|
|
125
|
+
`)},
|
|
126
|
+
${n}]`;if(typeof e=="object"){const r=Object.entries(e);return r.length===0?"{}":r.every(([,l])=>typeof l!="object"||l===null)&&JSON.stringify(e).length<80&&t>0?`{ ${r.map(([c,d])=>`${c}: ${Ct(d,t+1)}`).join(", ")} }`:`{
|
|
127
|
+
${r.map(([l,c])=>{const d=/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(l)?l:`'${l}'`;return`${o}${d}: ${Ct(c,t+1)}`}).join(`,
|
|
128
|
+
`)},
|
|
129
|
+
${n}}`}return String(e)}async function _l(e,t="diagram.json"){const n=JSON.stringify(e,null,2),o=new Blob([n],{type:"application/json"});try{if("showSaveFilePicker"in window){const s=await window.showSaveFilePicker({suggestedName:t,types:[{description:"Arc Diagram",accept:{"application/json":[".json"]}}]}),l=await s.createWritable();return await l.write(o),await l.close(),s.name}}catch(s){if(s.name==="AbortError")return null;console.error("Save failed:",s)}const r=URL.createObjectURL(o),i=document.createElement("a");return i.href=r,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r),t}async function $l(){try{if("showOpenFilePicker"in window){const[e]=await window.showOpenFilePicker({types:[{description:"Arc Diagram",accept:{"application/json":[".json"]}}]}),n=await(await e.getFile()).text();return{diagram:JSON.parse(n),filename:e.name}}}catch(e){if(e.name==="AbortError")return null;console.error("Load failed:",e)}return new Promise(e=>{const t=document.createElement("input");t.type="file",t.accept=".json",t.onchange=async n=>{const o=n.target.files?.[0];if(!o){e(null);return}try{const r=await o.text(),i=JSON.parse(r);e({diagram:i,filename:o.name})}catch(r){console.error("Parse error:",r),e(null)}},t.click()})}async function rn(e){try{return await navigator.clipboard.writeText(e),!0}catch(t){return console.error("Copy failed:",t),!1}}function et({icon:e,label:t,description:n,onClick:o,loading:r=!1,success:i=!1,secondary:s=!1}){return a.jsxs("button",{onClick:o,disabled:r,className:`
|
|
130
|
+
w-full flex items-start gap-3 p-3 rounded-lg text-left transition-colors
|
|
131
|
+
${s?"bg-zinc-50 dark:bg-zinc-800/50 hover:bg-zinc-100 dark:hover:bg-zinc-800":"bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 hover:border-blue-300 dark:hover:border-blue-600"}
|
|
132
|
+
${r?"opacity-60 cursor-wait":""}
|
|
133
|
+
`,children:[a.jsx("div",{className:`
|
|
134
|
+
p-2 rounded-lg
|
|
135
|
+
${i?"bg-green-100 dark:bg-green-900/30":"bg-zinc-100 dark:bg-zinc-700"}
|
|
136
|
+
`,children:r?a.jsx($i,{className:"w-5 h-5 animate-spin text-zinc-500"}):i?a.jsx(ci,{className:"w-5 h-5 text-green-600 dark:text-green-400"}):a.jsx(e,{className:"w-5 h-5 text-zinc-600 dark:text-zinc-400"})}),a.jsxs("div",{className:"flex-1 min-w-0",children:[a.jsx("div",{className:"font-medium text-sm text-zinc-900 dark:text-zinc-100",children:i?"Done!":t}),a.jsx("div",{className:"text-xs text-zinc-500 dark:text-zinc-400 mt-0.5",children:n})]})]})}function Sl({diagram:e,cropBounds:t,onCropChange:n}){const o=b.useRef(null),[r,i]=b.useState(null),[s,l]=b.useState(null),c=450,d=250,f=Math.min(c/e.layout.width,d/e.layout.height)*.9,u=e.layout.width*f,h=e.layout.height*f,p=t.x*f,g=t.y*f,x=t.width*f,k=t.height*f,y=b.useCallback(_=>{if(!o.current)return{x:0,y:0};const N=o.current.getBoundingClientRect();return{x:(_.clientX-N.left-(c-u)/2)/f,y:(_.clientY-N.top-(d-h)/2)/f}},[f,u,h]),m=b.useCallback((_,N)=>{_.preventDefault(),_.stopPropagation(),i(N),l({mouse:y(_),bounds:{...t}})},[t,y]),C=b.useCallback(_=>{if(!r||!s)return;const N=y(_),E=N.x-s.mouse.x,S=N.y-s.mouse.y,{bounds:w}=s;let M={...w};if(r==="move")M.x=Math.max(0,Math.min(e.layout.width-w.width,w.x+E)),M.y=Math.max(0,Math.min(e.layout.height-w.height,w.y+S));else{if(r.includes("w")){const $=w.x+E,A=w.width-E;A>=50&&$>=0&&(M.x=$,M.width=A)}if(r.includes("e")){const $=w.width+E;$>=50&&w.x+$<=e.layout.width&&(M.width=$)}if(r.includes("n")){const $=w.y+S,A=w.height-S;A>=50&&$>=0&&(M.y=$,M.height=A)}if(r.includes("s")){const $=w.height+S;$>=50&&w.y+$<=e.layout.height&&(M.height=$)}}n({x:Math.round(M.x),y:Math.round(M.y),width:Math.round(M.width),height:Math.round(M.height)})},[r,s,e.layout,y,n]),v=b.useCallback(()=>{i(null),l(null)},[]),z=b.useMemo(()=>nn(e,{backgroundColor:"#f4f4f5",padding:0}),[e]);return a.jsxs("div",{ref:o,className:"relative bg-zinc-200 dark:bg-zinc-700 rounded-lg overflow-hidden select-none",style:{width:c,height:d},onMouseMove:r?C:void 0,onMouseUp:r?v:void 0,onMouseLeave:r?v:void 0,children:[a.jsxs("div",{className:"absolute",style:{left:(c-u)/2,top:(d-h)/2,width:u,height:h},children:[a.jsx("div",{className:"w-full h-full opacity-40",dangerouslySetInnerHTML:{__html:z},style:{pointerEvents:"none"}}),a.jsxs("svg",{className:"absolute inset-0 w-full h-full",viewBox:`0 0 ${u} ${h}`,children:[a.jsx("defs",{children:a.jsxs("mask",{id:"cropMask",children:[a.jsx("rect",{width:"100%",height:"100%",fill:"white"}),a.jsx("rect",{x:p,y:g,width:x,height:k,fill:"black"})]})}),a.jsx("rect",{width:"100%",height:"100%",fill:"rgba(0,0,0,0.5)",mask:"url(#cropMask)"}),a.jsx("rect",{x:p,y:g,width:x,height:k,fill:"none",stroke:"#3b82f6",strokeWidth:2,className:"cursor-move",onMouseDown:_=>m(_,"move")}),[{x:p,y:g,cursor:"nwse-resize",type:"nw"},{x:p+x,y:g,cursor:"nesw-resize",type:"ne"},{x:p,y:g+k,cursor:"nesw-resize",type:"sw"},{x:p+x,y:g+k,cursor:"nwse-resize",type:"se"}].map(({x:_,y:N,cursor:E,type:S})=>a.jsx("circle",{cx:_,cy:N,r:6,fill:"#3b82f6",className:`cursor-${E}`,style:{cursor:E},onMouseDown:w=>m(w,S)},S))]})]}),a.jsxs("div",{className:"absolute bottom-2 right-2 px-2 py-1 bg-black/60 rounded text-xs text-white font-mono",children:[Math.round(t.width)," × ",Math.round(t.height)]})]})}function Al({diagram:e,viewportBounds:t,onClose:n}){const[o,r]=b.useState(()=>{if(t&&t.width>0)return{x:Math.max(0,Math.round(t.x)),y:Math.max(0,Math.round(t.y)),width:Math.round(Math.min(t.width,e.layout.width)),height:Math.round(Math.min(t.height,e.layout.height))};const A=Math.min(800,e.layout.width*.8),B=Math.min(600,e.layout.height*.8);return{x:Math.round((e.layout.width-A)/2),y:Math.round((e.layout.height-B)/2),width:Math.round(A),height:Math.round(B)}}),[i,s]=b.useState(!1),[l,c]=b.useState(!1),[d,f]=b.useState(!1),[u,h]=b.useState(!1),[p,g]=b.useState(!1),[x,k]=b.useState(!1),[y,m]=b.useState(!1),C=b.useMemo(()=>({...e,exportZone:o}),[e,o]),v=b.useMemo(()=>JSON.stringify(C,null,2),[C]),z=b.useMemo(()=>Ml(C),[C]),_=b.useMemo(()=>zl(C),[C]),N=async()=>{await rn(v)&&(s(!0),setTimeout(()=>s(!1),2e3))},E=async()=>{await rn(z)&&(c(!0),setTimeout(()=>c(!1),2e3))},S=async()=>{await rn(_)&&(f(!0),setTimeout(()=>f(!1),2e3))},w=async()=>{h(!0);try{const A=nn(C,{backgroundColor:"#ffffff"});$r(A,"diagram.svg","image/svg+xml"),k(!0),setTimeout(()=>k(!1),2e3)}finally{h(!1)}},M=async()=>{g(!0);try{const A=await Nl(C,{scale:2,backgroundColor:"#ffffff"});$r(A,"diagram.png","image/png"),m(!0),setTimeout(()=>m(!1),2e3)}catch(A){console.error("PNG generation failed:",A)}finally{g(!1)}},$=()=>{r({x:0,y:0,width:e.layout.width,height:e.layout.height})};return a.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/50",children:a.jsxs("div",{className:"w-full max-w-xl bg-zinc-100 dark:bg-zinc-900 rounded-2xl shadow-2xl overflow-hidden",children:[a.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-white dark:bg-zinc-800 border-b border-zinc-200 dark:border-zinc-700",children:[a.jsx("h2",{className:"text-lg font-semibold text-zinc-900 dark:text-white",children:"Share"}),a.jsxs("div",{className:"flex items-center gap-2",children:[a.jsxs("button",{onClick:$,className:"flex items-center gap-1 px-2 py-1 text-xs text-zinc-600 dark:text-zinc-400 hover:bg-zinc-100 dark:hover:bg-zinc-700 rounded transition-colors",title:"Reset to full canvas",children:[a.jsx(ji,{className:"w-3 h-3"}),"Reset"]}),a.jsx("button",{onClick:n,className:"p-1.5 rounded-lg hover:bg-zinc-100 dark:hover:bg-zinc-700 transition-colors",children:a.jsx(as,{className:"w-5 h-5"})})]})]}),a.jsx("div",{className:"p-4 flex justify-center",children:a.jsx(Sl,{diagram:e,cropBounds:o,onCropChange:r})}),a.jsxs("div",{className:"px-4 pb-4 space-y-2",children:[a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx(et,{icon:Mn,label:"Copy TypeScript",description:"ArcDiagram format",onClick:E,success:l}),a.jsx(et,{icon:ii,label:"Copy JSON",description:"Raw data",onClick:N,success:i})]}),a.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[a.jsx(et,{icon:yi,label:"Download SVG",description:"Vector",onClick:w,loading:u,success:x,secondary:!0}),a.jsx(et,{icon:Ni,label:"Download PNG",description:"2x resolution",onClick:M,loading:p,success:y,secondary:!0})]}),a.jsx(et,{icon:_i,label:"Copy Link",description:"Shareable URL with embedded data",onClick:S,success:d,secondary:!0})]})]})})}function Il({onDelete:e,onUndo:t,onRedo:n,onSave:o,onNew:r,onEscape:i,onSetMode:s}){const l=b.useCallback(c=>{if(c.target.tagName==="INPUT"||c.target.tagName==="TEXTAREA"){c.key==="Escape"&&c.target.blur();return}const d=c.metaKey||c.ctrlKey;if((c.key==="Delete"||c.key==="Backspace")&&!d){c.preventDefault(),e?.();return}if(c.key==="Escape"){c.preventDefault(),i?.();return}if(d&&c.key==="z"&&!c.shiftKey){c.preventDefault(),t?.();return}if(d&&c.key==="z"&&c.shiftKey){c.preventDefault(),n?.();return}if(d&&c.key==="s"){c.preventDefault(),o?.();return}if(d&&c.key==="n"){c.preventDefault(),r?.();return}if(!d&&!c.shiftKey&&!c.altKey)switch(c.key.toLowerCase()){case"v":c.preventDefault(),s?.("select");return;case"h":c.preventDefault(),s?.("pan");return;case"n":c.preventDefault(),s?.("addNode");return;case"c":c.preventDefault(),s?.("addConnector");return}},[e,t,n,o,r,i,s]);b.useEffect(()=>(window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)),[l])}const El={layout:{width:1600,height:900},grid:{enabled:!0,size:24,color:"#71717a",opacity:.1,type:"dots"},nodes:{talkie:{x:50,y:45,size:"l"},talkieLive:{x:50,y:155,size:"m"},talkieEngine:{x:50,y:255,size:"m"},talkieServer:{x:360,y:55,size:"m"},iCloud:{x:380,y:255,size:"m"},iPhone:{x:600,y:55,size:"m"},watch:{x:620,y:155,size:"s"}},nodeData:{talkie:{icon:"Monitor",name:"Talkie",subtitle:"Swift/SwiftUI",description:"UI, Workflows, Data, Orchestration",color:"violet"},talkieLive:{icon:"Mic",name:"TalkieLive",subtitle:"Swift",description:"Ears & Hands",color:"emerald"},talkieEngine:{icon:"Cpu",name:"TalkieEngine",subtitle:"Swift",description:"Local Brain",color:"blue"},talkieServer:{icon:"Server",name:"TalkieServer",subtitle:"TypeScript",description:"iOS Bridge",color:"amber"},iCloud:{icon:"Cloud",name:"iCloud",subtitle:"CloudKit",description:"Memo Sync",color:"sky"},iPhone:{icon:"Smartphone",name:"iPhone",subtitle:"iOS",description:"Voice Capture",color:"zinc"},watch:{icon:"Watch",name:"Watch",subtitle:"watchOS",color:"zinc"}},connectors:[{from:"talkie",to:"talkieLive",fromAnchor:"bottom",toAnchor:"top",style:"xpc"},{from:"talkieLive",to:"talkieEngine",fromAnchor:"bottom",toAnchor:"top",style:"audio"},{from:"talkie",to:"talkieServer",fromAnchor:"right",toAnchor:"left",style:"http"},{from:"talkieServer",to:"iPhone",fromAnchor:"right",toAnchor:"left",style:"tailscale"},{from:"iPhone",to:"watch",fromAnchor:"bottom",toAnchor:"top",style:"peer"},{from:"talkie",to:"iCloud",fromAnchor:"bottomRight",toAnchor:"left",style:"cloudkit",curve:"natural"},{from:"iPhone",to:"iCloud",fromAnchor:"bottomLeft",toAnchor:"right",style:"cloudkit",curve:"natural"}],connectorStyles:{xpc:{color:"sky",strokeWidth:2,label:"",dashed:!0},http:{color:"amber",strokeWidth:2,label:"HTTP",dashed:!0},tailscale:{color:"sky",strokeWidth:2,label:"Tailscale",dashed:!0},cloudkit:{color:"sky",strokeWidth:2,label:"",dashed:!0},audio:{color:"sky",strokeWidth:2,label:"",dashed:!0},peer:{color:"sky",strokeWidth:2,label:"",dashed:!0}}};function Dl({isDark:e,onToggleTheme:t}){const{actions:n}=le(),o=ke(),r=je(),i=Hn(),[s,l]=b.useState(!1),[c,d]=b.useState(null);gs({title:"Arc Editor | Visual Diagram Builder",description:"Drag-and-drop diagram builder with real-time preview and JSON export.",image:"/og-editor.png",url:"/editor"});const f=b.useCallback(()=>{i.isDirty&&!window.confirm("Discard unsaved changes?")||n.newDiagram()},[i.isDirty,n]),u=b.useCallback(async()=>{if(i.isDirty&&!window.confirm("Discard unsaved changes?"))return;const k=await $l();k&&n.loadDiagram(k.diagram,k.filename)},[i.isDirty,n]),h=b.useCallback(async()=>{const k=await _l(o,i.filename||"diagram.json");k&&n.markSaved(k)},[o,i.filename,n]),p=b.useCallback(()=>{l(!0)},[]),g=b.useCallback(()=>{if(r.selectedNodeIds?.length>0)for(const k of r.selectedNodeIds)n.removeNode(k);else r.selectedConnectorIndex!==null?n.removeConnector(r.selectedConnectorIndex):r.selectedGroupId!==null&&n.removeGroup(r.selectedGroupId)},[r.selectedNodeIds,r.selectedConnectorIndex,r.selectedGroupId,n]),x=b.useCallback(()=>{r.pendingConnector?n.clearPendingConnector():r.mode!=="select"?n.setMode("select"):n.clearSelection()},[r.mode,r.pendingConnector,n]);return Il({onDelete:g,onUndo:n.undo,onRedo:n.redo,onSave:h,onNew:f,onEscape:x,onSetMode:n.setMode}),a.jsxs("div",{className:"flex flex-col h-screen bg-zinc-100 dark:bg-zinc-950",children:[a.jsx(ms,{onNew:f,onOpen:u,onSave:h,onShare:p,isDark:e,onToggleTheme:t}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[a.jsxs("div",{className:"flex-1 relative p-4 overflow-hidden",children:[a.jsx("div",{className:"w-full h-full rounded-xl overflow-hidden border border-zinc-200 dark:border-zinc-800 shadow-sm",children:a.jsx(Qn,{onViewportChange:d,embedConfig:{enableViewModeToggle:!0}})}),a.jsx(xs,{})]}),a.jsx(wl,{})]}),s&&a.jsx(Al,{diagram:o,viewportBounds:c,onClose:()=>l(!1)})]})}function Ol({isDark:e,onToggleTheme:t}){return a.jsx(Yn,{initialDiagram:El,children:a.jsx(Dl,{isDark:e,onToggleTheme:t})})}const Sr='"JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace',Ll={blue:{top:"#3b82f6",side:"#2563eb",front:"#1d4ed8"},violet:{top:"#8b5cf6",side:"#7c3aed",front:"#6d28d9"},cyan:{top:"#06b6d4",side:"#0891b2",front:"#0e7490"},emerald:{top:"#10b981",side:"#059669",front:"#047857"},amber:{top:"#f59e0b",side:"#d97706",front:"#b45309"},rose:{top:"#f43f5e",side:"#e11d48",front:"#be123c"},slate:{top:"#475569",side:"#334155",front:"#1e293b"}},Tl={blue:{top:"#93c5fd",side:"#60a5fa",front:"#3b82f6"},violet:{top:"#c4b5fd",side:"#a78bfa",front:"#8b5cf6"},cyan:{top:"#67e8f9",side:"#22d3ee",front:"#06b6d4"},emerald:{top:"#6ee7b7",side:"#34d399",front:"#10b981"},amber:{top:"#fcd34d",side:"#fbbf24",front:"#f59e0b"},rose:{top:"#fda4af",side:"#fb7185",front:"#f43f5e"},slate:{top:"#e2e8f0",side:"#cbd5e1",front:"#94a3b8"}};function Nt(e,t,n){const o=d=>{const f=d.replace("#","");return{r:parseInt(f.substring(0,2),16),g:parseInt(f.substring(2,4),16),b:parseInt(f.substring(4,6),16)}},r=o(e),i=o(t),s=Math.round(r.r+(i.r-r.r)*n),l=Math.round(r.g+(i.g-r.g)*n),c=Math.round(r.b+(i.b-r.b)*n);return`rgb(${s},${l},${c})`}function Pl({x:e,y:t,z:n,children:o,fontSize:r=8,color:i="#1e293b"}){const s=T(e,t,n);return a.jsx("g",{transform:`translate(${s.screenX}, ${s.screenY})`,children:a.jsx("g",{transform:"matrix(0.866, -0.5, 0.866, 0.5, 0, 0)",children:a.jsx("text",{x:0,y:0,textAnchor:"middle",fill:i,fontSize:r,fontWeight:500,fontFamily:Sr,style:{textTransform:"uppercase",letterSpacing:"0.08em"},children:o})})})}function Fl({width:e,depth:t,elevation:n,color:o,opacity:r,borderColor:i,theme:s,isGround:l}){const d=Oe(e,t,l?8:2,0,0),f=T(0,0,n);return a.jsxs("g",{transform:`translate(${f.screenX}, ${f.screenY})`,children:[l&&a.jsx("g",{transform:"translate(4, 4)",opacity:.2,children:a.jsx("path",{d:d.top,fill:"#000"})}),a.jsx("path",{d:d.top,fill:o,opacity:r}),l&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:d.left,fill:s==="dark"?"#0f172a":"#cbd5e1",opacity:.8}),a.jsx("path",{d:d.right,fill:s==="dark"?"#1e293b":"#94a3b8",opacity:.8})]}),a.jsx("path",{d:d.top,fill:"none",stroke:i||(s==="dark"?"#475569":"#94a3b8"),strokeWidth:l?1.5:.75,opacity:l?1:.6})]})}function Yl({config:e,options:t={},className:n,style:o}){const{interactive:r=!0,animate:i=!0,showLabels:s=!0}=t,{theme:l,canvas:c,origin:d,tiers:f,floorSize:u,nodes:h,cornerRadius:p=0}=e,g=l==="dark"?Ll:Tl,x=l==="dark"?"#0f172a":"#fafafa",k=l==="dark"?"#e2e8f0":"#1e293b",y=l==="dark"?"#64748b":"#94a3b8",[m,C]=b.useState(new Set);b.useEffect(()=>{i?(C(new Set),f.forEach((N,E)=>{setTimeout(()=>{C(S=>new Set([...S,E]))},E*150+100)})):C(new Set(f.map((N,E)=>E)))},[e.id,i,f.length]);const[v,z]=b.useState(null),_=[...h].sort((N,E)=>{const S=f[N.tier]?.elevation||0,w=f[E.tier]?.elevation||0;if(S!==w)return S-w;const M=N.x+N.width+(N.y+N.depth);return E.x+E.width+(E.y+E.depth)-M});return a.jsx("div",{className:n,style:{display:"inline-block",...o},children:a.jsxs("svg",{width:c.width,height:c.height,style:{backgroundColor:x},children:[a.jsxs("defs",{children:[a.jsx("pattern",{id:`grid-${e.id}`,width:"24",height:"24",patternUnits:"userSpaceOnUse",children:a.jsx("circle",{cx:"12",cy:"12",r:"0.5",fill:l==="dark"?"#1e293b":"#e2e8f0"})}),a.jsx("filter",{id:`glow-${e.id}`,x:"-20%",y:"-20%",width:"140%",height:"140%",children:a.jsx("feDropShadow",{dx:"0",dy:"4",stdDeviation:"8",floodColor:l==="dark"?"#60a5fa":"#3b82f6",floodOpacity:"0.3"})})]}),a.jsx("rect",{width:"100%",height:"100%",fill:`url(#grid-${e.id})`,opacity:"0.5"}),a.jsx("g",{transform:`translate(${d.x}, ${d.y})`,children:f.map((N,E)=>{const S=_.filter(P=>P.tier===E),w=m.has(E),M=r&&v===E,$=w?0:60,A=w?1:0,B=M?1.02:1,W=r&&v!==null&&!M,G=T(u.width/2,u.depth/2,N.elevation);return a.jsxs("g",{onMouseEnter:()=>r&&z(E),onMouseLeave:()=>r&&z(null),style:{transform:`translate(${G.screenX}px, ${G.screenY+$}px) scale(${B}) translate(${-G.screenX}px, ${-G.screenY}px)`,transition:"transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease-out",opacity:A*(W?.5:1),filter:M?`url(#glow-${e.id})`:"none",cursor:r?"pointer":"default"},children:[a.jsx(Fl,{width:u.width,depth:u.depth,elevation:E===0?-2:N.elevation,color:N.floorColor||(l==="dark"?"#0f172a":"#f8fafc"),opacity:N.floorOpacity||(E===0?.95:.5),borderColor:N.borderColor,theme:l,isGround:E===0}),S.map((P,ne)=>{const Q=N.elevation+5,ye=T(P.x,P.y,Q),R=Oe(P.width,P.depth,P.height,ye.screenX,ye.screenY,p),U=g[P.color]||g.slate;return a.jsxs("g",{opacity:P.opacity??1,children:[R.cornerBackRight?.map((Z,se)=>a.jsx("path",{d:Z.path,fill:Nt(U.front,U.side,Z.intensity)},`cbr-${se}`)),R.cornerBackLeft?.map((Z,se)=>a.jsx("path",{d:Z.path,fill:Nt(U.side,U.front,Z.intensity)},`cbl-${se}`)),a.jsx("path",{d:R.left,fill:U.side}),a.jsx("path",{d:R.right,fill:U.front}),R.cornerFrontRight?.map((Z,se)=>a.jsx("path",{d:Z.path,fill:Nt(U.front,U.side,Z.intensity)},`cfr-${se}`)),R.cornerFrontLeft?.map((Z,se)=>a.jsx("path",{d:Z.path,fill:Nt(U.front,U.side,Z.intensity)},`cfl-${se}`)),a.jsx("path",{d:R.top,fill:U.top}),a.jsx("path",{d:R.top,fill:"none",stroke:"rgba(255,255,255,0.15)",strokeWidth:"0.5",strokeLinejoin:"round"}),s&&P.label&&a.jsx(Pl,{x:P.x+P.width/2,y:P.y+P.depth/2,z:Q+P.height+2,fontSize:P.width>70?8:7,color:k,children:P.label})]},ne)}),s&&a.jsx("text",{x:T(-25,u.depth/2,N.elevation+15).screenX-35,y:T(-25,u.depth/2,N.elevation+15).screenY,fill:y,fontSize:9,fontWeight:500,fontFamily:Sr,opacity:.6,style:{letterSpacing:"0.05em"},children:N.name})]},E)})})]})})}const Ar='"JetBrains Mono", "Fira Code", "SF Mono", Consolas, monospace',Hl={blue:{top:"#3b82f6",side:"#2563eb",front:"#1d4ed8"},violet:{top:"#8b5cf6",side:"#7c3aed",front:"#6d28d9"},cyan:{top:"#06b6d4",side:"#0891b2",front:"#0e7490"},emerald:{top:"#10b981",side:"#059669",front:"#047857"},amber:{top:"#f59e0b",side:"#d97706",front:"#b45309"},rose:{top:"#f43f5e",side:"#e11d48",front:"#be123c"},slate:{top:"#475569",side:"#334155",front:"#1e293b"}},Bl={blue:{top:"#93c5fd",side:"#60a5fa",front:"#3b82f6"},violet:{top:"#c4b5fd",side:"#a78bfa",front:"#8b5cf6"},cyan:{top:"#67e8f9",side:"#22d3ee",front:"#06b6d4"},emerald:{top:"#6ee7b7",side:"#34d399",front:"#10b981"},amber:{top:"#fcd34d",side:"#fbbf24",front:"#f59e0b"},rose:{top:"#fda4af",side:"#fb7185",front:"#f43f5e"},slate:{top:"#e2e8f0",side:"#cbd5e1",front:"#94a3b8"}};function zt(e,t,n){const o=d=>{const f=d.replace("#","");return{r:parseInt(f.substring(0,2),16),g:parseInt(f.substring(2,4),16),b:parseInt(f.substring(4,6),16)}},r=o(e),i=o(t),s=Math.round(r.r+(i.r-r.r)*n),l=Math.round(r.g+(i.g-r.g)*n),c=Math.round(r.b+(i.b-r.b)*n);return`rgb(${s},${l},${c})`}function Ir(e){const{theme:t,canvas:n,origin:o,tiers:r,floorSize:i,nodes:s,cornerRadius:l=0}=e,c=t==="dark"?Hl:Bl,d=t==="dark"?"#0f172a":"#fafafa",f=t==="dark"?"#e2e8f0":"#1e293b",u=t==="dark"?"#64748b":"#94a3b8",h=[...s].sort((g,x)=>{const k=r[g.tier]?.elevation||0,y=r[x.tier]?.elevation||0;return k!==y?k-y:x.x+x.width+(x.y+x.depth)-(g.x+g.width+(g.y+g.depth))});let p=`<svg xmlns="http://www.w3.org/2000/svg" width="${n.width}" height="${n.height}" style="background:${d}">`;p+=`<defs>
|
|
137
|
+
<pattern id="grid" width="24" height="24" patternUnits="userSpaceOnUse">
|
|
138
|
+
<circle cx="12" cy="12" r="0.5" fill="${t==="dark"?"#1e293b":"#e2e8f0"}"/>
|
|
139
|
+
</pattern>
|
|
140
|
+
</defs>`,p+='<rect width="100%" height="100%" fill="url(#grid)" opacity="0.5"/>',p+=`<g transform="translate(${o.x},${o.y})">`;for(let g=0;g<r.length;g++){const x=r[g],k=h.filter(N=>N.tier===g),y=g===0?8:2,m=Oe(i.width,i.depth,y,0,0),C=T(0,0,g===0?-2:x.elevation),v=x.floorColor||(t==="dark"?"#0f172a":"#f8fafc"),z=x.floorOpacity||(g===0?.95:.5);p+=`<g transform="translate(${C.screenX},${C.screenY})">`,g===0&&(p+=`<g transform="translate(4,4)" opacity="0.2"><path d="${m.top}" fill="#000"/></g>`),p+=`<path d="${m.top}" fill="${v}" opacity="${z}"/>`,g===0&&(p+=`<path d="${m.left}" fill="${t==="dark"?"#0f172a":"#cbd5e1"}" opacity="0.8"/>`,p+=`<path d="${m.right}" fill="${t==="dark"?"#1e293b":"#94a3b8"}" opacity="0.8"/>`),p+=`<path d="${m.top}" fill="none" stroke="${x.borderColor||(t==="dark"?"#475569":"#94a3b8")}" stroke-width="${g===0?1.5:.75}" opacity="${g===0?1:.6}"/>`,p+="</g>";for(const N of k){const E=x.elevation+5,S=T(N.x,N.y,E),w=Oe(N.width,N.depth,N.height,S.screenX,S.screenY,l),M=c[N.color]||c.slate,$=N.opacity??1;if(p+=`<g opacity="${$}">`,w.cornerBackRight)for(const A of w.cornerBackRight)p+=`<path d="${A.path}" fill="${zt(M.front,M.side,A.intensity)}"/>`;if(w.cornerBackLeft)for(const A of w.cornerBackLeft)p+=`<path d="${A.path}" fill="${zt(M.side,M.front,A.intensity)}"/>`;if(p+=`<path d="${w.left}" fill="${M.side}"/>`,p+=`<path d="${w.right}" fill="${M.front}"/>`,w.cornerFrontRight)for(const A of w.cornerFrontRight)p+=`<path d="${A.path}" fill="${zt(M.front,M.side,A.intensity)}"/>`;if(w.cornerFrontLeft)for(const A of w.cornerFrontLeft)p+=`<path d="${A.path}" fill="${zt(M.front,M.side,A.intensity)}"/>`;if(p+=`<path d="${w.top}" fill="${M.top}"/>`,p+=`<path d="${w.top}" fill="none" stroke="rgba(255,255,255,0.15)" stroke-width="0.5" stroke-linejoin="round"/>`,N.label){const A=T(N.x+N.width/2,N.y+N.depth/2,E+N.height+2),B=N.width>70?8:7;p+=`<g transform="translate(${A.screenX},${A.screenY})">`,p+='<g transform="matrix(0.866,-0.5,0.866,0.5,0,0)">',p+=`<text x="0" y="0" text-anchor="middle" fill="${f}" font-size="${B}" font-weight="500" font-family="${Ar}" style="text-transform:uppercase;letter-spacing:0.08em">${N.label}</text>`,p+="</g></g>"}p+="</g>"}const _=T(-25,i.depth/2,x.elevation+15);p+=`<text x="${_.screenX-35}" y="${_.screenY}" fill="${u}" font-size="9" font-weight="500" font-family="${Ar}" opacity="0.6" style="letter-spacing:0.05em">${x.name}</text>`}return p+="</g></svg>",p}function Wl(e,t){e.innerHTML=Ir(t)}function Er(e){return typeof e>"u"||e===null}function Ul(e){return typeof e=="object"&&e!==null}function Xl(e){return Array.isArray(e)?e:Er(e)?[]:[e]}function jl(e,t){var n,o,r,i;if(t)for(i=Object.keys(t),n=0,o=i.length;n<o;n+=1)r=i[n],e[r]=t[r];return e}function Gl(e,t){var n="",o;for(o=0;o<t;o+=1)n+=e;return n}function Vl(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Kl=Er,ql=Ul,Zl=Xl,Jl=Gl,Ql=Vl,Rl=jl,ie={isNothing:Kl,isObject:ql,toArray:Zl,repeat:Jl,isNegativeZero:Ql,extend:Rl};function Dr(e,t){var n="",o=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
|
|
141
|
+
|
|
142
|
+
`+e.mark.snippet),o+" "+n):o}function tt(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=Dr(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}tt.prototype=Object.create(Error.prototype),tt.prototype.constructor=tt,tt.prototype.toString=function(t){return this.name+": "+Dr(this,t)};var he=tt;function on(e,t,n,o,r){var i="",s="",l=Math.floor(r/2)-1;return o-t>l&&(i=" ... ",t=o-l+i.length),n-o>l&&(s=" ...",n=o+l-s.length),{str:i+e.slice(t,n).replace(/\t/g,"→")+s,pos:o-t+i.length}}function sn(e,t){return ie.repeat(" ",t-e.length)+e}function ec(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,o=[0],r=[],i,s=-1;i=n.exec(e.buffer);)r.push(i.index),o.push(i.index+i[0].length),e.position<=i.index&&s<0&&(s=o.length-2);s<0&&(s=o.length-1);var l="",c,d,f=Math.min(e.line+t.linesAfter,r.length).toString().length,u=t.maxLength-(t.indent+f+3);for(c=1;c<=t.linesBefore&&!(s-c<0);c++)d=on(e.buffer,o[s-c],r[s-c],e.position-(o[s]-o[s-c]),u),l=ie.repeat(" ",t.indent)+sn((e.line-c+1).toString(),f)+" | "+d.str+`
|
|
143
|
+
`+l;for(d=on(e.buffer,o[s],r[s],e.position,u),l+=ie.repeat(" ",t.indent)+sn((e.line+1).toString(),f)+" | "+d.str+`
|
|
144
|
+
`,l+=ie.repeat("-",t.indent+f+3+d.pos)+`^
|
|
145
|
+
`,c=1;c<=t.linesAfter&&!(s+c>=r.length);c++)d=on(e.buffer,o[s+c],r[s+c],e.position-(o[s]-o[s+c]),u),l+=ie.repeat(" ",t.indent)+sn((e.line+c+1).toString(),f)+" | "+d.str+`
|
|
146
|
+
`;return l.replace(/\n$/,"")}var tc=ec,nc=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],rc=["scalar","sequence","mapping"];function oc(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(o){t[String(o)]=n})}),t}function ic(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(nc.indexOf(n)===-1)throw new he('Unknown option "'+n+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(n){return n},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=oc(t.styleAliases||null),rc.indexOf(this.kind)===-1)throw new he('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var ce=ic;function Or(e,t){var n=[];return e[t].forEach(function(o){var r=n.length;n.forEach(function(i,s){i.tag===o.tag&&i.kind===o.kind&&i.multi===o.multi&&(r=s)}),n[r]=o}),n}function sc(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function o(r){r.multi?(e.multi[r.kind].push(r),e.multi.fallback.push(r)):e[r.kind][r.tag]=e.fallback[r.tag]=r}for(t=0,n=arguments.length;t<n;t+=1)arguments[t].forEach(o);return e}function an(e){return this.extend(e)}an.prototype.extend=function(t){var n=[],o=[];if(t instanceof ce)o.push(t);else if(Array.isArray(t))o=o.concat(t);else if(t&&(Array.isArray(t.implicit)||Array.isArray(t.explicit)))t.implicit&&(n=n.concat(t.implicit)),t.explicit&&(o=o.concat(t.explicit));else throw new he("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(i){if(!(i instanceof ce))throw new he("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(i.loadKind&&i.loadKind!=="scalar")throw new he("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(i.multi)throw new he("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),o.forEach(function(i){if(!(i instanceof ce))throw new he("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var r=Object.create(an.prototype);return r.implicit=(this.implicit||[]).concat(n),r.explicit=(this.explicit||[]).concat(o),r.compiledImplicit=Or(r,"implicit"),r.compiledExplicit=Or(r,"explicit"),r.compiledTypeMap=sc(r.compiledImplicit,r.compiledExplicit),r};var Lr=an,Tr=new ce("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),Pr=new ce("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Fr=new ce("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Yr=new Lr({explicit:[Tr,Pr,Fr]});function ac(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function lc(){return null}function cc(e){return e===null}var Hr=new ce("tag:yaml.org,2002:null",{kind:"scalar",resolve:ac,construct:lc,predicate:cc,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function dc(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function uc(e){return e==="true"||e==="True"||e==="TRUE"}function hc(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Br=new ce("tag:yaml.org,2002:bool",{kind:"scalar",resolve:dc,construct:uc,predicate:hc,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function fc(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function pc(e){return 48<=e&&e<=55}function gc(e){return 48<=e&&e<=57}function yc(e){if(e===null)return!1;var t=e.length,n=0,o=!1,r;if(!t)return!1;if(r=e[n],(r==="-"||r==="+")&&(r=e[++n]),r==="0"){if(n+1===t)return!0;if(r=e[++n],r==="b"){for(n++;n<t;n++)if(r=e[n],r!=="_"){if(r!=="0"&&r!=="1")return!1;o=!0}return o&&r!=="_"}if(r==="x"){for(n++;n<t;n++)if(r=e[n],r!=="_"){if(!fc(e.charCodeAt(n)))return!1;o=!0}return o&&r!=="_"}if(r==="o"){for(n++;n<t;n++)if(r=e[n],r!=="_"){if(!pc(e.charCodeAt(n)))return!1;o=!0}return o&&r!=="_"}}if(r==="_")return!1;for(;n<t;n++)if(r=e[n],r!=="_"){if(!gc(e.charCodeAt(n)))return!1;o=!0}return!(!o||r==="_")}function mc(e){var t=e,n=1,o;if(t.indexOf("_")!==-1&&(t=t.replace(/_/g,"")),o=t[0],(o==="-"||o==="+")&&(o==="-"&&(n=-1),t=t.slice(1),o=t[0]),t==="0")return 0;if(o==="0"){if(t[1]==="b")return n*parseInt(t.slice(2),2);if(t[1]==="x")return n*parseInt(t.slice(2),16);if(t[1]==="o")return n*parseInt(t.slice(2),8)}return n*parseInt(t,10)}function xc(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!ie.isNegativeZero(e)}var Wr=new ce("tag:yaml.org,2002:int",{kind:"scalar",resolve:yc,construct:mc,predicate:xc,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),bc=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function kc(e){return!(e===null||!bc.test(e)||e[e.length-1]==="_")}function vc(e){var t,n;return t=e.replace(/_/g,"").toLowerCase(),n=t[0]==="-"?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:n*parseFloat(t,10)}var wc=/^[-+]?[0-9]+e/;function Cc(e,t){var n;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(ie.isNegativeZero(e))return"-0.0";return n=e.toString(10),wc.test(n)?n.replace("e",".e"):n}function Nc(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||ie.isNegativeZero(e))}var Ur=new ce("tag:yaml.org,2002:float",{kind:"scalar",resolve:kc,construct:vc,predicate:Nc,represent:Cc,defaultStyle:"lowercase"}),Xr=Yr.extend({implicit:[Hr,Br,Wr,Ur]}),jr=Xr,Gr=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),Vr=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function zc(e){return e===null?!1:Gr.exec(e)!==null||Vr.exec(e)!==null}function Mc(e){var t,n,o,r,i,s,l,c=0,d=null,f,u,h;if(t=Gr.exec(e),t===null&&(t=Vr.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],o=+t[2]-1,r=+t[3],!t[4])return new Date(Date.UTC(n,o,r));if(i=+t[4],s=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(f=+t[10],u=+(t[11]||0),d=(f*60+u)*6e4,t[9]==="-"&&(d=-d)),h=new Date(Date.UTC(n,o,r,i,s,l,c)),d&&h.setTime(h.getTime()-d),h}function _c(e){return e.toISOString()}var Kr=new ce("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:zc,construct:Mc,instanceOf:Date,represent:_c});function $c(e){return e==="<<"||e===null}var qr=new ce("tag:yaml.org,2002:merge",{kind:"scalar",resolve:$c}),ln=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
147
|
+
\r`;function Sc(e){if(e===null)return!1;var t,n,o=0,r=e.length,i=ln;for(n=0;n<r;n++)if(t=i.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;o+=6}return o%8===0}function Ac(e){var t,n,o=e.replace(/[\r\n=]/g,""),r=o.length,i=ln,s=0,l=[];for(t=0;t<r;t++)t%4===0&&t&&(l.push(s>>16&255),l.push(s>>8&255),l.push(s&255)),s=s<<6|i.indexOf(o.charAt(t));return n=r%4*6,n===0?(l.push(s>>16&255),l.push(s>>8&255),l.push(s&255)):n===18?(l.push(s>>10&255),l.push(s>>2&255)):n===12&&l.push(s>>4&255),new Uint8Array(l)}function Ic(e){var t="",n=0,o,r,i=e.length,s=ln;for(o=0;o<i;o++)o%3===0&&o&&(t+=s[n>>18&63],t+=s[n>>12&63],t+=s[n>>6&63],t+=s[n&63]),n=(n<<8)+e[o];return r=i%3,r===0?(t+=s[n>>18&63],t+=s[n>>12&63],t+=s[n>>6&63],t+=s[n&63]):r===2?(t+=s[n>>10&63],t+=s[n>>4&63],t+=s[n<<2&63],t+=s[64]):r===1&&(t+=s[n>>2&63],t+=s[n<<4&63],t+=s[64],t+=s[64]),t}function Ec(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var Zr=new ce("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Sc,construct:Ac,predicate:Ec,represent:Ic}),Dc=Object.prototype.hasOwnProperty,Oc=Object.prototype.toString;function Lc(e){if(e===null)return!0;var t=[],n,o,r,i,s,l=e;for(n=0,o=l.length;n<o;n+=1){if(r=l[n],s=!1,Oc.call(r)!=="[object Object]")return!1;for(i in r)if(Dc.call(r,i))if(!s)s=!0;else return!1;if(!s)return!1;if(t.indexOf(i)===-1)t.push(i);else return!1}return!0}function Tc(e){return e!==null?e:[]}var Jr=new ce("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Lc,construct:Tc}),Pc=Object.prototype.toString;function Fc(e){if(e===null)return!0;var t,n,o,r,i,s=e;for(i=new Array(s.length),t=0,n=s.length;t<n;t+=1){if(o=s[t],Pc.call(o)!=="[object Object]"||(r=Object.keys(o),r.length!==1))return!1;i[t]=[r[0],o[r[0]]]}return!0}function Yc(e){if(e===null)return[];var t,n,o,r,i,s=e;for(i=new Array(s.length),t=0,n=s.length;t<n;t+=1)o=s[t],r=Object.keys(o),i[t]=[r[0],o[r[0]]];return i}var Qr=new ce("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Fc,construct:Yc}),Hc=Object.prototype.hasOwnProperty;function Bc(e){if(e===null)return!0;var t,n=e;for(t in n)if(Hc.call(n,t)&&n[t]!==null)return!1;return!0}function Wc(e){return e!==null?e:{}}var Rr=new ce("tag:yaml.org,2002:set",{kind:"mapping",resolve:Bc,construct:Wc}),cn=jr.extend({implicit:[Kr,qr],explicit:[Zr,Jr,Qr,Rr]}),$e=Object.prototype.hasOwnProperty,Mt=1,eo=2,to=3,_t=4,dn=1,Uc=2,no=3,Xc=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,jc=/[\x85\u2028\u2029]/,Gc=/[,\[\]\{\}]/,ro=/^(?:!|!!|![a-z\-]+!)$/i,oo=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function io(e){return Object.prototype.toString.call(e)}function Ce(e){return e===10||e===13}function Ie(e){return e===9||e===32}function fe(e){return e===9||e===32||e===10||e===13}function Ye(e){return e===44||e===91||e===93||e===123||e===125}function Vc(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function Kc(e){return e===120?2:e===117?4:e===85?8:0}function qc(e){return 48<=e&&e<=57?e-48:-1}function so(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
|
|
148
|
+
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"
":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}function Zc(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function ao(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}for(var lo=new Array(256),co=new Array(256),He=0;He<256;He++)lo[He]=so(He)?1:0,co[He]=so(He);function Jc(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||cn,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function uo(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=tc(n),new he(t,n)}function L(e,t){throw uo(e,t)}function $t(e,t){e.onWarning&&e.onWarning.call(null,uo(e,t))}var ho={YAML:function(t,n,o){var r,i,s;t.version!==null&&L(t,"duplication of %YAML directive"),o.length!==1&&L(t,"YAML directive accepts exactly one argument"),r=/^([0-9]+)\.([0-9]+)$/.exec(o[0]),r===null&&L(t,"ill-formed argument of the YAML directive"),i=parseInt(r[1],10),s=parseInt(r[2],10),i!==1&&L(t,"unacceptable YAML version of the document"),t.version=o[0],t.checkLineBreaks=s<2,s!==1&&s!==2&&$t(t,"unsupported YAML version of the document")},TAG:function(t,n,o){var r,i;o.length!==2&&L(t,"TAG directive accepts exactly two arguments"),r=o[0],i=o[1],ro.test(r)||L(t,"ill-formed tag handle (first argument) of the TAG directive"),$e.call(t.tagMap,r)&&L(t,'there is a previously declared suffix for "'+r+'" tag handle'),oo.test(i)||L(t,"ill-formed tag prefix (second argument) of the TAG directive");try{i=decodeURIComponent(i)}catch{L(t,"tag prefix is malformed: "+i)}t.tagMap[r]=i}};function Se(e,t,n,o){var r,i,s,l;if(t<n){if(l=e.input.slice(t,n),o)for(r=0,i=l.length;r<i;r+=1)s=l.charCodeAt(r),s===9||32<=s&&s<=1114111||L(e,"expected valid JSON character");else Xc.test(l)&&L(e,"the stream contains non-printable characters");e.result+=l}}function fo(e,t,n,o){var r,i,s,l;for(ie.isObject(n)||L(e,"cannot merge mappings; the provided source object is unacceptable"),r=Object.keys(n),s=0,l=r.length;s<l;s+=1)i=r[s],$e.call(t,i)||(ao(t,i,n[i]),o[i]=!0)}function Be(e,t,n,o,r,i,s,l,c){var d,f;if(Array.isArray(r))for(r=Array.prototype.slice.call(r),d=0,f=r.length;d<f;d+=1)Array.isArray(r[d])&&L(e,"nested arrays are not supported inside keys"),typeof r=="object"&&io(r[d])==="[object Object]"&&(r[d]="[object Object]");if(typeof r=="object"&&io(r)==="[object Object]"&&(r="[object Object]"),r=String(r),t===null&&(t={}),o==="tag:yaml.org,2002:merge")if(Array.isArray(i))for(d=0,f=i.length;d<f;d+=1)fo(e,t,i[d],n);else fo(e,t,i,n);else!e.json&&!$e.call(n,r)&&$e.call(t,r)&&(e.line=s||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,L(e,"duplicated mapping key")),ao(t,r,i),delete n[r];return t}function un(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):L(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function te(e,t,n){for(var o=0,r=e.input.charCodeAt(e.position);r!==0;){for(;Ie(r);)r===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),r=e.input.charCodeAt(++e.position);if(t&&r===35)do r=e.input.charCodeAt(++e.position);while(r!==10&&r!==13&&r!==0);if(Ce(r))for(un(e),r=e.input.charCodeAt(e.position),o++,e.lineIndent=0;r===32;)e.lineIndent++,r=e.input.charCodeAt(++e.position);else break}return n!==-1&&o!==0&&e.lineIndent<n&&$t(e,"deficient indentation"),o}function St(e){var t=e.position,n;return n=e.input.charCodeAt(t),!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||fe(n)))}function hn(e,t){t===1?e.result+=" ":t>1&&(e.result+=ie.repeat(`
|
|
149
|
+
`,t-1))}function Qc(e,t,n){var o,r,i,s,l,c,d,f,u=e.kind,h=e.result,p;if(p=e.input.charCodeAt(e.position),fe(p)||Ye(p)||p===35||p===38||p===42||p===33||p===124||p===62||p===39||p===34||p===37||p===64||p===96||(p===63||p===45)&&(r=e.input.charCodeAt(e.position+1),fe(r)||n&&Ye(r)))return!1;for(e.kind="scalar",e.result="",i=s=e.position,l=!1;p!==0;){if(p===58){if(r=e.input.charCodeAt(e.position+1),fe(r)||n&&Ye(r))break}else if(p===35){if(o=e.input.charCodeAt(e.position-1),fe(o))break}else{if(e.position===e.lineStart&&St(e)||n&&Ye(p))break;if(Ce(p))if(c=e.line,d=e.lineStart,f=e.lineIndent,te(e,!1,-1),e.lineIndent>=t){l=!0,p=e.input.charCodeAt(e.position);continue}else{e.position=s,e.line=c,e.lineStart=d,e.lineIndent=f;break}}l&&(Se(e,i,s,!1),hn(e,e.line-c),i=s=e.position,l=!1),Ie(p)||(s=e.position+1),p=e.input.charCodeAt(++e.position)}return Se(e,i,s,!1),e.result?!0:(e.kind=u,e.result=h,!1)}function Rc(e,t){var n,o,r;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,o=r=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(Se(e,o,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)o=e.position,e.position++,r=e.position;else return!0;else Ce(n)?(Se(e,o,r,!0),hn(e,te(e,!1,t)),o=r=e.position):e.position===e.lineStart&&St(e)?L(e,"unexpected end of the document within a single quoted scalar"):(e.position++,r=e.position);L(e,"unexpected end of the stream within a single quoted scalar")}function ed(e,t){var n,o,r,i,s,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=o=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return Se(e,n,e.position,!0),e.position++,!0;if(l===92){if(Se(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),Ce(l))te(e,!1,t);else if(l<256&&lo[l])e.result+=co[l],e.position++;else if((s=Kc(l))>0){for(r=s,i=0;r>0;r--)l=e.input.charCodeAt(++e.position),(s=Vc(l))>=0?i=(i<<4)+s:L(e,"expected hexadecimal character");e.result+=Zc(i),e.position++}else L(e,"unknown escape sequence");n=o=e.position}else Ce(l)?(Se(e,n,o,!0),hn(e,te(e,!1,t)),n=o=e.position):e.position===e.lineStart&&St(e)?L(e,"unexpected end of the document within a double quoted scalar"):(e.position++,o=e.position)}L(e,"unexpected end of the stream within a double quoted scalar")}function td(e,t){var n=!0,o,r,i,s=e.tag,l,c=e.anchor,d,f,u,h,p,g=Object.create(null),x,k,y,m;if(m=e.input.charCodeAt(e.position),m===91)f=93,p=!1,l=[];else if(m===123)f=125,p=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),m=e.input.charCodeAt(++e.position);m!==0;){if(te(e,!0,t),m=e.input.charCodeAt(e.position),m===f)return e.position++,e.tag=s,e.anchor=c,e.kind=p?"mapping":"sequence",e.result=l,!0;n?m===44&&L(e,"expected the node content, but found ','"):L(e,"missed comma between flow collection entries"),k=x=y=null,u=h=!1,m===63&&(d=e.input.charCodeAt(e.position+1),fe(d)&&(u=h=!0,e.position++,te(e,!0,t))),o=e.line,r=e.lineStart,i=e.position,We(e,t,Mt,!1,!0),k=e.tag,x=e.result,te(e,!0,t),m=e.input.charCodeAt(e.position),(h||e.line===o)&&m===58&&(u=!0,m=e.input.charCodeAt(++e.position),te(e,!0,t),We(e,t,Mt,!1,!0),y=e.result),p?Be(e,l,g,k,x,y,o,r,i):u?l.push(Be(e,null,g,k,x,y,o,r,i)):l.push(x),te(e,!0,t),m=e.input.charCodeAt(e.position),m===44?(n=!0,m=e.input.charCodeAt(++e.position)):n=!1}L(e,"unexpected end of the stream within a flow collection")}function nd(e,t){var n,o,r=dn,i=!1,s=!1,l=t,c=0,d=!1,f,u;if(u=e.input.charCodeAt(e.position),u===124)o=!1;else if(u===62)o=!0;else return!1;for(e.kind="scalar",e.result="";u!==0;)if(u=e.input.charCodeAt(++e.position),u===43||u===45)dn===r?r=u===43?no:Uc:L(e,"repeat of a chomping mode identifier");else if((f=qc(u))>=0)f===0?L(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?L(e,"repeat of an indentation width identifier"):(l=t+f-1,s=!0);else break;if(Ie(u)){do u=e.input.charCodeAt(++e.position);while(Ie(u));if(u===35)do u=e.input.charCodeAt(++e.position);while(!Ce(u)&&u!==0)}for(;u!==0;){for(un(e),e.lineIndent=0,u=e.input.charCodeAt(e.position);(!s||e.lineIndent<l)&&u===32;)e.lineIndent++,u=e.input.charCodeAt(++e.position);if(!s&&e.lineIndent>l&&(l=e.lineIndent),Ce(u)){c++;continue}if(e.lineIndent<l){r===no?e.result+=ie.repeat(`
|
|
150
|
+
`,i?1+c:c):r===dn&&i&&(e.result+=`
|
|
151
|
+
`);break}for(o?Ie(u)?(d=!0,e.result+=ie.repeat(`
|
|
152
|
+
`,i?1+c:c)):d?(d=!1,e.result+=ie.repeat(`
|
|
153
|
+
`,c+1)):c===0?i&&(e.result+=" "):e.result+=ie.repeat(`
|
|
154
|
+
`,c):e.result+=ie.repeat(`
|
|
155
|
+
`,i?1+c:c),i=!0,s=!0,c=0,n=e.position;!Ce(u)&&u!==0;)u=e.input.charCodeAt(++e.position);Se(e,n,e.position,!1)}return!0}function po(e,t){var n,o=e.tag,r=e.anchor,i=[],s,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=i),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,L(e,"tab characters must not be used in indentation")),!(c!==45||(s=e.input.charCodeAt(e.position+1),!fe(s))));){if(l=!0,e.position++,te(e,!0,-1)&&e.lineIndent<=t){i.push(null),c=e.input.charCodeAt(e.position);continue}if(n=e.line,We(e,t,to,!1,!0),i.push(e.result),te(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&c!==0)L(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=o,e.anchor=r,e.kind="sequence",e.result=i,!0):!1}function rd(e,t,n){var o,r,i,s,l,c,d=e.tag,f=e.anchor,u={},h=Object.create(null),p=null,g=null,x=null,k=!1,y=!1,m;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),m=e.input.charCodeAt(e.position);m!==0;){if(!k&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,L(e,"tab characters must not be used in indentation")),o=e.input.charCodeAt(e.position+1),i=e.line,(m===63||m===58)&&fe(o))m===63?(k&&(Be(e,u,h,p,g,null,s,l,c),p=g=x=null),y=!0,k=!0,r=!0):k?(k=!1,r=!0):L(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,m=o;else{if(s=e.line,l=e.lineStart,c=e.position,!We(e,n,eo,!1,!0))break;if(e.line===i){for(m=e.input.charCodeAt(e.position);Ie(m);)m=e.input.charCodeAt(++e.position);if(m===58)m=e.input.charCodeAt(++e.position),fe(m)||L(e,"a whitespace character is expected after the key-value separator within a block mapping"),k&&(Be(e,u,h,p,g,null,s,l,c),p=g=x=null),y=!0,k=!1,r=!1,p=e.tag,g=e.result;else if(y)L(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=f,!0}else if(y)L(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,e.anchor=f,!0}if((e.line===i||e.lineIndent>t)&&(k&&(s=e.line,l=e.lineStart,c=e.position),We(e,t,_t,!0,r)&&(k?g=e.result:x=e.result),k||(Be(e,u,h,p,g,x,s,l,c),p=g=x=null),te(e,!0,-1),m=e.input.charCodeAt(e.position)),(e.line===i||e.lineIndent>t)&&m!==0)L(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return k&&Be(e,u,h,p,g,null,s,l,c),y&&(e.tag=d,e.anchor=f,e.kind="mapping",e.result=u),y}function od(e){var t,n=!1,o=!1,r,i,s;if(s=e.input.charCodeAt(e.position),s!==33)return!1;if(e.tag!==null&&L(e,"duplication of a tag property"),s=e.input.charCodeAt(++e.position),s===60?(n=!0,s=e.input.charCodeAt(++e.position)):s===33?(o=!0,r="!!",s=e.input.charCodeAt(++e.position)):r="!",t=e.position,n){do s=e.input.charCodeAt(++e.position);while(s!==0&&s!==62);e.position<e.length?(i=e.input.slice(t,e.position),s=e.input.charCodeAt(++e.position)):L(e,"unexpected end of the stream within a verbatim tag")}else{for(;s!==0&&!fe(s);)s===33&&(o?L(e,"tag suffix cannot contain exclamation marks"):(r=e.input.slice(t-1,e.position+1),ro.test(r)||L(e,"named tag handle cannot contain such characters"),o=!0,t=e.position+1)),s=e.input.charCodeAt(++e.position);i=e.input.slice(t,e.position),Gc.test(i)&&L(e,"tag suffix cannot contain flow indicator characters")}i&&!oo.test(i)&&L(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch{L(e,"tag name is malformed: "+i)}return n?e.tag=i:$e.call(e.tagMap,r)?e.tag=e.tagMap[r]+i:r==="!"?e.tag="!"+i:r==="!!"?e.tag="tag:yaml.org,2002:"+i:L(e,'undeclared tag handle "'+r+'"'),!0}function id(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&L(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!fe(n)&&!Ye(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&L(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function sd(e){var t,n,o;if(o=e.input.charCodeAt(e.position),o!==42)return!1;for(o=e.input.charCodeAt(++e.position),t=e.position;o!==0&&!fe(o)&&!Ye(o);)o=e.input.charCodeAt(++e.position);return e.position===t&&L(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),$e.call(e.anchorMap,n)||L(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],te(e,!0,-1),!0}function We(e,t,n,o,r){var i,s,l,c=1,d=!1,f=!1,u,h,p,g,x,k;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,i=s=l=_t===n||to===n,o&&te(e,!0,-1)&&(d=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;od(e)||id(e);)te(e,!0,-1)?(d=!0,l=i,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=d||r),(c===1||_t===n)&&(Mt===n||eo===n?x=t:x=t+1,k=e.position-e.lineStart,c===1?l&&(po(e,k)||rd(e,k,x))||td(e,x)?f=!0:(s&&nd(e,x)||Rc(e,x)||ed(e,x)?f=!0:sd(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&L(e,"alias node should not have any properties")):Qc(e,x,Mt===n)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(f=l&&po(e,k))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&L(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),u=0,h=e.implicitTypes.length;u<h;u+=1)if(g=e.implicitTypes[u],g.resolve(e.result)){e.result=g.construct(e.result),e.tag=g.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if($e.call(e.typeMap[e.kind||"fallback"],e.tag))g=e.typeMap[e.kind||"fallback"][e.tag];else for(g=null,p=e.typeMap.multi[e.kind||"fallback"],u=0,h=p.length;u<h;u+=1)if(e.tag.slice(0,p[u].tag.length)===p[u].tag){g=p[u];break}g||L(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&L(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+g.kind+'", not "'+e.kind+'"'),g.resolve(e.result,e.tag)?(e.result=g.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):L(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function ad(e){var t=e.position,n,o,r,i=!1,s;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(s=e.input.charCodeAt(e.position))!==0&&(te(e,!0,-1),s=e.input.charCodeAt(e.position),!(e.lineIndent>0||s!==37));){for(i=!0,s=e.input.charCodeAt(++e.position),n=e.position;s!==0&&!fe(s);)s=e.input.charCodeAt(++e.position);for(o=e.input.slice(n,e.position),r=[],o.length<1&&L(e,"directive name must not be less than one character in length");s!==0;){for(;Ie(s);)s=e.input.charCodeAt(++e.position);if(s===35){do s=e.input.charCodeAt(++e.position);while(s!==0&&!Ce(s));break}if(Ce(s))break;for(n=e.position;s!==0&&!fe(s);)s=e.input.charCodeAt(++e.position);r.push(e.input.slice(n,e.position))}s!==0&&un(e),$e.call(ho,o)?ho[o](e,o,r):$t(e,'unknown document directive "'+o+'"')}if(te(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,te(e,!0,-1)):i&&L(e,"directives end mark is expected"),We(e,e.lineIndent-1,_t,!1,!0),te(e,!0,-1),e.checkLineBreaks&&jc.test(e.input.slice(t,e.position))&&$t(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&St(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,te(e,!0,-1));return}if(e.position<e.length-1)L(e,"end of the stream or a document separator is expected");else return}function go(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
|
|
156
|
+
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new Jc(e,t),o=e.indexOf("\0");for(o!==-1&&(n.position=o,L(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)ad(n);return n.documents}function ld(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var o=go(e,n);if(typeof t!="function")return o;for(var r=0,i=o.length;r<i;r+=1)t(o[r])}function cd(e,t){var n=go(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new he("expected a single document in the stream, but found more")}}var dd=ld,ud=cd,yo={loadAll:dd,load:ud},mo=Object.prototype.toString,xo=Object.prototype.hasOwnProperty,fn=65279,hd=9,nt=10,fd=13,pd=32,gd=33,yd=34,pn=35,md=37,xd=38,bd=39,kd=42,bo=44,vd=45,At=58,wd=61,Cd=62,Nd=63,zd=64,ko=91,vo=93,Md=96,wo=123,_d=124,Co=125,de={};de[0]="\\0",de[7]="\\a",de[8]="\\b",de[9]="\\t",de[10]="\\n",de[11]="\\v",de[12]="\\f",de[13]="\\r",de[27]="\\e",de[34]='\\"',de[92]="\\\\",de[133]="\\N",de[160]="\\_",de[8232]="\\L",de[8233]="\\P";var $d=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],Sd=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function Ad(e,t){var n,o,r,i,s,l,c;if(t===null)return{};for(n={},o=Object.keys(t),r=0,i=o.length;r<i;r+=1)s=o[r],l=String(t[s]),s.slice(0,2)==="!!"&&(s="tag:yaml.org,2002:"+s.slice(2)),c=e.compiledTypeMap.fallback[s],c&&xo.call(c.styleAliases,l)&&(l=c.styleAliases[l]),n[s]=l;return n}function Id(e){var t,n,o;if(t=e.toString(16).toUpperCase(),e<=255)n="x",o=2;else if(e<=65535)n="u",o=4;else if(e<=4294967295)n="U",o=8;else throw new he("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+ie.repeat("0",o-t.length)+t}var Ed=1,rt=2;function Dd(e){this.schema=e.schema||cn,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=ie.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=Ad(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?rt:Ed,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function No(e,t){for(var n=ie.repeat(" ",t),o=0,r=-1,i="",s,l=e.length;o<l;)r=e.indexOf(`
|
|
157
|
+
`,o),r===-1?(s=e.slice(o),o=l):(s=e.slice(o,r+1),o=r+1),s.length&&s!==`
|
|
158
|
+
`&&(i+=n),i+=s;return i}function gn(e,t){return`
|
|
159
|
+
`+ie.repeat(" ",e.indent*t)}function Od(e,t){var n,o,r;for(n=0,o=e.implicitTypes.length;n<o;n+=1)if(r=e.implicitTypes[n],r.resolve(t))return!0;return!1}function It(e){return e===pd||e===hd}function ot(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==fn||65536<=e&&e<=1114111}function zo(e){return ot(e)&&e!==fn&&e!==fd&&e!==nt}function Mo(e,t,n){var o=zo(e),r=o&&!It(e);return(n?o:o&&e!==bo&&e!==ko&&e!==vo&&e!==wo&&e!==Co)&&e!==pn&&!(t===At&&!r)||zo(t)&&!It(t)&&e===pn||t===At&&r}function Ld(e){return ot(e)&&e!==fn&&!It(e)&&e!==vd&&e!==Nd&&e!==At&&e!==bo&&e!==ko&&e!==vo&&e!==wo&&e!==Co&&e!==pn&&e!==xd&&e!==kd&&e!==gd&&e!==_d&&e!==wd&&e!==Cd&&e!==bd&&e!==yd&&e!==md&&e!==zd&&e!==Md}function Td(e){return!It(e)&&e!==At}function it(e,t){var n=e.charCodeAt(t),o;return n>=55296&&n<=56319&&t+1<e.length&&(o=e.charCodeAt(t+1),o>=56320&&o<=57343)?(n-55296)*1024+o-56320+65536:n}function _o(e){var t=/^\n* /;return t.test(e)}var $o=1,yn=2,So=3,Ao=4,Ue=5;function Pd(e,t,n,o,r,i,s,l){var c,d=0,f=null,u=!1,h=!1,p=o!==-1,g=-1,x=Ld(it(e,0))&&Td(it(e,e.length-1));if(t||s)for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=it(e,c),!ot(d))return Ue;x=x&&Mo(d,f,l),f=d}else{for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=it(e,c),d===nt)u=!0,p&&(h=h||c-g-1>o&&e[g+1]!==" ",g=c);else if(!ot(d))return Ue;x=x&&Mo(d,f,l),f=d}h=h||p&&c-g-1>o&&e[g+1]!==" "}return!u&&!h?x&&!s&&!r(e)?$o:i===rt?Ue:yn:n>9&&_o(e)?Ue:s?i===rt?Ue:yn:h?Ao:So}function Fd(e,t,n,o,r){e.dump=(function(){if(t.length===0)return e.quotingType===rt?'""':"''";if(!e.noCompatMode&&($d.indexOf(t)!==-1||Sd.test(t)))return e.quotingType===rt?'"'+t+'"':"'"+t+"'";var i=e.indent*Math.max(1,n),s=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-i),l=o||e.flowLevel>-1&&n>=e.flowLevel;function c(d){return Od(e,d)}switch(Pd(t,l,e.indent,s,c,e.quotingType,e.forceQuotes&&!o,r)){case $o:return t;case yn:return"'"+t.replace(/'/g,"''")+"'";case So:return"|"+Io(t,e.indent)+Eo(No(t,i));case Ao:return">"+Io(t,e.indent)+Eo(No(Yd(t,s),i));case Ue:return'"'+Hd(t)+'"';default:throw new he("impossible error: invalid scalar style")}})()}function Io(e,t){var n=_o(e)?String(t):"",o=e[e.length-1]===`
|
|
160
|
+
`,r=o&&(e[e.length-2]===`
|
|
161
|
+
`||e===`
|
|
162
|
+
`),i=r?"+":o?"":"-";return n+i+`
|
|
163
|
+
`}function Eo(e){return e[e.length-1]===`
|
|
164
|
+
`?e.slice(0,-1):e}function Yd(e,t){for(var n=/(\n+)([^\n]*)/g,o=(function(){var d=e.indexOf(`
|
|
165
|
+
`);return d=d!==-1?d:e.length,n.lastIndex=d,Do(e.slice(0,d),t)})(),r=e[0]===`
|
|
166
|
+
`||e[0]===" ",i,s;s=n.exec(e);){var l=s[1],c=s[2];i=c[0]===" ",o+=l+(!r&&!i&&c!==""?`
|
|
167
|
+
`:"")+Do(c,t),r=i}return o}function Do(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,o,r=0,i,s=0,l=0,c="";o=n.exec(e);)l=o.index,l-r>t&&(i=s>r?s:l,c+=`
|
|
168
|
+
`+e.slice(r,i),r=i+1),s=l;return c+=`
|
|
169
|
+
`,e.length-r>t&&s>r?c+=e.slice(r,s)+`
|
|
170
|
+
`+e.slice(s+1):c+=e.slice(r),c.slice(1)}function Hd(e){for(var t="",n=0,o,r=0;r<e.length;n>=65536?r+=2:r++)n=it(e,r),o=de[n],!o&&ot(n)?(t+=e[r],n>=65536&&(t+=e[r+1])):t+=o||Id(n);return t}function Bd(e,t,n){var o="",r=e.tag,i,s,l;for(i=0,s=n.length;i<s;i+=1)l=n[i],e.replacer&&(l=e.replacer.call(n,String(i),l)),(ze(e,t,l,!1,!1)||typeof l>"u"&&ze(e,t,null,!1,!1))&&(o!==""&&(o+=","+(e.condenseFlow?"":" ")),o+=e.dump);e.tag=r,e.dump="["+o+"]"}function Oo(e,t,n,o){var r="",i=e.tag,s,l,c;for(s=0,l=n.length;s<l;s+=1)c=n[s],e.replacer&&(c=e.replacer.call(n,String(s),c)),(ze(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&ze(e,t+1,null,!0,!0,!1,!0))&&((!o||r!=="")&&(r+=gn(e,t)),e.dump&&nt===e.dump.charCodeAt(0)?r+="-":r+="- ",r+=e.dump);e.tag=i,e.dump=r||"[]"}function Wd(e,t,n){var o="",r=e.tag,i=Object.keys(n),s,l,c,d,f;for(s=0,l=i.length;s<l;s+=1)f="",o!==""&&(f+=", "),e.condenseFlow&&(f+='"'),c=i[s],d=n[c],e.replacer&&(d=e.replacer.call(n,c,d)),ze(e,t,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),ze(e,t,d,!1,!1)&&(f+=e.dump,o+=f));e.tag=r,e.dump="{"+o+"}"}function Ud(e,t,n,o){var r="",i=e.tag,s=Object.keys(n),l,c,d,f,u,h;if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys=="function")s.sort(e.sortKeys);else if(e.sortKeys)throw new he("sortKeys must be a boolean or a function");for(l=0,c=s.length;l<c;l+=1)h="",(!o||r!=="")&&(h+=gn(e,t)),d=s[l],f=n[d],e.replacer&&(f=e.replacer.call(n,d,f)),ze(e,t+1,d,!0,!0,!0)&&(u=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,u&&(e.dump&&nt===e.dump.charCodeAt(0)?h+="?":h+="? "),h+=e.dump,u&&(h+=gn(e,t)),ze(e,t+1,f,!0,u)&&(e.dump&&nt===e.dump.charCodeAt(0)?h+=":":h+=": ",h+=e.dump,r+=h));e.tag=i,e.dump=r||"{}"}function Lo(e,t,n){var o,r,i,s,l,c;for(r=n?e.explicitTypes:e.implicitTypes,i=0,s=r.length;i<s;i+=1)if(l=r[i],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,mo.call(l.represent)==="[object Function]")o=l.represent(t,c);else if(xo.call(l.represent,c))o=l.represent[c](t,c);else throw new he("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=o}return!0}return!1}function ze(e,t,n,o,r,i,s){e.tag=null,e.dump=n,Lo(e,n,!1)||Lo(e,n,!0);var l=mo.call(e.dump),c=o,d;o&&(o=e.flowLevel<0||e.flowLevel>t);var f=l==="[object Object]"||l==="[object Array]",u,h;if(f&&(u=e.duplicates.indexOf(n),h=u!==-1),(e.tag!==null&&e.tag!=="?"||h||e.indent!==2&&t>0)&&(r=!1),h&&e.usedDuplicates[u])e.dump="*ref_"+u;else{if(f&&h&&!e.usedDuplicates[u]&&(e.usedDuplicates[u]=!0),l==="[object Object]")o&&Object.keys(e.dump).length!==0?(Ud(e,t,e.dump,r),h&&(e.dump="&ref_"+u+e.dump)):(Wd(e,t,e.dump),h&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object Array]")o&&e.dump.length!==0?(e.noArrayIndent&&!s&&t>0?Oo(e,t-1,e.dump,r):Oo(e,t,e.dump,r),h&&(e.dump="&ref_"+u+e.dump)):(Bd(e,t,e.dump),h&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&Fd(e,e.dump,t,i,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new he("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function Xd(e,t){var n=[],o=[],r,i;for(mn(e,n,o),r=0,i=o.length;r<i;r+=1)t.duplicates.push(n[o[r]]);t.usedDuplicates=new Array(i)}function mn(e,t,n){var o,r,i;if(e!==null&&typeof e=="object")if(r=t.indexOf(e),r!==-1)n.indexOf(r)===-1&&n.push(r);else if(t.push(e),Array.isArray(e))for(r=0,i=e.length;r<i;r+=1)mn(e[r],t,n);else for(o=Object.keys(e),r=0,i=o.length;r<i;r+=1)mn(e[o[r]],t,n)}function jd(e,t){t=t||{};var n=new Dd(t);n.noRefs||Xd(e,n);var o=e;return n.replacer&&(o=n.replacer.call({"":o},"",o)),ze(n,0,o,!0,!0)?n.dump+`
|
|
171
|
+
`:""}var Gd=jd,Vd={dump:Gd};function xn(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var Kd=ce,qd=Lr,Zd=Yr,Jd=Xr,Qd=jr,Rd=cn,eu=yo.load,tu=yo.loadAll,nu=Vd.dump,ru=he,ou={binary:Zr,float:Ur,map:Fr,null:Hr,pairs:Qr,set:Rr,timestamp:Kr,bool:Br,int:Wr,merge:qr,omap:Jr,seq:Pr,str:Tr},iu=xn("safeLoad","load"),su=xn("safeLoadAll","loadAll"),au=xn("safeDump","dump"),lu={Type:Kd,Schema:qd,FAILSAFE_SCHEMA:Zd,JSON_SCHEMA:Jd,CORE_SCHEMA:Qd,DEFAULT_SCHEMA:Rd,load:eu,loadAll:tu,dump:nu,YAMLException:ru,types:ou,safeLoad:iu,safeLoadAll:su,safeDump:au};function cu(e){const t=e.match(/^(\d+)x(\d+)x(\d+)$/);return t?{width:parseInt(t[1],10),depth:parseInt(t[2],10),height:parseInt(t[3],10)}:null}function To(e){const t=e.match(/^(\d+)x(\d+)$/);return t?{width:parseInt(t[1],10),height:parseInt(t[2],10)}:null}function du(e){const t=e.match(/^(-?\d+),(-?\d+)$/);return t?{x:parseInt(t[1],10),y:parseInt(t[2],10)}:null}function uu(e){const t=e.match(/^(.+?)\s*@\s*(\d+)$/);return t?{name:t[1].trim(),elevation:parseInt(t[2],10)}:null}function hu(e,t,n){let o={};const r=e.match(/\{([^}]+)\}\s*$/);if(r){const p=r[1].split(/\s+/);for(const g of p){const[x,k]=g.split("=");if(x&&k){const y=parseFloat(k);o[x]=isNaN(y)?k:y}}e=e.replace(/\{[^}]+\}\s*$/,"").trim()}const i=e.trim().split(/\s+/);if(i.length<4)return null;const s=i[0],l=i[1],c=i[2],d=i[3],f=du(c),u=cu(d);if(!f||!u)return null;const h=n[l]||l;return{tier:t,label:s,color:h,x:f.x,y:f.y,width:u.width,depth:u.depth,height:u.height,...o}}function fu(e){const t=lu.load(e);let n={width:1100,height:700};if(typeof t.canvas=="string"){const h=To(t.canvas);h&&(n=h)}else t.canvas&&typeof t.canvas=="object"&&(n=t.canvas);let o={width:400,depth:280};if(typeof t.floor=="string"){const h=To(t.floor);h&&(o={width:h.width,depth:h.height})}else t.floor&&typeof t.floor=="object"&&(o=t.floor);let r={x:n.width/2,y:n.height-80};t.origin&&typeof t.origin=="object"&&(r=t.origin);const i={};if(t.colors&&typeof t.colors=="object")for(const[h,p]of Object.entries(t.colors))i[h]=p;const s=[],l={dark:["#0f172a","#1e293b","#334155","#475569"],light:["#f1f5f9","#e0f2fe","#dbeafe","#ede9fe"]},c={dark:["#334155","#475569","#64748b","#94a3b8"],light:["#94a3b8","#7dd3fc","#93c5fd","#c4b5fd"]},d=t.theme||"dark";Array.isArray(t.tiers)&&t.tiers.forEach((h,p)=>{if(typeof h=="string"){const g=uu(h);g&&s.push({name:g.name,elevation:g.elevation,floorColor:l[d][p]||l[d][0],floorOpacity:p===0?.95:.7-p*.1,borderColor:c[d][p]||c[d][0]})}else if(h&&typeof h=="object"){const g=h;s.push({name:g.name||`Tier ${p}`,elevation:g.elevation||p*150,floorColor:g.floorColor||l[d][p],floorOpacity:g.floorOpacity??(p===0?.95:.7-p*.1),borderColor:g.borderColor||c[d][p]})}});const f=[];if(t.nodes&&typeof t.nodes=="object"&&!Array.isArray(t.nodes)){const h=t.nodes;for(const[p,g]of Object.entries(h)){const x=parseInt(p,10);if(!(isNaN(x)||!Array.isArray(g))){for(const k of g)if(typeof k=="string"){const y=hu(k,x,i);y&&f.push(y)}else if(k&&typeof k=="object"){const y=k;f.push({tier:x,label:y.label||"",color:i[y.color]||y.color||"slate",x:y.x||0,y:y.y||0,width:y.width||100,depth:y.depth||80,height:y.height||40,opacity:y.opacity,blur:y.blur,translucent:y.translucent})}}}}const u=[];if(Array.isArray(t.pillars)){for(const h of t.pillars)if(typeof h=="string"){const p=h.match(/^(-?\d+),(-?\d+)\s+(\d+)->(\d+)$/);p&&u.push({x:parseInt(p[1],10),y:parseInt(p[2],10),fromTier:parseInt(p[3],10),toTier:parseInt(p[4],10)})}else if(h&&typeof h=="object"){const p=h;u.push({x:p.x||0,y:p.y||0,fromTier:p.fromTier||0,toTier:p.toTier||1})}}return{title:t.title||"Untitled",description:t.description||"",theme:d,canvas:n,origin:r,cornerRadius:t.corner??t.cornerRadius??14,tiers:s,floorSize:o,nodes:f,pillars:u.length>0?u:void 0}}function pu(e){const t=[];t.push(`title: ${e.title}`),e.description&&t.push(`description: ${e.description}`),t.push(`theme: ${e.theme}`),t.push(`canvas: ${e.canvas.width}x${e.canvas.height}`),t.push(`floor: ${e.floorSize.width}x${e.floorSize.depth}`),e.cornerRadius&&t.push(`corner: ${e.cornerRadius}`),t.push("");const n={};e.nodes.forEach(r=>{n[r.color]=(n[r.color]||0)+1});const o=Object.entries(n).filter(([,r])=>r>=2).map(([r])=>r);return o.length>0&&(t.push("colors:"),o.forEach(r=>{const i=r.slice(0,3);t.push(` ${i}: &${i} ${r}`)}),t.push("")),t.push("tiers:"),e.tiers.forEach(r=>{t.push(` - ${r.name} @ ${r.elevation}`)}),t.push(""),t.push("nodes:"),e.tiers.forEach((r,i)=>{const s=e.nodes.filter(l=>l.tier===i);s.length!==0&&(t.push(` ${i}: # ${r.name}`),s.forEach(l=>{let c=l.color;o.includes(l.color)&&(c=`*${l.color.slice(0,3)}`);const d=[];l.opacity!==void 0&&d.push(`opacity=${l.opacity}`),l.blur!==void 0&&d.push(`blur=${l.blur}`),l.translucent&&d.push("translucent=true");const f=d.length>0?` { ${d.join(" ")} }`:"",u=`${l.width}x${l.depth}x${l.height}`,h=`${l.x},${l.y}`,p=l.label.padEnd(12),g=c.padEnd(8);t.push(` - ${p} ${g} ${h.padEnd(8)} ${u}${f}`)}))}),e.pillars&&e.pillars.length>0&&(t.push(""),t.push("pillars:"),e.pillars.forEach(r=>{t.push(` - ${r.x},${r.y} ${r.fromTier}->${r.toTier}`)})),t.join(`
|
|
172
|
+
`)}K.ArcDiagram=Yl,K.DiagramCanvas=Qn,K.DiagramEditor=Ol,K.EditorProvider=Yn,K.ISO_COLORS=Ge,K.configToYaml=pu,K.getColorShading=Vn,K.isoBoundingBox=bs,K.isoBox=Oe,K.isoShading=Gn,K.isoToScreen=T,K.parseYamlConfig=fu,K.renderToElement=Wl,K.renderToString=Ir,K.screenToIsoFloor=Yt,K.useDiagram=ke,K.useEditor=le,K.useEditorState=je,K.useViewMode=Ft,Object.defineProperty(K,Symbol.toStringTag,{value:"Module"})}));
|