1import{a as l,j as e}from"./chunk-three-BTWAGdoL.js";import{u as me}from"./useLoungeData-BiBj8bds.js";import{u as ue}from"./use-upload-CSQWclIx.js";import{u as xe,a as pe,b}from"./chunk-query-NCR7N3-H.js";import{v as be,B as r,C as B,G as I,n as q,A as ge,E as je,o as R,p as M,q as G,r as Q,i as c,I as D,S as fe,j as we,k as ve,l as Ne,m as ye}from"./index-CmZofxmK.js";import{T as De}from"./textarea-CHmViPUw.js";import{S as Ce}from"./switch-Bl7c15gA.js";import{p as m,ai as C,n as Ae,aO as V,aG as z,ah as J,M as Fe,a$ as ke,b as Pe,a4 as Se,T as Le,a_ as Te}from"./chunk-icons-CmzO8GHu.js";import"./chunk-router-DABpbG10.js";import"./chunk-uppy-Ddo71Xia.js";import"./chunk-charts-D8AvoNRl.js";import"./chunk-utils-CL3reoUV.js";import"./chunk-maps-ByCLyVpA.js";import"./chunk-radix-CYYWsbOs.js";const K=["Entrance","Main Lounge","VIP Section","Bar Area","Outdoor Patio","Private Room","DJ Booth","Hookah Bar","Restrooms","Custom"],Y={title:"",description:"",imageUrl:"",areaLabel:"",customAreaLabel:"",isPublished:!0,sortOrder:0};function Ye(){const{loungeId:H}=me(),u=xe(),{toast:i}=be(),A=l.useRef(null),[W,d]=l.useState(!1),[x,F]=l.useState(null),[a,o]=l.useState(Y),[g,p]=l.useState(null),[k,j]=l.useState(null),[_,f]=l.useState(!1),[P,S]=l.useState(null),X=async t=>{try{const s=t.imageUrl.startsWith("http")?t.imageUrl:`${window.location.origin}${t.imageUrl}`;await navigator.clipboard.writeText(s),S(t.id),i({title:"Link copied!",description:"Photo link copied to clipboard. You can paste it in AR templates or anywhere else."}),setTimeout(()=>S(null),2e3)}catch{i({title:"Copy failed",description:"Could not copy the link. Try again.",variant:"destructive"})}},{uploadFile:L,isUploading:w,progress:T}=ue({onSuccess:t=>{o(s=>({...s,imageUrl:t.objectPath})),i({title:"Photo uploaded",description:"Your photo has been uploaded successfully."})},onError:t=>{i({title:"Upload failed",description:t.message,variant:"destructive"})}}),{data:h=[],isLoading:Z}=pe({queryKey:["/api/lounge/tours","gallery"],queryFn:async()=>{const t=await fetch("/api/lounge/tours?type=gallery",{credentials:"include"});if(!t.ok)throw new Error("Failed to fetch tours");return t.json()},enabled:!!H}),U=b({mutationFn:async t=>{const s=await fetch("/api/lounge/tours",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({...t,tourType:"gallery"})});if(!s.ok)throw new Error("Failed to create tour");return s.json()},onSuccess:()=>{u.invalidateQueries({queryKey:["/api/lounge/tours","gallery"]}),i({title:"Scene created",description:"Your new tour scene has been added."})},onError:()=>{i({title:"Error",description:"Failed to create tour scene.",variant:"destructive"})}}),v=b({mutationFn:async({id:t,...s})=>{const{customAreaLabel:Ue,...he}=s,$=await fetch(`/api/lounge/tours/${t}`,{method:"PATCH",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({...he,tourType:"gallery"})});if(!$.ok)throw new Error("Failed to update tour");return $.json()},onSuccess:()=>{u.invalidateQueries({queryKey:["/api/lounge/tours","gallery"]}),i({title:"Scene updated",description:"Tour scene has been updated."})},onError:()=>{i({title:"Error",description:"Failed to update tour scene.",variant:"destructive"})}}),E=b({mutationFn:async t=>{const s=await fetch(`/api/lounge/tours/${t}`,{method:"DELETE",credentials:"include"});if(!s.ok)throw new Error("Failed to delete tour");return s.json()},onSuccess:()=>{u.invalidateQueries({queryKey:["/api/lounge/tours","gallery"]}),i({title:"Photo deleted",description:"Gallery photo has been removed."})},onError:()=>{i({title:"Error",description:"Failed to delete tour scene.",variant:"destructive"})}}),N=l.useCallback(async t=>{if(!t.type.startsWith("image/")){i({title:"Invalid file",description:"Please select an image file.",variant:"destructive"});return}const s=URL.createObjectURL(t);j(s),await L(t)},[L,i]),ee=t=>{const s=t.target.files?.[0];s&&N(s),t.target.value=""},te=l.useCallback(t=>{t.preventDefault(),f(!1);const s=t.dataTransfer.files[0];s&&N(s)},[N]),se=t=>{t.preventDefault(),f(!0)},ae=t=>{t.preventDefault(),f(!1)},ie=()=>a.areaLabel==="Custom"?a.customAreaLabel.trim():a.areaLabel,O=()=>{F(null),o({...Y,sortOrder:h.length}),j(null),d(!0)},re=t=>{F(t);const s=K.includes(t.areaLabel||"");
1o({title:t.title,description:t.description||"",imageUrl:t.imageUrl,areaLabel:s?t.areaLabel||"":t.areaLabel?"Custom":"",customAreaLabel:s?"":t.areaLabel||"",isPublished:t.isPublished,sortOrder:t.sortOrder}),j(t.imageUrl),d(!0)},le=()=>{if(!a.title.trim()||!a.imageUrl.trim())return;const t=ie(),s={title:a.title.trim(),description:a.description.trim(),imageUrl:a.imageUrl.trim(),areaLabel:t,isPublished:a.isPublished,sortOrder:a.sortOrder};x?v.mutate({id:x.id,...s},{onSuccess:()=>d(!1)}):U.mutate(s,{onSuccess:()=>d(!1)})},oe=t=>{E.mutate(t,{onSuccess:()=>p(null)})},ne=t=>{v.mutate({id:t.id,isPublished:!t.isPublished})},y=b({mutationFn:async()=>{const t=await fetch("/api/lounge/tours/publish-all",{method:"POST",credentials:"include"});if(!t.ok)throw new Error("Failed to publish tours");return t.json()},onSuccess:t=>{u.invalidateQueries({queryKey:["/api/lounge/tours","gallery"]}),i({title:"All photos published",description:`${t.count} photo(s) are now visible to customers.`})},onError:()=>{i({title:"Error",description:"Failed to publish tours.",variant:"destructive"})}}),n=U.isPending||v.isPending||E.isPending,de=h.some(t=>!t.isPublished),ce=[...h].sort((t,s)=>t.sortOrder-s.sortOrder);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-display font-bold text-white mb-2","data-testid":"text-gallery-title",children:"Gallery"}),e.jsx("p",{className:"text-white/60",children:"Upload photos to showcase your lounge"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[de&&h.length>0&&e.jsxs(r,{onClick:()=>y.mutate(),variant:"outline",className:"border-green-500/30 text-green-400 hover:bg-green-500/10",disabled:y.isPending,"data-testid":"button-publish-all",children:[y.isPending?e.jsx(m,{className:"w-4 h-4 mr-2 animate-spin"}):e.jsx(C,{className:"w-4 h-4 mr-2"}),"Publish All"]}),e.jsxs(r,{onClick:O,className:"bg-gradient-to-r from-[#D4AF37] to-[#B8860B] text-black font-semibold hover:from-[#B8860B] hover:to-[#D4AF37]","data-testid":"button-add-tour",children:[e.jsx(Ae,{className:"w-4 h-4 mr-2"}),"Add Scene"]})]})]}),Z?e.jsx("div",{className:"flex items-center justify-center py-16",children:e.jsx(m,{className:"w-8 h-8 animate-spin text-[#D4AF37]"})}):h.length===0?e.jsx(B,{className:"bg-gradient-to-br from-black/60 to-black/40 border-[#D4AF37]/10","data-testid":"card-empty-state",children:e.jsxs(I,{className:"py-16 text-center",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-[#D4AF37]/10 flex items-center justify-center mx-auto mb-6",children:e.jsx(V,{className:"w-10 h-10 text-[#D4AF37]"})}),e.jsx("h3",{className:"text-2xl font-semibold text-white mb-3","data-testid":"text-empty-title",children:"Create Your Gallery"}),e.jsx("p",{className:"text-white/50 mb-4 max-w-lg mx-auto","data-testid":"text-empty-description",children:"Upload photos of different areas of your lounge to showcase your space to customers."}),e.jsxs("div",{className:"bg-black/30 rounded-lg p-4 max-w-md mx-auto mb-8 border border-[#D4AF37]/10",children:[e.jsx("p",{className:"text-[#D4AF37] font-medium text-sm mb-2",children:"ð¸ Tips for great tour photos:"}),e.jsxs("ul",{className:"text-white/40 text-sm space-y-1 text-left",children:[e.jsx("li",{children:"⢠Take photos of your entrance, main area, VIP section, bar, and outdoor spaces"}),e.jsx("li",{children:"⢠Use wide-angle shots to capture the full atmosphere"}),e.jsx("li",{children:"⢠Photograph during your best lighting conditions"}),e.jsx("li",{children:"⢠Include unique features like hookah setups, DJ booth, or décor"})]})]}),e.jsxs(r,{onClick:O,className:"bg-gradient-to-r from-[#D4AF37] to-[#B8860B] text-black font-semibold hover:from-[#B8860B] hover:to-[#D4AF37]","data-testid":"button-empty-add-tour",children:[e.jsx(z,{className:"w-4 h-4 mr-2"}),"Upload Your First Photo"]})]})}):e.jsx("div",{className:"grid md:grid-cols-2 lg:grid-cols-3 gap-4",children:ce.map(t=>e.jsxs(B,{className:"bg-gradient-to-br from-black/60 to-black/40 border-[#D4AF37]/10 overflow-hidden group","data-testid":`card-tour-${t.id}`,children:[e.jsxs("div",{className:"relative h-48 bg-black/40",children:[t.imageUrl?e.jsx("img",{src:t.imageUrl,alt:t.title,className:"w-full h-full object-cover transition-transform duration-300 group-hover:scale-105","data-testid":`img-tour
1-${t.id}`}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(V,{className:"w-12 h-12 text-white/20"})}),e.jsx("div",{className:"absolute top-2 right-2 flex gap-1.5",children:e.jsx(q,{className:t.isPublished?"bg-green-500/20 text-green-400 border-green-500/30 backdrop-blur-sm":"bg-white/10 text-white/50 border-white/20 backdrop-blur-sm",variant:"outline","data-testid":`badge-status-${t.id}`,children:t.isPublished?e.jsxs(e.Fragment,{children:[e.jsx(C,{className:"w-3 h-3 mr-1"})," Published"]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-3 h-3 mr-1"})," Draft"]})})}),t.areaLabel&&e.jsx("div",{className:"absolute bottom-2 left-2",children:e.jsxs(q,{className:"bg-[#D4AF37]/20 text-[#D4AF37] border-[#D4AF37]/30 backdrop-blur-sm",variant:"outline","data-testid":`badge-area-${t.id}`,children:[e.jsx(Fe,{className:"w-3 h-3 mr-1"}),t.areaLabel]})})]}),e.jsx(ge,{className:"pb-2",children:e.jsx(je,{className:"text-lg text-white","data-testid":`text-tour-title-${t.id}`,children:t.title})}),e.jsxs(I,{className:"space-y-3",children:[t.description&&e.jsx("p",{className:"text-sm text-white/60 line-clamp-2","data-testid":`text-tour-desc-${t.id}`,children:t.description}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(r,{size:"sm",variant:"ghost",className:"text-white/50 hover:text-[#D4AF37] hover:bg-[#D4AF37]/10 h-8 w-8 p-0",onClick:()=>re(t),disabled:n,"data-testid":`button-edit-tour-${t.id}`,children:e.jsx(ke,{className:"w-4 h-4"})}),e.jsx(r,{size:"sm",variant:"ghost",className:`h-8 w-8 p-0 ${P===t.id?"text-green-400":"text-white/50 hover:text-cyan-400 hover:bg-cyan-500/10"}`,onClick:()=>X(t),"data-testid":`button-copy-link-${t.id}`,children:P===t.id?e.jsx(Pe,{className:"w-4 h-4"}):e.jsx(Se,{className:"w-4 h-4"})}),e.jsx(r,{size:"sm",variant:"ghost",className:"text-white/50 hover:text-white hover:bg-white/10 h-8 w-8 p-0",onClick:()=>ne(t),disabled:n,"data-testid":`button-toggle-published-${t.id}`,children:t.isPublished?e.jsx(J,{className:"w-4 h-4"}):e.jsx(C,{className:"w-4 h-4"})}),e.jsx(r,{size:"sm",variant:"ghost",className:"text-white/50 hover:text-red-400 hover:bg-red-500/10 h-8 w-8 p-0 ml-auto",onClick:()=>p(t.id),disabled:n,"data-testid":`button-delete-tour-${t.id}`,children:e.jsx(Le,{className:"w-4 h-4"})})]})]})]},t.id))}),e.jsx(R,{open:W,onOpenChange:d,children:e.jsxs(M,{className:"bg-[#1a1a1a] border-[#D4AF37]/30 text-white max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(G,{children:e.jsx(Q,{className:"text-xl font-bold text-white","data-testid":"text-tour-dialog-title",children:x?"Edit Tour Scene":"Add Tour Scene"})}),e.jsxs("div",{className:"space-y-4 mt-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-white/80",children:"Photo *"}),e.jsxs("div",{className:`relative border-2 border-dashed rounded-lg transition-colors cursor-pointer ${_?"border-[#D4AF37] bg-[#D4AF37]/10":a.imageUrl?"border-[#D4AF37]/30 bg-black/30":"border-white/20 bg-black/30 hover:border-[#D4AF37]/40"}`,onDrop:te,onDragOver:se,onDragLeave:ae,onClick:()=>!w&&A.current?.click(),"data-testid":"dropzone-photo",children:[e.jsx("input",{ref:A,type:"file",accept:"image/*",className:"hidden",onChange:ee,"data-testid":"input-photo-file"}),w?e.jsxs("div",{className:"flex flex-col items-center justify-center py-8",children:[e.jsx(m,{className:"w-8 h-8 animate-spin text-[#D4AF37] mb-2"}),e.jsxs("p",{className:"text-white/60 text-sm",children:["Uploading... ",T,"%"]}),e.jsx("div",{className:"w-48 h-1.5 bg-white/10 rounded-full mt-2 overflow-hidden",children:e.jsx("div",{className:"h-full bg-[#D4AF37] rounded-full transition-all duration-300",style:{width:`${T}%`}})})]}):k||a.imageUrl?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:k||a.imageUrl,alt:"Scene preview",className:"w-full h-40 object-cover rounded-lg","data-testid":"img-tour-preview"}),e.jsx("div",{className:"absolute inset-0 bg-black/40 opacity-0 hover:opacity-100 transition-opacity rounded-lg flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx(Te,{className:"w-6 h-6 text-white mx-auto mb-1"}),e.jsx("p",{className:"text-white text-sm font-medium",children:"Change Photo"})]})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-10",children:[e.jsx("div",{className:"w-14 h-14 roun
1ded-full bg-[#D4AF37]/10 flex items-center justify-center mb-3",children:e.jsx(z,{className:"w-7 h-7 text-[#D4AF37]"})}),e.jsx("p",{className:"text-white/70 text-sm font-medium mb-1",children:"Drop your photo here or click to browse"}),e.jsx("p",{className:"text-white/40 text-xs",children:"JPG, PNG, WebP up to 10MB"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-white/80",children:"Title *"}),e.jsx(D,{value:a.title,onChange:t=>o(s=>({...s,title:t.target.value})),placeholder:"e.g. Main Lounge Area",className:"bg-black/50 border-[#D4AF37]/30 text-white","data-testid":"input-tour-title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-white/80",children:"Area Label"}),e.jsxs(fe,{value:a.areaLabel,onValueChange:t=>o(s=>({...s,areaLabel:t,customAreaLabel:t==="Custom"?s.customAreaLabel:""})),children:[e.jsx(we,{className:"bg-black/50 border-[#D4AF37]/30 text-white","data-testid":"select-area-label",children:e.jsx(ve,{placeholder:"Select an area..."})}),e.jsx(Ne,{className:"bg-[#1a1a1a] border-[#D4AF37]/30",children:K.map(t=>e.jsx(ye,{value:t,className:"text-white hover:bg-[#D4AF37]/10","data-testid":`option-area-${t.toLowerCase().replace(/\s+/g,"-")}`,children:t},t))})]}),a.areaLabel==="Custom"&&e.jsx(D,{value:a.customAreaLabel,onChange:t=>o(s=>({...s,customAreaLabel:t.target.value})),placeholder:"Enter custom area label...",className:"bg-black/50 border-[#D4AF37]/30 text-white mt-2","data-testid":"input-custom-area-label"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-white/80",children:"Description"}),e.jsx(De,{value:a.description,onChange:t=>o(s=>({...s,description:t.target.value})),placeholder:"Describe this area of your lounge...",className:"bg-black/50 border-[#D4AF37]/30 text-white min-h-[80px]","data-testid":"input-tour-description"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-white/80",children:"Sort Order"}),e.jsx(D,{type:"number",min:"0",value:a.sortOrder,onChange:t=>o(s=>({...s,sortOrder:Number(t.target.value)||0})),className:"bg-black/50 border-[#D4AF37]/30 text-white","data-testid":"input-tour-sort-order"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(c,{className:"text-white/80",children:"Published"}),e.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[e.jsx(Ce,{checked:a.isPublished,onCheckedChange:t=>o(s=>({...s,isPublished:t})),"data-testid":"switch-tour-published"}),e.jsx("span",{className:"text-sm text-white/60",children:a.isPublished?"Visible to customers":"Draft"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx(r,{variant:"outline",onClick:()=>d(!1),className:"border-white/20 text-white/70","data-testid":"button-cancel-tour",children:"Cancel"}),e.jsx(r,{onClick:le,disabled:!a.title.trim()||!a.imageUrl.trim()||n||w,className:"bg-gradient-to-r from-[#D4AF37] to-[#B8860B] text-black font-semibold","data-testid":"button-save-tour",children:n?e.jsx(m,{className:"w-4 h-4 animate-spin"}):x?"Update":"Create"})]})]})]})}),e.jsx(R,{open:!!g,onOpenChange:()=>p(null),children:e.jsxs(M,{className:"bg-[#1a1a1a] border-red-500/30 text-white max-w-sm",children:[e.jsx(G,{children:e.jsx(Q,{className:"text-lg font-bold text-white","data-testid":"text-delete-dialog-title",children:"Delete Tour Scene"})}),e.jsx("p",{className:"text-white/60 text-sm","data-testid":"text-delete-confirmation",children:"Are you sure you want to delete this tour scene? This action cannot be undone."}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx(r,{variant:"outline",onClick:()=>p(null),className:"border-white/20 text-white/70","data-testid":"button-cancel-delete-tour",children:"Cancel"}),e.jsx(r,{onClick:()=>g&&oe(g),disabled:n,className:"bg-red-600 hover:bg-red-700 text-white","data-testid":"button-confirm-delete-tour",children:n?e.jsx(m,{className:"w-4 h-4 animate-spin"}):"Delete"})]})]})})]})}export{Ye as default};
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.