1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[974],{61:()=>{},2417:(e,t,n)=>{"use strict";n.r(t),n.d(t,{default:()=>ed});var r=n(5155),o=n(2115),a=n(9462),i=n(8218),s=n(3728),l=n(5242);n(61);var d=n(5339),c=n(7548),u=n(7003),p=n(7650),m=n(5016);let h=o.forwardRef((e,t)=>{var n,a,i,s;let{className:l,children:d,value:c,onChange:u,disabled:h,...g}=e,[x,f]=o.useState(!1),[b,v]=o.useState({}),y=o.useRef(null),j=o.useRef(null),w=o.useRef(null),N=o.useMemo(()=>{let e=[];return o.Children.forEach(d,t=>{if(o.isValidElement(t)&&"option"===t.type){var n,r;let o=t.props;e.push({value:null!=(n=o.value)?n:"",label:"string"==typeof o.children?o.children:String(null!=(r=o.children)?r:""),disabled:o.disabled})}}),e},[d]),C=null!=(s=null!=(i=null==(n=N.find(e=>e.value===String(null!=c?c:"")))?void 0:n.label)?i:null==(a=N[0])?void 0:a.label)?s:"";o.useEffect(()=>{if(!x)return;let e=e=>{var t,n;let r=e.target,o=null==(t=y.current)?void 0:t.contains(r),a=null==(n=w.current)?void 0:n.contains(r);o||a||f(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[x]),o.useEffect(()=>{if(!x)return;let e=e=>{"Escape"===e.key&&f(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[x]);let k=x?(0,r.jsx)("div",{ref:w,style:b,className:"nb-select-list rounded-xl border overflow-hidden shadow-lg",children:(0,r.jsx)("div",{className:"max-h-60 overflow-y-auto py-1 scrollbar-thin",children:N.map(e=>{let t=String(null!=c?c:"")===e.value;return(0,r.jsxs)("button",{type:"button",disabled:e.disabled,onMouseDown:t=>{t.preventDefault(),e.disabled||(e=>{null==u||u({target:{value:e},currentTarget:{value:e}}),f(!1)})(e.value)},className:(0,m.cn)("nb-select-option w-full px-3 py-1.5 text-sm text-left transition-colors duration-100 flex items-center gap-2",t&&"is-selected",e.disabled&&"opacity-35 cursor-not-allowed"),children:[t&&(0,r.jsx)("svg",{viewBox:"0 0 10 8",className:"h-2.5 w-2.5 flex-shrink-0 opacity-60",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M1 4l3 3 5-6"})}),!t&&(0,r.jsx)("span",{className:"w-2.5 flex-shrink-0"}),(0,r.jsx)("span",{className:"truncate",children:e.label})]},e.value)})})}):null;return(0,r.jsxs)("div",{ref:y,className:(0,m.cn)("nb-select relative w-full",l),children:[(0,r.jsx)("select",{ref:t,value:c,onChange:u,disabled:h,className:"sr-only",tabIndex:-1,"aria-hidden":"true",...g,children:d}),(0,r.jsx)("button",{ref:j,type:"button",disabled:h,onClick:()=>{if(!h){if(!x&&j.current){let e=j.current.getBoundingClientRect();v({position:"fixed",top:e.bottom+4,left:e.left,width:e.width,zIndex:99999})}f(e=>!e)}},className:(0,m.cn)("w-full h-9 rounded-lg border px-3 pr-8 text-sm font-medium text-foreground/90 outline-none transition-all duration-150 cursor-pointer flex items-center text-left select-none nb-select-trigger",x&&"is-open",h&&"cursor-not-allowed opacity-40"),children:(0,r.jsx)("span",{className:"truncate",children:C})}),(0,r.jsx)("svg",{"aria-hidden":!0,viewBox:"0 0 12 8",className:(0,m.cn)("pointer-events-none absolute right-2.5 top-1/2 -translate-y-1/2 h-2 w-2.5 text-foreground/40 transition-transform duration-150",x&&"rotate-180"),fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M1 1.5l5 5 5-5"})}),"undefined"!=typeof document&&k&&(0,p.createPortal)(k,document.body)]})});h.displayName="Select";let g=o.forwardRef((e,t)=>{let{className:n,...o}=e;return(0,r.jsx)("textarea",{className:(0,m.cn)("flex w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",n),ref:t,...o})});g.displayName="Textarea";let x=o.forwardRef((e,t)=>{let{className:n,label:o,valueLabel:a,min:i=0,max:s=100,step:l=1,...d}=e;return(0,r.jsxs)("div",{className:(0,m.cn)("w-full",n),children:[(o||a)&&(0,r.jsxs)("div",{className:"flex items-center justify-between text-xs text-muted-foreground mb-1",children:[(0,r.jsx)("span",{children:o}),(0,r.jsx)("span",{children:a})]}),(0,r.jsx)("input",{ref:t,type:"range",min:i,max:s,step:l,className:(0,m.cn)("w-full appearance-none h-2 rounded-lg bg-muted outline-none focus-visible:ring-2 focus-visible:ring-ring","[&::-webkit-slider-thumb]:appearance-none [&::-webkit-slider-thumb]:h-4 [&::-webkit-slider-thumb]:w-4 [&::-webkit-slider-thumb]:rounded-full","[&::-webkit-slider-thumb]:bg-primary [&::-webkit-slider-thumb]:cursor-pointer","[&::-moz-range-thumb]:h-4 [&::-moz-range-thumb]:w-4 [&::-moz-range-thumb]:border-0 [&::-moz-range-thumb]:rounded-full [&::-moz-range-thumb]:bg-primary"),...d})]})});x.displayName="Slider";let f=["#FFFFFF","#E5E5E5","#A1A1A1","#525252","#1F1F1F","#000000","#EF4444","#F59E0B","#FACC15","#22C55E","#06B6D4","#3B82F6","#8B5CF6","#EC4899","#FDE68A","#FCA5A5","#A7F3D0","#BFDBFE"];function b(e){let t=e.trim().replace(/^#/,"").toUpperCase();return(3===(t=t.replace(/[^0-9A-F]/g,"").slice(0,6)).length&&(t=t.
1split("").map(e=>e+e).join("")),6!==t.length)?"":"#"+t}function v(e,t,n){let r=n*t,o=r*(1-Math.abs(e/60%2-1)),a=n-r,i=0,s=0,l=0;e<60?[i,s,l]=[r,o,0]:e<120?[i,s,l]=[o,r,0]:e<180?[i,s,l]=[0,r,o]:e<240?[i,s,l]=[0,o,r]:e<300?[i,s,l]=[o,0,r]:[i,s,l]=[r,0,o];let d=e=>Math.round((e+a)*255).toString(16).padStart(2,"0").toUpperCase();return"#"+d(i)+d(s)+d(l)}let y=o.forwardRef((e,t)=>{let{className:n,value:a,onChange:i,...s}=e,l="string"==typeof a&&/^#?[0-9a-f]{3,6}$/i.test(a)&&b(a)||"#FFFFFF",[d,c]=o.useState(!1),[u,p]=o.useState(l),h=o.useRef(null),g=o.useRef(null);o.useEffect(()=>{p(l)},[l]),o.useEffect(()=>{if(!d)return;let e=e=>{var t,n;let r=e.target;(null==(t=g.current)?void 0:t.contains(r))||(null==(n=h.current)?void 0:n.contains(r))||c(!1)},t=e=>{"Escape"===e.key&&c(!1)};return document.addEventListener("pointerdown",e),document.addEventListener("keydown",t),()=>{document.removeEventListener("pointerdown",e),document.removeEventListener("keydown",t)}},[d]);let x=e=>{i&&i({target:{value:e}})},y=function(e){let t=e.match(/^#?([0-9a-f]{6})$/i);if(!t)return{h:0,s:0,v:0};let n=parseInt(t[1],16),r=(n>>16&255)/255,o=(n>>8&255)/255,a=(255&n)/255,i=Math.max(r,o,a),s=i-Math.min(r,o,a),l=0;if(0!==s){switch(i){case r:l=(o-a)/s%6;break;case o:l=(a-r)/s+2;break;case a:l=(r-o)/s+4}(l*=60)<0&&(l+=360)}return{h:l,s:0===i?0:s/i,v:i}}(l);return(0,r.jsxs)("div",{ref:h,className:(0,m.cn)("nb-color relative w-full",n),children:[(0,r.jsxs)("button",{type:"button",onClick:()=>c(e=>!e),className:(0,m.cn)("group flex w-full items-center gap-2 h-9 rounded-lg border border-input bg-background hover:bg-muted/60 hover:border-ring/35 pl-1.5 pr-3 cursor-pointer transition-colors text-foreground",d&&"border-primary/60 ring-2 ring-primary/25"),"aria-haspopup":"dialog","aria-expanded":d,children:[(0,r.jsx)("span",{className:"relative inline-block h-6 w-6 rounded-md ring-1 ring-border shadow-inner overflow-hidden",style:{backgroundImage:"linear-gradient(45deg, hsl(var(--foreground) / 0.09) 25%, transparent 25%), linear-gradient(-45deg, hsl(var(--foreground) / 0.09) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, hsl(var(--foreground) / 0.09) 75%), linear-gradient(-45deg, transparent 75%, hsl(var(--foreground) / 0.09) 75%)",backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0"},children:(0,r.jsx)("span",{className:"absolute inset-0",style:{backgroundColor:l}})}),(0,r.jsx)("span",{className:"flex-1 text-left text-xs font-mono uppercase tracking-wider text-foreground/85 select-none",children:l}),(0,r.jsx)("svg",{"aria-hidden":!0,viewBox:"0 0 12 8",className:(0,m.cn)("h-2.5 w-3 text-foreground/60 transition-transform",d&&"rotate-180"),fill:"none",stroke:"currentColor",strokeWidth:"1.75",strokeLinecap:"round",strokeLinejoin:"round",children:(0,r.jsx)("path",{d:"M1 1.5l5 5 5-5"})})]}),d&&(0,r.jsxs)("div",{ref:g,className:"absolute z-50 mt-2 w-60 rounded-xl border border-border bg-popover p-3 shadow-2xl text-popover-foreground",role:"dialog",children:[(0,r.jsxs)("div",{className:"relative h-32 w-full rounded-md overflow-hidden cursor-crosshair touch-none",onPointerDown:e=>{let t=e.currentTarget;t.setPointerCapture(e.pointerId);let n=t.getBoundingClientRect(),r=(e,t)=>{let r=Math.min(Math.max(0,e-n.left),n.width),o=Math.min(Math.max(0,t-n.top),n.height),a=0===n.width?0:r/n.width,i=0===n.height?0:1-o/n.height;x(v(y.h,a,i))};r(e.clientX,e.clientY);let o=e=>r(e.clientX,e.clientY),a=()=>{t.removeEventListener("pointermove",o),t.removeEventListener("pointerup",a)};t.addEventListener("pointermove",o),t.addEventListener("pointerup",a)},style:{backgroundColor:v(y.h,1,1)},children:[(0,r.jsx)("div",{className:"absolute inset-0",style:{background:"linear-gradient(to right, #ffffff, transparent)"}}),(0,r.jsx)("div",{className:"absolute inset-0",style:{background:"linear-gradient(to top, #000000, transparent)"}}),(0,r.jsx)("div",{className:"absolute h-3 w-3 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow pointer-events-none",style:{left:"".concat(100*y.s,"%"),top:"".concat((1-y.v)*100,"%")}})]}),(0,r.jsx)("div",{className:"relative mt-3 h-3 w-full rounded-full cursor-ew-resize touch-none",onPointerDown:e=>{let t=e.currentTarget;t.setPointerCapture(e.pointerId);let n=t.getBoundingClientRect(),r=e=>{let t=Math.min(Math.max(0,e-n.left),n.width);x(v(0===n.width?0:t/n.width*360,y.s||1,y.v||1))};r(e.clientX);let o=e=>r(e.clientX),a=()=>{t.removeEventListener("pointermove",o),t.removeEventListener("pointerup",a)};t.addEventListener("pointermove",o),t.addEventListener("pointerup",a)},style:{background:"linear-gradient(to right, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%)"},children:(0,r.jsx)("div",{className:"absolute top-1/2 h-4 w-4 -translate-x-1/2 -translate-y-1/2 roun
1ded-full border-2 border-white shadow pointer-events-none",style:{left:"".concat(y.h/360*100,"%")}})}),(0,r.jsxs)("div",{className:"mt-3 flex items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[10px] font-mono text-foreground/60",children:"HEX"}),(0,r.jsx)("input",{value:u.replace(/^#/,""),onChange:e=>p(e.target.value),onBlur:()=>{let e=b(u);e?x(e):p(l)},onKeyDown:e=>{if("Enter"===e.key){let t=b(u);t?x(t):p(l),e.currentTarget.blur()}},className:"flex-1 h-7 rounded-md border border-input bg-background px-2 text-xs font-mono uppercase tracking-wider text-foreground/95 focus:outline-none focus:border-primary/60 focus:ring-1 focus:ring-primary/25",spellCheck:!1,maxLength:7})]}),(0,r.jsx)("div",{className:"mt-3 grid grid-cols-9 gap-1.5",children:f.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>x(e),title:e,className:(0,m.cn)("h-5 w-5 rounded-md ring-1 ring-border hover:ring-ring transition-all",e.toUpperCase()===l&&"ring-2 ring-primary"),style:{backgroundColor:e}},e))})]})]})});y.displayName="ColorPicker";let j=o.forwardRef((e,t)=>{let{className:n,...o}=e;return(0,r.jsx)("input",{ref:t,type:"checkbox",className:(0,m.cn)("h-4 w-4 rounded border border-input bg-background cursor-pointer align-middle",n),style:{accentColor:"hsl(var(--primary))"},...o})});j.displayName="Checkbox";var w=n(5299),N=n(5664),C=n(368),k=n(7937),P=n(4033),E=n(2108);function S(e){let{label:t,values:n,current:o,onChange:a,format:i,title:s}=e,l=Math.max(0,n.indexOf(null!=o?o:n[0])),d=i?i(n[l]):n[l],c=Math.max(1,n.length-1);return(0,r.jsxs)("div",{title:s,children:[(0,r.jsxs)("div",{className:"flex items-center justify-between mb-1",children:[(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:t}),(0,r.jsx)("span",{className:"text-xs font-medium tabular-nums ".concat(0===l?"text-muted-foreground/60":"text-foreground"),children:d})]}),(0,r.jsxs)("div",{className:"nb-preset-slider-wrap",style:{"--pct":"".concat(l/c*100,"%")},children:[(0,r.jsx)("div",{className:"nb-preset-slider-track","aria-hidden":"true",children:(0,r.jsx)("div",{className:"nb-preset-slider-fill"})}),(0,r.jsx)("div",{className:"nb-preset-slider-ticks","aria-hidden":"true",children:n.map((e,t)=>(0,r.jsx)("span",{className:t<=l?"is-active":void 0},t))}),(0,r.jsx)("input",{type:"range",min:0,max:n.length-1,step:1,value:l,onChange:e=>a(n[parseInt(e.target.value,10)]),onPointerDown:e=>e.stopPropagation(),className:"nb-preset-slider w-full","aria-label":t})]})]})}function R(e){let{startTime:t,executionTime:n,isRunning:a}=e,[i,s]=(0,o.useState)(0);if((0,o.useEffect)(()=>{if(!a||!t)return;let e=setInterval(()=>{s(Date.now()-t)},100);return()=>clearInterval(e)},[a,t]),!t&&!n)return null;let l=((a?i:n||0)/1e3).toFixed(1);return(0,r.jsxs)("span",{className:"flex items-center gap-1 text-[10px] font-mono font-normal opacity-70",children:[a?(0,r.jsx)(w.A,{className:"w-3 h-3 animate-spin text-banana-500"}):(0,r.jsx)("span",{className:"text-green-500 font-bold",children:"â"}),l,"s"]})}async function A(e){try{let t=await fetch(e),n=await t.blob();if("image/png"!==n.type){let t=document.createElement("canvas"),n=t.getContext("2d"),r=new Image;await new Promise(o=>{r.onload=()=>{t.width=r.width,t.height=r.height,null==n||n.drawImage(r,0,0),o(void 0)},r.src=e});let o=await new Promise(e=>{t.toBlob(t=>e(t),"image/png")});await navigator.clipboard.write([new ClipboardItem({"image/png":o})])}else await navigator.clipboard.write([new ClipboardItem({"image/png":n})])}catch(e){console.error("Failed to copy image to clipboard:",e)}}function M(e){let{nodeId:t,output:n,downloadFileName:o}=e;return n?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("div",{className:"flex items-center justify-between",children:(0,r.jsx)("div",{className:"text-xs text-white/70",children:"Output"})}),(0,r.jsx)("img",{src:n,className:"w-full rounded cursor-pointer hover:opacity-80 transition-all duration-200 hover:ring-2 hover:ring-white/30",alt:"Output",onClick:()=>A(n),onContextMenu:e=>{e.preventDefault(),A(n);let t=e.currentTarget,r=t.title;t.title="Copied to clipboard!",t.style.filter="brightness(1.2)",t.style.transform="scale(0.98)",setTimeout(()=>{t.title=r,t.style.filter="",t.style.transform=""},300)},title:"Click or right-click to copy image to clipboard"})]}),(0,r.jsx)(u.$,{className:"w-full hover:bg-primary hover:text-primary-foreground transition-colors",variant:"secondary",onClick:()=>(function(e,t){let n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n)})(n,o),children:"Download Output"})]}):null}let T=1;function I(e,t){let[n,r]=(0,o.useState)({x:e.x,y:e.y}),a=(0,o.useRef)(!1),i=(0,o.useRef)(null);return(0,o.useEffect)(()=>{r({x:e.x,y:e.y})},[e.x,e.y]),{localPos:n,onPointerDown:e=>{e.stopPropagation(),a.current=!0,i.current={sx:e.clientX,sy:e.clientY,ox:n.x,oy:n.y},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:n=>{if(!a.current||!i.current)return;
1let o=(n.clientX-i.current.sx)/T,s=(n.clientY-i.current.sy)/T,l=i.current.ox+o,d=i.current.oy+s;r({x:l,y:d}),t&&t(e.id,l,d)},onPointerUp:e=>{a.current=!1,i.current=null,e.currentTarget.releasePointerCapture(e.pointerId)}}}function D(e){let{className:t,nodeId:n,isOutput:o,connected:a,onStartConnection:i,onEndConnection:s,onDisconnect:l}=e;return(0,r.jsx)("div",{className:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter(Boolean).join(" ")}("nb-port",t,o?"out":"in",a&&"nb-port--connected"),onPointerDown:e=>{e.stopPropagation(),o&&n&&i?i(n):!o&&a&&n&&l&&l(n)},onPointerUp:e=>{!o&&n&&s&&(e.stopPropagation(),s(n))},title:o?"Drag from here to connect to another node's input":a?"Pull to disconnect":"Drop a connection here"})}function O(e){let{node:t,onDelete:n,onUpdate:o,onStartConnection:a,onEndConnection:i,onProcess:s,onUpdatePosition:l,outputConnected:d}=e,{localPos:c,onPointerDown:p,onPointerMove:m,onPointerUp:x}=I(t,l);return(0,r.jsxs)("div",{className:"nb-node absolute text-white w-[320px]",style:{left:c.x,top:c.y},onDrop:e=>{e.preventDefault();let n=e.dataTransfer.files;if(n&&n.length){let e=new FileReader;e.onload=()=>{o(t.id,{customBackgroundImage:e.result})},e.readAsDataURL(n[0])}},onDragOver:e=>e.preventDefault(),onPaste:e=>{let n=e.clipboardData.items;for(let e=0;e<n.length;e++)if(n[e].type.startsWith("image/")){let r=n[e].getAsFile();if(r){let e=new FileReader;e.onload=()=>{o(t.id,{customBackgroundImage:e.result})},e.readAsDataURL(r);return}}let r=e.clipboardData.getData("text");r&&(r.startsWith("http")||r.startsWith("data:image"))&&o(t.id,{customBackgroundImage:r})},children:[(0,r.jsxs)("div",{className:"nb-header px-3 py-2 flex items-center justify-between rounded-t-[14px] cursor-grab active:cursor-grabbing",onPointerDown:p,onPointerMove:m,onPointerUp:x,children:[(0,r.jsx)(D,{className:"in",nodeId:t.id,isOutput:!1,connected:!!t.input,onEndConnection:i,onDisconnect:e=>
1o(e,{input:void 0})}),(0,r.jsxs)("div",{className:"font-semibold text-sm flex-1 text-center flex items-center justify-center gap-1.5",children:["BACKGROUND",(0,r.jsx)(R,{startTime:t.startTime,executionTime:t.executionTime,isRunning:t.isRunning})]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(D,{className:"out",nodeId:t.id,isOutput:!0,connected:d,onStartConnection:a})})]}),(0,r.jsxs)("div",{className:"p-3 space-y-3",children:[(0,r.jsxs)(h,{className:"w-full",value:t.backgroundType||"color",onChange:e=>o(t.id,{backgroundType:e.target.value}),children:[(0,r.jsx)("option",{value:"color",children:"Solid Color"}),(0,r.jsx)("option",{value:"gradient",children:"Gradient Color"}),(0,r.jsx)("option",{value:"image",children:"Preset Background"}),(0,r.jsx)("option",{value:"city",children:"City Scene"}),(0,r.jsx)("option",{value:"photostudio",children:"Photo Studio"}),(0,r.jsx)("option",{value:"upload",children:"Upload Image"}),(0,r.jsx)("option",{value:"custom",children:"Custom Prompt"})]}),"color"===t.backgroundType&&(0,r.jsx)(y,{className:"w-full",value:t.backgroundColor||"#ffffff",onChange:e=>o(t.id,{backgroundColor:e.target.value})}),"gradient"===t.backgroundType&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("label",{className:"text-xs text-white/70",children:"Gradient Direction"}),(0,r.jsxs)(h,{className:"w-full",value:t.gradientDirection||"to right",onChange:e=>o(t.id,{gradientDirection:e.target.value}),children:[(0,r.jsx)("option",{value:"to right",children:"Left to Right"}),(0,r.jsx)("option",{value:"to left",children:"Right to Left"}),(0,r.jsx)("option",{value:"to bottom",children:"Top to Bottom"}),(0,r.jsx)("option",{value:"to top",children:"Bottom to Top"}),(0,r.jsx)("option",{value:"to bottom right",children:"Diagonal Top-Left to Bottom-Right"}),(0,r.jsx)("option",{value:"to bottom left",children:"Diagonal Top-Right to Bottom-Left"}),(0,r.jsx)("option",{value:"to top right",children:"Diagonal Bottom-Left to Top-Right"}),(0,r.jsx)("option",{value:"to top left",children:"Diagonal Bottom-Right to Top-Left"}),(0,r.jsx)("option",{value:"radial",children:"Radial (Center to Edge)"})]}),(0,r.jsx)("label",{className:"text-xs text-white/70",children:"Start Color"}),(0,r.jsx)(y,{className:"w-full",value:t.gradientStartColor||"#ff6b6b",onChange:e=>o(t.id,{gradientStartColor:e.target.value})}),(0,r.jsx)("label",{className:"text-xs text-white/70",children:"End Color"}),(0,r.jsx)(y,{className:"w-full",value:t.gradientEndColor||"#4ecdc4",onChange:e=>o(t.id,{gradientEndColor:e.target.value})}),(0,r.jsx)("div",{className:"w-full h-8 rounded-md border border-white/20",style:{background:"radial"===t.gradientDirection?"radial-gradient(circle, ".concat(t.gradientStartColor||"#ff6b6b"," 0%, ").concat(t.gradientEndColor||"#4ecdc4"," 100%)"):"linear-gradient(".concat(t.gradientDirection||"to right",", ").concat(t.gradientStartColor||"#ff6b6b"," 0%, ").concat(t.gradientEndColor||"#4ecdc4"," 100%)")},title:"Gradient Preview"})]}),"image"===t.backgroundType&&(0,r.jsxs)(h,{className:"w-full",value:t.backgroundImage||"",onChange:e=>o(t.id,{backgroundImage:e.target.value}),children:[(0,r.jsx)("option",{value:"",children:"Select Backgroun
1d"}),(0,r.jsx)("option",{value:"beach",children:"Beach"}),(0,r.jsx)("option",{value:"office",children:"Office"}),(0,r.jsx)("option",{value:"studio",children:"Studio"}),(0,r.jsx)("option",{value:"nature",children:"Nature"}),(0,r.jsx)("option",{value:"city",children:"City Skyline"})]}),"city"===t.backgroundType&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("label",{className:"text-xs text-white/70",children:"City Scene Type"}),(0,r.jsxs)(h,{className:"w-full",value:t.citySceneType||"busy_street",onChange:e=>o(t.id,{citySceneType:e.target.value}),children:[(0,r.jsx)("option",{value:"busy_street",children:"Busy Street with Close Pedestrians"}),(0,r.jsx)("option",{value:"tokyo_shibuya",children:"Tokyo Shibuya Crossing"}),(0,r.jsx)("option",{value:"tokyo_subway",children:"Tokyo Subway"}),(0,r.jsx)("option",{value:"times_square",children:"Times Square NYC"}),(0,r.jsx)("option",{value:"downtown_skyline",children:"Downtown Skyline"}),(0,r.jsx)("option",{value:"urban_crosswalk",children:"Urban Crosswalk Scene"}),(0,r.jsx)("option",{value:"shopping_district",children:"Shopping District"}),(0,r.jsx)("option",{value:"city_park",children:"City Park"}),(0,r.jsx)("option",{value:"rooftop_view",children:"Rooftop City View"}),(0,r.jsx)("option",{value:"blade_runner_street",children:"Blade Runner Style Street"}),(0,r.jsx)("option",{value:"matrix_alley",children:"Matrix Style Urban Alley"})]}),(0,r.jsx)("label",{className:"text-xs text-white/70",children:"Time of Day"}),(0,r.jsxs)(h,{className:"w-full",value:t.cityTimeOfDay||"daytime",onChange:e=>o(t.id,{cityTimeOfDay:e.target.value}),children:[(0,r.jsx)("option",{value:"golden_hour",children:"Golden Hour"}),(0,r.jsx)("option",{value:"daytime",children:"Daytime"}),(0,r.jsx)("option",{value:"blue_hour",children:"Blue Hour"}),(0,r.jsx)("option",{value:"night",children:"Night with City Lights"}),(0,r.jsx)("option",{value:"dawn",children:"Dawn"}),(0,r.jsx)("option",{value:"overcast",children:"Overcast Day"})]})]}),"photostudio"===t.backgroundType&&(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("label",{className:"text-xs text-white/70",children:"Studio Setup"}),(0,r.jsxs)(h,{className:"w-full",value:t.studioSetup||"white_seamless",onChange:e=>o(t.id,{studioSetup:e.target.value}),children:[(0,r.jsx)("option",{value:"white_seamless",children:"White Seamless Background"}),(0,r.jsx)("option",{value:"black_seamless",children:"Black Seamless Background"}),(0,r.jsx)("option",{value:"grey_seamless",children:"Grey Seamless Background"}),(0,r.jsx)("option",{value:"colored_seamless",children:"Colored Seamless Background"}),(0,r.jsx)("option",{value:"textured_backdrop",children:"Textured Backdrop"}),(0,r.jsx)("option",{value:"infinity_cove",children:"Infinity Cove"})]}),"colored_seamless"===t.studioSetup&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("label",{className:"text-xs text-white/70",children:"Backgroun
1d Color"}),(0,r.jsx)(y,{className:"w-full",value:t.studioBackgroundColor||"#ffffff",onChange:e=>o(t.id,{studioBackgroundColor:e.target.value})})]}),(0,r.jsx)("label",{className:"text-xs text-white/70",children:"Lighting Setup"}),(0,r.jsxs)(h,{className:"w-full",value:t.studioLighting||"key_fill",onChange:e=>o(t.id,{studioLighting:e.target.value}),children:[(0,r.jsx)("option",{value:"key_fill",children:"Key + Fill Light"}),(0,r.jsx)("option",{value:"three_point",children:"Three-Point Lighting"}),(0,r.jsx)("option",{value:"beauty_lighting",children:"Beauty Lighting"}),(0,r.jsx)("option",{value:"dramatic_lighting",children:"Dramatic Single Light"}),(0,r.jsx)("option",{value:"soft_lighting",children:"Soft Diffused Lighting"}),(0,r.jsx)("option",{value:"hard_lighting",children:"Hard Directional Lighting"})]}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)("input",{type:"checkbox",checked:t.faceCamera||!1,onChange:e=>o(t.id,{faceCamera:e.target.checked}),className:"w-4 h-4"}),(0,r.jsx)("label",{className:"text-xs text-white/70",children:"Position character to face camera"})]})]}),"upload"===t.backgroundType&&(0,r.jsx)("div",{className:"space-y-2",children:t.customBackgroundImage?(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("img",{src:t.customBackgroundImage,className:"w-full rounded",alt:"Custom Background"}),(0,r.jsx)(u.$,{variant:"destructive",size:"sm",className:"absolute top-2 right-2",onClick:()=>o(t.id,{customBackgroundImage:null}),children:"Remove"})]}):(0,r.jsxs)("label",{className:"block",children:[(0,r.jsx)("input",{type:"file",accept:"image/*",className:"hidden",onChange:e=>{var n;if(null==(n=e.target.files)?void 0:n.length){let n=new FileReader;n.onload=()=>{o(t.id,{customBackgroundImage:n.result})},n.readAsDataURL(e.target.files[0])}}}),(0,r.jsxs)("div",{className:"border-2 border-dashed border-white/20 rounded-lg p-4 text-center cursor-pointer hover:border-white/40",children:[(0,r.jsx)("p",{className:"text-xs text-white/60",children:"Drop, upload, or paste background image"}),(0,r.jsx)("p",{className:"text-xs text-white/40 mt-1",children:"JPG, PNG, WEBP"})]})]})}),"custom"===t.backgroundType&&(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(g,{className:"w-full",placeholder:"Describe the background...",value:t.customPrompt||"",onChange:e=>o(t.id,{customPrompt:e.target.value}),rows:2}),(0,r.jsx)(u.$,{variant:"outline",size:"sm",className:"w-full text-xs",onClick:async()=>{if(!t.customPrompt)return void alert("Please enter a background description first");try{let e=await fetch("/api/improve-prompt",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:t.customPrompt,type:"background"})});if(e.ok){let{improvedPrompt:n}=await e.json();o(t.id,{customPrompt:n})}else alert("Failed to improve prompt. Please try again.")}catch(e){console.error("Error improving prompt:",e),alert("Failed to improve prompt. Please try again.")}},title:"Use Gemini 2.5 Flash to improve your background prompt",children:"⨠Improve with Gemini"})]}),(0,r.jsx)(u.$,{className:"w-full",onClick:()=>s(t.id),disabled:t.isRunning,title:t.input?"Process all unprocessed nodes in chain":"Connect an input first",children:t.isRunning?"Processing...":"Apply Background"}),(0,r.jsx)(M,{nodeId:t.id,output:t.output,downloadFileName:"background-".concat(Date.now(),".png")}),t.error&&(0,r.jsx)("div",{className:"text-xs text-red-400 mt-2",children:t.error})]})]})}function L(e){let{node:t,onDelete:n,onUpdate:o,onStartConnection:a,onEndConnection:i,onProcess:s,onUpdatePosition:l,getNodeHistoryInfo:d,navigateNodeHistory:c,getCurrentNodeImage:p,outputConnected:m}=e,{localPos:h,onPointerDown:x,onPointerMove:f,onPointerUp:b}=I(t,l),v=async e=>{let n=e.clipboardData.items;for(let e=0;e<n.length;e++){let r=n[e];if(r.type.startsWith("image/")){let e=r.getAsFile();if(e){let n=new FileReader;n.onload=()=>{o(t.id,{clothesImage:n.result})},n.readAsDataURL(e);return}}}};return(0,r.jsxs)("div",{className:"nb-node absolute w-[320px]",style:{left:h.x,top:h.y},onDrop:e=>{e.preventDefault();let n=e.dataTransfer.files;if(n&&n.length){let e=new FileReader;e.onload=()=>{o(t.id,{clothesImage:e.result})}
1,e.readAsDataURL(n[0])}},onDragOver:e=>e.preventDefault(),onPaste:v,children:[(0,r.jsxs)("div",{className:"nb-header px-3 py-2 flex items-center justify-between rounded-t-[14px] cursor-grab active:cursor-grabbing",onPointerDown:x,onPointerMove:f,onPointerUp:b,children:[(0,r.jsx)(D,{className:"in",nodeId:t.id,isOutput:!1,connected:!!t.input,onEndConnection:i,onDisconnect:e=>o(e,{input:void 0})}),(0,r.jsxs)("div",{className:"font-semibold text-sm flex-1 text-center flex items-center justify-center gap-1.5",children:["CLOTHES",(0,r.jsx)(R,{startTime:t.startTime,executionTime:t.executionTime,isRunning:t.isRunning})]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(D,{className:"out",nodeId:t.id,isOutput:!0,connected:m,onStartConnection:a})})]}),(0,r.jsxs)("div",{className:"p-3 space-y-3",children:[(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:"Reference Clothing Image (Optional)"}),(0,r.jsx)("div",{className:"space-y-2",children:t.clothesImage?(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)("img",{src:t.clothesImage,className:"w-full rounded max-h-40 object-contain bg-muted/30",alt:"Clothing Reference"}),(0,r.jsx)(u.$,{variant:"destructive",size:"sm",className:"absolute top-2 right-2",onClick:()=>o(t.id,{clothesImage:null}),children:"Remove"})]}):(0,r.jsxs)("label",{className:"block",children:[(0,r.jsx)("input",{type:"file",accept:"image/*",className:"hidden",onChange:e=>{var n;let r=null==(n=e.target.files)?void 0:n[0];if(r){let e=new FileReader;e.onload=()=>{o(t.id,{clothesImage:e.result})},e.readAsDataURL(r)}}}),(0,r.jsxs)("div",{className:"border-2 border-dashed border-white/20 rounded-lg p-4 text-center cursor-pointer hover:border-white/40 transition-colors",children:[(0,r.jsx)("p",{className:"text-xs text-white/60",children:"Drop, upload, or paste clothing image"}),(0,r.jsx)("p",{className:"text-xs text-white/40 mt-1",children:"JPG, PNG, WEBP"})]})]})}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:"Clothing Description"}),(0,r.jsx)(g,{className:"w-full",placeholder:"Describe the clothing (e.g. 'black leather jacket', 'floral summer dress', 'navy blue business suit')",value:t.clothesPrompt||"",onChange:e=>o(t.id,{clothesPrompt:e.target.value}),rows:3}),(0,r.jsx)(u.$,{className:"w-full",onClick:()=>s(t.id),disabled:t.isRunning||!t.clothesPrompt&&!t.clothesImage,title:t.input?t.clothesPrompt||t.clothesImage?"Apply Clothing":"Enter a clothing description or upload an image":"Connect an input first",children:t.isRunning?"Processing...":"Apply Clothes"}),(0,r.jsx)(M,{nodeId:t.id,output:t.output,downloadFileName:"clothes-".concat(Date.now(),".png")}),t.error&&(0,r.jsx)("div",{className:"text-xs text-red-400 mt-2",children:t.error})]})]})}function G(e){let{node:t,onDelete:n,onUpdate:o,onStartConnection:a,onEndConnection:i,onProcess:s,onUpdatePosition:l,getNodeHistoryInfo:d,navigateNodeHistory:c,getCurrentNodeImage:p,outputConnected:m}=e,{localPos:h,onPointerDown:g,onPointerMove:f,onPointerUp:b}=I(t,l);return(0,r.jsxs)("div",{className:"nb-node absolute w-[280px]",style:{left:h.x,top:h.y},children:[(0,r.jsxs)("div",{className:"nb-header px-3 py-2 flex items-center justify-between rounded-t-[14px] cursor-grab active:cursor-grabbing",onPointerDown:g,onPointerMove:f,onPointerUp:b,children:[(0,r.jsx)(D,{className:"in",nodeId:t.id,isOutput:!1,connected:!!t.input,onEndConnection:i,onDisconnect:e=>
1o(e,{input:void 0})}),(0,r.jsxs)("div",{className:"font-semibold text-sm flex-1 text-center flex items-center justify-center gap-1.5",children:["AGE",(0,r.jsx)(R,{startTime:t.startTime,executionTime:t.executionTime,isRunning:t.isRunning})]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(D,{className:"out",nodeId:t.id,isOutput:!0,connected:m,onStartConnection:a})})]}),(0,r.jsxs)("div",{className:"p-3 space-y-3",children:[(0,r.jsx)("div",{children:(0,r.jsx)(x,{label:"Target Age",valueLabel:"".concat(t.targetAge||30," years"),min:18,max:100,value:t.targetAge||30,onChange:e=>o(t.id,{targetAge:parseInt(e.target.value)})})}),(0,r.jsx)(u.$,{className:"w-full",onClick:()=>s(t.id),disabled:t.isRunning,title:t.input?"Process all unprocessed nodes in chain":"Connect an input first",children:t.isRunning?"Processing...":"Apply Age"}),(0,r.jsx)(M,{nodeId:t.id,output:t.output,downloadFileName:"age-".concat(Date.now(),".png")}),t.error&&(0,r.jsx)("div",{className:"text-xs text-red-400 mt-2",children:t.error})]})]})}function F(e){let{node:t,onDelete:n,onUpdate:o,onStartConnection:a,onEndConnection:i,onProcess:s,onUpdatePosition:l,getNodeHistoryInfo:d,navigateNodeHistory:c,getCurrentNodeImage:p,outputConnected:m}=e,{localPos:g,onPointerDown:x,onPointerMove:f,onPointerUp:b}=I(t,l);return(0,r.jsxs)("div",{className:"nb-node absolute w-[360px]",style:{left:g.x,top:g.y},children:[(0,r.jsxs)("div",{className:"nb-header px-3 py-2 flex items-center justify-between rounded-t-[14px] cursor-grab active:cursor-grabbing",onPointerDown:x,onPointerMove:f,onPointerUp:b,children:[(0,r.jsx)(D,{className:"in",nodeId:t.id,isOutput:!1,connected:!!t.input,onEndConnection:i,onDisconnect:e=>
1o(e,{input:void 0})}),(0,r.jsxs)("div",{className:"font-semibold text-sm flex-1 text-center flex items-center justify-center gap-1.5",children:["CAMERA",(0,r.jsx)(R,{startTime:t.startTime,executionTime:t.executionTime,isRunning:t.isRunning})]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(D,{className:"out",nodeId:t.id,isOutput:!0,connected:m,onStartConnection:a})})]}),(0,r.jsxs)("div",{className:"p-3 space-y-2 max-h-[500px] overflow-y-auto scrollbar-thin",children:[(0,r.jsx)("div",{className:"text-xs text-muted-foreground font-semibold mb-1",children:"Basic Settings"}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(S,{label:"Focal Length",values:["None","14mm","24mm","28mm","35mm","50mm","70mm","85mm","135mm","200mm","400mm"],current:t.focalLength,onChange:e=>o(t.id,{focalLength:e}),title:"Drag to set focal length â wider on the left, telephoto on the right"}),(0,r.jsx)(S,{label:"Aperture",values:["None","f/1.2","f/1.4","f/1.8","f/2.8","f/4","f/5.6","f/8","f/11","f/16","f/22"],current:t.aperture,onChange:e=>o(t.id,{aperture:e}),title:"Drag to set aperture â wide open (shallow depth) on the left"}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-muted-foreground",children:"Motion Blur"}),(0,r.jsx)(h,{className:"w-full",value:t.motionBlur||"None",onChange:e=>o(t.id,{motionBlur:e.target.value}),title:"Select Motion Blur Effect",children:["None","Light Motion Blur","Medium Motion Blur","Heavy Motion Blur"].map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground font-semibold mb-1 mt-3",children:"Lighting"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-muted-foreground",children:"Setup"}),(0,r.jsx)(h,{className:"w-full",value:t.lightingSetup||"None",onChange:e=>o(t.id,{lightingSetup:e.target.value}),title:"Geometry of the light source(s)",children:["None","Rembrandt","Split","Butterfly (Paramount)","Loop","Rim / Backlit","Silhouette","Three-point studio","Natural daylight"].map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-muted-foreground",children:"Quality"}),(0,r.jsx)(h,{className:"w-full",value:t.lightingQuality||"None",onChange:e=>o(t.id,{lightingQuality:e.target.value}),title:"Character of the light â soft vs hard, time of day, mood",children:["None","Soft / Diffused","Hard / Direct","Golden Hour","Blue Hour","High Key","Low Key","Overcast"].map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground font-semibold mb-1 mt-3",children:"Look & Feel"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-muted-foreground",children:"White Balance"}),(0,r.jsx)(h,{className:"w-full",value:t.whiteBalance||"None",onChange:e=>o(t.id,{whiteBalance:e.target.value}),children:["None","2800K candlelight","3200K tungsten","4000K fluorescent","5600K daylight","6500K cloudy","7000K shade","8000K blue sky"].map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-muted-foreground",children:"Film Stock"}),(0,r.jsx)(h,{className:"w-full",value:t.filmStyle||"None",onChange:e=>o(t.id,{filmStyle:e.target.value}),children:["None","Kodak Portra 400","Kodak Ektar","Kodak Tri-X (B&W)","Fuji 400H","Fuji Velvia","CineStill 800T","Polaroid SX-70","Black & White","Sepia"].map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]}),(0,r.jsxs)("div",{className:"col-span-2",children:[(0,r.jsx)("label",{className:"text-xs text-muted-foreground",children:"Lens Character"}),(0,r.jsx)(h,{className:"w-full",value:t.bokeh||"None",onChange:e=>o(t.id,{bokeh:e.target.value}),title:"Optical signature of the lens â anamorphic ovals, swirly Petzval, mirror-lens donuts",children:["None","Anamorphic (oval)","Petzval (swirly)","Mirror lens (donut)","Hexagonal","Cat Eye"].map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})]}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground font-semibold mb-1 mt-3",children:"Composition"}),(0,r.jsx)("div",{className:"grid grid-cols-2 gap-2",children:(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-muted-foreground",children:"Camera Angle"}),(0,r.jsx)(h,{className:"w-full",value:t.angle||"None",onChange:e=>o(t.id,{angle:e.target.value}),children:["None","eye level","low angle","high angle","Dutch tilt","bird's eye","worm's eye","over the shoulder","POV"].map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]})}),(0,r.jsx)(u.$,{className:"w-full",onClick:()=>s(t.id),disabled:t.isRunning,title:t.input?"Process all unprocessed nodes in chain":"Connect an input first",children:t.isRunning?"Processing...":"Apply Camera Settings"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(M,{nodeId:t.id,output:t.output,downloadFileName:"camera-".concat(Date.now(),".png")})}),t.error&&(0,r.jsx)("div",{className:"text-xs text-red-400 mt-2",children:t.error})]})]})}function B(e){var t,n,o,a,i,s,l,d,c;let{node:p,onDelete:m,onUpdate:g,onStartConnection:x,onEndConnection:f,onProcess:b,onUpdatePosition:v,getNodeHistoryInfo:y,navigateNodeHistory:w,getCurrentNodeImage:N,outputConnected:C}=e,{localPos:k,onPointerDown:P,onPointerMove:E,onPointerUp:S}=I(p,v);return(0,r.jsxs)("div",{className:"nb-node absolute w-[340px]",style:{left:k.x,top:k.y},children:[(0,r.jsxs)("div",{className:"nb-header px-3 py-2 flex items-center justify-between rounded-t-[14px] curs
1or-grab active:cursor-grabbing",onPointerDown:P,onPointerMove:E,onPointerUp:S,children:[(0,r.jsx)(D,{className:"in",nodeId:p.id,isOutput:!1,connected:!!p.input,onEndConnection:f,onDisconnect:e=>g(e,{input:void 0})}),(0,r.jsxs)("div",{className:"font-semibold text-sm flex-1 text-center flex items-center justify-center gap-1.5",children:["FACE",(0,r.jsx)(R,{startTime:p.startTime,executionTime:p.executionTime,isRunning:p.isRunning})]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(D,{className:"out",nodeId:p.id,isOutput:!0,connected:C,onStartConnection:x})})]}),(0,r.jsxs)("div",{className:"p-3 space-y-2 max-h-[500px] overflow-y-auto scrollbar-thin",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[(0,r.jsx)(j,{checked:(null==(t=p.faceOptions)?void 0:t.removePimples)||!1,onChange:e=>g(p.id,{faceOptions:{...p.faceOptions,removePimples:e.target.checked}})}),"Remove pimples "]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[(0,r.jsx)(j,{checked:(null==(n=p.faceOptions)?void 0:n.addSunglasses)||!1,onChange:e=>g(p.id,{faceOptions:{...p.faceOptions,addSunglasses:e.target.checked}})}),"Add sunglasses "]}),(0,r.jsxs)("label",{className:"flex items-center gap-2 text-xs cursor-pointer",children:[(0,r.jsx)(j,{checked:(null==(o=p.faceOptions)?void 0:o.addHat)||!1,onChange:e=>g(p.id,{faceOptions:{...p.faceOptions,addHat:e.target.checked}})}),"Add hat "]})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-white/70",children:"Hairstyle"}),(0,r.jsx)(h,{className:"w-full",value:(null==(a=p.faceOptions)?void 0:a.changeHairstyle)||"None",onChange:e=>g(p.id,{faceOptions:{...p.faceOptions,changeHairstyle:e.target.value}}),children:["None","short","long","curly","straight","bald","mohawk","ponytail"].map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-white/70",children:"Expression"}),(0,r.jsx)(h,{className:"w-full",value:(null==(i=p.faceOptions)?void 0:i.facialExpression)||"None",onChange:e=>g(p.id,{faceOptions:{...p.faceOptions,facialExpression:e.target.value}}),children:["None","happy","serious","smiling","laughing","sad","surprised","angry"].map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-white/70",children:"Beard"}),(0,r.jsx)(h,{className:"w-full",value:(null==(s=p.faceOptions)?void 0:s.beardStyle)||"None",onChange:e=>g(p.id,{faceOptions:{...p.faceOptions,beardStyle:e.target.value}}),children:["None","stubble","goatee","full beard","mustache","clean shaven"].map(e=>(0,r.jsx)("option",{value:e,children:e},e))})]}),(0,r.jsxs)("div",{children:[(0,r.jsx)("label",{className:"text-xs text-muted-foreground",children:"Makeup"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[" ",(0,r.jsxs)("button",{className:"p-1 rounded border transition-colors ".concat((null==(l=p.faceOptions)?void 0:l.selectedMakeup)&&(null==(d=p.faceOptions)?void 0:d.selectedMakeup)!=="None"?"border-white/20 hover:border-white/40":"border-indigo-400 bg-indigo-500/20"),onClick:()=>g(p.id,{faceOptions:{...p.faceOptions,selectedMakeup:"None",makeupImage:null}}),title:"No makeup application - natural look",children:[(0,r.jsx)("div",{className:"w-full h-24 flex items-center justify-center text-xs text-muted-foreground/60 border border-dashed border-border rounded mb-1",children:"No Makeup "}),(0,r.jsx)("div",{className:"text-xs",children:"None"})," "]}),(0,r.jsxs)("button",{className:"p-1 rounded border transition-colors ".concat((null==(c=p.faceOptions)?void 0:c.selectedMakeup)==="Makeup"?"border-primary bg-primary/20":"border-border hover:border-primary/50"),onClick:()=>g(p.id,{faceOptions:{...p.faceOptions,selectedMakeup:"Makeup",makeupImage:"/makeup/makeup1.png"}}
1),title:"Apply makeup style - enhances facial features",children:[(0,r.jsx)("img",{src:"/makeup/makeup1.png",alt:"Makeup Style Preview",className:"w-full h-24 object-contain rounded mb-1",title:"Preview of makeup style that will be applied"}),(0,r.jsx)("div",{className:"text-xs",children:"Makeup"})," "]})]})]}),(0,r.jsx)(u.$,{className:"w-full",onClick:()=>b(p.id),disabled:p.isRunning,title:p.input?"Process all unprocessed nodes in chain":"Connect an input first",children:p.isRunning?"Processing...":"Apply Face Changes"}),(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(M,{nodeId:p.id,output:p.output,downloadFileName:"face-".concat(Date.now(),".png")})}),p.error&&(0,r.jsx)("div",{className:"text-xs text-red-400 mt-2",children:p.error})]})]})}function H(e){let{node:t,onDelete:n,onUpdate:o,onStartConnection:a,onEndConnection:i,onProcess:s,onUpdatePosition:l,getNodeHistoryInfo:d,navigateNodeHistory:c,getCurrentNodeImage:p,outputConnected:m}=e,{localPos:g,onPointerDown:f,onPointerMove:b,onPointerUp:v}=I(t,l);return(0,r.jsxs)("div",{className:"nb-node absolute w-[320px]",style:{left:g.x,top:g.y},children:[(0,r.jsxs)("div",{className:"nb-header px-3 py-2 flex items-center justify-between rounded-t-[14px] cursor-grab active:cursor-grabbing",onPointerDown:f,onPointerMove:b,onPointerUp:v,children:[(0,r.jsx)(D,{className:"in",nodeId:t.id,isOutput:!1,connected:!!t.input,onEndConnection:i,onDisconnect:e=>
1o(e,{input:void 0})}),(0,r.jsxs)("div",{className:"font-semibold text-sm flex-1 text-center flex items-center justify-center gap-1.5",children:["STYLE",(0,r.jsx)(R,{startTime:t.startTime,executionTime:t.executionTime,isRunning:t.isRunning})]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(D,{className:"out",nodeId:t.id,isOutput:!0,connected:m,onStartConnection:a})})]}),(0,r.jsxs)("div",{className:"p-3 space-y-3",children:[(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:"Art Style"}),(0,r.jsx)("div",{className:"text-xs text-muted-foreground/50 mb-2",children:"Select an artistic style to apply to your image"}),(0,r.jsxs)(h,{className:"w-full",value:t.stylePreset||"",onChange:e=>o(t.id,{stylePreset:e.target.value}),children:[(0,r.jsx)("option",{value:"",children:"Select a style..."}),[{value:"90s-anime",label:"90's Anime Style"},{value:"mha",label:"My Hero Academia Style"},{value:"dbz",label:"Dragon Ball Z Style"},{value:"ukiyo-e",label:"Ukiyo-e Style"},{value:"spiderverse",label:"Spiderverse Style"},{value:"cubism",label:"Cubism Style"},{value:"van-gogh",label:"Post-Impressionist (Van Gogh) Style"},{value:"simpsons",label:"Simpsons Style"},{value:"family-guy",label:"Family Guy Style"},{value:"pixar",label:"Pixar Style"},{value:"manga",label:"Manga Style"}].map(e=>(0,r.jsx)("option",{value:e.value,children:e.label},e.value))]}),(0,r.jsx)("div",{children:(0,r.jsx)(x,{label:"Style Strength",valueLabel:"".concat(t.styleStrength||50,"%"),min:0,max:100,value:t.styleStrength||50,onChange:e=>o(t.id,{styleStrength:parseInt(e.target.value)}),title:"Adjust how strongly the artistic style is applied - lower values are more subtle"})}),(0,r.jsx)(u.$,{className:"w-full",onClick:()=>s(t.id),disabled:t.isRunning||!t.stylePreset,title:t.input?t.stylePreset?"Apply the selected artistic style to your input image":"Select a style first":"Connect an input first",children:t.isRunning?"Applying Style...":"Apply Style Transfer"}),(0,r.jsx)(M,{nodeId:t.id,output:t.output,downloadFileName:"style-".concat(Date.now(),".png")}),t.error&&(0,r.jsx)("div",{className:"text-xs text-red-400 mt-2",children:t.error})]})]})}function U(e){let{node:t,onDelete:n,onUpdate:o,onStartConnection:a,onEndConnection:i,onProcess:s,onUpdatePosition:l,getNodeHistoryInfo:d,navigateNodeHistory:c,getCurrentNodeImage:p,outputConnected:m}=e,{localPos:h,onPointerDown:g,onPointerMove:x,onPointerUp:f}=I(t,l);return(0,r.jsxs)("div",{className:"nb-node absolute text-white w-[320px]",style:{left:h.x,top:h.y},children:[(0,r.jsxs)("div",{className:"nb-header px-3 py-2 flex items-center justify-between rounded-t-[14px] cursor-grab active:cursor-grabbing",onPointerDown:g,onPointerMove:x,onPointerUp:f,children:[(0,r.jsx)(D,{className:"in",nodeId:t.id,isOutput:!1,connected:!!t.input,onEndConnection:i,onDisconnect:e=>
1o(e,{input:void 0})}),(0,r.jsxs)("div",{className:"font-semibold text-sm flex-1 text-center flex items-center justify-center gap-1.5",children:["LIGHTNING",(0,r.jsx)(R,{startTime:t.startTime,executionTime:t.executionTime,isRunning:t.isRunning})]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(D,{className:"out",nodeId:t.id,isOutput:!0,connected:m,onStartConnection:a})})]}),(0,r.jsxs)("div",{className:"p-3 space-y-3",children:[(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:"Lighting Presets"}),(0,r.jsx)("div",{className:"grid grid-cols-2 gap-2",children:[{name:"Moody Cinematic",path:"/lighting/light1.png",prompt:"Moody cinematic portrait lighting with a sharp vertical beam of warm orange-red light cutting across the face and neck, contrasted with cool teal ambient fill on the surrounding areas. Strong chiaroscuro effect, deep shadows, high contrast between warm and cool tones, dramatic spotlight strip"},{name:"Dual-Tone Neon",path:"/lighting/light2.png",prompt:"Cinematic portrait lighting with strong dual-tone rim lights: deep blue light illuminating the front-left side of the face, intense red light as a rim light from the back-right, dark black background, high contrast, minimal fill light, dramatic neon glow"},{name:"Natural Shadow Play",path:"/lighting/light3.png",prompt:"DRAMATIC natural shadow play with hard directional sunlight filtering through foliage, creating bold contrasting patterns of light and shadow across the subject. Strong chiaroscuro effect with deep blacks and bright highlights, dappled leaf shadows dancing across face and body, creating an artistic interplay of illumination and darkness. Emphasize the sculptural quality of light carving through shadow, with sharp shadow edges and brilliant sun-kissed highlights for maximum visual impact"}].map(e=>(0,r.jsxs)("button",{className:"p-2 rounded border ".concat(t.selectedLighting===e.name?"border-primary bg-primary/20":"border-border hover:border-primary/50"),onClick:()=>{var n,r;return e.path,n=e.name,r=e.prompt,void o(t.id,{lightingPrompt:r,selectedLighting:n})},children:[(0,r.jsx)("img",{src:e.path,alt:e.name,className:"w-full h-24 object-contain rounded mb-1",title:"Click to select lighting"}),(0,r.jsx)("div",{className:"text-xs",children:e.name})]},e.name))}),(0,r.jsx)(u.$,{className:"w-full",onClick:()=>s(t.id),disabled:t.isRunning||!t.selectedLighting,title:t.input?t.selectedLighting?"Apply lighting effect":"Select a lighting preset first":"Connect an input first",children:t.isRunning?"Processing...":"Apply Lighting"}),(0,r.jsx)(M,{nodeId:t.id,output:t.output,downloadFileName:"lightning-".concat(Date.now(),".png")}),t.error&&(0,r.jsx)("div",{className:"text-xs text-red-400 mt-2",children:t.error})]})]})}function _(e){let{node:t,onDelete:n,onUpdate:o,onStartConnection:a,onEndConnection:i,onProcess:s,onUpdatePosition:l,getNodeHistoryInfo:d,navigateNodeHistory:c,getCurrentNodeImage:p,outputConnected:m}=e,{localPos:h,onPointerDown:g,onPointerMove:x,onPointerUp:f}=I(t,l);return(0,r.jsxs)("div",{className:"nb-node absolute w-[320px]",style:{left:h.x,top:h.y},children:[(0,r.jsxs)("div",{className:"nb-header px-3 py-2 flex items-center justify-between rounded-t-[14px] cursor-grab active:cursor-grabbing",onPointerDown:g,onPointerMove:x,onPointerUp:f,children:[(0,r.jsx)(D,{className:"in",nodeId:t.id,isOutput:!1,connected:!!t.input,onEndConnection:i,onDisconnect:e=>
1o(e,{input:void 0})}),(0,r.jsxs)("div",{className:"font-semibold text-sm flex-1 text-center flex items-center justify-center gap-1.5",children:["POSES",(0,r.jsx)(R,{startTime:t.startTime,executionTime:t.executionTime,isRunning:t.isRunning})]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(D,{className:"out",nodeId:t.id,isOutput:!0,connected:m,onStartConnection:a})})]}),(0,r.jsxs)("div",{className:"p-3 space-y-3",children:[(0,r.jsx)("div",{className:"text-xs text-white/70",children:"Pose References"}),(0,r.jsx)("div",{className:"grid grid-cols-2 gap-2",children:[{name:"Dynamic Standing",path:"/poses/stand1.png",prompt:"A dynamic standing pose with the figure's weight shifted to one side. The right arm extends forward in a pointing gesture while the left arm hangs naturally. The figure has a slight hip tilt and appears to be in mid-movement, creating an energetic, directional composition."},{name:"Arms Crossed",path:"/poses/stand2.png",prompt:"A relaxed standing pose with arms crossed over the torso. The weight is distributed fairly evenly, with one leg slightly forward. The figure's posture suggests a casual, confident stance with the head tilted slightly downward in a contemplative manner."},{name:"Seated Composed",path:"/poses/sit1.png",prompt:"A seated pose on what appears to be a stool or high chair. The figure sits with legs crossed at the knee, creating an asymmetrical but balanced composition. The hands rest on the lap, and the overall posture is upright and composed."},{name:"Relaxed Lean",path:"/poses/sit2.png",prompt:"A more relaxed seated pose with the figure leaning to one side. One leg is bent and raised while the other extends downward. The figure appears to be resting or in casual repose, with arms supporting the body and creating a diagonal flow through the composition."}].map(e=>(0,r.jsxs)("button",{className:"p-2 rounded border ".concat(t.selectedPose===e.name?"border-indigo-400 bg-indigo-500/20":"border-white/20 hover:border-white/40"),onClick:()=>{var n,r;return e.path,n=e.name,r=e.prompt,void o(t.id,{posePrompt:r,selectedPose:n})},children:[(0,r.jsx)("img",{src:e.path,alt:e.name,className:"w-full h-24 object-contain rounded mb-1",title:"Click to select pose"}),(0,r.jsx)("div",{className:"text-xs",children:e.name})]},e.name))}),(0,r.jsx)(u.$,{className:"w-full",onClick:()=>s(t.id),disabled:t.isRunning||!t.selectedPose,title:t.input?t.selectedPose?"Apply pose modification":"Select a pose first":"Connect an input first",children:t.isRunning?"Processing...":"Apply Pose"}),(0,r.jsx)(M,{nodeId:t.id,output:t.output,downloadFileName:"poses-".concat(Date.now(),".png")}),t.error&&(0,r.jsx)("div",{className:"text-xs text-red-400 mt-2",children:t.error})]})]})}function Y(e){var t,n;let{node:o,onUpdate:a,onStartConnection:i,onEndConnection:s,onProcess:l,onUpdatePosition:d,getNodeHistoryInfo:c,navigateNodeHistory:p,getCurrentNodeImage:m,outputConnected:h}=e,{localPos:x,onPointerDown:f,onPointerMove:b,onPointerUp:v}=I(o,d);return(0,r.jsxs)("div",{className:"nb-node absolute w-[320px]",style:{left:x.x,top:x.y},children:[(0,r.jsxs)("div",{className:"nb-header px-3 py-2 flex items-center justify-between rounded-t-[14px] cursor-grab active:cursor-grabbing",onPointerDown:f,onPointerMove:b,onPointerUp:v,children:[(0,r.jsx)(D,{className:"in",nodeId:o.id,isOutput:!1,connected:!!o.input,onEndConnection:s,onDisconnect:e=>
1a(e,{input:void 0})}),(0,r.jsxs)("div",{className:"font-semibold text-sm flex-1 text-center flex items-center justify-center gap-1.5",children:["EDIT",(0,r.jsx)(R,{startTime:o.startTime,executionTime:o.executionTime,isRunning:o.isRunning})]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(D,{className:"out",nodeId:o.id,isOutput:!0,connected:h,onStartConnection:i})})]}),(0,r.jsxs)("div",{className:"p-3 space-y-3",children:[(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)("div",{className:"text-xs text-muted-foreground mb-1",children:"Edit Instructions"}),(0,r.jsx)(g,{className:"w-full",placeholder:"Describe what to edit (e.g., 'make it brighter', 'add more contrast', 'make it look vintage')",value:o.editPrompt||"",onChange:e=>{a(o.id,{editPrompt:e.target.value})},rows:3})]}),(0,r.jsx)(u.$,{className:"w-full",onClick:()=>l(o.id),disabled:o.isRunning||!(null==(t=o.editPrompt)?void 0:t.trim()),title:o.input?(null==(n=o.editPrompt)?void 0:n.trim())?"Apply the edit to the input image":"Enter edit instructions first":"Connect an input first",children:o.isRunning?"Processing...":"Apply Edit"}),(0,r.jsx)(M,{nodeId:o.id,output:o.output,downloadFileName:"edit-".concat(Date.now(),".png")}),o.error&&(0,r.jsx)("div",{className:"text-xs text-red-400 mt-2 p-2 bg-red-900/20 rounded",children:o.error})]})]})}function z(e,t,n){return Math.min(n,Math.max(t,e))}function X(e){if(!Number.isFinite(e))return 0;let t=e;for(;t>1;)t-=2;for(;t<-1;)t+=2;return t}function W(e,t,n){let r=e*Math.PI,o=z(t,-.98,.98)*(Math.PI/2);return new d.Pq0(Math.sin(r)*Math.cos(o)*n,Math.sin(o)*n,Math.cos(r)*Math.cos(o)*n)}function $(e){let{label:t,value:n,fillFraction:o,onDelta:a,onSetFraction:i}=e,s=100*Math.max(0,Math.min(1,o));return(0,r.jsxs)("div",{className:"relative h-10 rounded-md bg-muted/40 border border-border/70 cursor-ew-resize overflow-hidden select-none",onPointerDown:e=>{e.stopPropagation();let t=e.currentTarget.getBoundingClientRect(),n=e.clientX;i&&i(Math.max(0,Math.min(1,(e.clientX-t.left)/t.width)));let r=e=>{let r=e.clientX-n;n=e.clientX,a(r,t.width)},o=()=>{window.removeEventListener("pointermove",r),window.removeEventListener("pointerup",o)};window.addEventListener("pointermove",r),window.addEventListener("pointerup",o)},children:[(0,r.jsx)("div",{className:"absolute inset-y-0 left-0 bg-primary/20 pointer-events-none transition-[width] duration-75",style:{width:"".concat(s,"%")}}),(0,r.jsxs)("div",{className:"absolute inset-0 px-3 flex items-center justify-between text-sm",children:[(0,r.jsx)("span",{className:"text-foreground/85",children:t}),(0,r.jsx)("span",{className:"text-foreground tabular-nums font-medium",children:n})]})]})}function K(e){let{cameraX:t,cameraY:n,cameraZ:a,onChange:i}=e,s=(0,o.useRef)(null),l=(0,o.useRef)({cameraX:t,cameraY:n,cameraZ:a}),u=(0,o.useRef)(null),p=(0,o.useRef)(null),m=(0,o.useCallback)((e,t,n)=>{let r=u.current;if(!r)return;let o=W(e,t,1.12),a=W(e,t,1.62+.75*n);r.marker.position.copy(a),r.marker.lookAt(0,0,0),r.marker.scale.setScalar(.9+.22*n),r.ray.geometry.dispose(),r.ray.geometry=new d.LoY().setFromPoints([o,a])},[]);(0,o.useEffect)(()=>{let e=s.current;if(!e)return;let t=new c.JeP({antialias:!0,alpha:!0});t.setPixelRatio(Math.min(window.devicePixelRatio||1,2)),t.outputColorSpace=d.er$,t.domElement.style.display="block",t.domElement.style.width="100%",t.domElement.style.height="100%",t.domElement.style.touchAction="none",e.appendChild(t.domElement);let n=new d.Z58,r=new d.ubm(38,1,.1,100);r.position.set(0,.15,5.2),r.lookAt(0,0,0),n.add(new d.$p8(0xffffff,1.5));let o=new d.ZyN(0xffffff,2.2);o.position.set(3,2.8,4.5),n.add(o);let a=new d.ZyN(8246268,1.15);a.position.set(-3.5,1.2,-2.5),n.add(a);let i=function(){let e=document.createElement("canvas");e.width=1024,e.height=512;let t=e.getContext("2d");if(!t)return null;let n=e.width,r=e.height,o=t.createLinearGradient(0,0,n,r);o.addColorStop(0,"#0f766e"),o.addColorStop(.38,"#0ea5e9"),o.addColorStop(.72,"#1d4ed8"),o.addColorStop(1,"#075985"),t.fillStyle=o,t.fillRect(0,0,n,r),t.globalAlpha=.22,t.strokeStyle="#d9f99d",t.lineWidth=1;for(let e=64;e<r;e+=64)t.beginPath(),t.moveTo(0,e),t.lineTo(n,e+8*Math.sin(.04*e)),t.stroke();t.globalAlpha=1;let a=function(e){let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"#66a65f";t.beginPath(),e.forEach((e,o)=>{let[a,i]=e,[s,l]=[(a+180)/360*n,(90-i)/180*r];0===o?t.moveTo(s,l):t.lineTo(s,l)}),t.closePath(),t.fillStyle=o,t.fill(),t.strokeStyle="rgba(255, 255, 255, 0.32)",t.lineWidth=2,t.stroke()};a([[-168,70],[-132,72],[-104,58],[-82,46],[-62,48],[-52,28],[-76,8],[-104,20],[-118,34],[-144,44]],"#75a85b"),a([[-84,13],[-56,10],[-38,-8],[-48,-34],[-64,-56],[-78,-38],[-72,-12]],"#579b5d"),a([[-12,72],[22,70],[56,61],[84,58],[132,46],[154,28],[124,10],[82,18],[46,9],[14,30],[-8,36],[-26,54]],"#84b661"),a([[-18,34],[34,31],[48,9],[42,-20],[22,-35],[2,-30],[-14,-4]],"#6fa65b"),a([[66,28],[94,26],[104,10],[86,-6],[68,6]],"#78ad5c"),a([[112,-12],[154,-16],[150,-42],[116,-38],[104,-26]],"#9aa85d"),a([[-52,78],[-24,72],[-38,60],[-58,62]],"#b4c78b");let i=new d.GOR(e);
1return i.colorSpace=d.er$,i.anisotropy=4,i}(),p=new d.eaF(new d.Gu$(1.1,96,64),new d._4j({map:null!=i?i:void 0,roughness:.82,metalness:.04}));n.add(p);let h=function(){let e=document.createElement("canvas");e.width=1024,e.height=512;let t=e.getContext("2d");if(!t)return null;t.clearRect(0,0,e.width,e.height),t.fillStyle="rgba(255, 255, 255, 0.38)";for(let n=0;n<85;n++){let n=Math.random()*e.width,r=Math.random()*e.height,o=18+80*Math.random(),a=5+20*Math.random();t.beginPath(),t.ellipse(n,r,o,a,Math.random()*Math.PI,0,2*Math.PI),t.fill()}let n=new d.GOR(e);return n.colorSpace=d.er$,n}(),g=new d.eaF(new d.Gu$(1.125,96,64),new d.V9B({map:null!=h?h:void 0,transparent:!0,opacity:.2,depthWrite:!1}));n.add(g);let x=new d.eaF(new d.Gu$(1.22,96,64),new d.V9B({color:3718648,transparent:!0,opacity:.08,side:d.hsX,depthWrite:!1}));n.add(x);let f=new d.mrM({color:0xffffff,transparent:!0,opacity:.14,depthTest:!0});for(let e=-60;e<=60;e+=30){let t=[];for(let n=-180;n<=180;n+=4){let r=n*Math.PI/180,o=e*Math.PI/180;t.push(new d.Pq0(Math.sin(r)*Math.cos(o)*1.115,1.115*Math.sin(o),Math.cos(r)*Math.cos(o)*1.115))}n.add(new d.N1A(new d.LoY().setFromPoints(t),f.clone()))}for(let e=0;e<180;e+=30){let t=[];for(let n=-88;n<=88;n+=4){let r=e*Math.PI/180,o=n*Math.PI/180;t.push(new d.Pq0(Math.sin(r)*Math.cos(o)*1.116,1.116*Math.sin(o),Math.cos(r)*Math.cos(o)*1.116))}n.add(new d.N1A(new d.LoY().setFromPoints(t),f.clone()))}let b=new d.N1A(new d.LoY().setFromPoints([new d.Pq0,new d.Pq0]),new d.mrM({color:0xff4d18,transparent:!0,opacity:.82,depthTest:!0}));n.add(b);let v=new d.YJl,y=new d.eaF(new d.iNn(.22,.14,.14),new d._4j({color:0xff5a1f,roughness:.45,metalness:.12})),j=new d.eaF(new d.Ho_(.045,.065,.08,24),new d._4j({color:1120295,roughness:.35,metalness:.2}));j.rotation.x=Math.PI/2,j.position.z=-.1;let w=new d.eaF(new d.O3Y(.085,.008,12,28),new d._4j({color:0xffffff,roughness:.25,metalness:.4}));w.rotation.x=Math.PI/2,w.position.z=-.143,v.add(y,j,w),n.add(v);let N=()=>{let n=Math.max(1,e.clientWidth),o=Math.max(1,e.clientHeight);t.setSize(n,o,!1),r.aspect=n/o,r.updateProjectionMatrix()},C=new ResizeObserver(N);C.observe(e),N();let k={renderer:t,scene:n,viewCamera:r,earth:p,clouds:g,marker:v,ray:b,frameId:0,resizeObserver:C};u.current=k;let P=l.current;m(P.cameraX,P.cameraY,P.cameraZ);let E=()=>{p.rotation.y+=.0015,g.rotation.y+=.0022,t.render(n,r),k.frameId=window.requestAnimationFrame(E)};return E(),()=>{window.cancelAnimationFrame(k.frameId),C.disconnect(),n.traverse(e=>{e.geometry&&e.geometry.dispose();let t=e.material;(Array.isArray(t)?t:t?[t]:[]).forEach(e=>{let t=e.map;t&&t.dispose(),e.dispose()})}),t.dispose(),t.domElement.remove(),u.current=null}},[m]),(0,o.useEffect)(()=>{m(t,n,a)},[m,t,n,a]);let h=e=>{var t;(null==(t=p.current)?void 0:t.pointerId)===e.pointerId&&(e.stopPropagation(),p.current=null)};return(0,r.jsx)("div",{ref:s,className:"absolute inset-0 cursor-grab touch-none active:cursor-grabbing",onPointerDown:e=>{e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),p.current={pointerId:e.pointerId,startX:e.clientX,startY:e.clientY,cameraX:t,cameraY:n}},onPointerMove:e=>{let t=p.current;t&&t.pointerId===e.pointerId&&(e.stopPropagation(),i({cameraX:X(t.cameraX+(e.clientX-t.startX)/150),cameraY:z(t.cameraY+(t.startY-e.clientY)/120,-1,1)}))},onPointerUp:h,onPointerCancel:h,onWheel:e=>{e.stopPropagation(),e.preventDefault(),i({cameraZ:z(a+.001*e.deltaY,0,1)})},title:"Drag to orbit the camera; scroll to adjust distance"})}function Z(e){let{node:t,onUpdate:n,onStartConnection:o,onEndConnection:i,onProcess:s,onUpdatePosition:l,outputConnected:d}=e,{localPos:c,onPointerDown:p,onPointerMove:m,onPointerUp:h}=I(t,l),g="number"==typeof t.cameraX?t.cameraX:0,x="number"==typeof t.cameraY?t.cameraY:0,f="number"==typeof t.cameraZ?t.cameraZ:.5,b=Math.round((g+1)/2*360),v=Math.round(90*x),y=Math.round(10*f),j=g*Math.PI,S=-(Math.PI/2*x),A=Math.sin(j)*Math.cos(S)*.74,T=-(.74*Math.sin(S)),O=Math.sin(j)*Math.cos(S)*.7548,L=-(.7548*Math.sin(S)),G=Math.cos(j)*Math.cos(S)>=-.001,F=e=>n(t.id,{cameraX:X(g+15/180*e)}),B=e=>n(t.id,{cameraY:z(x+15/90*e,-1,1)});return(0,r.jsxs)("div",{className:"nb-node absolute w-[320px]",style:{left:c.x,top:c.y},children:[(0,r.jsxs)("div",{className:"nb-header px-3 py-2 flex items-center justify-between rounded-t-[14px] curs
1or-grab active:cursor-grabbing",onPointerDown:p,onPointerMove:m,onPointerUp:h,children:[(0,r.jsx)(D,{className:"in",nodeId:t.id,isOutput:!1,connected:!!t.input,onEndConnection:i,onDisconnect:e=>n(e,{input:void 0})}),(0,r.jsxs)("div",{className:"font-semibold text-sm flex-1 text-center flex items-center justify-center gap-1.5",children:["Angles",(0,r.jsx)(R,{startTime:t.startTime,executionTime:t.executionTime,isRunning:t.isRunning})]}),(0,r.jsx)("div",{className:"flex items-center gap-1",children:(0,r.jsx)(D,{className:"out",nodeId:t.id,isOutput:!0,connected:d,onStartConnection:o})})]}),(0,r.jsxs)("div",{className:"p-4 flex flex-col gap-3",children:[(0,r.jsxs)("div",{className:"nb-angle-panel rounded-xl p-3",children:[(0,r.jsxs)("div",{className:"sr-only",children:["Hold and drag to change",(0,r.jsx)("br",{}),"camera angle"]}),(0,r.jsxs)("div",{className:"nb-angle-globe relative h-56 select-none overflow-hidden rounded-lg",children:[(0,r.jsx)(K,{cameraX:g,cameraY:x,cameraZ:f,onChange:e=>n(t.id,e)}),(0,r.jsxs)("svg",{viewBox:"-1 -1 2 2",className:"hidden",onPointerDown:e=>{e.stopPropagation()},onWheel:e=>{e.stopPropagation(),e.preventDefault()},children:[(0,r.jsx)("circle",{cx:"0",cy:"0",r:.74,fill:"none",stroke:"hsl(0 0% 100% / 0.18)",strokeWidth:"0.005"}),[-60,-30,0,30,60].map(e=>{let t=e*Math.PI/180,n=.74*Math.sin(t),o=.74*Math.cos(t),a=.74*Math.abs(Math.sin(S+t))*.4+.005;return(0,r.jsx)("ellipse",{cx:"0",cy:n*Math.cos(S)+Math.sin(S)*Math.cos(t)*0,rx:o,ry:a,fill:"none",stroke:"hsl(0 0% 100% / 0.12)",strokeWidth:"0.005"},"lat-".concat(e))}),[0,30,60,90,120,150].map(e=>{let t=.74*Math.abs(Math.cos(e*Math.PI/180+j));return(0,r.jsx)("ellipse",{cx:"0",cy:"0",rx:t,ry:.74,fill:"none",stroke:"hsl(0 0% 100% / 0.10)",strokeWidth:"0.005"},"lon-".concat(e))}),(0,r.jsx)("line",{x1:"0",y1:"0",x2:A,y2:T,stroke:"hsl(0 0% 100% / 0.55)",strokeWidth:"0.012",strokeLinecap:"round"}),(0,r.jsx)("rect",{x:-.13,y:-.13,width:"0.26",height:"0.26",rx:"0.025",fill:"hsl(var(--primary) / 0.18)",stroke:"hsl(var(--primary) / 0.6)",strokeWidth:"0.008"})]}),(0,r.jsx)(a.P.div,{className:"hidden",animate:{left:"".concat(50+50*O,"%"),top:"".concat(50+50*L,"%"),opacity:G?1:.35},transition:{type:"spring",stiffness:360,damping:32},style:{x:"-50%",y:"-50%"},children:(0,r.jsx)("div",{className:"w-7 h-7 rounded-md bg-card border border-white/30 shadow-[0_4px_12px_rgba(0,0,0,0.6)] flex items-center justify-center text-base",children:(0,r.jsx)(N.A,{className:"h-4 w-4 text-primary","aria-hidden":!0})})}),(0,r.jsx)("button",{type:"button",onClick:()=>F(-1),onPointerDown:e=>e.stopPropagation(),className:"nb-angle-stepper absolute left-2 top-1/2 -translate-y-1/2 w-8 h-8 rounded-full flex items-center justify-center transition-colors","aria-label":"Rotate left",children:(0,r.jsx)(C.A,{className:"h-4 w-4"})}),(0,r.jsx)("button",{type:"button",onClick:()=>F(1),onPointerDown:e=>e.stopPropagation(),className:"nb-angle-stepper absolute right-2 top-1/2 -translate-y-1/2 w-8 h-8 rounded-full flex items-center justify-center transition-colors","aria-label":"Rotate right",children:(0,r.jsx)(k.A,{className:"h-4 w-4"})}),(0,r.jsx)("button",{type:"button",onClick:()=>B(1),onPointerDown:e=>e.stopPropagation(),className:"nb-angle-stepper absolute left-1/2 -translate-x-1/2 bottom-2 w-8 h-8 rounded-full flex items-center justify-center transition-colors","aria-label":"Tilt down",children:(0,r.jsx)(P.A,{className:"h-4 w-4"})}),(0,r.jsx)("button",{type:"button",onClick:()=>B(-1),onPointerDown:e=>e.stopPropagation(),className:"nb-angle-stepper absolute left-1/2 -translate-x-1/2 top-2 w-8 h-8 rounded-full flex items-center justify-center transition-colors","aria-label":"Tilt up",children:(0,r.jsx)(E.A,{className:"h-4 w-4"})})]})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)($,{label:"Rotation",value:"".concat(b,"\xb0"),fillFraction:(g+1)/2,onDelta:(e,r)=>{let o=X(g+e/r*2);n(t.id,{cameraX:o})},onSetFraction:e=>n(t.id,{cameraX:2*e-1})}),(0,r.jsx)($,{label:"Tilt",value:"".concat(v,"\xb0"),fillFraction:(x+1)/2,onDelta:(e,r)=>{let o=z(x+e/r*2,-1,1);n(t.id,{cameraY:o})},onSetFraction:e=>n(t.id,{cameraY:2*e-1})}),(0,r.jsx)($,{label:"Zoom",value:"".concat(y),fillFraction:f,onDelta:(e,r)=>{let o=z(f+e/r,0,1);n(t.id,{cameraZ:o})},onSetFraction:e=>n(t.id,{cameraZ:e})})]}),(0,r.jsx)(u.$,{className:"w-full nb-btn-primary",onClick:()=>s(t.id),disabled:t.isRunning||!t.input,title:t.input?"Generate image with this camera angle":"Connect an input first",children:t.isRunning?(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(w.A,{className:"w-4 h-4 animate-spin"}),(0,r.jsx)("span",{children:"Adjusting Perspective..."})]}):"Apply Camera Angle"}),(0,r.jsx)(M,{nodeId:t.id,output:t.output,downloadFileName:"camera-angle-".concat(Date.now(),".png")}),t.error&&(0,r.jsx)("div",{className:"text-xs text-red-400 bg-red-400/10 p-2 rounded border border-red-400/20 w-full animate-in fade-in slide-in-from-top-1",children:t.error})]})]})}let q=o.forwardRef((e,t)=>
1{let{className:n,type:o,...a}=e;return(0,r.jsx)("input",{type:o,className:(0,m.cn)("flex h-9 w-full rounded-md border border-input bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",n),ref:t,...a})});q.displayName="Input";let J=()=>Math.random().toString(36).slice(2,9);function Q(e){let t=e.length;return e.map((e,t)=>"Image ".concat(t+1," (").concat(e.label,")")).join(", "),"MERGE TASK: Create a natural, cohesive group photo combining ALL subjects from ".concat(t," provided images.\n\nImages provided:\n").concat(e.map((e,t)=>"- Image ".concat(t+1,": ").concat(e.label)).join("\n"),"\n\nCRITICAL REQUIREMENTS:\n1. Extract ALL people/subjects from EACH image exactly as they appear\n2. Place them together in a SINGLE UNIFIED SCENE with:\n - Consistent lighting direction and color temperature\n - Matching shadows and ambient lighting\n - Proper scale relationships (realistic relative sizes)\n - Natural spacing as if they were photographed together\n - Shared environment/background that looks cohesive\n\n3. Composition guidelines:\n - Arrange subjects at similar depth (not one far behind another)\n - Use natural group photo positioning (slight overlap is ok)\n - Ensure all faces are clearly visible\n - Create visual balance in the composition\n - Apply consistent color grading across all subjects\n\n4. Environmental unity:\n - Use a single, coherent background for all subjects\n - Match the perspective as if taken with one camera\n - Ensure ground plane continuity (all standing on same level)\n - Apply consistent atmospheric effects (if any)\n\nThe result should look like all subjects were photographed together in the same place at the same time, NOT like separate images placed side by side.")}let V="/reo.png";function ee(e){return Promise.all(Array.from(e).map(e=>new Promise((t,n)=>{let r=new FileReader;r.onload=()=>
1t(r.result),r.onerror=n,r.readAsDataURL(e)})))}function et(e,t,n,r,o,a){return{x:(e-n.left-r)/a,y:(t-n.top-o)/a}}let en={CHARACTER:340,MERGE:420,BACKGROUND:320,CLOTHES:320,EDIT:320,CAMERA:360,AGE:280,FACE:340,STYLE:320,LIGHTNING:320,POSES:320,ANGLE:320},er=e=>({x:e.x+(en[e.type]||320)-18.5,y:e.y+19}),eo=e=>({x:e.x+18.5,y:e.y+19});function ea(e,t,n,r){let[a,i]=(0,o.useState)(n),s=(0,o.useRef)(!1),l=(0,o.useRef)(null);return(0,o.useEffect)(()=>{i(n)},[n.x,n.y]),{pos:a,onPointerDown:e=>{e.stopPropagation(),s.current=!0,l.current={sx:e.clientX,sy:e.clientY,ox:a.x,oy:a.y},e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:n=>{if(!s.current||!l.current)return;let o=(n.clientX-l.current.sx)/t.current,a=(n.clientY-l.current.sy)/t.current,d=l.current.ox+o,c=l.current.oy+a;i({x:d,y:c}),r(e,d,c)},onPointerUp:e=>{s.current=!1,l.current=null,e.currentTarget.releasePointerCapture(e.pointerId)}}}function ei(e){let{className:t,nodeId:n,isOutput:o,connected:a,onStartConnection:i,onEndConnection:s,onDisconnect:l}=e;return(0,r.jsx)("div",{className:function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.filter(Boolean).join(" ")}("nb-port",t,o?"out":"in",a&&"nb-port--connected"),onPointerDown:e=>{e.stopPropagation(),o&&n&&i?i(n):!o&&a&&n&&l&&l(n)},onPointerUp:e=>{!o&&n&&s&&(e.stopPropagation(),s(n))},title:o?"Drag from here to connect to another node's input":a?"Pull to disconnect":"Drop a connection here"})}function es(e){let{node:t,scaleRef:n,outputConnected:a,onChangeImage:i,onChangeLabel:s,onStartConnection:l,onUpdatePosition:d,onDelete:c}=e,{pos:u,onPointerDown:p,onPointerMove:m,onPointerUp:h}=ea(t.id,n,{x:t.x,y:t.y},d),[g,x]=(0,o.useState)(!1),f=async e=>{e.preventDefault();let n=e.dataTransfer.files;if(n&&n.length){let[e]=await ee(n);e&&i(t.id,e)}},b=async e=>{let n=e.clipboardData.items,r=[];for(let e=0;e<n.length;e++){let t=n[e];if(t.type.startsWith("image/")){let e=t.getAsFile();e&&r.push(e)}}if(r.length){let[e]=await ee(r);e&&i(t.id,e);return}let o=e.clipboardData.getData("text");o&&(o.startsWith("http")||o.startsWith("data:image"))&&i(t.id,o)};return(0,r.jsxs)("div",{className:"nb-node nb-character-node absolute w-[340px] select-none overflow-hidden",style:{left:u.x,top:u.y},onDrop:f,onDragOver:e=>e.preventDefault(),onPaste:b,children:[(0,r.jsx)("video",{className:"nb-character-video",src:"https://d8j0ntlcm91z4.cloudfront.net/user_34DpnLwtmxkLgtVe8psPn1j2G8i/hf_20260510_115212_9d7d0835-d6dd-4287-823d-9c5313f88aba.mp4",autoPlay:!0,muted:!0,loop:!0,playsInline:!0,"aria-hidden":"true"}),(0,r.jsx)("div",{className:"nb-character-glass","aria-hidden":"true"}),(0,r.jsxs)("div",{className:"nb-header relative z-10 cursor-grab active:cursor-grabbing rounded-t-[14px] px-3 py-2 flex items-center justify-between",onPointerDown:p,onPointerMove:m,onPointerUp:h,children:[g?(0,r.jsx)("input",{autoFocus:!0,className:"bg-transparent outline-none text-sm font-semibold tracking-wide flex-1 border-b border-white/20 focus:border-white/50 text-white/90 placeholder:text-white/50",value:t.label||"",placeholder:"CHARACTER",onChange:e=>s(t.id,e.target.value),onBlur:()=>x(!1),onKeyDown:e=>{("Enter"===e.key||"Escape"===e.key)&&e.currentTarget.blur()},onPointerDown:e=>e.stopPropagation()}):(0,r.jsx)("span",{className:"text-sm font-semibold tracking-wide flex-1 cursor-text truncate",onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),x(!0)},title:"Click to rename",children:t.label||"CHARACTER"}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(ei,{className:"out",nodeId:t.id,isOutput:!0,connected:a,onStartConnection:l})})]}),(0,r.jsx)("div",{className:"relative z-10 p-3 space-y-3",children:(0,r.jsxs)("label",{className:"aspect-[4/5] w-full rounded-xl bg-black/20 grid place-items-center overflow-hidden border border-white/15 cursor-pointer group relative shadow-[inset_0_1px_0_rgba(255,255,255,0.12)]",title:"Click to upload, drag an image here, or right-click to copy",children:[(0,r.jsx)("input",{type:"file",accept:"image/*",className:"hidden",onChange:async e=>{let n=e.currentTarget.files;if(n&&n.length>0){let[r]=await ee(n);r&&i(t.id,r);try{e.currentTarget.value=""}catch(e){}}}}),(0,r.jsx)("img",{src:t.image,alt:"character",className:"h-full w-full object-contain group-hover:opacity-80 transition-opacity",draggable:!1,onContextMenu:async e=>{e.preventDefault();try{let n=await fetch(t.image),r=await n.blob();await navigator.clipboard.write([new ClipboardItem({[r.type]:r})]);let o=e.currentTarget,a=o.style.filter;o.style.filter="brightness(1.2)",setTimeout(()=>{o.style.filter=a},500)}catch(e){console.error("Failed to copy image:",e)}}}),(0,r.jsx)("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 px-2 py-1 text-[10px] text-white/80 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity text-center",children:"Click or drop image to replace"})]})})]})}function el(e){let{node:t,scaleRef:n,allNodes:o,outputConnected:a,onRun:i,onEndConnection:s,onStartConnection:l,onUpdatePosition:d,onDelete:c,onClearConnections:p}=e,{pos:m,onPointerDown:h,onPointerMove:g,onPointerUp:x}=ea(t.id,n,{x:t.x,y:t.y},d);return(0,r.jsxs)("div",{className:"nb-node absolute w-[420px]",style:{left:m.x,top:m.y},children:[(0,r.jsxs)("div",{className:"nb-header cursor-grab active:cursor-grabbing rounded-t-[14px] px-3 py-2 flex items-center justify-between",onPointerDown:h,onPointerMove:g,onPointerUp:x,children:[(0,r.jsx)(R,{startTime:t.startTime,executionTime:t.executionTime,isRunning:t.isRunning}),(0,r.jsx)(ei,{className:"in",nodeId:t.id,isOutput:!1,connected:t.inputs.length>0,onEndConnection:s,onDisconnect:()=>p(t.id)}),(0,r.jsx)("div",{className:"font-semibold tracking-wide text-sm flex-1 text-center",children:"MERGE"}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(ei,{className:"out",nodeId:t.id,isOutput:!0,connected:a,onStartConnection:l})})]}),(0,r.jsxs)("div",{className:"p-3 space-y-3",children:[(0,r.jsx)("div",{className:"text-xs text-muted-foreground font-medium",children:"Inputs"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:t.inputs.map(e=>
1{let t=o.find(t=>t.id===e);if(!t)return null;let n=null,a="";if("CHARACTER"===t.type)n=t.image,a=t.label||"Character";else if(t.output)n=t.output,a="".concat(t.type);else if("MERGE"===t.type&&t.output){let e=t.output;n=void 0!==e?e:null,a="Merged"}else a="".concat(t.type," (pending)");return(0,r.jsxs)("div",{className:"flex items-center gap-2 bg-secondary/50 border border-border/50 text-secondary-foreground rounded px-2 py-1",children:[n&&(0,r.jsx)("div",{className:"w-6 h-6 rounded overflow-hidden bg-muted",children:(0,r.jsx)("img",{src:n,className:"w-full h-full object-contain cursor-pointer hover:opacity-80",alt:"inp",onClick:async()=>{try{let e=await fetch(n),t=await e.blob();await navigator.clipboard.write([new ClipboardItem({[t.type]:t})])}catch(e){console.error("Failed to copy image:",e)}},onContextMenu:async e=>{e.preventDefault();try{let t=await fetch(n),r=await t.blob();await navigator.clipboard.write([new ClipboardItem({[r.type]:r})]);let o=e.currentTarget,a=o.style.filter;o.style.filter="brightness(1.2)",setTimeout(()=>{o.style.filter=a},300)}catch(e){console.error("Failed to copy image:",e)}},title:"Click or right-click to copy"})}),(0,r.jsx)("span",{className:"text-xs",children:a})]},e)})}),0===t.inputs.length&&(0,r.jsx)("p",{className:"text-xs text-muted-foreground/70",children:"Drag from any node's output port to connect"}),(0,r.jsx)("div",{className:"flex items-center gap-2",children:(0,r.jsx)(u.$,{size:"sm",onClick:()=>i(t.id),disabled:t.isRunning||t.inputs.length<2,children:t.isRunning?"Mergingâ¦":"Merge"})}),(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)("div",{className:"flex items-center justify-between mb-1",children:(0,r.jsx)("div",{className:"text-xs text-muted-foreground",children:"Output"})}),(0,r.jsx)("div",{className:"w-full min-h-[200px] max-h-[400px] rounded-xl bg-muted/40 dark:bg-black/40 grid place-items-center",children:t.output?(0,r.jsx)("img",{src:t.output,className:"w-full h-auto max-h-[400px] object-contain rounded-xl cursor-pointer hover:opacity-80 transition-opacity",alt:"output",onClick:async()=>{if(t.output)try{let e=await fetch(t.output),n=await e.blob();await navigator.clipboard.write([new ClipboardItem({[n.type]:n})])}catch(e){console.error("Failed to copy image:",e)}},onContextMenu:async e=>{if(e.preventDefault(),t.output)try{let n=await fetch(t.output),r=await n.blob();await navigator.clipboard.write([new ClipboardItem({[r.type]:r})]);let o=e.currentTarget,a=o.style.filter;o.style.filter="brightness(1.2)",setTimeout(()=>{o.style.filter=a},500)}catch(e){console.error("Failed to copy image:",e)}},title:"Click or right-click to copy image to clipboard"}):(0,r.jsx)("span",{className:"text-muted-foreground/70 text-xs py-16",children:"Run merge to see result"})}),t.output&&(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(u.$,{className:"w-full",variant:"secondary",onClick:()=>{let e=document.createElement("a");e.href=t.output,e.download="merge-".concat(Date.now(),".png"),document.body.appendChild(e),e.click(),document.body.removeChild(e)},children:"\uD83D\uDCE5 Download Merged Image"})}),t.error&&(0,r.jsxs)("div",{className:"mt-2",children:[(0,r.jsx)("div",{className:"text-xs text-red-400",children:t.error}),t.error.includes("API key")&&(0,r.jsxs)("div",{className:"text-xs text-muted-foreground mt-2 space-y-1",children:[(0,r.jsx)("p",{children:"To fix this:"}),(0,r.jsxs)("ol",{className:"list-decimal list-inside space-y-1",children:[(0,r.jsxs)("li",{children:["Get key from: ",(0,r.jsx)("a",{href:"https://aistudio.google.com/app/apikey",target:"_blank",className:"text-blue-400 hover:underline",children:"Google AI Studio"})]}),(0,r.jsx)("li",{children:"Replace APi key placeholder with your key"}),(0,r.jsx)("li",{children:"Restart server (Ctrl+C, npm run dev)"})]})]})]})]})]})]})}function ed(){let[e,t]=(0,o.useState)(()=>[{id:J(),type:"CHARACTER",x:80,y:120,image:V,label:"CHARACTER 1"}]),[n,d]=(0,o.useState)(1),[c,p]=(0,o.useState)(0),[m,g]=(0,o.useState)(0),x=(0,o.useRef)(null),f=(0,o.useRef)(n);(0,o.useEffect)(()=>{f.current=n,T=n||1},[n]),(0,o.useEffect)(()=>{(async()=>{ed(!0);try{let e=await fetch("/api/auth/callback",{method:"GET"});if(e.ok){let t=await e.json();
1ea(t.isLoggedIn),t.isLoggedIn&&z("huggingface"),t.user&&eu(t.user)}}catch(e){console.error("Auth check error:",e)}finally{ed(!1)}})()},[]);let b=async()=>{if(en)try{await fetch("/api/auth/callback",{method:"DELETE"}),ea(!1),eu(null)}catch(e){console.error("Logout error:",e)}else try{let e=await fetch("/api/oauth-config"),{isConfigured:t,loginUrl:n,redirectUrl:r}=await e.json();if(console.log("OAuth Config from API:",{isConfigured:t,loginUrl:n?"present":"missing",redirectUrl:r}),!t||!n){console.error("OAuth not configured on server. Check Space settings."),alert("OAuth is not configured for this Space. Please ensure:\n1. hf_oauth: true is set in README.md\n2. Space has been rebuilt\n3. Check Space logs for OAuth configuration");return}window.location.href=n}catch(e){console.error("Failed to get OAuth config:",e),alert("Failed to initialize OAuth login. Please try again.")}},[v,y]=(0,o.useState)(null),[j,w]=(0,o.useState)(null),N=(0,o.useRef)(null),C=(0,o.useRef)(null),[k,P]=(0,o.useState)(""),[E,S]=(0,o.useState)(""),[R,A]=(0,o.useState)(!1),[M,I]=(0,o.useState)(()=>localStorage.getItem("nb-accent")||"0 75% 55%");(0,o.useEffect)(()=>{document.documentElement.style.setProperty("--primary",M),localStorage.setItem("nb-accent",M)},[M]);let[D,z]=(0,o.useState)("huggingface"),X={"gemini-2.5-flash-image":{provider:"gemini",label:"Gemini 2.5 Flash Image"},"gemini-3-pro-image-preview":{provider:"gemini",label:"Gemini 3 Pro Image"},"gemini-3.1-flash-image-preview":{provider:"gemini",label:"Gemini 3.1 Flash Image"},"gpt-image-1":{provider:"openai",label:"GPT Image 1"}},[W,$]=(0,o.useState)("gemini-2.5-flash-image"),[K,ee]=(0,o.useState)("Qwen-Image-2.1"),[en,ea]=(0,o.useState)(!1),[ei,ed]=(0,o.useState)(!0),[ec,eu]=(0,o.useState)(null);e.filter(e=>"CHARACTER"===e.type),e.filter(e=>"MERGE"===e.type);let ep=(e,n)=>{t(t=>t.map(t=>t.id===e&&"CHARACTER"===t.type?{...t,image:n}:t))},em=(e,n)=>{t(t=>t.map(t=>t.id===e&&"CHARACTER"===t.type?{...t,label:n}:t))},eh=(e,n,r)=>{t(t=>t.map(t=>t.id===e?{...t,x:n,y:r}:t))},eg=e=>{t(t=>t.filter(t=>t.id!==e).map(t=>"MERGE"===t.type?{...t,inputs:t.inputs.filter(t=>t!==e)}:t.input===e?{...t,input:void 0}:t))},ex=e=>{t(t=>t.map(t=>t.id===e&&"MERGE"===t.type?{...t,inputs:[]}:t))},ef=(e,n)=>{t(t=>t.map(t=>t.id===e?{...t,...n}:t))},eb=(t,n)=>{let r=new Set,o=t=>{if(t===n)return!0;if(r.has(t))return!1;r.add(t);let a=e.find(e=>e.id===t);if(!a)return!1;let i=a.input;if("string"==typeof i&&o(i))return!0;let s=a.inputs;if(Array.isArray(s)){for(let e of s)if(o(e))return!0}return!1};return o(t)},ev=()=>{y(null),w(null),N.current=null,C.current=null,document.body.classList.remove("nb-connecting"),document.body.style.userSelect="",document.body.style.webkitUserSelect=""},ey=(t,n)=>{let r=48/(f.current||1),o=null,a=r;for(let r of e){if(r.id===n||"CHARACTER"===r.type||eb(n,r.id))continue;let e=eo(r),i=Math.hypot(t.x-e.x,t.y-e.y);i<a&&(a=i,o=r)}return o},ej=()=>{let e=N.current,t=C.current;if(e&&t){let n=ey(t,e);if(n)return void("MERGE"===n.type?eP(n.id):ew(n.id))}ev()};(0,o.useEffect)(()=>{if(!v)return;let e=()=>ej();return window.addEventListener("pointerup",e),window.addEventListener("pointercancel",e),()=>{window.removeEventListener("pointerup",e),window.removeEventListener("pointercancel",e)}},[v,e]);let ew=n=>{v&&(e.find(e=>e.id===v)&&(v===n||eb(v,n)?t(e=>e.map(e=>e.id===n?{...e,error:"Invalid connection: this would create a loop."}:e)):t(e=>e.map(e=>e.id===n?{...e,input:v,error:null}:e))),ev())},eN=e=>{let t={};switch(e.type){case"BACKGROUND":e.backgroundType&&(t.backgroundType=e.backgroundType,t.backgroundColor=e.backgroundColor,t.backgroundImage=e.backgroundImage,t.customBackgroundImage=e.customBackgroundImage,t.customPrompt=e.customPrompt,"gradient"===e.backgroundType&&(t.gradientDirection=e.gradientDirection,t.gradientStartColor=e.gradientStartColor,t.gradientEndColor=e.gradientEndColor),"city"===e.backgroundType&&(t.citySceneType=e.citySceneType,t.cityTimeOfDay=e.cityTimeOfDay),"photostudio"===e.backgroundType&&(t.studioSetup=e.studioSetup,t.studioBackgroundColor=e.studioBackgroundColor,t.studioLighting=e.studioLighting,t.faceCamera=e.faceCamera));break;case"CLOTHES":e.clothesPrompt&&(t.clothesPrompt=e.clothesPrompt),e.clothesImage&&(t.clothesImage=e.clothesImage);break;case"STYLE":e.stylePreset&&(t.stylePreset=e.stylePreset,t.styleStrength=e.styleStrength);break;case"EDIT":e.editPrompt&&(t.editPrompt=e.editPrompt);break;case"CAMERA":e.focalLength&&"None"!==e.focalLength&&(t.focalLength=e.focalLength),e.aperture&&"None"!==e.aperture&&(t.aperture=e.aperture),e.whiteBalance&&"None"!==e.whiteBalance&&(t.whiteBalance=e.whiteBalance),e.angle&&"None"!==e.angle&&(t.angle=e.angle),e.filmStyle&&"None"!==e.filmStyle&&(t.filmStyle=e.filmStyle);{let n=[e.lightingSetup,e.lightingQuality].filter(e=>!!e&&"None"!==e);n.length&&(t.lighting=n.join(", "))}e.bokeh&&"None"!==e.bokeh&&(t.bokeh=e.bokeh),e.composition&&"None"!==e.composition&&(t.composition=e.composition),e.aspectRatio&&"None"!==e.aspectRatio&&(t.aspectRatio=e.aspectRatio),e.motionBlur&&"None"!==e.motionBlur&&(t.motionBlur=e.motionBlur);break;case"AGE":e.targetAge&&(t.targetAge=e.targetAge);break;case"FACE":if(e.faceOptions){let n={};e.faceOptions.removePimples&&(n.removePimples=!0),e.faceOptions.addSunglasses&&(n.addSunglasses=!0),e.faceOptions.addHat&&(n.addHat=!0),e.faceOptions.changeHairstyle&&"None"!==e.faceOptions.changeHairstyle&&(n.changeHairstyle=e.faceOptions.changeHairstyle),e.faceOptions.facialExpression&&"None"!==e.faceOptions.facialExpression&&(n.facialExpression=e.faceOptions.facialExpression),e.faceOptions.beardStyle&&"None"!==e.faceOptions.beardStyle&&(n.beardStyle=e.faceOptions.beardStyle),Object.keys(n).length>0&&(t.faceOptions=n)}break;case"LIGHTNING":e.lightingPrompt&&e.selectedLighting&&(t.lightingPrompt=e.lightingPrompt,t.selectedLighting=e.selectedLighting);break;case"POSES":e.posePrompt&&e.selectedPose&&(t.posePrompt=e.posePrompt,t.selectedPose=e.selectedPose);break;case"ANGLE":void 0!==e.cameraX&&void 0!==e.cameraY&&(t.cameraX=e.cameraX,t.cameraY=e.cameraY,void 0!==e.cameraZ&&(t.cameraZ=e.cameraZ))}return t},eC=async n=>{let r=e.find(e=>e.id===n);if(!r)return void console.error("Node not found:",n);let o=null,a={},i=[],s=r.input;if(s){let r=[],l=new Map,d=function(t){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;if(n.has(t))return null;n.add(t);let o=e.find(e=>e.id===t);if(!o)return null;if("CHARACTER"===o.type)return o.image;if("MERGE"===o.type&&l.has(t))return l.get(t)||null;if("MERGE"===o.type&&o.output)return o.output||null;if(o.output)return o.output;if("MERGE"===o.type){if(!o.output&&o.inputs.length>=2)return r.some(e=>e.id===o.id)||r.push(o),null;if(o.inputs.length>0){let e=d(o.inputs[0],n);if(e)return e}}let a=o.input;return a?d(a,n):null},c=function(t){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Set;if(r.has(t))return{};r.add(t);let o=e.find(e=>e.id===t);if(!o)return{};let a={},s=o.input;if(s&&(a=c(s,r)),t===n||!o.output&&t!==n){let e=eN(o);Object.keys(e).length>0&&(a={...a,...e},t===n||o.output||i.push(t))}return a};if(o=d(s),r.length>0&&!o){for(let e of r){t(t=>t.map(t=>
1t.id===e.id?{...t,isRunning:!0,error:null}:t));try{let n=await eS(e);t(t=>t.map(t=>t.id===e.id?{...t,output:n||void 0,isRunning:!1,error:null}:t)),i.push(e.id),n&&l.set(e.id,n),s===e.id&&(o=n)}catch(r){console.error("Auto-merge error:",r),t(t=>t.map(t=>t.id===e.id?{...t,isRunning:!1,error:(null==r?void 0:r.message)||"Merge failed"}:t)),t(e=>e.map(e=>e.id===n?{...e,error:"Failed to process upstream MERGE node",isRunning:!1}:e));return}}o||(o=d(s))}a=c(s,new Set)}if(!o){let e=s?"No source image found in the chain. Connect to a CHARACTER node or processed node.":"No input connected. Connect an image source to this node.";t(t=>t.map(t=>t.id===n?{...t,error:e,isRunning:!1}:t));return}let l=eN(r),d={...a,...l},c=Object.keys(d).length>0?i.length+1:1,u=Date.now();t(e=>e.map(e=>e.id===n||i.includes(e.id)?{...e,isRunning:!0,error:null,startTime:u,executionTime:void 0}:e));try{let e;if(o&&o.length>0xa00000&&console.warn("Large input image detected, size:",(o.length/1048576).toFixed(2)+"MB"),d.customBackgroundImage&&!d.customBackgroundImage.startsWith("data:")&&!d.customBackgroundImage.startsWith("http")&&!d.customBackgroundImage.startsWith("/"))throw Error("Invalid background image format. Please upload a valid image.");if(o&&o.startsWith("blob:"))try{let e=await fetch(o),t=await e.blob();o=await new Promise(e=>{let n=new FileReader;n.onloadend=()=>e(n.result),n.readAsDataURL(t)})}catch(e){console.error("Failed to convert blob URL:",e)}if("huggingface"===D){if(!en)throw Error("Please login with HuggingFace to use HF models. Click 'Login with HuggingFace' in the header.");console.log("[HF Debug] Sending to /api/hf-process:",{hasImage:!!o,imageType:o?o.startsWith("data:")?"dataURL":o.startsWith("blob:")?"blobURL":o.startsWith("http")?"httpURL":"unknown":"null",imagePreview:null==o?void 0:o.substring(0,80),model:K}),e=await fetch("/api/hf-process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"COMBINED",model:K,image:o,params:d})})}else e=await fetch("/api/process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"COMBINED",image:o,params:d,model:W,apiToken:"gemini"===D&&k||void 0,openaiApiToken:"gpt"===D&&E||void 0})});let a=e.headers.get("content-type");if(!a||!a.includes("application/json")){let t=await e.text();throw console.error("Non-JSON response received:",t),Error("Server returned an error page instead of JSON. Check your API key configuration.")}let s=await e.json();if(!e.ok){var p;let e="string"==typeof s.error?s.error:(null==(p=s.error)?void 0:p.message)||JSON.stringify(s.error)||"Processing failed";throw Error(e)}let l=Date.now()-u;t(e=>e.map(e=>e.id===n?{...e,output:s.image,isRunning:!1,error:null,executionTime:l}:i.includes(e.id)?{...e,isRunning:!1,error:null,executionTime:l}:e)),c>1||r.type}catch(e){console.error("Process error:",e),t(t=>t.map(t=>t.id===n||i.includes(t.id)?{...t,isRunning:!1,error:(null==e?void 0:e.message)||"Error"}:t))}},ek=t=>{y(t),N.current=t;let n=e.find(e=>e.id===t);if(n){let e=er(n);w(e),C.current=e}document.body.classList.add("nb-connecting"),document.body.style.userSelect="none",document.body.style.webkitUserSelect="none"},eP=n=>{if(v){if(e.find(e=>e.id===v))if(v===n||eb(v,n))t(e=>e.map(e=>e.id===n?{...e,error:"Invalid connection: this would create a loop."}:e));else t(e=>e.map(e=>e.id===n&&"MERGE"===e.type?{...e,inputs:Array.from(new Set([...e.inputs,v]))}:e));ev()}},eE=t=>{let n=new Set,r=t;for(;r&&!n.has(r);){n.add(r);let t=e.find(e=>e.id===r);if(!t)break;if("CHARACTER"===t.type)return{image:t.image,label:t.label||""};let o=t.output;if(o)return{image:o,label:"MERGE"===t.type?"Merged Image":"".concat(t.type," Output")};if("MERGE"===t.type)break;r=t.input}return{image:null,label:""}},eS=async e=>{var t;let n=[],r=[];for(let t of e.inputs){let{image:e,label:o}=eE(t);if(e){if(!e.startsWith("data:")&&!e.startsWith("http")&&!e.startsWith("/")){console.error("Invalid image format for ".concat(o,":"),e.substring(0,100));continue}n.push(e),r.push({image:e,label:o||"Input ".concat(n.length)})}}
1if(n.length<2)throw Error("Not enough valid inputs for merge. Need at least 2 images.");let o=Q(r),a=await fetch("/api/process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"MERGE",images:n,prompt:o,model:W,apiToken:"gemini"===D&&k||void 0,openaiApiToken:"gpt"===D&&E||void 0})}),i=a.headers.get("content-type");if(!i||!i.includes("application/json"))throw console.error("Non-JSON response received:",await a.text()),Error("Server returned an error page instead of JSON. Check your API key configuration.");let s=await a.json();if(!a.ok)throw Error(s.error||"Merge failed");return s.image||(null==(t=s.images)?void 0:t[0])||null},eR=async n=>{if("huggingface"===D)return void t(e=>e.map(e=>e.id===n&&"MERGE"===e.type?{...e,error:"MERGE requires a multi-image model. HuggingFace models only accept single images. Please switch to Gemini or GPT in the header and enter your API key."}:e));t(e=>e.map(e=>e.id===n&&"MERGE"===e.type?{...e,isRunning:!0,error:null}:e));try{var r;let o=e.find(e=>e.id===n)||null;if(!o)return;let a=o.inputs.map((e,t)=>{let{image:n,label:r}=eE(e);return n?{image:n,label:r||"Input ".concat(t+1)}:null}).filter(Boolean);if(a.length<2)throw Error("Connect at least two nodes with images (CHARACTER nodes or processed nodes).");let i=Q(a),s=a.map(e=>e.image),l=await fetch("/api/process",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"MERGE",images:s,prompt:i,model:W,apiToken:"gemini"===D&&k||void 0,openaiApiToken:"gpt"===D&&E||void 0})}),d=l.headers.get("content-type");if(!d||!d.includes("application/json")){let e=await l.text();throw console.error("Non-JSON response received:",e),Error("Server returned an error page instead of JSON. Check your API key configuration.")}let c=await l.json();if(!l.ok){let e=c.error||"Merge failed";if(e.includes("API key"))throw Error("API key not configured. Add GOOGLE_API_KEY to .env.local");throw Error(e)}let u=c.image||(null==(r=c.images)?void 0:r[0])||null;t(e=>e.map(e=>e.id===n&&"MERGE"===e.type?{...e,output:u,isRunning:!1}:e)),u&&o.inputs.map((t,n)=>{let r=e.find(e=>e.id===t);return(null==r?void 0:r.type)==="CHARACTER"?r.label||"Character ".concat(n+1):"".concat((null==r?void 0:r.type)||"Node"," ").concat(n+1)})}catch(e){console.error("Merge error:",e),t(t=>t.map(t=>t.id===n&&"MERGE"===t.type?{...t,isRunning:!1,error:(null==e?void 0:e.message)||"Error"}:t))}},eA=(0,o.useMemo)(()=>{let t=0,n=0,r=1e3,o=1e3;return e.forEach(e=>{t=Math.min(t,e.x-100),n=Math.min(n,e.y-100),r=Math.max(r,e.x+500),o=Math.max(o,e.y+500)}),j&&(t=Math.min(t,j.x-100),n=Math.min(n,j.y-100),r=Math.max(r,j.x+100),o=Math.max(o,j.y+100)),{x:t,y:n,width:r-t,height:o-n}},[e,j]),eM=(0,o.useMemo)(()=>{let t=(e,t,n,r)=>{let o=n-e,a=r-t,i=Math.min(200,Math.max(50,.3*Math.sqrt(o*o+a*a)));return"M ".concat(e," ").concat(t," C ").concat(e+i," ").concat(t,", ").concat(n-i," ").concat(r,", ").concat(n," ").concat(r)},n=[],r=null;for(let r of e)if("MERGE"===r.type)for(let o of r.inputs){let a=e.find(e=>e.id===o);if(a){let e=er(a),o=eo(r),i=r.isRunning;n.push({path:t(e.x,e.y,o.x,o.y),processing:i})}}else if(r.input){let o=r.input,a=e.find(e=>e.id===o);if(a){let e=er(a),o=eo(r),i=r.isRunning;n.push({path:t(e.x,e.y,o.x,o.y),processing:i})}}if(v&&j){let o=e.find(e=>e.id===v);if(o){let e=er(o),a=ey(j,v),i=a?eo(a):j;a&&(r=i),n.push({path:t(e.x,e.y,i.x,i.y),active:!0,snapped:!!a})}}return{paths:n,snapPoint:r}},[e,v,j,n]),eT=(0,o.useRef)(!1),eI=(0,o.useRef)(null),eD=e=>{eT.current=!1,eI.current=null,e.currentTarget.releasePointerCapture(e.pointerId)},eO=(0,o.useRef)(c),eL=(0,o.useRef)(m);(0,o.useEffect)(()=>{eO.current=c,eL.current=m},[c,m]),(0,o.useEffect)(()=>{let e=x.current;if(!e)return;let t={x:0,y:0},n=null,r=()=>{n=null,eO.current-=t.x,eL.current-=t.y,t.x=0,t.y=0,p(eO.current),g(eL.current)},o=(e,o)=>{t.x+=e,t.y+=o,null===n&&(n=requestAnimationFrame(r))},a=t=>{let n=e=>1===t.deltaMode?16*e:2===t.deltaMode?100*e:e;if(t.ctrlKey||t.metaKey){t.preventDefault();let r=e.getBoundingClientRect(),o=f.current,a=Math.min(2.5,Math.max(.25,o*Math.exp(-(.0015*n(t.deltaY))))),i=(t.clientX-r.left-eO.current)/o,s=(t.clientY-r.top-eL.current)/o,l=t.clientX-r.left-i*a,c=t.clientY-r.top-s*a;eO.current=l,eL.current=c,f.current=a,p(l),g(c),d(a);return}if(!((t,n)=>{let r=t instanceof Element?t:null;for(;r&&r!==e;){if(r instanceof HTMLElement){let e=getComputedStyle(r);if(/(auto|scroll)/.test(e.overflowY)&&r.scrollHeight>r.clientHeight+1&&(n>0?r.scrollTop+r.clientHeight<r.scrollHeight-1:r.scrollTop>0))return r}r=r.parentElement}return null})(t.target,n(t.deltaY))){if(t.target instanceof Element&&t.target.closest(".
1nb-overlay"))return void t.preventDefault();t.preventDefault(),t.shiftKey?o(n(0!==t.deltaY?t.deltaY:t.deltaX),0):o(n(t.deltaX),n(t.deltaY))}};return e.addEventListener("wheel",a,{passive:!1}),()=>{e.removeEventListener("wheel",a),null!==n&&cancelAnimationFrame(n)}},[]);let[eG,eF]=(0,o.useState)(!1),[eB,eH]=(0,o.useState)({x:0,y:0}),[eU,e_]=(0,o.useState)({x:0,y:0}),[eY,ez]=(0,o.useState)({open:!1,x:0,y:0,nodeId:null}),eX=()=>ez(e=>({...e,open:!1,nodeId:null})),eW=e=>{let n={id:J(),x:eU.x,y:eU.y};switch(e){case"CHARACTER":t(e=>[...e,{id:J(),type:"CHARACTER",x:eU?eU.x:80+60*Math.random(),y:eU?eU.y:120+60*Math.random(),image:V,label:"CHARACTER ".concat(e.filter(e=>"CHARACTER"===e.type).length+1)}]);break;case"MERGE":t(e=>[...e,{id:J(),type:"MERGE",x:eU?eU.x:520,y:eU?eU.y:160,inputs:[]}]);break;case"BACKGROUND":t(e=>[...e,{...n,type:"BACKGROUND",backgroundType:"color"}]);break;case"CLOTHES":t(e=>[...e,{...n,type:"CLOTHES"}]);break;case"STYLE":t(e=>[...e,{...n,type:"STYLE",styleStrength:50}]);break;case"CAMERA":t(e=>[...e,{...n,type:"CAMERA"}]);break;case"AGE":t(e=>[...e,{...n,type:"AGE",targetAge:30}]);break;case"FACE":t(e=>[...e,{...n,type:"FACE",faceOptions:{}}]);break;case"EDIT":t(e=>[...e,{...n,type:"EDIT"}
1]);break;case"LIGHTNING":t(e=>[...e,{...n,type:"LIGHTNING",lightingStrength:75}]);break;case"POSES":t(e=>[...e,{...n,type:"POSES",poseStrength:60}]);break;case"ANGLE":t(e=>[...e,{...n,type:"ANGLE",cameraX:0,cameraY:0,cameraZ:.5}])}eF(!1)};return(0,r.jsxs)("div",{className:"min-h-[100svh] bg-background text-foreground",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between px-6 py-3 border-b border-border/60 bg-card/70 backdrop-blur",children:[(0,r.jsxs)("h1",{className:"text-lg font-semibold tracking-wide",children:[(0,r.jsx)("span",{className:"mr-2","aria-hidden":!0,children:"\uD83D\uDDBCï¸"}),"Portrait Editor"]}),(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("div",{className:"flex items-center gap-1 p-1 bg-card rounded-lg relative border border-border shadow-sm",children:["gpt","gemini","huggingface"].map(e=>(0,r.jsxs)("button",{className:"relative px-4 py-1.5 text-sm font-medium rounded-md transition-colors z-10 ".concat(D===e?"text-primary-foreground":"text-gray-500 hover:text-gray-900 dark:text-zinc-400 dark:hover:text-zinc-100"),onClick:()=>{z(e),"gemini"===e?$("gemini-2.5-flash-image"):"gpt"===e&&$("gpt-image-1")},title:"gpt"===e?"Use OpenAI GPT image models":"gemini"===e?"Use Google Gemini image models - supports all features including MERGE":"Use HuggingFace models - requires HF login",children:[D===e&&(0,r.jsx)(a.P.div,{layoutId:"active-mode-pill",className:"absolute inset-0 bg-primary rounded-md shadow-sm border border-primary/50 -z-10",transition:{type:"spring",stiffness:400,damping:30}}),(0,r.jsxs)("span",{className:"relative z-10 flex items-center gap-1.5",children:["gpt"===e&&(0,r.jsx)(s.A,{size:14}),"gemini"===e&&(0,r.jsx)(i.A.Color,{size:14}),"huggingface"===e&&(0,r.jsx)(l.A.Color,{size:14}),(0,r.jsx)("span",{children:"gpt"===e?"GPT":"gemini"===e?"Gemini":"HuggingFace"})]})]},e))}),"gemini"===D?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"h-6 w-px bg-border"}),(0,r.jsx)(h,{id:"image-model",value:W,onChange:e=>$(e.target.value),className:"w-52",children:Object.entries(X).filter(e=>{let[,t]=e;return"gemini"===t.provider}).map(e=>{let[t,n]=e;return(0,r.jsx)("option",{value:t,children:n.label},t)})}),k?(0,r.jsx)("div",{className:"text-xs px-2 py-1 rounded-md bg-green-500/20 text-green-400",children:"Gemini key set â"}):(0,r.jsx)("div",{className:"text-xs px-2 py-1 rounded-md bg-red-500/20 text-red-400",children:"Gemini key required"}),(0,r.jsx)(q,{id:"api-token",type:"password",placeholder:"Gemini API key",value:k,onChange:e=>P(e.target.value),className:"w-44"})]}):"gpt"===D?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"h-6 w-px bg-border"}),(0,r.jsx)(h,{id:"image-model",value:W,onChange:e=>$(e.target.value),className:"w-44",children:Object.entries(X).filter(e=>{let[,t]=e;return"openai"===t.provider}).map(e=>{let[t,n]=e;return(0,r.jsx)("option",{value:t,children:n.label},t)})}),E?(0,r.jsx)("div",{className:"text-xs px-2 py-1 rounded-md bg-green-500/20 text-green-400",children:"OpenAI key set â"}):(0,r.jsx)("div",{className:"text-xs px-2 py-1 rounded-md bg-red-500/20 text-red-400",children:"OpenAI key required"}),(0,r.jsx)(q,{id:"openai-token",type:"password",placeholder:"OpenAI API key",value:E,onChange:e=>S(e.target.value),className:"w-44"})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"h-6 w-px bg-border"}),en&&ec?(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[ec.avatarUrl&&(0,r.jsx)("img",{src:ec.avatarUrl,alt:ec.name||"User",className:"w-6 h-6 rounded-full"}),(0,r.jsx)("span",{className:"text-sm font-medium",children:ec.name||ec.username}),(0,r.jsx)(u.$,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs",onClick:b,children:"Logout"})]}):(0,r.jsx)(u.$,{variant:"default",size:"sm",className:"h-8",onClick:b,disabled:ei,children:ei?"Checking...":"Login with HuggingFace"}),en&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("label",{htmlFor:"hf-model",className:"text-sm font-medium text-muted-foreground",children:"Model:"}),(0,r.jsx)("select",{id:"hf-model",value:K,onChange:e=>ee(e.target.value),className:"h-8 px-2 text-sm bg-background border border-border rounded-md focus:outline-none focus:ring-2 focus:ring-ring",children:Object.entries({"Qwen-Image-2.1":{id:"Qwen
1/Qwen-Image-2.1",name:"Qwen Image 2.1",type:"image-to-image",description:"Latest Qwen image editing and generation model"}}).map(e=>{let[t,n]=e;return(0,r.jsxs)("option",{value:t,children:[n.name," (",n.type,")"]},t)})})]})]}),(0,r.jsx)("div",{className:"h-6 w-px bg-border"}),(0,r.jsx)(u.$,{variant:"outline",size:"sm",className:"h-8 px-3",type:"button",onClick:()=>A(!0),children:"Help"})]})]}),R&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("div",{className:"fixed inset-0 bg-black/60 z-[9998]",onClick:()=>A(!1)}),(0,r.jsxs)("div",{className:"fixed right-0 top-0 h-full w-[26rem] bg-card border-l border-border shadow-2xl z-[9999] overflow-y-auto scrollbar-thin",children:[(0,r.jsxs)("div",{className:"px-6 py-5 border-b border-border/60 flex items-center justify-between sticky top-0 bg-card z-10",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h2",{className:"text-base font-semibold text-foreground tracking-tight",children:"Help & Guide"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-0.5",children:"Modes, models, shortcuts & tips"})]}),(0,r.jsx)(u.$,{variant:"ghost",size:"sm",className:"h-8 w-8 p-0 rounded-md hover:bg-muted",onClick:()=>A(!1),"aria-label":"Close help",children:(0,r.jsx)("span",{className:"text-lg leading-none",children:"\xd7"})})]}),(0,r.jsxs)("div",{className:"p-6 space-y-7",children:[(0,r.jsxs)("section",{children:[(0,r.jsx)("h3",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground mb-3",children:"Accent Colour"}),(0,r.jsx)("div",{className:"flex flex-wrap gap-2",children:[{name:"Red",hsl:"0 75% 55%"},{name:"Orange",hsl:"24 88% 52%"},{name:"Amber",hsl:"43 96% 48%"},{name:"Lime",hsl:"84 60% 42%"},{name:"Teal",hsl:"172 58% 40%"},{name:"Sky",hsl:"200 80% 50%"},{name:"Blue",hsl:"217 80% 58%"},{name:"Violet",hsl:"263 68% 60%"},{name:"Pink",hsl:"328 68% 57%"},{name:"Rose",hsl:"350 72% 54%"}].map(e=>{let t=M===e.hsl;return(0,r.jsx)("button",{title:e.name,onClick:()=>I(e.hsl),className:"w-8 h-8 rounded-full border-2 transition-all duration-150 hover:scale-110 focus:outline-none flex items-center justify-center",style:{backgroundColor:"hsl(".concat(e.hsl,")"),borderColor:t?"rgba(255,255,255,0.9)":"transparent",boxShadow:t?"0 0 0 3px hsl(".concat(e.hsl," / 0.55)"):void 0},children:t&&(0,r.jsx)("svg",{viewBox:"0 0 10 8",width:"14",height:"14",fill:"none",stroke:"white",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",style:{filter:"drop-shadow(0 0 1.5px rgba(0,0,0,0.7))"},children:(0,r.jsx)("path",{d:"M1 4l3 3 5-6"})})},e.hsl)})})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h3",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground mb-3",children:"Quick start"}),(0,r.jsxs)("ol",{className:"text-sm text-foreground/90 space-y-2 list-decimal list-inside marker:text-muted-foreground",children:[(0,r.jsxs)("li",{children:["Pick a mode in the navbar â ",(0,r.jsx)("strong",{children:"GPT"}),", ",(0,r.jsx)("strong",{children:"Gemini"}),", or ",(0,r.jsx)("strong",{children:"HuggingFace"}),"."]}),(0,r.jsx)("li",{children:"Paste the matching API key (kept in memory only â cleared on refresh)."}),(0,r.jsx)("li",{children:"Right-click blank canvas to add a Character or any other node."}),(0,r.jsx)("li",{children:"Right-click any node to duplicate it or delete it."}),(0,r.jsx)("li",{children:"Drag from a green output port to a red input port to wire nodes together."}),(0,r.jsxs)("li",{children:["Click ",(0,r.jsx)("strong",{children:"Run"})," on a node to process the chain up to that point."]})]})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h3",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground mb-3",children:"Canvas controls"}),(0,r.jsx)("div",{className:"p-3 rounded-lg border border-border bg-muted/40",children:(0,r.jsxs)("ul",{className:"text-sm text-muted-foreground space-y-2",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{className:"text-foreground",children:"Zoom in / out"})," â hold ",(0,r.jsx)("kbd",{className:"text-xs px-1.5 py-0.5 rounded bg-background/60 border border-border/60",children:"Ctrl"})," (or ",(0,r.jsx)("kbd",{className:"text-xs px-1.5 py-0.5 rounded bg-background/60 border border-border/60",children:"Cmd"})," on Mac) and scroll the mouse wheel. Pinch on a trackpad works too. Zoom centres on your cursor."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{className:"text-foreground",children:"Scroll up / down"})," â just scroll the mouse wheel."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{className:"text-foreground",children:"Scroll left / right"})," â hold ",(0,r.jsx)("kbd",{className:"text-xs px-1.5 py-0.5 rounded bg-background/60 border border-border/60",children:"Shift"})," and scroll."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{className:"text-foreground",children:"Pan freely"})," â click and drag any empty canvas area."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{className:"text-foreground",children:"Move a node"})," â drag it by its header."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{className:"text-foreground",children:"Connect nodes"})," â drag from a green port; the line snaps to a red input port when you get close, then release."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("strong",{className:"text-foreground",children:"Disconnect"})," â grab the red input port and pull the connection off."]}),(0,r.jsx)("li",{children:"Scrolling while hovering a node panel or menu with its own scrollbar scrolls that content instead of the canvas."})]})})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h3",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground mb-3",children:"Processing Modes"}),(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"p-3 rounded-lg border border-border bg-muted/40",children:[(0,r.jsxs)("p",{className:"font-medium text-foreground mb-1 flex items-center gap-2",children:[(0,r.jsx)(s.A,{size:16})," GPT ",(0,r.jsx)("span",{className:"text-xs text-muted-foreground font-normal",children:"(OpenAI)"})]}),(0,r.jsxs)("p",{className:"text-sm text-muted-foreground",children:["Calls the OpenAI Responses API with the ",(0,r.jsx)("code",{className:"text-xs px-1 py-0.5 rounded bg-background/60 border border-border/60",children:"image_generation"})," tool. Supports text-to-image and image edit nodes including MERGE."]}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground mt-2",children:["Model: ",(0,r.jsx)("strong",{className:"text-foreground",children:"gpt-image-1"}),". Get a key from ",(0,r.jsx)("a",{href:"https://platform.openai.com/api-keys",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"platform.openai.com"}),"."]})]}),(0,r.jsxs)("div",{className:"p-3 rounded-lg border border-border bg-muted/40",children:[(0,r.jsxs)("p",{className:"font-medium text-foreground mb-1 flex items-center gap-2",children:[(0,r.jsx)(i.A.Color,{size:16})," Gemini ",(0,r.jsx)("span",{className:"text-xs text-muted-foreground font-normal",children:"(Google)"})]}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Google Gemini image models. Pick from the model dropdown â Flash for speed, Pro for quality, preview variants for the latest."}),(0,r.jsxs)("p",{className:"text-xs text-muted-foreground mt-2",children:["Models: ",(0,r.jsx)("strong",{className:"text-foreground",children:"2.5-flash-image"}),", ",(0,r.jsx)("strong",{className:"text-foreground",children:"3-pro-image-preview"}),", ",(0,r.jsx)("strong",{className:"text-foreground",children:"3.1-flash-image-preview"}),". Key from ",(0,r.jsx)("a",{href:"https://aistudio.google.com/app/apikey",target:"_blank",rel:"noopener noreferrer",className:"text-primary hover:underline",children:"AI Studio"}),"."]})]}),(0,r.jsxs)("div",{className:"p-3 rounded-lg border border-border bg-muted/40",children:[(0,r.jsxs)("p",{className:"font-medium text-foreground mb-1 flex items-center gap-2",children:[(0,r.jsx)(l.A.Color,{size:16})," HuggingFace"]}),(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:"Qwen-Image-2.1 via our HuggingFace Gradio Space. Single-image edits only â no MERGE."}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground mt-2",children:"Sign in with HuggingFace; uses your GPU quota."})]})]})]}),(0,r.jsxs)("section",{className:"p-3 rounded-lg border border-amber-500/30 bg-amber-500/10",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-amber-400 mb-1",children:"â ï¸ MERGE compatibility"}),(0,r.jsxs)("p",{className:"text-sm text-muted-foreground",children:[(0,r.jsx)("strong",{children:"MERGE"})," needs a multi-image model. It works with ",(0,r.jsx)("strong",{children:"GPT"})," and ",(0,r.jsx)("strong",{children:"Gemini"}),", but not HuggingFace."]})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h3",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground mb-3",children:"Node types"}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[(0,r.jsxs)("div",{className:"p-2 rounded-md bg-muted/40 border border-border/60",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"Character"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Upload, paste, or drop an image."})]}),(0,r.jsxs)("div",{className:"p-2 rounded-md bg-muted/40 border border-border/60",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"Merge"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Combine 2+ characters into one scene."})]}),(0,r.jsxs)("div",{className:"p-2 rounded-md bg-muted/40 border border-border/60",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"Backgroun
1d"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Color, gradient, scene, or reference image."})]}),(0,r.jsxs)("div",{className:"p-2 rounded-md bg-muted/40 border border-border/60",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"Style"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Anime, cyberpunk, Van Gogh, etc."})]}),(0,r.jsxs)("div",{className:"p-2 rounded-md bg-muted/40 border border-border/60",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"Face / Pose"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Expressions, hair, body posing."})]}),(0,r.jsxs)("div",{className:"p-2 rounded-md bg-muted/40 border border-border/60",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"Age / Camera / Light"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Transform photographic feel."})]}),(0,r.jsxs)("div",{className:"p-2 rounded-md bg-muted/40 border border-border/60",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"Angle"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Control a 3D Earth camera orbit and zoom."})]}),(0,r.jsxs)("div",{className:"p-2 rounded-md bg-muted/40 border border-border/60",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"Clothes"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Swap outfits using a reference."})]}),(0,r.jsxs)("div",{className:"p-2 rounded-md bg-muted/40 border border-border/60",children:[(0,r.jsx)("p",{className:"font-medium text-foreground",children:"Edit"}),(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"Free-form prompt for any change."})]})]})]}),(0,r.jsxs)("section",{children:[(0,r.jsx)("h3",{className:"text-[11px] font-semibold uppercase tracking-wider text-muted-foreground mb-3",children:"Tips & shortcuts"}),(0,r.jsxs)("ul",{className:"text-sm text-foreground/90 space-y-1.5",children:[(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"â¢"})," ",(0,r.jsx)("strong",{children:"Right-click"})," blank canvas to add nodes."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"â¢"})," ",(0,r.jsx)("strong",{children:"Right-click"})," a node to duplicate or delete it."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"â¢"})," ",(0,r.jsx)("strong",{children:"Drag"})," a node header to move it; ",(0,r.jsx)("strong",{children:"scroll"})," the canvas to zoom."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"â¢"})," ",(0,r.jsx)("strong",{children:"Drag"})," from the green output port to a red input port."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"â¢"})," ",(0,r.jsx)("strong",{children:"Drag"})," the Angle node 3D Earth to orbit; ",(0,r.jsx)("strong",{children:"scroll"})," it to adjust distance."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"â¢"})," ",(0,r.jsx)("strong",{children:"Paste"})," an image from clipboard directly into Character / Background."]}),(0,r.jsxs)("li",{children:[(0,r.jsx)("span",{className:"text-muted-foreground",children:"â¢"})," Hover a node to see its ",(0,r.jsx)("strong",{children:"elapsed time"})," badge."]})]})]}),(0,r.jsxs)("section",{className:"p-3 rounded-lg border border-border bg-muted/40",children:[(0,r.jsx)("h4",{className:"text-sm font-semibold text-foreground mb-2",children:"\uD83D\uDD12 Privacy & keys"}),(0,r.jsxs)("ul",{className:"text-sm text-muted-foreground space-y-1",children:[(0,r.jsxs)("li",{children:["⢠",(0,r.jsx)("strong",{children:"OpenAI"})," and ",(0,r.jsx)("strong",{children:"Gemini"})," keys live in memory only â cleared the moment you refresh."]}),(0,r.jsxs)("li",{children:["⢠",(0,r.jsx)("strong",{children:"HuggingFace"})," auth uses a secure HTTP-only cookie."]}),(0,r.jsx)("li",{children:"⢠Requests go directly to the official provider APIs from this server."}),(0,r.jsx)("li",{children:"⢠Nothing is persisted to a database."})]})]})]})]})]}),(0,r.jsxs)("div",{ref:x,className:"relative w-full h-[calc(100svh-56px)] overflow-hidden nb-canvas",style:{imageRendering:"auto",transform:"translateZ(0)",willChange:"contents"},onContextMenu:e=>{e.preventDefault();let t=x.current.getBoundingClientRect();e_(et(e.clientX,e.clientY,t,c,m,n));let r=e.clientX-t.left,o=e.clientY-t.top;r+224>t.width&&(r=t.width-224-10),o+320>t.height&&(o=t.height-320-10),eH({x:r=Math.max(10,r),y:o=Math.max(10,o)}),eF(!0)},onPointerDown:e=>{(e.target===e.currentTarget||"svg"===e.target.tagName||"line"===e.target.tagName)&&(eT.current=!0,eI.current={sx:e.clientX,sy:e.clientY,ox:c,oy:m},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{(e=>{if(!eT.current||!eI.current)return;let t=e.clientX-eI.current.sx,n=e.clientY-eI.current.sy;p(eI.current.ox+t),g(eI.current.oy+n)})(e);if(N.current){let t=x.current.getBoundingClientRect(),r=et(e.clientX,e.clientY,t,c,m,n);w(r),C.current=r}},onPointerUp:e=>{eD(e),v&&ej()},onPointerLeave:e=>{eD(e)},children:[(0,r.jsxs)("div",{className:"absolute left-0 top-0 will-change-transform",style:{transform:"translate3d(".concat(c,"px, ").concat(m,"px, 0) scale(").concat(n,")"),transformOrigin:"0 0",transformStyle:"preserve-3d",backfaceVisibility:"hidden"},children:[(0,r.jsxs)("svg",{className:"absolute pointer-events-none z-0",style:{left:"".concat(eA.x,"px"),top:"".concat(eA.y,"px"),width:"".concat(eA.width,"px"),height:"".concat(eA.height,"px")},viewBox:"".concat(eA.x," ").concat(eA.y," ").concat(eA.width," ").concat(eA.height),children:[(0,r.jsx)("defs",{children:(0,r.jsxs)("filter",{id:"glow",children:[(0,r.jsx)("feGaussianBlur",{stdDeviation:"3",result:"coloredBlur"}),(0,r.jsxs)("feMerge",{children:[(0,r.jsx)("feMergeNode",{in:"coloredBlur"}),(0,r.jsx)("feMergeNode",{in:"SourceGraphic"})]})]})}),eM.paths.map((e,t)=>(0,r.jsx)("path",{className:e.processing?"connection-processing":e.snapped?"connection-snapped":e.active?"connection-dragging":"",d:e.path,fill:"none",stroke:e.processing||e.snapped||e.active?void 0:"hsl(var(--muted-foreground))",strokeWidth:e.processing||e.snapped||e.active?void 0:"2.5",style:e.processing||e.snapped||e.active?{}:{opacity:.9}},t)),eM.snapPoint&&(0,r.jsx)("circle",{className:"connection-snap-ring",cx:eM.snapPoint.x,cy:eM.snapPoint.y,r:"10"})]}),(0,r.jsx)("div",{className:"relative z-10",children:(()=>{let t=new Set;for(let n of e){let e=n.input;"string"==typeof e&&t.add(e);let r=n.inputs;if(Array.isArray(r))for(let e of r)t.add(e)}return e.map(n=>{let o=t.has(n.id),a=e=>(0,r.jsx)("div",{onContextMenu:e=>((e,t)=>{var n;t.preventDefault(),t.stopPropagation();let r=null==(n=x.current)?void 0:n.getBoundingClientRect(),o=r?t.clientX-r.left:t.clientX,a=r?t.clientY-r.top:t.clientY,i=r?r.width:window.innerWidth,s=r?r.height:window.innerHeight,l=Math.max(8,Math.min(o,i-160-8)),d=Math.max(8,Math.min(a,s-88-8));eF(!1),ez({open:!0,x:l,y:d,nodeId:e})})(n.id,e),children:e},n.id);switch(n.type){case"CHARACTER":return a((0,r.jsx)(es,{node:n,scaleRef:f,outputConnected:o,onChangeImage:ep,onChangeLabel:em,onStartConnection:ek,onUpdatePosition:eh,onDelete:eg},n.id));case"MERGE":return a((0,r.jsx)(el,{node:n,scaleRef:f,allNodes:e,outputConnected:o,onRun:eR,onEndConnection:eP,onStartConnection:ek,onUpdatePosition:eh,onDelete:eg,onClearConnections:ex},n.id));case"BACKGROUND":return a((0,r.jsx)(O,{node:n,onDelete:eg,onUpdate:ef,onStartConnection:ek,onEndConnection:ew,onProcess:eC,onUpdatePosition:eh,outputConnected:o},n.id));case"CLOTHES":return a((0,r.jsx)(L,{node:n,onDelete:eg,onUpdate:ef,onStartConnection:ek,onEndConnection:ew,onProcess:eC,onUpdatePosition:eh,outputConnected:o},n.id));case"STYLE":return a((0,r.jsx)(H,{node:n,onDelete:eg,onUpdate:ef,onStartConnection:ek,onEndConnection:ew,onProcess:eC,onUpdatePosition:eh,outputConnected:o},n.id));case"EDIT":return a((0,r.jsx)(Y,{node:n,onDelete:eg,onUpdate:ef,onStartConnection:ek,onEndConnection:ew,onProcess:eC,onUpdatePosition:eh,outputConnected:o},n.id));case"CAMERA":return a((0,r.jsx)(F,{node:n,onDelete:eg,onUpdate:ef,onStartConnection:ek,onEndConnection:ew,onProcess:eC,onUpdatePosition:eh,outputConnected:o},n.id));case"AGE":return a((0,r.jsx)(G,{node:n,onDelete:eg,onUpdate:ef,onStartConnection:ek,onEndConnection:ew,onProcess:eC,onUpdatePosition:eh,outputConnected:o},n.id));case"FACE":return a((0,r.jsx)(B,{node:n,onDelete:eg,onUpdate:ef,onStartConnection:ek,onEndConnection:ew,onProcess:eC,onUpdatePosition:eh,outputConnected:o},n.id));case"LIGHTNING":return a((0,r.jsx)(U,{node:n,onDelete:eg,onUpdate:ef,onStartConnection:ek,onEndConnection:ew,onProcess:eC,onUpdatePosition:eh,outputConnected:o},n.id));case"POSES":return a((0,r.jsx)(_,{node:n,onDelete:eg,onUpdate:ef,onStartConnection:ek,onEndConnection:ew,onProcess:eC,onUpdatePosition:eh,outputConnected:o},n.id));case"ANGLE":return a((0,r.jsx)(Z,{node:n,onDelete:eg,onUpdate:ef,onStartConnection:ek,onEndConnection:ew,onProcess:eC,onUpdatePosition:eh,outputConnected:o},n.id));default:return null}})})()})]}),eY.open&&eY.nodeId&&(0,r.jsxs)("div",{className:"nb-overlay absolute z-50 rounded-xl border border-border bg-popover/95 backdrop-blur p-1
1w-40 shadow-2xl text-popover-foreground",style:{left:eY.x,top:eY.y},onMouseLeave:eX,children:[(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>{var e;eY.nodeId&&(e=eY.nodeId,t(t=>{let n=t.find(t=>t.id===e);return n?[...t,{...n,id:J(),x:n.x+40,y:n.y+40,input:void 0,inputs:"MERGE"===n.type?[]:n.inputs,output:void 0,isRunning:!1,startTime:void 0,executionTime:void 0,error:null}]:t})),eX()},children:"Duplicate"}),(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm text-destructive hover:bg-destructive/15 rounded-lg transition-colors",onClick:()=>{let e=eY.nodeId;eX(),e&&eg(e)},children:"Delete"})]}),eG&&(0,r.jsxs)("div",{className:"nb-overlay absolute z-50 rounded-xl border border-border bg-popover/95 backdrop-blur p-1 w-56 shadow-2xl text-popover-foreground",style:{left:eB.x,top:eB.y},onMouseLeave:()=>eF(!1),children:[(0,r.jsx)("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Add node"}),(0,r.jsxs)("div",{className:"max-h-[300px] overflow-y-auto scrollbar-thin pr-1",onWheel:e=>e.stopPropagation(),children:[(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>eW("CHARACTER"),children:"CHARACTER"}),(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>eW("MERGE"),children:"MERGE"}),(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>eW("BACKGROUND"),children:"BACKGROUND"}),(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>eW("CLOTHES"),children:"CLOTHES"}),(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>eW("STYLE"),children:"STYLE"}),(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>eW("EDIT"),children:"EDIT"}),(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>eW("CAMERA"),children:"CAMERA"}),(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>eW("ANGLE"),children:"ANGLE"}),(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>eW("AGE"),children:"AGE"}),(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>eW("FACE"),children:"FACE"}),(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>eW("LIGHTNING"),children:"LIGHTNING"}),(0,r.jsx)("button",{className:"w-full text-left px-3 py-2 text-sm hover:bg-accent hover:text-accent-foreground rounded-lg transition-colors",onClick:()=>eW("POSES"),children:"POSES"})]})]})]})]})}},5016:(e,t,n)=>{"use strict";n.d(t,{cn:()=>a});var r=n(2821),o=n(5889);function a(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,o.QP)((0,r.$)(t))}},7003:(e,t,n)=>{"use strict";n.d(t,{$:()=>l});var r=n(5155),o=n(2115),a=n(3101),i=n(5016);let s=(0,a.F)("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 px-3",lg:"h-10 px-6",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),l=o.forwardRef((e,t)=>
1{let{className:n,variant:o,size:a,...l}=e;return(0,r.jsx)("button",{className:(0,i.cn)(s({variant:o,size:a}),n),ref:t,...l})});l.displayName="Button"},8661:(e,t,n)=>{Promise.resolve().then(n.bind(n,2417))}},e=>{e.O(0,[10,367,831,999,930,441,255,358],()=>e(e.s=8661)),_N_E=e.O()}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.