1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,694487,e=>{"use strict";var t=e.i(843476),l=e.i(271645),s=e.i(174080),r=e.i(705766),a=e.i(398756),i=e.i(319508);let o=["[email protected]"];function n({listing:e,onUpdate:s,onDelete:n}){let[h,g]=(0,l.useState)(!1),[p,m]=(0,l.useState)(!1),[f,b]=(0,l.useState)(!1),[v,j]=(0,l.useState)(!1),[y,N]=(0,l.useState)(!1),[w,k]=(0,l.useState)(!1),[S,C]=(0,l.useState)(!1),[L,F]=(0,l.useState)(!1),[M,T]=(0,l.useState)(!1),U=(0,l.useRef)(null),D=function(){let e=(0,a.useUser)();if(!e)return!1;let t=e.primaryEmail?.toLowerCase();return!!t&&o.includes(t)}();if((0,l.useEffect)(()=>{let e=e=>{U.current&&!U.current.contains(e.target)&&g(!1)};return h&&document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[h]),!D)return null;let $=async()=>{j(!0);try{let t=await fetch(`/api/admin/listings/${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({isFeatured:!e.isFeatured})});if(t.ok){let l=await t.json();r.default.success(e.isFeatured?"Removed from featured":l.featuredNotification?.sent?"Marked as featured â agent notified by email":"Marked as featured"),s?.()}else r.default.error("Failed to update listing")}catch(e){console.error("Error toggling featured:",e),r.default.error("Failed to update listing")}finally{j(!1),g(!1)}},z=async t=>{N(!0);try{(await fetch(`/api/admin/listings/${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({listingStatus:t})})).ok?(r.default.success(`Marked as ${t}`),s?.()):r.default.error("Failed to update listing status")}catch(e){console.error("Error updating status:",e),r.default.error("Failed to update listing status")}finally{N(!1),g(!1)}},E=async t=>{C(!0);try{(await fetch(`/api/admin/listings/${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({propertyType:t})})).ok?(r.default.success(`Changed type to ${t}`),s?.()):r.default.error("Failed to update property type")}catch(e){console.error("Error updating property type:",e),r.default.error("Failed to update property type")}finally{C(!1),k(!1),g(!1)}};return e.images?.map((e,t)=>({url:e,idx:t})).filter(({url:e})=>!(0,i.isVideoUrl)(e)&&!(0,i.isSplatUrl)(e)),(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{ref:U,className:"relative",children:[(0,t.jsx)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),g(!h)},className:"p-2 bg-background/80 hover:bg-surface text-foreground rounded-lg transition-colors border border-highlight/50",title:"Admin Menu",children:(0,t.jsx)("svg",{className:"w-4 h-4",fill:"currentColor",viewBox:"0 0 20 20",children:(0,t.jsx)("path",{d:"M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z"})})}),h&&(0,t.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-48 bg-surface rounded-xl border border-highlight/30 shadow-xl z-50 overflow-hidden",children:[(0,t.jsx)("div",{className:"px-3 py-2 bg-highlight/20 border-b border-highlight/30",children:(0,t.jsx)("span",{className:"text-xs font-semibold text-highlight",children:"ð§ Admin Menu"})}),(0,t.jsxs)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),m(!0),g(!1)},className:"w-full px-4 py-3 text-left text-foreground hover:bg-surface-elevated flex items-center gap-3 transition-colors",children:[(0,t.jsx)("svg",{className:"w-4 h-4 text-blue-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})}),(0,t.jsx)("span",{className:"text-sm",children:"Edit Listing"})]}),(0,t.jsxs)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),$()},disabled:v,className:"w-full px-4 py-3 text-left text-foreground hover:bg-surface-elevated flex items-center gap-3 transition-colors disabled:opacity-50",children:[(0,t.jsx)("span",{className:"text-lg",children:e.isFeatured?"â":"â"}),(0,t.jsx)("span",{className:"text-sm",children:v?"Updating...":e.isFeatured?"Remove Featured":"Mark as Featured"})]}),(0,t.jsxs)("div",{className:"border-t border-surface-elevated",children:[(0,t.jsxs)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),k(!w)},className:"w-full px-4 py-3 text-left text-foreground hover:bg-surface-elevated flex items-center justify-between transition-colors",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("svg",{className:"w-4 h-4 text-purple-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"})}),(0,t.jsx)("span",{className:"text-sm",children:"Change Type"}),(0,t.jsxs)("span",{className:"text-xs text-subtle",children:["(",e.propertyType||"None",")"]})]}),(0,t.jsx)("svg",{className:`w-4 h-4 text-subtle transition-transform ${w?"rotate-180":""}`,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})})]}),w&&(0,t.jsx)("div",{className:"bg-background/50 px-2 pb-2",children:(0,t.jsx)("div",{className:"grid grid-cols-2 gap-1",children:["Land","Home","Condo","Commercial","Resort","Multi-Family","Island","Other"].map(l=>(0,t.jsx)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),E(l)},disabled:S||e.propertyType===l,className:`px-2 py-1.5 text-xs rounded-lg transition-colors disabled:opacity-50 ${e.propertyType===l?"bg-purple-500/30 text-purple-300 border border-purple-500/50":"bg-surface-elevated text-muted hover:bg-surface-elevated"}`,children:l},l))})})]}),e.images&&e.images.length>0&&(0,t.jsxs)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),F(!0),g(!1)},className:"w-full px-4 py-3 text-left text-foreground hover:bg-surface-elevated flex items-center gap-3 transition-colors border-t border-surface-elevated",children:[(0,t.jsx)("span",{className:"text-lg",children:"ð¬"}),(0,t.jsx)("span",{className:"text-sm",children:"Video Manager"})]}),!1,(0,t.jsxs)("div",{className:"border-t border-surface-elevated",children:["Sold"!==e.listingStatus&&(0,t.jsxs)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),z("Sold")},disabled:y,className:"w-full px-4 py-3 text-left text-highlight hover:bg-highlight/20 flex items-center gap-3 transition-colors disabled:opacity-50",children:[(0,t.jsx)("span",{className:"text-lg",children:"ð°"}),(0,t.jsx)("span",{className:"text-sm",children:y?"Updating...":"Mark as Sold"})]}),"Off Market"!==e.listingStatus&&(0,t.jsxs)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),z("Off Market")},disabled:y,className:"w-full px-4 py-3 text-left text-orange-400 hover:bg-orange-500/20 flex items-center gap-3 transition-colors disabled:opacity-50",children:[(0,t.jsx)("span",{className:"text-lg",children:"ð«"}),(0,t.jsx)("span",{className:"text-sm",children:y?"Updating...":"Mark as Off Market"})]}),("Sold"===e.listingStatus||"Off Market"===e.listingStatus)&&(0,t.jsxs)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),z("For Sale")},disabled:y,className:"w-full px-4 py-3 text-left text-accent hover:bg-accent/20 flex items-center gap-3 transition-colors disabled:opacity-50",children:[(0,t.jsx)("span",{className:"text-lg",children:"ð "}),(0,t.jsx)("span",{className:"text-sm",children:y?"Updating...":"Mark as For Sale"})]})]}),(0,t.jsxs)("button",{onClick:e=>{e.preventDefault(),e.stopPropagation(),b(!0),g(!1)},className:"w-full px-4 py-3 text-left text-red-400 hover:bg-red-500/20 flex items-center gap-3 transition-colors border-t border-surface-elevated",children:[(0,t.jsx)("svg",{className:"w-4 h-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),(0,t.jsx)("span",{className:"text-sm",children:"Delete + Images"})]})]})]}),p&&(0,t.jsx)(u,{listing:e,onClose:()=>m(!1),onSave:()=>{m(!1),s?.()}}),f&&(0,t.jsx)(x,{listing:e,onClose:()=>b(!1),onDelete:()=>{b(!1),n?.()}}),L&&(0,t.jsx)(d,{listing:e,onClose:()=>F(!1),onUpdate:()=>s?.()}),M&&(0,t.jsx)(c,{listing:e,onClose:()=>T(!1),onUpdate:()=>s?.()})]})}function d({listing:e,onClose:a,onUpdate:o}){let[n,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(new Set),[x,h]=(0,l.useState)("slow zoom in"),[g,p]=(0,l.useState)(""),[m,f]=(0,l.useState)(!1),[b,v]=(0,l.useState)(null),[j,y]=(0,l.useState)({done:0,total:0});(0,l.useEffect)(()=>(d(!0),document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]);let[N,w]=(0,l.useState)(null),k=e.images||[],S=k.filter(e=>!(0,i.isSplatUrl)(e)),C=k.filter(e=>(0,i.isSplatUrl)(e)),L=S.filter(e=>!(0,i.isVideoUrl)(e)),F=S.filter(e=>(0,i.isVideoUrl)(e)),M=S[0]||null,T=async t=>{w(t);try{let l=S.filter(e=>e!==t),s=[...C,t,...l];(await fetch(`/api/admin/listings/${e.id}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({images:s})})).ok?(r.default.success("Cover updated"),o()):r.default.error("Failed to set cover")}catch{r.default.error("Failed to set cover")}finally{w(null)}}
1,U=[{label:"Grok Imagine (Best)",value:"grok",desc:"Image-to-video, highest quality"},{label:"Wan 2.2 I2V Fast ($0.05)",value:"wan-i2v",desc:"Image-to-video, cheap & good"},{label:"Wan 2.2 T2V Fast ($0.03)",value:"wan-t2v",desc:"Text-only, ultra cheap, no image"}],[D,$]=(0,l.useState)("grok"),z=async()=>{let t=Array.from(c);if(0===t.length)return;f(!0),y({done:0,total:t.length});let l=g?`${x}, ${g}`:x,s=0,a=(await Promise.allSettled(t.map(async(a,i)=>{let o=await fetch(`/api/admin/listings/${e.id}/generate-video`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageUrl:a,prompt:l,model:D})});if(y({done:++s,total:t.length}),o.ok)r.default.success(`Video ${s}/${t.length} done`);else{let e=await o.json().catch(()=>({}));throw r.default.error(`Video ${i+1} failed: ${e.error||"Unknown error"}`),Error(e.error)}}))).filter(e=>"fulfilled"===e.status).length;r.default.success(`${a}/${t.length} videos generated`),y({done:t.length,total:t.length}),v(null),f(!1),u(new Set),o()},E=(0,t.jsx)("div",{className:"fixed inset-0 z-9999 flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm",onClick:e=>{e.target!==e.currentTarget||m||a()},children:(0,t.jsxs)("div",{className:"bg-surface rounded-2xl w-full max-w-3xl max-h-[90vh] overflow-hidden border border-purple-500/30 shadow-2xl flex flex-col",children:[(0,t.jsx)("div",{className:"bg-purple-600 px-6 py-4 shrink-0",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center text-2xl",children:"ð¬"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-bold text-foreground",children:"Video Manager"}),(0,t.jsxs)("p",{className:"text-foreground/80 text-sm",children:[F.length," video",1!==F.length?"s":""," generated"," ","·"," ",L.length," image",1!==L.length?"s":""," available"]})]})]}),(0,t.jsx)("button",{onClick:a,disabled:m,className:"p-2 text-foreground/80 hover:text-foreground rounded-lg hover:bg-white/10 transition-colors disabled:opacity-50",children:(0,t.jsx)("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[S.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"text-sm font-semibold text-purple-400 flex items-center gap-2 mb-3",children:["Set Cover Media",(0,t.jsx)("span",{className:"text-xs text-subtle font-normal",children:"â shown on listing cards & home page"})]}),(0,t.jsx)("div",{className:"grid grid-cols-4 sm:grid-cols-5 md:grid-cols-6 gap-2",children:S.map(e=>{let l=e===M,s=(0,i.isVideoUrl)(e);return(0,t.jsxs)("button",{onClick:()=>!l&&!N&&T(e),disabled:!!N||m,className:`relative aspect-square rounded-lg overflow-hidden border-2 transition-all ${l?"border-highlight ring-2 ring-highlight/30":"border-surface-elevated hover:border-purple-400 cursor-pointer"} disabled:cursor-default`,children:[s?(0,t.jsx)("video",{src:e,muted:!0,playsInline:!0,preload:"metadata",className:"w-full h-full object-cover"}):(0,t.jsx)("img",{src:e,alt:"",className:"w-full h-full object-cover"}),l&&(0,t.jsx)("div",{className:"absolute top-1 left-1 px-1.5 py-0.5 bg-highlight text-foreground text-[8px] font-bold rounded",children:"COVER"}),s&&(0,t.jsx)("div",{className:`absolute ${l?"top-1 right-1":"top-1 left-1"} px-1.5 py-0.5 bg-purple-500/80 text-foreground text-[8px] font-bold rounded`,children:"VIDEO"}),N===e&&(0,t.jsx)("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:(0,t.jsx)("div",{className:"w-5 h-5 border-2 border-highlight border-t-transparent rounded-full animate-spin"})})]},e)})})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-purple-400 mb-3",children:"AI Model"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:U.map(e=>(0,t.jsx)("button",{onClick:()=>$(e.value),disabled:m,className:`px-3 py-1.5 text-xs rounded-lg border transition-colors disabled:opacity-50 ${D===e.value?"bg-purple-500/20 border-purple-400 text-purple-300":"bg-surface-elevated border-surface-elevated text-muted hover:border-surface-elevated"}`,title:e.desc,children:e.label},e.value))}),(0,t.jsx)("p",{className:"text-[10px] text-subtle mt-1",children:U.find(e=>e.value===D)?.desc})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-purple-400 mb-3",children:"Camera Motion"}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2 mb-2",children:[{label:"Slow Zoom In",value:"slow zoom in"},{label:"Slow Zoom Out",value:"slow zoom out"},{label:"Gentle Push In",value:"gentle push in"},{label:"Subtle Dolly In",value:"subtle dolly in"},{label:"Slow Pull Back",value:"slow pull back"}].map(e=>(0,t.jsx)("button",{onClick:()=>h(e.value),disabled:m,className:`px-3 py-1.5 text-xs rounded-lg border transition-colors disabled:opacity-50 ${x===e.value?"bg-purple-500/20 border-purple-400 text-purple-300":"bg-surface-elevated border-surface-elevated text-muted hover:border-surface-elevated"}`,children:e.label},e.value))}),(0,t.jsx)("input",{type:"text",value:g,onChange:e=>p(e.target.value),disabled:m,placeholder:'Extra prompt text (e.g. "with ocean waves")',className:"w-full px-3 py-2 text-xs bg-surface-elevated border border-surface-elevated rounded-lg text-foreground placeholder-subtle focus:border-purple-400 focus:outline-none disabled:opacity-50"}),g&&(0,t.jsxs)("p",{className:"text-[10px] text-subtle mt-1",children:['Full prompt: "',x,", ",g,'"']})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-purple-400",children:"Select Images to Generate Videos"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:()=>u(new Set(L)),disabled:m,className:"px-3 py-1.5 text-xs text-muted bg-surface-elevated hover:bg-surface-elevated rounded-lg transition-colors disabled:opacity-50",children:"Select All"}),(0,t.jsx)("button",{onClick:()=>u(new Set),disabled:m,className:"px-3 py-1.5 text-xs text-muted bg-surface-elevated hover:bg-surface-elevated rounded-lg transition-colors disabled:opacity-50",children:"Deselect All"})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-4 sm:grid-cols-5 md:grid-cols-6 gap-2",children:L.map(e=>(0,t.jsxs)("button",{onClick:()=>!m&&void u(t=>{let l=new Set(t);return l.has(e)?l.delete(e):l.add(e),l}),disabled:m,className:`relative aspect-square rounded-lg overflow-hidden border-2 transition-all ${c.has(e)?"border-purple-400 ring-2 ring-purple-400/30":"border-surface-elevated hover:border-surface-elevated"} ${m&&b===e?"ring-2 ring-highlight/50 border-highlight":""} disabled:cursor-default`,children:[(0,t.jsx)("img",{src:e,alt:"",className:"w-full h-full object-cover"}),(0,t.jsx)("div",{className:`absolute top-1 right-1 w-5 h-5 rounded flex items-center justify-center ${c.has(e)?"bg-purple-500 text-foreground":"bg-black/50 border border-white/30"}`,children:c.has(e)&&(0,t.jsx)("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),m&&b===e&&(0,t.jsx)("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:(0,t.jsx)("div",{className:"w-6 h-6 border-2 border-highlight border-t-transparent roun
1ded-full animate-spin"})})]},e))})]}),m&&(0,t.jsxs)("div",{className:"bg-background/50 rounded-xl p-4 border border-purple-500/20",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsxs)("span",{className:"text-sm text-muted",children:["Generating video ",j.done+1," of ",j.total,"..."]}),(0,t.jsxs)("span",{className:"text-sm text-purple-400 font-mono",children:[j.done,"/",j.total]})]}),(0,t.jsx)("div",{className:"w-full bg-surface-elevated rounded-full h-2",children:(0,t.jsx)("div",{className:"bg-purple-500 h-2 rounded-full transition-all duration-500",style:{width:`${j.done/j.total*100}%`}})})]})]}),(0,t.jsxs)("div",{className:"shrink-0 border-t border-surface-elevated px-6 py-4 bg-surface flex items-center justify-between",children:[(0,t.jsx)("button",{onClick:a,disabled:m,className:"px-6 py-3 text-subtle hover:text-foreground transition-colors disabled:opacity-50",children:m?"Please wait...":"Close"}),(0,t.jsx)("button",{onClick:z,disabled:m||0===c.size,className:"px-8 py-3 bg-purple-600 text-foreground font-semibold rounded-xl hover:bg-purple-700 transition-all disabled:opacity-50 flex items-center gap-2",children:m?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Generating..."]}):(0,t.jsxs)(t.Fragment,{children:["ð¬ Generate ",c.size>0?`${c.size} Video${c.size>1?"s":""}`:"Selected"]})})]})]})});return n?(0,s.createPortal)(E,document.body):null}function c({listing:e,onClose:a,onUpdate:o}){let[n,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(new Set),[x,h]=(0,l.useState)(!1),[g,p]=(0,l.useState)(null),[m,f]=(0,l.useState)({done:0,total:0}),[b,v]=(0,l.useState)(!1);(0,l.useEffect)(()=>(d(!0),document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]);let j=e.images||[],y=j.filter(e=>!(0,i.isVideoUrl)(e)&&!(0,i.isSplatUrl)(e)),N=j.filter(e=>(0,i.isSplatUrl)(e)),w=async()=>{let t=Array.from(c);if(0!==t.length){h(!0),f({done:0,total:t.length});for(let l=0;l<t.length;l++){p(t[l]),f({done:l,total:t.length});try{let s=await fetch(`/api/admin/listings/${e.id}/generate-splat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageUrl:t[l]})});if(s.ok)r.default.success(`Splat ${l+1}/${t.length} generated`);else{let e=await s.json();r.default.error(`Splat ${l+1} failed: ${e.error||"Unknown error"}`)}}catch(e){console.error("Error generating splat:",e),r.default.error(`Splat ${l+1} failed`)}}f({done:t.length,total:t.length}),p(null),h(!1),u(new Set),o()}},k=async()=>{if(confirm(`Delete all ${N.length} 3D splat(s)? This removes them from blob storage.`)){v(!0);try{let t=await fetch(`/api/admin/listings/${e.id}/delete-splat`,{method:"DELETE"});if(t.ok)r.default.success("All splats deleted"),o();else{let e=await t.json();r.default.error(e.error||"Failed to delete splats")}}catch(e){console.error("Error deleting splats:",e),r.default.error("Failed to delete splats")}finally{v(!1)}}},S=(0,t.jsx)("div",{className:"fixed inset-0 z-9999 flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm",onClick:e=>{e.target!==e.currentTarget||x||a()},children:(0,t.jsxs)("div",{className:"bg-surface rounded-2xl w-full max-w-3xl max-h-[90vh] overflow-hidden border border-cyan-500/30 shadow-2xl flex flex-col",children:[(0,t.jsx)("div",{className:"bg-blue-600 px-6 py-4 shrink-0",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center text-2xl",children:"ð§"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-bold text-foreground",children:"3D Splat Manager"}),(0,t.jsxs)("p",{className:"text-foreground/80 text-sm",children:[N.length," splat",1!==N.length?"s":""," generated"," ","·"," ",y.length," image",1!==y.length?"s":""," available"]})]})]}),(0,t.jsx)("button",{onClick:a,disabled:x,className:"p-2 text-foreground/80 hover:text-foreground rounded-lg hover:bg-white/10 transition-colors disabled:opacity-50",children:(0,t.jsx)("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[N.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("h3",{className:"text-sm font-semibold text-cyan-400 flex items-center gap-2",children:["Existing 3D Splats (",N.length,")"]}),(0,t.jsx)("button",{onClick:k,disabled:b||x,className:"px-3 py-1.5 text-xs text-red-400 bg-red-500/10 hover:bg-red-500/20 rounded-lg border border-red-500/30 transition-colors disabled:opacity-50",children:b?"Deleting...":"Delete All Splats"})]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:N.map((e,l)=>(0,t.jsx)("div",{className:"w-16 h-16 bg-surface-elevated rounded-lg flex items-center justify-center border border-cyan-500/30",children:(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)("svg",{className:"w-5 h-5 text-cyan-400 mx-auto",fill:"currentColor",viewBox:"0 0 20 20",children:(0,t.jsx)("path",{d:"M10 2L2 7l8 5 8-5-8-5zM2 13l8 5 8-5M2 10l8 5 8-5"})}),(0,t.jsxs)("span",{className:"text-[8px] text-cyan-400 font-bold",children:["3D #",l+1]})]})},e))})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-cyan-400",children:"Select Images to Generate Splats"}),(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)("button",{onClick:()=>{u(new Set(y))},disabled:x,className:"px-3 py-1.5 text-xs text-muted bg-surface-elevated hover:bg-surface-elevated rounded-lg transition-colors disabled:opacity-50",children:"Select All"}),(0,t.jsx)("button",{onClick:()=>{u(new Set)},disabled:x,className:"px-3 py-1.5 text-xs text-muted bg-surface-elevated hover:bg-surface-elevated rounded-lg transition-colors disabled:opacity-50",children:"Deselect All"})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-4 sm:grid-cols-5 md:grid-cols-6 gap-2",children:y.map(e=>(0,t.jsxs)("button",{onClick:()=>!x&&void u(t=>{let l=new Set(t);return l.has(e)?l.delete(e):l.add(e),l}),disabled:x,className:`relative aspect-square rounded-lg overflow-hidden border-2 transition-all ${c.has(e)?"border-cyan-400 ring-2 ring-cyan-400/30":"border-surface-elevated hover:border-surface-elevated"} ${x&&g===e?"ring-2 ring-highlight/50 border-highlight":""} disabled:cursor-default`,children:[(0,t.jsx)("img",{src:e,alt:"",className:"w-full h-full object-cover"}),(0,t.jsx)("div",{className:`absolute top-1 right-1 w-5 h-5 rounded flex items-center justify-center ${c.has(e)?"bg-cyan-500 text-foreground":"bg-black/50 border border-white/30"}`,children:c.has(e)&&(0,t.jsx)("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})})}),x&&g===e&&(0,t.jsx)("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center",children:(0,t.jsx)("div",{className:"w-6 h-6 border-2 border-highlight border-t-transparent roun
1ded-full animate-spin"})})]},e))})]}),x&&(0,t.jsxs)("div",{className:"bg-background/50 rounded-xl p-4 border border-cyan-500/20",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,t.jsxs)("span",{className:"text-sm text-muted",children:["Generating splat ",m.done+1," of ",m.total,"..."]}),(0,t.jsxs)("span",{className:"text-sm text-cyan-400 font-mono",children:[m.done,"/",m.total]})]}),(0,t.jsx)("div",{className:"w-full bg-surface-elevated rounded-full h-2",children:(0,t.jsx)("div",{className:"bg-cyan-500 h-2 rounded-full transition-all duration-500",style:{width:`${m.done/m.total*100}%`}})})]})]}),(0,t.jsxs)("div",{className:"shrink-0 border-t border-surface-elevated px-6 py-4 bg-surface flex items-center justify-between",children:[(0,t.jsx)("button",{onClick:a,disabled:x,className:"px-6 py-3 text-subtle hover:text-foreground transition-colors disabled:opacity-50",children:x?"Please wait...":"Close"}),(0,t.jsx)("button",{onClick:w,disabled:x||0===c.size,className:"px-8 py-3 bg-blue-600 text-foreground font-semibold rounded-xl hover:bg-blue-700 transition-all disabled:opacity-50 flex items-center gap-2",children:x?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Generating..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("svg",{className:"w-5 h-5",fill:"currentColor",viewBox:"0 0 20 20",children:(0,t.jsx)("path",{d:"M10 2L2 7l8 5 8-5-8-5zM2 13l8 5 8-5M2 10l8 5 8-5"})}),"Generate ",c.size>0?`${c.size} Splat${c.size>1?"s":""}`:"Selected"]})})]})]})});return n?(0,s.createPortal)(S,document.body):null}function u({listing:e,onClose:a,onSave:o}){let[n,d]=(0,l.useState)(!1),[c,u]=(0,l.useState)(!1),[x,h]=(0,l.useState)(!0),[g,p]=(0,l.useState)(null),[m,f]=(0,l.useState)(null),[b,v]=(0,l.useState)(e.images||[]),[j,y]=(0,l.useState)({title:e.title||"",description:e.description||"",price:e.price?.toString()||"",currency:e.currency||"USD",bedrooms:e.bedrooms?.toString()||"",bathrooms:e.bathrooms?.toString()||"",area:e.area?.toString()||"",areaUnit:e.areaUnit||"SQ FT",lotSize:e.lotSize?.toString()||"",lotSizeUnit:e.lotSizeUnit||"acres",propertyType:e.propertyType||"",listingStatus:e.listingStatus||"For Sale",financingAvailable:e.financingAvailable||!1,priceReduced:e.priceReduced||!1,isFeatured:e.isFeatured||!1,city:e.city||"",region:e.region||"",location:e.location||"",latitude:e.latitude?.toString()||"",longitude:e.longitude?.toString()||"",url:e.url||""});(0,l.useEffect)(()=>{d(!0),document.body.style.overflow="hidden";let t=!1;return fetch(`/api/admin/listings/${e.id}`,{cache:"no-store"}).then(async e=>{if(!e.ok)throw Error((await e.json()).error||"Unable to load listing");return e.json()}).then(e=>{t||(v(e.images||[]),y({title:e.title||"",description:e.description||"",price:e.price?.toString()||"",currency:e.currency||"USD",bedrooms:e.bedrooms?.toString()||"",bathrooms:e.bathrooms?.toString()||"",area:e.area?.toString()||"",areaUnit:e.areaUnit||"SQ FT",lotSize:e.lotSize?.toString()||"",lotSizeUnit:e.lotSizeUnit||"acres",propertyType:e.propertyType||"",listingStatus:e.listingStatus||"For Sale",financingAvailable:e.financingAvailable||!1,priceReduced:e.priceReduced||!1,isFeatured:e.isFeatured||!1,city:e.city||"",region:e.region||"",location:e.location||"",latitude:e.latitude?.toString()||"",longitude:e.longitude?.toString()||"",url:e.url||""}))}).catch(e=>r.default.error(e instanceof Error?e.message:"Unable to load listing")).finally(()=>{t||h(!1)}),()=>{t=!0,document.body.style.overflow=""}},[e.id]);let N=async t=>{if(b[0]!==t){f(t);try{let l=await fetch(`/api/listings/${e.id}/cover`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageUrl:t})}),s=await l.json();if(!l.ok)throw Error(s.error||"Unable to set display image");v(s.images),r.default.success(s.selectedVideoReady?"Display image and matching video updated":"Display image updated; its matching video is now first in the queue")}catch(e){r.default.error(e instanceof Error?e.message:"Unable to set display image")}finally{f(null)}}},w=async()=>{u(!0);
1try{let t={title:j.title,description:j.description||null,price:j.price?parseFloat(j.price):null,currency:j.currency,bedrooms:j.bedrooms?parseInt(j.bedrooms):null,bathrooms:j.bathrooms?parseFloat(j.bathrooms):null,area:j.area?parseFloat(j.area):null,areaUnit:j.areaUnit||null,lotSize:j.lotSize?parseFloat(j.lotSize):null,lotSizeUnit:j.lotSizeUnit||null,propertyType:j.propertyType||null,listingStatus:j.listingStatus||null,financingAvailable:j.financingAvailable,priceReduced:j.priceReduced,isFeatured:j.isFeatured,city:j.city||null,region:j.region||null,location:j.location||null,latitude:j.latitude?parseFloat(j.latitude):null,longitude:j.longitude?parseFloat(j.longitude):null,url:j.url||e.url||`https://placeholder.local/${e.id}`},l=await fetch(`/api/admin/listings/${e.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(l.ok){let e=await l.json();r.default.success(e.featuredNotification?.sent?"Listing updated â agent notified that it is featured":"Listing updated successfully"),o()}else{let e=await l.json();r.default.error(e.error||"Failed to update listing")}}catch(e){console.error("Error updating listing:",e),r.default.error("Failed to update listing")}finally{u(!1)}},k=async t=>{if(window.confirm("Delete this image? This cannot be undone.")){p(t);try{let l=await fetch(`/api/admin/listings/${e.id}/image`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({imageUrl:t})});if(l.ok)v(e=>e.filter(e=>e!==t)),r.default.success("Image deleted");else{let e=await l.json();r.default.error(e.error||"Failed to delete image")}}catch(e){console.error("Error deleting image:",e),r.default.error("Failed to delete image")}finally{p(null)}}},S=(0,t.jsx)("div",{className:"fixed inset-0 z-9999 flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm",onClick:e=>{e.target===e.currentTarget&&a()},children:(0,t.jsxs)("div",{className:"bg-surface rounded-2xl w-full max-w-4xl max-h-[90vh] overflow-hidden border border-highlight/30 shadow-2xl flex flex-col",children:[(0,t.jsx)("div",{className:"bg-highlight px-6 py-4 shrink-0",children:(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center",children:(0,t.jsx)("svg",{className:"w-6 h-6 text-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-bold text-foreground",children:"Edit Listing"}),(0,t.jsxs)("p",{className:"text-foreground/80 text-sm",children:["ID: ",e.id]})]})]}),(0,t.jsx)("button",{onClick:a,className:"p-2 text-foreground/80 hover:text-foreground rounded-lg hover:bg-white/10 transition-colors",children:(0,t.jsx)("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto p-6 space-y-6",children:[x&&(0,t.jsxs)("div",{className:"flex items-center justify-center gap-3 rounded-xl border border-highlight/20 bg-background/40 p-8 text-sm text-muted",children:[(0,t.jsx)("div",{className:"h-5 w-5 animate-spin rounded-full border-2 border-highlight border-t-transparent"}),"Loading the complete listingâ¦"]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-highlight mb-3 flex items-center gap-2",children:"ð Basic Information"}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Title *"}),(0,t.jsx)("input",{type:"text",value:j.title,onChange:e=>y({...j,title:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Description"}),(0,t.jsx)("textarea",{value:j.description,onChange:e=>y({...j,description:e.target.value}),rows:4,className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight resize-none"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Exter
1nal URL"}),(0,t.jsx)("input",{type:"url",value:j.url,onChange:e=>y({...j,url:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight"})]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-highlight mb-3 flex items-center gap-2",children:"ð° Price & Status"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Price"}),(0,t.jsx)("input",{type:"number",value:j.price,onChange:e=>y({...j,price:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Currency"}),(0,t.jsxs)("select",{value:j.currency,onChange:e=>y({...j,currency:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight",children:[(0,t.jsx)("option",{value:"USD",children:"USD"}),(0,t.jsx)("option",{value:"BZD",children:"BZD"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Property Type"}),(0,t.jsxs)("select",{value:j.propertyType,onChange:e=>y({...j,propertyType:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight",children:[(0,t.jsx)("option",{value:"",children:"Select..."}),["Land","Home","Condo","Commercial","Resort","Farm","Island","Development","Other"].map(e=>(0,t.jsx)("option",{value:e,children:e},e))]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Listing Status"}),(0,t.jsx)("select",{value:j.listingStatus,onChange:e=>y({...j,listingStatus:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight",children:["For Sale","Pending","Sold","Off Market"].map(e=>(0,t.jsx)("option",{value:e,children:e},e))})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap gap-4 mt-4",children:[(0,t.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:j.financingAvailable,onChange:e=>y({...j,financingAvailable:e.target.checked}),className:"w-5 h-5 rounded bg-surface-elevated border-surface-elevated text-accent focus:ring-accent"}),(0,t.jsx)("span",{className:"text-sm text-muted",children:"ðµ Financing Available"})]}),(0,t.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:j.priceReduced,onChange:e=>y({...j,priceReduced:e.target.checked}),className:"w-5 h-5 rounded bg-surface-elevated border-surface-elevated text-orange-500 focus:ring-orange-500"}),(0,t.jsx)("span",{className:"text-sm text-muted",children:"ð·ï¸ Price Reduced"})]}),(0,t.jsxs)("label",{className:"flex items-center gap-2 cursor-pointer",children:[(0,t.jsx)("input",{type:"checkbox",checked:j.isFeatured,onChange:e=>y({...j,isFeatured:e.target.checked}),className:"w-5 h-5 rounded bg-surface-elevated border-surface-elevated text-highlight focus:ring-highlight"}),(0,t.jsx)("span",{className:"text-sm text-muted",children:"â Featured"})]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-highlight mb-3 flex items-center gap-2",children:"ð Property Details"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Bedrooms"}),(0,t.jsx)("input",{type:"number",value:j.bedrooms,onChange:e=>y({...j,bedrooms:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Bathrooms"}),(0,t.jsx)("input",{type:"number",step:"0.5",value:j.bathrooms,onChange:e=>y({...j,bathrooms:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Area"}),(0,t.jsx)("input",{type:"number",value:j.area,onChange:e=>y({...j,area:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Area Unit"}),(0,t.jsxs)("select",{value:j.areaUnit,onChange:e=>y({...j,areaUnit:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight",children:[(0,t.jsx)("option",{value:"SQ FT",children:"SQ FT"}),(0,t.jsx)("option",{value:"acres",children:"Acres"}),(0,t.jsx)("option",{value:"sq m",children:"Sq M"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Lot Size"}),(0,t.jsx)("input",{type:"number",step:"0.01",value:j.lotSize,onChange:e=>y({...j,lotSize:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Lot Size Unit"}),(0,t.jsxs)("select",{value:j.lotSizeUnit,onChange:e=>y({...j,lotSizeUnit:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight",children:[(0,t.jsx)("option",{value:"acres",children:"Acres"}),(0,t.jsx)("option",{value:"SQ FT",children:"SQ FT"}),(0,t.jsx)("option",{value:"sq m",children:"Sq M"})]})]})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-highlight mb-3 flex items-center gap-2",children:"ð Location"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"City"}),(0,t.jsx)("input",{type:"text",value:j.city,onChange:e=>y({...j,city:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Region"}),(0,t.jsxs)("select",{value:j.region,onChange:e=>y({...j,region:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight",children:[(0,t.jsx)("option",{value:"",children:"Select..."}),["Belize District","Cayo District","Corozal District","Orange Walk District","Stann Creek District","Toledo District"].map(e=>(0,t.jsx)("option",{value:e,children:e},e))]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Location/Address"}),(0,t.jsx)("input",{type:"text",value:j.location,onChange:e=>y({...j,location:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Latitude"}),(0,t.jsx)("input",{type:"number",step:"0.000001",value:j.latitude,onChange:e=>y({...j,latitude:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-sm text-muted mb-1",children:"Longitude"}),(0,t.jsx)("input",{type:"number",step:"0.000001",value:j.longitude,onChange:e=>y({...j,longitude:e.target.value}),className:"w-full px-4 py-3 bg-surface-elevated border border-surface-elevated rounded-xl text-foreground focus:outline-none focus:border-highlight"})]})]})]}),b.length>0&&(0,t.jsxs)("div",{children:[(0,t.jsxs)("h3",{className:"text-sm font-semibold text-highlight mb-3 flex items-center gap-2",children:["ð· Images (",b.length,")"]}),(0,t.jsx)("div",{className:"flex flex-wrap gap-2",children:b.map((e,l)=>(0,t.jsxs)("div",{className:"relative group w-28",children:[(0,t.jsx)("div",{className:`h-24 w-full bg-surface-elevated rounded-lg overflow-hidden ${(0,i.isVideoUrl)(e)?"ring-2 ring-purple-500/70":""}`,children:(0,i.isVideoUrl)(e)?(0,t.jsx)("video",{src:e,muted:!0,playsInl
1ine:!0,preload:"metadata",className:"w-full h-full object-cover"}):(0,t.jsx)("img",{src:e,alt:`Image ${l+1}`,className:"w-full h-full object-cover"})}),(0,i.isVideoUrl)(e)&&(0,t.jsx)("div",{className:"absolute bottom-0.5 left-0.5 bg-purple-600/90 text-foreground text-[8px] font-bold px-1 py-0.5 rounded leading-none pointer-events-none",children:"â¶ VID"}),!(0,i.isVideoUrl)(e)&&!(0,i.isSplatUrl)(e)&&(0,t.jsx)("button",{type:"button",onClick:()=>N(e),disabled:0===l||null!==m,className:`mt-1 w-full rounded-md px-1.5 py-1 text-[10px] font-semibold transition-colors ${0===l?"bg-accent text-accent-fg":"bg-surface-elevated text-muted hover:bg-highlight/20 hover:text-highlight"} disabled:cursor-default disabled:opacity-70`,children:m===e?"Settingâ¦":0===l?"â Display image":"Set as display"}),(0,t.jsx)("button",{onClick:()=>k(e),disabled:g===e,className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-red-500 hover:bg-red-600 text-foreground rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity shadow-lg disabled:opacity-50",title:"Delete image",children:g===e?(0,t.jsx)("div",{className:"w-3 h-3 border border-white border-t-transparent rounded-full animate-spin"}):(0,t.jsx)("svg",{className:"w-3 h-3",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:3,children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})})})]},e))})]})]}),(0,t.jsxs)("div",{className:"shrink-0 border-t border-surface-elevated px-6 py-4 bg-surface flex items-center justify-between",children:[(0,t.jsx)("button",{onClick:a,className:"px-6 py-3 text-subtle hover:text-foreground transition-colors",children:"Cancel"}),(0,t.jsx)("button",{onClick:w,disabled:c||x||!j.title.trim(),className:"px-8 py-3 bg-highlight text-foreground font-semibold rounded-xl hover:bg-highlight-hover transition-all disabled:opacity-50 flex items-center gap-2",children:c?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-white border-t-transparent rounded-full animate-spin"}),"Saving..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})}),"Save Changes"]})})]})]})});return n?(0,s.createPortal)(S,document.body):null}function x({listing:e,onClose:a,onDelete:i}){let[o,n]=(0,l.useState)(!1),[d,c]=(0,l.useState)(!1);(0,l.useEffect)(()=>(n(!0),document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]);let u=async()=>{c(!0);try{let t=await fetch(`/api/admin/listings/${e.id}`,{method:"DELETE"});if(t.ok){let e=await t.json();r.default.success(`Deleted listing and ${e.imagesDeleted||0} images`),i()}else{let e=await t.json();r.default.error(e.error||"Failed to delete listing")}}catch(e){console.error("Error deleting listing:",e),r.default.error("Failed to delete listing")}finally{c(!1)}},x=(0,t.jsx)("div",{className:"fixed inset-0 z-9999 flex items-center justify-center p-4 bg-black/70 backdrop-blur-sm",onClick:e=>{e.target===e.currentTarget&&a()},children:(0,t.jsxs)("div",{className:"bg-surface rounded-2xl w-full max-w-md border border-red-500/30 shadow-2xl overflow-hidden",children:[(0,t.jsx)("div",{className:"bg-red-600 px-6 py-4",children:(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"w-10 h-10 bg-white/20 rounded-xl flex items-center justify-center",children:(0,t.jsx)("svg",{className:"w-6 h-6 text-foreground",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}),(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-lg font-bold text-foreground",children:"Delete Listing"}),(0,t.jsx)("p",{className:"text-foreground/80 text-sm",children:"This action cannot be undone"})]})]})}),(0,t.jsxs)("div",{className:"p-6 space-y-4",children:[(0,t.jsx)("p",{className:"text-muted",children:"Are you sure you want to delete this listing? This will:"}),(0,t.jsxs)("ul",{className:"space-y-2 text-sm",children:[(0,t.jsxs)("li",{className:"flex items-center gap-2 text-subtle",children:[(0,t.jsx)("svg",{className:"w-4 h-4 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Remove the listing from the database"]}),(0,t.jsxs)("li",{className:"flex items-center gap-2 text-subtle",children:[(0,t.jsx)("svg",{className:"w-4 h-4 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Delete all ",e.images?.length||0," images from blob storage"]}),(0,t.jsxs)("li",{className:"flex items-center gap-2 text-subtle",children:[(0,t.jsx)("svg",{className:"w-4 h-4 text-red-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})}),"Remove from all user favorites and collections"]})]}),(0,t.jsxs)("div",{className:"bg-surface-elevated/50 rounded-xl p-3",children:[(0,t.jsx)("p",{className:"text-foreground font-medium text-sm line-clamp-2",children:e.title}),(0,t.jsxs)("p",{className:"text-subtle text-xs mt-1",children:["ID: ",e.id]})]})]}),(0,t.jsxs)("div",{className:"border-t border-surface-elevated px-6 py-4 flex items-center justify-end gap-3",children:[(0,t.jsx)("button",{onClick:a,className:"px-6 py-3 text-subtle hover:text-foreground transition-colors",children:"Cancel"}),(0,t.jsx)("button",{onClick:u,disabled:d,className:"px-8 py-3 bg-red-600 text-foreground font-semibold rounded-xl hover:bg-red-700 transition-all disabled:opacity-50 flex items-center gap-2",children:d?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-white border-t-transparent roun
1ded-full animate-spin"}),"Deleting..."]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("svg",{className:"w-5 h-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})}),"Delete Forever"]})})]})]})});return o?(0,s.createPortal)(x,document.body):null}e.s(["default",()=>n])}]);
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.