1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,43940,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"BailoutToCSR",{enumerable:!0,get:function(){return i}});let r=e.r(41192);function i({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new r.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},65533,(e,t,a)=>{"use strict";function r(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"encodeURIPath",{enumerable:!0,get:function(){return r}})},14215,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"PreloadChunks",{enumerable:!0,get:function(){return l}});let r=e.r(53286),i=e.r(23273),n=e.r(65136),s=e.r(65533),o=e.r(31336);function l({moduleIds:e}){if("u">typeof window)return null;let t=n.workAsyncStorage.getStore();if(void 0===t)return null;let a=[];if(t.reactLoadableManifest&&e){let r=t.reactLoadableManifest;for(let t of e){if(!r[t])continue;let e=r[t].files;a.push(...e)}}if(0===a.length)return null;let d=(0,o.getAssetTokenQuery)();return(0,r.jsx)(r.Fragment,{children:a.map(e=>{let a=`${t.assetPrefix}/_next/${(0,s.encodeURIPath)(e)}${d}`;return e.endsWith(".css")?(0,r.jsx)("link",{precedence:"dynamic",href:a,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,i.preload)(a,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},83163,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"default",{enumerable:!0,get:function(){return d}});let r=e.r(53286),i=e.r(94189),n=e.r(43940),s=e.r(14215);function o(e){return{default:e&&"default"in e?e.default:e}}let l={loader:()=>Promise.resolve(o(()=>null)),loading:null,ssr:!0},d=function(e){let t={...l,...e},a=(0,i.lazy)(()=>t.loader().then(o)),d=t.loading;function c(e){let o=d?(0,r.jsx)(d,{isLoading:!0,pastDelay:!0,error:null}):null,l=!t.ssr||!!t.loading,c=l?i.Suspense:i.Fragment,p=t.ssr?(0,r.jsxs)(r.Fragment,{children:["u"<typeof window?(0,r.jsx)(s.PreloadChunks,{moduleIds:t.modules}):null,(0,r.jsx)(a,{...e})]}):(0,r.jsx)(n.BailoutToCSR,{reason:"next/dynamic",children:(0,r.jsx)(a,{...e})});return(0,r.jsx)(c,{...l?{fallback:o}:{},children:p})}return c.displayName="LoadableComponent",c}},33421,(e,t,a)=>{"use strict";Object.defineProperty(a,"__esModule",{value:!0}),Object.defineProperty(a,"default",{enumerable:!0,get:function(){return i}});let r=e.r(81258)._(e.r(83163));function i(e,t){let a={};"function"==typeof e&&(a.loader=e);let i={...a,...t};return(0,r.default)({...i,modules:i.loadableGenerated?.modules})}("function"==typeof a.default||"object"==typeof a.default&&null!==a.default)&&void 0===a.default.__esModule&&(Object.defineProperty(a.default,"__esModule",{value:!0}),Object.assign(a.default,a),t.exports=a.default)},35305,(e,t,a)=>{"use strict";t.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},61227,(e,t,a)=>{"use strict";var r=e.r(35305);function i(){}function n(){}n.resetWarningCache=i,t.exports=function(){function e(e,t,a,i,n,s){if(s!==r){var o=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw o.name="Invariant Violation",o}}function t(){return e}e.isRequired=e;var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:n,resetWarningCache:i}
1;return a.PropTypes=a,a}},4153,(e,t,a)=>{t.exports=e.r(61227)()},75592,(e,t,a)=>{"use strict";a.__esModule=!0,a.default=function(e,t){if(e&&t){var a=Array.isArray(t)?t:t.split(",");if(0===a.length)return!0;var r=e.name||"",i=(e.type||"").toLowerCase(),n=i.replace(/\/.*$/,"");return a.some(function(e){var t=e.trim().toLowerCase();return"."===t.charAt(0)?r.toLowerCase().endsWith(t):t.endsWith("/*")?n===t.replace(/\/.*$/,""):i===t})}return!0}},6855,e=>{"use strict";var t=e.i(53286),a=e.i(94189),r=e.i(8310),i=e.i(37833),n=e.i(82026);let s=(0,n.default)("calculator",[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["line",{x1:"8",x2:"16",y1:"6",y2:"6",key:"x4nwl0"}],["line",{x1:"16",x2:"16",y1:"14",y2:"18",key:"wjye3r"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M8 14h.01",key:"6423bh"}],["path",{d:"M12 18h.01",key:"mhygvu"}],["path",{d:"M8 18h.01",key:"lrp35t"}]]),o=(0,n.default)("map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]),l=(0,n.default)("menu",[["path",{d:"M4 5h16",key:"1tepv9"}],["path",{d:"M4 12h16",key:"1lakjw"}],["path",{d:"M4 19h16",key:"1djgab"}]]),d=(0,n.default)("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]),c=(0,n.default)("layout-grid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);var p=e.i(22349);let u=(0,n.default)("crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]),m=(0,n.default)("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);var x=e.i(47957),f=e.i(90513),h=e.i(26747),g=e.i(75157),b=e.i(30747),v=e.i(61143),y=e.i(21364);let _=(0,n.default)("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]),j=(0,n.default)("lock-keyhole",[["circle",{cx:"12",cy:"16",r:"1",key:"1au0dj"}],["rect",{x:"3",y:"10",width:"18",height:"12",rx:"2",key:"6s8ecr"}],["path",{d:"M7 10V7a5 5 0 0 1 10 0v3",key:"1pqi11"}]]),w=(0,n.default)("crosshair",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"22",x2:"18",y1:"12",y2:"12",key:"l9bcsi"}],["line",{x1:"6",x2:"2",y1:"12",y2:"12",key:"13hhkx"}],["line",{x1:"12",x2:"12",y1:"6",y2:"2",key:"10w3f3"}],["line",{x1:"12",x2:"12",y1:"22",y2:"18",key:"15g9kq"}]]);var k=e.i(56198);function N({flip:e,reduced:a}){return(0,t.jsxs)(f.motion.svg,{viewBox:"0 0 8 16",width:8,height:16,"aria-hidden":"true",className:(0,g.cn)("absolute top-0",e?"right-0 -scale-x-100":"left-0"),initial:a?{opacity:1,scale:1}:{opacity:0,scale:.6},whileInView:{opacity:1,scale:1},viewport:{once:!0,margin:"-60px"},transition:a?{duration:0}:{duration:.25,delay:.9,ease:b.ease},children:[(0,t.jsx)("line",{x1:"4",y1:"1",x2:"4",y2:"15",style:{stroke:"var(--cine-ion)",strokeWidth:1,opacity:.8}}),(0,t.jsx)("line",{x1:"0.5",y1:"11.5",x2:"7.5",y2:"4.5",style:{stroke:"var(--cine-ion)",strokeWidth:1.25}})]})}function S({reduced:e}){return(0,t.jsxs)("div",{className:"relative mt-1 h-4 w-full","aria-hidden":"true",children:[(0,t.jsx)(N,{reduced:e}),(0,t.jsx)("svg",{className:"absolute inset-x-[4px] top-0 h-4 w-[calc(100%-8px)]",preserveAspectRatio:"none",children:(0,t.jsx)(f.motion.line,{x1:"0",y1:"8",x2:"100%",y2:"8",style:{stroke:"var(--line-hair)",
1strokeWidth:1},initial:e?{pathLength:1}:{pathLength:0},whileInView:{pathLength:1},viewport:{once:!0,margin:"-60px"},transition:e?{duration:0}:{duration:1,delay:.1,ease:"easeInOut"}})}),(0,t.jsx)(N,{flip:!0,reduced:e})]})}function z({step:e,kicker:a,title:r,blurb:i,className:n,action:s,line:o}){let l=(0,b.usePrefersReducedMotion)();return(0,t.jsxs)("div",{className:(0,g.cn)("flex flex-col gap-3",n),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[e&&(0,t.jsx)("span",{className:"figure-mono text-xs text-accent",children:e}),(0,t.jsx)("span",{className:"figure-mono text-[0.66rem] uppercase tracking-[0.32em] text-ion/75",children:a})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-end justify-between gap-4",children:[(0,t.jsx)("h2",{className:"font-serif text-3xl font-light leading-[1.05] tracking-tight text-foreground sm:text-4xl",children:r}),s]}),i&&(0,t.jsx)("p",{className:"max-w-2xl text-sm leading-relaxed text-muted-foreground",children:i}),o?(0,t.jsx)(S,{reduced:l}):(0,t.jsx)("div",{className:"hairline mt-1"})]})}var $=e.i(69042),C=e.i(50145),M=e.i(11428);let E=(0,n.default)("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]),D=(0,n.default)("columns-2",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M12 3v18",key:"108xh3"}]]);var P=e.i(42525),O=e.i(29233),L=e.i(37099);let A=(0,n.default)("chevron-left",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);var R=e.i(94588);let T=(0,n.default)("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);var F=e.i(25957);let q=(0,n.default)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);function I({before:e,after:r,beforeLabel:i="Before",afterLabel:n="After",className:s}){let[o,l]=a.useState(50);return(0,t.jsx)("div",{className:(0,g.cn)("w-full",s),children:(0,t.jsxs)("div",{className:"relative aspect-[16/10] w-full select-none overflow-hidden rounded-lg border border-border bg-muted",children:[(0,t.jsx)("img",{src:e,alt:i,className:"absolute inset-0 h-full w-full object-contain",draggable:!1}),(0,t.jsx)("span",{className:"absolute left-3 top-3 z-10 inline-flex items-center rounded-md border border-border bg-card/85 px-2.5 py-1 text-[0.6rem] font-medium uppercase tracking-wide text-foreground backdrop-blur-sm",children:i}),(0,t.jsxs)("div",{className:"absolute inset-0",style:{clipPath:`inset(0 0 0 ${o}%)`},children:[(0,t.jsx)("img",{src:r,alt:n,className:"absolute inset-0 h-full w-full object-contain",draggable:!1}),(0,t.jsx)("span",{className:"absolute right-3 top-3 inline-flex items-center rounded-md border border-accent/40 bg-black/45 px-2.5 py-1 text-[0.6rem] font-medium uppercase tracking-wide text-white backdrop-blur-sm",children:n})]}),(0,t.jsx)("div",{className:"pointer-events-none absolute inset-y-0 z-20 w-px bg-accent",style:{left:`${o}%`},children:(0,t.jsx)("span",{className:"absolute left-1/2 top-1/2 flex size-8 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border border-accent bg-card shadow-sm",children:(0,t.jsx)("span",{className:"text-[0.6rem] font-semibold text-accent",children:"â"})})}),(0,t.jsx)("input",{type:"range",min:0,max:100,value:o,onChange:e=>l(Number(e.target.value)),"aria-label":"Reveal edited render",className:"absolute inset-0 z-30 h-full w-full cursor-ew-resize opacity-0"})]})})}async function U(e){let t=new FormData;t.append("file",e);let a=await fetch("/api/upload",{method:"POST",body:t}),r=await a.json();if(!a.ok||"done"!==r.status)throw Error(r.error||`Upload failed (${a.status}).`);return r}async function W(e){let t=await fetch("/api/edit/run",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok||"done"!==a.status)throw Error(a.error||`Generate failed (${t.status}).`);return a}
1async function B(e){let t=async()=>{let t=await fetch("/api/render/edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}),a=await t.json();if(!t.ok||"done"!==a.status)throw Error(a.error||`Render failed (${t.status}).`);return a};try{return await t()}catch(e){await new Promise(e=>setTimeout(e,1200));try{return await t()}catch{throw e instanceof Error?e:Error("Render failed.")}}}function G(e){return e.map((e,t)=>{let a=e.instruction.trim();return{id:e.id||`m${t+1}`,color:e.color,label:a.length>48?`${a.slice(0,45)}â¦`:a,text:a,bbox:function(e){if("box"===e.tool)return[Math.max(0,Math.min(e.start.x,e.end.x)/100),Math.max(0,Math.min(e.start.y,e.end.y)/100),Math.abs(e.end.x-e.start.x)/100,Math.abs(e.end.y-e.start.y)/100];if("brush"===e.tool){let t=e.points.length?e.points:[{x:50,y:50}],a=t.map(e=>e.x),r=t.map(e=>e.y),i=Math.min(...a),n=Math.min(...r),s=Math.max(...a)-i,o=Math.max(...r)-n;return[Math.max(0,i/100),Math.max(0,n/100),s/100,o/100]}return[Math.max(0,e.point.x/100-.05),Math.max(0,e.point.y/100-.05),.1,.1]}(e)}})}let H="https://v3b.fal.media/files/b/0a9fe241/A7b7X6M3nnGLz0SgfC3ZS_6215-anita-st-dallas-tx-75214-High-Res-16.jpg",V="Highland Park luxury kitchen refresh with warm white cabinetry, unlacquered brass hardware, honed marble, linen roman shades, and natural oak accents.",K="Camera position and angle\nAll walls, windows, and doorways\nEvery fixture, furniture piece, and surface\nRoom layout, proportions, and materials";function X({photo:e,onSelectPhoto:r,onGenerate:n,generating:s,lastDoc:o,onAnnotate:l}){let d=(0,b.usePrefersReducedMotion)(),[c,p]=a.useState(V),[u,m]=a.useState(!1),[x,h]=a.useState(null),[v,_]=a.useState(null),[j,w]=a.useState([]),[k,N]=a.useState(null),[S,z]=a.useState(!1),[U,W]=a.useState(100),[G,Q]=a.useState(!1),[Z,ee]=a.useState({state:"idle",verdict:null}),et=e?.status==="ready"?e.remoteUrl:null;a.useEffect(()=>{_(null),h(null),z(!1),W(100),ee({state:"idle",verdict:null}),et?(w([{url:et,label:"Source",source:!0}]),N(et)):(w([]),N(null))},[et]);let ea=k??et??H,er=!et&&ea===H,ei=a.useCallback(async(e,t,a)=>{ee({state:"checking",verdict:null});try{let r=await fetch("/api/render/verify",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({before_url:e,after_url:t,instruction:a,preserve:K})}),i=await r.json();ee({state:"done",verdict:r.ok&&"done"===i.status&&i.verdict?i.verdict:null})}catch{ee({state:"done",verdict:null})}},[]),en=a.useCallback(async()=>{if(et){m(!0),h(null),z(!1),ee({state:"idle",verdict:null});try{let e=c.trim()||V,t=await B({source_image_url:et,edit_instruction:e,preserve:K});if(_(t),t.output_url){let a={url:t.output_url,label:c.trim().slice(0,28)||"Design"};w(e=>[...e,a]),N(t.output_url),t.mocked||ei(et,t.output_url,e)}}catch(e){h(e instanceof Error?e.message:"Render failed.")}finally{m(!1)}}},[et,c,ei]),es=Math.max(0,j.findIndex(e=>e.url===k)),eo=e=>{if(!j.length)return;let t=(es+e+j.length)%j.length;N(j[t].url),z(!1)},el=a.useRef(null);return(0,t.jsxs)(f.motion.div,{...(0,b.fadeUp)(d),className:"flex flex-col gap-5 lg:flex-row lg:items-start",children:[(0,t.jsxs)("aside",{className:"flex w-full shrink-0 flex-col gap-4 lg:w-[360px]",children:[(0,t.jsxs)("section",{className:"panel p-4",children:[(0,t.jsx)("p",{className:"rail-label mb-3",children:"â Source photo"}),(0,t.jsxs)("div",{className:"relative aspect-[4/3] overflow-hidden rounded-lg border border-border bg-muted/40",children:[e?(0,t.jsx)("img",{src:e.previewUrl,alt:e.name,className:"size-full object-cover"}):(0,t.jsx)("img",{src:H,alt:"Demo kitchen",className:"size-full object-cover opacity-80"}),e?.status==="uploading"&&(0,t.jsx)("span",{className:"absolute inset-0 grid place-items-center bg-background/50 text-xs text-muted-foreground",children:(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"})})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>el.current?.click(),className:"mt-3 flex w-full flex-col items-center gap-0.5 rounded-lg border border-border bg-card/60 py-3 text-sm font-medium text-foreground transition-colors hover:border-primary/50 hover:bg-card focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)(M.ImageUp,{className:"size-4 text-primary"})," Upload local photo"]}),(0,t.jsx)("span",{className:"text-[0.65rem] font-normal text-muted-foreground",children:"or drag and drop"})]}),(0,t.jsx)("input",{ref:el,type:"file",accept:"image/*",className:"hidden",onChange:e=>{var t;let a;(a=(t=e.target.files)&&(Array.from(t).find(e=>e.type.startsWith("image/"))??t[0]))&&r(a)}})]}),(0,t.jsxs)("section",{className:"panel p-4",children:[(0,t.jsx)("p",{className:"rail-label mb-3",children:"⦠Plans from this image"}),(0,t.jsxs)("div",{className:"mb-3 flex items-start gap-3 rounded-lg border border-border bg-card/40 p-3",children:[(0,t.jsx)("span",{className:"grid size-9 shrink-0 place-items-center rounded-md bg-primary/10 text-primary",children:(0,t.jsx)(i.Ruler,{className:"size-4"})}),(0,t.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:"Create an accurate floor plan from this image."})]}),(0,t.jsxs)("button",{type:"button",onClick:n,disabled:s,className:"cta-emerald flex w-full items-center justify-center gap-2 rounded-lg py-2.5 text-sm font-semibold text-white transition-transform active:scale-[0.99] disabled:opacity-60",children:[s?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(i.Ruler,{className:"size-4"}),s?"Generatingâ¦":"Generate plan"]})]}),(0,t.jsxs)("section",{className:"panel p-4",children:[(0,t.jsx)("p",{className:"rail-label mb-3",children:"â¶ Tell us what to change"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("textarea",{value:c,maxLength:500,onChange:e=>p(e.target.value),rows:5,placeholder:"Describe the look you wantâ¦",className:"w-full resize-none rounded-lg border border-border bg-card/40 p-3 text-sm leading-relaxed text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary/60"}),(0,t.jsxs)("span",{className:"pointer-events-none absolute bottom-2 right-3 text-[0.65rem] text-muted-foreground",children:[c.length," / 500"]})]}),(0,t.jsxs)("button",{type:"button",onClick:en,disabled:u||!et,className:"cta-emerald mt-3 flex w-full items-center justify-center gap-2 rounded-lg py-3 text-sm font-semibold text-white transition-transform active:scale-[0.99] disabled:opacity-60",children:[u?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(E,{className:"size-4"}),u?"Creatingâ¦":"Create Design"]}),!et&&(0,t.jsx)("p",{className:"mt-2 text-center text-[0.65rem] text-muted-foreground",children:"Upload a photo to create a design."})]}),(0,t.jsxs)("div",{className:"panel overflow-hidden",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>Q(e=>!e),className:"flex w-full items-center justify-between px-4 py-3 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",children:[(0,t.jsx)("span",{className:"rail-label",children:"â Design details"}),(0,t.jsx)(T,{className:(0,g.cn)("size-4 text-muted-foreground transition-transform",G&&"rotate-180")}
1)]}),G&&(0,t.jsxs)("div",{className:"space-y-2 border-t border-border px-4 py-3 text-xs text-muted-foreground",children:[(0,t.jsx)("p",{className:"text-foreground",children:"Geometry-preserving render"}),(0,t.jsx)("p",{children:"Keeps camera, walls, windows, fixtures, and proportions locked while restyling surfaces and lighting."}),(0,t.jsxs)("p",{className:"pt-1",children:["Engine · ",(0,t.jsx)("code",{className:"font-mono",children:"/api/render/edit"})]})]})]})]}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-4",children:[(0,t.jsxs)("div",{className:"glow-emerald relative overflow-hidden rounded-2xl border border-border bg-black/40",children:[(0,t.jsxs)("div",{className:"absolute left-1/2 top-4 z-20 flex -translate-x-1/2 items-center gap-1 rounded-xl border border-border bg-background/80 p-1.5 backdrop-blur-xl",children:[(0,t.jsx)(Y,{icon:y.PenLine,label:"Annotate changes",active:!0,onClick:l}),(0,t.jsx)(Y,{icon:i.Ruler,label:"Generate plan",onClick:n}),(0,t.jsx)(Y,{icon:D,label:"Compare",disabled:!v?.output_url||!et,onClick:()=>z(e=>!e)}),(0,t.jsx)(Y,{icon:P.Download,label:"Download",onClick:()=>{let e=document.createElement("a");e.href=ea,e.download="vizhaus-design.jpg",e.target="_blank",e.rel="noreferrer",e.click()}})]}),(0,t.jsx)("div",{className:"grid aspect-[16/10] w-full place-items-center overflow-hidden",children:S&&v?.output_url&&et?(0,t.jsx)("div",{className:"size-full p-0",children:(0,t.jsx)(I,{before:et,after:v.output_url,beforeLabel:"Original",afterLabel:"Design"})}):(0,t.jsx)("img",{src:ea,alt:"Design canvas",style:{transform:`scale(${U/100})`},className:"size-full object-cover transition-transform duration-200"})}),!S&&(0,t.jsxs)("div",{className:"absolute bottom-4 right-4 z-20 flex flex-col items-end gap-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1 rounded-lg border border-border bg-background/80 p-1 backdrop-blur",children:[(0,t.jsx)(J,{icon:A,onClick:()=>eo(-1),disabled:j.length<2}),(0,t.jsx)(J,{icon:R.ChevronRight,onClick:()=>eo(1),disabled:j.length<2})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1 rounded-lg border border-border bg-background/80 p-1 backdrop-blur",children:[(0,t.jsx)(J,{icon:L.Minus,onClick:()=>W(e=>Math.max(50,e-10))}),(0,t.jsxs)("span",{className:"w-12 text-center text-xs tabular-nums text-muted-foreground",children:[U,"%"]}),(0,t.jsx)(J,{icon:O.Plus,onClick:()=>W(e=>Math.min(200,e+10))})]})]}),u&&(0,t.jsxs)("div",{className:"absolute inset-x-0 bottom-0 z-20 flex items-center gap-3 border-t border-border bg-background/85 px-4 py-2.5 backdrop-blur",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Preparing your designâ¦"}),(0,t.jsx)("div",{className:"relative h-1 flex-1 overflow-hidden rounded-full bg-muted",children:(0,t.jsx)(f.motion.span,{className:"absolute inset-y-0 left-0 w-1/3 rounded-full bg-gradient-to-r from-primary/40 via-primary to-accent",animate:d?{}:{x:["-100%","320%"]},transition:{duration:1.4,repeat:1/0,ease:"easeInOut"}})})]}),er&&!u&&(0,t.jsx)("span",{className:"absolute left-4 top-4 z-20 rounded-full border border-border bg-background/80 px-2.5 py-1 text-[0.62rem] uppercase tracking-[0.14em] text-muted-foreground backdrop-blur",children:"Demo · 6215 Anita"})]}),x&&(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-4"})," ",x]}),v?.mocked&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Rendered in mock mode (no FAL_KEY) â the exact prompt was built but no image was generated."}),v?.output_url&&!v.mocked&&"idle"!==Z.state&&(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-2 text-xs",children:"checking"===Z.state?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-muted-foreground",children:[(0,t.jsx)($.Loader2,{className:"size-3.5 animate-spin"}),"Verifying the renderâ¦"]}):Z.verdict&&Z.verdict.ok?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:(0,g.cn)("badge-basis",Z.verdict.change_applied&&!Z.verdict.drift?"badge-verified":Z.verdict.drift?"badge-drift":"badge-typical"),children:Z.verdict.change_applied&&!Z.verdict.drift?"Verified â change applied, nothing drifted":Z.verdict.drift?"Drift detected":"Could not confirm the change"}),(0,t.jsxs)("span",{className:"figure-mono text-muted-foreground",children:[Z.verdict.confidence.toFixed(2)," · ",Z.verdict.provider]}),Z.verdict.note&&(0,t.jsx)("span",{className:"text-muted-foreground",children:Z.verdict.note})]}):(0,t.jsx)("span",{className:"badge-basis badge-typical",children:"Accepted â verifier unavailable"})}),o&&!s&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-sm text-primary",children:[(0,t.jsx)(F.Check,{className:"size-4"}),(0,t.jsxs)("span",{children:["Plan ready: ",(0,t.jsx)("strong",{className:"font-medium",children:o.name})," â open the"," ",(0,t.jsx)("span",{className:"caps text-xs",children:"Plans"})," tab."]})]}),(0,t.jsxs)("div",{className:"panel p-3",children:[(0,t.jsx)("p",{className:"rail-label mb-2 px-1",children:"Recent designs"}),0===j.length?(0,t.jsx)("p",{className:"px-1 py-4 text-center text-xs text-muted-foreground",children:"Your generated designs will appear here."}):(0,t.jsx)("div",{className:"flex gap-2 overflow-x-auto pb-1",children:j.map((e,a)=>{let r=e.url===k&&!S;return(0,t.jsxs)("button",{type:"button",onClick:()=>{N(e.url),z(!1)},className:(0,g.cn)("relative aspect-[4/3] w-28 shrink-0 overflow-hidden rounded-lg border transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",r?"border-primary ring-2 ring-primary/40":"border-border hover:border-primary/50"),title:e.label,children:[(0,t.jsx)("img",{src:e.url,alt:e.label,className:"size-full object-cover"}),e.source&&(0,t.jsx)("span",{className:"absolute left-1 top-1 grid size-4 place-items-center rounded-full bg-background/80 text-primary",children:(0,t.jsx)(q,{className:"size-2.5"})})]},`${e.url}-${a}`)})})]})]})]})}function Y({icon:e,label:a,active:r,disabled:i,onClick:n}){return(0,t.jsxs)("button",{type:"button",onClick:n,disabled:i,className:(0,g.cn)("flex items-center gap-2 rounded-lg px-3 py-2 text-xs font-medium transition-colors disabled:opacity-40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",r?"bg-primary/15 text-foreground glow-emerald":"text-muted-foreground hover:bg-card hover:text-foreground"),children:[(0,t.jsx)(e,{className:(0,g.cn)("size-4",r&&"text-primary")}),(0,t.jsx)("span",{className:"hidden sm:inline",children:a})]})}function J({icon:e,onClick:a,disabled:r}){return(0,t.jsx)("button",{type:"button",onClick:a,disabled:r,className:"grid size-7 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-card hover:text-foreground disabled:opacity-30 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",children:(0,t.jsx)(e,{className:"size-4"})})}var Q=e.i(33421),Z=e.i(65837);let ee=(0,n.default)("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);var et=e.i(21666);let ea=(0,n.default)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);var er=e.i(19455),ei=e.i(73549);let en=(0,e.i(94237).cva)("inline-flex items-center justify-center rounded-full border px-2 py-0.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",secondary:"border-transparent bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90",destructive:"border-transparent bg-destructive text-white [a&]:hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground"}},defaultVariants:{variant:"default"}});function es({className:e,variant:a,asChild:r=!1,...i}){let n=r?ei.Slot.Slot:"span";return(0,t.jsx)(n,{"data-slot":"badge",className:(0,g.cn)(en({variant:a}),e),...i})}"u">typeof window&&window.document&&window.document.createElement;var eo=globalThis?.document?a.useLayoutEffect:()=>{};a[" useEffectEvent ".trim().toString()],a[" useInsertionEffect ".trim().toString()];var el=a[" useInsertionEffect ".trim().toString()]||eo;Symbol("RADIX:SYNC_STATE");var ed=e.i(62081);e.i(23273);
1var ec=e.i(41257),ep=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"].reduce((e,r)=>{let i=(0,ec.createSlot)(`Primitive.${r}`),n=a.forwardRef((e,a)=>{let{asChild:n,...s}=e;return"u">typeof window&&(window[Symbol.for("radix-ui")]=!0),(0,t.jsx)(n?i:r,{...s,ref:a})});return n.displayName=`Primitive.${r}`,{...e,[r]:n}},{}),eu=e=>{var t;let r,i,{present:n,children:s}=e,o=function(e){var t,r;let[i,n]=a.useState(),s=a.useRef(null),o=a.useRef(e),l=a.useRef("none"),[d,c]=(t=e?"mounted":"unmounted",r={mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}},a.useReducer((e,t)=>r[e][t]??e,t));return a.useEffect(()=>{let e=ex(s.current);l.current="mounted"===d?e:"none"},[d]),eo(()=>{let t=s.current,a=o.current;if(a!==e){let r=l.current,i=ex(t);e?c("MOUNT"):"none"===i||t?.display==="none"?c("UNMOUNT"):a&&r!==i?c("ANIMATION_OUT"):c("UNMOUNT"),o.current=e}},[e,c]),eo(()=>{if(i){let e,t=i.ownerDocument.defaultView??window,a=a=>{let r=ex(s.current).includes(CSS.escape(a.animationName));if(a.target===i&&r&&(c("ANIMATION_END"),!o.current)){let a=i.style.animationFillMode;i.style.animationFillMode="forwards",e=t.setTimeout(()=>{"forwards"===i.style.animationFillMode&&(i.style.animationFillMode=a)})}},r=e=>{e.target===i&&(l.current=ex(s.current))};return i.addEventListener("animationstart",r),i.addEventListener("animationcancel",a),i.addEventListener("animationend",a),()=>{t.clearTimeout(e),i.removeEventListener("animationstart",r),i.removeEventListener("animationcancel",a),i.removeEventListener("animationend",a)}}c("ANIMATION_END")},[i,c]),{isPresent:["mounted","unmountSuspended"].includes(d),ref:a.useCallback(e=>{s.current=e?getComputedStyle(e):null,n(e)},[])}}(n),l="function"==typeof s?s({present:o.isPresent}):a.Children.only(s),d=function(...e){let t=a.useRef(e);return t.current=e,a.useCallback(e=>{let a=t.current,r=!1,i=a.map(t=>{let a=em(t,e);return r||"function"!=typeof a||(r=!0),a});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];"function"==typeof t?t():em(a[e],null)}}},[])}(o.ref,(t=l,(i=(r=Object.getOwnPropertyDescriptor(t.props,"ref")?.get)&&"isReactWarning"in r&&r.isReactWarning)?t.ref:(i=(r=Object.getOwnPropertyDescriptor(t,"ref")?.get)&&"isReactWarning"in r&&r.isReactWarning)?t.props.ref:t.props.ref||t.ref));return"function"==typeof s||o.isPresent?a.cloneElement(l,{ref:d}):null};function em(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function ex(e){return e?.animationName||"none"}eu.displayName="Presence";var ef=a[" useId ".trim().toString()]||(()=>void 0),eh=0,eg="Collapsible",[eb,ev]=function(e,r=[]){let i=[],n=()=>{let t=i.map(e=>a.createContext(e));return function(r){let i=r?.[e]||t;return a.useMemo(()=>({[`__scope${e}`]:{...r,[e]:i}}),[r,i])}};return n.scopeName=e,[function(r,n){let s=a.createContext(n);s.displayName=r+"Context";let o=i.length;i=[...i,n];let l=r=>{let{scope:i,children:n,...l}=r,d=i?.[e]?.[o]||s,c=a.useMemo(()=>l,Object.values(l));return(0,t.jsx)(d.Provider,{value:c,children:n})};return l.displayName=r+"Provider",[l,function(t,i){let l=i?.[e]?.[o]||s,d=a.useContext(l);if(d)return d;if(void 0!==n)return n;throw Error(`\`${t}\` must be used within \`${r}\``)}]},function(...e){let t=e[0];if(1===e.length)return t;let r=()=>{let r=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let i=r.reduce((t,{useScope:a,scopeName:r})=>{let i=a(e)[`__scope${r}`];return{...t,...i}},{});return a.useMemo(()=>({[`__scope${t.scopeName}`]:i}),[i])}};return r.scopeName=t.scopeName,r}(n,...r)]}(eg),[ey,e_]=eb(eg),ej=a.forwardRef((e,r)=>{let{__scopeCollapsible:i,open:n,defaultOpen:s,disabled:o,onOpenChange:l,...d}=e,[c,p]=function({prop:e,defaultProp:t,onChange:r=()=>{},caller:i}){let[n,s,o]=function({defaultProp:e,onChange:t}){let[r,i]=a.useState(e),n=a.useRef(r),s=a.useRef(t);return el(()=>{s.current=t},[t]),a.useEffect(()=>{n.current!==r&&(s.current?.(r),n.current=r)},[r,n]),[r,i,s]}({defaultProp:t,onChange:r}),l=void 0!==e,d=l?e:n;{let t=a.useRef(void 0!==e);a.useEffect(()=>{let e=t.current;if(e!==l){let t=l?"controlled":"uncontrolled";console.warn(`${i} is changing from ${e?"controlled":"uncontrolled"} to ${t}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`)}t.current=l},[l,i])}return[d,a.useCallback(t=>{if(l){let a="function"==typeof t?t(e):t;a!==e&&o.current?.(a)}else s(t)},[l,e,s,o])]}({prop:n,defaultProp:s??!1,onChange:l,caller:eg});return(0,t.jsx)(ey,{scope:i,disabled:o,contentId:function(){let[e,t]=a.useState(ef());return eo(()=>{t(e=>e??String(eh++))},[void 0]),e?`radix-${e}
1`:""}(),open:c,onOpenToggle:a.useCallback(()=>p(e=>!e),[p]),children:(0,t.jsx)(ep.div,{"data-state":e$(c),"data-disabled":o?"":void 0,...d,ref:r})})});ej.displayName=eg;var ew="CollapsibleTrigger",ek=a.forwardRef((e,a)=>{let{__scopeCollapsible:r,...i}=e,n=e_(ew,r);return(0,t.jsx)(ep.button,{type:"button","aria-controls":n.open?n.contentId:void 0,"aria-expanded":n.open||!1,"data-state":e$(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...i,ref:a,onClick:function(e,t,{checkForDefaultPrevented:a=!0}={}){return function(r){if(e?.(r),!1===a||!r.defaultPrevented)return t?.(r)}}(e.onClick,n.onOpenToggle)})});ek.displayName=ew;var eN="CollapsibleContent",eS=a.forwardRef((e,a)=>{let{forceMount:r,...i}=e,n=e_(eN,e.__scopeCollapsible);return(0,t.jsx)(eu,{present:r||n.open,children:({present:e})=>(0,t.jsx)(ez,{...i,ref:a,present:e})})});eS.displayName=eN;var ez=a.forwardRef((e,r)=>{let{__scopeCollapsible:i,present:n,children:s,...o}=e,l=e_(eN,i),[d,c]=a.useState(n),p=a.useRef(null),u=(0,ed.useComposedRefs)(r,p),m=a.useRef(0),x=m.current,f=a.useRef(0),h=f.current,g=l.open||d,b=a.useRef(g),v=a.useRef(void 0);return a.useEffect(()=>{let e=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(e)},[]),eo(()=>{let e=p.current;if(e){v.current=v.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration="0s",e.style.animationName="none";let t=e.getBoundingClientRect();m.current=t.height,f.current=t.width,b.current||(e.style.transitionDuration=v.current.transitionDuration,e.style.animationName=v.current.animationName),c(n)}},[l.open,n]),(0,t.jsx)(ep.div,{"data-state":e$(l.open),"data-disabled":l.disabled?"":void 0,id:l.contentId,hidden:!g,...o,ref:u,style:{"--radix-collapsible-content-height":x?`${x}px`:void 0,"--radix-collapsible-content-width":h?`${h}px`:void 0,...e.style},children:g&&s})});function e$(e){return e?"open":"closed"}e.s(["Collapsible",0,ej,"CollapsibleContent",0,eS,"CollapsibleTrigger",0,ek,"Content",0,eS,"Root",0,ej,"Trigger",0,ek,"createCollapsibleScope",0,ev],96049);var eC=e.i(96049),eC=eC;function eM({...e}){return(0,t.jsx)(eC.Root,{"data-slot":"collapsible",...e})}function eE({...e}){return(0,t.jsx)(eC.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function eD({...e}){return(0,t.jsx)(eC.CollapsibleContent,{"data-slot":"collapsible-content",...e})}var eP=e.i(96806);let eO=(0,n.default)("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]),eL=(0,e.i(54020).default)("outline","upload","Upload",[["path",{d:"M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2",key:"svg-0"}],["path",{d:"M7 9l5 -5l5 5",key:"svg-1"}],["path",{d:"M12 4l0 12",key:"svg-2"}]]);var eA=e.i(4153),eR=e.i(24627);let eT
vendor: 41,168 bytes, line 1
1=new Map([["1km","application/vnd.1000minds.decision-model+xml"],["3dml","text/vnd.in3d.3dml"],["3ds","image/x-3ds"],["3g2","video/3gpp2"],["3gp","video/3gp"],["3gpp","video/3gpp"],["3mf","model/3mf"],["7z","application/x-7z-compressed"],["7zip","application/x-7z-compressed"],["123","application/vnd.lotus-1-2-3"],["aab","application/x-authorware-bin"],["aac","audio/x-acc"],["aam","application/x-authorware-map"],["aas","application/x-authorware-seg"],["abw","application/x-abiword"],["ac","application/vnd.nokia.n-gage.ac+xml"],["ac3","audio/ac3"],["acc","application/vnd.americandynamics.acc"],["ace","application/x-ace-compressed"],["acu","application/vnd.acucobol"],["acutc","application/vnd.acucorp"],["adp","audio/adpcm"],["aep","application/vnd.audiograph"],["afm","application/x-font-type1"],["afp","application/vnd.ibm.modcap"],["ahead","application/vnd.ahead.space"],["ai","application/pdf"],["aif","audio/x-aiff"],["aifc","audio/x-aiff"],["aiff","audio/x-aiff"],["air","application/vnd.adobe.air-application-installer-package+zip"],["ait","application/vnd.dvb.ait"],["ami","application/vnd.amiga.ami"],["amr","audio/amr"],["apk","application/vnd.android.package-archive"],["apng","image/apng"],["appcache","text/cache-manifest"],["application","application/x-ms-application"],["apr","application/vnd.lotus-approach"],["arc","application/x-freearc"],["arj","application/x-arj"],["asc","application/pgp-signature"],["asf","video/x-ms-asf"],["asm","text/x-asm"],["aso","application/vnd.accpac.simply.aso"],["asx","video/x-ms-asf"],["atc","application/vnd.acucorp"],["atom","application/atom+xml"],["atomcat","application/atomcat+xml"],["atomdeleted","application/atomdeleted+xml"],["atomsvc","application/atomsvc+xml"],["atx","application/vnd.antix.game-component"],["au","audio/x-au"],["avi","video/x-msvideo"],["avif","image/avif"],["aw","application/applixware"],["azf","application/vnd.airzip.filesecure.azf"],["azs","application/vnd.airzip.filesecure.azs"],["azv","image/vnd.airzip.accelerator.azv"],["azw","application/vnd.amazon.ebook"],["b16","image/vnd.pco.b16"],["bat","application/x-msdownload"],["bcpio","application/x-bcpio"],["bdf","application/x-font-bdf"],["bdm","application/vnd.syncml.dm+wbxml"],["bdoc","application/x-bdoc"],["bed","application/vnd.realvnc.bed"],["bh2","application/vnd.fujitsu.oasysprs"],["bin","application/octet-stream"],["blb","application/x-blorb"],["blorb","application/x-blorb"],["bmi","application/vnd.bmi"],["bmml","application/vnd.balsamiq.bmml+xml"],["bmp","image/bmp"],["book","application/vnd.framemaker"],["box","application/vnd.previewsystems.box"],["boz","application/x-bzip2"],["bpk","application/octet-stream"],["bpmn","application/octet-stream"],["bsp","model/vnd.valve.source.compiled-map"],["btif","image/prs.btif"],["buffer","application/octet-stream"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["c","text/x-c"],["c4d","application/vnd.clonk.c4group"],["c4f","application/vnd.clonk.c4group"],["c4g","application/vnd.clonk.c4group"],["c4p","application/vnd.clonk.c4group"],["c4u","application/vnd.clonk.c4group"],["c11amc","application/vnd.cluetrust.cartomobile-config"],["c11amz","application/vnd.cluetrust.cartomobile-config-pkg"],["cab","application/vnd.ms-cab-compressed"],["caf","audio/x-caf"],["cap","application/vnd.tcpdump.pcap"],["car","application/vnd.curl.car"],["cat","application/vnd.ms-pki.seccat"],["cb7","application/x-cbr"],["cba","application/x-cbr"],["cbr","application/x-cbr"],["cbt","application/x-cbr"],["cbz","application/x-cbr"],["cc","text/x-c"],["cco","application/x-cocoa"],["cct","application/x-director"],["ccxml","application/ccxml+xml"],["cdbcmsg","application/vnd.contact.cmsg"],["cda","application/x-cdf"],["cdf","application/x-netcdf"],["cdfx","application/cdfx+xml"],["cdkey","application/vnd.mediastation.cdkey"],["cdmia","application/cdmi-capability"],["cdmic","application/cdmi-container"],["cdmid","application/cdmi-domain"],["cdmio","application/cdmi-object"],["cdmiq","application/cdmi-queue"],["cdr","application/cdr"],["cdx","chemical/x-cdx"],["cdxml","application/vnd.chemdraw+xml"],["cdy","application/vnd.cinderella"],["cer","application/pkix-cert"],["cfs","application/x-cfs-compressed"],["cgm","image/cgm"],["chat","application/x-chat"],["chm","application/vnd.ms-htmlhelp"],["chrt","application/vnd.kde.kchart"],["cif","chemical/x-cif"],["cii","application/vnd.anser-web-certificate-issue-initiation"],["cil","application/vnd.ms-artgalry"],["cjs","application/node"],["cla","application/vnd.claymore"],["class","application/octet-stream"],["clkk","application/vnd.crick.clicker.keyboard"],["clkp","application/vnd.crick.clicker.palette"],["clkt","application/vnd.crick.clicker.template"],["clkw","application/vnd.crick.clicker.wordbank"],["clkx","application/vnd.crick.clicker"],["clp","application/x-msclip"],["cmc","application/vnd.cosmocaller"],["cmdf","chemical/x-cmdf"],["cml","chemical/x-cml"],["cmp","application/vnd.yellowriver-custom-menu"],["cmx","image/x-cmx"],["cod","application/vnd.rim.cod"],["coffee","text/coffeescript"],["com","application/x-msdownload"],["conf","text/plain"],["cpio","application/x-cpio"],["cpp","text/x-c"],["cpt","application/mac-compactpro"],["crd","application/x-mscardfile"],["crl","application/pkix-crl"],["crt","application/x-x509-ca-cert"],["crx","application/x-chrome-extension"],["cryptonote","application/vnd.rig.cryptonote"],["csh","application/x-csh"],["csl","application/vnd.citationstyles.style+xml"],["csml","chemical/x-csml"],["csp","application/vnd.commonspace"],["csr","application/octet-stream"],["css","text/css"],["cst","application/x-director"],["csv","text/csv"],["cu","application/cu-seeme"],["curl","text/vnd.curl"],["cww","application/prs.cww"],["cxt","application/x-director"],["cxx","text/x-c"],["dae","model/vnd.collada+xml"],["daf","application/vnd.mobius.daf"],["dart","application/vnd.dart"],["dataless","application/vnd.fdsn.seed"],["davmount","application/davmount+xml"],["dbf","application/vnd.dbf"],["dbk","application/docbook+xml"],["dcr","application/x-director"],["dcurl","text/vnd.curl.dcurl"],["dd2","application/vnd.oma.dd2+xml"],["ddd","application/vnd.fujixerox.ddd"],["ddf","application/vnd.syncml.dmddf+xml"],["dds","image/vnd.ms-dds"],["deb","application/x-debian-package"],["def","text/plain"],["deploy","application/octet-stream"],["der","application/x-x509-ca-cert"],["dfac","application/vnd.dreamfactory"],["dgc","application/x-dgc-compressed"],["dic","text/x-c"],["dir","application/x-director"],["dis","application/vnd.mobius.dis"],["disposition-notification","message/disposition-notification"],["dist","application/octet-stream"],["distz","application/octet-stream"],["djv","image/vnd.djvu"],["djvu","image/vnd.djvu"],["dll","application/octet-stream"],["dmg","application/x-apple-diskimage"],["dmn","application/octet-stream"],["dmp","application/vnd.tcpdump.pcap"],["dms","application/octet-stream"],["dna","application/vnd.dna"],["doc","application/msword"],["docm","application/vnd.ms-word.template.macroEnabled.12"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["dot","application/msword"],["dotm","application/vnd.ms-word.template.macroEnabled.12"],["dotx","application/vnd.openxmlformats-officedocument.wordprocessingml.template"],["dp","application/vnd.osgi.dp"],["dpg","application/vnd.dpgraph"],["dra","audio/vnd.dra"],["drle","image/dicom-rle"],["dsc","text/prs.lines.tag"],["dssc","application/dssc+der"],["dtb","application/x-dtbook+xml"],["dtd","application/xml-dtd"],["dts","audio/vnd.dts"],["dtshd","audio/vnd.dts.hd"],["dump","application/octet-stream"],["dvb","video/vnd.dvb.file"],["dvi","application/x-dvi"],["dwd","application/atsc-dwd+xml"],["dwf","model/vnd.dwf"],["dwg","image/vnd.dwg"],["dxf","image/vnd.dxf"],["dxp","application/vnd.spotfire.dxp"],["dxr","application/x-director"],["ear","application/java-archive"],["ecelp4800","audio/vnd.nuera.ecelp4800"],["ecelp7470","audio/vnd.nuera.ecelp7470"],["ecelp9600","audio/vnd.nuera.ecelp9600"],["ecma","application/ecmascript"],["edm","application/vnd.novadigm.edm"],["edx","application/vnd.novadigm.edx"],["efif","application/vnd.picsel"],["ei6","application/vnd.pg.osasli"],["elc","application/octet-stream"],["emf","image/emf"],["eml","message/rfc822"],["emma","application/emma+xml"],["emotionml","application/emotionml+xml"],["emz","application/x-msmetafile"],["eol","audio/vnd.digital-winds"],["eot","application/vnd.ms-fontobject"],["eps","application/postscript"],["epub","application/epub+zip"],["es","application/ecmascript"],["es3","application/vnd.eszigno3+xml"],["esa","application/vnd.osgi.subsystem"],["esf","application/vnd.epson.esf"],["et3","application/vnd.eszigno3+xml"],["etx","text/x-setext"],["eva","application/x-eva"],["evy","application/x-envoy"],["exe","application/octet-stream"],["exi","application/exi"],["exp","application/express"],["exr","image/aces"],["ext","application/vnd.novadigm.ext"],["ez","application/andrew-inset"],["ez2","application/vnd.ezpix-album"],["ez3","application/vnd.ezpix-package"],["f","text/x-fortran"],["f4v","video/mp4"],["f77","text/x-fortran"],["f90","text/x-fortran"],["fbs","image/vnd.fastbidsheet"],["fcdt","application/vnd.adobe.formscentral.fcdt"],["fcs","application/vnd.isac.fcs"],["fdf","application/vnd.fdf"],["fdt","application/fdt+xml"],["fe_launch","application/vnd.denovo.fcselayout-link"],["fg5","application/vnd.fujitsu.oasysgp"],["fgd","application/x-director"],["fh","image/x-freehand"],["fh4","image/x-freehand"],["fh5","image/x-freehand"],["fh7","image/x-freehand"],["fhc","image/x-freehand"],["fig","application/x-xfig"],["fits","image/fits"],["flac","audio/x-flac"],["fli","video/x-fli"],["flo","application/vnd.micrografx.flo"],["flv","video/x-flv"],["flw","application/vnd.kde.kivio"],["flx","text/vnd.fmi.flexstor"],["fly","text/vnd.fly"],["fm","application/vnd.framemaker"],["fnc","application/vnd.frogans.fnc"],["fo","application/vnd.software602.filler.form+xml"],["for","text/x-fortran"],["fpx","image/vnd.fpx"],["frame","application/vnd.framemaker"],["fsc","application/vnd.fsc.weblaunch"],["fst","image/vnd.fst"],["ftc","application/vnd.fluxtime.clip"],["fti","application/vnd.anser-web-funds-transfer-initiation"],["fvt","video/vnd.fvt"],["fxp","application/vnd.adobe.fxp"],["fxpl","application/vnd.adobe.fxp"],["fzs","application/vnd.fuzzysheet"],["g2w","application/vnd.geoplan"],["g3","image/g3fax"],["g3w","application/vnd.geospace"],["gac","application/vnd.groove-account"],["gam","application/x-tads"],["gbr","application/rpki-ghostbusters"],["gca","application/x-gca-compressed"],["gdl","model/vnd.gdl"],["gdoc","application/vnd.google-apps.document"],["geo","application/vnd.dynageo"],["geojson","application/geo+json"],["gex","application/vnd.geometry-explorer"],["ggb","application/vnd.geogebra.file"],["ggt","application/vnd.geogebra.tool"],["ghf","application/vnd.groove-help"],["gif","image/gif"],["gim","application/vnd.groove-identity-message"],["glb","model/gltf-binary"],["gltf","model/gltf+json"],["gml","application/gml+xml"],["gmx","application/vnd.gmx"],["gnumeric","application/x-gnumeric"],["gpg","application/gpg-keys"],["gph","application/vnd.flographit"],["gpx","application/gpx+xml"],["gqf","application/vnd.grafeq"],["gqs","application/vnd.grafeq"],["gram","application/srgs"],["gramps","application/x-gramps-xml"],["gre","application/vnd.geometry-explorer"],["grv","application/vnd.groove-injector"],["grxml","application/srgs+xml"],["gsf","application/x-font-ghostscript"],["gsheet","application/vnd.google-apps.spreadsheet"],["gslides","application/vnd.google-apps.presentation"],["gtar","application/x-gtar"],["gtm","application/vnd.groove-tool-message"],["gtw","model/vnd.gtw"],["gv","text/vnd.graphviz"],["gxf","application/gxf"],["gxt","application/vnd.geonext"],["gz","application/gzip"],["gzip","application/gzip"],["h","text/x-c"],["h261","video/h261"],["h263","video/h263"],["h264","video/h264"],["hal","application/vnd.hal+xml"],["hbci","application/vnd.hbci"],["hbs","text/x-handlebars-template"],["hdd","application/x-virtualbox-hdd"],["hdf","application/x-hdf"],["heic","image/heic"],["heics","image/heic-sequence"],["heif","image/heif"],["heifs","image/heif-sequence"],["hej2","image/hej2k"],["held","application/atsc-held+xml"],["hh","text/x-c"],["hjson","application/hjson"],["hlp","application/winhlp"],["hpgl","application/vnd.hp-hpgl"],["hpid","application/vnd.hp-hpid"],["hps","application/vnd.hp-hps"],["hqx","application/mac-binhex40"],["hsj2","image/hsj2"],["htc","text/x-component"],["htke","application/vnd.kenameaapp"],["htm","text/html"],["html","text/html"],["hvd","application/vnd.yamaha.hv-dic"],["hvp","application/vnd.yamaha.hv-voice"],["hvs","application/vnd.yamaha.hv-script"],["i2g","application/vnd.intergeo"],["icc","application/vnd.iccprofile"],["ice","x-conference/x-cooltalk"],["icm","application/vnd.iccprofile"],["ico","image/x-icon"],["ics","text/calendar"],["ief","image/ief"],["ifb","text/calendar"],["ifm","application/vnd.shana.informed.formdata"],["iges","model/iges"],["igl","application/vnd.igloader"],["igm","application/vnd.insors.igm"],["igs","model/iges"],["igx","application/vnd.micrografx.igx"],["iif","application/vnd.shana.informed.interchange"],["img","application/octet-stream"],["imp","application/vnd.accpac.simply.imp"],["ims","application/vnd.ms-ims"],["in","text/plain"],["ini","text/plain"],["ink","application/inkml+xml"],["inkml","application/inkml+xml"],["install","application/x-install-instructions"],["iota","application/vnd.astraea-software.iota"],["ipfix","application/ipfix"],["ipk","application/vnd.shana.informed.package"],["irm","application/vnd.ibm.rights-management"],["irp","application/vnd.irepository.package+xml"],["iso","application/x-iso9660-image"],["itp","application/vnd.shana.informed.formtemplate"],["its","application/its+xml"],["ivp","application/vnd.immervision-ivp"],["ivu","application/vnd.immervision-ivu"],["jad","text/vnd.sun.j2me.app-descriptor"],["jade","text/jade"],["jam","application/vnd.jam"],["jar","application/java-archive"],["jardiff","application/x-java-archive-diff"],["java","text/x-java-source"],["jhc","image/jphc"],["jisp","application/vnd.jisp"],["jls","image/jls"],["jlt","application/vnd.hp-jlyt"],["jng","image/x-jng"],["jnlp","application/x-java-jnlp-file"],["joda","application/vnd.joost.joda-archive"],["jp2","image/jp2"],["jpe","image/jpeg"],["jpeg","image/jpeg"],["jpf","image/jpx"],["jpg","image/jpeg"],["jpg2","image/jp2"],["jpgm","video/jpm"],["jpgv","video/jpeg"],["jph","image/jph"],["jpm","video/jpm"],["jpx","image/jpx"],["js","application/javascript"],["json","application/json"],["json5","application/json5"],["jsonld","application/ld+json"],["jsonl","application/jsonl"],["jsonml","application/jsonml+json"],["jsx","text/jsx"],["jxr","image/jxr"],["jxra","image/jxra"],["jxrs","image/jxrs"],["jxs","image/jxs"],["jxsc","image/jxsc"],["jxsi","image/jxsi"],["jxss","image/jxss"],["kar","audio/midi"],["karbon","application/vnd.kde.karbon"],["kdb","application/octet-stream"],["kdbx","application/x-keepass2"],["key","application/x-iwork-keynote-sffkey"],["kfo","application/vnd.kde.kformula"],["kia","application/vnd.kidspiration"],["kml","application/vnd.google-earth.kml+xml"],["kmz","application/vnd.google-earth.kmz"],["kne","application/vnd.kinar"],["knp","application/vnd.kinar"],["kon","application/vnd.kde.kontour"],["kpr","application/vnd.kde.kpresenter"],["kpt","application/vnd.kde.kpresenter"],["kpxx","application/vnd.ds-keypoint"],["ksp","application/vnd.kde.kspread"],["ktr","application/vnd.kahootz"],["ktx","image/ktx"],["ktx2","image/ktx2"],["ktz","application/vnd.kahootz"],["kwd","application/vnd.kde.kword"],["kwt","application/vnd.kde.kword"],["lasxml","application/vnd.las.las+xml"],["latex","application/x-latex"],["lbd","application/vnd.llamagraphics.life-balance.desktop"],["lbe","application/vnd.llamagraphics.life-balance.exchange+xml"],["les","application/vnd.hhe.lesson-player"],["less","text/less"],["lgr","application/lgr+xml"],["lha","application/octet-stream"],["link66","application/vnd.route66.link66+xml"],["list","text/plain"],["list3820","application/vnd.ibm.modcap"],["listafp","application/vnd.ibm.modcap"],["litcoffee","text/coffeescript"],["lnk","application/x-ms-shortcut"],["log","text/plain"],["lostxml","application/lost+xml"],["lrf","application/octet-stream"],["lrm","application/vnd.ms-lrm"],["ltf","application/vnd.frogans.ltf"],["lua","text/x-lua"],["luac","application/x-lua-bytecode"],["lvp","audio/vnd.lucent.voice"],["lwp","application/vnd.lotus-wordpro"],["lzh","application/octet-stream"],["m1v","video/mpeg"],["m2a","audio/mpeg"],["m2v","video/mpeg"],["m3a","audio/mpeg"],["m3u","text/plain"],["m3u8","application/vnd.apple.mpegurl"],["m4a","audio/x-m4a"],["m4p","application/mp4"],["m4s","video/iso.segment"],["m4u","application/vnd.mpegurl"],["m4v","video/x-m4v"],["m13","application/x-msmediaview"],["m14","application/x-msmediaview"],["m21","application/mp21"],["ma","application/mathematica"],["mads","application/mads+xml"],["maei","application/mmt-aei+xml"],["mag","application/vnd.ecowin.chart"],["maker","application/vnd.framemaker"],["man","text/troff"],["manifest","text/cache-manifest"],["map","application/json"],["mar","application/octet-stream"],["markdown","text/markdown"],["mathml","application/mathml+xml"],["mb","application/mathematica"],["mbk","application/vnd.mobius.mbk"],["mbox","application/mbox"],["mc1","application/vnd.medcalcdata"],["mcd","application/vnd.mcd"],["mcurl","text/vnd.curl.mcurl"],["md","text/markdown"],["mdb","application/x-msaccess"],["mdi","image/vnd.ms-modi"],["mdx","text/mdx"],["me","text/troff"],["mesh","model/mesh"],["meta4","application/metalink4+xml"],["metalink","application/metalink+xml"],["mets","application/mets+xml"],["mfm","application/vnd.mfmp"],["mft","application/rpki-manifest"],["mgp","application/vnd.osgeo.mapguide.package"],["mgz","application/vnd.proteus.magazine"],["mid","audio/midi"],["midi","audio/midi"],["mie","application/x-mie"],["mif","application/vnd.mif"],["mime","message/rfc822"],["mj2","video/mj2"],["mjp2","video/mj2"],["mjs","application/javascript"],["mk3d","video/x-matroska"],["mka","audio/x-matroska"],["mkd","text/x-markdown"],["mks","video/x-matroska"],["mkv","video/x-matroska"],["mlp","application/vnd.dolby.mlp"],["mmd","application/vnd.chipnuts.karaoke-mmd"],["mmf","application/vnd.smaf"],["mml","text/mathml"],["mmr","image/vnd.fujixerox.edmics-mmr"],["mng","video/x-mng"],["mny","application/x-msmoney"],["mobi","application/x-mobipocket-ebook"],["mods","application/mods+xml"],["mov","video/quicktime"],["movie","video/x-sgi-movie"],["mp2","audio/mpeg"],["mp2a","audio/mpeg"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mp4a","audio/mp4"],["mp4s","application/mp4"],["mp4v","video/mp4"],["mp21","application/mp21"],["mpc","application/vnd.mophun.certificate"],["mpd","application/dash+xml"],["mpe","video/mpeg"],["mpeg","video/mpeg"],["mpg","video/mpeg"],["mpg4","video/mp4"],["mpga","audio/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["mpm","application/vnd.blueice.multipass"],["mpn","application/vnd.mophun.application"],["mpp","application/vnd.ms-project"],["mpt","application/vnd.ms-project"],["mpy","application/vnd.ibm.minipay"],["mqy","application/vnd.mobius.mqy"],["mrc","application/marc"],["mrcx","application/marcxml+xml"],["ms","text/troff"],["mscml","application/mediaservercontrol+xml"],["mseed","application/vnd.fdsn.mseed"],["mseq","application/vnd.mseq"],["msf","application/vnd.epson.msf"],["msg","application/vnd.ms-outlook"],["msh","model/mesh"],["msi","application/x-msdownload"],["msl","application/vnd.mobius.msl"],["msm","application/octet-stream"],["msp","application/octet-stream"],["msty","application/vnd.muvee.style"],["mtl","model/mtl"],["mts","model/vnd.mts"],["mus","application/vnd.musician"],["musd","application/mmt-usd+xml"],["musicxml","application/vnd.recordare.musicxml+xml"],["mvb","application/x-msmediaview"],["mvt","application/vnd.mapbox-vector-tile"],["mwf","application/vnd.mfer"],["mxf","application/mxf"],["mxl","application/vnd.recordare.musicxml"],["mxmf","audio/mobile-xmf"],["mxml","application/xv+xml"],["mxs","application/vnd.triscape.mxs"],["mxu","video/vnd.mpegurl"],["n-gage","application/vnd.nokia.n-gage.symbian.install"],["n3","text/n3"],["nb","application/mathematica"],["nbp","application/vnd.wolfram.player"],["nc","application/x-netcdf"],["ncx","application/x-dtbncx+xml"],["nfo","text/x-nfo"],["ngdat","application/vnd.nokia.n-gage.data"],["nitf","application/vnd.nitf"],["nlu","application/vnd.neurolanguage.nlu"],["nml","application/vnd.enliven"],["nnd","application/vnd.noblenet-directory"],["nns","application/vnd.noblenet-sealer"],["nnw","application/vnd.noblenet-web"],["npx","image/vnd.net-fpx"],["nq","application/n-quads"],["nsc","application/x-conference"],["nsf","application/vnd.lotus-notes"],["nt","application/n-triples"],["ntf","application/vnd.nitf"],["numbers","application/x-iwork-numbers-sffnumbers"],["nzb","application/x-nzb"],["oa2","application/vnd.fujitsu.oasys2"],["oa3","application/vnd.fujitsu.oasys3"],["oas","application/vnd.fujitsu.oasys"],["obd","application/x-msbinder"],["obgx","application/vnd.openblox.game+xml"],["obj","model/obj"],["oda","application/oda"],["odb","application/vnd.oasis.opendocument.database"],["odc","application/vnd.oasis.opendocument.chart"],["odf","application/vnd.oasis.opendocument.formula"],["odft","application/vnd.oasis.opendocument.formula-template"],["odg","application/vnd.oasis.opendocument.graphics"],["odi","application/vnd.oasis.opendocument.image"],["odm","application/vnd.oasis.opendocument.text-master"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogex","model/vnd.opengex"],["ogg","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["omdoc","application/omdoc+xml"],["onepkg","application/onenote"],["onetmp","application/onenote"],["onetoc","application/onenote"],["onetoc2","application/onenote"],["opf","application/oebps-package+xml"],["opml","text/x-opml"],["oprc","application/vnd.palm"],["opus","audio/ogg"],["org","text/x-org"],["osf","application/vnd.yamaha.openscoreformat"],["osfpvg","application/vnd.yamaha.openscoreformat.osfpvg+xml"],["osm","application/vnd.openstreetmap.data+xml"],["otc","application/vnd.oasis.opendocument.chart-template"],["otf","font/otf"],["otg","application/vnd.oasis.opendocument.graphics-template"],["oth","application/vnd.oasis.opendocument.text-web"],["oti","application/vnd.oasis.opendocument.image-template"],["otp","application/vnd.oasis.opendocument.presentation-template"],["ots","application/vnd.oasis.opendocument.spreadsheet-template"],["ott","application/vnd.oasis.opendocument.text-template"],["ova","application/x-virtualbox-ova"],["ovf","application/x-virtualbox-ovf"],["owl","application/rdf+xml"],["oxps","application/oxps"],["oxt","application/vnd.openofficeorg.extension"],["p","text/x-pascal"],["p7a","application/x-pkcs7-signature"],["p7b","application/x-pkcs7-certificates"],["p7c","application/pkcs7-mime"],["p7m","application/pkcs7-mime"],["p7r","application/x-pkcs7-certreqresp"],["p7s","application/pkcs7-signature"],["p8","application/pkcs8"],["p10","application/x-pkcs10"],["p12","application/x-pkcs12"],["pac","application/x-ns-proxy-autoconfig"],["pages","application/x-iwork-pages-sffpages"],["pas","text/x-pascal"],["paw","application/vnd.pawaafile"],["pbd","application/vnd.powerbuilder6"],["pbm","image/x-portable-bitmap"],["pcap","application/vnd.tcpdump.pcap"],["pcf","application/x-font-pcf"],["pcl","application/vnd.hp-pcl"],["pclxl","application/vnd.hp-pclxl"],["pct","image/x-pict"],["pcurl","application/vnd.curl.pcurl"],["pcx","image/x-pcx"],["pdb","application/x-pilot"],["pde","text/x-processing"],["pdf","application/pdf"],["pem","application/x-x509-user-cert"],["pfa","application/x-font-type1"],["pfb","application/x-font-type1"],["pfm","application/x-font-type1"],["pfr","application/font-tdpfr"],["pfx","application/x-pkcs12"],["pgm","image/x-portable-graymap"],["pgn","application/x-chess-pgn"],["pgp","application/pgp"],["php","application/x-httpd-php"],["php3","application/x-httpd-php"],["php4","application/x-httpd-php"],["phps","application/x-httpd-php-source"],["phtml","application/x-httpd-php"],["pic","image/x-pict"],["pkg","application/octet-stream"],["pki","application/pkixcmp"],["pkipath","application/pkix-pkipath"],["pkpass","application/vnd.apple.pkpass"],["pl","application/x-perl"],["plb","application/vnd.3gpp.pic-bw-large"],["plc","application/vnd.mobius.plc"],["plf","application/vnd.pocketlearn"],["pls","application/pls+xml"],["pm","application/x-perl"],["pml","application/vnd.ctc-posml"],["png","image/png"],["pnm","image/x-portable-anymap"],["portpkg","application/vnd.macports.portpkg"],["pot","application/vnd.ms-powerpoint"],["potm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["potx","application/vnd.openxmlformats-officedocument.presentationml.template"],["ppa","application/vnd.ms-powerpoint"],["ppam","application/vnd.ms-powerpoint.addin.macroEnabled.12"],["ppd","application/vnd.cups-ppd"],["ppm","image/x-portable-pixmap"],["pps","application/vnd.ms-powerpoint"],["ppsm","application/vnd.ms-powerpoint.slideshow.macroEnabled.12"],["ppsx","application/vnd.openxmlformats-officedocument.presentationml.slideshow"],["ppt","application/powerpoint"],["pptm","application/vnd.ms-powerpoint.presentation.macroEnabled.12"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["pqa","application/vnd.palm"],["prc","application/x-pilot"],["pre","application/vnd.lotus-freelance"],["prf","application/pics-rules"],["provx","application/provenance+xml"],["ps","application/postscript"],["psb","application/vnd.3gpp.pic-bw-small"],["psd","application/x-photoshop"],["psf","application/x-font-linux-psf"],["pskcxml","application/pskc+xml"],["pti","image/prs.pti"],["ptid","application/vnd.pvi.ptid1"],["pub","application/x-mspublisher"],["pvb","application/vnd.3gpp.pic-bw-var"],["pwn","application/vnd.3m.post-it-notes"],["pya","audio/vnd.ms-playready.media.pya"],["pyv","video/vnd.ms-playready.media.pyv"],["qam","application/vnd.epson.quickanime"],["qbo","application/vnd.intu.qbo"],["qfx","application/vnd.intu.qfx"],["qps","application/vnd.publishare-delta-tree"],["qt","video/quicktime"],["qwd","application/vnd.quark.quarkxpress"],["qwt","application/vnd.quark.quarkxpress"],["qxb","application/vnd.quark.quarkxpress"],["qxd","application/vnd.quark.quarkxpress"],["qxl","application/vnd.quark.quarkxpress"],["qxt","application/vnd.quark.quarkxpress"],["ra","audio/x-realaudio"],["ram","audio/x-pn-realaudio"],["raml","application/raml+yaml"],["rapd","application/route-apd+xml"],["rar","application/x-rar"],["ras","image/x-cmu-raster"],["rcprofile","application/vnd.ipunplugged.rcprofile"],["rdf","application/rdf+xml"],["rdz","application/vnd.data-vision.rdz"],["relo","application/p2p-overlay+xml"],["rep","application/vnd.businessobjects"],["res","application/x-dtbresource+xml"],["rgb","image/x-rgb"],["rif","application/reginfo+xml"],["rip","audio/vnd.rip"],["ris","application/x-research-info-systems"],["rl","application/resource-lists+xml"],["rlc","image/vnd.fujixerox.edmics-rlc"],["rld","application/resource-lists-diff+xml"],["rm","audio/x-pn-realaudio"],["rmi","audio/midi"],["rmp","audio/x-pn-realaudio-plugin"],["rms","application/vnd.jcp.javame.midlet-rms"],["rmvb","application/vnd.rn-realmedia-vbr"],["rnc","application/relax-ng-compact-syntax"],["rng","application/xml"],["roa","application/rpki-roa"],["roff","text/troff"],["rp9","application/vnd.cloanto.rp9"],["rpm","audio/x-pn-realaudio-plugin"],["rpss","application/vnd.nokia.radio-presets"],["rpst","application/vnd.nokia.radio-preset"],["rq","application/sparql-query"],["rs","application/rls-services+xml"],["rsa","application/x-pkcs7"],["rsat","application/atsc-rsat+xml"],["rsd","application/rsd+xml"],["rsheet","application/urc-ressheet+xml"],["rss","application/rss+xml"],["rtf","text/rtf"],["rtx","text/richtext"],["run","application/x-makeself"],["rusd","application/route-usd+xml"],["rv","video/vnd.rn-realvideo"],["s","text/x-asm"],["s3m","audio/s3m"],["saf","application/vnd.yamaha.smaf-audio"],["sass","text/x-sass"],["sbml","application/sbml+xml"],["sc","application/vnd.ibm.secure-container"],["scd","application/x-msschedule"],["scm","application/vnd.lotus-screencam"],["scq","application/scvp-cv-request"],["scs","application/scvp-cv-response"],["scss","text/x-scss"],["scurl","text/vnd.curl.scurl"],["sda","application/vnd.stardivision.draw"],["sdc","application/vnd.stardivision.calc"],["sdd","application/vnd.stardivision.impress"],["sdkd","application/vnd.solent.sdkm+xml"],["sdkm","application/vnd.solent.sdkm+xml"],["sdp","application/sdp"],["sdw","application/vnd.stardivision.writer"],["sea","application/octet-stream"],["see","application/vnd.seemail"],["seed","application/vnd.fdsn.seed"],["sema","application/vnd.sema"],["semd","application/vnd.semd"],["semf","application/vnd.semf"],["senmlx","application/senml+xml"],["sensmlx","application/sensml+xml"],["ser","application/java-serialized-object"],["setpay","application/set-payment-initiation"],["setreg","application/set-registration-initiation"],["sfd-hdstx","application/vnd.hydrostatix.sof-data"],["sfs","application/vnd.spotfire.sfs"],["sfv","text/x-sfv"],["sgi","image/sgi"],["sgl","application/vnd.stardivision.writer-global"],["sgm","text/sgml"],["sgml","text/sgml"],["sh","application/x-sh"],["shar","application/x-shar"],["shex","text/shex"],["shf","application/shf+xml"],["shtml","text/html"],["sid","image/x-mrsid-image"],["sieve","application/sieve"],["sig","application/pgp-signature"],["sil","audio/silk"],["silo","model/mesh"],["sis","application/vnd.symbian.install"],["sisx","application/vnd.symbian.install"],["sit","application/x-stuffit"],["sitx","application/x-stuffitx"],["siv","application/sieve"],["skd","application/vnd.koan"],["skm","application/vnd.koan"],["skp","application/vnd.koan"],["skt","application/vnd.koan"],["sldm","application/vnd.ms-powerpoint.slide.macroenabled.12"],["sldx","application/vnd.openxmlformats-officedocument.presentationml.slide"],["slim","text/slim"],["slm","text/slim"],["sls","application/route-s-tsid+xml"],["slt","application/vnd.epson.salt"],["sm","application/vnd.stepmania.stepchart"],["smf","application/vnd.stardivision.math"],["smi","application/smil"],["smil","application/smil"],["smv","video/x-smv"],["smzip","application/vnd.stepmania.package"],["snd","audio/basic"],["snf","application/x-font-snf"],["so","application/octet-stream"],["spc","application/x-pkcs7-certificates"],["spdx","text/spdx"],["spf","application/vnd.yamaha.smaf-phrase"],["spl","application/x-futuresplash"],["spot","text/vnd.in3d.spot"],["spp","application/scvp-vp-response"],["spq","application/scvp-vp-request"],["spx","audio/ogg"],["sql","application/x-sql"],["src","application/x-wais-source"],["srt","application/x-subrip"],["sru","application/sru+xml"],["srx","application/sparql-results+xml"],["ssdl","application/ssdl+xml"],["sse","application/vnd.kodak-descriptor"],["ssf","application/vnd.epson.ssf"],["ssml","application/ssml+xml"],["sst","application/octet-stream"],["st","application/vnd.sailingtracker.track"],["stc","application/vnd.sun.xml.calc.template"],["std","application/vnd.sun.xml.draw.template"],["stf","application/vnd.wt.stf"],["sti","application/vnd.sun.xml.impress.template"],["stk","application/hyperstudio"],["stl","model/stl"],["stpx","model/step+xml"],["stpxz","model/step-xml+zip"],["stpz","model/step+zip"],["str","application/vnd.pg.format"],["stw","application/vnd.sun.xml.writer.template"],["styl","text/stylus"],["stylus","text/stylus"],["sub","text/vnd.dvb.subtitle"],["sus","application/vnd.sus-calendar"],["susp","application/vnd.sus-calendar"],["sv4cpio","application/x-sv4cpio"],["sv4crc","application/x-sv4crc"],["svc","application/vnd.dvb.service"],["svd","application/vnd.svd"],["svg","image/svg+xml"],["svgz","image/svg+xml"],["swa","application/x-director"],["swf","application/x-shockwave-flash"],["swi","application/vnd.aristanetworks.swi"],["swidtag","application/swid+xml"],["sxc","application/vnd.sun.xml.calc"],["sxd","application/vnd.sun.xml.draw"],["sxg","application/vnd.sun.xml.writer.global"],["sxi","application/vnd.sun.xml.impress"],["sxm","application/vnd.sun.xml.math"],["sxw","application/vnd.sun.xml.writer"],["t","text/troff"],["t3","application/x-t3vm-image"],["t38","image/t38"],["taglet","application/vnd.mynfc"],["tao","application/vnd.tao.intent-module-archive"],["tap","image/vnd.tencent.tap"],["tar","application/x-tar"],["tcap","application/vnd.3gpp2.tcap"],["tcl","application/x-tcl"],["td","application/urc-targetdesc+xml"],["teacher","application/vnd.smart.teacher"],["tei","application/tei+xml"],["teicorpus","application/tei+xml"],["tex","application/x-tex"],["texi","application/x-texinfo"],["texinfo","application/x-texinfo"],["text","text/plain"],["tfi","application/thraud+xml"],["tfm","application/x-tex-tfm"],["tfx","image/tiff-fx"],["tga","image/x-tga"],["tgz","application/x-tar"],["thmx","application/vnd.ms-officetheme"],["tif","image/tiff"],["tiff","image/tiff"],["tk","application/x-tcl"],["tmo","application/vnd.tmobile-livetv"],["toml","application/toml"],["torrent","application/x-bittorrent"],["tpl","application/vnd.groove-tool-template"],["tpt","application/vnd.trid.tpt"],["tr","text/troff"],["tra","application/vnd.trueapp"],["trig","application/trig"],["trm","application/x-msterminal"],["ts","video/mp2t"],["tsd","application/timestamped-data"],["tsv","text/tab-separated-values"],["ttc","font/collection"],["ttf","font/ttf"],["ttl","text/turtle"],["ttml","application/ttml+xml"],["twd","application/vnd.simtech-mindmapper"],["twds","application/vnd.simtech-mindmapper"],["txd","application/vnd.genomatix.tuxedo"],["txf","application/vnd.mobius.txf"],["txt","text/plain"],["u8dsn","message/global-delivery-status"],["u8hdr","message/global-headers"],["u8mdn","message/global-disposition-notification"],["u8msg","message/global"],["u32","application/x-authorware-bin"],["ubj","application/ubjson"],["udeb","application/x-debian-package"],["ufd","application/vnd.ufdl"],["ufdl","application/vnd.ufdl"],["ulx","application/x-glulx"],["umj","application/vnd.umajin"],["unityweb","application/vnd.unity"],["uoml","application/vnd.uoml+xml"],["uri","text/uri-list"],["uris","text/uri-list"],["urls","text/uri-list"],["usdz","model/vnd.usdz+zip"],["ustar","application/x-ustar"],["utz","application/vnd.uiq.theme"],["uu","text/x-uuencode"],["uva","audio/vnd.dece.audio"],["uvd","application/vnd.dece.data"],["uvf","application/vnd.dece.data"],["uvg","image/vnd.dece.graphic"],["uvh","video/vnd.dece.hd"],["uvi","image/vnd.dece.graphic"],["uvm","video/vnd.dece.mobile"],["uvp","video/vnd.dece.pd"],["uvs","video/vnd.dece.sd"],["uvt","application/vnd.dece.ttml+xml"],["uvu","video/vnd.uvvu.mp4"],["uvv","video/vnd.dece.video"],["uvva","audio/vnd.dece.audio"],["uvvd","application/vnd.dece.data"],["uvvf","application/vnd.dece.data"],["uvvg","image/vnd.dece.graphic"],["uvvh","video/vnd.dece.hd"],["uvvi","image/vnd.dece.graphic"],["uvvm","video/vnd.dece.mobile"],["uvvp","video/vnd.dece.pd"],["uvvs","video/vnd.dece.sd"],["uvvt","application/vnd.dece.ttml+xml"],["uvvu","video/vnd.uvvu.mp4"],["uvvv","video/vnd.dece.video"],["uvvx","application/vnd.dece.unspecified"],["uvvz","application/vnd.dece.zip"],["uvx","application/vnd.dece.unspecified"],["uvz","application/vnd.dece.zip"],["vbox","application/x-virtualbox-vbox"],["vbox-extpack","application/x-virtualbox-vbox-extpack"],["vcard","text/vcard"],["vcd","application/x-cdlink"],["vcf","text/x-vcard"],["vcg","application/vnd.groove-vcard"],["vcs","text/x-vcalendar"],["vcx","application/vnd.vcx"],["vdi","application/x-virtualbox-vdi"],["vds","model/vnd.sap.vds"],["vhd","application/x-virtualbox-vhd"],["vis","application/vnd.visionary"],["viv","video/vnd.vivo"],["vlc","application/videolan"],["vmdk","application/x-virtualbox-vmdk"],["vob","video/x-ms-vob"],["vor","application/vnd.stardivision.writer"],["vox","application/x-authorware-bin"],["vrml","model/vrml"],["vsd","application/vnd.visio"],["vsf","application/vnd.vsf"],["vss","application/vnd.visio"],["vst","application/vnd.visio"],["vsw","application/vnd.visio"],["vtf","image/vnd.valve.source.texture"],["vtt","text/vtt"],["vtu","model/vnd.vtu"],["vxml","application/voicexml+xml"],["w3d","application/x-director"],["wad","application/x-doom"],["wadl","application/vnd.sun.wadl+xml"],["war","application/java-archive"],["wasm","application/wasm"],["wav","audio/x-wav"],["wax","audio/x-ms-wax"],["wbmp","image/vnd.wap.wbmp"],["wbs","application/vnd.criticaltools.wbs+xml"],["wbxml","application/wbxml"],["wcm","application/vnd.ms-works"],["wdb","application/vnd.ms-works"],["wdp","image/vnd.ms-photo"],["weba","audio/webm"],["webapp","application/x-web-app-manifest+json"],["webm","video/webm"],["webmanifest","application/manifest+json"],["webp","image/webp"],["wg","application/vnd.pmi.widget"],["wgt","application/widget"],["wks","application/vnd.ms-works"],["wm","video/x-ms-wm"],["wma","audio/x-ms-wma"],["wmd","application/x-ms-wmd"],["wmf","image/wmf"],["wml","text/vnd.wap.wml"],["wmlc","application/wmlc"],["wmls","text/vnd.wap.wmlscript"],["wmlsc","application/vnd.wap.wmlscriptc"],["wmv","video/x-ms-wmv"],["wmx","video/x-ms-wmx"],["wmz","application/x-msmetafile"],["woff","font/woff"],["woff2","font/woff2"],["word","application/msword"],["wpd","application/vnd.wordperfect"],["wpl","application/vnd.ms-wpl"],["wps","application/vnd.ms-works"],["wqd","application/vnd.wqd"],["wri","application/x-mswrite"],["wrl","model/vrml"],["wsc","message/vnd.wfa.wsc"],["wsdl","application/wsdl+xml"],["wspolicy","application/wspolicy+xml"],["wtb","application/vnd.webturbo"],["wvx","video/x-ms-wvx"],["x3d","model/x3d+xml"],["x3db","model/x3d+fastinfoset"],["x3dbz","model/x3d+binary"],["x3dv","model/x3d-vrml"],["x3dvz","model/x3d+vrml"],["x3dz","model/x3d+xml"],["x32","application/x-authorware-bin"],["x_b","model/vnd.parasolid.transmit.binary"],["x_t","model/vnd.parasolid.transmit.text"],["xaml","application/xaml+xml"],["xap","application/x-silverlight-app"],["xar","application/vnd.xara"],["xav","application/xcap-att+xml"],["xbap","application/x-ms-xbap"],["xbd","application/vnd.fujixerox.docuworks.binder"],["xbm","image/x-xbitmap"],["xca","application/xcap-caps+xml"],["xcs","application/calendar+xml"],["xdf","application/xcap-diff+xml"],["xdm","application/vnd.syncml.dm+xml"],["xdp","application/vnd.adobe.xdp+xml"],["xdssc","application/dssc+xml"],["xdw","application/vnd.fujixerox.docuworks"],["xel","application/xcap-el+xml"],["xenc","application/xenc+xml"],["xer","application/patch-ops-error+xml"],["xfdf","application/vnd.adobe.xfdf"],["xfdl","application/vnd.xfdl"],["xht","application/xhtml+xml"],["xhtml","application/xhtml+xml"],["xhvml","application/xv+xml"],["xif","image/vnd.xiff"],["xl","application/excel"],["xla","application/vnd.ms-excel"],["xlam","application/vnd.ms-excel.addin.macroEnabled.12"],["xlc","application/vnd.ms-excel"],["xlf","application/xliff+xml"],["xlm","application/vnd.ms-excel"],["xls","application/vnd.ms-excel"],["xlsb","application/vnd.ms-excel.sheet.binary.macroEnabled.12"],["xlsm","application/vnd.ms-excel.sheet.macroEnabled.12"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xlt","application/vnd.ms-excel"],["xltm","application/vnd.ms-excel.template.macroEnabled.12"],["xltx","application/vnd.openxmlformats-officedocument.spreadsheetml.template"],["xlw","application/vnd.ms-excel"],["xm","audio/xm"],["xml","application/xml"],["xns","application/xcap-ns+xml"],["xo","application/vnd.olpc-sugar"],["xop","application/xop+xml"],["xpi","application/x-xpinstall"],["xpl","application/xproc+xml"],["xpm","image/x-xpixmap"],["xpr","application/vnd.is-xpr"],["xps","application/vnd.ms-xpsdocument"],["xpw","application/vnd.intercon.formnet"],["xpx","application/vnd.intercon.formnet"],["xsd","application/xml"],["xsl","application/xml"],["xslt","application/xslt+xml"],["xsm","application/vnd.syncml+xml"],["xspf","application/xspf+xml"],["xul","application/vnd.mozilla.xul+xml"],["xvm","application/xv+xml"],["xvml","application/xv+xml"],["xwd","image/x-xwindowdump"],["xyz","chemical/x-xyz"],["xz","application/x-xz"],["yaml","text/yaml"],["yang","application/yang"],["yin","application/yin+xml"],["yml","text/yaml"],["ymp","text/x-suse-ymp"],["z","application/x-compress"],["z1","application/x-zmachine"],["z2","application/x-zmachine"],["z3","application/x-zmachine"],["z4","application/x-zmachine"],["z5","application/x-zmachine"],["z6","application/x-zmachine"],["z7","application/x-zmachine"],["z8","application/x-zmachine"],["zaz","application/vnd.zzazz.deck+xml"],["zip","application/zip"],["zir","application/vnd.zul"],["zirz","application/vnd.zul"],["zmm","application/vnd.handheld-entertainment+xml"],["zsh","text/x-scriptzsh"]]);function
1eF(e,t,a){let r=function(e){let{name:t}=e;if(t&&-1!==t.lastIndexOf(".")&&!e.type){let a=t.split(".").pop().toLowerCase(),r=eT.get(a);r&&Object.defineProperty(e,"type",{value:r,writable:!1,configurable:!1,enumerable:!0})}return e}(e),{webkitRelativePath:i}=e,n="string"==typeof t?t:"string"==typeof i&&i.length>0?i:`./${e.name}`;return"string"!=typeof r.path&&eq(r,"path",n),void 0!==a&&Object.defineProperty(r,"handle",{value:a,writable:!1,configurable:!1,enumerable:!0}),eq(r,"relativePath",n),r}function eq(e,t,a){Object.defineProperty(e,t,{value:a,writable:!1,configurable:!1,enumerable:!0})}let eI=[".DS_Store","Thumbs.db"];function eU(e){return"object"==typeof e&&null!==e}function eW(e){return e.filter(e=>-1===eI.indexOf(e.name))}function eB(e){if(null===e)return[];let t=[];for(let a=0;a<e.length;a++){let r=e[a];t.push(r)}return t}function eG(e){if("function"!=typeof e.webkitGetAsEntry)return eH(e);let t=e.webkitGetAsEntry();return t&&t.isDirectory?eK(t):eH(e,t)}function eH(e,t){return(0,eR.__awaiter)(this,void 0,void 0,function*(){var a;if(globalThis.isSecureContext&&"function"==typeof e.getAsFileSystemHandle){let t=yield e.getAsFileSystemHandle();if(null===t)throw Error(`${e} is not a File`);if(void 0!==t){let e=yield t.getFile();return e.handle=t,eF(e)}}let r=e.getAsFile();if(!r)throw Error(`${e} is not a File`);return eF(r,null!=(a=null==t?void 0:t.fullPath)?a:void 0)})}function eV(e){return(0,eR.__awaiter)(this,void 0,void 0,function*(){return e.isDirectory?eK(e):function(e){return(0,eR.__awaiter)(this,void 0,void 0,function*(){return new Promise((t,a)=>{e.file(a=>{t(eF(a,e.fullPath))},e=>{a(e)})})})}(e)})}function eK(e){let t=e.createReader();return new Promise((e,a)=>{let r=[];!function i(){t.readEntries(t=>(0,eR.__awaiter)(this,void 0,void 0,function*(){if(t.length){let e=Promise.all(t.map(eV));r.push(e),i()}else try{let t=yield Promise.all(r);e(t)}catch(e){a(e)}}),e=>{a(e)})}()})}var eX=e.i(75592);function eY(e){return function(e){if(Array.isArray(e))return e2(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||e1(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eJ(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function eQ(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};
1t%2?eJ(Object(a),!0).forEach(function(t){eZ(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):eJ(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}function eZ(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function e0(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a,r,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n=[],s=!0,o=!1;try{for(i=i.call(e);!(s=(a=i.next()).done)&&(n.push(a.value),!t||n.length!==t);s=!0);}catch(e){o=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(o)throw r}}return n}}(e,t)||e1(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function e1(e,t){if(e){if("string"==typeof e)return e2(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);if("Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a)return Array.from(e);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return e2(e,t)}}function e2(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,r=Array(t);a<t;a++)r[a]=e[a];return r}var e5="function"==typeof eX.default?eX.default:eX.default.default,e3=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=e.split(","),a=t.length>1?"one of ".concat(t.join(", ")):t[0];return{code:"file-invalid-type",message:"File type must be ".concat(a)}},e4=function(e){return{code:"file-too-large",message:"File is larger than ".concat(e," ").concat(1===e?"byte":"bytes")}},e6=function(e){return{code:"file-too-small",message:"File is smaller than ".concat(e," ").concat(1===e?"byte":"bytes")}},e8={code:"too-many-files",message:"Too many files"};function e7(e,t){var a="application/x-moz-file"===e.type||e5(e,t)||""===e.type&&"function"==typeof e.getAsFile;return[a,a?null:e3(t)]}function e9(e,t,a){if(te(e.size)){if(te(t)&&te(a)){if(e.size>a)return[!1,e4(a)];if(e.size<t)return[!1,e6(t)]}else if(te(t)&&e.size<t)return[!1,e6(t)];else if(te(a)&&e.size>a)return[!1,e4(a)]}return[!0,null]}function te(e){return null!=e}function tt(e){return"function"==typeof e.isPropagationStopped?e.isPropagationStopped():void 0!==e.cancelBubble&&e.cancelBubble}function ta(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(e){return"Files"===e||"application/x-moz-file"===e}):!!e.target&&!!e.target.files}function tr(e){e.preventDefault()}function ti(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return function(e){for(var a=arguments.length,r=Array(a>1?a-1:0),i=1;i<a;i++)r[i-1]=arguments[i];return t.some(function(t){return!tt(e)&&t&&t.apply(void 0,[e].concat(r)),tt(e)})}}function tn(e){return"audio/*"===e||"video/*"===e||"image/*"===e||"text/*"===e||"application/*"===e||/\w+\/[-+.\w]+/g.test(e)}function ts(e){return/^.*\.[\w]+$/.test(e)}var to=["children"],tl=["open"],td=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],tc=["refKey","onChange","onClick"];function tp(e){return function(e){if(Array.isArray(e))return tx(e)}(e)||function(e){if("u">typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||tm(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tu(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a,r,i=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n=[],s=!0,o=!1;try{for(i=i.call(e);!(s=(a=i.next()).done)&&(n.push(a.value),!t||n.length!==t);s=!0);}catch(e){o=!0,r=e}finally{try{s||null==i.return||i.return()}finally{if(o)throw r}}return n}}(e,t)||tm(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tm(e,t){if(e){if("string"==typeof e)return tx(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);if("Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a)return Array.from(e);if("Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return tx(e,t)}}function tx(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,r=Array(t);a<t;a++)r[a]=e[a];return r}function tf(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),a.push.apply(a,r)}return a}function th(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};
1t%2?tf(Object(a),!0).forEach(function(t){tg(e,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):tf(Object(a)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))})}return e}function tg(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function tb(e,t){if(null==e)return{};var a,r,i=function(e,t){if(null==e)return{};var a,r,i={},n=Object.keys(e);for(r=0;r<n.length;r++)a=n[r],t.indexOf(a)>=0||(i[a]=e[a]);return i}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(r=0;r<n.length;r++)a=n[r],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(i[a]=e[a])}return i}var tv=(0,a.forwardRef)(function(e,t){var r=e.children,i=tj(tb(e,to)),n=i.open,s=tb(i,tl);return(0,a.useImperativeHandle)(t,function(){return{open:n}},[n]),a.default.createElement(a.Fragment,null,r(th(th({},s),{},{open:n})))});tv.displayName="Dropzone";var ty={disabled:!1,getFilesFromEvent:function(e){return(0,eR.__awaiter)(this,void 0,void 0,function*(){var t;if(eU(e)&&eU(e.dataTransfer))return function(e,t){return(0,eR.__awaiter)(this,void 0,void 0,function*(){if(e.items){let a=eB(e.items).filter(e=>"file"===e.kind);return"drop"!==t?a:eW(function e(t){return t.reduce((t,a)=>[...t,...Array.isArray(a)?e(a):[a]],[])}((yield Promise.all(a.map(eG)))))}return eW(eB(e.files).map(e=>eF(e)))})}(e.dataTransfer,e.type);if(eU(t=e)&&eU(t.target))return eB(e.target.files).map(e=>eF(e));return Array.isArray(e)&&e.every(e=>"getFile"in e&&"function"==typeof e.getFile)?function(e){return(0,eR.__awaiter)(this,void 0,void 0,function*(){return(yield Promise.all(e.map(e=>e.getFile()))).map(e=>eF(e))})}(e):[]})},maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!1,autoFocus:!1};tv.defaultProps=ty,tv.propTypes={children:eA.default.func,accept:eA.default.objectOf(eA.default.arrayOf(eA.default.string)),multiple:eA.default.bool,preventDropOnDocument:eA.default.bool,noClick:eA.default.bool,noKeyboard:eA.default.bool,noDrag:eA.default.bool,noDragEventsBubbling:eA.default.bool,minSize:eA.default.number,maxSize:eA.default.number,maxFiles:eA.default.number,disabled:eA.default.bool,getFilesFromEvent:eA.default.func,onFileDialogCancel:eA.default.func,onFileDialogOpen:eA.default.func,useFsAccessApi:eA.default.bool,autoFocus:eA.default.bool,onDragEnter:eA.default.func,onDragLeave:eA.default.func,onDragOver:eA.default.func,onDrop:eA.default.func,onDropAccepted:eA.default.func,onDropRejected:eA.default.func,onError:eA.default.func,validator:eA.default.func};var t_={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,isDragGlobal:!1,acceptedFiles:[],fileRejections:[]};function tj(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=th(th({},ty),e),r=t.accept,i=t.disabled,n=t.getFilesFromEvent,s=t.maxSize,o=t.minSize,l=t.multiple,d=t.maxFiles,c=t.onDragEnter,p=t.onDragLeave,u=t.onDragOver,m=t.onDrop,x=t.onDropAccepted,f=t.onDropRejected,h=t.onFileDialogCancel,g=t.onFileDialogOpen,b=t.useFsAccessApi,v=t.autoFocus,y=t.preventDropOnDocument,_=t.noClick,j=t.noKeyboard,w=t.noDrag,k=t.noDragEventsBubbling,N=t.onError,S=t.validator,z=(0,a.useMemo)(function(){return te(r)?Object.entries(r).reduce(function(e,t){var a=e0(t,2),r=a[0],i=a[1];return[].concat(eY(e),[r],eY(i))},[]).filter(function(e){return tn(e)||ts(e)}).join(","):void 0},[r]),$=(0,a.useMemo)(function(){return te(r)?[{description:"Files",accept:Object.entries(r).filter(function(e){var t=e0(e,2),a=t[0],r=t[1],i=!0;return tn(a)||(console.warn('Skipped "'.concat(a,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),Array.isArray(r)&&r.every(ts)||(console.warn('Skipped "'.concat(a,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(e,t){var a=e0(t,2),r=a[0],i=a[1];return eQ(eQ({},e),{},eZ({},r,i))},{})}]:r},[r]),C=(0,a.useMemo)(function(){return"function"==typeof g?g:tk},[g]),M=(0,a.useMemo)(function(){return"function"==typeof h?h:tk},[h]),E=(0,a.useRef)(null),D=(0,a.useRef)(null),P=tu((0,a.useReducer)(tw,t_),2),O=P[0],L=P[1],A=O.isFocused,R=O.isFileDialogActive,T=(0,a.useRef)("u">typeof window&&window.isSecureContext&&b&&"showOpenFilePicker"in window),F=function(){!T.current&&R&&setTimeout(function(){D.current&&(D.current.files.length||(L({type:"closeDialog"}),M()))},300)};(0,a.useEffect)(function(){return window.addEventListener("focus",F,!1),function(){window.removeEventListener("focus",F,!1)}},[D,R,M,T]);var q=(0,a.useRef)([]),I=(0,a.useRef)([]),U=function(e){E.current&&E.current.contains(e.target)||(e.preventDefault(),q.current=[])};(0,a.useEffect)(function(){return y&&(document.addEventListener("dragover",tr,!1),document.addEventListener("drop",U,!1)),function(){y&&(document.removeEventListener("dragover",tr),document.removeEventListener("drop",U))}},[E,y]),(0,a.useEffect)(function(){var e=function(e){I.current=[].concat(tp(I.current),[e.target]),ta(e)&&L({isDragGlobal:!0,type:"setDragGlobal"})},t=function(e){I.current=I.current.filter(function(t){return t!==e.target&&null!==t}),I.current.length>0||L({isDragGlobal:!1,type:"setDragGlobal"})},a=function(){I.current=[],L({isDragGlobal:!1,type:"setDragGlobal"})},r=function(){I.current=[],L({isDragGlobal:!1,type:"setDragGlobal"})};return document.addEventListener("dragenter",e,!1),document.addEventListener("dragleave",t,!1),document.addEventListener("dragend",a,!1),document.addEventListener("drop",r,!1),function(){document.removeEventListener("dragenter",e),document.removeEventListener("dragleave",t),document.removeEventListener("dragend",a),document.removeEventListener("drop",r)}},[E]),(0,a.useEffect)(function(){return!i&&v&&E.current&&E.current.focus(),function(){}},[E,v,i]);var W=(0,a.useCallback)(function(e){N?N(e):console.error(e)},[N]),B=(0,a.useCallback)(function(e){e.preventDefault(),e.persist(),er(e),q.current=[].concat(tp(q.current),[e.target]),ta(e)&&Promise.resolve(n(e)).then(function(t){if(!tt(e)||k){var a,r,i,n,p,u,m,x,f=t.length,h=f>0&&(r=(a={files:t,accept:z,minSize:o,maxSize:s,multiple:l,maxFiles:d,validator:S}).files,i=a.accept,n=a.minSize,p=a.maxSize,u=a.multiple,m=a.maxFiles,x=a.validator,(!!u||!(r.length>1))&&(!u||!(m>=1)||!(r.length>m))&&r.every(function(e){var t=e0(e7(e,i),1)[0],a=e0(e9(e,n,p),1)[0],r=x?x(e):null;return t&&a&&!r}));L({isDragAccept:h,isDragReject:f>0&&!h,isDragActive:!0,type:"setDraggedFiles"}),c&&c(e)}}).catch(function(e){return W(e)})},[n,c,W,k,z,o,s,l,d,S]),G=(0,a.useCallback)(function(e){e.preventDefault(),e.persist(),er(e);var t=ta(e);if(t&&e.dataTransfer)try{e.dataTransfer.dropEffect="copy"}catch(e){}return t&&u&&u(e),!1},[u,k]),H=(0,a.useCallback)(function(e){e.preventDefault(),e.persist(),er(e);var t=q.current.filter(function(e){return E.current&&E.current.contains(e)}),a=t.indexOf(e.target);-1!==a&&t.splice(a,1),q.current=t,!(t.length>0)&&(L({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),ta(e)&&p&&p(e))},[E,p,k]),V=(0,a.useCallback)(function(e,t){var a=[],r=[];e.forEach(function(e){var t=tu(e7(e,z),2),i=t[0],n=t[1],l=tu(e9(e,o,s),2),d=l[0],c=l[1],p=S?S(e):null;if(i&&d&&!p)a.push(e);else{var u=[n,c];p&&(u=u.concat(p)),r.push({file:e,errors:u.filter(function(e){return e})})}}),(!l&&a.length>1||l&&d>=1&&a.length>
1d)&&(a.forEach(function(e){r.push({file:e,errors:[e8]})}),a.splice(0)),L({acceptedFiles:a,fileRejections:r,type:"setFiles"}),m&&m(a,r,t),r.length>0&&f&&f(r,t),a.length>0&&x&&x(a,t)},[L,l,z,o,s,d,m,x,f,S]),K=(0,a.useCallback)(function(e){e.preventDefault(),e.persist(),er(e),q.current=[],ta(e)&&Promise.resolve(n(e)).then(function(t){(!tt(e)||k)&&V(t,e)}).catch(function(e){return W(e)}),L({type:"reset"})},[n,V,W,k]),X=(0,a.useCallback)(function(){if(T.current){L({type:"openDialog"}),C(),window.showOpenFilePicker({multiple:l,types:$}).then(function(e){return n(e)}).then(function(e){V(e,null),L({type:"closeDialog"})}).catch(function(e){e instanceof DOMException&&("AbortError"===e.name||e.code===e.ABORT_ERR)?(M(e),L({type:"closeDialog"})):e instanceof DOMException&&("SecurityError"===e.name||e.code===e.SECURITY_ERR)?(T.current=!1,D.current?(D.current.value=null,D.current.click()):W(Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):W(e)});return}D.current&&(L({type:"openDialog"}),C(),D.current.value=null,D.current.click())},[L,C,M,b,V,W,$,l]),Y=(0,a.useCallback)(function(e){E.current&&E.current.isEqualNode(e.target)&&(" "===e.key||"Enter"===e.key||32===e.keyCode||13===e.keyCode)&&(e.preventDefault(),X())},[E,X]),J=(0,a.useCallback)(function(){L({type:"focus"})},[]),Q=(0,a.useCallback)(function(){L({type:"blur"})},[]),Z=(0,a.useCallback)(function(){_||(function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:window.navigator.userAgent;return -1!==e.indexOf("MSIE")||-1!==e.indexOf("Trident/")||-1!==e.indexOf("Edge/")}()?setTimeout(X,0):X())},[_,X]),ee=function(e){return i?null:e},et=function(e){return j?null:ee(e)},ea=function(e){return w?null:ee(e)},er=function(e){k&&e.stopPropagation()},ei=(0,a.useMemo)(function(){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.refKey,a=e.role,r=e.onKeyDown,n=e.onFocus,s=e.onBlur,o=e.onClick,l=e.onDragEnter,d=e.onDragOver,c=e.onDragLeave,p=e.onDrop,u=tb(e,td);return th(th(tg({onKeyDown:et(ti(r,Y)),onFocus:et(ti(n,J)),onBlur:et(ti(s,Q)),onClick:ee(ti(o,Z)),onDragEnter:ea(ti(l,B)),onDragOver:ea(ti(d,G)),onDragLeave:ea(ti(c,H)),onDrop:ea(ti(p,K)),role:"string"==typeof a&&""!==a?a:"presentation"},void 0===t?"ref":t,E),i||j?{}:{tabIndex:0}),u)}},[E,Y,J,Q,Z,B,G,H,K,j,w,i]),en=(0,a.useCallback)(function(e){e.stopPropagation()},[]),es=(0,a.useMemo)(function(){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.refKey,a=e.onChange,r=e.onClick,i=tb(e,tc);return th(th({},tg({accept:z,multiple:l,type:"file",style:{border:0,clip:"rect(0, 0, 0, 0)",clipPath:"inset(50%)",height:"1px",margin:"0 -1px -1px 0",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap"},onChange:ee(ti(a,K)),onClick:ee(ti(r,en)),tabIndex:-1},void 0===t?"ref":t,D)),i)}},[D,r,l,K,i]);return th(th({},O),{},{isFocused:A&&!i,getRootProps:ei,getInputProps:es,rootRef:E,inputRef:D,open:ee(X)})}function tw(e,t){switch(t.type){case"focus":return th(th({},e),{},{isFocused:!0});case"blur":return th(th({},e),{},{isFocused:!1});case"openDialog":return th(th({},t_),{},{isFileDialogActive:!0});case"closeDialog":return th(th({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return th(th({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return th(th({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections,isDragReject:!1});case"setDragGlobal":return th(th({},e),{},{isDragGlobal:t.isDragGlobal});case"reset":return th({},t_);default:return e}}function tk(){}let tN={initial:{x:0,y:0},animate:{x:20,y:-20,opacity:.9}},tS={initial:{opacity:0}
1,animate:{opacity:1}},tz=({onChange:e})=>{let[r,i]=(0,a.useState)([]),n=(0,a.useRef)(null),s=t=>{i(e=>[...e,...t]),e&&e(t)},{getRootProps:o,isDragActive:l}=tj({multiple:!1,noClick:!0,onDrop:s,onDropRejected:e=>{console.log(e)}});return(0,t.jsx)("div",{className:"w-full",...o(),children:(0,t.jsxs)(f.motion.div,{onClick:()=>{n.current?.click()},whileHover:"animate",className:"group/file relative block w-full cursor-pointer overflow-hidden rounded-lg p-10",children:[(0,t.jsx)("input",{ref:n,id:"file-upload-handle",type:"file",onChange:e=>s(Array.from(e.target.files||[])),className:"hidden"}),(0,t.jsx)("div",{className:"absolute inset-0 [mask-image:radial-gradient(ellipse_at_center,white,transparent)]",children:(0,t.jsx)(t$,{})}),(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center",children:[(0,t.jsx)("p",{className:"relative z-20 font-sans text-base font-bold text-neutral-700 dark:text-neutral-300",children:"Upload file"}),(0,t.jsx)("p",{className:"relative z-20 mt-2 font-sans text-base font-normal text-neutral-400 dark:text-neutral-400",children:"Drag or drop your files here or click to upload"}),(0,t.jsxs)("div",{className:"relative mx-auto mt-10 w-full max-w-xl",children:[r.length>0&&r.map((e,a)=>(0,t.jsxs)(f.motion.div,{layoutId:0===a?"file-upload":"file-upload-"+a,className:(0,g.cn)("relative z-40 mx-auto mt-4 flex w-full flex-col items-start justify-start overflow-hidden rounded-md bg-white p-4 md:h-24 dark:bg-neutral-900","shadow-sm"),children:[(0,t.jsxs)("div",{className:"flex w-full items-center justify-between gap-4",children:[(0,t.jsx)(f.motion.p,{initial:{opacity:0}
1,animate:{opacity:1},layout:!0,className:"max-w-xs truncate text-base text-neutral-700 dark:text-neutral-300",children:e.name}),(0,t.jsxs)(f.motion.p,{initial:{opacity:0},animate:{opacity:1},layout:!0,className:"shadow-input w-fit shrink-0 rounded-lg px-2 py-1 text-sm text-neutral-600 dark:bg-neutral-800 dark:text-white",children:[(e.size/1048576).toFixed(2)," MB"]})]}),(0,t.jsxs)("div",{className:"mt-2 flex w-full flex-col items-start justify-between text-sm text-neutral-600 md:flex-row md:items-center dark:text-neutral-400",children:[(0,t.jsx)(f.motion.p,{initial:{opacity:0},animate:{opacity:1},layout:!0,className:"rounded-md bg-gray-100 px-1 py-0.5 dark:bg-neutral-800",children:e.type}),(0,t.jsxs)(f.motion.p,{initial:{opacity:0},animate:{opacity:1},layout:!0,children:["modified"," ",new Date(e.lastModified).toLocaleDateString()]})]})]},"file"+a)),!r.length&&(0,t.jsx)(f.motion.div,{layoutId:"file-upload",variants:tN,transition:{type:"spring",stiffness:300,damping:20},className:(0,g.cn)("relative z-40 mx-auto mt-4 flex h-32 w-full max-w-[8rem] items-center justify-center rounded-md bg-white group-hover/file:shadow-2xl dark:bg-neutral-900","shadow-[0px_10px_50px_rgba(0,0,0,0.1)]"),children:l?(0,t.jsxs)(f.motion.p,{initial:{opacity:0}
1,animate:{opacity:1},className:"flex flex-col items-center text-neutral-600",children:["Drop it",(0,t.jsx)(eL,{className:"h-4 w-4 text-neutral-600 dark:text-neutral-400"})]}):(0,t.jsx)(eL,{className:"h-4 w-4 text-neutral-600 dark:text-neutral-300"})}),!r.length&&(0,t.jsx)(f.motion.div,{variants:tS,className:"absolute inset-0 z-30 mx-auto mt-4 flex h-32 w-full max-w-[8rem] items-center justify-center rounded-md border border-dashed border-sky-400 bg-transparent opacity-0"})]})]})]})})};function t$(){return(0,t.jsx)("div",{className:"flex shrink-0 scale-105 flex-wrap items-center justify-center gap-x-px gap-y-px bg-gray-100 dark:bg-neutral-900",children:Array.from({length:11}).map((e,a)=>Array.from({length:41}).map((e,r)=>(0,t.jsx)("div",{className:`flex h-10 w-10 shrink-0 rounded-[2px] ${(41*a+r)%2==0?"bg-gray-50 dark:bg-neutral-950":"bg-gray-50 shadow-[0px_0px_1px_3px_rgba(255,255,255,1)_inset] dark:bg-neutral-950 dark:shadow-[0px_0px_1px_3px_rgba(0,0,0,1)_inset]"}`},`${r}-${a}`)))})}function tC({photo:e,onSelect:r,hint:i}){let n=a.useCallback(e=>{let t=e.find(e=>e.type.startsWith("image/"))??e[0];t&&r(t)},[r]);return e?(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4 sm:flex-row sm:items-center",children:[(0,t.jsx)("figure",{className:"relative h-28 w-40 shrink-0 overflow-hidden rounded-md border border-border bg-muted",children:(0,t.jsx)("img",{src:e.previewUrl,alt:e.name,className:"h-full w-full object-cover"})}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-1.5",children:[(0,t.jsx)("p",{className:"truncate text-sm font-medium text-foreground",children:e.name}),(0,t.jsx)(tM,{photo:e}),(0,t.jsx)("div",{children:(0,t.jsxs)("label",{className:"inline-flex cursor-pointer items-center gap-1.5 text-xs text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(eO,{className:"size-3.5"}),"Replace photo",(0,t.jsx)("input",{type:"file",accept:"image/*",className:"hidden",onChange:e=>n(Array.from(e.target.files??[]))})]})})]})]}):(0,t.jsxs)("div",{className:"rounded-lg border border-border bg-card/60",children:[(0,t.jsx)(tz,{onChange:n}),i&&(0,t.jsx)("p",{className:"px-6 pb-5 text-center text-xs text-muted-foreground",children:i})]})}function tM({photo:e}){return"uploading"===e.status?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground",children:[(0,t.jsx)($.Loader2,{className:"size-3.5 animate-spin"})," Hosting photo for the engineâ¦"]}):"error"===e.status?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs text-destructive",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-3.5"})," ",e.error??"Upload failed."]}):(0,t.jsxs)("span",{className:(0,g.cn)("inline-flex items-center gap-1.5 text-xs text-primary"),children:[(0,t.jsx)(eP.CheckCircle2,{className:"size-3.5"}),e.mocked?"Staged (mock host)":"Hosted â ready to generate"]})}let tE=(0,Q.default)(()=>e.A(12590).then(e=>e.LiveMarkupCanvas),{loadableGenerated:{modules:[17088]},ssr:!1,loading:()=>(0,t.jsxs)("div",{className:"flex min-h-[520px] items-center justify-center rounded-[18px] border border-border bg-muted/40 text-sm text-muted-foreground",children:[(0,t.jsx)($.Loader2,{className:"mr-2 size-4 animate-spin"})," Loading canvasâ¦"]})}),tD=[{label:"Warm it up",direction:"Warm up the overall color temperature and lighting of the room; keep all geometry, materials, and layout exactly the same."},{label:"Refine",direction:"Refine and polish the material and finish quality throughout the room; keep all geometry, fixtures, and layout exactly the same."},{label:"Adjust",direction:"Subtly rebalance the styling and composition of the scene; keep all geometry, fixtures, and layout exactly the same."},{label:"Change lighting",direction:"Change the lighting to a soft warm golden-hour ambience; keep everything else in the scene the same."}];function tP({photo:e,onSelectPhoto:i}){let n=(0,b.usePrefersReducedMotion)(),[s,o]=a.useState([]),[l,d]=a.useState(""),[c,p]=a.useState([]),[u,m]=a.useState(null),[x,h]=a.useState(!1),[v,_]=a.useState(null),[j,w]=a.useState(null),k=e?.status==="ready"?e.remoteUrl:null;a.useEffect(()=>{if(!k){p([]),m(null);return}p([{id:"v0",name:"Original",url:k}]),m("v0"),o([]),d(""),_(null),w(null)},[k]);let N=c.find(e=>e.id===u)??null,S=a.useMemo(()=>G(s),[s]),z=a.useCallback(e=>{o(t=>t.filter(t=>t.id!==e).map((e,t)=>({...e,number:t+1})))},[]),M=a.useCallback(async e=>{if(!N)return;let t=e?[]:S,a=(e??l).trim();if(0===t.length&&!a)return void _("Drop at least one mark with an instruction, or add a whole-image direction.");h(!0),_(null);try{let r=await W({source_image_url:N.url,marks:t,wholeDirection:a||void 0}),i=r.final_url??N.url,n=c.filter(e=>"v0"!==e.id).length+1,s={id:`v-${Date.now()}`,name:e?`Refine ${n}`:`Edit ${n}`,url:i,fromUrl:N.url,reasoning:r.design_reasoning,steps:r.steps,marksCount:t.length,decomposer:r.decomposer,mocked:r.mocked,costCents:r.cost_cents};p(e=>[...e,s]),m(s.id),w(r),o([]),e||d("")}catch(e){_(e instanceof Error?e.message:"Generate failed.")}finally{h(!1)}},[N,S,l,c]);return(0,t.jsxs)(f.motion.div,{...(0,b.fadeUp)(n),className:"flex flex-col gap-8",children:[(0,t.jsx)("p",{className:"text-sm leading-relaxed text-muted-foreground",children:"Drop numbered colored marks on the photo â each with one instruction â add an optional whole-image direction, then Generate Design. Every change is decomposed into single, geometry-preserving edits and chained."}),(0,t.jsx)(tC,{photo:e,onSelect:i,hint:"Upload a room photo to begin marking changes."}),N&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"caps text-xs text-muted-foreground",children:"Mark changes"}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Editing: ",(0,t.jsx)("strong",{className:"font-medium text-foreground",children:N.name})]})]}),(0,t.jsx)(tE,{imageUrl:N.url,mode:"edit",marks:s,isBusy:x,onMarksChange:o,onGeneratePlan:()=>M()}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Click âAnnotate changesâ, pick a tool (draw / box / pin) and a color, mark a region, then type the change and Save mark. Each saved mark becomes a numbered request below."})]}),(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-[minmax(0,1fr)_300px]",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-3 panel p-4",children:[(0,t.jsxs)("span",{className:"caps text-xs text-muted-foreground",children:["Saved requests (",s.length,")"]}),0===s.length?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"No marks yet â annotate the photo to add change requests."}):(0,t.jsx)("ul",{className:"flex flex-col gap-2",children:s.map((e,a)=>(0,t.jsxs)("li",{className:"flex items-start gap-3 rounded-md border border-border bg-background px-3 py-2",children:[(0,t.jsx)("span",{className:"mt-0.5 inline-flex size-5 shrink-0 items-center justify-center rounded-full text-[0.65rem] font-semibold text-white",style:{backgroundColor:e.color??"#ef4444"},children:a+1}),(0,t.jsx)("span",{className:"flex-1 text-sm text-foreground",children:e.instruction}),(0,t.jsx)("button",{type:"button","aria-label":"Remove request",onClick:()=>z(e.id),className:"text-muted-foreground transition-colors hover:text-destructive",children:(0,t.jsx)(ea,{className:"size-3.5"})})]},e.id))})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2 panel p-4",children:[(0,t.jsx)("label",{htmlFor:"whole-direction",className:"caps text-xs text-muted-foreground",children:"Whole image direction"}),(0,t.jsx)("textarea",{id:"whole-direction",value:l,maxLength:500,onChange:e=>d(e.target.value),placeholder:"Optional global intent, e.g. âWarm, high-end modern kitchen with a cohesive material palette.â",className:"min-h-24 w-full resize-y rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/40"}),(0,t.jsxs)("span",{className:"self-end text-[0.65rem] text-muted-foreground",children:[l.length,"/500"]})]})]}),v&&(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-4"}),v]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 panel p-5 sm:flex-row sm:items-center sm:justify-between",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:(0,t.jsx)(y.PenLine,{className:"size-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Generate design"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Decomposes your marks into single-change edits and chains them through"," ",(0,t.jsx)("code",{className:"font-mono text-[0.7rem]",children:"/api/edit/run"}),". ~1 credit per image."]})]})]}),(0,t.jsxs)(er.Button,{onClick:()=>M(),disabled:x||0===S.length&&!l.trim(),size:"lg",className:"shrink-0",children:[x?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(Z.Sparkles,{className:"size-4"}),x?"Generatingâ¦":"Generate Design"]})]}),N.fromUrl&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("span",{className:"caps text-xs text-muted-foreground",children:["Before / after â ",N.name]}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[N.decomposer??"engine","number"!=typeof N.c
1ostCents||N.mocked?N.mocked?" · mocked":"":` \xb7 $${(N.costCents/100).toFixed(2)}`]})]}),(0,t.jsx)(I,{before:N.fromUrl,after:N.url,beforeLabel:"Before",afterLabel:"After"}),(N.reasoning||N.steps&&N.steps.length>0)&&(0,t.jsxs)(eM,{defaultOpen:!0,className:"panel",children:[(0,t.jsxs)(eE,{className:"group flex w-full items-center justify-between px-4 py-3 text-left",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,t.jsx)(r.Wand2,{className:"size-4 text-primary"}),"Design reasoning"]}),(0,t.jsx)(T,{className:"size-4 text-muted-foreground transition-transform group-data-[state=open]:rotate-180"})]}),(0,t.jsxs)(eD,{className:"border-t border-border px-4 py-3",children:[N.reasoning&&(0,t.jsx)("p",{className:"mb-3 text-sm text-muted-foreground",children:N.reasoning}),N.steps&&N.steps.length>0&&(0,t.jsx)("ol",{className:"flex flex-col gap-2",children:N.steps.map(e=>{let a=e.verify,r=a&&a.ok?a.change_applied&&!a.drift?"text-cine-emerald":a.change_applied?"text-amber-600 dark:text-amber-400":"text-destructive":"text-muted-foreground",i=a?a.ok?a.change_applied&&!a.drift?"verified â change applied, nothing else drifted":a.change_applied?"applied, minor drift":"could not confirm change":"accepted (no verifier)":null;return(0,t.jsxs)("li",{className:"flex gap-3 text-sm",children:[(0,t.jsx)("span",{className:"mt-0.5 font-mono text-xs text-accent",children:String(e.step).padStart(2,"0")}),(0,t.jsxs)("span",{className:"flex flex-col gap-0.5",children:[e.label&&(0,t.jsx)("span",{className:"caps text-[0.65rem] text-muted-foreground",children:e.label}),(0,t.jsx)("span",{className:"text-foreground",children:e.edit_instruction}),i&&(0,t.jsxs)("span",{className:(0,g.cn)("text-[0.7rem]",r),children:["Auto-verify: ",i,e.retried&&e.attempts?` \xb7 ${e.attempts.length} attempts`:"",a?.ok&&a.note?` â ${a.note}`:""]})]})]},e.step)})})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"caps text-[0.65rem] text-muted-foreground",children:"Refine:"}),tD.map(e=>(0,t.jsx)("button",{type:"button",disabled:x,onClick:()=>M(e.direction),className:"rounded-full border border-border bg-background px-3 py-1.5 text-xs text-foreground transition-colors hover:border-primary hover:text-primary disabled:opacity-50",children:e.label},e.label))]})]}),c.length>1&&(0,t.jsxs)("div",{className:"flex flex-col gap-3 panel p-4",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,t.jsx)(ee,{className:"size-4 text-primary"}),"Canvas history"]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:c.map(e=>{let a=e.id===u;return(0,t.jsxs)("button",{type:"button",onClick:()=>{m(e.id),o([])},className:(0,g.cn)("group relative flex flex-col items-start gap-1 rounded-md border px-3 py-2 text-left transition-colors",a?"border-primary bg-primary/5":"border-border bg-background hover:border-primary/50"),children:[(0,t.jsxs)("span",{className:"flex items-center gap-1.5 text-xs font-medium text-foreground",children:[a?(0,t.jsx)(et.RotateCcw,{className:"size-3 text-primary"}):null,e.name]}),"number"==typeof e.marksCount&&e.marksCount>0&&(0,t.jsxs)(es,{variant:"secondary",className:"text-[0.6rem]",children:[e.marksCount," mark",1===e.marksCount?"":"s"]})]},e.id)})}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Select any canvas to revert. New marks then branch from the selected version."})]})]}),!N&&e?.status==="uploading"&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:"Hosting your photo â the annotator opens as soon as it is ready."}),j?.mocked&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Note: rendered in mock mode (no FAL_KEY) â decomposition ran, image edits were skipped."})]})}let tO=(0,n.default)("sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]),tL=(0,n.default)("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]);function tA({className:e}){let[r,i]=a.useState(52);return(0,t.jsxs)("div",{className:(0,g.cn)("w-full",e),children:[(0,t.jsxs)("div",{className:"relative aspect-[16/10] w-full overflow-hidden rounded-lg border border-border",children:[(0,t.jsx)(tR,{label:"Before",icon:(0,t.jsx)(tO,{className:"size-4"}),className:"absolute inset-0 bg-[radial-gradient(120%_120%_at_20%_0%,_hsl(39_38%_92%),_hsl(38_24%_78%))] dark:bg-[radial-gradient(120%_120%_at_20%_0%,_hsl(220_12%_22%),_hsl(220_14%_12%))]",align:"left"}),(0,t.jsx)("div",{className:"absolute inset-0",style:{clipPath:`inset(0 0 0 ${r}%)`},children:(0,t.jsx)(tR,{label:"After · relit",icon:(0,t.jsx)(tL,{className:"size-4"}),className:"h-full bg-[linear-gradient(135deg,_hsl(156_30%_22%),_hsl(218_38%_18%)_60%,_hsl(36_44%_38%))]",align:"right",invert:!0})}),(0,t.jsx)("div",{className:"pointer-events-none absolute inset-y-0 z-20 w-px bg-accent",style:{left:`${r}%`},children:(0,t.jsx)("span",{className:"absolute top-1/2 left-1/2 flex size-8 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border border-accent bg-card shadow-sm",children:(0,t.jsx)("span",{className:"text-[0.6rem] font-semibold text-accent",children:"â"})})}),(0,t.jsx)("input",{type:"range",min:0,max:100,value:r,onChange:e=>i(Number(e.target.value)),"aria-label":"Reveal relit render",className:"absolute inset-0 z-30 h-full w-full cursor-ew-resize opacity-0"})]}),(0,t.jsx)("p",{className:"mt-3 text-xs text-muted-foreground",children:"A sample of the before / after relight slider. Upload a room photo above to relight your own space â the real source and relit render replace these panels."})]})}function tR({label:e,icon:a,className:r,align:i,invert:n}){return(0,t.jsxs)("div",{className:(0,g.cn)("relative flex h-full w-full",r),children:[(0,t.jsxs)("svg",{className:"absolute inset-0 h-full w-full opacity-25",preserveAspectRatio:"none",viewBox:"0 0 100 62",children:[(0,t.jsx)("path",{d:"M0 0 L40 26 L40 40 L0 62",fill:"none",stroke:"currentColor",strokeWidth:"0.4"}),(0,t.jsx)("path",{d:"M100 0 L60 26 L60 40 L100 62",fill:"none",stroke:"currentColor",strokeWidth:"0.4"}),(0,t.jsx)("path",{d:"M40 26 L60 26 M40 40 L60 40",fill:"none",stroke:"currentColor",strokeWidth:"0.4"})]}),(0,t.jsxs)("span",{className:(0,g.cn)("absolute top-3 inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium backdrop-blur-sm","left"===i?"left-3":"right-3",n?"border-white/25 bg-black/25 text-white":"border-border bg-card/80 text-foreground"),children:[a,(0,t.jsx)("span",{className:"caps text-[0.6rem]",children:e})]})]})}let tT=[{label:"Warm golden hour",instruction:"Change the lighting to warm golden-hour sunlight streaming softly into the room; keep everything else in the scene exactly the same."},{label:"Bright daylight",instruction:"Change the lighting to bright, even, natural daylight; keep everything else in the scene exactly the same."},{label:"Warm evening",instruction:"Change the lighting to a warm, cozy evening glow with soft lamplight; keep everything else in the scene exactly the same."}];function tF({photo:e,onSelectPhoto:r}
1){let i=(0,b.usePrefersReducedMotion)(),[n,s]=a.useState(null),[o,l]=a.useState(null),[d,c]=a.useState(null),p=e?.status==="ready"?e.remoteUrl:null;a.useEffect(()=>{c(null),l(null)},[p]);let u=a.useCallback(async e=>{if(p){s(e.label),l(null);try{let t=await B({source_image_url:p,edit_instruction:e.instruction,preserve:"Camera position and angle\nAll walls, windows, and doorways\nEvery fixture, furniture piece, surface, material, and color\nRoom layout and proportions"});c(t)}catch(e){l(e instanceof Error?e.message:"Relight failed.")}finally{s(null)}}},[p]);return(0,t.jsxs)(f.motion.div,{...(0,b.fadeUp)(i),className:"flex flex-col gap-8",children:[(0,t.jsx)("p",{className:"text-sm leading-relaxed text-muted-foreground",children:"Re-stage the space under different lighting â a single lighting-only edit that keeps every wall, fixture, material, and color exactly in place."}),(0,t.jsx)(tC,{photo:e,onSelect:r,hint:"Upload a room photo to relight."}),p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"panel flex flex-col gap-3 p-5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:(0,t.jsx)(_,{className:"size-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Lighting only"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["One lighting-change edit via ",(0,t.jsx)("code",{className:"font-mono text-[0.7rem]",children:"/api/render/edit"}),"."]})]})]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:tT.map(e=>(0,t.jsxs)(er.Button,{onClick:()=>u(e),disabled:null!==n,variant:"outline",size:"sm",children:[n===e.label?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(Z.Sparkles,{className:"size-4"}),e.label]},e.label))})]}),o&&(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-4"}),o]}),d&&d.output_url&&(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("span",{className:"caps text-xs text-muted-foreground",children:["Before / after",d.mocked?" · mocked":"number"==typeof d.cost_cents?` \xb7 $${(d.cost_cents/100).toFixed(2)}`:""]}),(0,t.jsx)("div",{className:"glow-emerald overflow-hidden rounded-2xl",children:(0,t.jsx)(I,{before:p,after:d.output_url,beforeLabel:"Before",afterLabel:"Relit"})})]}),d&&d.mocked&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Rendered in mock mode (no FAL_KEY) â the lighting prompt was constructed but no image was generated."})]}):(0,t.jsx)(tA,{})]})}var tq=e.i(1238);e.i(64066);var tI=e.i(13901);function tU({text:e}){return(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-4 shrink-0"}),e]})}function tW({note:e}){return e?(0,t.jsx)("p",{className:"text-[0.68rem] leading-relaxed text-muted-foreground",children:e}):null}function tB(e){return e.toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2})}function tG({photo:e,onSelectPhoto:r}){let i=(0,b.usePrefersReducedMotion)(),[n,s]=a.useState(""),[o,l]=a.useState(!1),[d,c]=a.useState(null),[p,u]=a.useState(null),m=e?.status==="ready"?e.remoteUrl:null;a.useEffect(()=>{u(null),c(null)},[m]);let x=a.useCallback(async()=>{if(m&&n.trim()){l(!0),c(null);try{let e=await fetch("/api/render/locked",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({control_image_url:m,prompt:n.trim()})}),t=await e.json();if(!e.ok||"done"!==t.status)return void c(t.error||`Structure-locked render failed (HTTP ${e.status}).`);u(t)}catch(e){c(e instanceof Error?e.message:"Structure-locked render failed.")}finally{l(!1)}}},[m,n]);return(0,t.jsxs)(f.motion.div,{...(0,b.fadeUp)(i),className:"flex flex-col gap-5",children:[(0,t.jsx)(tC,{photo:e,onSelect:r,hint:"Upload the room to render with its structure locked."}),(0,t.jsxs)("div",{className:"panel flex flex-col gap-4 p-5",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:(0,t.jsx)(j,{className:"size-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Structure-locked render"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Two-stage geometry lock via ",(0,t.jsx)("code",{className:"font-mono text-[0.7rem]",children:"/api/render/locked"})," â a canny edge lock pins every wall, window, and fixture line, then a photo-finish pass restyles materials. Walls cannot move."]})]})]}),(0,t.jsx)("textarea",{value:n,maxLength:600,onChange:e=>s(e.target.value),rows:3,placeholder:"Warm white oak cabinetry, honed quartzite counters, unlacquered brass hardware, plaster range hoodâ¦",className:"w-full resize-none rounded-lg border border-border bg-card/40 p-3 text-sm leading-relaxed text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary/60"}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,t.jsx)("span",{className:"text-[0.68rem] text-muted-foreground",children:"Fires TWO paid model calls â the estimated cost is disclosed with the result."}),(0,t.jsxs)(er.Button,{onClick:x,disabled:o||!m||!n.trim(),size:"lg",children:[o?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(j,{className:"size-4"}
1),o?"Locking + renderingâ¦":"Structure-locked render"]})]}),!m&&(0,t.jsx)("p",{className:"text-[0.7rem] text-muted-foreground",children:"Upload a photo above to enable the render."})]}),d&&(0,t.jsx)(tU,{text:d}),p?.locked_url&&p.final_url&&(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"caps text-xs text-muted-foreground",children:"Geometry lock / final"}),(0,t.jsxs)("span",{className:"badge-basis badge-verified inline-flex items-center gap-1",children:[(0,t.jsx)(tq.Eye,{className:"size-3"}),"Geometry lock · eyeball-verified"]}),"number"==typeof p.cost_usd&&(0,t.jsxs)("span",{className:"figure-mono text-[0.7rem] text-muted-foreground",children:["est. ",tB(p.cost_usd)]})]}),(0,t.jsx)("div",{className:"glow-emerald overflow-hidden rounded-2xl",children:(0,t.jsx)(I,{before:p.locked_url,after:p.final_url,beforeLabel:"Locked geometry",afterLabel:"Final render"})}),(0,t.jsx)(tW,{note:p.honest_note??null})]})]})}function tH({photo:e,onSelectPhoto:r}){let i=(0,b.usePrefersReducedMotion)(),[n,s]=a.useState(""),[o,l]=a.useState(null),[d,c]=a.useState(null),[p,u]=a.useState(!1),[m,x]=a.useState(null),[h,v]=a.useState(null),y=a.useRef(null),_=e?.status==="ready"?e.remoteUrl:null;a.useEffect(()=>{v(null),x(null),l(null),c(null)},[_]);let j=a.useCallback(e=>{let t=y.current;if(!t||!t.naturalWidth)return;let a=t.getBoundingClientRect(),r=(e.clientX-a.left)/a.width,i=(e.clientY-a.top)/a.height;l({x:Math.round(r*t.naturalWidth),y:Math.round(i*t.naturalHeight)}),c({leftPct:100*r,topPct:100*i}),v(null)},[]),k=a.useCallback(async()=>{if(_&&o&&n.trim()){u(!0),x(null);try{let e=await fetch("/api/render/mask-edit",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({image_url:_,point:o,prompt:n.trim()})}),t=await e.json();if(!e.ok||"done"!==t.status)return void x(t.error||`Precision edit failed (HTTP ${e.status}).`);v(t)}catch(e){x(e instanceof Error?e.message:"Precision edit failed.")}finally{u(!1)}}},[_,o,n]);return(0,t.jsxs)(f.motion.div,{...(0,b.fadeUp)(i),className:"flex flex-col gap-5",children:[(0,t.jsx)(tC,{photo:e,onSelect:r,hint:"Upload the room, then click the exact surface to repaint."}),_&&(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsx)("span",{className:"caps text-xs text-muted-foreground",children:"Click the surface to edit"}),(0,t.jsxs)("div",{className:"relative overflow-hidden rounded-2xl border border-border bg-black/40",children:[(0,t.jsx)("img",{ref:y,src:_,alt:"Click a surface to select it",onClick:j,className:"w-full cursor-crosshair select-none",draggable:!1}),d&&(0,t.jsxs)("span",{"aria-hidden":!0,className:"pointer-events-none absolute z-10 grid size-6 -translate-x-1/2 -translate-y-1/2 place-items-center",style:{left:`${d.leftPct}%`,top:`${d.topPct}%`},children:[(0,t.jsx)("span",{className:"absolute inset-0 rounded-full border-2 border-ion/90"}),(0,t.jsx)("span",{className:"size-1.5 rounded-full bg-ion"})]})]}),!o&&(0,t.jsx)("p",{className:"text-[0.7rem] text-muted-foreground",children:"No surface selected yet â click the photo."})]}),(0,t.jsxs)("div",{className:"panel flex flex-col gap-4 p-5",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:(0,t.jsx)(w,{className:"size-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Precision edit"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Point-prompted segmentation + masked inpaint via"," ",(0,t.jsx)("code",{className:"font-mono text-[0.7rem]",children:"/api/render/mask-edit"})," â only the clicked surface is repainted; every unmasked pixel is untouched by the fill model."]})]})]}),(0,t.jsx)("input",{value:n,maxLength:300,onChange:e=>s(e.target.value),placeholder:"e.g. honed Calacatta marble backsplash",className:"w-full rounded-lg border border-border bg-card/40 px-3 py-2.5 text-sm text-foreground outline-none transition-colors placeholder:text-muted-foreground focus:border-primary/60"}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,t.jsx)("span",{className:"text-[0.68rem] text-muted-foreground",children:"Two paid model calls (segment + fill) â the estimated cost is disclosed with the result."}
1),(0,t.jsxs)(er.Button,{onClick:k,disabled:p||!_||!o||!n.trim(),size:"lg",children:[p?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(w,{className:"size-4"}),p?"Segmenting + paintingâ¦":"Repaint this surface"]})]})]}),m&&(0,t.jsx)(tU,{text:m}),h?.result_url&&_&&(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"caps text-xs text-muted-foreground",children:"Before / after â masked region only"}),(0,t.jsx)(tI.BasisChip,{basis:"typical",children:"Model segmentation â not a measured surface"}),"number"==typeof h.cost_usd&&(0,t.jsxs)("span",{className:"figure-mono text-[0.7rem] text-muted-foreground",children:["est. ",tB(h.cost_usd)]})]}),(0,t.jsx)("div",{className:"glow-emerald overflow-hidden rounded-2xl",children:(0,t.jsx)(I,{before:_,after:h.result_url,beforeLabel:"Before",afterLabel:"Precision edit"})}),h.mask_url&&(0,t.jsxs)("details",{className:"text-[0.7rem] text-muted-foreground",children:[(0,t.jsx)("summary",{className:"cursor-pointer",children:"Show the segmentation mask"}),(0,t.jsx)("img",{src:h.mask_url,alt:"SAM2 segmentation mask",className:(0,g.cn)("mt-2 max-h-64 rounded-lg border border-border")})]}),(0,t.jsx)(tW,{note:h.honest_note??null})]})]})}let tV=[{id:"transform",label:"Transform",icon:r.Wand2,blurb:"One geometry-preserving restyle from a prompt â judge-verified."},{id:"edit",label:"Edit",icon:y.PenLine,blurb:"Numbered marks â decomposed single-change edits, chained + auto-verified."},{id:"relight",label:"Relight",icon:_,blurb:"Lighting-only single change; everything else stays put."},{id:"locked",label:"Structure-locked",icon:j,blurb:"Two-stage canny geometry lock â walls cannot move."},{id:"precision",label:"Precision",icon:w,blurb:"Click a surface, repaint only that surface (masked inpaint)."}];function tK({mode:e}){let a=encodeURIComponent(`/studio?tab=${e}`);return(0,t.jsxs)("div",{className:"mx-auto flex max-w-lg flex-col items-center gap-4 roun
1ded-2xl border border-border bg-card/60 px-6 py-16 text-center",children:[(0,t.jsx)("span",{className:"grid size-12 place-items-center rounded-full bg-primary/10 text-primary",children:(0,t.jsx)(p.Lock,{className:"size-5"})}),(0,t.jsx)("h2",{className:"font-serif text-2xl font-light text-foreground",children:"A Studio render mode"}),(0,t.jsxs)("p",{className:"max-w-sm text-sm text-muted-foreground",children:[tV.find(t=>t.id===e)?.label," runs metered precision renders â sign in to your studio account to use it. The free preview keeps Transform, Measure, and Price open."]}),(0,t.jsxs)(h.default,{href:`/login?next=${a}`,className:"inline-flex items-center gap-2 rounded-full bg-white px-6 py-3 text-sm font-semibold text-black transition-transform hover:scale-[1.03] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:["Sign in",(0,t.jsx)(k.ArrowUpRight,{className:"size-4"})]})]})}function tX({photo:e,onSelectPhoto:a,onGenerate:r,generating:i,lastDoc:n,mode:s,onModeChange:o}){let l=(0,b.usePrefersReducedMotion)(),d=(0,v.useAccount)(),c=tV.find(e=>e.id===s)??tV[0],u=(0,v.tierAllows)(d.tier,s);return(0,t.jsxs)(f.motion.div,{...(0,b.fadeUp)(l),className:"flex flex-col gap-6",children:[(0,t.jsx)(z,{line:!0,kicker:"Design",title:"Render the change",blurb:c.blurb,action:(0,t.jsx)("div",{role:"tablist","aria-label":"Render mode",className:"flex flex-wrap items-center gap-1 rounded-full border border-border bg-card/60 p-1",children:tV.map(e=>{let a=e.id===s,r=!(0,v.tierAllows)(d.tier,e.id);return(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":a,onClick:()=>o(e.id),className:(0,g.cn)("inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-[0.68rem] font-medium uppercase tracking-[0.12em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",a?"bg-primary/15 text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(e.icon,{className:"size-3.5"}),e.label,r&&(0,t.jsx)(p.Lock,{className:"size-3 opacity-50"})]},e.id)})})}),!u&&(0,t.jsx)(tK,{mode:s}),u&&"transform"===s&&(0,t.jsx)(X,{photo:e,onSelectPhoto:a,onGenerate:r,generating:i,lastDoc:n,onAnnotate:()=>o("edit")}),u&&"edit"===s&&(0,t.jsx)(tP,{photo:e,onSelectPhoto:a}),u&&"relight"===s&&(0,t.jsx)(tF,{photo:e,onSelectPhoto:a}),u&&"locked"===s&&(0,t.jsx)(tG,{photo:e,onSelectPhoto:a}),u&&"precision"===s&&(0,t.jsx)(tH,{photo:e,onSelectPhoto:a})]})}var tY=e.i(5926);let tJ=(0,n.default)("cpu",[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]]),tQ=(0,n.default)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);var tZ=e.i(27885),t0=e.i(91096),t1=e.i(14192);let t2=(0,n.default)("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]]);var t5=e.i(28869);let t3=(0,n.default)("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]]),t4=(0,n.default)("file-chart-column",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M8 18v-1",key:"zg0ygc"}],["path",{d:"M12 18v-6",key:"17g6i2"}],["path",{d:"M16 18v-3",key:"j5jt4h"}]]);var t6=e.i(38732),t8=e.i(93479);function t7({doc:e,className:a}){let r=[{swatch:(0,t.jsx)("span",{className:"size-3 rounded-[3px] border border-primary bg-card"}),label:`${e.rooms.length} room${1===e.rooms.length?"":"s"}`},{swatch:(0,t.jsx)("span",{className:"size-3 rounded-[3px] border border-primary bg-secondary"}),label:`${e.fixtures.length} fixtures`},{swatch:(0,t.jsx)("span",{className:"h-1.5 w-3 rounded-full bg-foreground
1/80"}),label:`${e.walls.length} walls`},{swatch:(0,t.jsx)("span",{className:"h-3 w-3 rounded-[3px] border border-dashed border-muted-foreground"}),label:`${e.openings.length} openings`}];return(0,t.jsx)("div",{className:(0,g.cn)("flex flex-wrap items-center gap-x-5 gap-y-2",a),children:r.map(e=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-2 text-xs text-muted-foreground",children:[e.swatch,e.label]},e.label))})}var t9=e.i(53184);let ae=(0,n.default)("zoom-in",[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]]),at=({children:e,zoomFactor:r=1.5,lensSize:i=170,isStatic:n=!1,position:s={x:200,y:150},hovering:o,setHovering:l})=>{let d=(0,a.useRef)(null),[c,p]=(0,a.useState)(!1),u=l||p,[m,h]=(0,a.useState)({x:100,y:100});return(0,t.jsxs)("div",{ref:d,className:"relative overflow-hidden rounded-lg z-20",onMouseEnter:()=>{u(!0)},onMouseLeave:()=>u(!1),onMouseMove:e=>{let t=e.currentTarget.getBoundingClientRect();h({x:e.clientX-t.left,y:e.clientY-t.top})},children:[e,n?(0,t.jsx)("div",{children:(0,t.jsx)(f.motion.div,{initial:{opacity:0,scale:.58},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.3,ease:"easeOut"},className:"absolute inset-0 overflow-hidden",style:{maskImage:`radial-gradient(circle ${i/2}px at ${s.x}px ${s.y}px, black 100%, transparent 100%)`,WebkitMaskImage:`radial-gradient(circle ${i/2}px at ${s.x}px ${s.y}px, black 100%, transparent 100%)`,transformOrigin:`${s.x}px ${s.y}px`},children:(0,t.jsx)("div",{className:"absolute inset-0",style:{transform:`scale(${r})`,transformOrigin:`${s.x}px ${s.y}px`},children:e})})}):(0,t.jsx)(x.AnimatePresence,{children:(void 0!==o?o:c)&&(0,t.jsx)("div",{children:(0,t.jsx)(f.motion.div,{initial:{opacity:0,scale:.58},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.3,ease:"easeOut"},className:"absolute inset-0 overflow-hidden",style:{maskImage:`radial-gradient(circle ${i/2}px at ${m.x}px ${m.y}px, black 100%, transparent 100%)`,WebkitMaskImage:`radial-gradient(circle ${i/2}px at ${m.x}px ${m.y}px, black 100%, transparent 100%)`,transformOrigin:`${m.x}px ${m.y}px`,zIndex:50},children:(0,t.jsx)("div",{className:"absolute inset-0",style:{transform:`scale(${r})`,transformOrigin:`${m.x}px ${m.y}px`},children:e})})})})]})};var aa=e.i(97104),ar=e.i(93850),ai=e.i(96041),an=e.i(43984);let as=e=>Math.round(1e3*e)/1e3,ao={measured:"var(--cine-ion)",assumed:"var(--cine-gold)"};function al({doc:e,className:r,edgeDims:i=!0,showScaleBar:n=!0,onWallClick:s,animated:o=!0}){let l=e.bounds_ft.w+5.2,d=e.bounds_ft.h+5.2,c=46*l,p=46*d,u=a.useCallback(e=>as((e+2.6)*46),[]),m=a.useCallback(e=>as((e+2.6)*46),[]),x=a.useCallback(e=>as(46*e),[]),f=a.useMemo(()=>{let t;return{width:(t=t=>{let a=e.calibration?.[t]?.method;if(a&&"engine"!==a)return"proportional_estimate"===a?"assumed":"measured";let r=e.measurement_review?.estimate_basis?.[t];return"exact_anchor"===r?"measured":r?"assumed":e.confidence>=.8?"measured":"assumed"})("width"),depth:t("depth")}},[e]),h=a.useMemo(()=>{if(!i)return[];let t=[];return e.rooms.forEach((a,r)=>{let i=a.poly;for(let n=0;n<i.length;n++){let s=i[n],o=i[(n+1)%i.length],l=Math.hypot(o.x-s.x,o.y-s.y);if(l<1.6)continue;let d=0;e.rooms.forEach((e,t)=>{if(t!==r)for(let t=0;t<e.poly.length;t++)d+=function(e,t,a,r){let i=t.x-e.x,n=t.y-e.y,s=Math.hypot(i,n);if(s<1e-6)return 0;let o=i/s,l=n/s,d=Math.abs((a.x-e.x)*l-(a.y-e.y)*o),c=Math.abs((r.x-e.x)*l-(r.y-e.y)*o);if(d>.1||c>.1)return 0;let p=(a.x-e.x)*o+(a.y-e.y)*l,u=(r.x-e.x)*o+(r.y-e.y)*l,m=Math.max(0,Math.min(p,u));return Math.max(0,Math.min(s,Math.max(p,u))-m)}(s,o,e.poly[t],e.poly[(t+1)%e.poly.length])}),d>.5*l||t.push({key:`${a.id}-e${n}`,a:s,b:o,poly:i,len:l})}}),t},[e,i]),b=(0,t.jsxs)("svg",{viewBox:`0 0 ${c} ${p}`,className:(0,g.cn)("h-auto w-full select-none",r),role:"img","aria-label":`Floor plan: ${e.name}`,children:[(0,t.jsx)("defs",{children:(0,t.jsx)("pattern",{id:"pc-grid",width:46,height:46,patternUnits:"userSpaceOnUse",children:(0,t.jsx)("path",{d:"M 46 0 L 0 0 0 46",fill:"none",stroke:"var(--border)",strokeWidth:1,opacity:.5})})}),(0,t.jsx)("rect",{x:0,y:0,width:c,height:p,fill:"url(#pc-grid)",opacity:.6}),e.rooms.map((e,a)=>{let r=e.poly.map((e,t)=>`${0===t?"M":"L"} ${u(e.x)} ${m(e.y)}`).join(" ")+" Z",i=(0,an.polygonCentroid)(e.poly),n=e.area_ft2??(0,an.polygonAreaFt2)(e.poly),s=0===a;return(0,t.jsxs)("g",{children:[(0,t.jsx)("path",{d:r,fill:s?"var(--card)":"var(--muted)",opacity:s?.92:.85}),(0,t.jsx)(ai.DrawPath,{order:0,d:r,stroke:"var(--primary)",strokeWidth:1.25}),(0,t.jsx)(ai.DrawText,{order:3,x:u(i.x),y:m(i.y)-6,textAnchor:"middle",className:"fill-foreground",style:{fontSize:15,fontWeight:600,letterSpacing:"0.04em"},children:e.name}),(0,t.jsxs)(ai.DrawText,{order:3,x:u(i.x),y:m(i.y)+12,textAnchor:"middle",className:"fill-muted-foreground",style:{fontSize:11,fontFamily:"var(--font-geist-mono)"},children:[n.toFixed(0)," ft²"]})]},e.id)}),e.walls.map(e=>{let a="removed"===e.status,r="proposed"===e.status,i=(e.thickness_ft??.42)*46;return(0,t.jsxs)("g",{children:[(0,t.jsx)(ai.DrawLine,{order:1,x1:u(e.a.x),y1:m(e.a.y),x2:u(e.b.x),y2:m(e.b.y),stroke:a?"var(--destructive)":r?"var(--cine-gold)":"var(--foreground)",strokeWidth:a||r?Math.max(2,.45*i):i,strokeLinecap:"square",opacity:a?.55:r?.8:.9,strokeDasharray:a||r?"10 7":void 0}),s&&(0,t.jsx)("line",{x1:u(e.a.x),y1:m(e.a.y),x2:u(e.b.x),y2:m(e.b.y),stroke:"transparent",strokeWidth:22,strokeLinecap:"square",style:{cursor:"pointer",pointerEvents:"stroke"},tabIndex:0,role:"button","aria-label":`Wall ${e.id} â ${e.status??"active"}. Click to cycle: active, removed, proposed.`,onClick:()=>s(e.id),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),s(e.id))}})]},e.id)}),e.openings.map(e=>(0,t.jsx)(ap,{o:e,fx:u,fy:m,fl:x},e.id)),e.fixtures.map(e=>(0,t.jsx)(am,{f:e,fx:u,fy:m,fl:x},e.id)),e.dimensions.map(e=>{let a=1e-6>Math.abs(e.a.y-e.b.y)?f.width:f.depth;return(0,t.jsx)(ac,{a:e.a,b2:e.b,label:e.label,side:e.side,offsetFt:e.offset_ft,basis:a,fx:u,fy:m,order:4},e.id)}),h.map(e=>(0,t.jsx)(ad,{a:e.a,b:e.b,poly:e.poly,len:e.len,basis:f,fx:u,fy:m,order:4},e.key)),(0,t.jsxs)(ai.DrawGroup,{order:5,children:[(0,t.jsx)(ah,{x:c-55.199999999999996,y:50.6,deg:e.north_deg}),n&&(0,t.jsx)(af,{vbH:p,planWFt:e.bounds_ft.w})]})]});return o?(0,t.jsx)(ai.PlanDraw,{stagger:.18,children:b}):(0,t.jsx)(ai.PlanDraw,{stagger:0,children:b})}function ad({a:e,b:a,poly:r,len:i,basis:n,fx:s,fy:o,order:l}){let d=(a.x-e.x)/i,c=(a.y-e.y)/i,p=.5>Math.abs(d),u=.5>Math.abs(c)?n.width:p?n.depth:"measured"===n.width&&"measured"===n.depth?"measured":"assumed",m=ao[u],x="assumed"===u,f=-c,h=d;(function(e,t,a){let r=!1;for(let i=0,n=a.length-1;i<a.length;n=i++){let s=a[i].x,o=a[i].y,l=a[n].x,d=a[n].y;o>t!=d>t&&e<(l-s)*(t-o)/(d-o)+s&&(r=!r)}return r})((e.x+a.x)/2+.05*f,(e.y+a.y)/2+.05*h,r)&&(f=-f,h=-h);let g=s(e.x+1.15*f),b=o(e.y+1.15*h),v=s(a.x+1.15*f),y=o(a.y+1.15*h),_=-(5*c),j=5*d,w=180/Math.PI*Math.atan2(y-b,v-g);w>90?w-=180:w<-90&&(w+=180);let k=(g+v)/2,N=(b+y)/2,S=(0,an.formatFeetInches)(i),z=6.6*S.length+8;return(0,t.jsxs)("g",{children:[(0,t.jsx)(ai.DrawLine,{order:l,x1:s(e.x),y1:o(e.y),x2:g,y2:b,stroke:m,strokeWidth:.7,opacity:.5,strokeDasharray:x?"var(--line-dash)":void 0}),(0,t.jsx)(ai.DrawLine,{order:l,x1:s(a.x),y1:o(a.y),x2:v,y2:y,stroke:m,strokeWidth:.7,opacity:.5,strokeDasharray:x?"var(--line-dash)":void 0}),(0,t.jsx)(ai.DrawLine,{order:l,x1:g,y1:b,x2:v,y2:y,stroke:m,strokeWidth:1,opacity:.9}),(0,t.jsx)(ai.DrawLine,{order:l,x1:as(g-_),y1:as(b-j),x2:as(g+_),y2:as(b+j),stroke:m,strokeWidth:1.2}),(0,t.jsx)(ai.DrawLine,{order:l,x1:as(v-_),y1:as(y-j),x2:as(v+_),y2:as(y+j),stroke:m,strokeWidth:1.2}),(0,t.jsxs)(ai.DrawGroup,{order:l+1,transform:`translate(${as(k)} ${as(N)}) rotate(${as(w)})`,children:[(0,t.jsx)("rect",{x:as(-z/2),y:-8,width:as(z),height:15,fill:"var(--background)",opacity:.92,rx:2}),(0,t.jsx)("text",{x:0,y:3.5,textAnchor:"middle",style:{fontSize:11,fontFamily:"var(--font-geist-mono)",fontWeight:600,fill:m},children:S})]})]})}function ac({a:e,b2:a,label:r,side:i,offsetFt:n,basis:s,fx:o,fy:l,order:d}){let c,p,u,m,x,f=Math.hypot(a.x-e.x,a.y-e.y),h=r??(0,an.formatFeetInches)(f),g=n??1,b=1e-6>Math.abs(e.y-a.y),v=ao[s],y="assumed"===s,_=0;if(b){let t=l(e.y+("top"===i?-1:1)*g);c=[o(e.x),t],p=[o(a.x),t],u=[o(e.x),l(e.y)],m=[o(a.x),l(a.y)],x=[(c[0]+p[0])/2,t]}else{let t=o(e.x+("left"===i?-1:1)*g);c=[t,l(e.y)],p=[t,l(a.y)],u=[o(e.x),l(e.y)],m=[o(a.x),l(a.y)],x=[t,(c[1]+p[1])/2],_=-90}return(0,t.jsxs)("g",{children:[(0,t.jsx)(ai.DrawLine,{order:d,x1:u[0],y1:u[1],x2:c[0],y2:c[1],stroke:v,strokeWidth:.8,opacity:.5,strokeDasharray:y?"var(--line-dash)":void 0}),(0,t.jsx)(ai.DrawLine,{order:d,x1:m[0],y1:m[1],x2:p[0],y2:p[1],stroke:v,strokeWidth:.8,opacity:.5,strokeDasharray:y?"var(--line-dash)":void 0}),(0,t.jsx)(ai.DrawLine,{order:d,x1:c[0],y1:c[1],x2:p[0],y2:p[1],stroke:v,strokeWidth:1}),(0,t.jsx)(ai.DrawLine,{order:d,x1:c[0]-6,y1:c[1]-6,x2:c[0]+6,y2:c[1]+6,stroke:v,strokeWidth:1.2}),(0,t.jsx)(ai.DrawLine,{order:d,x1:p[0]-6,y1:p[1]-6,x2:p[0]+6,y2:p[1]+6,stroke:v,strokeWidth:1.2}),(0,t.jsxs)(ai.DrawGroup,{order:d+1,transform:`translate(${as(x[0])} ${as(x[1])}) rotate(${_})`,children:[(0,t.jsx)("rect",{x:-24,y:-9,width:48,height:14,fill:"var(--background)",rx:2,opacity:.92}),(0,t.jsx)("text",{x:0,y:2,textAnchor:"middle",style:{fontSize:11,fontFamily:"var(--font-geist-mono)",fontWeight:600,fill:v},children:h})]})]})}function ap({o:e,fx:a,fy:r,fl:i}){let n=a(e.a.x),s=r(e.a.y),o=a(e.b.x),l=r(e.b.y),d=Math.hypot(e.b.x-e.a.x,e.b.y-e.a.y),c=(0,t.jsx)("line",{x1:n,y1:s,x2:o,y2:l,stroke:"var(--card)",strokeWidth:23,strokeLinecap:"butt"});if("window"===e.kind)return(0,t.jsxs)("g",{children:[c,(0,t.jsx)(ai.DrawLine,{order:2,x1:n,y1:s,x2:o,y2:l,stroke:"var(--foreground)",strokeWidth:2}),(0,t.jsx)("line",{x1:n,y1:s,x2:o,y2:l,stroke:"var(--card)",strokeWidth:.9})]});if("cased"===e.kind)return(0,t.jsxs)("g",{children:[c,(0,t.jsx)(ai.DrawLine,{order:2,x1:n,y1:s,x2:o,y2:l,stroke:"var(--muted-foreground)",strokeWidth:1.5,strokeDasharray:"4 4"})]});let p="b"===e.hinge?{x:o,y:l}:{x:n,y:s},u="b"===e.hinge?{x:n,y:s}:{x:o,y:l},m=i(d),x=u.x-p.x,f=u.y-p.y,h=p.x-f,g=p.y+x;return(0,t.jsxs)("g",{children:[c,(0,t.jsx)(ai.DrawLine,{order:2,x1:p.x,y1:p.y,x2:h,y2:g,stroke:"var(--foreground)",strokeWidth:1.5}),(0,t.jsx)(ai.DrawPath,{order:2,d:`M ${as(u.x)} ${as(u.y)} A ${as(m)} ${as(m)} 0 0 1 ${as(h)} ${as(g)}`,stroke:"var(--muted-foreground)",strokeWidth:1,strokeDasharray:"3 3"})]})}let au={tub:"var(--secondary)",shower:"var(--secondary)",toilet:"var(--secondary)",sink:"var(--secondary)",vanity:"var(--secondary)",cabinet:"var(--muted)",island:"var(--muted)",appliance:"var(--muted)",stairs:"var(--muted)",closet:"var(--muted)",generic:"var(--muted)"};function am({f:e,fx:a,fy:r,fl:i}){let n="proposed"===e.status,s=a(e.bbox_ft.x),o=r(e.bbox_ft.y),l=i(e.bbox_ft.w),d=i(e.bbox_ft.h),c=s+l/2,p=o+d/2,u=e.rotation_deg??0;return(0,t.jsxs)("g",{transform:u?`rotate(${u} ${as(c)} ${as(p)})`:void 0,children:[!n&&(0,t.jsx)("rect",{x:s,y:o,width:l,height:d,rx:5,fill:au[e.kind]??"var(--muted)",opacity:.9}),(0,t.jsx)(ax,{x:s,y:o,w:l,h:d,stroke:n?"var(--cine-gold)":"var(--primary)",dashed:n}),(0,t.jsx)(ai.DrawText,{order:3,x:c,y:p+3.5,textAnchor:"middle",style:{fontSize:10,fontFamily:"var(--font-geist-mono)",letterSpacing:"0.08em",fill:n?"var(--cine-gold)":"var(--foreground)"},children:e.label})]})}function ax({x:e,y:a,w:r,h:i,stroke:n,dashed:s}){let o=`M ${as(e+5)} ${as(a)} H ${as(e+r-5)} Q ${as(e+r)} ${as(a)} ${as(e+r)} ${as(a+5)} V ${as(a+i-5)} Q ${as(e+r)} ${as(a+i)} ${as(e+r-5)} ${as(a+i)} H ${as(e+5)} Q ${as(e)} ${as(a+i)} ${as(e)} ${as(a+i-5)} V ${as(a+5)} Q ${as(e)} ${as(a)} ${as(e+5)} ${as(a)} Z`;return(0,t.jsx)(ai.DrawPath,{order:3,d:o,stroke:n,strokeWidth:s?1.4:1,strokeDasharray:s?"6 4":void 0})}function af({vbH:e,planWFt:a}){let r=1;for(let e of[1,2,4,5,8,10,16,20,30,40,50])e<=Math.max(1,.38*a)&&(r=e);let i=46*r/4,n=e-30;
1return(0,t.jsxs)("g",{"aria-hidden":!0,children:[[0,1,2,3].map(e=>(0,t.jsx)("rect",{x:as(10+e*i),y:n,width:as(i),height:7,fill:e%2==0?"var(--foreground)":"var(--card)",stroke:"var(--foreground)",strokeWidth:.9,opacity:.8},e)),(0,t.jsx)("text",{x:10,y:n+7+13,className:"fill-muted-foreground",style:{fontSize:10,fontFamily:"var(--font-geist-mono)"},children:"0"}),(0,t.jsxs)("text",{x:as(10+4*i),y:n+7+13,textAnchor:"end",className:"fill-muted-foreground",style:{fontSize:10,fontFamily:"var(--font-geist-mono)"},children:[r," ft"]})]})}function ah({x:e,y:a,deg:r}){return(0,t.jsxs)("g",{transform:`translate(${as(e)} ${as(a)})`,children:[(0,t.jsx)("circle",{r:20,fill:"var(--card)",stroke:"var(--border)",strokeWidth:1}),(0,t.jsxs)("g",{transform:`rotate(${r})`,children:[(0,t.jsx)("polygon",{points:"0,-14 5,4 0,0 -5,4",fill:"var(--primary)"}),(0,t.jsx)("polygon",{points:"0,-14 5,4 0,0",fill:"var(--foreground)",opacity:.35})]}),(0,t.jsx)("text",{y:31,textAnchor:"middle",className:"fill-muted-foreground",style:{fontSize:9,fontWeight:700,letterSpacing:"0.2em"},children:"N"})]})}function ag({text:e}){return(0,b.usePrefersReducedMotion)()?(0,t.jsx)(t.Fragment,{children:e}):(0,t.jsx)(aa.EncryptedText,{text:e,charset:"0123456789",revealDelayMs:40,flipDelayMs:45,encryptedClassName:"text-muted-foreground/60"})}function ab({doc:e}){let a=e.rooms.reduce((e,t)=>e+(t.area_ft2??(0,an.polygonAreaFt2)(t.poly)),0);return(0,t.jsxs)("header",{className:"flex flex-wrap items-end justify-between gap-x-6 gap-y-3 border-b border-border px-5 py-4 sm:px-6",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"caps text-[0.62rem] text-muted-foreground",children:"Floor plan"}),(0,t.jsx)("h3",{className:"mt-0.5 truncate font-serif text-2xl font-light text-foreground",children:e.name}),e.address&&(0,t.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.address})]}),(0,t.jsxs)("dl",{className:"flex flex-wrap items-end gap-x-6 gap-y-2",children:[(0,t.jsx)(av,{label:"Total area",value:`${a.toFixed(0)} ft\xb2`,reveal:!0}),(0,t.jsx)(av,{label:"Extents",value:`${(0,an.formatFeetInches)(e.bounds_ft.w)} \xd7 ${(0,an.formatFeetInches)(e.bounds_ft.h)}`,reveal:!0}),(0,t.jsx)(av,{label:"Scale",value:e.scale_note}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("dt",{className:"caps text-[0.6rem] text-muted-foreground",children:"North"}),(0,t.jsxs)("dd",{className:"figure-mono inline-flex items-center gap-1.5 text-sm text-foreground",children:[(0,t.jsx)(t9.Compass,{className:"size-3.5 text-primary",style:{transform:`rotate(${e.north_deg}deg)`},"aria-hidden":!0}),e.north_deg,"°"]})]})]})]})}function av({label:e,value:a,reveal:r}){return(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsx)("dt",{className:"caps text-[0.6rem] text-muted-foreground",children:e}),(0,t.jsx)("dd",{className:"figure-mono text-sm text-foreground",children:r?(0,t.jsx)(ag,{text:a}):a})]})}function ay({doc:e,proposedDoc:r,view:i="existing",onViewChange:n,editing:s=!1,onToggleEditing:o,onWallClick:l,onAddIsland:d,onResetProposal:c,proposalNotes:p=[],className:u}){let[m,x]=a.useState(!1),f=!!(n&&l),h=!!r,b="proposed"===i&&h,v=b?r:e,_=(0,t.jsx)(al,{doc:v,showScaleBar:!0,edgeDims:!0,onWallClick:s?l:void 0,className:"mx-auto max-h-[680px]"},`${v.id}-${i}-${s?"edit":"view"}`);return(0,t.jsxs)("figure",{className:(0,g.cn)("glow-emerald overflow-hidden rounded-2xl border border-border bg-card/50",u),children:[(0,t.jsx)(ab,{doc:e}),f&&(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 border-b border-border px-5 py-2.5 sm:px-6",children:[(0,t.jsx)("div",{className:"inline-flex items-center rounded-full border border-border bg-card/60 p-0.5",role:"tablist","aria-label":"Sheet view",children:[{id:"existing",label:"Existing · measured"},{id:"proposed",label:"Proposed"}].map(e=>{let a="proposed"===e.id===b,r="proposed"===e.id&&!h;return(0,t.jsx)("button",{type:"button",role:"tab","aria-selected":a,disabled:r,title:r?"Click a wall (Edit walls) or add an island to start a proposal":void 0,onClick:()=>n?.(e.id),className:(0,g.cn)("rounded-full px-3 py-1.5 text-[0.66rem] font-medium uppercase tracking-[0.14em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 disabled:opacity-40",a?"bg-primary/15 text-foreground":"text-muted-foreground hover:text-foreground"),children:e.label},e.id)})}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:o,"aria-pressed":s,className:(0,g.cn)("inline-flex items-center gap-1.5 rounded-full border px-3 py-1.5 text-[0.66rem] font-medium uppercase tracking-[0.14em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",s?"border-primary/50 bg-primary/10 text-primary":"border-border bg-card/80 text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(y.PenLine,{className:"size-3"}),s?"Editing walls â click a wall":"Edit walls"]}),d&&(0,t.jsxs)("button",{type:"button",onClick:d,className:"inline-flex items-center gap-1.5 rounded-full border border-border bg-card/80 px-3 py-1.5 text-[0.66rem] font-medium uppercase tracking-[0.14em] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",children:[(0,t.jsx)(O.Plus,{className:"size-3"}),"Add island"]}),h&&c&&(0,t.jsxs)("button",{type:"button",onClick:c,className:"inline-flex items-center gap-1.5 rounded-full border border-border bg-card/80 px-3 py-1.5 text-[0.66rem] font-medium uppercase tracking-[0.14em] text-muted-foreground transition-colors hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",children:[(0,t.jsx)(et.RotateCcw,{className:"size-3"}),"Reset"]})]})]}),b&&(0,t.jsxs)("div",{className:"flex flex-wrap items-start gap-2 border-b border-border px-5 py-2.5 sm:px-6",children:[(0,t.jsx)(tI.BasisChip,{basis:"assumed",children:"PROPOSED â not yet field-verified"}),p.length>0&&(0,t.jsx)("span",{className:"text-[0.68rem] leading-relaxed text-muted-foreground",children:p.join(" · ")})]}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"cine-grid absolute inset-0","aria-hidden":!0}),(0,t.jsx)("div",{className:"relative p-4 sm:p-6",children:m&&!s?(0,t.jsx)(at,{zoomFactor:1.8,lensSize:210,children:_}):_}),!s&&(0,t.jsxs)("button",{type:"button",onClick:()=>x(e=>!e),"aria-pressed":m,title:m?"Zoom lens on â hover the plan":"Zoom lens off",className:(0,g.cn)("absolute bottom-3 right-3 inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[0.62rem] font-medium uppercase tracking-[0.14em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",m?"border-primary/50 bg-primary/10 text-primary":"border-border bg-card/80 text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(ae,{className:"size-3"}),"Lens"]})]}),(0,t.jsx)("div",{className:"px-5 sm:px-6",children:(0,t.jsx)(ar.TitleBlockFooter,{project:e.name,date:e.created_at?e.created_at.slice(0,10):void 0,sheet:b?"A-2 · PROPOSED":"A-1 · EXISTING",scale:e.scale_note,meta:[...e.address?[{label:"Site",value:e.address}]:[],...e.human_calibrated?[{label:"Calibration",value:"human-calibrated"}]:[]]})})]})}function a_({doc:e,className:a}){let r=e.rooms.map(e=>{let t=e.area_ft2??(0,an.polygonAreaFt2)(e.poly);return{id:e.id,name:e.name,area:t,perimeter:function(e){let t=0;for(let a=0;a<e.length;a++){let r=e[a],i=e[(a+1)%e.length];t+=Math.hypot(i.x-r.x,i.y-r.y)}return t}(e.poly)}}),i=r.reduce((e,t)=>
1e+t.area,0);return(0,t.jsx)("div",{className:(0,g.cn)("overflow-hidden rounded-xl border border-border bg-card",a),children:(0,t.jsxs)("table",{className:"w-full border-collapse text-sm",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"border-b border-border bg-muted/20 text-left",children:[(0,t.jsx)("th",{scope:"col",className:"caps px-4 py-2.5 text-[0.62rem] font-medium text-muted-foreground",children:"Room"}),(0,t.jsx)("th",{scope:"col",className:"caps px-4 py-2.5 text-right text-[0.62rem] font-medium text-muted-foreground",children:"Area"}),(0,t.jsx)("th",{scope:"col",className:"caps px-4 py-2.5 text-right text-[0.62rem] font-medium text-muted-foreground",children:"Perimeter"})]})}),(0,t.jsx)("tbody",{className:"divide-y divide-border",children:r.map(e=>(0,t.jsxs)("tr",{children:[(0,t.jsx)("td",{className:"px-4 py-2.5 font-medium text-foreground",children:e.name}),(0,t.jsx)("td",{className:"figure-mono px-4 py-2.5 text-right text-foreground",children:(0,t.jsx)(ag,{text:`${e.area.toFixed(1)} ft\xb2`})}),(0,t.jsx)("td",{className:"figure-mono px-4 py-2.5 text-right text-muted-foreground",children:(0,t.jsx)(ag,{text:(0,an.formatFeetInches)(e.perimeter)})})]},e.id))}),r.length>1&&(0,t.jsx)("tfoot",{children:(0,t.jsxs)("tr",{className:"border-t border-border bg-muted/10",children:[(0,t.jsx)("td",{className:"caps px-4 py-2.5 text-[0.62rem] text-muted-foreground",children:"Total"}),(0,t.jsx)("td",{className:"figure-mono px-4 py-2.5 text-right font-semibold text-foreground",children:(0,t.jsx)(ag,{text:`${i.toFixed(1)} ft\xb2`})}),(0,t.jsx)("td",{})]})})]})})}function aj({doc:e,className:a}){let r,i,n,s,o=(r=e.measurement_review,i=e.calibration,n=e.confidence_axes,[(s=t=>{let a="Width"===t?"width":"depth",s="Width"===t?r?.observed_ft?.w??e.bounds_ft.w:r?.observed_ft?.h??e.bounds_ft.h;return{axis:t,ft:s,badge:(i?function(e){switch(e){case"human_measured":return{label:"Human measured",className:"badge-verified",note:"a person taped this wall"};case"ruler_accepted":return{label:"Ruler calibrated",className:"badge-measured",note:"photo-object ruler, user-confirmed"};case"corroborated":return{label:"Corroborated",className:"badge-verified",note:"ruler agrees with the anchor"};case"proportional_estimate":return{label:"Proportional",className:"badge-assumed",note:"scaled from the other axis â disclosed heuristic"};case"preserved":return{label:"Anchor verified",className:"badge-verified",note:"anchor-verified axis, kept as-is"};case"engine":return null}}(i[a].method):null)??function(e){switch(e){case"exact_anchor":return{label:"Measured",className:"badge-measured",note:"fixture anchor spans this wall"};case"lower_bound":return{label:"Lower bound",className:"badge-assumed",note:"at least this long â anchor doesn't span the wall"};case"fixture_run":return{label:"Lower bound",className:"badge-assumed",note:"summed fixture run â at least this long"};case"aspect_prior":return{label:"Assumed",className:"badge-assumed",note:"aspect-prior heuristic for this room type"};case"vlm":return{label:"AI estimate",className:"badge-typical",note:"raw model estimate â no anchor found"};default:return{label:"AI estimate",className:"badge-typical"}}}(r?.estimate_basis?.[a]),confidence:r?.axis_confidence?.[a]??(n?n[a]??null:null)??(r||n?null:e.confidence)}})("Width"),s("Depth")]),l=!!e.calibration&&("proportional_estimate"===e.calibration.width.method||"proportional_estimate"===e.calibration.depth.method);return(0,t.jsxs)("div",{className:(0,g.cn)("rounded-xl border border-border bg-card p-4",a),children:[(0,t.jsx)("p",{className:"caps mb-3 text-xs text-muted-foreground",children:"Measurement provenance"}),(0,t.jsx)("div",{className:"flex flex-col gap-3",children:o.map(e=>(0,t.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:e.axis}),(0,t.jsxs)("span",{className:"figure-mono text-sm text-foreground",children:[null!==e.ft?(0,an.formatFeetInches)(e.ft):"â",null!==e.confidence&&(0,t.jsxs)("span",{className:"ml-2 text-[0.7rem] text-muted-foreground",children:["· ",e.confidence.toFixed(2)]})]})]}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:(0,g.cn)("badge-basis",e.badge.className),children:e.badge.label}),e.badge.note&&(0,t.jsx)("span",{className:"text-right text-[0.65rem] text-muted-foreground",children:e.badge.note})]})]},e.axis))}),l&&(0,t.jsx)("p",{className:"mt-3 border-t border-border pt-2.5 text-[0.65rem] leading-relaxed text-muted-foreground",children:"One axis is a proportional estimate scaled from the other â disclosed, never presented as measured."}),!e.measurement_review&&!e.confidence_axes&&!e.calibration&&(0,t.jsx)("p",{className:"mt-3 border-t border-border pt-2.5 text-[0.65rem] leading-relaxed text-muted-foreground",children:"No per-axis review on this plan â the model-level confidence badge above is the only certainty signal."})]})}let aw={ok:"text-primary",info:"text-muted-foreground",warn:"text-amber-500 dark:text-amber-400",err:"text-destructive"};function ak(){return(0,t.jsxs)("span",{className:"select-none",children:[(0,t.jsx)("span",{className:"text-primary",children:"vizhaus"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:":~$"})," "]})}function aN({command:e,generating:r,startedAt:i,resultLines:n,onDone:s,className:o}
1){let[l,d]=a.useState(0),c=l>=e.length;a.useEffect(()=>{if(c)return;let e=setTimeout(()=>d(e=>e+1),16+22*Math.random());return()=>clearTimeout(e)},[l,c]);let[p,u]=a.useState(()=>Date.now()),m=a.useRef(null);n&&null===m.current&&(m.current=Date.now()),a.useEffect(()=>{if(!r)return;let e=setInterval(()=>u(Date.now()),100);return()=>clearInterval(e)},[r]);let x=Math.max(0,((m.current??p)-i)/1e3),[h,b]=a.useState(0);a.useEffect(()=>{if(!n||!c)return;if(h<n.length){let e=setTimeout(()=>b(e=>e+1),150);return()=>clearTimeout(e)}let e=setTimeout(s,1700);return()=>clearTimeout(e)},[n,c,h,s]);let[v,y]=a.useState(!0);a.useEffect(()=>{let e=setInterval(()=>y(e=>!e),530);return()=>clearInterval(e)},[]);let _=(0,t.jsx)("span",{"aria-hidden":!0,className:(0,g.cn)("ml-0.5 inline-block h-3.5 w-[7px] translate-y-[2px] bg-primary/80 transition-opacity duration-100",!v&&"opacity-0")}),j=null!==n&&h>=n.length;return(0,t.jsxs)(f.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.45,ease:[.22,1,.36,1]},role:"status","aria-live":"polite","aria-label":"Plan generation progress",className:(0,g.cn)("glow-emerald overflow-hidden rounded-2xl border border-border bg-[var(--cine-black,#030305)]",o),children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 border-b border-border bg-card/50 px-4 py-2.5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5","aria-hidden":!0,children:[(0,t.jsx)("span",{className:"size-2.5 rounded-full bg-red-400/70"}),(0,t.jsx)("span",{className:"size-2.5 rounded-full bg-amber-300/70"}),(0,t.jsx)("span",{className:"size-2.5 rounded-full bg-cine-emerald/70"})]}),(0,t.jsx)("span",{className:"flex-1 truncate text-center font-mono text-[0.65rem] text-muted-foreground",children:"vizhaus â plan pipeline"}),(0,t.jsxs)("span",{className:"w-[52px] text-right font-mono text-[0.65rem] tabular-nums text-muted-foreground/70",children:[x.toFixed(1),"s"]})]}),(0,t.jsxs)("div",{className:"min-h-[240px] p-4 font-mono text-xs leading-relaxed sm:p-5",children:[(0,t.jsxs)("div",{className:"whitespace-pre-wrap break-all",children:[(0,t.jsx)(ak,{}),(0,t.jsx)("span",{className:"text-foreground",children:e.slice(0,l)}),!c&&_]}),c&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"mt-1 whitespace-pre-wrap text-muted-foreground/50",children:"# route · upload â image2cad engine â vlm recognize â anchor-derived dims â floorplan_graph.v1 â dxf"}),null===n&&(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-2 text-muted-foreground",children:[(0,t.jsx)("span",{"aria-hidden":!0,className:"inline-block size-3 animate-spin rounded-full border border-primary/60 border-t-transparent"}),(0,t.jsxs)("span",{children:["â image2cad engine · measuring⦠",(0,t.jsxs)("span",{className:"tabular-nums",children:[x.toFixed(1),"s"]})]})]}),n?.slice(0,h).map((e,a)=>(0,t.jsx)("div",{className:(0,g.cn)("mt-1 whitespace-pre-wrap break-words",aw[e.tone]),children:e.text},a)),j&&(0,t.jsxs)("div",{className:"mt-1",children:[(0,t.jsx)(ak,{}),_]})]})]})]})}var aS=e.i(23317);let az=null,a$=new Set,aC={id:"",title:"Renovation Proposal",client:"",created_at:"",updated_at:"",lines:[],heroImageUrl:null,planJson:null,siteGeo:null};function aM(){return az||(az=(0,aS.loadPackage)()??(0,aS.emptyPackage)()),az}function aE(e){return a$.add(e),()=>a$.delete(e)}function aD(e){let t=e(aM());return az=t,(0,aS.savePackage)(t),a$.forEach(e=>e()),t}function aP(){return a.useSyncExternalStore(aE,aM,()=>aC)}var aO=e.i(84389);function aL({doc:e,wholeHome:r=!1}){let[n,s]=a.useState(null),[o,l]=a.useState(!0),[d,c]=a.useState(null),[p,u]=a.useState(!1),m=a.useRef(e);m.current=e,a.useEffect(()=>{let e=new AbortController;return l(!0),c(null),u(!1),fetch("/api/budget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({document:m.current}),signal:e.signal}).then(e=>e.json()).then(e=>{e&&e.ok&&e.budget?(s(e.budget),c(null)):(s(null),c("Budget unavailable â is the cost engine on :8787?")),l(!1)}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||(s(null),c("Budget unavailable â is the cost engine on :8787?"),l(!1))}),()=>e.abort()},[e.id]);let x=aP(),f=a.useMemo(()=>new Set(x.lines.filter(e=>e.id.startsWith("budget-")).map(e=>e.id)),[x.lines]),h=a.useMemo(()=>
1{if(!n)return[];let e=[];return n.rooms.forEach(t=>t.lines.forEach(a=>e.push(`budget-${t.room_id}-${a.element_slug}`))),e},[n]),g=h.length>0&&h.every(e=>f.has(e)),b=p||g,v=a.useCallback(()=>{n&&(aD(e=>{let t={...e,updated_at:new Date().toISOString()};return n.rooms.forEach(e=>e.lines.forEach(a=>{var r,i,n;let s,o,l,d;t=(0,aS.upsertLine)(t,(r=e.room_label,i=e.space_kind,n=e.room_id,s=!a.available||a.low_usd<=0&&a.high_usd<=0,o=a.quantity>0?Math.round(100*a.low_usd/a.quantity):0,l=a.quantity>0?Math.round(100*a.high_usd/a.quantity):0,d=!s&&a.priced_choice&&a.priced_choice.display!==a.material?` \xb7 banded as ${a.priced_choice.display}`:"",{id:`budget-${n}-${a.element_slug}`,element_slug:a.element_slug,display_name:a.display_name,room_type:i,room_label:r,choice_display:a.material,material_choice_slug:a.element_slug,tier:(void 0)??"mid",unit_of_measure:a.unit,quantity:a.quantity,unit_low_cents:s?0:o,unit_high_cents:s?0:l,line_low_usd:s?0:a.low_usd,line_high_usd:s?0:a.high_usd,supplier:(0,aO.consumerSafeSupplierLabel)(a.vendor,`${a.display_name} ${a.material}`),source:s?"priced-on-request":a.source,provenance:`Auto-budget from your measured plan \xb7 ${a.quantity} ${a.unit} (${a.basis})`+(a.homes_count?` \xb7 seen in ${a.homes_count} homes`:"")+d,priced_on_request:s,added_at:new Date().toISOString()}))})),t}),u(!0))},[n]);return(0,t.jsxs)("section",{className:"panel flex flex-col gap-5 p-5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"caps text-xs text-muted-foreground",children:r?n&&n.rooms.length>0?`â Whole-home budget \xb7 ${n.rooms.length} rooms from your measured plan`:"â Whole-home budget · from your measured plan":"â Project budget · from your measured plan"}),o||d||!n?null:"live-curated-engine"===n.source?(0,t.jsx)("span",{className:"inline-flex items-center rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[0.65rem] font-medium text-primary",children:"Live Patten cost engine"}):(0,t.jsx)("span",{className:"inline-flex items-center rounded-full border border-border bg-muted/40 px-2 py-0.5 text-[0.65rem] font-medium text-muted-foreground",children:"Engine offline"})]}),o?(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-3 text-sm text-muted-foreground",children:[(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}),"Pricing your planâ¦"]}):d?(0,t.jsx)("p",{className:"rounded-lg border border-border bg-card px-4 py-3 text-sm text-muted-foreground",children:d}):n?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-3 gap-y-1",children:[(0,t.jsxs)("span",{className:"text-3xl font-bold tracking-tight text-foreground tabular-nums",children:[(0,aS.usdWhole)(n.total_low),"â",(0,aS.usdWhole)(n.total_high)]}),n.priced_on_request>0&&(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:["+",n.priced_on_request," priced on request"]})]}),(0,t.jsx)("div",{className:"flex flex-col gap-3",children:n.rooms.map(e=>(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-3",children:[(0,t.jsx)("span",{className:"text-sm font-semibold text-foreground",children:e.room_label}),(0,t.jsxs)("span",{className:"shrink-0 text-xs text-muted-foreground tabular-nums",children:[e.area_ft2," ft² measured"]})]}),(0,t.jsx)("div",{className:"flex flex-col gap-2.5",children:e.lines.map(e=>(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-2 gap-y-0.5",children:[(0,t.jsx)("span",{className:"text-sm font-semibold text-foreground",children:e.display_name}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:e.material})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:["measured"===e.basis?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[0.6rem] font-medium text-primary",children:[(0,t.jsx)(i.Ruler,{className:"size-3"}),"measured"]}):(0,t.jsx)("span",{className:"inline-flex items-center rounded-full border border-border bg-muted/40 px-2 py-0.5 text-[0.6rem] text-muted-foreground",children:"typical"}),e.vendor&&(0,t.jsx)("span",{className:"inline-flex items-center rounded-full border border-border px-2 py-0.5 text-[0.6rem] text-muted-foreground",children:e.vendor}),"number"==typeof e.homes_count&&e.homes_count>0&&(0,t.jsxs)("span",{className:"inline-flex items-center rounded-full border border-border px-2 py-0.5 text-[0.6rem] text-muted-foreground",children:["seen in ",e.homes_count," home",1===e.homes_count?"":"s"]})]})]}),(0,t.jsxs)("div",{className:"flex shrink-0 flex-col items-end gap-0.5",children:[e.available?(0,t.jsxs)("span",{className:"font-mono text-sm font-semibold text-foreground tabular-nums",children:[(0,aS.usdWhole)(e.low_usd),"â",(0,aS.usdWhole)(e.high_usd)]}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"Priced on request"}),(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground tabular-nums",children:[e.quantity," ",e.unit]})]})]},e.element_slug))}),(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 border-t border-border pt-2.5 text-sm",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:"Subtotal"}),(0,t.jsxs)("span",{className:"font-mono font-semibold text-foreground tabular-nums",children:[(0,aS.usdWhole)(e.subtotal_low),"â",(0,aS.usdWhole)(e.subtotal_high)]})]})]},e.room_id))}),(0,t.jsx)("div",{className:"flex items-center justify-between gap-3",children:(0,t.jsxs)(er.Button,{type:"button",variant:b?"secondary":"default",onClick:v,"aria-pressed":b,disabled:0===n.rooms.length,children:[b?(0,t.jsx)(F.Check,{className:"size-4"}):(0,t.jsx)(O.Plus,{className:"size-4"}),b?"Added â":"Add full budget to proposal"]})})]}):null,(0,t.jsx)("p",{className:"text-[0.65rem] text-muted-foreground",children:"Quantities are derived from your measured plan â floor areas are measured-exact; field-verify before purchase."})]})}var aA=e.i(53880),aR=e.i(51071);function aT({confidence:e,demo:a,className:r}
1){let i=(0,an.confidenceBand)(e),n=Math.round(100*e);return a?(0,t.jsxs)(es,{variant:"outline",className:(0,g.cn)("gap-1.5 rounded-md border-amber-500/40 bg-amber-500/10 px-2.5 py-1 font-medium text-amber-600 dark:text-amber-400",r),children:[(0,t.jsx)(aA.ShieldCheck,{className:"size-3.5"}),(0,t.jsx)("span",{className:"caps text-[0.65rem]",children:"Demo sample"})]}):(0,t.jsxs)(es,{variant:"outline",className:(0,g.cn)("gap-1.5 rounded-md px-2.5 py-1 font-medium","High"===i?"border-primary/40 bg-primary/10 text-primary":"Moderate"===i?"border-accent/50 bg-accent/15 text-accent-foreground":"border-destructive/40 bg-destructive/10 text-destructive",r),children:[(0,t.jsx)(aA.ShieldCheck,{className:"size-3.5"}),(0,t.jsxs)("span",{className:"caps text-[0.65rem]",children:[i," confidence"]}),(0,t.jsxs)("span",{className:"font-mono text-[0.7rem] tabular-nums opacity-80",children:[n,"%"]})]})}function aF({className:e}){return(0,t.jsxs)("div",{className:(0,g.cn)("flex items-start gap-2.5 rounded-md border border-border bg-muted/40 px-3.5 py-3 text-xs leading-relaxed text-muted-foreground",e),children:[(0,t.jsx)(aR.TriangleAlert,{className:"mt-0.5 size-4 shrink-0 text-accent"}),(0,t.jsx)("p",{children:an.FIELD_VERIFY_DISCLAIMER})]})}let aq=(0,n.default)("gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]),aI={High:"border-cine-emerald/50 bg-cine-emerald/10 text-cine-emerald",Moderate:"border-amber-500/50 bg-amber-500/10 text-amber-500",Low:"border-red-500/50 bg-red-500/10 text-red-500",Unverified:"border-border bg-card text-muted-foreground"},aU={stable:"border-cine-emerald/40 text-cine-emerald",noisy:"border-amber-500/40 text-amber-500",single:"border-border text-muted-foreground"};function aW({roomHint:e}){var r;let[i,n]=a.useState(!1),[s,o]=a.useState(null),[l,d]=a.useState(null),[c,p]=a.useState(null),u=a.useRef(null),m=a.useCallback(async()=>{if(u.current){n(!0),d(null);try{let t=new FormData;t.append("file",u.current,u.current.name),t.set("n","3"),t.set("provider","hf"),e&&t.set("room_hint",e);let a=await fetch("/api/plan/consensus",{method:"POST",body:t}),r=await a.json();r.ok?o(r):d(r.error||"Consensus measure failed.")}catch{d("Measurement service unreachable.")}finally{n(!1)}}},[e]),x=s?.measurement_confidence,f=x?null===(r=x.trust_score)?"Unverified":r>=.8?"High":r>=.55?"Moderate":"Low":null;return(0,t.jsxs)("section",{className:"panel flex flex-col gap-4 p-5",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:(0,t.jsx)(aA.ShieldCheck,{className:"size-4"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Verify the measurement · multi-shot consensus"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["We measure your photo ",(0,t.jsx)("strong",{className:"text-foreground",children:"3 times"})," and show the median plus how much it varied â an ",(0,t.jsx)("span",{className:"font-medium text-foreground",children:"honest confidence"}),", not a false-precise number. The thing every AI-measure tool hides, surfaced."]})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("label",{className:"inline-flex cursor-pointer items-center gap-1.5 rounded-md border border-border bg-card px-3 py-2 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(M.ImageUp,{className:"size-3.5"})," ",c?"Change photo":"Choose a room photo",(0,t.jsx)("input",{type:"file",accept:"image/jpeg,image/png,image/webp",className:"hidden",onChange:e=>{let t=e.target.files?.[0]??null;u.current=t,p(t?.name??null),o(null),d(null),e.target.value=""}})]}),c&&(0,t.jsx)("span",{className:"max-w-[12rem] truncate text-[0.7rem] text-muted-foreground",children:c}),(0,t.jsxs)("button",{type:"button",onClick:m,disabled:i||!c,className:"cta-emerald inline-flex items-center gap-2 rounded-md px-3 py-2 text-xs font-semibold text-white active:scale-[0.99] disabled:opacity-60",children:[i?(0,t.jsx)($.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(aq,{className:"size-3.5"}),i?"Measuring 3Ãâ¦":"Verify measurement"]}),(0,t.jsx)("span",{className:"text-[0.65rem] text-muted-foreground",children:"~30s · runs the engine 3 times"})]}),l?(0,t.jsxs)("p",{className:"inline-flex items-center gap-1.5 text-xs text-amber-500",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-3.5"})," ",l]}):null,x&&f?(0,t.jsxs)("div",{className:"flex flex-col gap-3 rounded-lg border border-border bg-card/50 p-4",children:[s?.is_demo_sample&&(0,t.jsxs)("p",{className:"inline-flex items-center gap-1.5 text-[0.7rem] text-amber-500",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-3.5"})," Engine fell back to a demo sample â not your photo."]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex items-baseline gap-2",children:[(0,t.jsxs)("span",{className:"font-mono text-2xl font-semibold text-foreground",children:[(0,an.formatFeetInches)(x.width_ft)," à ",(0,an.formatFeetInches)(x.depth_ft)]}),(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:["median of ",x.n_shots," shots"]})]}),(0,t.jsxs)("span",{className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-semibold ${aI[f]}`,children:[(0,t.jsx)(aA.ShieldCheck,{className:"size-3.5"})," ",null===x.trust_score?"Trust unverified · single shot":`Trust ${(100*x.trust_score).toFixed(0)}% \xb7 ${f}`]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1.5 text-[0.72rem] sm:grid-cols-3",children:[(0,t.jsx)(aB,{k:"Width spread",v:"single"!==x.reproducibility?`\xb1${(x.spread_w_in/2).toFixed(1)}â³`:"1 shot · not measured"}),(0,t.jsx)(aB,{k:"Depth spread",v:"single"!==x.reproducibility?`\xb1${(x.spread_d_in/2).toFixed(1)}â³`:"1 shot · not measured"}),(0,t.jsx)(aB,{k:"Reproducibility",v:(0,t.jsx)("span",{className:`rounded border px-1.5 py-0.5 text-[0.62rem] font-semibold uppercase ${aU[x.reproducibility]}`,children:x.reproducibility})}),(0,t.jsx)(aB,{k:"Area (median)",v:`${x.area_ft2} ft\xb2`}),(0,t.jsx)(aB,{k:"Width range",v:"single"!==x.reproducibility?`${(0,an.formatFeetInches)(x.width_range_ft[0])}â${(0,an.formatFeetInches)(x.width_range_ft[1])}`:"â"}),(0,t.jsx)(aB,{k:"Model conf.",v:`${(100*x.model_confidence).toFixed(0)}%`})]}),s?.note&&(0,t.jsx)("p",{className:"text-[0.7rem] leading-relaxed text-muted-foreground",children:s.note})]}):null]})}function aB({k:e,v:a}){return(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:e}),(0,t.jsx)("span",{className:"font-mono text-foreground",children:a})]})}var aG=e.i(79422);function aH(e,t){return Math.hypot(t.x-e.x,t.y-e.y)}function aV(e,t,a){return{x:e.x+(t.x-e.x)*a,y:e.y+(t.y-e.y)*a}}function aK(e,t,a){let r=a.x-t.x,i=a.y-t.y,n=r*r+i*i;
1if(0===n)return{d:aH(e,t),t:0};let s=((e.x-t.x)*r+(e.y-t.y)*i)/n;return s=Math.max(0,Math.min(1,s)),{d:aH(e,{x:t.x+r*s,y:t.y+i*s}),t:s}}function aX(e,t){let a=aK(e.a,t.a,t.b),r=aK(e.b,t.a,t.b);return a.d<=.35&&r.d<=.35}function aY(e){if(0===e.length)return null;let t=1/0,a=1/0,r=-1/0,i=-1/0;for(let n of e)for(let e of[n.a,n.b])t=Math.min(t,e.x),a=Math.min(a,e.y),r=Math.max(r,e.x),i=Math.max(i,e.y);return{x0:t,y0:a,x1:r,y1:i}}function aJ(e){if(0===e.length)return null;let t=1/0,a=1/0,r=-1/0,i=-1/0;for(let n of e)t=Math.min(t,n.x),a=Math.min(a,n.y),r=Math.max(r,n.x),i=Math.max(i,n.y);return{x0:t,y0:a,x1:r,y1:i}}function aQ(e,t){let a=e,r=2;for(;t.has(a);)a=`${e}-${r++}`;return t.add(a),a}function aZ(e){return Math.round(100*e)/100}let a0=["ROOMS","WALLS","WALLS-REMOVED","WALLS-PROPOSED","OPENINGS","FIXTURES","FIXTURES-PROPOSED","DIMS","NOTES"],a1=e=>String(Math.round(1e3*e)/1e3);function a2(e,t,a,r,i){e.push("0","LINE","8",t,"10",a1(a.x),"20",a1(i(a.y)),"30","0","11",a1(r.x),"21",a1(i(r.y)),"31","0")}function a5(e,t,a,r,i,n){let s=i.replace(/[\r\n]+/g," ").trim();s&&e.push("0","TEXT","8",t,"10",a1(a.x),"20",a1(n(a.y)),"30","0","40",a1(r),"1",s)}function a3(e,t,a,r,i){if(!(a.length<2)){for(let n of(e.push("0","POLYLINE","8",t,"66","1","70",r?"1":"0"),a))e.push("0","VERTEX","8",t,"10",a1(n.x),"20",a1(i(n.y)),"30","0");e.push("0","SEQEND")}}function a4(e,t="existing"){let a,r=(a=e.bounds_ft.h,e=>a-e),i=[];for(let e of(i.push("0","SECTION","2","HEADER","9","$INSUNITS","70","2","0","ENDSEC"),i.push("0","SECTION","2","TABLES","0","TABLE","2","LAYER","70",String(a0.length)),a0)){let t="WALLS-REMOVED"===e?"1":e.endsWith("PROPOSED")?"2":"7";i.push("0","LAYER","2",e,"70","0","62",t,"6","CONTINUOUS")}for(let t of(i.push("0","ENDTAB","0","ENDSEC"),i.push("0","SECTION","2","ENTITIES"),e.rooms)){a3(i,"ROOMS",t.poly,!0,r);let e=(0,an.polygonCentroid)(t.poly),a=t.area_ft2??(0,an.polygonAreaFt2)(t.poly);a5(i,"ROOMS",{x:e.x,y:e.y},.5,`${t.name} (${a.toFixed(0)} SF)`,r)}for(let t of e.walls)a2(i,"removed"===t.status?"WALLS-REMOVED":"proposed"===t.status?"WALLS-PROPOSED":"WALLS",t.a,t.b,r);for(let t of e.openings)a2(i,"OPENINGS",t.a,t.b,r),a5(i,"OPENINGS",{x:(t.a.x+t.b.x)/2,y:(t.a.y+t.b.y)/2},.25,t.kind.toUpperCase(),r);for(let t of e.fixtures){let e="proposed"===t.status?"FIXTURES-PROPOSED":"FIXTURES",{x:a,y:n,w:s,h:o}=t.bbox_ft;a3(i,e,[{x:a,y:n},{x:a+s,y:n},{x:a+s,y:n+o},{x:a,y:n+o}],!0,r),a5(i,e,{x:a+s/2,y:n+o/2},.3,t.label,r)}for(let t of e.dimensions){a2(i,"DIMS",t.a,t.b,r);let e=Math.hypot(t.b.x-t.a.x,t.b.y-t.a.y);a5(i,"DIMS",{x:(t.a.x+t.b.x)/2,y:(t.a.y+t.b.y)/2},.35,t.label??(0,an.formatFeetInches)(e),r)}let n="proposed"===t?`${e.name} - PROPOSED (not yet field-verified)`:`${e.name} - EXISTING (measured)`;return a5(i,"NOTES",{x:0,y:e.bounds_ft.h+1.2},.6,n,r),a5(i,"NOTES",{x:0,y:e.bounds_ft.h+2},.35,"AI concept documentation - field-verify before building",r),i.push("0","ENDSEC","0","EOF"),i.join("\n")+"\n"}function a6({doc:e,samples:r,activeSampleId:i,onSelectSample:n,generated:s,artifacts:l,error:d,generating:c,hasUpload:p,photo:u,onSelectPhoto:m,onGenerate:x,onGenerateFromPhoto:h,onImportPlan:g,onOpenSite:v,homeRoomCount:y=0,canAddRoomToHome:_=!1,roomInHome:j=!1,onAddRoomToHome:w,onClearHome:k}){let N=(0,b.usePrefersReducedMotion)(),S="__generated__"===i,M="__home__"===i,E=!!(S&&l&&(l.dxf||l.dxfUrl)),[D,L]=a.useState(!1),[A,R]=a.useState([]),[T,F]=a.useState("existing"),[q,I]=a.useState(!1),U=e.id;a.useEffect(()=>{R([]),F("existing"),I(!1)},[U]);let W=a.useMemo(()=>(function(e,t){if(0===t.length)return{doc:e,notes:[]};let a=[],r=new Map;for(let e of t)"wall_status"===e.kind&&r.set(e.wall_id,e.status);let i={...e,walls:e.walls.map(e=>r.has(e.id)?{...e,status:r.get(e.id)}:e),fixtures:[...e.fixtures]};for(let[e,t]of r)"removed"===t?a.push(`Wall ${e} â remove (open the wall)`):"proposed"===t&&a.push(`Wall ${e} â proposed new wall`);if(t.some(e=>"add_island"===e.kind)){let t=function(e,t){let a=structuredClone(e),r=function(e){let t=new Set;for(let a of e.walls)t.add(a.id);for(let a of e.openings)t.add(a.id);for(let a of e.fixtures)t.add(a.id);for(let a of e.dimensions)t.add(a.id);for(let a of e.rooms)t.add(a.id);return t}(a),i=[],n=[],s=null;for(let[e,o]of t.entries())switch(o.kind){case"open_wall":n.push(function(e,t,a,r,i,n){let{wall:s,how:o}=function(e,t){let a=e.walls.filter(e=>(e.status??"active")!=="removed");if(t?.open_wall_id){let e=a.find(e=>e.id===t.open_wall_id)??null;return{wall:e,how:e?"wall specified by the caller":`wall "${t.open_wall_id}" not found`}}if(0===a.length)return{wall:null,how:"the plan has no walls"};let r=aY(e.walls),i=new Set(a.filter(t=>e.openings.some(e=>"window"===e.kind&&aX(e,t))).map(e=>e.id)),n=(e,t)=>aH(t.a,t.b)-aH(e.a,e.b),s=r?a.filter(e=>{let t;return!((t=(e,t,a,r)=>.35>=Math.abs(a(e)-r)&&.35>=Math.abs(a(t)-r))(e.a,e.b,e=>e.x,r.x0)||t(e.a,e.b,e=>e.x,r.x1)||t(e.a,e.b,e=>e.y,r.y0)||t(e.a,e.b,e=>e.y,r.y1))}):[],o=s.filter(e=>!i.has(e.id)).sort(n);if(o.length>0)return{wall:o[0],how:"auto-selected: longest interior windowless wall"};if(s.length>0)return{wall:s.sort(n)[0],how:"auto-selected: longest interior wall (carries a window â verify)"};let l=a.filter(e=>!i.has(e.id)).sort(n);return l.length>0?{wall:l[0],how:"auto-selected: longest windowless envelope wall â a one-photo plan only sees this room, so the shared wall to the adjacent space is ASSUMED; confirm which wall adjoins before demolition"}:{wall:a.sort(n)[0],how:"auto-selected: longest wall (every wall carries a window â verify)"}}(e,r);if(!s)return{move:t,move_index:a,applied:!1,mutation:"none",target_ids:[],basis:"assumed",note:`open_wall dropped â ${o}.`};let l=aH(s.a,s.b);if(l<4)return{move:t,move_index:a,applied:!1,mutation:"none",target_ids:[],basis:t.basis,note:`open_wall dropped â wall ${s.id} is ${(0,an.formatFeetInches)(l)} long, below the ${(0,an.formatFeetInches)(4)} a cased opening needs. Not forced.`};let d=Math.min(l-2,10),c="wide cased opening";d<3&&(d=3,c="doorway-sized cased opening");let p=(l-d)/2,u=p<.4,m=u?0:p/l,x=u?1:(p+d)/l,f=aV(s.a,s.b,m),h=aV(s.a,s.b,x),g=u?l:d,b=[],v=[];e.openings=e.openings.filter(e=>{let t,a;if(!aX(e,s))return!0;let r=(t=aK(e.a,s.a,s.b).t,{t0:Math.min(t,a=aK(e.b,s.a,s.b).t),t1:Math.max(t,a)});return!(r.t0>
1=m-.35/l)||!(r.t1<=x+.35/l)||("window"===e.kind?(v.push(e.id),!0):(b.push(e.id),!1))});let y=[],_=[];for(let t of e.walls){if(t.id!==s.id){_.push(t);continue}if(u)_.push({...t,status:"removed"}),y.push(s.id);else{let e=aQ(`${s.id}__stub_a`,i),t=aQ(`${s.id}__stub_b`,i);_.push({id:e,a:{...s.a},b:f,thickness_ft:s.thickness_ft,status:s.status??"active"}),_.push({id:s.id,a:f,b:h,thickness_ft:s.thickness_ft,status:"removed"}),_.push({id:t,a:h,b:{...s.b},thickness_ft:s.thickness_ft,status:s.status??"active"}),y.push(e,s.id,t)}}e.walls=_;let j=aQ(`${s.id}__opening`,i);e.openings.push({id:j,kind:"cased",a:f,b:h}),y.push(j);let w=Math.abs(s.b.y-s.a.y)<=Math.abs(s.b.x-s.a.x),k=aY(e.walls),N=aV(f,h,.5),S=w?k&&N.y-k.y0<k.y1-N.y?"top":"bottom":k&&N.x-k.x0<k.x1-N.x?"left":"right",z=aQ(`${s.id}__opening_dim`,i);e.dimensions.push({id:z,a:f,b:h,side:S,offset_ft:1}),y.push(z),v.length>0&&n.push(`open_wall: window(s) ${v.join(", ")} sit inside the opened span of ${s.id} â kept in the plan and flagged, never silently deleted. Resolve before demolition.`);let $=[`Opened a ${(0,an.formatFeetInches)(g)} ${c} in wall ${s.id} (${(0,an.formatFeetInches)(l)} segment`+(u?", full-span removal":`, ${(0,an.formatFeetInches)(p)} stubs each end`)+")",o,b.length>0?`absorbed existing opening(s) ${b.join(", ")} into the new span`:null,"measured"===t.basis?"span sized from the measured wall geometry":"plan geometry is assumed (no measured plan grounded this move)","load path / structural adequacy needs field verification by a licensed professional"].filter(Boolean);return{move:t,move_index:a,applied:!0,mutation:"wall_opening",target_ids:y,basis:t.basis,note:$.join(" â ")+"."}}(a,o,e,void 0,r,i));break;case"add_island":{let t=function(e,t,a,r,i){let{room:n,matchedKind:s,how:o}=function(e,t){if(t?.island_room_id){let a=e.rooms.find(e=>e.id===t.island_room_id)??null;return{room:a,matchedKind:null!=a,how:a?"room specified by the caller":`room "${t.island_room_id}" not found`}}let a=(0,aG.inferSpaceKind)(t?.room_kind??"kitchen"),r=e=>{let t=aJ(e.poly);return t?(t.x1-t.x0)*(t.y1-t.y0):0},i=e.rooms.filter(e=>(0,aG.inferSpaceKind)(e.name)===a).sort((e,t)=>r(t)-r(e));if(i.length>0)return{room:i[0],matchedKind:!0,how:`largest measured ${a} room`};let n=[...e.rooms].sort((e,t)=>r(t)-r(e));return n.length>0?{room:n[0],matchedKind:!1,how:`no ${a} room in the plan â placed in the largest room (verify)`}:{room:null,matchedKind:!1,how:"the plan has no rooms"}}(e,r),l=n?aJ(n.poly):null,d=o,c=s&&null!=n;if(!l)if(!(e.bounds_ft.w>0)||!(e.bounds_ft.h>0))return{move:t,move_index:a,applied:!1,mutation:"none",target_ids:[],basis:"assumed",note:`add_island dropped â ${o} and the document has no usable bounds. Not forced.`};else l={x0:0,y0:0,x1:e.bounds_ft.w,y1:e.bounds_ft.h},d=`${o}; placed against the document bounds (no room polygon)`,c=!1;let p=l.x1-l.x0,u=l.y1-l.y0,m=p>=u?"x":"y",x=Math.min(7,Math.max(p,u)-7),f=Math.min(3.5,Math.min(p,u)-7);if(x<4.5||f<2)return{move:t,move_index:a,applied:!1,mutation:"none",target_ids:[],basis:c?"measured":"assumed",note:`add_island dropped â the ${(0,an.formatFeetInches)(p)} \xd7 ${(0,an.formatFeetInches)(u)} room cannot hold a ${(0,an.formatFeetInches)(4.5)} \xd7 ${(0,an.formatFeetInches)(2)} island with 42" clearances on every side (${d}). Not forced.`};let h="x"===m?x:f,g="x"===m?f:x,b=(l.x0+l.x1)/2,v=(l.y0+l.y1)/2,y=aQ("island__proposed",i),_=x<7-1e-9||f<3.5-1e-9,j={id:y,kind:"island",label:`PROPOSED ISLAND ${(0,an.formatFeetInches)(x)} \xd7 ${(0,an.formatFeetInches)(f)}`,bbox_ft:{x:aZ(b-h/2),y:aZ(v-g/2),w:aZ(h),h:aZ(g)}};e.fixtures.push(j);let w=c&&"measured"===t.basis?"measured":"assumed",k=[`Placed a ${(0,an.formatFeetInches)(x)} \xd7 ${(0,an.formatFeetInches)(f)} proposed island centered in the room`+(_?` (scaled down from the ${(0,an.formatFeetInches)(7)} default to keep 42" clearances)`:""),d,'clearances are computed against the room envelope, not existing perimeter cabinetry â confirm 42" working aisles against the actual cabinet faces',"assumed"===w?"sizing is assumed pending a measured plan of this room":"sizing grounded on the measured room polygon"];return{move:t,move_index:a,applied:!0,mutation:"island_fixture",target_ids:[y],basis:w,note:k.join(" â ")+"."}}(a,o,e,void 0,r);t.applied&&(s=t.target_ids[0]??null),n.push(t);break}case"waterfall_island":n.push(function(e,t,a,r){let i=r&&e.fixtures.find(e=>e.id===r)||e.fixtures.find(e=>"island"===e.kind)||null;if(!i)return{move:t,move_index:a,applied:!1,mutation:"none",target_ids:[],basis:"assumed",note:"waterfall_island dropped â no island fixture in the plan to waterfall (add_island first, or draw one)."};/WATERFALL/i.test(i.label)||(i.label=`${i.label} \xb7 WATERFALL ENDS`);let n=Math.min(i.bbox_ft.w,i.bbox_ft.h);return{move:t,move_index:a,applied:!0,mutation:"island_annotation",target_ids:[i.id],basis:t.basis,note:`Annotated island ${i.id} counter spec: stone waterfalls down BOTH ends â adds two ~36" end panels (${(0,an.formatFeetInches)(n)} deep) to the countertop takeoff basis. No geometry change.`}}(a,o,e,s));break;default:n.push({move:o,move_index:e,applied:!1,mutation:"none",target_ids:[],basis:o.basis,note:`${o.kind} is a finish move â it re-dresses surfaces in the render; no plan-geometry change.`})}for(let e of n.filter(e=>e.move.structural&&!e.applied))i.push(`Structural move dropped (disclosed): ${e.note}`);return{schema:"design_moves.v1",graph:a,applied:n,notes:i}}(i,[{kind:"add_island",summary:"Add a kitchen island",structural
1:!0,basis:e.measurement_review||e.human_calibrated||e.calibration?"measured":"assumed"}]),r=t.applied[0];if(r?.applied){let e=new Set(r.target_ids);i={...t.graph,fixtures:t.graph.fixtures.map(t=>e.has(t.id)?{...t,status:"proposed"}:t)}}else i=t.graph;r?.note&&a.push(r.note),a.push(...t.notes)}return{doc:i,notes:a}})(e,A),[e,A]),B=A.some(e=>"add_island"===e.kind||"wall_status"===e.kind&&"active"!==e.status),G=B?W.doc:null,H=a.useCallback(t=>{R(a=>{let r=e.walls.find(e=>e.id===t)?.status??"active",i=a.find(e=>"wall_status"===e.kind&&e.wall_id===t),n=function(e){switch(e??"active"){case"active":return"removed";case"removed":return"proposed";default:return"active"}}(i&&"wall_status"===i.kind?i.status:r),s=a.filter(e=>"wall_status"!==e.kind||e.wall_id!==t);return n===r?s:[...s,{kind:"wall_status",wall_id:t,status:n}]}),F("proposed")},[e]),V=a.useCallback(()=>{R(e=>e.some(e=>"add_island"===e.kind)?e:[...e,{kind:"add_island",id:"island-proposed"}]),F("proposed"),I(!0)},[]),K=a.useCallback(()=>{R([]),F("existing"),I(!1)},[]),X=a.useCallback(()=>{if(!G)return;let t=new Blob([a4(G,"proposed")],{type:"application/dxf"}),a=URL.createObjectURL(t),r=document.createElement("a");r.href=a,r.download=`${e.id}.proposed.dxf`,r.click(),URL.revokeObjectURL(a)},[G,e.id]),Y=a.useRef("vizhaus plan --photo upload --engine image2cad"),[J,Q]=a.useState(null),Z=a.useRef(!1);a.useEffect(()=>{!c||Z.current||N||Q({command:Y.current,startedAt:Date.now()}),Z.current=!!c},[c,N]);let ee=a.useMemo(()=>x?e=>{Y.current=`vizhaus plan --home ${e.home} --room ${e.room} --provider ${e.provider} --engine image2cad`,x(e)}:void 0,[x]),et=a.useMemo(()=>h?e=>{Y.current=`vizhaus plan --photo upload --provider ${e} --engine image2cad`,h(e)}:void 0,[h]),ea=a.useMemo(()=>g?e=>{Y.current=`vizhaus plan import --file ${e.name}`,g(e)}:void 0,[g]),ei=a.useMemo(()=>{if(!J||c)return null;if(d)return[{text:`â ${d}`,tone:"err"}];if(!S||!e)return[{text:"â request settled â no plan returned",tone:"info"}];let t=[{text:`â floorplan_graph.v1 \xb7 ${e.rooms.length} room${1===e.rooms.length?"":"s"} \xb7 ${(0,an.formatFeetInches)(e.bounds_ft.w)} \xd7 ${(0,an.formatFeetInches)(e.bounds_ft.h)}`,tone:"ok"}];return l?.vlmModel&&t.push({text:`â vlm ${l.vlmProvider||l.provider}/${l.vlmModel}`,tone:"ok"}),l?.source&&t.push({text:`â source ${l.source}`,tone:"info"}),t.push({text:`â model confidence ${e.confidence.toFixed(2)}`,tone:"info"}),l&&(l.dxf||l.dxfUrl)&&t.push({text:`â dxf ready \xb7 ${l.dxfFilename||`${e.id}.dxf`}`,tone:"ok"}),l?.isDemoSample&&t.push({text:"â demo sample â calibrated example, not your photo",tone:"warn"}),t},[J,c,d,S,e,l]),en=a.useCallback(()=>Q(null),[]),es=a.useCallback(async()=>{L(!0);try{let t=await fetch("/api/spatial",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({document:e})}),a=await t.json();a.ok&&a.id&&window.open(`/report/${a.id}`,"_blank","noopener,noreferrer")}catch{}finally{L(!1)}},[e]),[eo,el]=a.useState(!1),ed=a.useCallback(async()=>{el(!0);try{let t=await fetch("/api/spatial",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({document:e})}),a=await t.json();a.ok&&a.id&&window.open(`/ar/${a.id}`,"_blank","noopener,noreferrer")}catch{}finally{el(!1)}},[e]),ec=()=>{if(E&&l){if(l.dxf){let t=new Blob([l.dxf],{type:"application/dxf"}),a=URL.createObjectURL(t),r=document.createElement("a");r.href=a,r.download=l.dxfFilename||`${e.id}.dxf`,r.click(),URL.revokeObjectURL(a)}else l.dxfUrl&&window.open(l.dxfUrl,"_blank","noopener,noreferrer");return}let t=new Blob([a4(e,"existing")],{type:"application/dxf"}),a=URL.createObjectURL(t),r=document.createElement("a");r.href=a,r.download=`${e.id}.dxf`,r.click(),URL.revokeObjectURL(a)};return(0,t.jsxs)(f.motion.div,{...(0,b.fadeUp)(N),className:"flex flex-col gap-8",children:[(0,t.jsx)(z,{line:!0,step:"Step 01",kicker:"Measure",title:"The measured plan",action:(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(aT,{confidence:e.confidence,demo:S&&!!l?.isDemoSample}),(0,t.jsxs)(er.Button,{variant:"outline",size:"sm",onClick:ec,title:E?"Download the engine's measured (EXISTING) DXF":"Download the EXISTING sheet as DXF â written locally from the plan graph",children:[(0,t.jsx)(tY.FileDown,{className:"size-3.5"}),"DXF · Existing"]}),(0,t.jsxs)(er.Button,{variant:"outline",size:"sm",onClick:X,disabled:!B,title:B?"Download the PROPOSED-variant DXF (working copy)":"Edit a wall or add an island to create a proposal",children:[(0,t.jsx)(tY.FileDown,{className:"size-3.5"}),"DXF · Proposed"]}),(0,t.jsxs)(er.Button,{variant:"outline",size:"sm",onClick:()=>{let t=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),a=URL.createObjectURL(t),r=document.createElement("a");r.href=a,r.download=`${e.id}.floorplan_graph.v1.json`,r.click(),URL.revokeObjectURL(a)},children:[(0,t.jsx)(P.Download,{className:"size-3.5"}),"JSON"]})]}),blurb:"Photo in, dimensioned plan out â rooms, fixtures, openings, and per-edge dimension strings in feet-inches, every figure wearing its basis. Upload right here, run the engine, then open a wall or drop an island on the living sheet."}),m&&(0,t.jsx)(tC,{photo:u??null,onSelect:m,hint:"Drop a room photo â the engine measures it into a dimensioned plan."}),(0,t.jsx)(a7,{generating:!!c,hasUpload:!!p,onGenerate:ee,onGenerateFromPhoto:et,onImportPlan:ea}),d&&(0,t.jsxs)("div",{className:"flex items-start gap-2.5 rounded-md border border-destructive/40 bg-destructive/5 px-3.5 py-3 text-sm text-destructive",children:[(0,t.jsx)(C.AlertTriangle,{className:"mt-0.5 size-4 shrink-0"}),(0,t.jsx)("span",{children:d})]}),S&&l?.isDemoSample&&(0,t.jsxs)("div",{className:"flex items-start gap-2.5 rounded-md border border-amber-500/40 bg-amber-500/5 px-3.5 py-3 text-sm text-amber-700 dark:text-amber-400",children:[(0,t.jsx)(C.AlertTriangle,{className:"mt-0.5 size-4 shrink-0"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{children:"Demo sample (6215 Anita · Bath 3)"})," â this is a calibrated example plan, not your photo. Upload a room and run the engine to generate a measured plan from your image."]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"caps text-xs text-muted-foreground",children:"Source"}),y>0&&(0,t.jsxs)(re,{active:M,onClick:()=>n("__home__"),children:[(0,t.jsx)(t2,{className:"mr-1 inline size-3"}
1),"Home plan · ",y," room",1===y?"":"s"]}),s&&(0,t.jsx)(re,{active:"__generated__"===i,onClick:()=>n("__generated__"),children:"Generated"}),r.map(e=>(0,t.jsx)(re,{active:i===e.id,onClick:()=>n(e.id),children:e.name},e.id))]}),J&&!N?(0,t.jsx)(aN,{command:J.command,generating:!!c,startedAt:J.startedAt,resultLines:ei,onDone:en},J.startedAt):(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-6",children:[(0,t.jsx)(ay,{doc:e,proposedDoc:G,view:T,onViewChange:F,editing:q,onToggleEditing:()=>I(e=>!e),onWallClick:H,onAddIsland:V,onResetProposal:K,proposalNotes:W.notes}),(0,t.jsxs)("div",{className:"grid gap-6 lg:grid-cols-[minmax(0,1fr)_300px]",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("span",{className:"caps text-xs text-muted-foreground",children:"Room schedule"}),(0,t.jsx)(a_,{doc:e})]}),(0,t.jsxs)("aside",{className:"flex flex-col gap-5",children:[(0,t.jsx)(aj,{doc:e}),S&&l&&(l.vlmModel||l.source)&&(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-card p-4",children:[(0,t.jsx)("p",{className:"caps mb-3 text-xs text-muted-foreground",children:"Engine"}),(0,t.jsxs)("dl",{className:"flex flex-col gap-2 text-sm",children:[l.vlmModel&&(0,t.jsx)(rt,{label:"VLM",value:`${l.vlmProvider||l.provider}/${l.vlmModel}`,mono:!0}),l.source&&(0,t.jsx)(rt,{label:"Source",value:l.source,mono:!0}),(l.dxf||l.dxfUrl)&&(0,t.jsxs)("button",{type:"button",onClick:ec,className:"mt-1 inline-flex items-center gap-1.5 rounded-sm text-xs font-medium text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",children:[(0,t.jsx)(tY.FileDown,{className:"size-3.5"}),"Download CAD (DXF)"]})]})]}),(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-card p-4",children:[(0,t.jsx)("p",{className:"caps mb-3 text-xs text-muted-foreground",children:"Legend"}),(0,t.jsx)(t7,{doc:e,className:"flex-col items-start gap-2.5"})]}),(0,t.jsx)(aF,{})]})]})]}),(0,t.jsxs)("div",{className:"grid gap-4 sm:grid-cols-3",children:[(0,t.jsx)(a8,{icon:(0,t.jsx)(t4,{className:"size-4"}),title:"Spatial report",blurb:"Dimensioned plan + per-room data table â a printable PDF reference with CSV/SVG/DXF exports.",action:(0,t.jsxs)(er.Button,{onClick:es,disabled:D,size:"sm",className:"w-full",children:[D?(0,t.jsx)($.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(t4,{className:"size-3.5"}),D?"Buildingâ¦":"Generate report"]})}),(0,t.jsx)(a8,{icon:(0,t.jsx)(t6.Box,{className:"size-4"}),title:"Cast in 3D · AR",blurb:"Extrude the measured plan to GLB + USDZ and walk the room at real scale on any phone or iPad. Beta.",action:(0,t.jsxs)(er.Button,{onClick:ed,disabled:eo,size:"sm",variant:"outline",className:"w-full",children:[eo?(0,t.jsx)($.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(t6.Box,{className:"size-3.5"}),eo?"Buildingâ¦":"Cast in 3D"]})}),(0,t.jsx)(a8,{icon:(0,t.jsx)(o,{className:"size-4"}),title:"Magic site plan",blurb:"Lay out a to-scale site plan from lot dimensions â drag the pool, then generate a photoreal aerial.",action:(0,t.jsxs)(er.Button,{variant:"outline",size:"sm",onClick:v,disabled:!v,className:"w-full",children:["Open the Site pillar",(0,t.jsx)(t0.ArrowRight,{className:"size-3.5"})]})})]}),(w||y>0)&&(0,t.jsxs)("section",{className:"panel flex flex-col gap-4 p-5",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:(0,t.jsx)(t3,{className:"size-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Whole-home bid package"}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Add each room's measured plan to build one whole-home bid â then the budget below prices every room."})]})]}),y>0&&(0,t.jsxs)("span",{className:"inline-flex shrink-0 items-center gap-1 rounded-full border border-primary bg-primary/10 px-2.5 py-1 text-[0.65rem] font-medium text-primary",children:[(0,t.jsx)(t2,{className:"size-3"}
1),y," room",1===y?"":"s"," in plan"]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)(er.Button,{type:"button",size:"sm",onClick:w,disabled:!_||!w,title:_?"Add this measured room to your whole-home bid":j?"This room is already in your home plan":"Generate or import a measured plan from your photo first",children:[(0,t.jsx)(O.Plus,{className:"size-3.5"}),j?"Already in home plan":y>0?"Add this room to home plan":"Start a whole-home bid with this room"]}),y>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(er.Button,{type:"button",variant:"outline",size:"sm",onClick:()=>n("__home__"),disabled:M,children:[(0,t.jsx)(t2,{className:"size-3.5"}),"View home plan"]}),(0,t.jsxs)(er.Button,{type:"button",variant:"ghost",size:"sm",onClick:k,disabled:!k,children:[(0,t.jsx)(t5.X,{className:"size-3.5"}),"Clear"]})]})]}),!_&&0===y&&(0,t.jsx)("p",{className:"text-[0.7rem] text-muted-foreground",children:"Generate a measured plan from your uploaded photo (above), then add it here. Repeat for each room to assemble the whole home."}),M&&(0,t.jsx)("p",{className:"text-[0.7rem] text-muted-foreground",children:"Showing your whole-home plan â every added room, laid out on one sheet. The budget below is priced per room."})]}),(0,t.jsx)(aW,{}),(0,t.jsx)(aL,{doc:e,wholeHome:M&&y>1})]})}function a8({icon:e,title:a,blurb:r,action:i}){return(0,t.jsxs)("section",{className:"panel flex flex-col gap-3 p-5",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:e}),(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:a})]}),(0,t.jsx)("p",{className:"flex-1 text-xs leading-relaxed text-muted-foreground",children:r}),i]})}function a7({generating:e,hasUpload:r,onGenerate:i,onGenerateFromPhoto:n,onImportPlan:s}){let[o,l]=a.useState("6215-anita"),[d,c]=a.useState("bath3"),[p,u]=a.useState("hf");
1return(0,t.jsxs)("div",{className:"flex flex-col gap-4 rounded-lg border border-border bg-card p-5",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:(0,t.jsx)(tJ,{className:"size-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"Generate a measured plan"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["Photo â conceptual floorplan via"," ",(0,t.jsx)("code",{className:"font-mono text-[0.7rem]",children:"/api/plan"})," â ",(0,t.jsx)("code",{className:"font-mono text-[0.7rem]",children:"image2cad"}),"."]})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"caps text-[0.65rem] text-muted-foreground",children:"Provider"}),(0,t.jsx)(a9,{active:"hf"===p,onClick:()=>u("hf"),icon:(0,t.jsx)(tQ,{className:"size-3"}),children:"Fast · hf"}),(0,t.jsx)(a9,{active:"zai"===p,onClick:()=>u("zai"),icon:(0,t.jsx)(tZ.Target,{className:"size-3"}),children:"Accurate · zai"}),(0,t.jsx)("span",{className:"text-[0.7rem] text-muted-foreground",children:"hf"===p?"Qwen2.5-VL-72B, ~6â10s":"GLM-4.5V, ~50s, richest fixtures"})]}),(0,t.jsxs)(er.Button,{onClick:()=>{n&&!e&&n(p)},disabled:e||!r,size:"lg",className:"w-full",children:[e?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(M.ImageUp,{className:"size-4"}),e?"Measuring your photoâ¦":"Generate from your uploaded photo"]}),!r&&(0,t.jsx)("p",{className:"-mt-1.5 text-[0.7rem] text-muted-foreground",children:"Upload a room photo (Transform tab or the picker) to measure your own space â or load a calibrated sample below."}),(0,t.jsxs)("details",{className:"group rounded-md border border-border bg-card/60",children:[(0,t.jsxs)("summary",{className:"flex cursor-pointer list-none items-center justify-between px-3.5 py-2.5 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)("span",{className:"caps",children:"Advanced · load a calibrated sample room"}),(0,t.jsx)(T,{className:"size-4 transition-transform group-open:rotate-180"})]}),(0,t.jsxs)("div",{className:"grid gap-3 border-t border-border p-3.5 sm:grid-cols-[1fr_1fr_auto] sm:items-end",children:[(0,t.jsxs)("label",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)("span",{className:"caps text-[0.65rem] text-muted-foreground",children:"Home"}),(0,t.jsx)(t8.Input,{value:o,onChange:e=>l(e.target.value),placeholder:"6215-anita",spellCheck:!1})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1.5",children:[(0,t.jsx)("span",{className:"caps text-[0.65rem] text-muted-foreground",children:"Room"}),(0,t.jsx)(t8.Input,{value:d,onChange:e=>c(e.target.value),placeholder:"bath3",spellCheck:!1})]}),(0,t.jsxs)(er.Button,{onClick:()=>{i&&!e&&i({home:o.trim()||"6215-anita",room:d.trim()||"bath3",provider:p})},disabled:e,variant:"outline",size:"lg",className:"shrink-0",children:[e?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(tJ,{className:"size-4"}),"Load sample"]})]})]}),s&&(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border border-dashed border-border px-3.5 py-2.5",children:[(0,t.jsxs)("span",{className:"text-[0.7rem] text-muted-foreground",children:["Have a LiDAR / Polycam scan? Import a measured"," ",(0,t.jsx)("code",{className:"font-mono text-[0.65rem]",children:"floorplan_graph.v1"}),"."]}),(0,t.jsxs)("label",{className:"inline-flex shrink-0 cursor-pointer items-center gap-1.5 rounded-md border border-border bg-card px-2.5 py-1 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(t1.Upload,{className:"size-3.5"})," Import .json",(0,t.jsx)("input",{type:"file",accept:"application/json,.json",className:"hidden",onChange:e=>{let t=e.target.files?.[0];t&&s(t),e.target.value=""}})]})]})]})}function a9({active:e,onClick:a,icon:r,children:i}){return(0,t.jsxs)("button",{type:"button",onClick:a,className:(0,g.cn)("inline-flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",e?"border-primary bg-primary/10 text-primary":"border-border bg-card text-muted-foreground hover:text-foreground"),children:[r,i]})}function re({active:e,onClick:a,children:r}){return(0,t.jsx)("button",{type:"button",onClick:a,className:(0,g.cn)("rounded-md border px-3 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",e?"border-primary bg-primary/10 text-primary":"border-border bg-card text-muted-foreground hover:text-foreground"),children:r})}function rt({label:e,value:a,mono:r}){return(0,t.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:e}),(0,t.jsx)("dd",{className:(0,g.cn)("text-right text-foreground",r&&"font-mono text-xs break-all"),children:a})]})}var ra=e.i(3352),rr=e.i(78823);let ri=(0,n.default)("badge-check",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),rn=(0,n.default)("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]),rs=(0,n.default)("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);var ro=e.i(53100);let rl=({children:e,className:a,containerClassName:r,animate:i=!0})=>{let n={initial:{backgroundPosition:"0 50%"},animate:{backgroundPosition:["0, 50%","100% 50%","0 50%"]}};return(0,t.jsxs)("div",{className:(0,g.cn)("relative p-[4px] group",r),children:[(0,t.jsx)(f.motion.div,{variants:i?n:void 0,initial:i?"initial":void 0,animate:i?"animate":void 0,transition:i?{duration:5,repeat:1/0,repeatType:"reverse"}:void 0,style:{backgroundSize:i?"400% 400%":void 0},className:(0,g.cn)("absolute inset-0 rounded-3xl z-[1] opacity-60 group-hover:opacity-100 blur-xl transition duration-500 will-change-transform"," bg-[radial-gradient(circle_farthest-side_at_0_100%,#00ccb1,transparent),radial-gradient(circle_farthest-side_at_100%_0,#7b61ff,transparent),radial-gradient(circle_farthest-side_at_100%_100%,#ffc414,transparent),radial-gradient(circle_farthest-side_at_0_0,#1ca0fb,#141316)]")}),(0,t.jsx)(f.motion.div,{variants:i?n:void 0,initial:i?"initial":void 0,animate:i?"animate":void 0,transition:i?{duration:5,repeat:1/0,repeatType:"reverse"}:void 0,style:{backgroundSize:i?"400% 400%":void 0},className:(0,g.cn)("absolute inset-0 rounded-3xl z-[1] will-change-transform","bg-[radial-gradient(circle_farthest-side_at_0_100%,#00ccb1,transparent),radial-gradient(circle_farthest-side_at_100%_0,#7b61ff,transparent),radial-gradient(circle_farthest-side_at_100%_100%,#ffc414,transparent),radial-gradient(circle_farthest-side_at_0_0,#1ca0fb,#141316)]")}),(0,t.jsx)("div",{className:(0,g.cn)("relative z-10",a),children:e})]})};var rd=a.forwardRef((e,a)=>(0,t.jsx)(ep.label,{...e,ref:a,onMouseDown:t=>{t.target.closest("button, input, select, textarea")||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));rd.displayName="Label",e.s(["Label",0,rd,"Root",0,rd],18530);var rc=e.i(18530),rc=rc;function rp({className:e,...a}){return(0,t.jsx)(rc.Root,{"data-slot":"label",className:(0,g.cn)("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...a})}var ru=e.i(3673),rm=e.i(5714);let rx={kitchen:"Kitchen",primary_bath:"Primary Bath",secondary_bath:"Secondary Bath",bathroom_secondary:"Secondary Bath",powder:"Powder",whole_home:"Whole Home",dining:"Dining",living:"Living",laundry:"Laundry",exterior:"Exterior",exterior_envelope:"Exterior",exterior_outdoor:"Landscape"};function rf(e){return rx[e]??e.replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function rh(e){return e.replace(/_/g," ")}function rg(e){let t=(e??"").toLowerCase().trim(),a={white:"#f5f3ee","natural white oak":"#caa472","white oak":"#caa472",oak:"#caa472",wood:"#b88a52",walnut:"#6b4a2f",brass:"#c19e4c",gold:"#c19e4c","champagne bronze":"#b9926a",bronze:"#9c7248",nickel:"#aeb4b8",chrome:"#c7ccd0",black:"#2b2d31",matte_black:"#26282c",grey:"#9aa0a6",gray:"#9aa0a6",marble:"#eceae4",porcelain:"#eef0f2",ceramic:"#f0eee9",quartz:"#f1efe9"};if(a[t])return a[t];for(let e of Object.keys(a))if(t.includes(e))return a[e];return"#d9d4c9"}function rb(e,t,a){fetch("/api/recommend/feedback",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({selection_id:e,signal:t,room_type:a})}).catch(()=>{})}function rv({room:e}){let[r,i]=a.useState([]),[n,s]=a.useState(0),[o,l]=a.useState(!0),[d,c]=a.useState(!1),[p,u]=a.useState(new Set),[m,x]=a.use
1State({}),f=aP(),h=a.useMemo(()=>new Set(f.lines.map(e=>e.id)),[f.lines]);a.useEffect(()=>{let t=new AbortController;return l(!0),c(!1),fetch(`/api/recommend?room_type=${encodeURIComponent(e)}&limit=6`,{signal:t.signal}).then(e=>e.json()).then(e=>{i(Array.isArray(e.recommendations)?e.recommendations:[]),s("number"==typeof e.count?e.count:0),c(!!e.offline),l(!1)}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||(i([]),s(0),c(!0),l(!1))}),()=>t.abort()},[e]);let b=a.useCallback(e=>p.has(e.id)||h.has(`rec-${e.id}`),[p,h]),v=a.useCallback(t=>{aD(e=>{let a,r,i,n,s,o,l;return(0,aS.upsertLine)({...e,updated_at:new Date().toISOString()},(a=t.price_unit??"each",r=function(e,t){if("each"===t)return 1;let a=e.toLowerCase();return a.includes("shower")?120:a.includes("backsplash")?32:a.includes("counter")?54:a.includes("floor")?220:a.includes("wall")?200:"linear_feet"===t?28:100}(t.surface,a),i=t.consumer_low_cents??0,n=t.consumer_high_cents??0,s=i<=0&&n<=0,o=t.material_signature||t.example_product||`${t.material_type} ${t.surface}`,l=encodeURIComponent(`${t.vendor??""} ${t.example_product??t.material_signature}`.trim()),{id:`rec-${t.id}`,element_slug:`rec-${t.id}`,display_name:`${rh(t.surface)} â ${t.material_type}`,room_type:t.room_type,room_label:rf(t.room_type),choice_display:o,material_choice_slug:t.example_sku??`rec-${t.id}`,tier:"mid",unit_of_measure:a,quantity:r,unit_low_cents:i,unit_high_cents:n,line_low_usd:s?0:Math.round(i/100*r),line_high_usd:s?0:Math.round(n/100*r),supplier:t.vendor??"designer-curated",source:"demo-example",provenance:`${t.curation_note} \xb7 seen in ${t.homes_count} homes`,priced_on_request:s,curated:{swatch:rg(t.color),vendor:t.vendor??"Patten-curated",vendor_sku:t.example_sku??"â",affiliate_url:t.vendor?`https://www.google.com/search?q=${l}`:"#",appears_in_homes:t.homes_count},added_at:new Date().toISOString()}))}),u(e=>{let a=new Set(e);return a.add(t.id),a}),rb(t.id,"purchased",e)},[e]),y=a.useCallback((t,a)=>{x(e=>({...e,[t.id]:a})),rb(t.id,a,e)},[e]);return(0,t.jsxs)("section",{className:"panel flex flex-col gap-4 p-5",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)("span",{className:"caps text-xs text-muted-foreground",children:["â Designer recommends · for the ",rf(e)]}),(0,t.jsx)("span",{className:"text-[0.7rem] text-muted-foreground",children:"from Patten's curated multi-home history"})]}),o?(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-3 text-sm text-muted-foreground",children:[(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}),"Loading designer picksâ¦"]}):d?(0,t.jsx)("p",{className:"rounded-lg border border-border bg-card px-4 py-3 text-sm text-muted-foreground",children:"Designer engine offline â start it on :8787 to see curated picks."}):0===n||0===r.length?(0,t.jsx)("p",{className:"rounded-lg border border-border bg-card px-4 py-3 text-sm text-muted-foreground",children:"No curated picks for this room yet."}):(0,t.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:r.map(e=>{let a=e.consumer_low_cents??0,r=e.consumer_high_cents??0,i=m[e.id],n=b(e);return(0,t.jsxs)("article",{className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{style:{background:rg(e.color)},className:"mt-0.5 size-4 shrink-0 rounded-[4px] border border-border"}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col",children:[(0,t.jsx)("span",{className:"truncate text-sm font-semibold text-foreground",children:e.material_signature}),(0,t.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:rh(e.surface)})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"inline-flex items-center rounded-full border border-border px-2 py-0.5 text-[0.65rem] text-muted-foreground",children:["seen in ",e.homes_count," home",1===e.homes_count?"":"s"]}),e.confidence&&(0,t.jsx)("span",{className:"caps inline-flex items-center rounded-full border border-border bg-muted/40 px-2 py-0.5 text-[0.6rem] text-muted-foreground",children:e.confidence})]}),(0,t.jsx)("span",{className:"text-sm text-foreground",children:a>0&&r>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"font-semibold",children:[(0,aS.usdWhole)(a/100),"â",(0,aS.usdWhole)(r/100)]}),(0,t.jsxs)("span",{className:"text-muted-foreground",children:[" / ",e.price_unit??"unit"]})]}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"Priced on request"})}),(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(e.vendor||e.example_sku)&&(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[e.vendor,e.vendor&&e.example_sku?" · ":"",e.example_sku]}),e.curation_note&&(0,t.jsx)("span",{className:"text-[0.7rem] text-muted-foreground",children:e.curation_note})]}),(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-2",children:[(0,t.jsxs)(er.Button,{type:"button",size:"sm",variant:n?"secondary":"default",className:"flex-1",onClick:()=>v(e),"aria-pressed":n,children:[n?(0,t.jsx)(F.Check,{className:"size-3.5"}):(0,t.jsx)(O.Plus,{className:"size-3.5"}),n?"Added â":"Add to proposal"]}),(0,t.jsx)(er.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"Like this pick","aria-pressed":"liked"===i,onClick:()=>y(e,"liked"),className:(0,g.cn)("liked"===i&&"text-primary"),children:(0,t.jsx)(ru.ThumbsUp,{
1className:"size-4"})}),(0,t.jsx)(er.Button,{type:"button",size:"icon-sm",variant:"ghost","aria-label":"Dislike this pick","aria-pressed":"disliked"===i,onClick:()=>y(e,"disliked"),className:(0,g.cn)("disliked"===i&&"text-foreground"),children:(0,t.jsx)(rm.ThumbsDown,{className:"size-4"})})]})]},e.id)})}),(0,t.jsx)("p",{className:"text-[0.65rem] text-muted-foreground",children:"Your picks train the engine · attributed to claude-4.8-orchestrator"})]})}let ry=(0,n.default)("chevron-up",[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]]);function r_(e,t){return e?`https://www.google.com/search?q=${encodeURIComponent(`${e} ${t}`)}`:"#"}function rj(e,t){return e>0&&t>0?`${(0,aS.usdWhole)(e/100)}â${(0,aS.usdWhole)(t/100)}`:"Priced on request"}function rw({room:e}){let[r,i]=a.useState([]),[n,s]=a.useState(!0),[o,l]=a.useState(!1),[d,c]=a.useState(new Set),[p,u]=a.useState({}),[m,x]=a.useState(new Set),[f,h]=a.useState({}),g=a.useRef({}),b=aP(),v=a.useMemo(()=>{let e={};for(let t of b.lines){let a=/^look-(\d+)-/.exec(t.id);if(a){let t=Number(a[1]);e[t]=(e[t]??0)+1}}return e},[b.lines]);a.useEffect(()=>{let t=new AbortController;return s(!0),l(!1),fetch(`/api/looks?room_type=${encodeURIComponent(e)}&limit=6`,{signal:t.signal}).then(e=>e.json()).then(e=>{i(Array.isArray(e.looks)?e.looks:[]),l(!!e.offline),s(!1)}).catch(e=>{e instanceof DOMException&&"AbortError"===e.name||(i([]),l(!0),s(!1))}),()=>t.abort()},[e]);let y=a.useCallback(async e=>{let t=g.current[e.id];if(t)return t;try{let t=await fetch(`/api/look?id=${e.id}`),a=await t.json();if(!a.look)return null;return g.current={...g.current,[e.id]:a.look},u(g.current),a.look}catch{return null}},[]),_=a.useCallback(e=>{c(t=>{let a=new Set(t);return a.has(e.id)?a.delete(e.id):(a.add(e.id),y(e)),a})},[y]),j=a.useCallback(async e=>{let t=await y(e);t&&(aD(e=>{let a={...e,updated_at:new Date().toISOString()};return t.materials.forEach((e,r)=>{let i,n,s;a=(0,aS.upsertLine)(a,(i=e.est_low_cents??0,n=e.est_high_cents??0,s=i<=0&&n<=0,{id:`look-${t.id}-${r}`,element_slug:`look-${t.id}-${e.surface}`,display_name:`${rh(e.surface)} â ${e.trade}`,room_type:t.room_type,room_label:rf(t.room_type),choice_display:e.material,material_choice_slug:`${e.trade}-${e.material}`.replace(/\s+/g,"-").toLowerCase(),tier:"mid",unit_of_measure:"each",quantity:1,unit_low_cents:i,unit_high_cents:n,line_low_usd:s?0:Math.round(i/100),line_high_usd:s?0:Math.round(n/100),supplier:t.vendors||"designer-curated",source:"demo-example",provenance:`${t.look_
1name} \xb7 coordinated palette \xb7 ${t.confidence} confidence`,priced_on_request:s,curated:{swatch:rg(e.material),vendor:t.vendors||"Patten-curated",vendor_sku:"â",affiliate_url:r_(t.vendors,e.material),appears_in_homes:1},added_at:new Date().toISOString()}))}),a}),x(t=>{let a=new Set(t);return a.add(e.id),a}))},[y]),w=a.useCallback(async e=>{try{let t=await fetch(`/api/home?slug=${encodeURIComponent(e.home)}`),a=(await t.json()).home;if(!a||!Array.isArray(a.looks))return;aD(e=>{let t={...e,updated_at:new Date().toISOString()};return a.looks.forEach(e=>{let a,r,i;t=(0,aS.upsertLine)(t,(a=e.est_total_low_cents??0,r=e.est_total_high_cents??0,i=a<=0&&r<=0,{id:`lookroom-${e.id}`,element_slug:`lookroom-${e.id}`,display_name:e.look_name,room_type:e.room_type,room_label:rf(e.room_type),choice_display:`${e.hero_signature} \xb7 ${e.n_elements} elements`,material_choice_slug:`look-${e.id}`,tier:"mid",unit_of_measure:"each",quantity:1,unit_low_cents:a,unit_high_cents:r,line_low_usd:i?0:Math.round(a/100),line_high_usd:i?0:Math.round(r/100),supplier:e.vendors||"designer-curated",source:"demo-example",provenance:`Coordinated room look \xb7 ${e.n_elements} elements`,priced_on_request:i,curated:{swatch:rg(e.hero_signature),vendor:e.vendors||"Patten-curated",vendor_sku:"â",affiliate_url:r_(e.vendors,e.hero_signature),appears_in_homes:1},added_at:new Date().toISOString()}))}),t}),h(t=>({...t,[e.id]:a}))}catch{}},[]),k=a.useCallback(e=>p[e.id]?.materials.length??v[e.id]??0,[p,v]),N=a.useCallback(e=>m.has(e.id)||(v[e.id]??0)>0,[m,v]);return(0,t.jsxs)("section",{className:"panel flex flex-col gap-4 p-5",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsxs)("span",{className:"caps text-xs text-muted-foreground",children:["â Shop the look · ",rf(e)]}),(0,t.jsx)("span",{className:"text-[0.7rem] text-muted-foreground",children:"coordinated designer palettes â the whole room, priced together"})]}),n?(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-3 text-sm text-muted-foreground",children:[(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}),"Loading coordinated looksâ¦"]}):o?(0,t.jsx)("p",{className:"rounded-lg border border-border bg-card px-4 py-3 text-sm text-muted-foreground",children:"Designer engine offline â start it on :8787 to see coordinated looks."}):0===r.length?(0,t.jsx)("p",{className:"rounded-lg border border-border bg-card px-4 py-3 text-sm text-muted-foreground",children:"No coordinated looks for this room yet."}):(0,t.jsx)("div",{className:"grid gap-3 sm:grid-cols-2",children:r.map(e=>{let a,r,i=d.has(e.id),n=p[e.id],s=N(e),o=f[e.id],l=k(e);return(0,t.jsxs)("article",{className:"flex flex-col gap-3 rounded-lg border border-border bg-card p-4",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("span",{style:{background:rg(e.hero_signature)},className:"mt-0.5 size-4 shrink-0 rounded-[4px] border border-border"}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-col",children:[(0,t.jsx)("span",{className:"truncate text-sm font-semibold text-foreground",children:e.look_name}),(0,t.jsx)("span",{className:"truncate text-xs text-muted-foreground",children:e.hero_signature})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"inline-flex items-center rounded-full border border-border px-2 py-0.5 text-[0.65rem] text-muted-foreground",children:[e.n_elements," elements"]}),e.confidence&&(0,t.jsx)("span",{className:"caps inline-flex items-center rounded-full border border-border bg-muted/40 px-2 py-0.5 text-[0.6rem] text-muted-foreground",children:e.confidence}),e.vendors&&(0,t.jsx)("span",{className:"inline-flex max-w-full items-center truncate rounded-full border border-border px-2 py-0.5 text-[0.65rem] text-muted-foreground",children:e.vendors})]}),(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-2 rounded-md border border-border bg-muted/30 px-3 py-2",children:[(0,t.jsx)("span",{className:"caps text-[0.6rem] text-muted-foreground",children:"coordinated total"}),(0,t.jsx)("span",{className:"text-sm font-semibold text-foreground",children:rj(e.est_total_low_cents,e.est_total_high_cents)})]}),i&&(0,t.jsx)("div",{className:"flex flex-col gap-1.5 rounded-md border border-border bg-muted/20 p-3",children:n?0===n.materials.length?(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"No materials in this palette."}):n.materials.map((a,r)=>
1(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs",children:[(0,t.jsx)("span",{style:{background:rg(a.material)},className:"size-3 shrink-0 rounded-[3px] border border-border"}),(0,t.jsx)("span",{className:"shrink-0 text-muted-foreground",children:rh(a.surface)}),(0,t.jsx)("span",{className:"min-w-0 flex-1 truncate text-foreground",children:a.material}),(0,t.jsx)("span",{className:"shrink-0 text-foreground",children:rj(a.est_low_cents,a.est_high_cents)})]},`${e.id}-${a.surface}-${r}`)):(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,t.jsx)($.Loader2,{className:"size-3.5 animate-spin"}),"Loading paletteâ¦"]})}),(0,t.jsxs)("div",{className:"mt-1 flex items-center gap-2",children:[(0,t.jsxs)(er.Button,{type:"button",size:"sm",variant:"outline",onClick:()=>_(e),"aria-expanded":i,children:[i?(0,t.jsx)(ry,{className:"size-3.5"}):(0,t.jsx)(T,{className:"size-3.5"}),"View palette"]}),(0,t.jsxs)(er.Button,{type:"button",size:"sm",variant:s?"secondary":"default",className:"flex-1",onClick:()=>void j(e),"aria-pressed":s,children:[s?(0,t.jsx)(F.Check,{className:"size-3.5"}):(0,t.jsx)(O.Plus,{className:"size-3.5"}),s?`Added â (${l} items)`:"Add whole look"]})]}),(0,t.jsxs)(er.Button,{type:"button",size:"sm",variant:"secondary",className:"w-full",onClick:()=>void w(e),children:[(0,t.jsx)(t2,{className:"size-3.5"}),"Shop the whole home"]}),o&&(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-border bg-muted/20 px-3 py-2 text-xs text-muted-foreground",children:[(0,t.jsx)(F.Check,{className:"size-3.5 shrink-0"}),(0,t.jsxs)("span",{className:"min-w-0",children:["Added whole home · ",o.rooms," rooms · ",(a=o.home_total_low_cents,r=o.home_total_high_cents,null==a||null==r||a<=0&&r<=0?"priced on request":`${(0,aS.usdWhole)(a/100)}â${(0,aS.usdWhole)(r/100)}`)]})]})]},e.id)})}),(0,t.jsx)("p",{className:"text-[0.65rem] text-muted-foreground",children:"Coordinated palettes from Patten's curated multi-home history · 229 room looks"})]})}let rk=[{element_slug:"kitchen_countertop",display_name:"Kitchen Countertop",room_type:"kitchen",trade_slugs:["countertop"],default_unit_of_measure:"sqft",default_quantity:54,prompt_hint:"kitchen perimeter countertops"},{element_slug:"kitchen_island",display_name:"Kitchen Island",room_type:"kitchen",trade_slugs:["countertop","cabinet"],default_unit_of_measure:"sqft",default_quantity:30,prompt_hint:"kitchen island countertop",notes:"Composite â cabinet base + countertop top."},{element_slug:"kitchen_backsplash",display_name:"Kitchen Backsplash",room_type:"kitchen",trade_slugs:["tile"],default_unit_of_measure:"sqft",default_quantity:32,prompt_hint:"kitchen backsplash tile"},{element_slug:"kitchen_floor",display_name:"Kitchen Floor",room_type:"kitchen",trade_slugs:["flooring","tile"],default_unit_of_measure:"sqft",default_quantity:220,prompt_hint:"kitchen flooring"},{element_slug:"kitchen_cabinet_run",display_name:"Kitchen Cabinet Run",room_type:"kitchen",trade_slugs:["cabinet"],default_unit_of_measure:"linear_feet",default_quantity:28,prompt_hint:"kitchen cabinetry"},{element_slug:"primary_bath_floor",display_name:"Primary Bath Floor",room_type:"primary_bath",trade_slugs:["tile","flooring"],default_unit_of_measure:"sqft",default_quantity:90,prompt_hint:"primary bath floor tile"},{element_slug:"primary_bath_shower_walls",display_name:"Primary Bath Shower Walls",room_type:"primary_bath",trade_slugs:["tile"],default_unit_of_measure:"sqft",default_quantity:120,prompt_hint:"primary bath shower wall tile"},{element_slug:"primary_bath_shower_floor",display_name:"Primary Bath Shower Floor",room_type:"primary_bath",trade_slugs:["tile"],default_unit_of_measure:"sqft",default_quantity:16,prompt_hint:"primary bath shower floor tile"},{element_slug:"primary_bath_vanity",display_name:"Primary Bath Vanity",room_type:"primary_bath",trade_slugs:["cabinet","countertop","plumbing_fixture"],default_unit_of_measure:"each",default_quantity:1,prompt_hint:"primary bath vanity",notes:"Composite â base cabinet + countertop + lav sink + faucet."}
1,{element_slug:"secondary_bath_shower",display_name:"Secondary Bath Shower",room_type:"bathroom_secondary",trade_slugs:["tile"],default_unit_of_measure:"sqft",default_quantity:90,prompt_hint:"secondary bath shower tile"},{element_slug:"secondary_bath_vanity",display_name:"Secondary Bath Vanity",room_type:"bathroom_secondary",trade_slugs:["cabinet","countertop","plumbing_fixture"],default_unit_of_measure:"each",default_quantity:1,prompt_hint:"secondary bath vanity"},{element_slug:"powder_vanity",display_name:"Powder Vanity",room_type:"powder",trade_slugs:["cabinet","countertop","plumbing_fixture"],default_unit_of_measure:"each",default_quantity:1,prompt_hint:"powder room vanity"},{element_slug:"whole_home_floor",display_name:"Whole Home Flooring",room_type:"whole_home",trade_slugs:["flooring"],default_unit_of_measure:"sqft",default_quantity:2600,prompt_hint:"main flooring"},{element_slug:"whole_home_recessed",display_name:"Whole Home Recessed Cans",room_type:"whole_home",trade_slugs:["lighting"],default_unit_of_measure:"each",default_quantity:40,prompt_hint:"recessed can lighting"},{element_slug:"whole_home_exterior_brick",display_name:"Whole Home Exterior Brick",room_type:"exterior_envelope",trade_slugs:["siding"],default_unit_of_measure:"sqft",default_quantity:2400,prompt_hint:"exterior brick"},{element_slug:"kitchen_pendant_pair",display_name:"Kitchen Pendant Pair",room_type:"kitchen",trade_slugs:["lighting"],default_unit_of_measure:"each",default_quantity:2,prompt_hint:"kitchen island pendant lights"},{element_slug:"cabinet_hardware_pulls",display_name:"Cabinet Hardware Pulls",room_type:"whole_home",trade_slugs:["hardware"],default_unit_of_measure:"each",default_quantity:40,prompt_hint:"cabinet hardware"},{element_slug:"trim_package",display_name:"Trim Package",room_type:"whole_home",trade_slugs:["finish-trim"],default_unit_of_measure:"linear_feet",default_quantity:1800,prompt_hint:"interior trim"},{element_slug:"framing_lumber_package",display_name:"Framing Lumber Package",room_type:"whole_home",trade_slugs:["lumber"],default_unit_of_measure:"linear_feet",default_quantity:9e3,prompt_hint:"framing lumber"},{element_slug:"landscape_sod",display_name:"Landscape Sod",room_type:"exterior_outdoor",trade_slugs:["landscaping"],default_unit_of_measure:"sqft",default_quantity:3e3,prompt_hint:"sod"}],rN=[{material_choice_slug:"granite",choice_display:"Granite (slab)",trade_slug:"countertop",category_path:"countertop/stone/granite",tier:"mid",unit_of_measure:"sqft",supplier_pool:["solid-stone"],consumer_unit_low_cents:6500,consumer_unit_high_cents:9200,evidence_count:80,real_projects_used_in:9},{material_choice_slug:"quartz_generic",choice_display:"Quartz (Generic)",trade_slug:"countertop",category_path:"countertop/quartz/generic",tier:"mid",unit_of_measure:"sqft",supplier_pool:["solid-stone"],consumer_unit_low_cents:6900,consumer_unit_high_cents:8600,evidence_count:1910,real_projects_used_in:24},{material_choice_slug:"quartz_msi",choice_display:"Quartz â MSI",trade_slug:"countertop",category_path:"countertop/quartz/msi",tier:"mid",unit_of_measure:"sqft",supplier_pool:["solid-stone"],consumer_unit_low_cents:7400,consumer_unit_high_cents:9200,evidence_count:220,real_projects_used_in:11},{material_choice_slug:"soapstone",choice_display:"Soapstone",trade_slug:"countertop",category_path:"countertop/stone/soapstone",tier:"luxury",unit_of_measure:"sqft",supplier_pool:["solid-stone"],consumer_unit_low_cents:10200,consumer_unit_high_cents:12700,evidence_count:36,real_projects_used_in:7},{material_choice_slug:"quartz_cambria",choice_display:"Quartz â Cambria",trade_slug:"countertop",category_path:"countertop/quartz/cambria",tier:"luxury",unit_of_measure:"sqft",supplier_pool:["solid-stone"],consumer_unit_low_cents:9500,consumer_unit_high_cents:12200,evidence_count:64,real_projects_used_in:8},{material_choice_slug:"marble_calacatta",choice_display:"Marble â Calacatta",trade_slug:"countertop",category_path:"countertop/stone/marble/calacatta",tier:"luxury",unit_of_measure:"sqft",supplier_pool:["solid-stone"],consumer_unit_low_cents:11800,consumer_unit_high_cents:16500,evidence_count:140,real_projects_used_in:12},{material_choice_slug:"sink_cutout",choice_display:"Polished Sink Cutout (labor add)",trade_slug:"countertop",category_path:"countertop
1/labor/sink_cutout",tier:"mid",unit_of_measure:"each",supplier_pool:["solid-stone"],consumer_unit_low_cents:12500,consumer_unit_high_cents:27e3,evidence_count:60,real_projects_used_in:18},{material_choice_slug:"ceramic",choice_display:"Ceramic Tile",trade_slug:"tile",category_path:"tile/ceramic",tier:"budget",unit_of_measure:"sqft",supplier_pool:["bedrosians","daltile","prosource"],consumer_unit_low_cents:850,consumer_unit_high_cents:1400,evidence_count:88,real_projects_used_in:19},{material_choice_slug:"porcelain",choice_display:"Porcelain Tile",trade_slug:"tile",category_path:"tile/porcelain",tier:"mid",unit_of_measure:"sqft",supplier_pool:["bedrosians","daltile","eleganza-tiles"],consumer_unit_low_cents:1100,consumer_unit_high_cents:1900,evidence_count:64,real_projects_used_in:17},{material_choice_slug:"natural_stone",choice_display:"Natural Stone Tile",trade_slug:"tile",category_path:"tile/stone",tier:"luxury",unit_of_measure:"sqft",supplier_pool:["bedrosians","daltile","metro-brick"],consumer_unit_low_cents:1800,consumer_unit_high_cents:3400,evidence_count:22,real_projects_used_in:9},{material_choice_slug:"mosaic",choice_display:"Mosaic Tile",trade_slug:"tile",category_path:"tile/mosaic",tier:"mid",unit_of_measure:"sqft",supplier_pool:["bedrosians","daltile"],consumer_unit_low_cents:1600,consumer_unit_high_cents:2900,evidence_count:31,real_projects_used_in:11},{material_choice_slug:"engineered_oak",choice_display:"Engineered Oak Plank",trade_slug:"flooring",category_path:"flooring/wood/engineered/oak",tier:"mid",unit_of_measure:"sqft",supplier_pool:[],consumer_unit_low_cents:900,consumer_unit_high_cents:1500,evidence_count:10,real_projects_used_in:6},{material_choice_slug:"solid_oak",choice_display:"Solid Oak Plank",trade_slug:"flooring",category_path:"flooring/wood/solid/oak",tier:"luxury",unit_of_measure:"sqft",supplier_pool:[],consumer_unit_low_cents:1400,consumer_unit_high_cents:2200,evidence_count:8,real_projects_used_in:5},{material_choice_slug:"lvt",choice_display:"LVT (Luxury Vinyl Tile)",trade_slug:"flooring",category_path:"flooring/vinyl/lvt",tier:"mid",unit_of_measure:"sqft",supplier_pool:[],consumer_unit_low_cents:550,consumer_unit_high_cents:950,evidence_count:9,real_projects_used_in:5},{material_choice_slug:"shaker_paint_grade",choice_display:"Shaker (Paint Grade)",trade_slug:"cabinet",category_path:"cabinet/paint_grade/shaker",tier:"mid",unit_of_measure:"linear_feet",supplier_pool:[],consumer_unit_low_cents:28e3,consumer_unit_high_cents:42e3,evidence_count:33,real_projects_used_in:10},{material_choice_slug:"white_oak",choice_display:"White Oak (rift / qtr-sawn)",trade_slug:"cabinet",category_path:"cabinet/wood/oak/white",tier:"luxury",unit_of_measure:"linear_feet",supplier_pool:[],consumer_unit_low_cents:42e3,consumer_unit_high_cents:68e3,evidence_count:21,real_projects_used_in:7},{material_choice_slug:"kohler_kitchen_faucet",choice_display:"Kohler Kitchen Faucet",trade_slug:"plumbing_fixture",category_path:"fixture/plumbing/kitchen/faucet/kohler",tier:"mid",unit_of_measure:"each",supplier_pool:["ferguson","jarrell-co"],consumer_unit_low_cents:32e3,consumer_unit_high_cents:62e3,evidence_count:412,real_projects_used_in:22},{material_choice_slug:"kohler_toilet",choice_display:"Kohler Toilet",trade_slug:"plumbing_fixture",category_path:"fixture/plumbing/toilet/kohler",tier:"mid",unit_of_measure:"each",supplier_pool:["ferguson","facets-home"],consumer_unit_low_cents:45e3,consumer_unit_high_cents:78e3,evidence_count:180,real_projects_used_in:20},{material_choice_slug:"brizo_bath",choice_display:"Brizo Bath / Lav Trim",trade_slug:"plumbing_fixture",category_path:"fixture/plumbing/bath/brizo",tier:"luxury",unit_of_measure:"each",supplier_pool:["ferguson","jarrell-co"],consumer_unit_low_cents:38e3,consumer_unit_high_cents:92e3,evidence_count:70,real_projects_used_in:12},{material_choice_slug:"visual_comfort_pendant",choice_display:"Visual Comfort Pendant",trade_slug:"lighting",category_path:"fixture/lighting/pendant/visual_comfort",tier:"luxury",unit_of_measure:"each",supplier_pool:["visual-comfort"],consumer_unit_low_cents:45e3,consumer_unit_high_cents:13e4,evidence_count:70,real_projects_used_in:14},{material_choice_slug:"recessed_can",choice_display:"Recessed Can Light",trade_slug:"lighting",category_path:"fixture/lighting/recessed",tier:"budget",unit_of_measure:"each",supplier_pool:[],consumer_unit_low_cents:6500,consumer_unit_high_cents:12e3,evidence_count:40,real_projects_used_in:18},{material_choice_slug:"cabinet_pull",choice_display:"Cabinet Pull",trade_slug:"hardware",category_path:"hardware/cabinet/pull",tier:"mid",unit_of_measure:"each",supplier_pool:[],consumer_unit_low_cents:1800,consumer_unit_high_cents:4800,evidence_count:524,real_projects_used_in:20},{material_choice_slug:"brick",choice_display:"Brick (modular)",trade_slug:"siding",category_path:"siding/masonry/brick",tier:"mid",unit_of_measure:"sqft",supplier_pool:["metro-brick"],consumer_unit_low_cents:1400,consumer_unit_high_cents:2400,evidence_count:67,real_projects_used_in:10},{material_choice_slug:"sod",choice_display:"Sod",trade_slug:"landscaping",category_path:"landscape/sod",tier:"budget",unit_of_measure:"sqft",supplier_pool:["turfhub"],consumer_unit_low_cents:150,consumer_unit_high_cents:320,evidence_count:123,real_projects_used_in:8},{material_choice_slug:"dim_2x4",choice_display:"Dimensional 2x4",trade_slug:"lumber",category_path:"lumber/dim/2x4",tier:"budget",unit_of_measure:"linear_feet",supplier_pool:["84-lumber"],consumer_unit_low_cents:180,consumer_unit_high_cents:320,evidence_count:73,real_projects_used_in:9}],rS=[{id:"della-terra-calacatta-bellatrix",name:"Della Terra Calacatta Bellatrix",vendor:"Arizona Tile",vendor_sku:"CQ-7721",material_type:"Polished quartz",prompt_snippet:"polished Calacatta Bellatrix quartz countertops with soft warm-grey veining",swatch:"linear-gradient(135deg, #fbfaf7 0%, #f1efe9 38%, #d9d4c9 55%, #f4f2ec 72%, #fdfdfb 100%)",affiliate_url:"https://www.arizonatile.com/products/quartz/della-terra-quartz/",project_tag:"6215-anita",actual_purchased:!0}
1,{id:"calacatta-gold-quartz",name:"Calacatta Gold Quartz",vendor:"Arizona Tile",vendor_sku:"CQ-8104",material_type:"Polished quartz",prompt_snippet:"polished Calacatta Gold quartz countertops with bold golden-amber veining on a bright white field",swatch:"linear-gradient(120deg, #fdfbf4 0%, #f3ecd7 40%, #d8c79b 58%, #f6f0dd 74%, #fffdf6 100%)",affiliate_url:"https://www.arizonatile.com/products/quartz/",project_tag:"modeled-from-patten-history",actual_purchased:!1},{id:"carrara-mist",name:"Carrara Mist",vendor:"MSI",vendor_sku:"MSI-QZ-2207",material_type:"Honed quartz",prompt_snippet:"honed Carrara-look white quartz countertops with fine soft-grey veining",swatch:"linear-gradient(135deg, #fafafa 0%, #eeeff1 42%, #cfd4d9 56%, #eceef0 72%, #fdfdfd 100%)",affiliate_url:"https://www.msisurfaces.com/quartz-countertops/",project_tag:"modeled-from-patten-history",actual_purchased:!1},{id:"statuario-bianco",name:"Statuario Bianco",vendor:"Caesarstone",vendor_sku:"CS-5143",material_type:"Polished quartz",prompt_snippet:"polished Statuario Bianco quartz countertops with dramatic grey marble veining on a crisp white base",swatch:"linear-gradient(125deg, #ffffff 0%, #f0f1f3 36%, #c4c8cf 54%, #eef0f2 70%, #ffffff 100%)",affiliate_url:"https://www.caesarstoneus.com/colors/",project_tag:"modeled-from-patten-history",actual_purchased:!1},{id:"pietra-grey",name:"Pietra Grey",vendor:"MSI",vendor_sku:"MSI-QZ-3391",material_type:"Polished quartz",prompt_snippet:"polished Pietra Grey quartz countertops with deep charcoal field and fine white veining",swatch:"linear-gradient(135deg, #6f7378 0%, #565a60 40%, #3f4348 58%, #5c6066 74%, #797d83 100%)",affiliate_url:"https://www.msisurfaces.com/quartz-countertops/",project_tag:"modeled-from-patten-history",actual_purchased:!1},{id:"eternal-calacatta",name:"Eternal Calacatta",vendor:"Caesarstone",vendor_sku:"CS-5131",material_type:"Polished quartz",prompt_snippet:"polished Eternal Calacatta quartz countertops with elegant taupe-grey veining flowing over a soft white field",swatch:"linear-gradient(120deg, #fdfcfa 0%, #efece6 38%, #cfc7bb 56%, #edeae4 72%, #fefdfb 100%)",affiliate_url:"https://www.caesarstoneus.com/colors/",project_tag:"modeled-from-patten-history",actual_purchased:!1},{id:"frost-white",name:"Frost White",vendor:"Arizona Tile",vendor_sku:"CQ-7045",material_type:"Polished quartz",prompt_snippet:"polished Frost White quartz countertops with a clean uniform bright-white surface and faint cool-grey speckle",swatch:"linear-gradient(135deg, #ffffff 0%, #f6f7f8 45%, #e7eaed 60%, #f6f7f8 78%, #ffffff 100%)",affiliate_url:"https://www.arizonatile.com/products/quartz/",project_tag:"modeled-from-patten-history",actual_purchased:!1},{id:"midnight-majestic",name:"Midnight Majestic",vendor:"MSI",vendor_sku:"MSI-QZ-4488",material_type:"Polished quartz",prompt_snippet:"polished Midnight Majestic quartz countertops with a near-black field and bright bold white veining",swatch:"linear-gradient(130deg, #2b2d31 0%, #1c1d21 38%, #34363b 56%, #1f2024 74%, #2d2f33 100%)",affiliate_url:"https://www.msisurfaces.com/quartz-countertops/",project_tag:"modeled-from-patten-history",actual_purchased:!1}];function rz(e,t,a){var r;if(!e.includes("countertop")&&"kitchen_island"!==e)return null;let i=(r=({quartz_generic:"della-terra-calacatta-bellatrix",quartz_msi:"carrara-mist",quartz_cambria:"statuario-bianco",marble_calacatta:"calacatta-gold-quartz",marble_generic:"calacatta-gold-quartz",soapstone:"pietra-grey",granite:"midnight-majestic"})[t]??"della-terra-calacatta-bellatrix",rS.find(e=>e.id===r));return i?{swatch:i.swatch,vendor:i.vendor,vendor_sku:i.vendor_sku,affiliate_url:i.affiliate_url,appears_in_homes:a>0?a:1}:null}function r$(e){return"chateau_quartzite"===e.material_choice_slug?"Data caveat â this band is under review upstream (pending invoice split). Treat as indicative only.":[e.trade_slug??"",...e.component_trades??[]].includes("cabinet")?"Data caveat â cabinet cost data is quality-blocked upstream; band pending review. Treat as indicative only.":null}function rC(e){if("chateau_quartzite"===e.material_choice_slug)return r$({material_choice_slug:e.material_choice_slug});let t=rN.find(t=>t.material_choice_slug===e.material_choice_slug),a=rk.find(t=>t.element_slug===e.element_slug);return(t?[t.trade_slug]:e.is_composite?e.component_trades??a?.trade_slugs??[]:a&&1===a.trade_slugs.length?a.trade_slugs:[]).includes("cabinet")?r$({trade_slug:"cabinet"}):null}function rM({note:e}){return(0,t.jsxs)("span",{className:"badge-basis badge-drift",title:e,children:[(0,t.jsx)(C.AlertTriangle,{className:"size-3","aria-hidden":!0}),"Data caveat"]})}let rE=(0,Q.default)(()=>e.A(12590).then(e=>e.LiveMarkupCanvas),{loadableGenerated:{modules:[17088]},ssr:!1,loading:()=>(0,t.jsxs)("div",{className:"flex min-h-[520px] items-center justify-center rounded-[18px] border border-border bg-muted/40 text-sm text-muted-foreground",children:[(0,t.jsx)($.Loader2,{className:"mr-2 size-4 animate-spin"}
1)," Loading canvasâ¦"]})}),rD="https://v3b.fal.media/files/b/0a9fe241/A7b7X6M3nnGLz0SgfC3ZS_6215-anita-st-dallas-tx-75214-High-Res-16.jpg";function rP(e){return e.toLocaleString("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0})}function rO(e){return"sqft"===e?"sq ft":"linear_feet"===e?"lin ft":"each"===e?"each":"box"}let rL={kitchen:"Kitchen",primary_bath:"Primary Bath",bathroom_secondary:"Secondary Bath",powder:"Powder",whole_home:"Whole Home",exterior_envelope:"Exterior",exterior_outdoor:"Landscape"},rA={budget:"Budget",mid:"Mid",luxury:"Luxury"},rR=["kitchen","primary_bath","bathroom_secondary","powder","whole_home","exterior_envelope","exterior_outdoor"].filter(e=>rk.some(t=>t.room_type===e)),rT={budget:"Good",mid:"Better",luxury:"Best"},rF=["all","budget","mid","luxury"];function rq({photo:e,onSelectPhoto:n,visionPkg:o}){let l,d,c,p=(0,b.usePrefersReducedMotion)(),u=e?.status==="ready"&&e.remoteUrl?e.remoteUrl:rD,[m,x]=a.useState(rD),[h,v]=a.useState([]),[y,_]=a.useState(!1),[j,w]=a.useState(null),[k,N]=a.useState(null),[S,M]=a.useState("kitchen"),[E,D]=a.useState("kitchen_countertop"),[P,L]=a.useState(54),[A,R]=a.useState(!1),[T,q]=a.useState(null),[U,B]=a.useState(null),[H,V]=a.useState(null),[K,X]=a.useState("all"),[Y,J]=a.useState(!1),Q=(0,ro.useRouter)(),ee=aP(),[et,ea]=a.useState(!1),ei=a.useMemo(()=>rk.find(e=>e.element_slug===E),[E]),en=a.useMemo(()=>rk.filter(e=>e.room_type===S),[S]);a.useEffect(()=>{if(x(u),v([]),N(null),w(null),e?.name){let t=(0,aG.inferSpaceKind)(e.name),a=(0,aG.scopeElementsForSpace)(t);if(a.length>0){let e=rk.find(e=>e.element_slug===a[0]);e&&(M(e.room_type),D(e.element_slug))}}},[u,e?.name]),a.useEffect(()=>{ei&&L(ei.default_quantity),B(null),V(null),J(!1)},[ei]);let eo=a.useCallback(async()=>{if(ei){R(!0),q(null);try{let e=await fetch("/api/estimate",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({element_slug:ei.element_slug,quantity:P})}),t=await e.json();if(!e.ok||!t.ok)throw Error((t.ok?void 0:t.error)||`Estimate failed (${e.status}).`);B(t),V(t.primary?.material_choice_slug??t.alternatives[0]?.material_choice_slug??null)}catch(e){q(e instanceof Error?e.message:"Estimate failed.")}finally{R(!1)}}},[ei,P]),el=a.useCallback(async e=>{if(!ei)return;let t=`${e.choice_display} ${ei.prompt_hint??ei.display_name}`.trim(),a=G(h),r=a.length>0?a.map(a=>({...a,label:e.choice_display,text:t})):[{id:"finish",color:"#29c788",label:e.choice_display,text:t,bbox:[.3,.5,.4,.35]}];_(!0),w(null);try{let e=(await W({source_image_url:m,marks:r})).final_url??m;N({before:m,after:e}),x(e),v([])}catch(e){w(e instanceof Error?e.message:"Apply finish failed.")}finally{_(!1)}},[ei,h,m]),ed=U?.alternatives.find(e=>e.material_choice_slug===H)??null,ec=a.useMemo(()=>new Set(ee.lines.map(e=>e.id)),[ee.lines]),ep=a.useCallback(()=>{if(!U||!ed)return;let e=(0,aS.lineFromAlternative)({element_slug:U.element_slug,display_name:U.display_name,room_type:U.room_type,quantity:U.quantity,source:U.source,provenance:U.provenance},ed,rL[U.room_type]??U.room_type,{curated:ei?rz(ei.element_slug,ed.material_choice_slug,ed.real_projects_used_in):null,is_composite:"composite"===ed.trade_slug});aD(t=>{let a=k?.after??(m!==rD?m:null);return(0,aS.upsertLine)({...t,heroBeforeUrl:k?.before??t.heroBeforeUrl??null,heroImageUrl:a??t.heroImageUrl??null,updated_at:new Date().toISOString()},e)})},[U,ed,k,m]),eu=a.useCallback(async()=>{if(0!==ee.lines.length){ea(!0);try{(await fetch(`/api/proposal/${ee.id}`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(ee)})).ok&&Q.push(`/proposal/${ee.id}`)}catch{}finally{ea(!1)}}},[ee,Q]);return(0,t.jsxs)(f.motion.div,{...(0,b.fadeUp)(p),className:"flex flex-col gap-8",children:[(0,t.jsx)(z,{line:!0,step:"Step 02",kicker:"Price",title:"Pick a room, see the real cost",blurb:"Choose a room scope, get back tiered material choices priced from Patten Custom Homes' real cost history â material + install, the real supplier, with provenance. Drop a choice onto the render to see it. Pricing is an estimate band; field-verify before you buy.",action:(0,t.jsxs)(es,{variant:"secondary",className:"gap-1",children:[(0,t.jsx)(Z.Sparkles,{className:"size-3"}),"BETA"]})}),o&&(0,t.jsxs)("div",{className:"panel flex flex-wrap items-center justify-between gap-3 px-5 py-4",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[(0,t.jsxs)("span",{className:"caps text-[0.62rem] text-muted-foreground",children:["From your saved vision package",o.room_name?` \xb7 ${o.room_name}`:""]}),o.budget?(0,t.jsxs)("span",{className:"text-xs text-muted-foreground",children:[o.budget.source,o.budget.priced_on_request>0?` \xb7 ${o.budget.priced_on_request} line${1===o.budget.priced_on_request?"":"s"} priced on request â not in the band`:""]}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"No priced bill on this package â price a scope below."})]}),o.budget?(0,t.jsxs)("span",{className:"figure-mono text-xl font-semibold tracking-tight text-foreground",children:[rP(o.budget.total_low),"â",rP(o.budget.total_high)]}):(0,t.jsx)("span",{className:"badge-basis badge-request",children:"Priced on request"})]}),(0,t.jsx)(tC,{photo:e,onSelect:n,hint:"Upload a room, or keep going with the staged 6215 Anita render."}),ee.lines.length>0&&(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"panel overflow-hidden",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-3 border-b border-border px-5 py-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:(0,t.jsx)(rr.FileText,{className:"size-4"})}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("p",{className:"text-sm font-medium text-foreground",children:["Running estimate · ",ee.lines.length," scope",1===ee.lines.length?"":"s",(l=(0,aS.groupLine
1sByRoom)(ee).length)>1?` across ${l} rooms`:""]}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Itemized from your priced scopes â bands, never point prices."})]})]}),(0,t.jsxs)(er.Button,{onClick:eu,disabled:et,size:"lg",className:"shrink-0",children:[et?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(rr.FileText,{className:"size-4"}),et?"Generatingâ¦":"Save & generate proposal"]})]}),(0,t.jsx)("ul",{className:"divide-y divide-border",children:(0,aS.groupLinesByRoom)(ee).map(e=>(0,t.jsxs)("li",{className:"px-5 py-3",children:[(0,t.jsxs)("div",{className:"mb-2 flex items-baseline justify-between gap-3",children:[(0,t.jsx)("span",{className:"caps text-[0.62rem] text-muted-foreground",children:e.room_label}),(0,t.jsxs)("span",{className:"figure-mono text-xs text-muted-foreground",children:[(0,aS.usdWhole)(e.subtotal_low),"â",(0,aS.usdWhole)(e.subtotal_high)]})]}),(0,t.jsx)("ul",{className:"flex flex-col gap-2",children:e.lines.map(e=>{let a=rC(e);return(0,t.jsxs)("li",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1",children:[(0,t.jsxs)("span",{className:"truncate text-sm text-foreground",children:[e.display_name," · ",(0,t.jsx)("span",{className:"text-muted-foreground",children:e.choice_display})]}),(0,t.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5",children:[(0,t.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground",children:[e.quantity," ",rO(e.unit_of_measure)," · ",rT[e.tier]??e.tier," · ",e.supplier]}),a&&(0,t.jsx)(rM,{note:a})]})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2",children:[e.priced_on_request?(0,t.jsx)("span",{className:"badge-basis badge-request",children:"Priced on request"}):(0,t.jsxs)("span",{className:"figure-mono text-sm text-foreground",children:[(0,aS.usdWhole)(e.line_low_usd),"â",(0,aS.usdWhole)(e.line_high_usd)]}),(0,t.jsx)("button",{type:"button","aria-label":`Remove ${e.display_name}`,onClick:()=>aD(t=>(0,aS.removeLine)(t,e.id)),className:"grid size-6 place-items-center rounded-md text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",children:(0,t.jsx)(t5.X,{className:"size-3.5"})})]})]},e.id)})})]},e.key))})]}),(0,t.jsx)(rl,{animate:!1,containerClassName:"rounded-2xl",className:"rounded-[13px] bg-card",children:(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-3 px-5 py-4",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"caps text-[0.62rem] text-muted-foreground",children:"Running total · estimate band"}),ee.lines.some(e=>e.priced_on_request)&&(0,t.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground",children:["+",ee.lines.filter(e=>e.priced_on_request).length," line",1===ee.lines.filter(e=>e.priced_on_request).length?"":"s"," priced on request â not in the band"]})]}),(0,t.jsxs)("span",{className:"figure-mono text-2xl font-semibold tracking-tight text-foreground",children:[(0,aS.usdWhole)((0,aS.packageSubtotal)(ee).low),"â",(0,aS.usdWhole)((0,aS.packageSubtotal)(ee).high)]})]})})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:rR.map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>{M(e);let t=rk.find(t=>t.room_type===e);t&&D(t.element_slug)},"aria-pressed":S===e,className:(0,g.cn)("rounded-full border px-3.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",S===e?"border-primary bg-primary/10 text-foreground":"border-border text-muted-foreground hover:border-primary/50"),children:rL[e]??e},e))}),(0,t.jsx)("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4",children:en.map(e=>{let a=e.element_slug===E;return(0,t.jsxs)("button",{type:"button",onClick:()=>D(e.element_slug),"aria-pressed":a,className:(0,g.cn)("flex items-center justify-between gap-2 rounded-lg border px-3 py-2.5 text-left text-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",a?"border-primary ring-2 ring-primary/30":"border-border hover:border-primary/50"),children:[(0,t.jsx)("span",{className:"truncate text-foreground",children:e.display_name}),a&&(0,t.jsx)(F.Check,{className:"size-4 shrink-0 text-primary"})]},e.element_slug)})})]}),(0,t.jsx)(rv,{room:S}),(0,t.jsx)(rw,{room:S}),(0,t.jsxs)("div",{className:"grid gap-4 panel p-5 sm:grid-cols-[220px_minmax(0,1fr)] sm:items-end",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)(rp,{htmlFor:"qty",className:"caps text-xs text-muted-foreground",children:[(0,t.jsx)(i.Ruler,{className:"size-3.5"})," Quantity (",ei?rO(ei.default_unit_of_measure):"qty",")"]}),(0,t.jsx)(t8.Input,{id:"qty",type:"number",min:1,inputMode:"numeric",value:P,onChange:e=>{L(Number(e.target.value)),J(!0)}}),(0,t.jsxs)("span",{className:"flex flex-wrap items-center gap-1.5 text-[0.65rem] text-muted-foreground",children:[(0,t.jsx)("span",{className:(0,g.cn)("badge-basis",Y?"border-primary/40 bg-primary/10 text-primary":"badge-typical"),children:Y?"Your quantity":"Typical for scope"}),ei?`default ${ei.default_quantity} ${rO(ei.default_unit_of_measure)}`:""]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)(er.Button,{onClick:eo,disabled:!ei||A,size:"lg",children:[A?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(s,{className:"size-4"}),A?"Pricingâ¦":"Get estimate"]}),T&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs text-destructive",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-3.5"})," ",T]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsx)("span",{className:"caps text-xs text-muted-foreground",children:"Drop a choice onto the render"}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:e?.
1status==="ready"?"Your photo":"Demo · 6215 Anita St."})]}),(0,t.jsx)(rE,{imageUrl:m,mode:"edit",marks:h,isBusy:y,onMarksChange:v,onGeneratePlan:()=>ed&&el(ed)})]}),j&&(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-4"}),j," â pricing still works below."]}),k&&(0,t.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,t.jsx)("span",{className:"caps text-xs text-muted-foreground",children:"Before / after â finish swap"}),(0,t.jsx)(I,{before:k.before,after:k.after,beforeLabel:"Before",afterLabel:"With finish"})]}),U&&(0,t.jsxs)(f.motion.div,{...(0,b.fadeUp)(p),className:"flex flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("span",{className:"caps text-xs text-muted-foreground",children:[U.display_name," · ",U.alternatives.length," choices · ",U.quantity," ",rO(U.unit_of_measure)]}),(0,t.jsxs)(es,{variant:"live-db"===U.source?"default":"outline",className:"gap-1 text-[0.6rem]",children:["live-db"===U.source?(0,t.jsx)(rn,{className:"size-3"}):(0,t.jsx)(rs,{className:"size-3"}),"live-db"===U.source?"Live Patten DB":"Demo pricing"]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("span",{className:"caps text-[0.65rem] text-muted-foreground",children:"Tier"}),rF.map(e=>{let a="all"===e?U.alternatives.length:U.alternatives.filter(t=>t.tier===e).length;if("all"!==e&&0===a)return null;let r=K===e;return(0,t.jsxs)("button",{type:"button",onClick:()=>X(e),"aria-pressed":r,className:(0,g.cn)("rounded-full border px-3 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",r?"border-primary bg-primary/10 text-primary":"border-border bg-card text-muted-foreground hover:text-foreground"),children:["all"===e?"All":`${rT[e]} \xb7 ${rA[e]}`,(0,t.jsx)("span",{className:"figure-mono ml-1.5 text-[0.65rem] opacity-70",children:a})]},e)})]}),(0,t.jsx)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:U.alternatives.filter(e=>"all"===K||e.tier===K).map(e=>{let a=e.material_choice_slug===H,r=(e.consumer_unit_low_cents??0)<=0&&(e.consumer_unit_high_cents??0)<=0,i="composite"===e.trade_slug,n=r$({material_choice_slug:e.material_choice_slug,trade_slug:e.trade_slug,component_trades:i?ei?.trade_slugs:void 0}),s=ei?rz(ei.element_slug,e.material_choice_slug,e.real_projects_used_in):null;return(0,t.jsxs)("button",{type:"button",onClick:()=>V(e.material_choice_slug),"aria-pressed":a,className:(0,g.cn)("group flex flex-col gap-2 rounded-xl border bg-card p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",a?"border-primary ring-2 ring-primary/30":"border-border hover:border-primary/50"),children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("span",{className:"truncate text-sm font-medium text-foreground",children:e.choice_display}),(0,t.jsxs)(es,{variant:"secondary",className:"shrink-0 text-[0.55rem]",children:[rT[e.tier]," · ",rA[e.tier]]})]}),(0,t.jsx)("span",{className:"caps text-[0.6rem] text-muted-foreground",children:e.supplier_pool.length>0?e.supplier_pool.join(" · "):e.trade_slug.replace(/_/g," ")}),(0,t.jsx)("span",{className:"figure-mono text-xs text-muted-foreground",children:r?"":`${rP(e.consumer_unit_low_cents/100)}â${rP(e.consumer_unit_high_cents/100)} / ${rO(e.unit_of_measure)}`}),r?(0,t.jsx)("span",{className:"badge-basis badge-request w-fit",children:"Priced on request"}):(0,t.jsxs)("span",{className:"figure-mono text-base font-semibold text-foreground",children:[rP(e.line_low_usd),"â",rP(e.line_high_usd)]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[i&&(0,t.jsx)(es,{variant:"outline",className:"text-[0.5rem]",children:"Bundle"}),n&&(0,t.jsx)(rM,{note:n}),e.evidence_count>0&&(0,t.jsxs)("span",{className:"text-[0.6rem] text-muted-foreground",children:["from ",e.evidence_count.toLocaleStr
1ing()," real invoice lines · ",e.real_projects_used_in," homes"]})]}),s&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[0.6rem] text-muted-foreground",children:[(0,t.jsx)("span",{className:"size-3 shrink-0 rounded-[3px] border border-border",style:{background:s.swatch}}),(0,t.jsxs)("span",{className:"truncate",children:[s.vendor," ",s.vendor_sku," · appears in ",s.appears_in_homes," homes"]})]})]},e.material_choice_slug)})}),ed&&(d=(ed.consumer_unit_low_cents??0)<=0&&(ed.consumer_unit_high_cents??0)<=0,c=r$({material_choice_slug:ed.material_choice_slug,trade_slug:ed.trade_slug,component_trades:"composite"===ed.trade_slug?ei?.trade_slugs:void 0}),(0,t.jsxs)("div",{className:"overflow-hidden panel",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3 border-b border-border p-5",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-1.5",children:[(0,t.jsx)("span",{className:"truncate text-base font-semibold text-foreground",children:ed.choice_display}),(0,t.jsxs)("span",{className:"caps text-xs text-muted-foreground",children:[U.display_name," · ",ed.supplier_pool.length>0?ed.supplier_pool.join(" · "):ed.trade_slug.replace(/_/g," ")]}),c&&(0,t.jsx)(rM,{note:c})]}),(0,t.jsx)("span",{className:"inline-flex size-9 shrink-0 items-center justify-center rounded-md bg-primary/10 text-primary",children:(0,t.jsx)(s,{className:"size-4"})})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 p-5",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 text-sm",children:[(0,t.jsx)("span",{className:"figure-mono text-muted-foreground",children:d?`${U.quantity} ${rO(U.unit_of_measure)} \xd7 (priced on request)`:`${U.quantity} ${rO(U.unit_of_measure)} \xd7 ${rP(ed.consumer_unit_low_cents/100)}â${rP(ed.consumer_unit_high_cents/100)}`}),(0,t.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground",children:["from ",ed.evidence_count.toLocaleString()," real invoice lines · ",ed.real_projects_used_in," homes"]})]}),(0,t.jsxs)("div",{className:"flex items-end justify-between gap-3",children:[(0,t.jsx)("span",{className:"caps text-xs text-muted-foreground",children:"Estimated total"}),d?(0,t.jsx)("span",{className:"badge-basis badge-request text-sm",children:"Priced on request"}):(0,t.jsxs)("span",{className:"figure-mono text-3xl font-semibold tracking-tight text-foreground",children:[rP(ed.line_low_usd),"â",rP(ed.line_high_usd)]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-3 border-t border-border p-5",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row",children:[(0,t.jsxs)(er.Button,{onClick:()=>el(ed),disabled:y,size:"lg",className:"flex-1",children:[y?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(r.Wand2,{className:"size-4"}),y?"Applyingâ¦":"See it on the render"]}),(0,t.jsxs)(er.Button,{variant:"outline",size:"lg",className:"flex-1",onClick:ep,children:[ec.has(U.element_slug)?(0,t.jsx)(eP.CheckCircle2,{className:"size-4 text-primary"}):(0,t.jsx)(O.Plus,{className:"size-4"}),ec.has(U.element_slug)?"Update in proposal":"Add to proposal"]})]}),ec.has(U.element_slug)&&(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-md border border-primary/30 bg-primary/5 px-3 py-2 text-sm text-foreground",children:[(0,t.jsx)(ri,{className:"mt-0.5 size-4 shrink-0 text-primary"}),(0,t.jsxs)("span",{children:["Added to your proposal â ",U.display_name,": ",ed.choice_display,", ",U.quantity," ",rO(U.unit_of_measure),","," ",d?"priced on request":`est. ${rP(ed.line_low_usd)}â${rP(ed.line_high_usd)}`,". Open the running estimate above to generate the document."]})]}),(0,t.jsxs)("p",{className:"flex flex-wrap items-center gap-2 text-xs text-muted-foreground",children:[(0,t.jsxs)(es,{variant:"outline",className:"gap-1 text-[0.55rem]",children:[(0,t.jsx)(ra.ShoppingBag,{className:"size-3"}),"live-db"===U.source?"Real Patten cost data":"Demo · field-verify"]}),U.provenance," ",U.disclaimer]})]})]}))]})]})}var rI=e.i(48540);function rU({packageId:e}){let r=(0,b.usePrefersReducedMotion)(),[i,n]=a.useState("loading"),[s,o]=a.use
1State(null),[l,d]=a.useState(null),[c,p]=a.useState(0);return a.useEffect(()=>{let t=!0;return n("loading"),(async()=>{try{let a=e?`package=${encodeURIComponent(e)}`:"demo=1",r=await fetch(`/api/selections/book?${a}`,{cache:"no-store"}),i=await r.json();if(!t)return;if(!r.ok||!i.ok||!i.book){d(i.error||`Selections book failed (HTTP ${r.status}).`),n("error");return}o(i.book),n("ready")}catch(e){if(!t)return;d(e instanceof Error?e.message:"Selections book failed."),n("error")}})(),()=>{t=!1}},[e,c]),(0,t.jsxs)(f.motion.div,{...(0,b.fadeUp)(r),className:"flex flex-col gap-8",children:[(0,t.jsx)(z,{line:!0,kicker:"Selections",title:"The Selections Book",blurb:e?"Generated lighting, plumbing, finishes, and FF&E schedules for your saved vision package â real catalog labels, real bands or priced on request, with installed-in-N-Patten-homes provenance.":"Generated schedules and boards from the sample measured plan â real catalog labels, real bands or priced on request. Measure your own space (MEASURE tab) or reopen a saved package to build yours."}),"loading"===i&&(0,t.jsxs)("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,t.jsx)($.Loader2,{className:"size-3.5 animate-spin"}),"Composing the selections bookâ¦"]}),"error"===i&&(0,t.jsxs)("div",{className:"mx-auto flex max-w-lg flex-col items-center gap-4 roun
1ded-2xl border border-border bg-card/60 px-6 py-14 text-center",children:[(0,t.jsx)("h2",{className:"font-serif text-2xl font-light text-foreground",children:"Couldn't compose the book"}),(0,t.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:l}),(0,t.jsxs)("button",{type:"button",onClick:()=>p(e=>e+1),className:"inline-flex items-center gap-2 rounded-full border border-border bg-card/60 px-5 py-2.5 text-sm font-medium text-foreground transition-colors hover:border-primary/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",children:[(0,t.jsx)(eO,{className:"size-3.5"}),"Retry"]})]}),"ready"===i&&s&&(0,t.jsx)(rI.SelectionsBoard,{book:s})]})}var rW=e.i(96064);let rB=(0,n.default)("move",[["path",{d:"M12 2v20",key:"t6zp3m"}],["path",{d:"m15 19-3 3-3-3",key:"11eu04"}],["path",{d:"m19 9 3 3-3 3",key:"1mg7y2"}],["path",{d:"M2 12h20",key:"9i4pu4"}],["path",{d:"m5 9-3 3 3 3",key:"j64kie"}],["path",{d:"m9 5 3-3 3 3",key:"l8vdw6"}]]),rG=(0,n.default)("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]),rH="#4A9CC9",rV="#2C74A5",rK="#ECE4CD",rX="#608C4E",rY="#D9D2C4",rJ="#E7E0D2",rQ="#102038",rZ="#C19E4C",r0=e=>e[2]-e[0];function r1(e){let t=Math.min(2.5,.2*r0(e));return{spa:[e[0]+t,e[1]-6,e[2]-t,e[1]],ledge:[e[0],e[3]-3,e[2],e[3]]}}function r2(e=50,t=140){let a=e/2,r=Math.min(34,.66*e),i=Math.max(20,.18*t),n=[a-r/2,i,a+r/2,i+Math.min(54,.38*t)],s=[a-r/2+5,n[3],a+r/2-5,n[3]+10],o=[1.5,t-24,23.5,t-1.5],l=o[2],d=Math.min(16,.3*e),c=s[3]+5,p=a;p-d/2<l+1&&(p=l+1+d/2),p+d/2>e-1&&(p=e-1-d/2);let u=[p-d/2,c,p+d/2,Math.max(c+18,t-12)],{spa:m,ledge:x}=r1(u),f=[[n[0],Math.max(0,n[1]-3),n[2],n[1]],[e-8,t-12,e-2,t-2]];return{lot:{w:e,d:t},front:"south",house:n,garage:o,patio:s,pool:u,spa:m,ledge:x,beds:f,fences:[[0,0,.5,t],[e-.5,0,e,t],[0,t-.5,e,t]],label:`Magic site plan \xb7 ${e}' \xd7 ${t}' lot`}}function r5(e){return{x:e[0],y:e[1],width:e[2]-e[0],height:e[3]-e[1]}}function r3({geo:e,className:a,interactive:r,onPoolPointerDown:i,onHandlePointerDown:n}){let{w:s,d:o}
1=e.lot,l=s+16,d=o+16,c=e.pool,p=[{c:"sw",x:c[0],y:c[1],cur:"nesw-resize"},{c:"se",x:c[2],y:c[1],cur:"nwse-resize"},{c:"nw",x:c[0],y:c[3],cur:"nwse-resize"},{c:"ne",x:c[2],y:c[3],cur:"nesw-resize"}];return(0,t.jsxs)("svg",{viewBox:`0 0 ${l} ${d}`,className:a,role:"img","aria-label":e.label??"Site plan",children:[(0,t.jsx)("defs",{children:(0,t.jsxs)("linearGradient",{id:"sp-water",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,t.jsx)("stop",{offset:"0",stopColor:rH}),(0,t.jsx)("stop",{offset:"1",stopColor:rV})]})}),(0,t.jsx)("rect",{x:0,y:0,width:l,height:d,fill:"#fbfaf6"}),(0,t.jsxs)("g",{transform:`translate(8 ${o+8}) scale(1 -1)`,children:[(0,t.jsx)("rect",{x:0,y:0,width:s,height:o,fill:"#ABCC8C",stroke:"#1c2b1c",strokeWidth:.5}),e.fences?.map((e,a)=>(0,t.jsx)("rect",{...r5(e),fill:rQ,opacity:.65},`fence-${a}`)),e.beds?.map((e,a)=>(0,t.jsx)("rect",{...r5(e),fill:rX},`bed-${a}`)),e.patio&&(0,t.jsx)("rect",{...r5(e.patio),fill:rJ,stroke:"#0002",strokeWidth:.2}),(0,t.jsx)("rect",{x:c[0]-1.2,y:c[1]-1.2,width:c[2]-c[0]+2.4,height:c[3]-c[1]+2.4,rx:1,fill:rK,stroke:"#00000022",strokeWidth:.2}),(0,t.jsx)("rect",{...r5(c),rx:.8,fill:"url(#sp-water)",onPointerDown:r?i:void 0,stroke:r?rZ:void 0,strokeWidth:.6*!!r,style:r?{cursor:"grab",touchAction:"none"}:void 0}),e.ledge&&(0,t.jsx)("rect",{...r5(e.ledge),fill:rH,opacity:.55}),e.spa&&(0,t.jsx)("rect",{...r5(e.spa),rx:.6,fill:rK,stroke:rV,strokeWidth:.5}),e.garage&&(0,t.jsx)("rect",{...r5(e.garage),fill:"#565E63"}),(0,t.jsx)("rect",{...r5(e.house),fill:rY,stroke:"#3a3327",strokeWidth:.6}),r&&n&&p.map(e=>(0,t.jsx)("rect",{x:e.x-.9,y:e.y-.9,width:1.8,height:1.8,rx:.3,fill:rZ,stroke:"#ffffff",strokeWidth:.25,style:{cursor:e.cur,touchAction:"none"},onPointerDown:t=>n(e.c,t)},`h-${e.c}`))]}),(0,t.jsxs)("g",{transform:`translate(${l-6} 6)`,fill:rQ,children:[(0,t.jsx)("polygon",{points:"0,-3.5 1.6,1.5 0,0.4 -1.6,1.5"}),(0,t.jsx)("text",{x:0,y:5.2,fontSize:3,textAnchor:"middle",fill:rQ,fontWeight:"600",children:"N"})]}),(0,t.jsxs)("g",{transform:`translate(8 ${d-3.5})`,children:[(0,t.jsx)("line",{x1:0,y1:0,x2:20,y2:0,stroke:rQ,strokeWidth:.6}),(0,t.jsx)("line",{x1:0,y1:-1,x2:0,y2:1,stroke:rQ,strokeWidth:.6}),(0,t.jsx)("line",{x1:20,y1:-1,x2:20,y2:1,stroke:rQ,strokeWidth:.6}),(0,t.jsx)("text",{x:10,y:3,fontSize:2.6,textAnchor:"middle",fill:rQ,children:"20 ft"})]}),e.label&&(0,t.jsx)("text",{x:l-8,y:d-1.5,fontSize:2.8,textAnchor:"end",fill:rQ,fontWeight:"600",children:e.label})]})}let r4=(0,n.default)("satellite",[["path",{d:"m13.5 6.5-3.148-3.148a1.205 1.205 0 0 0-1.704 0L6.352 5.648a1.205 1.205 0 0 0 0 1.704L9.5 10.5",key:"dzhfyz"}],["path",{d:"M16.5 7.5 19 5",key:"1ltcjm"}],["path",{d:"m17.5 10.5 3.148 3.148a1.205 1.205 0 0 1 0 1.704l-2.296 2.296a1.205 1.205 0 0 1-1.704 0L13.5 14.5",key:"nfoymv"}],["path",{d:"M9 21a6 6 0 0 0-6-6",key:"1iajcf"}],["path",{d:"M9.352 10.648a1.205 1.205 0 0 0 0 1.704l2.296 2.296a1.205 1.205 0 0 0 1.704 0l4.296-4.296a1.205 1.205 0 0 0 0-1.704l-2.296-2.296a1.205 1.205 0 0 0-1.704 0z",key:"nv9zqy"}]]);function r6({address:e}){let r,n,[s,o]=a.useState(e??""),[l,d]=a.useState(!1),[c,p]=a.useState(null),[u,m]=a.useState(null);a.useEffect(()=>{e&&!s&&o(e)},[e,s]);let x=a.useCallback(async()=>{if(s.trim()){d(!0),m(null);try{let e=await fetch("/api/aerial/measured",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({address:s.trim()})}),t=await e.json();t.ok?p(t):m(t.error||"Could not pull a measured aerial.")}catch{m("Aerial service unreachable.")}finally{d(!1)}}},[s]),f=c?.aerial,h=f?(r=f.span_w_ft/5,(n=[5,10,20,25,50,100,150,200,300,500]).reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e,n[0])):0,g=f?h/f.feet_per_px:0;return(0,t.jsxs)("section",{className:"panel flex flex-col gap-3 p-4",children:[(0,t.jsxs)("p",{className:"rail-label inline-flex items-center gap-1.5",children:[(0,t.jsx)(r4,{className:"size-3.5 text-primary"})," Measured aerial (true to scale)"]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{value:s,onChange:e=>o(e.target.value),onKeyDown:e=>"Enter"===e.key&&x(),placeholder:"123 Whaley St, Dallas TX",className:"min-w-0 flex-1 rounded-lg border border-border bg-card/40 px-3 py-2 text-sm text-foreground outline-none focus:border-primary/60"}),(0,t.jsxs)("button",{onClick:x,disabled:l||!s.trim(),className:"cta-emerald inline-flex shrink-0 items-center gap-2 rounded-lg px-3 py-2 text-sm font-semibold text-white active:scale-[0.99] disabled:opacity-60",children:[l?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(i.Ruler,{className:"size-4"}),l?"Pullingâ¦":"Measure"]})]}),u?(0,t.jsxs)("p",{className:"inline-flex items-center gap-1.5 text-xs text-amber-500",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-3.5"})," ",u]}):null,f?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"relative overflow-hidden rounded-lg border border-border bg-black",children:[(0,t.jsx)("img",{src:f.image_url,alt:"Georeferenced aerial",className:"block w-full",width:f.width_px,height:f.height_px}),(0,t.jsxs)("svg",{viewBox:`0 0 ${f.width_px} ${f.height_px}`,className:"pointer-events-none absolute inset-0 h-full w-full",preserveAspectRatio:"none",children:[c?.parcel&&c.parcel.ring_px.length>2?(0,t.jsx)("polygon",{points:c.parcel.ring_px.map(e=>`${e.x},${e.y}`).join(" "),fill:"rgba(255,221,87,0.10)",stroke:"#ffdd57",strokeWidth:Math.max(2,f.width_px/400)}):null,(0,t.jsxs)("g",{transform:`translate(${.04*f.width_px}, ${.93*f.height_px})`,children:[(0,t.jsx)("rect",{x:0,y:0,width:g,height:Math.max(4,f.width_px/180),fill:"#fff",stroke:"#000",strokeWidth:1}),(0,t.jsxs)("text",{x:0,y:-8,fontSize:f.width_px/45,fill:"#fff",stroke:"#000",strokeWidth:.6,fontFamily:"monospace",children:[h," ft"]})]})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[0.7rem] text-muted-foreground",children:[(0,t.jsxs)("span",{className:"font-mono text-foreground",children:[f.feet_per_px.toFixed(3)," ft/px"]}),(0,t.jsxs)("span",{children:[f.provider," · z",f.zoom]}),c?.parcel?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("span",{className:"text-foreground",children:["Lot ",c.parcel.area_sqft?.toLocaleStr
1ing()," ft²"]}),(0,t.jsxs)("span",{children:[c.parcel.perimeter_ft," ft perimeter"]})]}):(0,t.jsx)("span",{className:"text-amber-500/80",children:"parcel lines need a Regrid/ATTOM key â imagery scale is live"}),(0,t.jsx)("span",{children:f.attribution})]}),(0,t.jsx)("p",{className:"text-[0.65rem] leading-relaxed text-muted-foreground",children:c?.disclaimer})]}):(0,t.jsx)("p",{className:"text-[0.65rem] text-muted-foreground",children:"Pulls a georeferenced satellite image at a known scale (Web Mercator) so you can measure footprints, lots, and pool placement to real feet â and overlays the recorded parcel boundary. Measured, not a stamped survey."})]})}let r8=(0,n.default)("flip-horizontal-2",[["path",{d:"m3 7 5 5-5 5V7",key:"couhi7"}],["path",{d:"m21 7-5 5 5 5V7",key:"6ouia7"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 14v2",key:"8jcxud"}],["path",{d:"M12 8v2",key:"1woqiv"}],["path",{d:"M12 2v2",key:"tus03m"}]]),r7=(0,n.default)("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]),r9="cortivex.align.v1.";function ie({address:e,geometry:r}){let n,s,[o,l]=a.useState(e??""),[d,c]=a.useState(!1),[p,u]=a.useState(null),[m,x]=a.useState(null),[f,h]=a.useState(null),[g,b]=a.useState(!0),v=a.useRef(null);a.useEffect(()=>{e&&e!==o&&!p&&l(e)},[e]);let y=p?.aerial,_=y?1/y.feet_per_px:0,j=r.lot,k=a.useCallback(()=>({cx:y?y.width_px/2:0,cy:y?y.height_px/2:0,rot:0,scale:1,flip:!1}),[y]),N=p?.formatted?r9+p.formatted:null,S=a.useCallback(async()=>{if(o.trim()){c(!0),x(null);try{let e=await fetch("/api/aerial/measured",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({address:o.trim()})}),t=await e.json();if(t.ok){u(t);let e=t.formatted?r9+t.formatted:null,a=null;if(e)try{let t=localStorage.getItem(e);if(t){let e=JSON.parse(t);e&&"object"==typeof e&&Number.isFinite(e.cx)&&Number.isFinite(e.cy)&&Number.isFinite(e.rot)&&Number.isFinite(e.scale)&&e.scale>0&&"boolean"==typeof e.flip&&(a=e)}}catch{}h(a??{cx:t.aerial.width_px/2,cy:t.aerial.height_px/2,rot:0,scale:1,flip:!1})}else x(t.error||"Could not pull a measured aerial."),u(null)}catch{x("Aerial service unreachable.")}finally{c(!1)}}},[o]);a.useEffect(()=>{if(!N||!f)return;let e=setTimeout(()=>{try{localStorage.setItem(N,JSON.stringify(f))}catch{}},250);return()=>clearTimeout(e)},[N,f]);let z=a.useCallback((e,t)=>{if(!f)return{x:0,y:0};let a=_*f.scale,r=((f.flip?j.w-e:e)-j.w/2)*a,i=(j.d/2-t)*a,n=f.rot*Math.PI/180,s=Math.cos(n),o=Math.sin(n);return{x:f.cx+r*s-i*o,y:f.cy+r*o+i*s}},[f,_,j.w,j.d]),M=a.useCallback(e=>[z(e[0],e[1]),z(e[2],e[1]),z(e[2],e[3]),z(e[0],e[3])].map(e=>`${e.x.toFixed(1)},${e.y.toFixed(1)}`).join(" "),[z]),E=a.useCallback((e,t)=>{let a=v.current;if(!a)return null;let r=a.getScreenCTM();if(!r)return null;let i=new DOMPoint(e,t).matrixTransform(r.inverse());return{x:i.x,y:i.y}},[]),D=a.useRef(null),P=a.useCallback(e=>{if(!f)return;let t=E(e.clientX,e.clientY);t&&(e.target.setPointerCapture?.(e.pointerId),D.current={startCx:f.cx,startCy:f.cy,p0:t})},[f,E]),O=a.useCallback(e=>{let t=D.current;if(!t)return;let a=E(e.clientX,e.clientY);a&&h(e=>e?{...e,cx:t.startCx+(a.x-t.p0.x),cy:t.startCy+(a.y-t.p0.y)}:e)},[E]),L=a.useCallback(e=>{D.current=null,e.target.releasePointerCapture?.(e.pointerId)},[]),A=a.useCallback(()=>{if(!p?.parcel||p.parcel.ring_px.length<3)return;let e=p.parcel.ring_px,t=e.reduce((e,t)=>e+t.x,0)/e.length,a=e.reduce((e,t)=>e+t.y,0)/e.length;h(e=>e?{...e,cx:t,cy:a}:e)},[p]),R=y?(n=y.span_w_ft/5,(s=[5,10,20,25,50,100,150,200,300,500]).reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e,s[0])):0,T=y&&f?R/y.feet_per_px:0,F=y?y.width_px/55:12,q=y?Math.max(1.5,y.width_px/600):2,I=(e,a,r="#ffffff")=>{let i=z((e[0]+e[2])/2,(e[1]+e[3])/2);return(0,t.jsx)("text",{x:i.x,y:i.y,fontSize:F,fontWeight:700,textAnchor:"middle",dominantBaseline:"central",fill:r,stroke:"#000",strokeWidth:F/7,paintOrder:"stroke",strokeLinejoin:"round",style:{letterSpacing:"0.04em"},children:a})},U=Math.round(r.pool[2]-r.pool[0]),W=Math.round(r.pool[3]-r.pool[1]);return(0,t.jsxs)("section",{className:"panel flex flex-col gap-3 p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("p",{className:"rail-label inline-flex items-center gap-1.5",children:[(0,t.jsx)(r4,{className:"size-3.5 text-primary"})," Place on the real aerial (true to scale)"]}),y?(0,t.jsxs)("button",{type:"button",onClick:()=>b(e=>!e),className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-card/60 px-2 py-1 text-[0.62rem] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(r7,{className:"size-3"})," ",g?"Hide":"Show"," labels"]}):null]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{value:o,onChange:e=>l(e.target.value),onKeyDown:e=>"Enter"===e.key&&S(),placeholder:"123 Whaley St, Dallas TX",className:"min-w-0 flex-1 rounded-lg border border-border bg-card/40 px-3 py-2 text-sm text-foreground outline-none focus:border-primary/60"}),(0,t.jsxs)("button",{onClick:S,disabled:d||!o.trim(),className:"cta-emerald inline-flex shrink-0 items-center gap-2 rounded-lg px-3 py-2 text-sm font-semibold text-white active:scale-[0.99] disabled:opacity-60",children:[d?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(i.Ruler,{className:"size-4"}),d?"Pullingâ¦":"Place"]})]}),m?(0,t.jsxs)("p",{className:"inline-flex items-center gap-1.5 text-xs text-amber-500",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-3.5"})," ",m]}):null,y&&f?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"relative aspect-square w-full overflow-hidden rounded-lg border border-border bg-black",children:[(0,t.jsx)("img",{src:y.image_url,alt:"Georeferenced aerial",className:"absolute inset-0 h-full w-full select-none",draggable:!1}),(0,t.jsxs)("svg",{ref:v,viewBox:`0 0 ${y.width_px} ${y.height_px}`,preserveAspectRatio:"none",className:"absolute inset-0 h-full w-full touch-none",onPointerMove:O,onPointerUp:L,onPointerLeave:L,children:[p?.parcel&&p.parcel.ring_px.length>2?(0,t.jsx)("polygon",{points:p.parcel.ring_px.map(e=>`${e.x},${e.y}`).join(" "),fill:"none",stroke:"#ffdd57",strokeWidth:q,strokeDasharray:`${3*q} ${2*q}`}):null,(0,t.jsxs)("g",{onPointerDown:P,style:{cursor:"grab"},children:[(0,t.jsx)("polygon",{points:M([0,0,j.w,j.d]),fill:"rgba(127,240,210,0.06)",stroke:"var(--ion, #7ff0d2)",strokeWidth:q}),r.beds?.map((e,a)=>(0,t.jsx)("polygon",{points:M(e),fill:rX,fillOpacity:.7,stroke:"none"},`bed${a}`)),r.garage?(0,t.jsx)("polygon",{points:M(r.garage),fill:rY,fillOpacity:.85,stroke:"#000",strokeWidth:.6*q}):null,r.house?(0,t.jsx)("polygon",{points:M(r.house),fill:rY,fillOpacity:.9,stroke:"#000",strokeWidth:.6*q}):null,r.patio?(0,t.jsx)("polygon",{points:M(r.patio),fill:rJ,fillOpacity:.85,stroke:"none"}):null,r.ledge?(0,t.jsx)("polygon",{points:M(r.ledge),fill:rK,fillOpacity:.9,stroke:"none"}):null,(0,t.jsx)("polygon",{points:M(r.pool),fill:rV,fillOpacity:.92,stroke:rK,strokeWidth:1.4*q}),r.spa?(0,t.jsx)("polygon",{points:M(r.spa),fill:rH,fillOpacity:.95,stroke:rK,strokeWidth:q}):null,g?(0,t.jsxs)(t.Fragment,{children:[r.garage?I(r.garage,"GARAGE"):null,r.house?I(r.house,"HOUSE"):null,r.patio?I(r.patio,"PATIO"):null,r.spa?I(r.spa,"SPA","#eaf6ff"):null,r.ledge?I(r.ledge,"TANNING LEDGE"):null,I(r.pool,`POOL ${U}\xd7${W}`,"#eaf6ff")]}):null]}),(0,t.jsxs)("g",{transform:`translate(${.94*y.width_px}, ${.1*y.height_px})`,opacity:.9,children:[(0,t.jsx)("line",{x1:0,y1:.05*y.height_px,x2:0,y2:-(.03*y.height_px),stroke:"#fff",strokeWidth:q}),(0,t.jsx)("polygon",{points:`0,${-(.045*y.height_px)} ${-(2.5*q)},${-(.02*y.height_px)} ${2.5*q},${-(.02*y.height_px)}`,fill:"#fff"}),(0,t.jsx)("text",{x:0,y:.08*y.height_px,fontSize:F,fill:"#fff",stroke:"#000",strokeWidth:.6,textAnchor:"middle",children:"N"})]}),(0,t.jsxs)("g",{transform:`translate(${.04*y.width_px}, ${.94*y.height_px})`,children:[(0,t.jsx)("rect",{x:0,y:0,width:T,height:Math.max(4,y.width_px/200),fill:"#fff",stroke:"#000",strokeWidth:1}),(0,t.jsxs)("text",{x:0,y:-8,fontSize:F,fill:"#fff",stroke:"#000",strokeWidth:.6,fontFamily:"monospace",children:[R," ft"]})]})]})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsxs)("label",{className:"flex items-center gap-2 text-[0.7rem] text-muted-foreground",children:[(0,t.jsx)("span",{className:"w-12 shrink-0",children:"Rotate"}),(0,t.jsx)("input",{type:"range",min:-180,max:180,step:1,value:f.rot,onChange:e=>h(t=>t?{...t,rot:Number(e.target.value)}:t),className:"flex-1 accent-[var(--ion,#7ff0d2)]"}),(0,t.jsxs)("span",{className:"w-10 shrink-0 text-right font-mono text-foreground",children:[f.rot,"°"]})]}),(0,t.jsxs)("label",{className:"flex items-center gap-2 text-[0.7rem] text-muted-foreground",children:[(0,t.jsx)("span",{className:"w-12 shrink-0",children:"Scale"}),(0,t.jsx)("input",{type:"range",min:.85,max:1.15,step:.005,value:f.scale,onChange:e=>h(t=>t?{...t,scale:Number(e.target.value)}:t),className:"flex-1 accent-[var(--ion,#7ff0d2)]"}),(0,t.jsxs)("span",{className:"w-10 shrink-0 text-right font-mono text-foreground",children:[f.scale.toFixed(2),"Ã"]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[[0,90,180,270].map(e=>(0,t.jsxs)("button",{type:"button",onClick:()=>h(t=>t?{...t,rot:270===e?-90:180===e?180:e}
1:t),className:"rounded-md border border-border bg-card/60 px-2 py-1 text-[0.62rem] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[e,"°"]},e)),(0,t.jsxs)("button",{type:"button",onClick:()=>h(e=>e?{...e,flip:!e.flip}:e),className:"inline-flex items-center gap-1 rounded-md border border-border bg-card/60 px-2 py-1 text-[0.62rem] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(r8,{className:"size-3"})," Flip"]}),p?.parcel?(0,t.jsxs)("button",{type:"button",onClick:A,className:"inline-flex items-center gap-1 rounded-md border border-border bg-card/60 px-2 py-1 text-[0.62rem] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(w,{className:"size-3"})," Center on parcel"]}):null,(0,t.jsxs)("button",{type:"button",onClick:()=>h(k()),className:"inline-flex items-center gap-1 rounded-md border border-border bg-card/60 px-2 py-1 text-[0.62rem] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(et.RotateCcw,{className:"size-3"})," Reset"]})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-[0.7rem] text-muted-foreground",children:[(0,t.jsxs)("span",{className:"font-mono text-foreground",children:[y.feet_per_px.toFixed(3)," ft/px"]}),(0,t.jsxs)("span",{children:[y.provider," · z",y.zoom]}),p?.parcel?(0,t.jsxs)("span",{className:"text-foreground",children:["Lot ",p.parcel.area_sqft?.toLocaleString()," ft² (recorded)"]}):(0,t.jsx)("span",{className:"text-amber-500/80",children:"no parcel key â align to the visible lot"}),(0,t.jsx)("span",{children:y.attribution})]}),(0,t.jsxs)("p",{className:"text-[0.65rem] leading-relaxed text-muted-foreground",children:["Drag the site onto your lot, then nudge rotation/scale to match the visible boundary (imagery is north-up). ",p?.disclaimer]})]}):(0,t.jsx)("p",{className:"text-[0.65rem] text-muted-foreground",children:"Pull the real satellite image at a known scale, then drag/rotate your to-scale site plan onto the actual lot â the pool lands where it will be built. Placement saves per address. Measured, not a stamped survey."})]})}let it=(0,n.default)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var ia=e.i(34558);let ir="#f7f1e8",ii="#7ff0d2",is="#b9e8da",io="#29c788",il="#e3b25c",id="Georgia, 'Playfair Display', serif",ic=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'");function ip(e,t){let a=e.split(/\s+/),r=[],i="";for(let e of a)(i+" "+e).trim().length>t&&i?(r.push(i),i=e):i=(i?i+" ":"")+e;return i&&r.push(i),r}let iu=e=>{let t=Math.floor(e),a=Math.round((e-t)*12);return 0===a?`${t}'`:12===a?`${t+1}'`:`${t}'-${a}"`};function im(e,t={}){let a=t.showAerial??!0,r=t.aerialOpacity??.55,i=e.parcel,n=e.bounds_ft,s=Math.max(10,.08*Math.max(n.w,n.h)),o=n.w+2*s,l=n.h+2*s,d=Math.min(740/o,700/l),c=36+(740-o*d)/2,p=36+(700-l*d)/2,u=e=>({x:c+(e.x+s)*d,y:p+(n.h+s-e.y)*d}),m=e=>e.map(e=>{let t=u(e);return`${t.x.toFixed(1)},${t.y.toFixed(1)}`}).join(" "),x=[];if(x.push('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1180 860" font-family="ui-monospace, \'Geist Mono\', Menlo, monospace">','<defs><linearGradient id="stg" x1="0" y1="0" x2="0" y2="1"><stop offset="0" stop-color="#12161d"/><stop offset="1" stop-color="#0b0d12"/></linearGradient>','<clipPath id="planclip"><rect x="36" y="36" width="740" height="700"/></clipPath></defs>','<rect width="1180" height="860" rx="14" fill="url(#stg)"/>',`<rect x="12" y="12" width="1156" height="836" rx="10" fill="none" stroke="${ir}" stroke-opacity="0.16"/>`),a&&e.aerial&&i&&i.ring_px.length>=3&&r>0){let t=e.aerial,a=d*t.feet_per_px,n=0,s=0,o=0;for(let e=0;e<Math.min(i.ring_ft.length,i.ring_px.length);e++){let t=u(i.ring_ft[e]);n+=t.x-i.ring_px[e].x*a,s+=t.y-i.ring_px[e].y*a,o++}o>0&&(n/=o,s/=o,x.push('<g clip-path="url(#planclip)">',`<image href="${ic(t.image_url)}" x="${n.toFixed(1)}" y="${s.toFixed(1)}" width="${(t.width_px*a).toFixed(1)}" height="${(t.height_px*a).toFixed(1)}" opacity="${r}" preserveAspectRatio="none"/>
1`,'<rect x="36" y="36" width="740" height="700" fill="#0b0d12" opacity="0.35"/>',"</g>"))}else{x.push(`<g stroke="${ii}" stroke-opacity="0.05">`);for(let e=36;e<=776;e+=40)x.push(`<line x1="${e}" y1="36" x2="${e}" y2="${736}"/>`);for(let e=36;e<=736;e+=40)x.push(`<line x1="36" y1="${e}" x2="${776}" y2="${e}"/>`);x.push("</g>")}if(i){let t,a;for(let t of e.footprints){let e="alley"===t.kind||"drive"===t.kind?' stroke-dasharray="6 5"':"",a="residence"===t.kind||"outbuilding"===t.kind?`fill="${ir}" fill-opacity="0.06"`:'fill="none"';x.push(`<polygon points="${m(t.ring)}" ${a} stroke="${is}" stroke-width="1.8" stroke-opacity="0.85"${e}/>`);let r=u({x:t.ring.reduce((e,t)=>e+t.x,0)/t.ring.length,y:t.ring.reduce((e,t)=>e+t.y,0)/t.ring.length}),i="residence"===t.kind||"outbuilding"===t.kind?`${t.area_sqft.toLocaleString()} SF \xb7 ${ic(t.source)}`:"";x.push(`<text x="${r.x}" y="${r.y}" fill="${is}" font-size="11" letter-spacing="2" text-anchor="middle" stroke="#0b0d12" stroke-width="3" paint-order="stroke">${ic(t.label)}</text>`),i&&x.push(`<text x="${r.x}" y="${r.y+13}" fill="${is}" fill-opacity="0.75" font-size="8" letter-spacing="1" text-anchor="middle" stroke="#0b0d12" stroke-width="3" paint-order="stroke">${ic(i)}</text>`)}for(let e of(x.push(`<polygon points="${m(i.ring_ft)}" fill="none" stroke="${ir}" stroke-width="2.6" stroke-linejoin="round"/>`),i.ring_ft)){let t=u(e);x.push(`<circle cx="${t.x}" cy="${t.y}" r="3" fill="none" stroke="${ir}" stroke-width="1.2"/>`)}for(let e of i.edges){let t=u(e.a),a=u(e.b),r=(t.x+a.x)/2,n=(t.y+a.y)/2,s=180*Math.atan2(a.y-t.y,a.x-t.x)/Math.PI;s>90&&(s-=180),s<-90&&(s+=180);let o=u({x:i.ring_ft.reduce((e,t)=>e+t.x,0)/i.ring_ft.length,y:i.ring_ft.reduce((e,t)=>e+t.y,0)/i.ring_ft.length}
1),l=-(a.y-t.y),d=a.x-t.x,c=Math.hypot(l,d)||1,p=(r-o.x)*l+(n-o.y)*d>0?1:-1,m=r+l/c*14*p,f=n+d/c*14*p;x.push(`<text x="${m}" y="${f}" transform="rotate(${s.toFixed(1)} ${m} ${f})" fill="${ii}" font-size="10" letter-spacing="1" text-anchor="middle" stroke="#0b0d12" stroke-width="3" paint-order="stroke">${ic(e.bearing)} \xb7 ${e.length_ft.toFixed(1)}'</text>`)}let r=e.placement?.sight_line;if(r){let e=u(r.a),t=u(r.b),a="derived"===r.basis?ii:il;x.push(`<line x1="${e.x}" y1="${e.y}" x2="${t.x}" y2="${t.y}" stroke="${a}" stroke-width="1.2" stroke-dasharray="10 6" stroke-opacity="0.85"/>`,`<text x="${t.x}" y="${t.y-6}" fill="${a}" font-size="9" letter-spacing="2" text-anchor="middle" stroke="#0b0d12" stroke-width="3" paint-order="stroke">SIGHT-LINE${"assumed"===r.basis?" (ASSUMED)":""}</text>`)}for(let t of e.placement?.elements??[]){let e="tanning_ledge"===t.move,a="pavilion_kitchen"===t.move,r="place_pool"===t.move?3:2,i=e||a?' stroke-dasharray="7 5"':"";x.push(`<polygon points="${m(t.ring)}" fill="${"place_pool"===t.move?io:"none"}" fill-opacity="${.08*("place_pool"===t.move)}" stroke="${io}" stroke-width="${r}" stroke-linejoin="round"${i}/>`);let n=u({x:t.ring.reduce((e,t)=>e+t.x,0)/t.ring.length,y:t.ring.reduce((e,t)=>e+t.y,0)/t.ring.length});e?x.push(`<text x="${n.x}" y="${n.y+3}" fill="${io}" fill-opacity="0.8" font-size="8" letter-spacing="1" text-anchor="middle" stroke="#0b0d12" stroke-width="3" paint-order="stroke">TANNING LEDGE</text>`):x.push(`<text x="${n.x}" y="${n.y+3}" fill="${io}" font-size="10.5" letter-spacing="1.5" text-anchor="middle" stroke="#0b0d12" stroke-width="3" paint-order="stroke">${ic(t.label)}</text>`)}let n=e.placement?.elements.find(e=>"place_pool"===e.move);if(n){let e=[];for(let[t,a]of[[1,2],[3,0]]){let r=n.ring[t],i=n.ring[a],s={x:(r.x+i.x)/2,y:(r.y+i.y)/2},o={x:n.ring.reduce((e,t)=>e+t.x,0)/4,y:n.ring.reduce((e,t)=>e+t.y,0)/4},l=s.x-o.x,d=s.y-o.y,c=Math.hypot(l,d)||1;e.push({p:s,d:{x:l/c,y:d/c}})}for(let{p:t,d:a}of e){let e=function(e,t,a){let r=null;for(let i=0;i<a.length;i++){let n=a[i],s=a[(i+1)%a.length],o=s.x-n.x,l=s.y-n.y,d=t.x*l-t.y*o;if(1e-9>Math.abs(d))continue;let c=((n.x-e.x)*l-(n.y-e.y)*o)/d,p=Math.abs(o)>Math.abs(l)?(e.x+c*t.x-n.x)/o:(e.y+c*t.y-n.y)/l;c>.01&&p>=0&&p<=1&&(null===r||c<r)&&(r=c)}return r}(t,a,i.ring_ft);if(null==e||e>200)continue;let r=u(t),n=u({x:t.x+a.x*e,y:t.y+a.y*e}),s=(r.x+n.x)/2,o=(r.y+n.y)/2;x.push(`<line x1="${r.x}" y1="${r.y}" x2="${n.x}" y2="${n.y}" stroke="${ii}" stroke-width="1" stroke-opacity="0.85"/>`,`<line x1="${r.x-4}" y1="${r.y-4}" x2="${r.x+4}" y2="${r.y+4}" stroke="${ii}" stroke-width="1.2"/>`,`<line x1="${n.x-4}" y1="${n.y-4}" x2="${n.x+4}" y2="${n.y+4}" stroke="${ii}" stroke-width="1.2"/>`,`<text x="${s}" y="${o-5}" fill="${ii}" font-size="10" text-anchor="middle" stroke="#0b0d12" stroke-width="3" paint-order="stroke">${ic(iu(e))}</text>`)}let t=(e,t,a)=>{let r=u(n.ring[e]),i=u(n.ring[t]),s=180*Math.atan2(i.y-r.y,i.x-r.x)/Math.PI;s>90&&(s-=180),s<-90&&(s+=180);let o=(r.x+i.x)/2,l=(r.y+i.y)/2;x.push(`<text x="${o}" y="${l+4}" transform="rotate(${s.toFixed(1)} ${o} ${l})" fill="${io}" font-size="9.5" text-anchor="middle" stroke="#0b0d12" stroke-width="3" paint-order="stroke">${ic(a)}</text>`)};t(0,1,iu(n.w_ft)),t(1,2,iu(n.l_ft))}let s=(t=o/5,(a=[5,10,20,25,50,100,150,200]).reduce((e,a)=>Math.abs(a-t)<Math.abs(e-t)?a:e,a[0])),l=s*d,c=50,p=716;x.push(`<rect x="${c}" y="${p}" width="${l.toFixed(1)}" height="6" fill="${ir}" stroke="#0b0d12" stroke-width="1"/>`,`<rect x="${c}" y="${p}" width="${(l/2).toFixed(1)}" height="6" fill="#0b0d12" stroke="${ir}" stroke-width="1"/>`,`<text x="${c}" y="${p-7}" fill="${ir}" font-size="10">0</text>`,`<text x="${c+l}" y="${p-7}" fill="${ir}" font-size="10" text-anchor="end">${s} ft</text>`),x.push(`<g transform="translate(${742} ${80})">`,`<circle r="20" fill="#0b0d12" fill-opacity="0.55" stroke="${ii}" stroke-opacity="0.5"/>`,`<path d="M0 -14 L6 6 L0 1 L-6 6 Z" fill="${is}"/>`,`<text x="0" y="-24" fill="${ii}" font-size="9" text-anchor="middle" letter-spacing="1">N</text>`,"</g>")}let f=76,h=e=>x.push(e);h(`<line x1="790" y1="52" x2="790" y2="808" stroke="${ir}" stroke-opacity="0.28"/>`),h(`<text x="812" y="${f}" fill="${ir}" font-family="${id}" font-size="21" letter-spacing="4">VIZHAUS</text>`),f+=20,h(`<text x="812" y="${f}" fill="${ii}" font-size="8.5" letter-spacing="3">TRUE-SCALE SITE PLAN \xb7 SITE_PLAN.V1</text>`),f+=16,h(`<line x1="812" y1="${f}" x2="1084" y2="${f}" stroke="${ir}" stroke-opacity="0.2"/>`),f+=22;let g=(e,t,a=ir)=>{for(let r of(h(`<text x="812" y="${f}" fill="${ii}" font-size="8" letter-spacing="2">${ic(e)}</text>`),f+=15,ip(t,40)))h(`<text x="812" y="${f}" fill="${a}" font-size="11">${ic(r)}</text>`),f+=14;f+=8};for(let[t,a,r]of(g("SITE",e.formatted??e.address??"â"),e.parcel&&g("LOT (COUNTY RECORD)",`${null!=e.parcel.area_sqft?e.parcel.area_sqft.toLocaleStr
1ing()+" SF":"area n/a"} \xb7 ${e.parcel.perimeter_ft.toLocaleString()} ft perimeter \xb7 ${e.parcel.ring_ft.length} vertices${e.parcel.apn?" · APN "+e.parcel.apn:""}`),e.aerial&&g("IMAGERY",`${e.aerial.provider} \xb7 z${e.aerial.zoom} \xb7 ${e.aerial.feet_per_px.toFixed(3)} ft/px (Web Mercator)`),g("ALIGNMENT GATE",`${e.alignment.confidence.toUpperCase()} \xb7 frameâimagery residual ${e.alignment.max_residual_ft.toFixed(2)} ft â eyeball the boundary on the underlay before trusting placement.`,"high"===e.alignment.confidence?is:il),h(`<text x="812" y="${f}" fill="${ii}" font-size="8" letter-spacing="2">LEGEND</text>`),f+=14,[[ir,"solid","Recorded parcel boundary"],[is,"solid","Public-record footprint"],[io,"solid","Proposed (true WÃL)"],[io,"dash","Proposed accessory"],[ii,"dash","Sight-line / dimension"]]))h(`<line x1="812" y1="${f-3}" x2="836" y2="${f-3}" stroke="${t}" stroke-width="3"${"dash"===a?' stroke-dasharray="6 4"':""}/>`),h(`<text x="844" y="${f}" fill="${ir}" font-size="10">${ic(r)}</text>`),f+=15;if(f+=10,e.placement)for(let t of(h(`<text x="812" y="${f}" fill="${ii}" font-size="8" letter-spacing="2">PLACEMENT RULES \xb7 APPLIED AS DATA</text>`),f+=15,e.placement.rules)){let e=t.pass?"â":"â",a=t.pass?io:"#e58e7b";for(let r of(h(`<text x="812" y="${f}" fill="${a}" font-size="10.5">${e}</text>`),ip(`${t.rule} â ${t.note}`,44)))h(`<text x="826" y="${f}" fill="${ir}" fill-opacity="0.8" font-size="8.5">${ic(r)}</text>`),f+=11;f+=5}for(let t of e.data_notes){for(let e of ip(`â ${t}`,48))h(`<text x="812" y="${f}" fill="${il}" fill-opacity="0.85" font-size="8.5">${ic(e)}</text>`),f+=11;f+=4}x.push(`<line x1="28" y1="794" x2="1152" y2="794" stroke="${ir}" stroke-opacity="0.2"/>`,`<text x="36" y="${814}" fill="${ir}" font-family="${id}" font-size="13">${ic(e.formatted??"Site plan")}</text>`,`<text x="36" y="${830}" fill="${ii}" font-size="8" letter-spacing="2">DATE ${ic(e.created_at.slice(0,10))} \xb7 SHEET S-1 \xb7 SCALE 1" = ${Math.round(1180/11/d)}' ON AN 11\xd78.5 PRINT</text>`);let b=ip(e.disclaimer,118),v=814;for(let e of b)x.push(`<text x="1144" y="${v}" fill="${ir}" fill-opacity="0.42" font-size="8.5" text-anchor="end">${ic(e)}</text>`),v+=11;return x.push("</svg>"),x.join("\n")}let ix=["BOUNDARY","STRUCTURES","FLATWORK","POOL-PROPOSED","SPA-PROPOSED","LEDGE-PROPOSED","PAVILION-PROPOSED","SIGHT-LINE","DIMS","NOTES"],ih=e=>String(Math.round(1e3*e)/1e3);function ig(e,t,a,r){if(!(a.length<2)){for(let i of(e.push("0","POLYLINE","8",t,"66","1","70",r?"1":"0"),a))e.push("0","VERTEX","8",t,"10",ih(i.x),"20",ih(i.y),"30","0");e.push("0","SEQEND")}}function ib(e,t,a,r,i){let n=i.replace(/[\r\n]+/g," ").trim().replace(/[·]/g,"-").replace(/[â¥]/g,">=").replace(/[â¤]/g,"<=").replace(/[Ã]/g,"x").replace(/[â]/g,"<->").replace(/[ââ]/g,"-").replace(/[°]/g,"deg").replace(/[ââ]/g,"'").replace(/[ââ]/g,'"').replace(/[âââ]/g,"*").replace(/[^\x20-\x7E]/g,"?");n&&e.push("0","TEXT","8",t,"10",ih(a.x),"20",ih(a.y),"30","0","40",ih(r),"1",n)}function iv(e){return{x:e.reduce((e,t)=>e+t.x,0)/e.length,y:e.reduce((e,t)=>e+t.y,0)/e.length}}let iy={place_pool:"POOL-PROPOSED",raised_spa:"SPA-PROPOSED",tanning_ledge:"LEDGE-PROPOSED",pavilion_kitchen:"PAVILION-PROPOSED"};function i_(e,t,a){let r=URL.createObjectURL(new Blob([e],{type:t})),i=document.createElement("a");i.href=r,i.download=a,i.click(),URL.revokeObjectURL(r)}function ij({address:e}){let[r,n]=a.useState(e??""),[s,o]=a.useState(!1),[l,d]=a.useState(null),[c,p]=a.useState(null),[u,m]=a.useState(!0),[x,f]=a.useState(14),[h,g]=a.useState(30),[b,v]=a.useState(!0),[y,_]=a.useState(!0),[j,w]=a.useState(!1);a.useEffect(()=>{e&&!c&&e!==r&&n(e)},[e]);let k=a.useCallback(async()=>{if(r.trim()){o(!0),d(null);try{let e=[{kind:"place_pool",w_ft:x,l_ft:h}];b&&e.push({kind:"raised_spa"}),y&&e.push({kind:"tanning_ledge"}),j&&e.push({kind:"pavilion_kitchen"});let t=await fetch("/api/site-plan",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({address:r.trim(),moves:e})}),a=await t.json();a.ok&&a.doc?p(a.doc):(d(a.error||"Could not compose the site plan."),p(null))}catch{d("Site-plan service unreachable.")}finally{o(!1)}}},[r,x,h,b,y,j]),N=a.useMemo(()=>c?im(c,{aerialOpacity:.55*!!u}):null,[c,u]),S=a.useMemo(()=>(c?.formatted??r??"site").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,60)||"site",[c,r]),z=a.useCallback(()=>
1{if(!c)return;let e=window.open("","_blank","noopener,noreferrer");e&&(e.document.write(`<!doctype html><html><head><meta charset="utf-8"><title>${S}-site-plan</title><style>@page{size:landscape;margin:8mm}body{margin:0;background:#060609}svg{width:100%;height:auto}</style></head><body>${im(c,{aerialOpacity:.55*!!u})}</body></html>`),e.document.close(),e.focus(),setTimeout(()=>e.print(),400))},[c,S,u]),M=c?.alignment.confidence;return(0,t.jsxs)("section",{className:"panel flex flex-col gap-3 p-4",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,t.jsxs)("p",{className:"rail-label inline-flex items-center gap-1.5",children:[(0,t.jsx)(t9.Compass,{className:"size-3.5 text-primary"})," True-dimension site sheet (CAD)"]}),c?(0,t.jsxs)("span",{className:`figure-mono rounded-md border px-2 py-0.5 text-[0.6rem] uppercase tracking-[0.18em] ${"high"===M?"border-primary/40 text-primary":"border-amber-500/40 text-amber-500"}`,children:["alignment ",M]}):null]}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("input",{value:r,onChange:e=>n(e.target.value),onKeyDown:e=>"Enter"===e.key&&k(),placeholder:"5438 Bonita Ave, Dallas TX",className:"min-w-0 flex-1 rounded-lg border border-border bg-card/40 px-3 py-2 text-sm text-foreground outline-none focus:border-primary/60"}),(0,t.jsxs)("button",{onClick:k,disabled:s||!r.trim(),className:"cta-emerald inline-flex shrink-0 items-center gap-2 rounded-lg px-3 py-2 text-sm font-semibold text-white active:scale-[0.99] disabled:opacity-60",children:[s?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(i.Ruler,{className:"size-4"}),s?"Drawingâ¦":"Draw sheet"]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-2 text-[0.7rem] text-muted-foreground",children:[(0,t.jsxs)("label",{className:"inline-flex items-center gap-1.5",children:["Pool",(0,t.jsx)("input",{type:"number",value:x,min:6,max:40,onChange:e=>f(Math.max(6,Math.min(40,Number(e.target.value)))),className:"w-14 rounded-md border border-border bg-card/40 px-2 py-1 text-xs text-foreground outline-none"}),"Ã",(0,t.jsx)("input",{type:"number",value:h,min:10,max:80,onChange:e=>g(Math.max(10,Math.min(80,Number(e.target.value)))),className:"w-14 rounded-md border border-border bg-card/40 px-2 py-1 text-xs text-foreground outline-none"}),"ft"]}),(0,t.jsxs)("label",{className:"inline-flex items-center gap-1.5",children:[(0,t.jsx)("input",{type:"checkbox",checked:b,onChange:e=>v(e.target.checked),className:"accent-[var(--ion,#7ff0d2)]"})," raised spa"]}),(0,t.jsxs)("label",{className:"inline-flex items-center gap-1.5",children:[(0,t.jsx)("input",{type:"checkbox",checked:y,onChange:e=>_(e.target.checked),className:"accent-[var(--ion,#7ff0d2)]"})," tanning ledge"]}),(0,t.jsxs)("label",{className:"inline-flex items-center gap-1.5",children:[(0,t.jsx)("input",{type:"checkbox",checked:j,onChange:e=>w(e.target.checked),className:"accent-[var(--ion,#7ff0d2)]"})," pavilion + kitchen"]})]}),l?(0,t.jsxs)("p",{className:"inline-flex items-center gap-1.5 text-xs text-amber-500",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-3.5"})," ",l]}):null,c&&N?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"overflow-hidden rounded-xl border border-border [&_svg]:block [&_svg]:h-auto [&_svg]:w-full","data-testid":"site-sheet-svg",dangerouslySetInnerHTML:{__html:N}}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("button",{type:"button",onClick:()=>m(e=>!e),className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-card/60 px-2.5 py-1.5 text-[0.68rem] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[u?(0,t.jsx)(it,{className:"size-3.5"}):(0,t.jsx)(tq.Eye,{className:"size-3.5"}),u?"Hide aerial gate":"Show aerial gate"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>i_(im(c),"image/svg+xml;charset=utf-8",`${S}-site-plan.svg`),className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-card/60 px-2.5 py-1.5 text-[0.68rem] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(P.Download,{className:"size-3.5"})," SVG"]}),(0,t.jsxs)("button",{type:"button",onClick:()=>i_(function(e){let t=[];for(let e of(t.push("0","SECTION","2","HEADER","9","$INSUNITS","70","2","0","ENDSEC"),t.push("0","SECTION","2","TABLES","0","TABLE","2","LAYER","70",String(ix.length)),ix)){let a=e.endsWith("PROPOSED")?"2":"SIGHT-LINE"===e||"DIMS"===e?"4":"FLATWORK"===e?"8":"7";t.push("0","LAYER","2",e,"70","0","62",a,"6","CONTINUOUS")}if(t.push("0","ENDTAB","0","ENDSEC"),t.push("0","SECTION","2","ENTITIES"),e.parcel){for(let a of(ig(t,"BOUNDARY",e.parcel.ring_ft,!0),e.parcel.edges))ib(t,"BOUNDARY",{x:(a.a.x+a.b.x)/2,y:(a.a.y+a.b.y)/2},1.2,`${a.bearing} ${a.length_ft.toFixed(1)}'`);let a=iv(e.parcel.ring_ft);null!=e.parcel.area_sqft&&ib(t,"BOUNDARY",{x:a.x,y:-4}
1,1.5,`LOT ${e.parcel.area_sqft.toLocaleString()} SF (COUNTY RECORD)${e.parcel.apn?` APN ${e.parcel.apn}`:""}`)}for(let a of e.footprints){let e="alley"===a.kind||"drive"===a.kind?"FLATWORK":"STRUCTURES";ig(t,e,a.ring,!0),ib(t,e,iv(a.ring),1,"residence"===a.kind||"outbuilding"===a.kind?`${a.label} (${a.source.toUpperCase()})`:a.label)}if(e.placement){for(let a of e.placement.elements){let e=iy[a.move]??"POOL-PROPOSED";ig(t,e,a.ring,!0);let r=iv(a.ring);ib(t,e,r,.9,a.label),"place_pool"===a.move&&ib(t,"DIMS",{x:r.x,y:r.y-2.5},.8,`${a.w_ft.toFixed(1)} x ${a.l_ft.toFixed(1)} FT (PROPOSED)`)}if(e.placement.sight_line){let a=e.placement.sight_line;t.push("0","LINE","8","SIGHT-LINE","10",ih(a.a.x),"20",ih(a.a.y),"30","0","11",ih(a.b.x),"21",ih(a.b.y),"31","0"),ib(t,"SIGHT-LINE",a.b,.8,`SIGHT-LINE${"assumed"===a.basis?" (ASSUMED)":""}`)}}let a=e.bounds_ft.h+4;if(ib(t,"NOTES",{x:0,y:a},1.4,`${e.formatted??e.address??"SITE"} - TRUE-SCALE SITE PLAN (site_plan.v1)`),a+=2.2,e.placement)for(let r of e.placement.rules)ib(t,"NOTES",{x:0,y:a},.8,`[${r.pass?"PASS":"FAIL"}] ${r.id}: ${r.note}`),a+=1.6;for(let r of e.data_notes)ib(t,"NOTES",{x:0,y:a},.8,r),a+=1.6;return ib(t,"NOTES",{x:0,y:a+.6},.9,e.disclaimer),t.push("0","ENDSEC","0","EOF"),t.join("\n")+"\n"}(c),"application/dxf",`${S}-site-plan.dxf`),className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-card/60 px-2.5 py-1.5 text-[0.68rem] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(tY.FileDown,{className:"size-3.5"})," DXF"]}),(0,t.jsxs)("button",{type:"button",onClick:z,className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-card/60 px-2.5 py-1.5 text-[0.68rem] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(ia.Printer,{className:"size-3.5"})," Print / PDF"]})]}),(0,t.jsx)("p",{className:"text-[0.65rem] leading-relaxed text-muted-foreground",children:c.alignment.note}),(0,t.jsx)("p",{className:"text-[0.62rem] leading-relaxed text-muted-foreground/70",children:c.disclaimer})]}):(0,t.jsx)("p",{className:"text-[0.65rem] text-muted-foreground",children:"County-recorded lot boundary with surveyor bearings, public-record building footprints, and a deterministic rule-driven pool placement â drawn at true scale over the measured aerial, exported as SVG / DXF / PDF. The geometry source of truth the backyard render locks to."})]})}async function iw(e,t,a=1280){let r=e.viewBox.baseVal,i=r.width>0?Math.round(a*(r.height/r.width)):a,n=new XMLSerializer().serializeToString(e),s=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(n)))}`,o=new Image;await new Promise((e,t)=>{o.onload=()=>e(),o.onerror=()=>t(Error("Could not rasterize the site schematic.")),o.src=s});let l=document.createElement("canvas");l.width=a,l.height=i;let d=l.getContext("2d");if(!d)throw Error("Canvas unavailable.");return d.fillStyle="#fbfaf6",d.fillRect(0,0,a,i),d.drawImage(o,0,0,a,i),new File([await new Promise((e,t)=>l.toBlob(a=>a?e(a):t(Error("toBlob failed")),"image/png"))],t,{type:"image/png"})}function ik(e,t,a){let[r,i,n,s]=e,o=n-r,l=s-i;return r<0&&(r=0,n=o),n>t&&(n=t,r=t-o),i<0&&(i=0,s=l),s>a&&(s=a,i=a-l),[r,i,n,s]}function iN(){let e=(0,b.usePrefersReducedMotion)(),[n,s]=a.useState(""),[o,l]=a.useState(50),[d,c]=a.useState(140),[p,u]=a.useState(()=>r2(50,140)),[m,x]=a.useState(null),[h,g]=a.useState(!1),[v,y]=a.useState(null),[_,j]=a.useState(!1),w=a.useRef(null),k=a.useRef(null),N=a.useCallback(e=>{let t=k.current;if(!t)return;let a=(e.clientX-t.sx)*t.fppx,r=-(e.clientY-t.sy)*t.fppy;if("move"===t.mode){var i;let e=(i=t.pool,[i[0]+a,i[1]+r,i[2]+a,i[3]+r]);u(t=>{let a=ik(e,t.lot.w,t.lot.d),{spa:r,ledge:i}=r1(a);return{...t,pool:a,spa:r,ledge:i}})}else u(e=>{let[i,n,s,o]=t.pool;"sw"===t.corner?(i+=a,n+=r):"se"===t.corner?(s+=a,n+=r):("nw"===t.corner?i+=a:s+=a,o+=r),i=Math.max(0,Math.min(i,s-6)),n=Math.max(0,Math.min(n,o-6)),s=Math.min(e.lot.w,Math.max(s,i+6)),o=Math.min(e.lot.d,Math.max(o,n+6));let l=[i,n,s,o],{spa:d,ledge:c}=r1(l);return{...e,pool:l,spa:d,ledge:c}})},[]),S=a.useCallback(()=>{k.current=null,window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",S
1)},[N]),M=a.useCallback((e,t)=>{let a=w.current?.querySelector("svg");if(!a)return;let r=a.getBoundingClientRect(),i={sx:e.clientX,sy:e.clientY,pool:p.pool,fppx:(p.lot.w+16)/r.width,fppy:(p.lot.d+16)/r.height};k.current="move"===t?{mode:"move",...i}:{mode:"resize",corner:t,...i},window.addEventListener("pointermove",N),window.addEventListener("pointerup",S)},[p.pool,p.lot.w,p.lot.d,N,S]),E=a.useCallback(e=>M(e,"move"),[M]),D=a.useCallback((e,t)=>M(t,e),[M]),P=a.useCallback(()=>{u(e=>{var t;let a,r,i,n,s=ik((a=((t=e.pool)[0]+t[2])/2,r=(t[1]+t[3])/2,i=r0(t),[a-(n=t[3]-t[1])/2,r-i/2,a+n/2,r+i/2]),e.lot.w,e.lot.d),{spa:o,ledge:l}=r1(s);return{...e,pool:s,spa:o,ledge:l}})},[]),O=p.pool[3]-p.pool[1]>=p.pool[2]-p.pool[0],[L,A]=a.useState(!1),R=a.useCallback(()=>{u(r2(o,d)),x(null),y(null),j(!1),A(!1)},[o,d]),T=a.useCallback(()=>{aD(e=>({...e,siteGeo:p,updated_at:new Date().toISOString()})),A(!0)},[p]),[q,I]=a.useState(!1),W=a.useCallback(async()=>{I(!0);try{let e=await fetch("/api/site",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({geometry:p})}),t=await e.json();t.ok&&t.id&&window.open(`/ar/site/${t.id}`,"_blank","noopener,noreferrer")}catch{}finally{I(!1)}},[p]),G=a.useCallback(async()=>{let e=w.current?.querySelector("svg");if(e){g(!0),y(null),j(!1);try{var t;let a,r,i,n=await iw(e,"site-aerial-schematic.png"),s=await U(n),{instruction:o,preserve:l}=(a=(t=p).pool[2]-t.pool[0],r=t.pool[3]-t.pool[1],i=["Turn this flat colored site diagram into a photorealistic TOP-DOWN DRONE photograph of a residential backyard at warm golden hour. Frame the rear yard so the pool is the dominant subject.",`- The large blue rectangle ${r>=a?"running VERTICALLY (long axis away from the house)":"running horizontally (parallel to the house)"} = a ${Math.round(a)}\xd7${Math.round(r)} ft in-ground pool with pearl-to-deep-blue plaster and calm, still water.`],t.spa&&i.push("- The small square at the house end of the pool = a raised limestone spa with a sheet spillway flowing into the pool."),i.push("- The cream band wrapping the pool = a 14-inch honed limestone coping; beyond it, manicured emerald artificial turf with subtle mow stripes."),t.ledge&&i.push("- The lighter blue str
1ip at the far end of the pool = a sun / tanning ledge in shallow water."),i.push("- The large tan rectangle = the two-story house â show only a SLICE of its dark OXFORD-GREY shingle roof at the near edge (not brown, not weathered wood)."),t.garage&&i.push("- The grey rectangle at the rear = a detached garage with a matching dark oxford-grey shingle roof."),t.beds?.length&&i.push("- The dark green patches = planting beds with low shrubs and seasonal color."),i.push("Remove every flat cartoon color and hard outline â it must read as a real drone photo, not a diagram. Preserve the EXACT footprint, position, scale, orientation, and proportions of every element."),{instruction:i.join("\n"),preserve:"The exact footprint, position, scale, orientation, and proportions of the pool, spa, coping, tanning ledge, house, garage, and planting beds; the top-down camera framing."}),d=await B({source_image_url:s.url,edit_instruction:o,preserve:l});d.output_url?x(d.output_url):d.mocked?j(!0):y("Aerial render returned no image.")}catch(e){y(e instanceof Error?e.message:"Aerial render failed.")}finally{g(!1)}}},[p]);return(0,t.jsxs)(f.motion.div,{...(0,b.fadeUp)(e),className:"flex flex-col gap-5 lg:flex-row lg:items-start",children:[(0,t.jsxs)("aside",{className:"flex w-full shrink-0 flex-col gap-4 lg:w-[360px]",children:[(0,t.jsx)(z,{line:!0,step:"Step 04",kicker:"Site & pool",title:"Magic site plan"}),(0,t.jsxs)("section",{className:"panel flex flex-col gap-3 p-4",children:[(0,t.jsx)("p",{className:"rail-label",children:"â Property (no survey needed)"}),(0,t.jsxs)("label",{className:"flex items-center gap-2 rounded-lg border border-border bg-card/40 px-3 py-2",children:[(0,t.jsx)(rW.MapPin,{className:"size-4 shrink-0 text-primary"}),(0,t.jsx)("input",{value:n,onChange:e=>s(e.target.value),placeholder:"123 Whaley St, Dallas TX",className:"w-full bg-transparent text-sm text-foreground outline-none placeholder:text-muted-foreground"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"rail-label",children:"Lot width (ft)"}),(0,t.jsx)("input",{type:"number",value:o,min:20,onChange:e=>l(Math.max(20,Number(e.target.value))),className:"rounded-lg border border-border bg-card/40 px-3 py-2 text-sm text-foreground outline-none focus:border-primary/60"})]}),(0,t.jsxs)("label",{className:"flex flex-col gap-1",children:[(0,t.jsx)("span",{className:"rail-label",children:"Lot depth (ft)"}),(0,t.jsx)("input",{type:"number",value:d,min:40,onChange:e=>c(Math.max(40,Number(e.target.value))),className:"rounded-lg border border-border bg-card/40 px-3 py-2 text-sm text-foreground outline-none focus:border-primary/60"})]})]}),(0,t.jsxs)("button",{onClick:R,className:"cta-emerald flex items-center justify-center gap-2 rounded-lg py-2.5 text-sm font-semibold text-white active:scale-[0.99]",children:[(0,t.jsx)(r.Wand2,{className:"size-4"})," Lay out the site"]}),(0,t.jsx)("p",{className:"text-[0.65rem] text-muted-foreground",children:"We place a to-scale house + sight-line pool from the lot dimensions â no survey or site plan required. Real addressâparcel calibration is the next data hook."})]}),(0,t.jsxs)("section",{className:"panel flex flex-col gap-3 p-4",children:[(0,t.jsx)("p",{className:"rail-label",children:"â¶ Photoreal aerial"}),(0,t.jsxs)("button",{onClick:G,disabled:h,className:"cta-emerald flex items-center justify-center gap-2 rounded-lg py-3 text-sm font-semibold text-white active:scale-[0.99] disabled:opacity-60",children:[h?(0,t.jsx)($.Loader2,{className:"size-4 animate-spin"}):(0,t.jsx)(Z.Sparkles,{className:"size-4"}),h?"Rendering drone shotâ¦":"Generate photoreal aerial"]}),(0,t.jsx)("p",{className:"text-[0.65rem] text-muted-foreground",children:"The colored schematic is rasterized and run through the FAL EDIT moat with a per-shape material legend â a top-down drone photo. Same feet-geometry as the plan."}),(0,t.jsxs)("button",{type:"button",onClick:T,className:"inline-flex items-center justify-center gap-2 rounded-lg border border-border bg-card/60 py-2 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground",children:[L?(0,t.jsx)(F.Check,{className:"size-3.5 text-primary"}):(0,t.jsx)(rr.FileText,{className:"size-3.5"}),L?"Added to proposal":"Add site plan to proposal"]}),(0,t.jsxs)("button",{type:"button",onClick:W,disabled:q,className:"inline-flex items-center justify-center gap-2 rounded-lg border border-border bg-card/60 py-2 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground disabled:opacity-60",children:[q?(0,t.jsx)($.Loader2,{className:"size-3.5 animate-spin"}):(0,t.jsx)(t6.Box,{className:"size-3.5"}),q?"Buildingâ¦":"Cast pool in AR"]})]}),(0,t.jsx)(r6,{address:n})]}),(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-4",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,t.jsxs)("span",{className:"rail-label",children:["To-scale site plan · ",p.label]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-[0.65rem] text-muted-foreground",children:[(0,t.jsx)(rB,{className:"size-3.5"})," drag · corner handles resize"]}),(0,t.jsxs)("button",{type:"button",onClick:P,className:"inline-flex items-center gap-1.5 rounded-md border border-border bg-card/60 px-2.5 py-1 text-[0.65rem] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[(0,t.jsx)(rG,{className:"size-3.5"})," Rotate 90° · ",O?"vertical":"horizontal"]})]})]}),(0,t.jsx)("div",{ref:w,className:"glow-emerald overflow-hidden rounded-2xl",children:(0,t.jsx)(r3,{geo:p,interactive:!0,onPoolPointerDown:E,onHandlePointerDown:D,className:"block w-full select-none"})}),v&&(0,t.jsxs)("div",{className:"flex items-center gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-sm text-destructive",children:[(0,t.jsx)(C.AlertTriangle,{className:"size-4"})," ",v]}),h&&!m&&(0,t.jsxs)("div",{className:"panel flex items-center gap-3 p-4",children:[(0,t.jsx)($.Loader2,{className:"size-4 animate-spin text-primary"}),(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:"Turning the schematic into a photoreal drone shotâ¦"})]}),_&&!m&&(0,t.jsxs)("div",{className:"flex items-start gap-2.5 rounded-md border border-border bg-muted/40 px-3.5 py-3 text-sm text-muted-foreground",children:[(0,t.jsx)(Z.Sparkles,{className:"mt-0.5 size-4 shrink-0 text-primary"}),(0,t.jsxs)("span",{children:[(0,t.jsx)("strong",{className:"text-foreground",children:"Mock preview â no FAL_KEY."})," The to-scale schematic was rasterized and the photoreal-aerial prompt + per-shape material legend were built, but no drone shot was rendered. Add a FAL_KEY to generate the photoreal aerial."]})]}),m&&(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)("span",{className:"rail-label",children:"Photoreal aerial"}),(0,t.jsx)("div",{className:"glow-emerald overflow-hidden rounded-2xl",children:(0,t.jsx)("img",{src:m,alt:"Photoreal aerial",className:"block w-full"})})]}),(0,t.jsxs)("div",{className:"panel flex items-start gap-3 p-4",children:[(0,t.jsx)(i.Ruler,{className:"mt-0.5 size-4 shrink-0 text-primary"}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:["The plan and the aerial share the ",(0,t.jsx)("strong",{children:"same feet-geometry"})," â define the pool once, render it to scale and photoreal. Drag the pool; both regenerate from the same model."]})]}),(0,t.jsx)(ie,{address:n,geometry:p}),(0,t.jsx)(ij,{address:n})]})]})}let iS={budget:"Good",mid:"Better",luxury:"Best"},iz={budget:"Budget",mid:"Mid",luxury:"Luxury"},i$={countertop:"Countertops",tile:"Tile",flooring:"Flooring",cabinet:"Cabinetry",plumbing_fixture:"Plumbing fixtures",lighting:"Lighting",hardware:"Hardware",siding:"Siding & masonry",landscaping:"Landscape",lumber:"Lumber & framing","finish-trim":"Trim & millwork",composite:"Bundles",other:"Other scopes"};function iC({pkg:e,onOpenEstimate:a}){let r=function(e){let t=[],a=new Map;for(let r of e.lines){let e=function(e){let t=rN.find(t=>t.material_choice_slug===e.material_choice_slug);
1if(t)return t.trade_slug;if(e.is_composite)return"composite";let a=rk.find(t=>t.element_slug===e.element_slug);return a?.trade_slugs[0]??"other"}(r),i=a.get(e);i||(i={trade:e,label:i$[e]??e.replace(/_/g," "),lines:[],low:0,high:0,pricedOnRequest:0},a.set(e,i),t.push(e)),i.lines.push(r),r.priced_on_request?i.pricedOnRequest+=1:(i.low+=r.line_low_usd,i.high+=r.line_high_usd)}return t.map(e=>a.get(e))}(e),i=e.lines.reduce((e,t)=>t.priced_on_request?e:{low:e.low+t.line_low_usd,high:e.high+t.line_high_usd},{low:0,high:0}),n=e.lines.filter(e=>e.priced_on_request).length;return 0===e.lines.length?(0,t.jsxs)("div",{className:"flex flex-col items-center gap-4 rounded-2xl border border-dashed border-border bg-card/40 px-6 py-16 text-center",children:[(0,t.jsx)("span",{className:"grid size-12 place-items-center rounded-full bg-primary/10 text-primary",children:(0,t.jsx)(d,{className:"size-5"})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-sm font-medium text-foreground",children:"No materials selected yet"}),(0,t.jsx)("p",{className:"mx-auto mt-1 max-w-sm text-xs text-muted-foreground",children:"Price a scope in the Estimate pillar and add it to the proposal â every selected finish lands here, grouped by trade with its band and provenance."})]}),a&&(0,t.jsxs)(er.Button,{variant:"outline",size:"sm",onClick:a,children:[(0,t.jsx)(s,{className:"size-3.5"}),"Open the Estimate pillar",(0,t.jsx)(t0.ArrowRight,{className:"size-3.5"})]})]}):(0,t.jsxs)("div",{className:"flex flex-col gap-8",children:[r.map(e=>(0,t.jsxs)("section",{className:"flex flex-col gap-3",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-3",children:[(0,t.jsxs)("h3",{className:"caps text-xs text-muted-foreground",children:[e.label,(0,t.jsxs)("span",{className:"figure-mono ml-2 text-[0.68rem] opacity-70",children:[e.lines.length," finish",1===e.lines.length?"":"es"]})]}),(0,t.jsxs)("span",{className:"figure-mono text-xs text-muted-foreground",children:[e.high>0&&`${(0,aS.usdWhole)(e.low)}â${(0,aS.usdWhole)(e.high)}`,e.pricedOnRequest>0&&(e.high>0?` \xb7 +${e.pricedOnRequest} on request`:`${e.pricedOnRequest} priced on request`)]})]}),(0,t.jsx)("div",{className:"grid gap-4 sm:grid-cols-2 xl:grid-cols-3",children:e.lines.map(e=>(0,t.jsx)(iM,{line:e,onOpenEstimate:a},e.id))})]},e.trade)),(0,t.jsx)(rl,{animate:!1,containerClassName:"rounded-2xl",className:"rounded-[13px] bg-card",children:(0,t.jsxs)("div",{className:"flex flex-wrap items-baseline justify-between gap-3 px-5 py-4",children:[(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"caps text-[0.62rem] text-muted-foreground",children:"Materials total · estimate band"}),n>0&&(0,t.jsxs)("span",{className:"text-[0.65rem] text-muted-foreground",children:["+",n," line",1===n?"":"s"," priced on request â not in the band"]})]}),(0,t.jsxs)("span",{className:"figure-mono text-2xl font-semibold tracking-tight text-foreground",children:[(0,aS.usdWhole)(i.low),"â",(0,aS.usdWhole)(i.high)]})]})})]})}function iM({line:e,onOpenEstimate:a}){let r=rC(e),i=function(e){let t=new Map;for(let a of[e.supplier,e.curated?.vendor])a&&!t.has(a.toLowerCase())&&t.set(a.toLowerCase(),a);return[...t.values()]}(e),n=iS[e.tier]?`${iS[e.tier]} \xb7 ${iz[e.tier]}`:e.tier;return(0,t.jsxs)("article",{className:"group cine-edge relative flex flex-col overflow-hidden rounded-xl border border-border bg-card transition-colors hover:border-primary/40",children:[(0,t.jsx)("div",{className:"h-16 w-full border-b border-border",style:e.curated?.swatch?{background:e.curated.swatch}:{background:"linear-gradient(135deg, var(--muted), var(--card))"},"aria-hidden":!0}),(0,t.jsxs)("div",{className:"flex flex-1 flex-col gap-2 p-4",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("p",{className:"min-w-0 truncate text-sm font-medium text-foreground",title:e.choice_display,children:e.choice_display}),(0,t.jsx)("span",{className:"badge-basis badge-typical shrink-0",children:n})]}),(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[e.display_name," · ",e.room_label]}),i.length>0&&(0,t.jsxs)("p",{className:"caps text-[0.6rem] text-muted-foreground",children:[i.join(" · "),e.curated?.vendor_sku?` \xb7 ${e.curated.vendor_sku}`:""]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[e.is_composite&&(0,t.jsx)("span",{className:"badge-basis badge-typical",children:"Bundle"}),r&&(0,t.jsx)(rM,{note:r}),"number"==typeof e.curated?.appears_in_homes&&e.curated.appears_in_homes>0&&(0,t.jsxs)("span",{className:"text-[0.6rem] text-muted-foreground",children:["appears in ",e.curated.appears_in_homes," home",1===e.curated.appears_in_homes?"":"s"]})]}),(0,t.jsxs)("div",{className:"mt-auto flex items-end justify-between gap-2 border-t border-border pt-3",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,t.jsxs)("span",{className:"figure-mono text-[0.68rem] text-muted-foreground",children:[e.quantity," ",e.unit_of_measure.replace(/_/g," ")
1]}),e.priced_on_request?(0,t.jsx)("span",{className:"badge-basis badge-request",children:"Priced on request"}):(0,t.jsxs)("span",{className:"figure-mono text-sm font-semibold text-foreground",children:[(0,aS.usdWhole)(e.line_low_usd),"â",(0,aS.usdWhole)(e.line_high_usd)]})]}),a&&(0,t.jsxs)("button",{type:"button",onClick:a,className:"inline-flex shrink-0 items-center gap-1 rounded-sm text-[0.68rem] font-medium text-primary opacity-80 transition-opacity hover:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",title:`Adjust ${e.display_name} in the Estimate pillar`,children:[(0,t.jsx)(s,{className:"size-3"}),"Estimate line"]})]})]})]})}function iE({onOpenEstimate:e}){let a=(0,b.usePrefersReducedMotion)(),r=aP();return(0,t.jsxs)(f.motion.div,{...(0,b.fadeUp)(a),className:"flex flex-col gap-8",children:[(0,t.jsx)(z,{line:!0,step:"Step 05",kicker:"Materials",title:"The materials board",blurb:"Every selected finish, grouped by trade â tier, supplier pool, evidence provenance, and the priced estimate line it belongs to. Bands, never point prices; supplier names live here in the pro studio and are stripped from the client proposal."}),(0,t.jsx)(iC,{pkg:r,onOpenEstimate:e}),r.lines.length>0&&(0,t.jsxs)(h.default,{href:`/proposal/${r.id}`,className:"inline-flex w-fit items-center gap-2 rounded-full bg-primary px-5 py-2.5 text-sm font-semibold text-primary-foreground transition-colors hover:bg-accent",children:["Open the client proposal ",(0,t.jsx)(t0.ArrowRight,{className:"size-4"})]})]})}var iD=e.i(98923);function iP(e){return Number.isFinite(e)?Math.abs(e)>=1e3?`$${Math.round(e/1e3)}k`:`$${Math.round(e)}`:"$0"}function iO(e,t){return"number"!=typeof e||"number"!=typeof t||!Number.isFinite(e)||!Number.isFinite(t)||e<=0&&t<=0?null:`${iP(e)} â ${iP(t)}`}function iL(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function iA(e){let t=e.summary,a=t.room_name&&t.room_name.trim()||"Untitled space",r=function(e){if(!e||"string"!=typeof e)return null;let t=e.replace(/[_-]+/g," ").trim();return t?t.replace(/\b\w/g,e=>e.toUpperCase()):null}(t.recognized_style),i=t.human_calibrated?"Calibrated":t.rendered?"Rendered":"Measured";return{id:e.id,kind:"package",title:a,subtitle:r?`${r} \xb7 vision package`:"Vision package",band:iO(t.total_low,t.total_high),bandLow:t.total_low,bandHigh:t.total_high,status:i,signed:!1,rendered:!!t.rendered,humanCalibrated:!!t.human_calibrated,directionCount:"number"==typeof t.direction_count?t.direction_count:null,widthFt:"number"==typeof t.width_ft?t.width_ft:null,depthFt:"number"==typeof t.depth_ft?t.depth_ft:null,lines:null,updatedAt:e.updated_at??null,href:e.url||`/vision?v=${encodeURIComponent(e.id)}`,hrefLabel:"Restore in Vision"}}function iR(e){let t=e.title&&e.title.trim()||"Untitled proposal",a=e.client&&e.client.trim()||"Private client";return{id:e.id,kind:"proposal",title:t,subtitle:`${a} \xb7 proposal`,band:iO(e.total_low,e.total_high),bandLow:e.total_low,bandHigh:e.total_high,status:e.signed?"Signed":"Draft",signed:!!e.signed,rendered:!1,humanCalibrated:!1,directionCount:null,widthFt:null,depthFt:null,lines:"number"==typeof e.lines?e.lines:null,updatedAt:e.updated_at??null,href:e.url||`/proposal/${encodeURIComponent(e.id)}`,hrefLabel:"Open proposal"}}let iT="cortivex-projects-canvas-v1";function iF(){try{let e=window.localStorage.getItem(iT),t=e?JSON.parse(e):{};if(t&&"object"==typeof t&&!Array.isArray(t)){let e={};for(let[a,r]of Object.entries(t))r&&"object"==typeof r&&"number"==typeof r.x&&"number"==typeof r.y&&(e[a]={x:r.x,y:r.y});return e}}catch{}return{}}let iq="cortivex-projects-mode-v1";function iI(){try{let e=window.localStorage.getItem(iq);return"grid"===e?"grid":"canvas"}catch{return"canvas"}}let iU=new Set;function iW(e){return iU.add(e),()=>iU.delete(e)}function iB({card:e,active:a=!1,className:r}){let n="proposal"===e.kind?y.PenLine:Z.Sparkles,s=iL(e.updatedAt);return(0,t.jsx)(rl,{animate:a,containerClassName:(0,g.cn)("rounded-[1.35rem]",r),className:(0,g.cn)("rounded-[1.15rem]",r?.includes("h-full")&&"flex h-full"),children:(0,t.jsxs)("div",{className:"flex h-full w-full flex-col gap-3 rounded-[1.15rem] bg-card/95 p-4 text-left",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("span",{className:(0,g.cn)("grid size-8 shrink-0 place-items-center rounded-lg border border-border bg-background/60 text-muted-foreground",a&&"text-primary"),children:(0,t.jsx)(n,{className:"size-4"})}),(0,t.jsx)(iG,{card:e})]}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("h3",{className:"truncate font-serif text-lg font-light leading-tight text-foreground",children:e.title}),(0,t.jsx)("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:e.subt
1itle})]}),(0,t.jsxs)("div",{className:"mt-auto flex flex-col gap-2",children:[e.band?(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("span",{className:"figure-mono text-sm font-semibold text-foreground",children:e.band}),(0,t.jsx)("span",{className:"badge-basis badge-measured",children:"Measured"})]}):(0,t.jsx)("span",{className:"badge-basis badge-request",children:"Priced on request"}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 text-[0.68rem] text-muted-foreground",children:["number"==typeof e.widthFt&&"number"==typeof e.depthFt?(0,t.jsxs)("span",{className:"figure-mono inline-flex items-center gap-1",children:[(0,t.jsx)(i.Ruler,{className:"size-3"}),e.widthFt.toFixed(1),"Ã",e.depthFt.toFixed(1)," ft"]}):null,"number"==typeof e.directionCount&&e.directionCount>0?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[(0,t.jsx)(t3,{className:"size-3"}),e.directionCount," ",1===e.directionCount?"direction":"directions"]}):null,"number"==typeof e.lines&&e.lines>0?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[e.lines," ",1===e.lines?"line":"lines"]}):null]}),(0,t.jsx)("span",{className:"text-[0.62rem] uppercase tracking-[0.14em] text-muted-foreground/70",children:s?`Updated ${s}`:"Saved to your account"})]})]})})}function iG({card:e}){return e.signed?(0,t.jsxs)("span",{className:"badge-basis badge-verified",children:[(0,t.jsx)(ri,{className:"size-3"}),"Signed"]}):"package"===e.kind&&e.humanCalibrated?(0,t.jsx)("span",{className:"badge-basis badge-verified",children:"Calibrated"}):"package"===e.kind&&e.rendered?(0,t.jsx)("span",{className:"badge-basis badge-measured",children:"Rendered"}):(0,t.jsx)("span",{className:"badge-basis badge-typical",children:e.status})}function iH({cards:e,onExpand:r,resetSignal:i}){let n=(0,b.usePrefersReducedMotion)(),s=a.useRef(null);return(0,t.jsxs)("div",{ref:s,className:"cine-grid relative w-full overflow-hidden rounded-2xl border border-border bg-background/30",style:{minHeight:560},children:[(0,t.jsx)("span",{className:"pointer-events-none absolute right-3 top-3 z-20 rounded-full border border-border bg-card/70 px-3 py-1 text-[0.6rem] uppercase tracking-[0.16em] text-muted-foreground backdrop-blur-sm",children:n?"Saved layout":"Drag to arrange"}),e.map((e,a)=>(0,t.jsx)(iV,{card:e,index:a,boundsRef:s,reduced:n,resetSignal:i,onExpand:r},e.id))]})}function iV({card:e,index:r,boundsRef:i,reduced:n,resetSignal:s,onExpand:o}){let l=a.useMemo(()=>{let t;return iF()[e.id]??(t=Math.floor(r/3),{x:r%3*320+(37*r%24-12),y:236*t+(53*r%20-10)})},[e.id,r,s]),d=(0,iD.useMotionValue)(l.x),c=(0,iD.useMotionValue)(l.y),[p,u]=a.useState(!1),m=a.useRef(!1);return a.useEffect(()=>{d.set(l.x),c.set(l.y)},[l.x,l.y,d,c]),(0,t.jsx)(f.motion.div,{className:"absolute left-0 top-0 z-10 select-none",style:{x:d,y:c,width:292},drag:!n,dragConstraints:i,dragElastic:.12,dragMomentum:!1,whileDrag:{zIndex:40,scale:1.02},onPointerDown:()=>{m.current=!1},onDragStart:()=>{m.current=!0,u(!0)},onDragEnd:()=>{!function(e,t){try{let a=iF();a[e]=t,window.localStorage.setItem(iT,JSON.stringify(a))}catch{}}(e.id,{x:d.get(),y:c.get()}),u(!1)},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),children:(0,t.jsx)("button",{type:"button",onClick:()=>{if(m.current){m.current=!1;return}o(e)},"aria-label":`Open ${e.title}`,className:n?"block w-full cursor-pointer text-left focus-visible:outline-none":"block w-full cursor-grab text-left focus-visible:outline-none active:cursor-grabbing",children:(0,t.jsx)(iB,{card:e,active:p})})})}function iK({onReset:e}){return(0,t.jsxs)("button",{type:"button",onClick:()=>{try{window.localStorage.removeItem(iT)}catch{}e()},className:"inline-flex items-center gap-1.5 rounded-full border border-border bg-card/60 px-3 py-1.5 text-[0.68rem] font-medium uppercase tracking-[0.14em] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",children:[(0,t.jsx)(et.RotateCcw,{className:"size-3.5"}),"Reset layout"]})}var iX=e.i(7888);function iY({cards:e,onExpand:a}
1){let r=(0,b.usePrefersReducedMotion)();return(0,t.jsx)(iX.BentoGrid,{className:"max-w-none md:auto-rows-[15.5rem]",children:e.map((e,i)=>(0,t.jsx)(f.motion.button,{type:"button",onClick:()=>a(e),"aria-label":`Open ${e.title}`,initial:r?{opacity:0}:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.5*!r,ease:[.22,1,.36,1],delay:r?0:Math.min(.04*i,.24)},className:(0,g.cn)("group block text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 rounded-[1.35rem]",0===i?"md:col-span-2":"md:col-span-1"),children:(0,t.jsx)(iB,{card:e,className:"h-full"})},e.id))})}let iJ=[.22,1,.36,1];function iQ({card:e,onClose:r}){var n;let s=(0,b.usePrefersReducedMotion)(),o=a.useRef(null);return n=()=>r(),(0,a.useEffect)(()=>{let e=e=>{let t=e.target;!o.current||t&&o.current.contains(t)||n(e)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[o,n]),a.useEffect(()=>{if(!e)return;let t=e=>{"Escape"===e.key&&r()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,r]),(0,t.jsx)(x.AnimatePresence,{children:e&&(0,t.jsxs)("div",{className:"fixed inset-0 z-[80] grid place-items-center p-4",children:[(0,t.jsx)(f.motion.div,{initial:{opacity:0}
1,animate:{opacity:1},exit:{opacity:0},transition:{duration:.28*!s},className:"absolute inset-0 bg-black/70 backdrop-blur-sm",onClick:r,"aria-hidden":!0}),(0,t.jsxs)(f.motion.div,{ref:o,layout:!s,role:"dialog","aria-modal":"true","aria-label":`${e.title} details`,initial:s?{opacity:0}:{opacity:0,y:22,scale:.96},animate:{opacity:1,y:0,scale:1},exit:s?{opacity:0}:{opacity:0,y:16,scale:.97},transition:{duration:.4*!s,ease:iJ},className:"glass-cine relative z-10 w-full max-w-lg overflow-hidden rounded-[1.6rem] p-6 text-foreground shadow-2xl",children:[(0,t.jsx)("span",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 h-px bg-gradient-to-r from-transparent via-primary/50 to-transparent"}),(0,t.jsxs)("div",{className:"flex items-start justify-between gap-3",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-[0.62rem] font-medium uppercase tracking-[0.28em] text-primary",children:"proposal"===e.kind?"Proposal":"Vision package"}),(0,t.jsx)("h2",{className:"mt-1.5 font-serif text-2xl font-light leading-tight text-foreground",children:e.title}),(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground",children:e.subt
1itle})]}),(0,t.jsx)("button",{type:"button",onClick:r,"aria-label":"Close details",className:"grid size-8 shrink-0 place-items-center rounded-full border border-border bg-background/60 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",children:(0,t.jsx)(t5.X,{className:"size-4"})})]}),(0,t.jsxs)("div",{className:"mt-5 flex flex-wrap items-center gap-2",children:[e.signed?(0,t.jsxs)("span",{className:"badge-basis badge-verified",children:[(0,t.jsx)(ri,{className:"size-3"}),"Signed"]}):e.humanCalibrated?(0,t.jsx)("span",{className:"badge-basis badge-verified",children:"Calibrated"}):e.rendered?(0,t.jsx)("span",{className:"badge-basis badge-measured",children:"Rendered"}):(0,t.jsx)("span",{className:"badge-basis badge-typical",children:e.status}),e.updatedAt?(0,t.jsxs)("span",{className:"text-[0.62rem] uppercase tracking-[0.14em] text-muted-foreground/70",children:["Updated ",iL(e.updatedAt)]}):null]}),(0,t.jsxs)("dl",{className:"mt-5 grid grid-cols-2 gap-3",children:[(0,t.jsx)(iZ,{label:"Estimate band",children:e.band?(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)("span",{className:"figure-mono text-sm font-semibold text-foreground",children:e.band}),(0,t.jsx)("span",{className:"badge-basis badge-measured",children:"Measured"})]}):(0,t.jsx)("span",{className:"badge-basis badge-request",children:"Priced on request"})}),"number"==typeof e.widthFt&&"number"==typeof e.depthFt?(0,t.jsx)(iZ,{label:"Measured size",children:(0,t.jsxs)("span",{className:"figure-mono inline-flex items-center gap-1 text-sm text-foreground",children:[(0,t.jsx)(i.Ruler,{className:"size-3.5 text-muted-foreground"}),e.widthFt.toFixed(1)," à ",e.depthFt.toFixed(1)," ft"]})}):null,"number"==typeof e.directionCount&&e.directionCount>0?(0,t.jsx)(iZ,{label:"Directions",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 text-sm text-foreground",children:[(0,t.jsx)(t3,{className:"size-3.5 text-muted-foreground"}),e.directionCount," explored"]})}):null,"number"==typeof e.lines&&e.lines>0?(0,t.jsx)(iZ,{label:"Line items",children:(0,t.jsx)("span",{className:"figure-mono text-sm text-foreground",children:e.lines})}):null]}),(0,t.jsxs)("div",{className:"mt-6 flex flex-col gap-3",children:[(0,t.jsxs)(h.default,{href:e.href,className:"inline-flex items-center justify-center gap-2 rounded-full bg-white px-6 py-3 text-sm font-semibold text-black transition-transform hover:scale-[1.03] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:[e.hrefLabel,(0,t.jsx)(k.ArrowUpRight,{className:"size-4"})]}),(0,t.jsx)("p",{className:"text-[0.62rem] uppercase tracking-[0.2em] text-muted-foreground/60",children:"proposal"===e.kind?"Signable deliverable · figures field-verify before building":"Reopens the exact package you saved · restore, evolve, or calibrate"})]})]})]})})}function iZ({label:e,children:a}){return(0,t.jsxs)("div",{className:"rounded-xl border border-border bg-background/40 px-3.5 py-3",children:[(0,t.jsx)("dt",{className:"text-[0.58rem] font-medium uppercase tracking-[0.16em] text-muted-foreground/70",children:e}),(0,t.jsx)("dd",{className:"mt-1.5",children:a})]})}function i0(){let[e,r]=a.useState("loading"),[i,n]=a.useState([]),[s,o]=[a.useSyncExternalStore(iW,iI,()=>"canvas"),a.useCallback(e=>{try{window.localStorage.setItem(iq,e)}catch{}for(let e of iU)e()},[])],[l,d]=a.useState(null),[c,p]=a.useState(0),[u,m]=a.useState(0);a.useEffect(()=>{let e=!0;return(async()=>{try{let t,a,i,s=await fetch("/api/studio/projects",{cache:"no-store"});if(!e)return;if(401===s.status)return void r("anon");if(!s.ok)throw Error(`HTTP ${s.status}`);let o=await s.json();if(!e)return;n((t=(o.proposals??[]).map(iR),a=(o.packages??[]).map(iA),i=(e,t)=>(t.updatedAt??"").localeCompare(e.updatedAt??""),t.sort(i),a.sort(i),[...t,...a])),r("ready")}catch{e&&r("error")}})(),()=>{e=!1}},[u]);let x=a.useCallback(()=>{r("loading"),m(e=>e+1)},[]),f=a.useMemo(()=>i.find(e=>e.id===l)??null,[i,l]),h=a.useCallback(e=>d(e.id),[]),g=a.useCallback(()=>d(null),[]),b="ready"===e&&0===i.length,v="ready"===e&&i.length>0;return(0,t.jsxs)("section",{className:"flex flex-col gap-6",children:[(0,t.jsx)(z,{line:!0,kicker:"â Projects",title:"Your saved designs",blurb:"Every vision package and proposal you've saved â arranged your way. Drag the glowing cards around the canvas, flip to a tidy grid, and click any card to open it.",action:v?(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:["canvas"===s&&(0,t.jsx)(iK,{onReset:()=>p(e=>e+1)}),(0,t.jsx)(i1,{mode:s,onChange:o})]}):void 0}),"loading"===e&&(0,t.jsxs)("p",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,t.jsx)($.Loader2,{className:"size-3.5 animate-spin"}),"Loading your projectsâ¦"]}),"anon"===e&&(0,t.jsx)(i5,{}),"error"===e&&(0,t.jsx)(i4,{onRetry:x}),b&&(0,t.jsx)(i3,{}),v&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("p",{className:"text-xs text-muted-foreground",children:[i.length," ",1===i.length?"project":"projects"," saved to your account."]}),"canvas"===s?(0,t.jsx)(iH,{cards:i,onExpand:h,resetSignal:c}):(0,t.jsx)(iY,{cards:i,onExpand:h})]}),(0,t.jsx)(iQ,{card:f,onClose:g})]})}function i1({mode:e,onChange:a}){return(0,t.jsx)("div",{className:"inline-flex items-center rounded-full border border-border bg-card/60 p-0.5",role:"tablist","aria-label":"Projects layout",children:[{id:"canvas",label:"Canvas",icon:rB},{id:"grid",label:"Grid",icon:c}].map(r=>
1{let i=e===r.id;return(0,t.jsxs)("button",{type:"button",role:"tab","aria-selected":i,onClick:()=>a(r.id),className:(0,g.cn)("inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-[0.7rem] font-medium uppercase tracking-[0.14em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",i?"bg-primary/15 text-foreground":"text-muted-foreground hover:text-foreground"),children:[(0,t.jsx)(r.icon,{className:"size-3.5"}),r.label]},r.id)})})}function i2({children:e}){return(0,t.jsx)("div",{className:"mx-auto flex max-w-lg flex-col items-center gap-4 rounded-2xl border border-border bg-card/60 px-6 py-16 text-center",children:e})}function i5(){return(0,t.jsxs)(i2,{children:[(0,t.jsx)("span",{className:"grid size-12 place-items-center rounded-full bg-primary/10 text-primary",children:(0,t.jsx)(p.Lock,{className:"size-5"})}),(0,t.jsx)("h2",{className:"font-serif text-2xl font-light text-foreground",children:"Sign in to save & revisit projects"}),(0,t.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Projects are tied to your account â every vision package and proposal you save appears here, on any device."}),(0,t.jsxs)(h.default,{href:"/login?next=/studio%3Ftab%3Dprojects",className:"inline-flex items-center gap-2 rounded-full bg-white px-6 py-3 text-sm font-semibold text-black transition-transform hover:scale-[1.03] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:["Sign in",(0,t.jsx)(k.ArrowUpRight,{className:"size-4"})]})]})}function i3(){return(0,t.jsxs)(i2,{children:[(0,t.jsx)("span",{className:"grid size-12 place-items-center rounded-full bg-primary/10 text-primary",children:(0,t.jsx)(Z.Sparkles,{className:"size-5"})}),(0,t.jsx)("h2",{className:"font-serif text-2xl font-light text-foreground",children:"Your saved designs will appear here"}),(0,t.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"Nothing saved yet. Drop a photo in Vision to measure a space, explore directions, and save your first package â it lands here."}),(0,t.jsxs)(h.default,{href:"/vision",className:"inline-flex items-center gap-2 rounded-full bg-white px-6 py-3 text-sm font-semibold text-black transition-transform hover:scale-[1.03] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:["Start in Vision",(0,t.jsx)(k.ArrowUpRight,{className:"size-4"})]})]})}function i4({onRetry:e}){return(0,t.jsxs)(i2,{children:[(0,t.jsx)("h2",{className:"font-serif text-2xl font-light text-foreground",children:"Couldn't load your projects"}),(0,t.jsx)("p",{className:"max-w-sm text-sm text-muted-foreground",children:"The projects store didn't respond. Your saved work is safe â try again in a moment."}),(0,t.jsx)("button",{type:"button",onClick:e,className:"inline-flex items-center gap-2 rounded-full border border-border bg-card/60 px-6 py-3 text-sm font-medium text-foreground transition-colors hover:border-primary/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",children:"Retry"})]})}let i6={schema:"floorplan_graph.v1",id:"bath3",name:"Bath 3 â Galley",units:"ft",coord_system:"editor-y-down",bounds_ft:{w:5.83,h:10.21},north_deg:0,scale_note:'1/2" = 1\'-0"',confidence:.82,source_photos:["bath3_north.jpg","bath3_south.jpg"],created_at:"2026-06-26T00:00:00.000Z",rooms:[{id:"room-bath3",name:"Bath 3",poly:[{x:0,y:0},{x:5.83,y:0},{x:5.83,y:10.21},{x:0,y:10.21}],area_ft2:59.52}],walls:[{id:"w-n",a:{x:0,y:0},b:{x:5.83,y:0},thickness_ft:.42},{id:"w-e",a:{x:5.83,y:0},b:{x:5.83,y:10.21},thickness_ft:.42},{id:"w-s",a:{x:5.83,y:10.21},b:{x:0,y:10.21},thickness_ft:.42},{id:"w-w",a:{x:0,y:10.21},b:{x:0,y:0},thickness_ft:.42}],openings:[{id:"door-1",kind:"door",a:{x:3.33,y:10.21},b:{x:5.83,y:10.21},hinge:"b",swing:"in"}],fixtures:[{id:"fx-tub",kind:"tub",label:"TUB",bbox_ft:{x:0,y:0,w:5.83,h:2.5}},{id:"fx-vanity",kind:"vanity",label:"VANITY",bbox_ft:{x:0,y:3.5,w:1.83,h:3}},{id:"fx-wc",kind:"toilet",label:"WC",bbox_ft:{x:3.37,y:6.4,w:2.46,h:1.6}}],dimensions:[{id:"dim-w",a:{x:0,y:10.21},b:{x:5.83,y:10.21},side:"bottom",offset_ft:1},{id:"dim-h",a:{x:0,y:0},b:{x:0,y:10.21},side:"left",offset_ft:1},{id:"dim-tub",a:{x:5.83,y:0},b:{x:5.83,y:2.5},side:"right",offset_ft:1}]}
1,i8=[i6,{schema:"floorplan_graph.v1",id:"bedroom2",name:"Bedroom 2",units:"ft",coord_system:"editor-y-down",bounds_ft:{w:12.33,h:11.5},north_deg:0,scale_note:'1/4" = 1\'-0"',confidence:.74,created_at:"2026-06-26T00:00:00.000Z",rooms:[{id:"room-bed2",name:"Bedroom 2",poly:[{x:0,y:0},{x:12.33,y:0},{x:12.33,y:11.5},{x:0,y:11.5}],area_ft2:141.8},{id:"room-closet",name:"Closet",poly:[{x:0,y:0},{x:4.5,y:0},{x:4.5,y:2.25},{x:0,y:2.25}],area_ft2:10.13}],walls:[{id:"bw-n",a:{x:0,y:0},b:{x:12.33,y:0},thickness_ft:.42},{id:"bw-e",a:{x:12.33,y:0},b:{x:12.33,y:11.5},thickness_ft:.42},{id:"bw-s",a:{x:12.33,y:11.5},b:{x:0,y:11.5},thickness_ft:.42},{id:"bw-w",a:{x:0,y:11.5},b:{x:0,y:0},thickness_ft:.42},{id:"bw-cl",a:{x:4.5,y:0},b:{x:4.5,y:2.25},thickness_ft:.33,status:"active"}],openings:[{id:"bdoor-1",kind:"door",a:{x:9,y:11.5},b:{x:11.6,y:11.5},hinge:"a",swing:"in"},{id:"bwin-1",kind:"window",a:{x:3.5,y:0},b:{x:8,y:0}},{id:"bcased-1",kind:"cased",a:{x:4.5,y:.4},b:{x:4.5,y:1.9}}],fixtures:[{id:"bfx-bed",kind:"generic",label:"QUEEN BED",bbox_ft:{x:7.4,y:.6,w:5,h:6.67}},{id:"bfx-night",kind:"cabinet",label:"NS",bbox_ft:{x:6,y:.6,w:1.5,h:1.5}},{id:"bfx-shelf",kind:"cabinet",label:"SHELF",bbox_ft:{x:.25,y:2,w:4,h:.6}}],dimensions:[{id:"bdim-w",a:{x:0,y:11.5},b:{x:12.33,y:11.5},side:"bottom",offset_ft:1.1},{id:"bdim-h",a:{x:12.33,y:0},b:{x:12.33,y:11.5},side:"right",offset_ft:1.1},{id:"bdim-cl",a:{x:0,y:0},b:{x:4.5,y:0},side:"top",offset_ft:1.1}]}];function i7(e,t,a){return{x:e.x+t,y:e.y+a}}function i9(e){return e?e.rooms.length:0}let ne=[{id:"measure",label:"Measure",icon:i.Ruler},{id:"price",label:"Price",icon:s},{id:"design",label:"Design",icon:r.Wand2},{id:"site",label:"Site",icon:o},{id:"materials",label:"Materials",icon:d},{id:"selections",label:"Selections",icon:m},{id:"projects",label:"Projects",icon:c}],nt=ne.map(e=>e.id),na=["transform","edit","relight","locked","precision"],nr={plans:"measure",select:"price",estimate:"price",transform:"design",edit:"design",relight:"design",locked:"design",precision:"design"};function ni({area:e}){let a=encodeURIComponent(`/studio?tab=${e}`);return(0,t.jsxs)("div",{className:"mx-auto flex max-w-lg flex-col items-center gap-4 roun
1ded-2xl border border-border bg-card/60 px-6 py-16 text-center",children:[(0,t.jsx)("span",{className:"grid size-12 place-items-center rounded-full bg-primary/10 text-primary",children:(0,t.jsx)(p.Lock,{className:"size-5"})}),(0,t.jsx)("h2",{className:"font-serif text-2xl font-light text-foreground",children:"A Studio feature"}),(0,t.jsxs)("p",{className:"max-w-sm text-sm text-muted-foreground",children:["The ",(0,t.jsx)("span",{className:"font-medium text-foreground",children:e})," area is part of the Builder / GC / Designer plan â coordinated finishes, selections, projects, and client send. Sign in to your studio account to open it."]}),(0,t.jsx)(h.default,{href:`/login?next=${a}`,className:"inline-flex items-center gap-2 rounded-full bg-white px-6 py-3 text-sm font-semibold text-black transition-transform hover:scale-[1.03] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/60",children:"Sign in"})]})}e.s(["StudioShell",0,function(){let e=(0,b.usePrefersReducedMotion)(),r=(0,v.useAccount)(),[i,n]=a.useState("measure"),[s,o]=a.useState("transform"),d=(0,v.tierAllows)(r.tier,i),[c,m]=a.useState([]),[y,_]=a.useState(!1),[j,w]=a.useState(null),[k,N]=a.useState(null),[S,z]=a.useState(null),[$,C]=a.useState(i6.id),[M,E]=a.useState(null),[D,P]=a.useState(()=>new Set),[O,L]=a.useState(null),[A,R]=a.useState(null),T=a.useRef(null),F=a.useCallback(e=>{m(t=>[...t,e]),w(null),N(null),z(null),C(i6.id),L(null),T.current&&URL.revokeObjectURL(T.current);let t=URL.createObjectURL(e);T.current=t,R({name:e.name,previewUrl:t,remoteUrl:null,status:"uploading"}),(async()=>{try{let a=await U(e);R(e=>e&&e.previewUrl===t?{...e,remoteUrl:a.url,status:"ready",mocked:a.mocked}:e)}catch(a){let e=a instanceof Error?a.message:"Upload failed.";R(a=>a&&a.previewUrl===t?{...a,status:"error",error:e}:a)}})()},[]);a.useEffect(()=>()=>{T.current&&URL.revokeObjectURL(T.current)},[]),a.useEffect(()=>{let e=new URLSearchParams(window.location.search),t=e.get("tab");t&&(nt.includes(t)?n(t):nr[t]&&(n(nr[t]),na.includes(t)&&o(t)));let a=e.get("v");a&&(async()=>{try{let e=await fetch(`/api/vision/package/${encodeURIComponent(a)}`,{cache:"no-store"});if(!e.ok)return;let t=await e.json();if(!t.ok||!t.package)return;let r=t.package;L({id:t.id,room_name:t.summary?.room_name??null,budget:r.budget?{total_low:r.budget.total_low,total_high:r.budget.total_high,source:r.budget.source,priced_on_request:r.budget.priced_on_request}:null}),r.document&&(w(r.document),N({dxf:null,dxfFilename:`${r.document.id}.dxf`,dxfUrl:null,pngUrl:null,provider:"vision",vlmModel:"",vlmProvider:"",source:`vision package ${t.id}`,isDemoSample:!1}),C("__generated__")),r.source_image_url&&R({name:t.summary?.room_name??"vision package photo",previewUrl:r.source_image_url,remoteUrl:r.source_image_url,status:"ready"})}catch{}})()},[]);let q=a.useCallback(async(e,t)=>{_(!0),z(null);try{let a;if(!(c.length>0)||e.home||e.room)a=await fetch("/api/plan",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)});else{let t=new FormData;for(let e of c.slice(-4))t.append("file",e);e.provider&&t.set("provider",e.provider);let r=c[c.length-1],i=(0,aG.planHint)((0,aG.inferSpaceKind)(r?.name));i&&t.set("room_hint",i),a=await fetch("/api/plan",{method:"POST",body:t})}let r=await a.json();if(!a.ok||!r.ok||!r.document){z(r?.error||`Plan request failed (HTTP ${a.status}).`),t&&n("measure");return}if(w(r.document),N({dxf:r.dxf??null,dxfFilename:r.dxf_filename??`${r.document.id}.dxf`,dxfUrl:r.dxf_url??null,pngUrl:r.png_url??null,provider:r.meta?.provider??e.provider??"hf",vlmModel:r.meta?.vlm_model??"",vlmProvider:r.meta?.vlm_provider??"",source:r.meta?.source??"",isDemoSample:r.meta?.is_demo_sample??!1}),!r.meta?.is_demo_sample){let e=r.document;aD(t=>({...t,planJson:e,updated_at:new Date().toISOString()}))}C("__generated__"),t&&n("measure")}catch(e){z(e instanceof Error?e.message:"Plan request failed â is the vision engine running?"),t&&n("measure")}finally{_(!1)}},[c]),I=a.useCallback(()=>void q({},!0),[q]),W=a.useCallback(e=>void q(e,!1),[q]),B=a.useCallback(e=>void q({provider:e},!1),[q]),G=a.useCallback(e=>{_(!0),z(null),(async()=>{try{let t=new FormData;t.append("file",e);let a=await fetch("/api/plan/import",{method:"POST",body:t}),r=await a.json();if(!a.ok||!r.ok||!r.document)return void z(r?.error||`Import failed (HTTP ${a.status}).`);let i=r.document;w(i),N({dxf:null,dxfFilename:`${i.id}.dxf`,dxfUrl:null,pngUrl:null,provider:"import",vlmModel:"",vlmProvider:"",source:r.meta?.source??"measured import",isDemoSample:!1}),aD(e=>({...e,planJson:i,updated_at:new Date().toISOString()})),C("__generated__")}catch(e){z(e instanceof Error?e.message:"Import failed.")}finally{_(!1)}})()},[]),H=null!==j&&D.has(j.id),V="__generated__"===$&&null!==j&&!k?.isDemoSample&&!H,K=a.useCallback(()=>{var e;let t,a,r,i,n,s,o,l,d,c,p,u;if(!j||k?.isDemoSample||D.has(j.id))return;let m=(a=Math.floor((t=i9(M))/3),i=t%3*34-(r=function(e){let t=1/0,a=1/0;for(let r of e.rooms)for(let e of r.poly)e.x<t&&(t=e.x),e.y<a&&(a=e.y);return{x:Number.isFinite(t)?t:0,y:Number.isFinite(a)?a:0}}(j)).x,n=30*a-r.y,e=`r${t}-`,s=j.name&&j.name.trim()?j.name:"Room",o={rooms:j.rooms.map(t=>({...t,id:`${e}${t.id}`,name:t.name&&t.name.trim()?t.name:s,poly:t.poly.map(e=>i7(e,i,n))})),walls:j.walls.map(t=>({...t,id:`${e}${t.id}`,a:i7(t.a,i,n),b:i7(t.b,i,n)})),openings:j.openings.map(t=>({...t,id:`${e}${t.id}`,a:i7(t.a,i,n),b:i7(t.b,i,n)})),fixtures:j.fixtures.map(t=>({...t,id:`${e}${t.id}`,bbox_ft:{...t.bbox_ft,x:t.bbox_ft.x+i,y:t.bbox_ft.y+n}})),dimensions:j.dimensions.map(t=>({...t,id:`${e}${t.id}`,a:i7(t.a,i,n),b:i7(t.b,i,n)}))},l=new Set((M?.rooms??[]).map(e=>(e.name||"Room").toLowerCase())),d=o.rooms.map(e=>{let t=function(e,t){let a=e&&e.trim()?e.trim():"Room";if(!t.has(a.toLowerCase()))return a;for(let e=2;e<100;e++){let r=`${a} (${e})`;if(!t.has(r.toLowerCase()))return r}return a}(e.name,l);return l.add(t.toLowerCase()),{...e,name:t}}),c=[...M?.rooms??[],...d],p=[...M?.walls??[],...o.walls],{schema:"floorplan_graph.v1",id:"home-plan",name:"Whole-home plan",units:"ft",coord_system:"editor-y-down",boun
1ds_ft:function(e,t,a){let r=0,i=0,n=(e,t)=>{e>r&&(r=e),t>i&&(i=t)};for(let t of e)for(let e of t.poly)n(e.x,e.y);for(let e of t)n(e.a.x,e.a.y),n(e.b.x,e.b.y);for(let e of a)n(e.bbox_ft.x+e.bbox_ft.w,e.bbox_ft.y+e.bbox_ft.h);return{w:Math.max(r,1),h:Math.max(i,1)}}(c,p,u=[...M?.fixtures??[],...o.fixtures]),north_deg:M?.north_deg??0,scale_note:M?.scale_note??j.scale_note,confidence:Math.min(M?.confidence??1,j.confidence??1),rooms:c,walls:p,openings:[...M?.openings??[],...o.openings],fixtures:u,dimensions:[...M?.dimensions??[],...o.dimensions],source_photos:[...M?.source_photos??[],...j.source_photos??[]],created_at:M?.created_at??j.created_at});E(m),P(e=>new Set(e).add(j.id)),C("__home__"),aD(e=>({...e,planJson:m,updated_at:new Date().toISOString()}))},[j,k,M,D]),X=a.useCallback(()=>{E(null),P(new Set),C(j?"__generated__":i6.id);let e=j&&!k?.isDemoSample?j:null;aD(t=>({...t,planJson:e,updated_at:new Date().toISOString()}))},[j,k]),Y="__home__"===$&&M?M:"__generated__"===$&&j?j:i8.find(e=>e.id===$)??i6;return(0,t.jsxs)("div",{className:"dark studio-bg flex min-h-dvh flex-col text-foreground",children:[(0,t.jsxs)("header",{className:"sticky top-0 z-30 border-b border-border bg-background/70 backdrop-blur-xl",children:[(0,t.jsxs)("div",{className:"mx-auto flex h-16 w-full max-w-[1500px] items-center justify-between gap-4 px-4 md:px-7",children:[(0,t.jsxs)("div",{className:"flex shrink-0 items-baseline gap-2.5",children:[(0,t.jsx)("span",{className:"font-serif text-sm font-medium tracking-[0.5em] text-white/90",children:"VIZHAUS"}),(0,t.jsx)("span",{className:"hidden text-sm font-light tracking-wide text-muted-foreground sm:block",children:"Studio"})]}),(0,t.jsx)("nav",{"aria-label":"Studio stages",className:"hidden items-center gap-1 md:flex",children:ne.map(a=>{let s=a.id===i;return(0,t.jsxs)("button",{type:"button",onClick:()=>n(a.id),"aria-current":s?"page":void 0,className:(0,g.cn)("relative rounded-md px-4 py-2 text-[0.78rem] font-medium uppercase tracking-[0.16em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",s?"text-foreground":"text-muted-foreground hover:text-foreground/90"),children:[a.label,!(0,v.tierAllows)(r.tier,a.id)&&(0,t.jsx)(p.Lock,{className:"ml-1 inline size-3 opacity-50"}),s&&(0,t.jsx)(f.motion.span,{layoutId:"studio-nav-underline",transition:e?{duration:0}:{type:"spring",stiffness:380,damping:32},className:"nav-glow absolute inset-x-3 -bottom-px h-0.5 rounded-full bg-primary"})]},a.id)})}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-2.5",children:[(0,v.tierAllows)(r.tier,"admin")&&(0,t.jsx)(h.default,{href:"/admin",title:"Owner console",className:"hidden size-9 place-items-center rounded-md border border-border bg-card/60 text-muted-foreground transition-colors hover:text-foreground sm:grid",children:(0,t.jsx)(u,{className:"size-4"})}),(0,t.jsx)(h.default,{href:"/login",title:r.signedIn?r.email:"Sign in",className:"grid size-9 place-items-center rounded-full bg-gradient-to-br from-primary/30 to-accent/30 text-xs font-semibold text-foreground ring-1 ring-border",children:r.signedIn?(r.name||"?").split(" ").map(e=>e[0]).join("").slice(0,2).toUpperCase()||"?":"â"}),(0,t.jsx)("button",{"aria-label":"Menu",className:"grid size-9 place-items-center rounded-md border border-border bg-card/60 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 md:hidden",children:(0,t.jsx)(l,{className:"size-4"})})]})]}),(0,t.jsx)("nav",{className:"flex items-center gap-1 overflow-x-auto border-t border-border px-3 py-2 md:hidden",children:ne.map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>n(e.id),className:(0,g.cn)("shrink-0 rounded-full px-3 py-1.5 text-[0.7rem] font-medium uppercase tracking-[0.14em] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/45",e.id===i?"bg-primary/15 text-foreground":"text-muted-foreground"),children:e.label},e.id))})]}),(0,t.jsx)("main",{className:"mx-auto w-full max-w-[1500px] flex-1 px-4 py-6 md:px-7 md:py-8",children:(0,t.jsx)(x.AnimatePresence,{mode:"wait",children:(0,t.jsxs)(f.motion.div,{initial:e?{opacity:0}
1:{opacity:0,y:8},animate:{opacity:1,y:0},exit:e?{opacity:0}:{opacity:0,y:-8},transition:{duration:.22*!e},children:[!d&&(0,t.jsx)(ni,{area:i}),d&&"measure"===i&&(0,t.jsx)("div",{className:"mx-auto max-w-7xl",children:(0,t.jsx)(a6,{doc:Y,samples:i8,activeSampleId:$,onSelectSample:C,generated:null!==j,artifacts:k,error:S,generating:y,hasUpload:c.length>0,photo:A,onSelectPhoto:F,onGenerate:W,onGenerateFromPhoto:B,onImportPlan:G,onOpenSite:()=>n("site"),homeRoomCount:i9(M),canAddRoomToHome:V,roomInHome:H,onAddRoomToHome:K,onClearHome:X})}),d&&"price"===i&&(0,t.jsx)("div",{className:"mx-auto max-w-5xl",children:(0,t.jsx)(rq,{photo:A,onSelectPhoto:F,visionPkg:O})}),d&&"design"===i&&(0,t.jsx)("div",{className:"mx-auto max-w-5xl",children:(0,t.jsx)(tX,{photo:A,onSelectPhoto:F,onGenerate:I,generating:y,lastDoc:j,mode:s,onModeChange:o})}),d&&"site"===i&&(0,t.jsx)("div",{className:"mx-auto max-w-4xl",children:(0,t.jsx)(iN,{})}),d&&"materials"===i&&(0,t.jsx)("div",{className:"mx-auto max-w-6xl",children:(0,t.jsx)(iE,{onOpenEstimate:()=>n("price")})}),d&&"selections"===i&&(0,t.jsx)("div",{className:"mx-auto max-w-6xl",children:(0,t.jsx)(rU,{packageId:O?.id??null})}),d&&"projects"===i&&(0,t.jsx)(i0,{})]},i)})})]})}],6855)}]);
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.